diff --git a/API/server.js b/API/server.js index 49205e1..48913ea 100644 --- a/API/server.js +++ b/API/server.js @@ -649,8 +649,11 @@ h1{font-size:1.25rem}a{color:#a78bfa} return res.status(404).json({ success: false, error: 'No connected Discord server found.' }); } - const deptKey = department || supportbot.Ticket?.DepartmentSystem?.DefaultDepartment || 'general'; - const deptConfig = supportbot.Ticket?.DepartmentSystem?.Departments?.[deptKey]; + const supportbot = configStore.supportbot; + const cmdconfig = configStore.commands; + + const deptKey = department || supportbot?.Ticket?.DepartmentSystem?.DefaultDepartment || 'general'; + const deptConfig = supportbot?.Ticket?.DepartmentSystem?.Departments?.[deptKey]; if (deptConfig && deptConfig.Enabled === false) { return res.status(400).json({ success: false, error: `Ticket department '${deptKey}' is currently disabled.` }); } @@ -661,19 +664,28 @@ h1{font-size:1.25rem}a{color:#a78bfa} targetUser = this.client.user; } - const openCmd = this.client.commands.get(cmdconfig.OpenTicket?.Command || "new"); + const openCmd = this.client.commands.get(cmdconfig?.OpenTicket?.Command || "new"); if (!openCmd) { return res.status(500).json({ success: false, error: 'Open ticket command not found in bot.' }); } const fakeInteraction = { + client: this.client, guild, user: targetUser, member: await guild.members.fetch(targetUser.id).catch(() => null), channel: guild.channels.cache.first(), department: deptKey, reason: subject || reason || "Opened via Web Dashboard", - priority: deptConfig?.DefaultPriority || supportbot.Ticket?.PrioritySystem?.DefaultPriority || "medium", + priority: deptConfig?.DefaultPriority || supportbot?.Ticket?.PrioritySystem?.DefaultPriority || "medium", + options: { + getString: (name) => { + if (name === "department") return deptKey; + if (name === "reason") return subject || reason || "Opened via Web Dashboard"; + if (name === "priority") return deptConfig?.DefaultPriority || supportbot?.Ticket?.PrioritySystem?.DefaultPriority || "medium"; + return null; + } + }, isCommand: () => false, isChatInputCommand: () => false, isButton: () => false, diff --git a/Structures/Database.js b/Structures/Database.js index 381f970..20576fa 100644 --- a/Structures/Database.js +++ b/Structures/Database.js @@ -355,6 +355,13 @@ function initMySQL() { } } catch (err) { console.error("[Database] Error initializing MySQL tables or state:", err.message); + console.warn("[Database] Falling back to SQLite database."); + mysqlReady = false; + if (mysqlPool) { + try { mysqlPool.end(); } catch (e) {} + mysqlPool = null; + } + initSQLite(); } })(); } @@ -449,7 +456,7 @@ function persistTicket(ticketId) { const t = state.tickets[ticketId]; if (!t) return; - if (isMySQL && mysqlPool) { + if (isMySQL && mysqlReady && mysqlPool) { const sql = ` INSERT INTO tickets ( ticket_id, user_id, subject, description, department, priority, status, @@ -526,7 +533,7 @@ function persistTicket(ticketId) { } function persistPanel(panelRow) { - if (isMySQL && mysqlPool) { + if (isMySQL && mysqlReady && mysqlPool) { mysqlPool.query( "INSERT INTO ticket_panels (id, message_id, channel_id, created_at) VALUES (?, ?, ?, ?)", [panelRow.id, panelRow.message_id, panelRow.channel_id, panelRow.created_at], @@ -542,7 +549,7 @@ function persistPanel(panelRow) { function persistTicketUser(ticketId, userId, action = "add") { if (action === "add") { - if (isMySQL && mysqlPool) { + if (isMySQL && mysqlReady && mysqlPool) { mysqlPool.query("INSERT IGNORE INTO ticket_users (ticket_id, user_id) VALUES (?, ?)", [ticketId, userId], (err) => { if (err) console.error("[Database] MySQL persistTicketUser error:", err.message); }); @@ -550,7 +557,7 @@ function persistTicketUser(ticketId, userId, action = "add") { sqliteDb.prepare("INSERT OR IGNORE INTO ticket_users (ticket_id, user_id) VALUES (?, ?)").run(ticketId, userId); } } else { - if (isMySQL && mysqlPool) { + if (isMySQL && mysqlReady && mysqlPool) { mysqlPool.query("DELETE FROM ticket_users WHERE ticket_id = ? AND user_id = ?", [ticketId, userId], (err) => { if (err) console.error("[Database] MySQL deleteTicketUser error:", err.message); }); @@ -564,7 +571,7 @@ function persistProfile(userId) { const p = state.profiles[userId]; if (!p) return; - if (isMySQL && mysqlPool) { + if (isMySQL && mysqlReady && mysqlPool) { const sql = ` INSERT INTO profiles (user_id, bio, timezone, clocked_in) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE bio=VALUES(bio), timezone=VALUES(timezone), clocked_in=VALUES(clocked_in); @@ -600,13 +607,13 @@ function persistSettings() { } function persistBlacklistedUser(userId, action = "add") { - if (isMySQL && !mysqlReady) { + if (isMySQL && mysqlReady && !mysqlPool) { mysqlWriteQueue.push(() => persistBlacklistedUser(userId, action)); return; } const b = state.blacklisted_users[userId]; if (action === "add" && b) { - if (isMySQL && mysqlPool) { + if (isMySQL && mysqlReady && mysqlPool) { const sql = ` INSERT INTO blacklisted_users (user_id, reason, added_by, created_at) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE reason=VALUES(reason), added_by=VALUES(added_by), created_at=VALUES(created_at); @@ -622,7 +629,7 @@ function persistBlacklistedUser(userId, action = "add") { stmt.run(b.user_id, b.reason || "", b.added_by || "", b.created_at || Date.now()); } } else { - if (isMySQL && mysqlPool) { + if (isMySQL && mysqlReady && mysqlPool) { mysqlPool.query("DELETE FROM blacklisted_users WHERE user_id = ?", [userId], (err) => { if (err) console.error("[Database] MySQL removeBlacklistedUser error:", err.message); }); diff --git a/public/dashboard/assets/index-xYh1zX07.js b/public/dashboard/assets/index-CzmlDpil.js similarity index 52% rename from public/dashboard/assets/index-xYh1zX07.js rename to public/dashboard/assets/index-CzmlDpil.js index 88ecbca..69799bc 100644 --- a/public/dashboard/assets/index-xYh1zX07.js +++ b/public/dashboard/assets/index-CzmlDpil.js @@ -1,4 +1,4 @@ -var w3=Object.defineProperty;var xy=t=>{throw TypeError(t)};var j3=(t,n,a)=>n in t?w3(t,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[n]=a;var vy=(t,n,a)=>j3(t,typeof n!="symbol"?n+"":n,a),by=(t,n,a)=>n.has(t)||xy("Cannot "+a);var pn=(t,n,a)=>(by(t,n,"read from private field"),a?a.call(t):n.get(t)),yy=(t,n,a)=>n.has(t)?xy("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(t):n.set(t,a),dp=(t,n,a,o)=>(by(t,n,"write to private field"),o?o.call(t,a):n.set(t,a),a);function C3(t,n){for(var a=0;ao[c]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const l of c)if(l.type==="childList")for(const d of l.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function a(c){const l={};return c.integrity&&(l.integrity=c.integrity),c.referrerPolicy&&(l.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?l.credentials="include":c.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(c){if(c.ep)return;c.ep=!0;const l=a(c);fetch(c.href,l)}})();function s2(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var fp={exports:{}},Sl={};/** +var w3=Object.defineProperty;var xy=t=>{throw TypeError(t)};var j3=(t,n,a)=>n in t?w3(t,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[n]=a;var by=(t,n,a)=>j3(t,typeof n!="symbol"?n+"":n,a),vy=(t,n,a)=>n.has(t)||xy("Cannot "+a);var pn=(t,n,a)=>(vy(t,n,"read from private field"),a?a.call(t):n.get(t)),yy=(t,n,a)=>n.has(t)?xy("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(t):n.set(t,a),dp=(t,n,a,o)=>(vy(t,n,"write to private field"),o?o.call(t,a):n.set(t,a),a);function C3(t,n){for(var a=0;ao[c]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const l of c)if(l.type==="childList")for(const d of l.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function a(c){const l={};return c.integrity&&(l.integrity=c.integrity),c.referrerPolicy&&(l.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?l.credentials="include":c.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(c){if(c.ep)return;c.ep=!0;const l=a(c);fetch(c.href,l)}})();function s2(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var fp={exports:{}},Sl={};/** * @license React * react-jsx-runtime.production.js * @@ -6,7 +6,7 @@ var w3=Object.defineProperty;var xy=t=>{throw TypeError(t)};var j3=(t,n,a)=>n in * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var wy;function S3(){if(wy)return Sl;wy=1;var t=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function a(o,c,l){var d=null;if(l!==void 0&&(d=""+l),c.key!==void 0&&(d=""+c.key),"key"in c){l={};for(var m in c)m!=="key"&&(l[m]=c[m])}else l=c;return c=l.ref,{$$typeof:t,type:o,key:d,ref:c!==void 0?c:null,props:l}}return Sl.Fragment=n,Sl.jsx=a,Sl.jsxs=a,Sl}var jy;function N3(){return jy||(jy=1,fp.exports=S3()),fp.exports}var s=N3(),mp={exports:{}},Pe={};/** + */var wy;function S3(){if(wy)return Sl;wy=1;var t=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function a(o,c,l){var d=null;if(l!==void 0&&(d=""+l),c.key!==void 0&&(d=""+c.key),"key"in c){l={};for(var m in c)m!=="key"&&(l[m]=c[m])}else l=c;return c=l.ref,{$$typeof:t,type:o,key:d,ref:c!==void 0?c:null,props:l}}return Sl.Fragment=n,Sl.jsx=a,Sl.jsxs=a,Sl}var jy;function N3(){return jy||(jy=1,fp.exports=S3()),fp.exports}var s=N3(),mp={exports:{}},ze={};/** * @license React * react.production.js * @@ -14,7 +14,7 @@ var w3=Object.defineProperty;var xy=t=>{throw TypeError(t)};var j3=(t,n,a)=>n in * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Cy;function E3(){if(Cy)return Pe;Cy=1;var t=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),d=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),w=Symbol.iterator;function y(O){return O===null||typeof O!="object"?null:(O=w&&O[w]||O["@@iterator"],typeof O=="function"?O:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,E={};function k(O,D,$){this.props=O,this.context=D,this.refs=E,this.updater=$||C}k.prototype.isReactComponent={},k.prototype.setState=function(O,D){if(typeof O!="object"&&typeof O!="function"&&O!=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,D,"setState")},k.prototype.forceUpdate=function(O){this.updater.enqueueForceUpdate(this,O,"forceUpdate")};function N(){}N.prototype=k.prototype;function T(O,D,$){this.props=O,this.context=D,this.refs=E,this.updater=$||C}var M=T.prototype=new N;M.constructor=T,S(M,k.prototype),M.isPureReactComponent=!0;var _=Array.isArray;function R(){}var L={H:null,A:null,T:null,S:null},te=Object.prototype.hasOwnProperty;function K(O,D,$){var H=$.ref;return{$$typeof:t,type:O,key:D,ref:H!==void 0?H:null,props:$}}function I(O,D){return K(O.type,D,O.props)}function G(O){return typeof O=="object"&&O!==null&&O.$$typeof===t}function Y(O){var D={"=":"=0",":":"=2"};return"$"+O.replace(/[=:]/g,function($){return D[$]})}var ce=/\/+/g;function fe(O,D){return typeof O=="object"&&O!==null&&O.key!=null?Y(""+O.key):D.toString(36)}function se(O){switch(O.status){case"fulfilled":return O.value;case"rejected":throw O.reason;default:switch(typeof O.status=="string"?O.then(R,R):(O.status="pending",O.then(function(D){O.status==="pending"&&(O.status="fulfilled",O.value=D)},function(D){O.status==="pending"&&(O.status="rejected",O.reason=D)})),O.status){case"fulfilled":return O.value;case"rejected":throw O.reason}}throw O}function P(O,D,$,H,X){var xe=typeof O;(xe==="undefined"||xe==="boolean")&&(O=null);var q=!1;if(O===null)q=!0;else switch(xe){case"bigint":case"string":case"number":q=!0;break;case"object":switch(O.$$typeof){case t:case n:q=!0;break;case v:return q=O._init,P(q(O._payload),D,$,H,X)}}if(q)return X=X(O),q=H===""?"."+fe(O,0):H,_(X)?($="",q!=null&&($=q.replace(ce,"$&/")+"/"),P(X,D,$,"",function(B){return B})):X!=null&&(G(X)&&(X=I(X,$+(X.key==null||O&&O.key===X.key?"":(""+X.key).replace(ce,"$&/")+"/")+q)),D.push(X)),1;q=0;var ge=H===""?".":H+":";if(_(O))for(var me=0;me{throw TypeError(t)};var j3=(t,n,a)=>n in * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Ny;function k3(){return Ny||(Ny=1,(function(t){function n(P,Z){var ae=P.length;P.push(Z);e:for(;0>>1,V=P[re];if(0>>1;rec($,ae))Hc(X,$)?(P[re]=X,P[H]=ae,re=H):(P[re]=$,P[D]=ae,re=D);else if(Hc(X,ae))P[re]=X,P[H]=ae,re=H;else break e}}return Z}function c(P,Z){var ae=P.sortIndex-Z.sortIndex;return ae!==0?ae:P.id-Z.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;t.unstable_now=function(){return l.now()}}else{var d=Date,m=d.now();t.unstable_now=function(){return d.now()-m}}var p=[],g=[],v=1,b=null,w=3,y=!1,C=!1,S=!1,E=!1,k=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;function M(P){for(var Z=a(g);Z!==null;){if(Z.callback===null)o(g);else if(Z.startTime<=P)o(g),Z.sortIndex=Z.expirationTime,n(p,Z);else break;Z=a(g)}}function _(P){if(S=!1,M(P),!C)if(a(p)!==null)C=!0,R||(R=!0,Y());else{var Z=a(g);Z!==null&&se(_,Z.startTime-P)}}var R=!1,L=-1,te=5,K=-1;function I(){return E?!0:!(t.unstable_now()-KP&&I());){var re=b.callback;if(typeof re=="function"){b.callback=null,w=b.priorityLevel;var V=re(b.expirationTime<=P);if(P=t.unstable_now(),typeof V=="function"){b.callback=V,M(P),Z=!0;break t}b===a(p)&&o(p),M(P)}else o(p);b=a(p)}if(b!==null)Z=!0;else{var O=a(g);O!==null&&se(_,O.startTime-P),Z=!1}}break e}finally{b=null,w=ae,y=!1}Z=void 0}}finally{Z?Y():R=!1}}}var Y;if(typeof T=="function")Y=function(){T(G)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,fe=ce.port2;ce.port1.onmessage=G,Y=function(){fe.postMessage(null)}}else Y=function(){k(G,0)};function se(P,Z){L=k(function(){P(t.unstable_now())},Z)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(P){P.callback=null},t.unstable_forceFrameRate=function(P){0>P||125re?(P.sortIndex=ae,n(g,P),a(p)===null&&P===a(g)&&(S?(N(L),L=-1):S=!0,se(_,ae-re))):(P.sortIndex=V,n(p,P),C||y||(C=!0,R||(R=!0,Y()))),P},t.unstable_shouldYield=I,t.unstable_wrapCallback=function(P){var Z=w;return function(){var ae=w;w=Z;try{return P.apply(this,arguments)}finally{w=ae}}}})(gp)),gp}var Ey;function T3(){return Ey||(Ey=1,hp.exports=k3()),hp.exports}var xp={exports:{}},hn={};/** + */var Ny;function k3(){return Ny||(Ny=1,(function(t){function n(P,W){var oe=P.length;P.push(W);e:for(;0>>1,G=P[ae];if(0>>1;aec(B,oe))Vc(Z,B)?(P[ae]=Z,P[V]=oe,ae=V):(P[ae]=B,P[D]=oe,ae=D);else if(Vc(Z,oe))P[ae]=Z,P[V]=oe,ae=V;else break e}}return W}function c(P,W){var oe=P.sortIndex-W.sortIndex;return oe!==0?oe:P.id-W.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;t.unstable_now=function(){return l.now()}}else{var d=Date,m=d.now();t.unstable_now=function(){return d.now()-m}}var p=[],g=[],b=1,v=null,w=3,y=!1,C=!1,S=!1,N=!1,E=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function k(P){for(var W=a(g);W!==null;){if(W.callback===null)o(g);else if(W.startTime<=P)o(g),W.sortIndex=W.expirationTime,n(p,W);else break;W=a(g)}}function _(P){if(S=!1,k(P),!C)if(a(p)!==null)C=!0,R||(R=!0,q());else{var W=a(g);W!==null&&se(_,W.startTime-P)}}var R=!1,L=-1,ne=5,X=-1;function I(){return N?!0:!(t.unstable_now()-XP&&I());){var ae=v.callback;if(typeof ae=="function"){v.callback=null,w=v.priorityLevel;var G=ae(v.expirationTime<=P);if(P=t.unstable_now(),typeof G=="function"){v.callback=G,k(P),W=!0;break t}v===a(p)&&o(p),k(P)}else o(p);v=a(p)}if(v!==null)W=!0;else{var O=a(g);O!==null&&se(_,O.startTime-P),W=!1}}break e}finally{v=null,w=oe,y=!1}W=void 0}}finally{W?q():R=!1}}}var q;if(typeof M=="function")q=function(){M(H)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,de=ce.port2;ce.port1.onmessage=H,q=function(){de.postMessage(null)}}else q=function(){E(H,0)};function se(P,W){L=E(function(){P(t.unstable_now())},W)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(P){P.callback=null},t.unstable_forceFrameRate=function(P){0>P||125ae?(P.sortIndex=oe,n(g,P),a(p)===null&&P===a(g)&&(S?(T(L),L=-1):S=!0,se(_,oe-ae))):(P.sortIndex=G,n(p,P),C||y||(C=!0,R||(R=!0,q()))),P},t.unstable_shouldYield=I,t.unstable_wrapCallback=function(P){var W=w;return function(){var oe=w;w=W;try{return P.apply(this,arguments)}finally{w=oe}}}})(gp)),gp}var Ey;function T3(){return Ey||(Ey=1,hp.exports=k3()),hp.exports}var xp={exports:{}},hn={};/** * @license React * react-dom.production.js * @@ -30,7 +30,7 @@ var w3=Object.defineProperty;var xy=t=>{throw TypeError(t)};var j3=(t,n,a)=>n in * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var ky;function M3(){if(ky)return hn;ky=1;var t=Xh();function n(p){var g="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(n){console.error(n)}}return t(),xp.exports=M3(),xp.exports}/** + */var ky;function M3(){if(ky)return hn;ky=1;var t=Xh();function n(p){var g="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(n){console.error(n)}}return t(),xp.exports=M3(),xp.exports}/** * @license React * react-dom-client.production.js * @@ -38,15 +38,15 @@ var w3=Object.defineProperty;var xy=t=>{throw TypeError(t)};var j3=(t,n,a)=>n in * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var My;function R3(){if(My)return Nl;My=1;var t=T3(),n=Xh(),a=o2();function o(e){var r="https://react.dev/errors/"+e;if(1V||(e.current=re[V],re[V]=null,V--)}function $(e,r){V++,re[V]=e.current,e.current=r}var H=O(null),X=O(null),xe=O(null),q=O(null);function ge(e,r){switch($(xe,r),$(X,e),$(H,null),r.nodeType){case 9:case 11:e=(e=r.documentElement)&&(e=e.namespaceURI)?Bb(e):0;break;default:if(e=r.tagName,r=r.namespaceURI)r=Bb(r),e=$b(r,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}D(H),$(H,e)}function me(){D(H),D(X),D(xe)}function B(e){e.memoizedState!==null&&$(q,e);var r=H.current,i=$b(r,e.type);r!==i&&($(X,e),$(H,i))}function ie(e){X.current===e&&(D(H),D(X)),q.current===e&&(D(q),yl._currentValue=ae)}var we,Ce;function ze(e){if(we===void 0)try{throw Error()}catch(i){var r=i.stack.trim().match(/\n( *(at )?)/);we=r&&r[1]||"",Ce=-1G||(e.current=ae[G],ae[G]=null,G--)}function B(e,r){G++,ae[G]=e.current,e.current=r}var V=O(null),Z=O(null),be=O(null),K=O(null);function ge(e,r){switch(B(be,r),B(Z,e),B(V,null),r.nodeType){case 9:case 11:e=(e=r.documentElement)&&(e=e.namespaceURI)?Bv(e):0;break;default:if(e=r.tagName,r=r.namespaceURI)r=Bv(r),e=$v(r,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}D(V),B(V,e)}function me(){D(V),D(Z),D(be)}function $(e){e.memoizedState!==null&&B(K,e);var r=V.current,i=$v(r,e.type);r!==i&&(B(Z,e),B(V,i))}function ie(e){Z.current===e&&(D(V),D(Z)),K.current===e&&(D(K),yl._currentValue=oe)}var ye,Se;function Be(e){if(ye===void 0)try{throw Error()}catch(i){var r=i.stack.trim().match(/\n( *(at )?)/);ye=r&&r[1]||"",Se=-1)":-1h||z[u]!==J[h]){var le=` -`+z[u].replace(" at new "," at ");return e.displayName&&le.includes("")&&(le=le.replace("",e.displayName)),le}while(1<=u&&0<=h);break}}}finally{Ke=!1,Error.prepareStackTrace=i}return(i=e?e.displayName||e.name:"")?ze(i):""}function Pt(e,r){switch(e.tag){case 26:case 27:case 5:return ze(e.type);case 16:return ze("Lazy");case 13:return e.child!==r&&r!==null?ze("Suspense Fallback"):ze("Suspense");case 19:return ze("SuspenseList");case 0:case 15:return ft(e.type,!1);case 11:return ft(e.type.render,!1);case 1:return ft(e.type,!0);case 31:return ze("Activity");default:return""}}function gn(e){try{var r="",i=null;do r+=Pt(e,i),i=e,e=e.return;while(e);return r}catch(u){return` +`+z[u].replace(" at new "," at ");return e.displayName&&le.includes("")&&(le=le.replace("",e.displayName)),le}while(1<=u&&0<=h);break}}}finally{Ke=!1,Error.prepareStackTrace=i}return(i=e?e.displayName||e.name:"")?Be(i):""}function qt(e,r){switch(e.tag){case 26:case 27:case 5:return Be(e.type);case 16:return Be("Lazy");case 13:return e.child!==r&&r!==null?Be("Suspense Fallback"):Be("Suspense");case 19:return Be("SuspenseList");case 0:case 15:return We(e.type,!1);case 11:return We(e.type.render,!1);case 1:return We(e.type,!0);case 31:return Be("Activity");default:return""}}function vn(e){try{var r="",i=null;do r+=qt(e,i),i=e,e=e.return;while(e);return r}catch(u){return` Error generating stack: `+u.message+` -`+u.stack}}var Yr=Object.prototype.hasOwnProperty,_n=t.unstable_scheduleCallback,wn=t.unstable_cancelCallback,Xn=t.unstable_shouldYield,Zn=t.unstable_requestPaint,It=t.unstable_now,po=t.unstable_getCurrentPriorityLevel,nn=t.unstable_ImmediatePriority,Dn=t.unstable_UserBlockingPriority,Da=t.unstable_NormalPriority,ho=t.unstable_LowPriority,Qn=t.unstable_IdlePriority,Es=t.log,qr=t.unstable_setDisableYieldValue,gr=null,Tt=null;function On(e){if(typeof Es=="function"&&qr(e),Tt&&typeof Tt.setStrictMode=="function")try{Tt.setStrictMode(gr,e)}catch{}}var Mt=Math.clz32?Math.clz32:go,Oi=Math.log,Li=Math.LN2;function go(e){return e>>>=0,e===0?32:31-(Oi(e)/Li|0)|0}var Kr=256,Oa=262144,Mr=4194304;function Kt(e){var r=e&42;if(r!==0)return r;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function La(e,r,i){var u=e.pendingLanes;if(u===0)return 0;var h=0,x=e.suspendedLanes,j=e.pingedLanes;e=e.warmLanes;var A=u&134217727;return A!==0?(u=A&~x,u!==0?h=Kt(u):(j&=A,j!==0?h=Kt(j):i||(i=A&~e,i!==0&&(h=Kt(i))))):(A=u&~x,A!==0?h=Kt(A):j!==0?h=Kt(j):i||(i=u&~e,i!==0&&(h=Kt(i)))),h===0?0:r!==0&&r!==h&&(r&x)===0&&(x=h&-h,i=r&-r,x>=i||x===32&&(i&4194048)!==0)?r:h}function Oe(e,r){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&r)===0}function tt(e,r){switch(e){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 it(){var e=Mr;return Mr<<=1,(Mr&62914560)===0&&(Mr=4194304),e}function rn(e){for(var r=[],i=0;31>i;i++)r.push(e);return r}function Ft(e,r){e.pendingLanes|=r,r!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Rt(e,r,i,u,h,x){var j=e.pendingLanes;e.pendingLanes=i,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=i,e.entangledLanes&=i,e.errorRecoveryDisabledLanes&=i,e.shellSuspendCounter=0;var A=e.entanglements,z=e.expirationTimes,J=e.hiddenUpdates;for(i=j&~i;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var h5=/[\n"\\]/g;function tr(e){return e.replace(h5,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function af(e,r,i,u,h,x,j,A){e.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?e.type=j:e.removeAttribute("type"),r!=null?j==="number"?(r===0&&e.value===""||e.value!=r)&&(e.value=""+er(r)):e.value!==""+er(r)&&(e.value=""+er(r)):j!=="submit"&&j!=="reset"||e.removeAttribute("value"),r!=null?sf(e,j,er(r)):i!=null?sf(e,j,er(i)):u!=null&&e.removeAttribute("value"),h==null&&x!=null&&(e.defaultChecked=!!x),h!=null&&(e.checked=h&&typeof h!="function"&&typeof h!="symbol"),A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"?e.name=""+er(A):e.removeAttribute("name")}function Ox(e,r,i,u,h,x,j,A){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(e.type=x),r!=null||i!=null){if(!(x!=="submit"&&x!=="reset"||r!=null)){rf(e);return}i=i!=null?""+er(i):"",r=r!=null?""+er(r):i,A||r===e.value||(e.value=r),e.defaultValue=r}u=u??h,u=typeof u!="function"&&typeof u!="symbol"&&!!u,e.checked=A?e.checked:!!u,e.defaultChecked=!!u,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(e.name=j),rf(e)}function sf(e,r,i){r==="number"&&xc(e.ownerDocument)===e||e.defaultValue===""+i||(e.defaultValue=""+i)}function wo(e,r,i,u){if(e=e.options,r){r={};for(var h=0;h"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),df=!1;if(Jr)try{var Ii={};Object.defineProperty(Ii,"passive",{get:function(){df=!0}}),window.addEventListener("test",Ii,Ii),window.removeEventListener("test",Ii,Ii)}catch{df=!1}var za=null,ff=null,bc=null;function $x(){if(bc)return bc;var e,r=ff,i=r.length,u,h="value"in za?za.value:za.textContent,x=h.length;for(e=0;e=$i),qx=" ",Kx=!1;function Wx(e,r){switch(e){case"keyup":return G5.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Xx(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var No=!1;function F5(e,r){switch(e){case"compositionend":return Xx(r);case"keypress":return r.which!==32?null:(Kx=!0,qx);case"textInput":return e=r.data,e===qx&&Kx?null:e;default:return null}}function Y5(e,r){if(No)return e==="compositionend"||!xf&&Wx(e,r)?(e=$x(),bc=ff=za=null,No=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:i,offset:r-e};e=u}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=a1(i)}}function o1(e,r){return e&&r?e===r?!0:e&&e.nodeType===3?!1:r&&r.nodeType===3?o1(e,r.parentNode):"contains"in e?e.contains(r):e.compareDocumentPosition?!!(e.compareDocumentPosition(r)&16):!1:!1}function i1(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var r=xc(e.document);r instanceof e.HTMLIFrameElement;){try{var i=typeof r.contentWindow.location.href=="string"}catch{i=!1}if(i)e=r.contentWindow;else break;r=xc(e.document)}return r}function yf(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r&&(r==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||r==="textarea"||e.contentEditable==="true")}var e4=Jr&&"documentMode"in document&&11>=document.documentMode,Eo=null,wf=null,Fi=null,jf=!1;function l1(e,r,i){var u=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;jf||Eo==null||Eo!==xc(u)||(u=Eo,"selectionStart"in u&&yf(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}),Fi&&Vi(Fi,u)||(Fi=u,u=fu(wf,"onSelect"),0>=j,h-=j,Ar=1<<32-Mt(r)+h|i<$e?(Xe=ke,ke=null):Xe=ke.sibling;var at=ee(F,ke,Q[$e],de);if(at===null){ke===null&&(ke=Xe);break}e&&ke&&at.alternate===null&&r(F,ke),U=x(at,U,$e),rt===null?Ae=at:rt.sibling=at,rt=at,ke=Xe}if($e===Q.length)return i(F,ke),Je&&ta(F,$e),Ae;if(ke===null){for(;$e$e?(Xe=ke,ke=null):Xe=ke.sibling;var as=ee(F,ke,at.value,de);if(as===null){ke===null&&(ke=Xe);break}e&&ke&&as.alternate===null&&r(F,ke),U=x(as,U,$e),rt===null?Ae=as:rt.sibling=as,rt=as,ke=Xe}if(at.done)return i(F,ke),Je&&ta(F,$e),Ae;if(ke===null){for(;!at.done;$e++,at=Q.next())at=he(F,at.value,de),at!==null&&(U=x(at,U,$e),rt===null?Ae=at:rt.sibling=at,rt=at);return Je&&ta(F,$e),Ae}for(ke=u(ke);!at.done;$e++,at=Q.next())at=ne(ke,F,$e,at.value,de),at!==null&&(e&&at.alternate!==null&&ke.delete(at.key===null?$e:at.key),U=x(at,U,$e),rt===null?Ae=at:rt.sibling=at,rt=at);return e&&ke.forEach(function(y3){return r(F,y3)}),Je&&ta(F,$e),Ae}function gt(F,U,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===S&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case y:e:{for(var Ae=Q.key;U!==null;){if(U.key===Ae){if(Ae=Q.type,Ae===S){if(U.tag===7){i(F,U.sibling),de=h(U,Q.props.children),de.return=F,F=de;break e}}else if(U.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===te&&Ps(Ae)===U.type){i(F,U.sibling),de=h(U,Q.props),Zi(de,Q),de.return=F,F=de;break e}i(F,U);break}else r(F,U);U=U.sibling}Q.type===S?(de=_s(Q.props.children,F.mode,de,Q.key),de.return=F,F=de):(de=Mc(Q.type,Q.key,Q.props,null,F.mode,de),Zi(de,Q),de.return=F,F=de)}return j(F);case C:e:{for(Ae=Q.key;U!==null;){if(U.key===Ae)if(U.tag===4&&U.stateNode.containerInfo===Q.containerInfo&&U.stateNode.implementation===Q.implementation){i(F,U.sibling),de=h(U,Q.children||[]),de.return=F,F=de;break e}else{i(F,U);break}else r(F,U);U=U.sibling}de=Mf(Q,F.mode,de),de.return=F,F=de}return j(F);case te:return Q=Ps(Q),gt(F,U,Q,de)}if(se(Q))return Ee(F,U,Q,de);if(Y(Q)){if(Ae=Y(Q),typeof Ae!="function")throw Error(o(150));return Q=Ae.call(Q),Le(F,U,Q,de)}if(typeof Q.then=="function")return gt(F,U,zc(Q),de);if(Q.$$typeof===T)return gt(F,U,_c(F,Q),de);Pc(F,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint"?(Q=""+Q,U!==null&&U.tag===6?(i(F,U.sibling),de=h(U,Q),de.return=F,F=de):(i(F,U),de=Tf(Q,F.mode,de),de.return=F,F=de),j(F)):i(F,U)}return function(F,U,Q,de){try{Xi=0;var Ae=gt(F,U,Q,de);return Po=null,Ae}catch(ke){if(ke===zo||ke===Oc)throw ke;var rt=Pn(29,ke,null,F.mode);return rt.lanes=de,rt.return=F,rt}finally{}}}var Us=A1(!0),_1=A1(!1),$a=!1;function $f(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Hf(e,r){e=e.updateQueue,r.updateQueue===e&&(r.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ha(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ga(e,r,i){var u=e.updateQueue;if(u===null)return null;if(u=u.shared,(ot&2)!==0){var h=u.pending;return h===null?r.next=r:(r.next=h.next,h.next=r),u.pending=r,r=Tc(e),h1(e,null,i),r}return kc(e,u,r,i),Tc(e)}function Qi(e,r,i){if(r=r.updateQueue,r!==null&&(r=r.shared,(i&4194048)!==0)){var u=r.lanes;u&=e.pendingLanes,i|=u,r.lanes=i,fn(e,i)}}function Gf(e,r){var i=e.updateQueue,u=e.alternate;if(u!==null&&(u=u.updateQueue,i===u)){var h=null,x=null;if(i=i.firstBaseUpdate,i!==null){do{var j={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};x===null?h=x=j:x=x.next=j,i=i.next}while(i!==null);x===null?h=x=r:x=x.next=r}else h=x=r;i={baseState:u.baseState,firstBaseUpdate:h,lastBaseUpdate:x,shared:u.shared,callbacks:u.callbacks},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=r:e.next=r,i.lastBaseUpdate=r}var Vf=!1;function Ji(){if(Vf){var e=Lo;if(e!==null)throw e}}function el(e,r,i,u){Vf=!1;var h=e.updateQueue;$a=!1;var x=h.firstBaseUpdate,j=h.lastBaseUpdate,A=h.shared.pending;if(A!==null){h.shared.pending=null;var z=A,J=z.next;z.next=null,j===null?x=J:j.next=J,j=z;var le=e.alternate;le!==null&&(le=le.updateQueue,A=le.lastBaseUpdate,A!==j&&(A===null?le.firstBaseUpdate=J:A.next=J,le.lastBaseUpdate=z))}if(x!==null){var he=h.baseState;j=0,le=J=z=null,A=x;do{var ee=A.lane&-536870913,ne=ee!==A.lane;if(ne?(We&ee)===ee:(u&ee)===ee){ee!==0&&ee===Oo&&(Vf=!0),le!==null&&(le=le.next={lane:0,tag:A.tag,payload:A.payload,callback:null,next:null});e:{var Ee=e,Le=A;ee=r;var gt=i;switch(Le.tag){case 1:if(Ee=Le.payload,typeof Ee=="function"){he=Ee.call(gt,he,ee);break e}he=Ee;break e;case 3:Ee.flags=Ee.flags&-65537|128;case 0:if(Ee=Le.payload,ee=typeof Ee=="function"?Ee.call(gt,he,ee):Ee,ee==null)break e;he=b({},he,ee);break e;case 2:$a=!0}}ee=A.callback,ee!==null&&(e.flags|=64,ne&&(e.flags|=8192),ne=h.callbacks,ne===null?h.callbacks=[ee]:ne.push(ee))}else ne={lane:ee,tag:A.tag,payload:A.payload,callback:A.callback,next:null},le===null?(J=le=ne,z=he):le=le.next=ne,j|=ee;if(A=A.next,A===null){if(A=h.shared.pending,A===null)break;ne=A,A=ne.next,ne.next=null,h.lastBaseUpdate=ne,h.shared.pending=null}}while(!0);le===null&&(z=he),h.baseState=z,h.firstBaseUpdate=J,h.lastBaseUpdate=le,x===null&&(h.shared.lanes=0),Ka|=j,e.lanes=j,e.memoizedState=he}}function D1(e,r){if(typeof e!="function")throw Error(o(191,e));e.call(r)}function O1(e,r){var i=e.callbacks;if(i!==null)for(e.callbacks=null,e=0;ex?x:8;var j=P.T,A={};P.T=A,cm(e,!1,r,i);try{var z=h(),J=P.S;if(J!==null&&J(A,z),z!==null&&typeof z=="object"&&typeof z.then=="function"){var le=c4(z,u);rl(e,r,le,Hn(e))}else rl(e,r,u,Hn(e))}catch(he){rl(e,r,{then:function(){},status:"rejected",reason:he},Hn())}finally{Z.p=x,j!==null&&A.types!==null&&(j.types=A.types),P.T=j}}function h4(){}function im(e,r,i,u){if(e.tag!==5)throw Error(o(476));var h=fv(e).queue;dv(e,h,r,ae,i===null?h4:function(){return mv(e),i(u)})}function fv(e){var r=e.memoizedState;if(r!==null)return r;r={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:sa,lastRenderedState:ae},next:null};var i={};return r.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:sa,lastRenderedState:i},next:null},e.memoizedState=r,e=e.alternate,e!==null&&(e.memoizedState=r),r}function mv(e){var r=fv(e);r.next===null&&(r=e.alternate.memoizedState),rl(e,r.next.queue,{},Hn())}function lm(){return sn(yl)}function pv(){return zt().memoizedState}function hv(){return zt().memoizedState}function g4(e){for(var r=e.return;r!==null;){switch(r.tag){case 24:case 3:var i=Hn();e=Ha(i);var u=Ga(r,e,i);u!==null&&(kn(u,r,i),Qi(u,r,i)),r={cache:Pf()},e.payload=r;return}r=r.return}}function x4(e,r,i){var u=Hn();i={lane:u,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},qc(e)?xv(r,i):(i=Ef(e,r,i,u),i!==null&&(kn(i,e,u),vv(i,r,u)))}function gv(e,r,i){var u=Hn();rl(e,r,i,u)}function rl(e,r,i,u){var h={lane:u,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(qc(e))xv(r,h);else{var x=e.alternate;if(e.lanes===0&&(x===null||x.lanes===0)&&(x=r.lastRenderedReducer,x!==null))try{var j=r.lastRenderedState,A=x(j,i);if(h.hasEagerState=!0,h.eagerState=A,zn(A,j))return kc(e,r,h,0),xt===null&&Ec(),!1}catch{}finally{}if(i=Ef(e,r,h,u),i!==null)return kn(i,e,u),vv(i,r,u),!0}return!1}function cm(e,r,i,u){if(u={lane:2,revertLane:$m(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},qc(e)){if(r)throw Error(o(479))}else r=Ef(e,i,u,2),r!==null&&kn(r,e,2)}function qc(e){var r=e.alternate;return e===Ue||r!==null&&r===Ue}function xv(e,r){Uo=Bc=!0;var i=e.pending;i===null?r.next=r:(r.next=i.next,i.next=r),e.pending=r}function vv(e,r,i){if((i&4194048)!==0){var u=r.lanes;u&=e.pendingLanes,i|=u,r.lanes=i,fn(e,i)}}var al={readContext:sn,use:Gc,useCallback:At,useContext:At,useEffect:At,useImperativeHandle:At,useLayoutEffect:At,useInsertionEffect:At,useMemo:At,useReducer:At,useRef:At,useState:At,useDebugValue:At,useDeferredValue:At,useTransition:At,useSyncExternalStore:At,useId:At,useHostTransitionStatus:At,useFormState:At,useActionState:At,useOptimistic:At,useMemoCache:At,useCacheRefresh:At};al.useEffectEvent=At;var bv={readContext:sn,use:Gc,useCallback:function(e,r){return vn().memoizedState=[e,r===void 0?null:r],e},useContext:sn,useEffect:nv,useImperativeHandle:function(e,r,i){i=i!=null?i.concat([e]):null,Fc(4194308,4,ov.bind(null,r,e),i)},useLayoutEffect:function(e,r){return Fc(4194308,4,e,r)},useInsertionEffect:function(e,r){Fc(4,2,e,r)},useMemo:function(e,r){var i=vn();r=r===void 0?null:r;var u=e();if(Bs){On(!0);try{e()}finally{On(!1)}}return i.memoizedState=[u,r],u},useReducer:function(e,r,i){var u=vn();if(i!==void 0){var h=i(r);if(Bs){On(!0);try{i(r)}finally{On(!1)}}}else h=r;return u.memoizedState=u.baseState=h,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:h},u.queue=e,e=e.dispatch=x4.bind(null,Ue,e),[u.memoizedState,e]},useRef:function(e){var r=vn();return e={current:e},r.memoizedState=e},useState:function(e){e=nm(e);var r=e.queue,i=gv.bind(null,Ue,r);return r.dispatch=i,[e.memoizedState,i]},useDebugValue:sm,useDeferredValue:function(e,r){var i=vn();return om(i,e,r)},useTransition:function(){var e=nm(!1);return e=dv.bind(null,Ue,e.queue,!0,!1),vn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,r,i){var u=Ue,h=vn();if(Je){if(i===void 0)throw Error(o(407));i=i()}else{if(i=r(),xt===null)throw Error(o(349));(We&127)!==0||B1(u,r,i)}h.memoizedState=i;var x={value:i,getSnapshot:r};return h.queue=x,nv(H1.bind(null,u,x,e),[e]),u.flags|=2048,$o(9,{destroy:void 0},$1.bind(null,u,x,i,r),null),i},useId:function(){var e=vn(),r=xt.identifierPrefix;if(Je){var i=_r,u=Ar;i=(u&~(1<<32-Mt(u)-1)).toString(32)+i,r="_"+r+"R_"+i,i=$c++,0<\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof u.is=="string"?j.createElement("select",{is:u.is}):j.createElement("select"),u.multiple?x.multiple=!0:u.size&&(x.size=u.size);break;default:x=typeof u.is=="string"?j.createElement(h,{is:u.is}):j.createElement(h)}}x[ye]=r,x[Re]=u;e:for(j=r.child;j!==null;){if(j.tag===5||j.tag===6)x.appendChild(j.stateNode);else if(j.tag!==4&&j.tag!==27&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===r)break e;for(;j.sibling===null;){if(j.return===null||j.return===r)break e;j=j.return}j.sibling.return=j.return,j=j.sibling}r.stateNode=x;e:switch(ln(x,h,u),h){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&ia(r)}}return wt(r),Cm(r,r.type,e===null?null:e.memoizedProps,r.pendingProps,i),null;case 6:if(e&&r.stateNode!=null)e.memoizedProps!==u&&ia(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(o(166));if(e=xe.current,_o(r)){if(e=r.stateNode,i=r.memoizedProps,u=null,h=an,h!==null)switch(h.tag){case 27:case 5:u=h.memoizedProps}e[ye]=r,e=!!(e.nodeValue===i||u!==null&&u.suppressHydrationWarning===!0||Ib(e.nodeValue,i)),e||Ua(r,!0)}else e=mu(e).createTextNode(u),e[ye]=r,r.stateNode=e}return wt(r),null;case 31:if(i=r.memoizedState,e===null||e.memoizedState!==null){if(u=_o(r),i!==null){if(e===null){if(!u)throw Error(o(318));if(e=r.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[ye]=r}else Ds(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;wt(r),e=!1}else i=Df(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),e=!0;if(!e)return r.flags&256?(Un(r),r):(Un(r),null);if((r.flags&128)!==0)throw Error(o(558))}return wt(r),null;case 13:if(u=r.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(h=_o(r),u!==null&&u.dehydrated!==null){if(e===null){if(!h)throw Error(o(318));if(h=r.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(o(317));h[ye]=r}else Ds(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;wt(r),h=!1}else h=Df(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=h),h=!0;if(!h)return r.flags&256?(Un(r),r):(Un(r),null)}return Un(r),(r.flags&128)!==0?(r.lanes=i,r):(i=u!==null,e=e!==null&&e.memoizedState!==null,i&&(u=r.child,h=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(h=u.alternate.memoizedState.cachePool.pool),x=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(x=u.memoizedState.cachePool.pool),x!==h&&(u.flags|=2048)),i!==e&&i&&(r.child.flags|=8192),Qc(r,r.updateQueue),wt(r),null);case 4:return me(),e===null&&Fm(r.stateNode.containerInfo),wt(r),null;case 10:return ra(r.type),wt(r),null;case 19:if(D(Lt),u=r.memoizedState,u===null)return wt(r),null;if(h=(r.flags&128)!==0,x=u.rendering,x===null)if(h)ol(u,!1);else{if(_t!==0||e!==null&&(e.flags&128)!==0)for(e=r.child;e!==null;){if(x=Uc(e),x!==null){for(r.flags|=128,ol(u,!1),e=x.updateQueue,r.updateQueue=e,Qc(r,e),r.subtreeFlags=0,e=i,i=r.child;i!==null;)g1(i,e),i=i.sibling;return $(Lt,Lt.current&1|2),Je&&ta(r,u.treeForkCount),r.child}e=e.sibling}u.tail!==null&&It()>ru&&(r.flags|=128,h=!0,ol(u,!1),r.lanes=4194304)}else{if(!h)if(e=Uc(x),e!==null){if(r.flags|=128,h=!0,e=e.updateQueue,r.updateQueue=e,Qc(r,e),ol(u,!0),u.tail===null&&u.tailMode==="hidden"&&!x.alternate&&!Je)return wt(r),null}else 2*It()-u.renderingStartTime>ru&&i!==536870912&&(r.flags|=128,h=!0,ol(u,!1),r.lanes=4194304);u.isBackwards?(x.sibling=r.child,r.child=x):(e=u.last,e!==null?e.sibling=x:r.child=x,u.last=x)}return u.tail!==null?(e=u.tail,u.rendering=e,u.tail=e.sibling,u.renderingStartTime=It(),e.sibling=null,i=Lt.current,$(Lt,h?i&1|2:i&1),Je&&ta(r,u.treeForkCount),e):(wt(r),null);case 22:case 23:return Un(r),Yf(),u=r.memoizedState!==null,e!==null?e.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(i&536870912)!==0&&(r.flags&128)===0&&(wt(r),r.subtreeFlags&6&&(r.flags|=8192)):wt(r),i=r.updateQueue,i!==null&&Qc(r,i.retryQueue),i=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(i=e.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==i&&(r.flags|=2048),e!==null&&D(zs),null;case 24:return i=null,e!==null&&(i=e.memoizedState.cache),r.memoizedState.cache!==i&&(r.flags|=2048),ra(Ut),wt(r),null;case 25:return null;case 30:return null}throw Error(o(156,r.tag))}function j4(e,r){switch(Af(r),r.tag){case 1:return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 3:return ra(Ut),me(),e=r.flags,(e&65536)!==0&&(e&128)===0?(r.flags=e&-65537|128,r):null;case 26:case 27:case 5:return ie(r),null;case 31:if(r.memoizedState!==null){if(Un(r),r.alternate===null)throw Error(o(340));Ds()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 13:if(Un(r),e=r.memoizedState,e!==null&&e.dehydrated!==null){if(r.alternate===null)throw Error(o(340));Ds()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 19:return D(Lt),null;case 4:return me(),null;case 10:return ra(r.type),null;case 22:case 23:return Un(r),Yf(),e!==null&&D(zs),e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 24:return ra(Ut),null;case 25:return null;default:return null}}function Gv(e,r){switch(Af(r),r.tag){case 3:ra(Ut),me();break;case 26:case 27:case 5:ie(r);break;case 4:me();break;case 31:r.memoizedState!==null&&Un(r);break;case 13:Un(r);break;case 19:D(Lt);break;case 10:ra(r.type);break;case 22:case 23:Un(r),Yf(),e!==null&&D(zs);break;case 24:ra(Ut)}}function il(e,r){try{var i=r.updateQueue,u=i!==null?i.lastEffect:null;if(u!==null){var h=u.next;i=h;do{if((i.tag&e)===e){u=void 0;var x=i.create,j=i.inst;u=x(),j.destroy=u}i=i.next}while(i!==h)}}catch(A){ct(r,r.return,A)}}function Ya(e,r,i){try{var u=r.updateQueue,h=u!==null?u.lastEffect:null;if(h!==null){var x=h.next;u=x;do{if((u.tag&e)===e){var j=u.inst,A=j.destroy;if(A!==void 0){j.destroy=void 0,h=r;var z=i,J=A;try{J()}catch(le){ct(h,z,le)}}}u=u.next}while(u!==x)}}catch(le){ct(r,r.return,le)}}function Vv(e){var r=e.updateQueue;if(r!==null){var i=e.stateNode;try{O1(r,i)}catch(u){ct(e,e.return,u)}}}function Fv(e,r,i){i.props=$s(e.type,e.memoizedProps),i.state=e.memoizedState;try{i.componentWillUnmount()}catch(u){ct(e,r,u)}}function ll(e,r){try{var i=e.ref;if(i!==null){switch(e.tag){case 26:case 27:case 5:var u=e.stateNode;break;case 30:u=e.stateNode;break;default:u=e.stateNode}typeof i=="function"?e.refCleanup=i(u):i.current=u}}catch(h){ct(e,r,h)}}function Dr(e,r){var i=e.ref,u=e.refCleanup;if(i!==null)if(typeof u=="function")try{u()}catch(h){ct(e,r,h)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(h){ct(e,r,h)}else i.current=null}function Yv(e){var r=e.type,i=e.memoizedProps,u=e.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":i.autoFocus&&u.focus();break e;case"img":i.src?u.src=i.src:i.srcSet&&(u.srcset=i.srcSet)}}catch(h){ct(e,e.return,h)}}function Sm(e,r,i){try{var u=e.stateNode;V4(u,e.type,i,r),u[Re]=r}catch(h){ct(e,e.return,h)}}function qv(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ja(e.type)||e.tag===4}function Nm(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||qv(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Ja(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Em(e,r,i){var u=e.tag;if(u===5||u===6)e=e.stateNode,r?(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i).insertBefore(e,r):(r=i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,r.appendChild(e),i=i._reactRootContainer,i!=null||r.onclick!==null||(r.onclick=Qr));else if(u!==4&&(u===27&&Ja(e.type)&&(i=e.stateNode,r=null),e=e.child,e!==null))for(Em(e,r,i),e=e.sibling;e!==null;)Em(e,r,i),e=e.sibling}function Jc(e,r,i){var u=e.tag;if(u===5||u===6)e=e.stateNode,r?i.insertBefore(e,r):i.appendChild(e);else if(u!==4&&(u===27&&Ja(e.type)&&(i=e.stateNode),e=e.child,e!==null))for(Jc(e,r,i),e=e.sibling;e!==null;)Jc(e,r,i),e=e.sibling}function Kv(e){var r=e.stateNode,i=e.memoizedProps;try{for(var u=e.type,h=r.attributes;h.length;)r.removeAttributeNode(h[0]);ln(r,u,i),r[ye]=e,r[Re]=i}catch(x){ct(e,e.return,x)}}var la=!1,Ht=!1,km=!1,Wv=typeof WeakSet=="function"?WeakSet:Set,Xt=null;function C4(e,r){if(e=e.containerInfo,Km=yu,e=i1(e),yf(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var u=i.getSelection&&i.getSelection();if(u&&u.rangeCount!==0){i=u.anchorNode;var h=u.anchorOffset,x=u.focusNode;u=u.focusOffset;try{i.nodeType,x.nodeType}catch{i=null;break e}var j=0,A=-1,z=-1,J=0,le=0,he=e,ee=null;t:for(;;){for(var ne;he!==i||h!==0&&he.nodeType!==3||(A=j+h),he!==x||u!==0&&he.nodeType!==3||(z=j+u),he.nodeType===3&&(j+=he.nodeValue.length),(ne=he.firstChild)!==null;)ee=he,he=ne;for(;;){if(he===e)break t;if(ee===i&&++J===h&&(A=j),ee===x&&++le===u&&(z=j),(ne=he.nextSibling)!==null)break;he=ee,ee=he.parentNode}he=ne}i=A===-1||z===-1?null:{start:A,end:z}}else i=null}i=i||{start:0,end:0}}else i=null;for(Wm={focusedElem:e,selectionRange:i},yu=!1,Xt=r;Xt!==null;)if(r=Xt,e=r.child,(r.subtreeFlags&1028)!==0&&e!==null)e.return=r,Xt=e;else for(;Xt!==null;){switch(r=Xt,x=r.alternate,e=r.flags,r.tag){case 0:if((e&4)!==0&&(e=r.updateQueue,e=e!==null?e.events:null,e!==null))for(i=0;i title"))),ln(x,u,i),x[ye]=e,Wt(x),u=x;break e;case"link":var j=ty("link","href",h).get(u+(i.href||""));if(j){for(var A=0;Agt&&(j=gt,gt=Le,Le=j);var F=s1(A,Le),U=s1(A,gt);if(F&&U&&(ne.rangeCount!==1||ne.anchorNode!==F.node||ne.anchorOffset!==F.offset||ne.focusNode!==U.node||ne.focusOffset!==U.offset)){var Q=he.createRange();Q.setStart(F.node,F.offset),ne.removeAllRanges(),Le>gt?(ne.addRange(Q),ne.extend(U.node,U.offset)):(Q.setEnd(U.node,U.offset),ne.addRange(Q))}}}}for(he=[],ne=A;ne=ne.parentNode;)ne.nodeType===1&&he.push({element:ne,left:ne.scrollLeft,top:ne.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;Ai?32:i,P.T=null,i=Om,Om=null;var x=Xa,j=ma;if(Yt=0,Yo=Xa=null,ma=0,(ot&6)!==0)throw Error(o(331));var A=ot;if(ot|=4,ob(x.current),rb(x,x.current,j,i),ot=A,pl(0,!1),Tt&&typeof Tt.onPostCommitFiberRoot=="function")try{Tt.onPostCommitFiberRoot(gr,x)}catch{}return!0}finally{Z.p=h,P.T=u,Sb(e,r)}}function Eb(e,r,i){r=rr(i,r),r=mm(e.stateNode,r,2),e=Ga(e,r,2),e!==null&&(Ft(e,2),Or(e))}function ct(e,r,i){if(e.tag===3)Eb(e,e,i);else for(;r!==null;){if(r.tag===3){Eb(r,e,i);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Wa===null||!Wa.has(u))){e=rr(i,e),i=kv(2),u=Ga(r,i,2),u!==null&&(Tv(i,u,r,e),Ft(u,2),Or(u));break}}r=r.return}}function Im(e,r,i){var u=e.pingCache;if(u===null){u=e.pingCache=new E4;var h=new Set;u.set(r,h)}else h=u.get(r),h===void 0&&(h=new Set,u.set(r,h));h.has(i)||(Rm=!0,h.add(i),e=A4.bind(null,e,r,i),r.then(e,e))}function A4(e,r,i){var u=e.pingCache;u!==null&&u.delete(r),e.pingedLanes|=e.suspendedLanes&i,e.warmLanes&=~i,xt===e&&(We&i)===i&&(_t===4||_t===3&&(We&62914560)===We&&300>It()-nu?(ot&2)===0&&qo(e,0):Am|=i,Fo===We&&(Fo=0)),Or(e)}function kb(e,r){r===0&&(r=it()),e=As(e,r),e!==null&&(Ft(e,r),Or(e))}function _4(e){var r=e.memoizedState,i=0;r!==null&&(i=r.retryLane),kb(e,i)}function D4(e,r){var i=0;switch(e.tag){case 31:case 13:var u=e.stateNode,h=e.memoizedState;h!==null&&(i=h.retryLane);break;case 19:u=e.stateNode;break;case 22:u=e.stateNode._retryCache;break;default:throw Error(o(314))}u!==null&&u.delete(r),kb(e,i)}function O4(e,r){return _n(e,r)}var cu=null,Wo=null,Um=!1,uu=!1,Bm=!1,Qa=0;function Or(e){e!==Wo&&e.next===null&&(Wo===null?cu=Wo=e:Wo=Wo.next=e),uu=!0,Um||(Um=!0,z4())}function pl(e,r){if(!Bm&&uu){Bm=!0;do for(var i=!1,u=cu;u!==null;){if(e!==0){var h=u.pendingLanes;if(h===0)var x=0;else{var j=u.suspendedLanes,A=u.pingedLanes;x=(1<<31-Mt(42|e)+1)-1,x&=h&~(j&~A),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(i=!0,Ab(u,x))}else x=We,x=La(u,u===xt?x:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(x&3)===0||Oe(u,x)||(i=!0,Ab(u,x));u=u.next}while(i);Bm=!1}}function L4(){Tb()}function Tb(){uu=Um=!1;var e=0;Qa!==0&&Y4()&&(e=Qa);for(var r=It(),i=null,u=cu;u!==null;){var h=u.next,x=Mb(u,r);x===0?(u.next=null,i===null?cu=h:i.next=h,h===null&&(Wo=i)):(i=u,(e!==0||(x&3)!==0)&&(uu=!0)),u=h}Yt!==0&&Yt!==5||pl(e),Qa!==0&&(Qa=0)}function Mb(e,r){for(var i=e.suspendedLanes,u=e.pingedLanes,h=e.expirationTimes,x=e.pendingLanes&-62914561;0A)break;var le=z.transferSize,he=z.initiatorType;le&&Ub(he)&&(z=z.responseEnd,j+=le*(z"u"?null:document;function Zb(e,r,i){var u=Xo;if(u&&typeof r=="string"&&r){var h=tr(r);h='link[rel="'+e+'"][href="'+h+'"]',typeof i=="string"&&(h+='[crossorigin="'+i+'"]'),Xb.has(h)||(Xb.add(h),e={rel:e,crossOrigin:i,href:r},u.querySelector(h)===null&&(r=u.createElement("link"),ln(r,"link",e),Wt(r),u.head.appendChild(r)))}}function t3(e){pa.D(e),Zb("dns-prefetch",e,null)}function n3(e,r){pa.C(e,r),Zb("preconnect",e,r)}function r3(e,r,i){pa.L(e,r,i);var u=Xo;if(u&&e&&r){var h='link[rel="preload"][as="'+tr(r)+'"]';r==="image"&&i&&i.imageSrcSet?(h+='[imagesrcset="'+tr(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(h+='[imagesizes="'+tr(i.imageSizes)+'"]')):h+='[href="'+tr(e)+'"]';var x=h;switch(r){case"style":x=Zo(e);break;case"script":x=Qo(e)}cr.has(x)||(e=b({rel:"preload",href:r==="image"&&i&&i.imageSrcSet?void 0:e,as:r},i),cr.set(x,e),u.querySelector(h)!==null||r==="style"&&u.querySelector(vl(x))||r==="script"&&u.querySelector(bl(x))||(r=u.createElement("link"),ln(r,"link",e),Wt(r),u.head.appendChild(r)))}}function a3(e,r){pa.m(e,r);var i=Xo;if(i&&e){var u=r&&typeof r.as=="string"?r.as:"script",h='link[rel="modulepreload"][as="'+tr(u)+'"][href="'+tr(e)+'"]',x=h;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Qo(e)}if(!cr.has(x)&&(e=b({rel:"modulepreload",href:e},r),cr.set(x,e),i.querySelector(h)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(bl(x)))return}u=i.createElement("link"),ln(u,"link",e),Wt(u),i.head.appendChild(u)}}}function s3(e,r,i){pa.S(e,r,i);var u=Xo;if(u&&e){var h=bo(u).hoistableStyles,x=Zo(e);r=r||"default";var j=h.get(x);if(!j){var A={loading:0,preload:null};if(j=u.querySelector(vl(x)))A.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":r},i),(i=cr.get(x))&&np(e,i);var z=j=u.createElement("link");Wt(z),ln(z,"link",e),z._p=new Promise(function(J,le){z.onload=J,z.onerror=le}),z.addEventListener("load",function(){A.loading|=1}),z.addEventListener("error",function(){A.loading|=2}),A.loading|=4,hu(j,r,u)}j={type:"stylesheet",instance:j,count:1,state:A},h.set(x,j)}}}function o3(e,r){pa.X(e,r);var i=Xo;if(i&&e){var u=bo(i).hoistableScripts,h=Qo(e),x=u.get(h);x||(x=i.querySelector(bl(h)),x||(e=b({src:e,async:!0},r),(r=cr.get(h))&&rp(e,r),x=i.createElement("script"),Wt(x),ln(x,"link",e),i.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},u.set(h,x))}}function i3(e,r){pa.M(e,r);var i=Xo;if(i&&e){var u=bo(i).hoistableScripts,h=Qo(e),x=u.get(h);x||(x=i.querySelector(bl(h)),x||(e=b({src:e,async:!0,type:"module"},r),(r=cr.get(h))&&rp(e,r),x=i.createElement("script"),Wt(x),ln(x,"link",e),i.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},u.set(h,x))}}function Qb(e,r,i,u){var h=(h=xe.current)?pu(h):null;if(!h)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(r=Zo(i.href),i=bo(h).hoistableStyles,u=i.get(r),u||(u={type:"style",instance:null,count:0,state:null},i.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){e=Zo(i.href);var x=bo(h).hoistableStyles,j=x.get(e);if(j||(h=h.ownerDocument||h,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(e,j),(x=h.querySelector(vl(e)))&&!x._p&&(j.instance=x,j.state.loading=5),cr.has(e)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},cr.set(e,i),x||l3(h,e,i,j.state))),r&&u===null)throw Error(o(528,""));return j}if(r&&u!==null)throw Error(o(529,""));return null;case"script":return r=i.async,i=i.src,typeof i=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Qo(i),i=bo(h).hoistableScripts,u=i.get(r),u||(u={type:"script",instance:null,count:0,state:null},i.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Zo(e){return'href="'+tr(e)+'"'}function vl(e){return'link[rel="stylesheet"]['+e+"]"}function Jb(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function l3(e,r,i,u){e.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=e.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),ln(r,"link",i),Wt(r),e.head.appendChild(r))}function Qo(e){return'[src="'+tr(e)+'"]'}function bl(e){return"script[async]"+e}function ey(e,r,i){if(r.count++,r.instance===null)switch(r.type){case"style":var u=e.querySelector('style[data-href~="'+tr(i.href)+'"]');if(u)return r.instance=u,Wt(u),u;var h=b({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return u=(e.ownerDocument||e).createElement("style"),Wt(u),ln(u,"style",h),hu(u,i.precedence,e),r.instance=u;case"stylesheet":h=Zo(i.href);var x=e.querySelector(vl(h));if(x)return r.state.loading|=4,r.instance=x,Wt(x),x;u=Jb(i),(h=cr.get(h))&&np(u,h),x=(e.ownerDocument||e).createElement("link"),Wt(x);var j=x;return j._p=new Promise(function(A,z){j.onload=A,j.onerror=z}),ln(x,"link",u),r.state.loading|=4,hu(x,i.precedence,e),r.instance=x;case"script":return x=Qo(i.src),(h=e.querySelector(bl(x)))?(r.instance=h,Wt(h),h):(u=i,(h=cr.get(x))&&(u=b({},i),rp(u,h)),e=e.ownerDocument||e,h=e.createElement("script"),Wt(h),ln(h,"link",u),e.head.appendChild(h),r.instance=h);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,hu(u,i.precedence,e));return r.instance}function hu(e,r,i){for(var u=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),h=u.length?u[u.length-1]:null,x=h,j=0;j title"):null)}function c3(e,r,i){if(i===1||r.itemProp!=null)return!1;switch(e){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 e=r.disabled,typeof r.precedence=="string"&&e==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 ry(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function u3(e,r,i,u){if(i.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var h=Zo(u.href),x=r.querySelector(vl(h));if(x){r=x._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(e.count++,e=xu.bind(e),r.then(e,e)),i.state.loading|=4,i.instance=x,Wt(x);return}x=r.ownerDocument||r,u=Jb(u),(h=cr.get(h))&&np(u,h),x=x.createElement("link"),Wt(x);var j=x;j._p=new Promise(function(A,z){j.onload=A,j.onerror=z}),ln(x,"link",u),i.instance=x}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(i,r),(r=i.state.preload)&&(i.state.loading&3)===0&&(e.count++,i=xu.bind(e),r.addEventListener("load",i),r.addEventListener("error",i))}}var ap=0;function d3(e,r){return e.stylesheets&&e.count===0&&bu(e,e.stylesheets),0ap?50:800)+r);return e.unsuspend=i,function(){e.unsuspend=null,clearTimeout(u),clearTimeout(h)}}:null}function xu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)bu(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var vu=null;function bu(e,r){e.stylesheets=null,e.unsuspend!==null&&(e.count++,vu=new Map,r.forEach(f3,e),vu=null,xu.call(e))}function f3(e,r){if(!(r.state.loading&4)){var i=vu.get(e);if(i)var u=i.get(null);else{i=new Map,vu.set(e,i);for(var h=e.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(n){console.error(n)}}return t(),pp.exports=R3(),pp.exports}var _3=A3();/** +`+u.stack}}var Xn=Object.prototype.hasOwnProperty,br=t.unstable_scheduleCallback,yn=t.unstable_cancelCallback,wn=t.unstable_shouldYield,Zn=t.unstable_requestPaint,Kt=t.unstable_now,po=t.unstable_getCurrentPriorityLevel,Pt=t.unstable_ImmediatePriority,Qn=t.unstable_UserBlockingPriority,Da=t.unstable_NormalPriority,Es=t.unstable_LowPriority,qr=t.unstable_IdlePriority,ho=t.log,Kr=t.unstable_setDisableYieldValue,Dn=null,yt=null;function On(e){if(typeof ho=="function"&&Kr(e),yt&&typeof yt.setStrictMode=="function")try{yt.setStrictMode(Dn,e)}catch{}}var Rt=Math.clz32?Math.clz32:go,Ai=Math.log,_i=Math.LN2;function go(e){return e>>>=0,e===0?32:31-(Ai(e)/_i|0)|0}var Wr=256,Oa=262144,Ar=4194304;function Wt(e){var r=e&42;if(r!==0)return r;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function La(e,r,i){var u=e.pendingLanes;if(u===0)return 0;var h=0,x=e.suspendedLanes,j=e.pingedLanes;e=e.warmLanes;var A=u&134217727;return A!==0?(u=A&~x,u!==0?h=Wt(u):(j&=A,j!==0?h=Wt(j):i||(i=A&~e,i!==0&&(h=Wt(i))))):(A=u&~x,A!==0?h=Wt(A):j!==0?h=Wt(j):i||(i=u&~e,i!==0&&(h=Wt(i)))),h===0?0:r!==0&&r!==h&&(r&x)===0&&(x=h&-h,i=r&-r,x>=i||x===32&&(i&4194048)!==0)?r:h}function De(e,r){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&r)===0}function rt(e,r){switch(e){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 lt(){var e=Ar;return Ar<<=1,(Ar&62914560)===0&&(Ar=4194304),e}function rn(e){for(var r=[],i=0;31>i;i++)r.push(e);return r}function It(e,r){e.pendingLanes|=r,r!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Jn(e,r,i,u,h,x){var j=e.pendingLanes;e.pendingLanes=i,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=i,e.entangledLanes&=i,e.errorRecoveryDisabledLanes&=i,e.shellSuspendCounter=0;var A=e.entanglements,z=e.expirationTimes,J=e.hiddenUpdates;for(i=j&~i;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var h5=/[\n"\\]/g;function rr(e){return e.replace(h5,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function af(e,r,i,u,h,x,j,A){e.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?e.type=j:e.removeAttribute("type"),r!=null?j==="number"?(r===0&&e.value===""||e.value!=r)&&(e.value=""+nr(r)):e.value!==""+nr(r)&&(e.value=""+nr(r)):j!=="submit"&&j!=="reset"||e.removeAttribute("value"),r!=null?sf(e,j,nr(r)):i!=null?sf(e,j,nr(i)):u!=null&&e.removeAttribute("value"),h==null&&x!=null&&(e.defaultChecked=!!x),h!=null&&(e.checked=h&&typeof h!="function"&&typeof h!="symbol"),A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"?e.name=""+nr(A):e.removeAttribute("name")}function Ox(e,r,i,u,h,x,j,A){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(e.type=x),r!=null||i!=null){if(!(x!=="submit"&&x!=="reset"||r!=null)){rf(e);return}i=i!=null?""+nr(i):"",r=r!=null?""+nr(r):i,A||r===e.value||(e.value=r),e.defaultValue=r}u=u??h,u=typeof u!="function"&&typeof u!="symbol"&&!!u,e.checked=A?e.checked:!!u,e.defaultChecked=!!u,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(e.name=j),rf(e)}function sf(e,r,i){r==="number"&&xc(e.ownerDocument)===e||e.defaultValue===""+i||(e.defaultValue=""+i)}function bo(e,r,i,u){if(e=e.options,r){r={};for(var h=0;h"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),df=!1;if(Jr)try{var Ii={};Object.defineProperty(Ii,"passive",{get:function(){df=!0}}),window.addEventListener("test",Ii,Ii),window.removeEventListener("test",Ii,Ii)}catch{df=!1}var za=null,ff=null,vc=null;function $x(){if(vc)return vc;var e,r=ff,i=r.length,u,h="value"in za?za.value:za.textContent,x=h.length;for(e=0;e=$i),qx=" ",Kx=!1;function Wx(e,r){switch(e){case"keyup":return G5.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Xx(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var jo=!1;function F5(e,r){switch(e){case"compositionend":return Xx(r);case"keypress":return r.which!==32?null:(Kx=!0,qx);case"textInput":return e=r.data,e===qx&&Kx?null:e;default:return null}}function Y5(e,r){if(jo)return e==="compositionend"||!xf&&Wx(e,r)?(e=$x(),vc=ff=za=null,jo=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:i,offset:r-e};e=u}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=a1(i)}}function o1(e,r){return e&&r?e===r?!0:e&&e.nodeType===3?!1:r&&r.nodeType===3?o1(e,r.parentNode):"contains"in e?e.contains(r):e.compareDocumentPosition?!!(e.compareDocumentPosition(r)&16):!1:!1}function i1(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var r=xc(e.document);r instanceof e.HTMLIFrameElement;){try{var i=typeof r.contentWindow.location.href=="string"}catch{i=!1}if(i)e=r.contentWindow;else break;r=xc(e.document)}return r}function yf(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r&&(r==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||r==="textarea"||e.contentEditable==="true")}var e4=Jr&&"documentMode"in document&&11>=document.documentMode,Co=null,wf=null,Fi=null,jf=!1;function l1(e,r,i){var u=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;jf||Co==null||Co!==xc(u)||(u=Co,"selectionStart"in u&&yf(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}),Fi&&Vi(Fi,u)||(Fi=u,u=fu(wf,"onSelect"),0>=j,h-=j,Dr=1<<32-Rt(r)+h|i<$e?(Qe=ke,ke=null):Qe=ke.sibling;var st=ee(F,ke,Q[$e],fe);if(st===null){ke===null&&(ke=Qe);break}e&&ke&&st.alternate===null&&r(F,ke),U=x(st,U,$e),at===null?Re=st:at.sibling=st,at=st,ke=Qe}if($e===Q.length)return i(F,ke),tt&&ta(F,$e),Re;if(ke===null){for(;$e$e?(Qe=ke,ke=null):Qe=ke.sibling;var as=ee(F,ke,st.value,fe);if(as===null){ke===null&&(ke=Qe);break}e&&ke&&as.alternate===null&&r(F,ke),U=x(as,U,$e),at===null?Re=as:at.sibling=as,at=as,ke=Qe}if(st.done)return i(F,ke),tt&&ta(F,$e),Re;if(ke===null){for(;!st.done;$e++,st=Q.next())st=he(F,st.value,fe),st!==null&&(U=x(st,U,$e),at===null?Re=st:at.sibling=st,at=st);return tt&&ta(F,$e),Re}for(ke=u(ke);!st.done;$e++,st=Q.next())st=re(ke,F,$e,st.value,fe),st!==null&&(e&&st.alternate!==null&&ke.delete(st.key===null?$e:st.key),U=x(st,U,$e),at===null?Re=st:at.sibling=st,at=st);return e&&ke.forEach(function(y3){return r(F,y3)}),tt&&ta(F,$e),Re}function ht(F,U,Q,fe){if(typeof Q=="object"&&Q!==null&&Q.type===S&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case y:e:{for(var Re=Q.key;U!==null;){if(U.key===Re){if(Re=Q.type,Re===S){if(U.tag===7){i(F,U.sibling),fe=h(U,Q.props.children),fe.return=F,F=fe;break e}}else if(U.elementType===Re||typeof Re=="object"&&Re!==null&&Re.$$typeof===ne&&Ps(Re)===U.type){i(F,U.sibling),fe=h(U,Q.props),Zi(fe,Q),fe.return=F,F=fe;break e}i(F,U);break}else r(F,U);U=U.sibling}Q.type===S?(fe=_s(Q.props.children,F.mode,fe,Q.key),fe.return=F,F=fe):(fe=Mc(Q.type,Q.key,Q.props,null,F.mode,fe),Zi(fe,Q),fe.return=F,F=fe)}return j(F);case C:e:{for(Re=Q.key;U!==null;){if(U.key===Re)if(U.tag===4&&U.stateNode.containerInfo===Q.containerInfo&&U.stateNode.implementation===Q.implementation){i(F,U.sibling),fe=h(U,Q.children||[]),fe.return=F,F=fe;break e}else{i(F,U);break}else r(F,U);U=U.sibling}fe=Mf(Q,F.mode,fe),fe.return=F,F=fe}return j(F);case ne:return Q=Ps(Q),ht(F,U,Q,fe)}if(se(Q))return Ee(F,U,Q,fe);if(q(Q)){if(Re=q(Q),typeof Re!="function")throw Error(o(150));return Q=Re.call(Q),Oe(F,U,Q,fe)}if(typeof Q.then=="function")return ht(F,U,zc(Q),fe);if(Q.$$typeof===M)return ht(F,U,_c(F,Q),fe);Pc(F,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint"?(Q=""+Q,U!==null&&U.tag===6?(i(F,U.sibling),fe=h(U,Q),fe.return=F,F=fe):(i(F,U),fe=Tf(Q,F.mode,fe),fe.return=F,F=fe),j(F)):i(F,U)}return function(F,U,Q,fe){try{Xi=0;var Re=ht(F,U,Q,fe);return Oo=null,Re}catch(ke){if(ke===Do||ke===Oc)throw ke;var at=Pn(29,ke,null,F.mode);return at.lanes=fe,at.return=F,at}finally{}}}var Us=A1(!0),_1=A1(!1),$a=!1;function $f(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Hf(e,r){e=e.updateQueue,r.updateQueue===e&&(r.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ha(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ga(e,r,i){var u=e.updateQueue;if(u===null)return null;if(u=u.shared,(it&2)!==0){var h=u.pending;return h===null?r.next=r:(r.next=h.next,h.next=r),u.pending=r,r=Tc(e),h1(e,null,i),r}return kc(e,u,r,i),Tc(e)}function Qi(e,r,i){if(r=r.updateQueue,r!==null&&(r=r.shared,(i&4194048)!==0)){var u=r.lanes;u&=e.pendingLanes,i|=u,r.lanes=i,bt(e,i)}}function Gf(e,r){var i=e.updateQueue,u=e.alternate;if(u!==null&&(u=u.updateQueue,i===u)){var h=null,x=null;if(i=i.firstBaseUpdate,i!==null){do{var j={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};x===null?h=x=j:x=x.next=j,i=i.next}while(i!==null);x===null?h=x=r:x=x.next=r}else h=x=r;i={baseState:u.baseState,firstBaseUpdate:h,lastBaseUpdate:x,shared:u.shared,callbacks:u.callbacks},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=r:e.next=r,i.lastBaseUpdate=r}var Vf=!1;function Ji(){if(Vf){var e=_o;if(e!==null)throw e}}function el(e,r,i,u){Vf=!1;var h=e.updateQueue;$a=!1;var x=h.firstBaseUpdate,j=h.lastBaseUpdate,A=h.shared.pending;if(A!==null){h.shared.pending=null;var z=A,J=z.next;z.next=null,j===null?x=J:j.next=J,j=z;var le=e.alternate;le!==null&&(le=le.updateQueue,A=le.lastBaseUpdate,A!==j&&(A===null?le.firstBaseUpdate=J:A.next=J,le.lastBaseUpdate=z))}if(x!==null){var he=h.baseState;j=0,le=J=z=null,A=x;do{var ee=A.lane&-536870913,re=ee!==A.lane;if(re?(Ze&ee)===ee:(u&ee)===ee){ee!==0&&ee===Ao&&(Vf=!0),le!==null&&(le=le.next={lane:0,tag:A.tag,payload:A.payload,callback:null,next:null});e:{var Ee=e,Oe=A;ee=r;var ht=i;switch(Oe.tag){case 1:if(Ee=Oe.payload,typeof Ee=="function"){he=Ee.call(ht,he,ee);break e}he=Ee;break e;case 3:Ee.flags=Ee.flags&-65537|128;case 0:if(Ee=Oe.payload,ee=typeof Ee=="function"?Ee.call(ht,he,ee):Ee,ee==null)break e;he=v({},he,ee);break e;case 2:$a=!0}}ee=A.callback,ee!==null&&(e.flags|=64,re&&(e.flags|=8192),re=h.callbacks,re===null?h.callbacks=[ee]:re.push(ee))}else re={lane:ee,tag:A.tag,payload:A.payload,callback:A.callback,next:null},le===null?(J=le=re,z=he):le=le.next=re,j|=ee;if(A=A.next,A===null){if(A=h.shared.pending,A===null)break;re=A,A=re.next,re.next=null,h.lastBaseUpdate=re,h.shared.pending=null}}while(!0);le===null&&(z=he),h.baseState=z,h.firstBaseUpdate=J,h.lastBaseUpdate=le,x===null&&(h.shared.lanes=0),Ka|=j,e.lanes=j,e.memoizedState=he}}function D1(e,r){if(typeof e!="function")throw Error(o(191,e));e.call(r)}function O1(e,r){var i=e.callbacks;if(i!==null)for(e.callbacks=null,e=0;ex?x:8;var j=P.T,A={};P.T=A,cm(e,!1,r,i);try{var z=h(),J=P.S;if(J!==null&&J(A,z),z!==null&&typeof z=="object"&&typeof z.then=="function"){var le=c4(z,u);rl(e,r,le,Hn(e))}else rl(e,r,u,Hn(e))}catch(he){rl(e,r,{then:function(){},status:"rejected",reason:he},Hn())}finally{W.p=x,j!==null&&A.types!==null&&(j.types=A.types),P.T=j}}function h4(){}function im(e,r,i,u){if(e.tag!==5)throw Error(o(476));var h=fb(e).queue;db(e,h,r,oe,i===null?h4:function(){return mb(e),i(u)})}function fb(e){var r=e.memoizedState;if(r!==null)return r;r={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:sa,lastRenderedState:oe},next:null};var i={};return r.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:sa,lastRenderedState:i},next:null},e.memoizedState=r,e=e.alternate,e!==null&&(e.memoizedState=r),r}function mb(e){var r=fb(e);r.next===null&&(r=e.alternate.memoizedState),rl(e,r.next.queue,{},Hn())}function lm(){return on(yl)}function pb(){return zt().memoizedState}function hb(){return zt().memoizedState}function g4(e){for(var r=e.return;r!==null;){switch(r.tag){case 24:case 3:var i=Hn();e=Ha(i);var u=Ga(r,e,i);u!==null&&(Tn(u,r,i),Qi(u,r,i)),r={cache:Pf()},e.payload=r;return}r=r.return}}function x4(e,r,i){var u=Hn();i={lane:u,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},qc(e)?xb(r,i):(i=Ef(e,r,i,u),i!==null&&(Tn(i,e,u),bb(i,r,u)))}function gb(e,r,i){var u=Hn();rl(e,r,i,u)}function rl(e,r,i,u){var h={lane:u,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(qc(e))xb(r,h);else{var x=e.alternate;if(e.lanes===0&&(x===null||x.lanes===0)&&(x=r.lastRenderedReducer,x!==null))try{var j=r.lastRenderedState,A=x(j,i);if(h.hasEagerState=!0,h.eagerState=A,zn(A,j))return kc(e,r,h,0),xt===null&&Ec(),!1}catch{}finally{}if(i=Ef(e,r,h,u),i!==null)return Tn(i,e,u),bb(i,r,u),!0}return!1}function cm(e,r,i,u){if(u={lane:2,revertLane:$m(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},qc(e)){if(r)throw Error(o(479))}else r=Ef(e,i,u,2),r!==null&&Tn(r,e,2)}function qc(e){var r=e.alternate;return e===Ie||r!==null&&r===Ie}function xb(e,r){zo=Bc=!0;var i=e.pending;i===null?r.next=r:(r.next=i.next,i.next=r),e.pending=r}function bb(e,r,i){if((i&4194048)!==0){var u=r.lanes;u&=e.pendingLanes,i|=u,r.lanes=i,bt(e,i)}}var al={readContext:on,use:Gc,useCallback:At,useContext:At,useEffect:At,useImperativeHandle:At,useLayoutEffect:At,useInsertionEffect:At,useMemo:At,useReducer:At,useRef:At,useState:At,useDebugValue:At,useDeferredValue:At,useTransition:At,useSyncExternalStore:At,useId:At,useHostTransitionStatus:At,useFormState:At,useActionState:At,useOptimistic:At,useMemoCache:At,useCacheRefresh:At};al.useEffectEvent=At;var vb={readContext:on,use:Gc,useCallback:function(e,r){return gn().memoizedState=[e,r===void 0?null:r],e},useContext:on,useEffect:nb,useImperativeHandle:function(e,r,i){i=i!=null?i.concat([e]):null,Fc(4194308,4,ob.bind(null,r,e),i)},useLayoutEffect:function(e,r){return Fc(4194308,4,e,r)},useInsertionEffect:function(e,r){Fc(4,2,e,r)},useMemo:function(e,r){var i=gn();r=r===void 0?null:r;var u=e();if(Bs){On(!0);try{e()}finally{On(!1)}}return i.memoizedState=[u,r],u},useReducer:function(e,r,i){var u=gn();if(i!==void 0){var h=i(r);if(Bs){On(!0);try{i(r)}finally{On(!1)}}}else h=r;return u.memoizedState=u.baseState=h,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:h},u.queue=e,e=e.dispatch=x4.bind(null,Ie,e),[u.memoizedState,e]},useRef:function(e){var r=gn();return e={current:e},r.memoizedState=e},useState:function(e){e=nm(e);var r=e.queue,i=gb.bind(null,Ie,r);return r.dispatch=i,[e.memoizedState,i]},useDebugValue:sm,useDeferredValue:function(e,r){var i=gn();return om(i,e,r)},useTransition:function(){var e=nm(!1);return e=db.bind(null,Ie,e.queue,!0,!1),gn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,r,i){var u=Ie,h=gn();if(tt){if(i===void 0)throw Error(o(407));i=i()}else{if(i=r(),xt===null)throw Error(o(349));(Ze&127)!==0||B1(u,r,i)}h.memoizedState=i;var x={value:i,getSnapshot:r};return h.queue=x,nb(H1.bind(null,u,x,e),[e]),u.flags|=2048,Io(9,{destroy:void 0},$1.bind(null,u,x,i,r),null),i},useId:function(){var e=gn(),r=xt.identifierPrefix;if(tt){var i=Or,u=Dr;i=(u&~(1<<32-Rt(u)-1)).toString(32)+i,r="_"+r+"R_"+i,i=$c++,0<\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof u.is=="string"?j.createElement("select",{is:u.is}):j.createElement("select"),u.multiple?x.multiple=!0:u.size&&(x.size=u.size);break;default:x=typeof u.is=="string"?j.createElement(h,{is:u.is}):j.createElement(h)}}x[te]=r,x[je]=u;e:for(j=r.child;j!==null;){if(j.tag===5||j.tag===6)x.appendChild(j.stateNode);else if(j.tag!==4&&j.tag!==27&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===r)break e;for(;j.sibling===null;){if(j.return===null||j.return===r)break e;j=j.return}j.sibling.return=j.return,j=j.sibling}r.stateNode=x;e:switch(cn(x,h,u),h){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&ia(r)}}return jt(r),Cm(r,r.type,e===null?null:e.memoizedProps,r.pendingProps,i),null;case 6:if(e&&r.stateNode!=null)e.memoizedProps!==u&&ia(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(o(166));if(e=be.current,Mo(r)){if(e=r.stateNode,i=r.memoizedProps,u=null,h=sn,h!==null)switch(h.tag){case 27:case 5:u=h.memoizedProps}e[te]=r,e=!!(e.nodeValue===i||u!==null&&u.suppressHydrationWarning===!0||Iv(e.nodeValue,i)),e||Ua(r,!0)}else e=mu(e).createTextNode(u),e[te]=r,r.stateNode=e}return jt(r),null;case 31:if(i=r.memoizedState,e===null||e.memoizedState!==null){if(u=Mo(r),i!==null){if(e===null){if(!u)throw Error(o(318));if(e=r.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[te]=r}else Ds(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;jt(r),e=!1}else i=Df(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),e=!0;if(!e)return r.flags&256?(Un(r),r):(Un(r),null);if((r.flags&128)!==0)throw Error(o(558))}return jt(r),null;case 13:if(u=r.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(h=Mo(r),u!==null&&u.dehydrated!==null){if(e===null){if(!h)throw Error(o(318));if(h=r.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(o(317));h[te]=r}else Ds(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;jt(r),h=!1}else h=Df(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=h),h=!0;if(!h)return r.flags&256?(Un(r),r):(Un(r),null)}return Un(r),(r.flags&128)!==0?(r.lanes=i,r):(i=u!==null,e=e!==null&&e.memoizedState!==null,i&&(u=r.child,h=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(h=u.alternate.memoizedState.cachePool.pool),x=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(x=u.memoizedState.cachePool.pool),x!==h&&(u.flags|=2048)),i!==e&&i&&(r.child.flags|=8192),Qc(r,r.updateQueue),jt(r),null);case 4:return me(),e===null&&Fm(r.stateNode.containerInfo),jt(r),null;case 10:return ra(r.type),jt(r),null;case 19:if(D(Lt),u=r.memoizedState,u===null)return jt(r),null;if(h=(r.flags&128)!==0,x=u.rendering,x===null)if(h)ol(u,!1);else{if(_t!==0||e!==null&&(e.flags&128)!==0)for(e=r.child;e!==null;){if(x=Uc(e),x!==null){for(r.flags|=128,ol(u,!1),e=x.updateQueue,r.updateQueue=e,Qc(r,e),r.subtreeFlags=0,e=i,i=r.child;i!==null;)g1(i,e),i=i.sibling;return B(Lt,Lt.current&1|2),tt&&ta(r,u.treeForkCount),r.child}e=e.sibling}u.tail!==null&&Kt()>ru&&(r.flags|=128,h=!0,ol(u,!1),r.lanes=4194304)}else{if(!h)if(e=Uc(x),e!==null){if(r.flags|=128,h=!0,e=e.updateQueue,r.updateQueue=e,Qc(r,e),ol(u,!0),u.tail===null&&u.tailMode==="hidden"&&!x.alternate&&!tt)return jt(r),null}else 2*Kt()-u.renderingStartTime>ru&&i!==536870912&&(r.flags|=128,h=!0,ol(u,!1),r.lanes=4194304);u.isBackwards?(x.sibling=r.child,r.child=x):(e=u.last,e!==null?e.sibling=x:r.child=x,u.last=x)}return u.tail!==null?(e=u.tail,u.rendering=e,u.tail=e.sibling,u.renderingStartTime=Kt(),e.sibling=null,i=Lt.current,B(Lt,h?i&1|2:i&1),tt&&ta(r,u.treeForkCount),e):(jt(r),null);case 22:case 23:return Un(r),Yf(),u=r.memoizedState!==null,e!==null?e.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(i&536870912)!==0&&(r.flags&128)===0&&(jt(r),r.subtreeFlags&6&&(r.flags|=8192)):jt(r),i=r.updateQueue,i!==null&&Qc(r,i.retryQueue),i=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(i=e.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==i&&(r.flags|=2048),e!==null&&D(zs),null;case 24:return i=null,e!==null&&(i=e.memoizedState.cache),r.memoizedState.cache!==i&&(r.flags|=2048),ra(Ut),jt(r),null;case 25:return null;case 30:return null}throw Error(o(156,r.tag))}function j4(e,r){switch(Af(r),r.tag){case 1:return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 3:return ra(Ut),me(),e=r.flags,(e&65536)!==0&&(e&128)===0?(r.flags=e&-65537|128,r):null;case 26:case 27:case 5:return ie(r),null;case 31:if(r.memoizedState!==null){if(Un(r),r.alternate===null)throw Error(o(340));Ds()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 13:if(Un(r),e=r.memoizedState,e!==null&&e.dehydrated!==null){if(r.alternate===null)throw Error(o(340));Ds()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 19:return D(Lt),null;case 4:return me(),null;case 10:return ra(r.type),null;case 22:case 23:return Un(r),Yf(),e!==null&&D(zs),e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 24:return ra(Ut),null;case 25:return null;default:return null}}function Gb(e,r){switch(Af(r),r.tag){case 3:ra(Ut),me();break;case 26:case 27:case 5:ie(r);break;case 4:me();break;case 31:r.memoizedState!==null&&Un(r);break;case 13:Un(r);break;case 19:D(Lt);break;case 10:ra(r.type);break;case 22:case 23:Un(r),Yf(),e!==null&&D(zs);break;case 24:ra(Ut)}}function il(e,r){try{var i=r.updateQueue,u=i!==null?i.lastEffect:null;if(u!==null){var h=u.next;i=h;do{if((i.tag&e)===e){u=void 0;var x=i.create,j=i.inst;u=x(),j.destroy=u}i=i.next}while(i!==h)}}catch(A){ut(r,r.return,A)}}function Ya(e,r,i){try{var u=r.updateQueue,h=u!==null?u.lastEffect:null;if(h!==null){var x=h.next;u=x;do{if((u.tag&e)===e){var j=u.inst,A=j.destroy;if(A!==void 0){j.destroy=void 0,h=r;var z=i,J=A;try{J()}catch(le){ut(h,z,le)}}}u=u.next}while(u!==x)}}catch(le){ut(r,r.return,le)}}function Vb(e){var r=e.updateQueue;if(r!==null){var i=e.stateNode;try{O1(r,i)}catch(u){ut(e,e.return,u)}}}function Fb(e,r,i){i.props=$s(e.type,e.memoizedProps),i.state=e.memoizedState;try{i.componentWillUnmount()}catch(u){ut(e,r,u)}}function ll(e,r){try{var i=e.ref;if(i!==null){switch(e.tag){case 26:case 27:case 5:var u=e.stateNode;break;case 30:u=e.stateNode;break;default:u=e.stateNode}typeof i=="function"?e.refCleanup=i(u):i.current=u}}catch(h){ut(e,r,h)}}function Lr(e,r){var i=e.ref,u=e.refCleanup;if(i!==null)if(typeof u=="function")try{u()}catch(h){ut(e,r,h)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(h){ut(e,r,h)}else i.current=null}function Yb(e){var r=e.type,i=e.memoizedProps,u=e.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":i.autoFocus&&u.focus();break e;case"img":i.src?u.src=i.src:i.srcSet&&(u.srcset=i.srcSet)}}catch(h){ut(e,e.return,h)}}function Sm(e,r,i){try{var u=e.stateNode;V4(u,e.type,i,r),u[je]=r}catch(h){ut(e,e.return,h)}}function qb(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ja(e.type)||e.tag===4}function Nm(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||qb(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Ja(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Em(e,r,i){var u=e.tag;if(u===5||u===6)e=e.stateNode,r?(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i).insertBefore(e,r):(r=i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,r.appendChild(e),i=i._reactRootContainer,i!=null||r.onclick!==null||(r.onclick=Qr));else if(u!==4&&(u===27&&Ja(e.type)&&(i=e.stateNode,r=null),e=e.child,e!==null))for(Em(e,r,i),e=e.sibling;e!==null;)Em(e,r,i),e=e.sibling}function Jc(e,r,i){var u=e.tag;if(u===5||u===6)e=e.stateNode,r?i.insertBefore(e,r):i.appendChild(e);else if(u!==4&&(u===27&&Ja(e.type)&&(i=e.stateNode),e=e.child,e!==null))for(Jc(e,r,i),e=e.sibling;e!==null;)Jc(e,r,i),e=e.sibling}function Kb(e){var r=e.stateNode,i=e.memoizedProps;try{for(var u=e.type,h=r.attributes;h.length;)r.removeAttributeNode(h[0]);cn(r,u,i),r[te]=e,r[je]=i}catch(x){ut(e,e.return,x)}}var la=!1,Ht=!1,km=!1,Wb=typeof WeakSet=="function"?WeakSet:Set,Zt=null;function C4(e,r){if(e=e.containerInfo,Km=yu,e=i1(e),yf(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var u=i.getSelection&&i.getSelection();if(u&&u.rangeCount!==0){i=u.anchorNode;var h=u.anchorOffset,x=u.focusNode;u=u.focusOffset;try{i.nodeType,x.nodeType}catch{i=null;break e}var j=0,A=-1,z=-1,J=0,le=0,he=e,ee=null;t:for(;;){for(var re;he!==i||h!==0&&he.nodeType!==3||(A=j+h),he!==x||u!==0&&he.nodeType!==3||(z=j+u),he.nodeType===3&&(j+=he.nodeValue.length),(re=he.firstChild)!==null;)ee=he,he=re;for(;;){if(he===e)break t;if(ee===i&&++J===h&&(A=j),ee===x&&++le===u&&(z=j),(re=he.nextSibling)!==null)break;he=ee,ee=he.parentNode}he=re}i=A===-1||z===-1?null:{start:A,end:z}}else i=null}i=i||{start:0,end:0}}else i=null;for(Wm={focusedElem:e,selectionRange:i},yu=!1,Zt=r;Zt!==null;)if(r=Zt,e=r.child,(r.subtreeFlags&1028)!==0&&e!==null)e.return=r,Zt=e;else for(;Zt!==null;){switch(r=Zt,x=r.alternate,e=r.flags,r.tag){case 0:if((e&4)!==0&&(e=r.updateQueue,e=e!==null?e.events:null,e!==null))for(i=0;i title"))),cn(x,u,i),x[te]=e,Xt(x),u=x;break e;case"link":var j=ty("link","href",h).get(u+(i.href||""));if(j){for(var A=0;Aht&&(j=ht,ht=Oe,Oe=j);var F=s1(A,Oe),U=s1(A,ht);if(F&&U&&(re.rangeCount!==1||re.anchorNode!==F.node||re.anchorOffset!==F.offset||re.focusNode!==U.node||re.focusOffset!==U.offset)){var Q=he.createRange();Q.setStart(F.node,F.offset),re.removeAllRanges(),Oe>ht?(re.addRange(Q),re.extend(U.node,U.offset)):(Q.setEnd(U.node,U.offset),re.addRange(Q))}}}}for(he=[],re=A;re=re.parentNode;)re.nodeType===1&&he.push({element:re,left:re.scrollLeft,top:re.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;Ai?32:i,P.T=null,i=Om,Om=null;var x=Xa,j=ma;if(Ft=0,Go=Xa=null,ma=0,(it&6)!==0)throw Error(o(331));var A=it;if(it|=4,ov(x.current),rv(x,x.current,j,i),it=A,pl(0,!1),yt&&typeof yt.onPostCommitFiberRoot=="function")try{yt.onPostCommitFiberRoot(Dn,x)}catch{}return!0}finally{W.p=h,P.T=u,Sv(e,r)}}function Ev(e,r,i){r=sr(i,r),r=mm(e.stateNode,r,2),e=Ga(e,r,2),e!==null&&(It(e,2),zr(e))}function ut(e,r,i){if(e.tag===3)Ev(e,e,i);else for(;r!==null;){if(r.tag===3){Ev(r,e,i);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Wa===null||!Wa.has(u))){e=sr(i,e),i=kb(2),u=Ga(r,i,2),u!==null&&(Tb(i,u,r,e),It(u,2),zr(u));break}}r=r.return}}function Im(e,r,i){var u=e.pingCache;if(u===null){u=e.pingCache=new E4;var h=new Set;u.set(r,h)}else h=u.get(r),h===void 0&&(h=new Set,u.set(r,h));h.has(i)||(Rm=!0,h.add(i),e=A4.bind(null,e,r,i),r.then(e,e))}function A4(e,r,i){var u=e.pingCache;u!==null&&u.delete(r),e.pingedLanes|=e.suspendedLanes&i,e.warmLanes&=~i,xt===e&&(Ze&i)===i&&(_t===4||_t===3&&(Ze&62914560)===Ze&&300>Kt()-nu?(it&2)===0&&Vo(e,0):Am|=i,Ho===Ze&&(Ho=0)),zr(e)}function kv(e,r){r===0&&(r=lt()),e=As(e,r),e!==null&&(It(e,r),zr(e))}function _4(e){var r=e.memoizedState,i=0;r!==null&&(i=r.retryLane),kv(e,i)}function D4(e,r){var i=0;switch(e.tag){case 31:case 13:var u=e.stateNode,h=e.memoizedState;h!==null&&(i=h.retryLane);break;case 19:u=e.stateNode;break;case 22:u=e.stateNode._retryCache;break;default:throw Error(o(314))}u!==null&&u.delete(r),kv(e,i)}function O4(e,r){return br(e,r)}var cu=null,Yo=null,Um=!1,uu=!1,Bm=!1,Qa=0;function zr(e){e!==Yo&&e.next===null&&(Yo===null?cu=Yo=e:Yo=Yo.next=e),uu=!0,Um||(Um=!0,z4())}function pl(e,r){if(!Bm&&uu){Bm=!0;do for(var i=!1,u=cu;u!==null;){if(e!==0){var h=u.pendingLanes;if(h===0)var x=0;else{var j=u.suspendedLanes,A=u.pingedLanes;x=(1<<31-Rt(42|e)+1)-1,x&=h&~(j&~A),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(i=!0,Av(u,x))}else x=Ze,x=La(u,u===xt?x:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(x&3)===0||De(u,x)||(i=!0,Av(u,x));u=u.next}while(i);Bm=!1}}function L4(){Tv()}function Tv(){uu=Um=!1;var e=0;Qa!==0&&Y4()&&(e=Qa);for(var r=Kt(),i=null,u=cu;u!==null;){var h=u.next,x=Mv(u,r);x===0?(u.next=null,i===null?cu=h:i.next=h,h===null&&(Yo=i)):(i=u,(e!==0||(x&3)!==0)&&(uu=!0)),u=h}Ft!==0&&Ft!==5||pl(e),Qa!==0&&(Qa=0)}function Mv(e,r){for(var i=e.suspendedLanes,u=e.pingedLanes,h=e.expirationTimes,x=e.pendingLanes&-62914561;0A)break;var le=z.transferSize,he=z.initiatorType;le&&Uv(he)&&(z=z.responseEnd,j+=le*(z"u"?null:document;function Zv(e,r,i){var u=qo;if(u&&typeof r=="string"&&r){var h=rr(r);h='link[rel="'+e+'"][href="'+h+'"]',typeof i=="string"&&(h+='[crossorigin="'+i+'"]'),Xv.has(h)||(Xv.add(h),e={rel:e,crossOrigin:i,href:r},u.querySelector(h)===null&&(r=u.createElement("link"),cn(r,"link",e),Xt(r),u.head.appendChild(r)))}}function t3(e){pa.D(e),Zv("dns-prefetch",e,null)}function n3(e,r){pa.C(e,r),Zv("preconnect",e,r)}function r3(e,r,i){pa.L(e,r,i);var u=qo;if(u&&e&&r){var h='link[rel="preload"][as="'+rr(r)+'"]';r==="image"&&i&&i.imageSrcSet?(h+='[imagesrcset="'+rr(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(h+='[imagesizes="'+rr(i.imageSizes)+'"]')):h+='[href="'+rr(e)+'"]';var x=h;switch(r){case"style":x=Ko(e);break;case"script":x=Wo(e)}dr.has(x)||(e=v({rel:"preload",href:r==="image"&&i&&i.imageSrcSet?void 0:e,as:r},i),dr.set(x,e),u.querySelector(h)!==null||r==="style"&&u.querySelector(bl(x))||r==="script"&&u.querySelector(vl(x))||(r=u.createElement("link"),cn(r,"link",e),Xt(r),u.head.appendChild(r)))}}function a3(e,r){pa.m(e,r);var i=qo;if(i&&e){var u=r&&typeof r.as=="string"?r.as:"script",h='link[rel="modulepreload"][as="'+rr(u)+'"][href="'+rr(e)+'"]',x=h;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Wo(e)}if(!dr.has(x)&&(e=v({rel:"modulepreload",href:e},r),dr.set(x,e),i.querySelector(h)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(vl(x)))return}u=i.createElement("link"),cn(u,"link",e),Xt(u),i.head.appendChild(u)}}}function s3(e,r,i){pa.S(e,r,i);var u=qo;if(u&&e){var h=Xr(u).hoistableStyles,x=Ko(e);r=r||"default";var j=h.get(x);if(!j){var A={loading:0,preload:null};if(j=u.querySelector(bl(x)))A.loading=5;else{e=v({rel:"stylesheet",href:e,"data-precedence":r},i),(i=dr.get(x))&&np(e,i);var z=j=u.createElement("link");Xt(z),cn(z,"link",e),z._p=new Promise(function(J,le){z.onload=J,z.onerror=le}),z.addEventListener("load",function(){A.loading|=1}),z.addEventListener("error",function(){A.loading|=2}),A.loading|=4,hu(j,r,u)}j={type:"stylesheet",instance:j,count:1,state:A},h.set(x,j)}}}function o3(e,r){pa.X(e,r);var i=qo;if(i&&e){var u=Xr(i).hoistableScripts,h=Wo(e),x=u.get(h);x||(x=i.querySelector(vl(h)),x||(e=v({src:e,async:!0},r),(r=dr.get(h))&&rp(e,r),x=i.createElement("script"),Xt(x),cn(x,"link",e),i.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},u.set(h,x))}}function i3(e,r){pa.M(e,r);var i=qo;if(i&&e){var u=Xr(i).hoistableScripts,h=Wo(e),x=u.get(h);x||(x=i.querySelector(vl(h)),x||(e=v({src:e,async:!0,type:"module"},r),(r=dr.get(h))&&rp(e,r),x=i.createElement("script"),Xt(x),cn(x,"link",e),i.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},u.set(h,x))}}function Qv(e,r,i,u){var h=(h=be.current)?pu(h):null;if(!h)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(r=Ko(i.href),i=Xr(h).hoistableStyles,u=i.get(r),u||(u={type:"style",instance:null,count:0,state:null},i.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){e=Ko(i.href);var x=Xr(h).hoistableStyles,j=x.get(e);if(j||(h=h.ownerDocument||h,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(e,j),(x=h.querySelector(bl(e)))&&!x._p&&(j.instance=x,j.state.loading=5),dr.has(e)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},dr.set(e,i),x||l3(h,e,i,j.state))),r&&u===null)throw Error(o(528,""));return j}if(r&&u!==null)throw Error(o(529,""));return null;case"script":return r=i.async,i=i.src,typeof i=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Wo(i),i=Xr(h).hoistableScripts,u=i.get(r),u||(u={type:"script",instance:null,count:0,state:null},i.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Ko(e){return'href="'+rr(e)+'"'}function bl(e){return'link[rel="stylesheet"]['+e+"]"}function Jv(e){return v({},e,{"data-precedence":e.precedence,precedence:null})}function l3(e,r,i,u){e.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=e.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),cn(r,"link",i),Xt(r),e.head.appendChild(r))}function Wo(e){return'[src="'+rr(e)+'"]'}function vl(e){return"script[async]"+e}function ey(e,r,i){if(r.count++,r.instance===null)switch(r.type){case"style":var u=e.querySelector('style[data-href~="'+rr(i.href)+'"]');if(u)return r.instance=u,Xt(u),u;var h=v({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return u=(e.ownerDocument||e).createElement("style"),Xt(u),cn(u,"style",h),hu(u,i.precedence,e),r.instance=u;case"stylesheet":h=Ko(i.href);var x=e.querySelector(bl(h));if(x)return r.state.loading|=4,r.instance=x,Xt(x),x;u=Jv(i),(h=dr.get(h))&&np(u,h),x=(e.ownerDocument||e).createElement("link"),Xt(x);var j=x;return j._p=new Promise(function(A,z){j.onload=A,j.onerror=z}),cn(x,"link",u),r.state.loading|=4,hu(x,i.precedence,e),r.instance=x;case"script":return x=Wo(i.src),(h=e.querySelector(vl(x)))?(r.instance=h,Xt(h),h):(u=i,(h=dr.get(x))&&(u=v({},i),rp(u,h)),e=e.ownerDocument||e,h=e.createElement("script"),Xt(h),cn(h,"link",u),e.head.appendChild(h),r.instance=h);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,hu(u,i.precedence,e));return r.instance}function hu(e,r,i){for(var u=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),h=u.length?u[u.length-1]:null,x=h,j=0;j title"):null)}function c3(e,r,i){if(i===1||r.itemProp!=null)return!1;switch(e){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 e=r.disabled,typeof r.precedence=="string"&&e==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 ry(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function u3(e,r,i,u){if(i.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var h=Ko(u.href),x=r.querySelector(bl(h));if(x){r=x._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(e.count++,e=xu.bind(e),r.then(e,e)),i.state.loading|=4,i.instance=x,Xt(x);return}x=r.ownerDocument||r,u=Jv(u),(h=dr.get(h))&&np(u,h),x=x.createElement("link"),Xt(x);var j=x;j._p=new Promise(function(A,z){j.onload=A,j.onerror=z}),cn(x,"link",u),i.instance=x}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(i,r),(r=i.state.preload)&&(i.state.loading&3)===0&&(e.count++,i=xu.bind(e),r.addEventListener("load",i),r.addEventListener("error",i))}}var ap=0;function d3(e,r){return e.stylesheets&&e.count===0&&vu(e,e.stylesheets),0ap?50:800)+r);return e.unsuspend=i,function(){e.unsuspend=null,clearTimeout(u),clearTimeout(h)}}:null}function xu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)vu(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var bu=null;function vu(e,r){e.stylesheets=null,e.unsuspend!==null&&(e.count++,bu=new Map,r.forEach(f3,e),bu=null,xu.call(e))}function f3(e,r){if(!(r.state.loading&4)){var i=bu.get(e);if(i)var u=i.get(null);else{i=new Map,bu.set(e,i);for(var h=e.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(n){console.error(n)}}return t(),pp.exports=R3(),pp.exports}var _3=A3();/** * react-router v7.18.2 * * Copyright (c) Remix Software Inc. @@ -55,14 +55,14 @@ Error generating stack: `+u.message+` * LICENSE.md file in the root directory of this source tree. * * @license MIT - */var Zh=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,i2=/^[\\/]{2}/;function D3(t,n){return n+t.replace(/\\/g,"/")}var Ay="popstate";function _y(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function O3(t={}){function n(o,c){var g;let l=(g=c.state)==null?void 0:g.masked,{pathname:d,search:m,hash:p}=l||o.location;return Qp("",{pathname:d,search:m,hash:p},c.state&&c.state.usr||null,c.state&&c.state.key||"default",l?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function a(o,c){return typeof c=="string"?c:Il(c)}return z3(n,a,null,t)}function Nt(t,n){if(t===!1||t===null||typeof t>"u")throw new Error(n)}function fr(t,n){if(!t){typeof console<"u"&&console.warn(n);try{throw new Error(n)}catch{}}}function L3(){return Math.random().toString(36).substring(2,10)}function Dy(t,n){return{usr:t.state,key:t.key,idx:n,masked:t.mask?{pathname:t.pathname,search:t.search,hash:t.hash}:void 0}}function Qp(t,n,a=null,o,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof n=="string"?vi(n):n,state:a,key:n&&n.key||o||L3(),mask:c}}function Il({pathname:t="/",search:n="",hash:a=""}){return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),a&&a!=="#"&&(t+=a.charAt(0)==="#"?a:"#"+a),t}function vi(t){let n={};if(t){let a=t.indexOf("#");a>=0&&(n.hash=t.substring(a),t=t.substring(0,a));let o=t.indexOf("?");o>=0&&(n.search=t.substring(o),t=t.substring(0,o)),t&&(n.pathname=t)}return n}function z3(t,n,a,o={}){let{window:c=document.defaultView,v5Compat:l=!1}=o,d=c.history,m="POP",p=null,g=v();g==null&&(g=0,d.replaceState({...d.state,idx:g},""));function v(){return(d.state||{idx:null}).idx}function b(){m="POP";let E=v(),k=E==null?null:E-g;g=E,p&&p({action:m,location:S.location,delta:k})}function w(E,k){m="PUSH";let N=_y(E)?E:Qp(S.location,E,k);g=v()+1;let T=Dy(N,g),M=S.createHref(N.mask||N);try{d.pushState(T,"",M)}catch(_){if(_ instanceof DOMException&&_.name==="DataCloneError")throw _;c.location.assign(M)}l&&p&&p({action:m,location:S.location,delta:1})}function y(E,k){m="REPLACE";let N=_y(E)?E:Qp(S.location,E,k);g=v();let T=Dy(N,g),M=S.createHref(N.mask||N);d.replaceState(T,"",M),l&&p&&p({action:m,location:S.location,delta:0})}function C(E){return P3(c,E)}let S={get action(){return m},get location(){return t(c,d)},listen(E){if(p)throw new Error("A history only accepts one active listener");return c.addEventListener(Ay,b),p=E,()=>{c.removeEventListener(Ay,b),p=null}},createHref(E){return n(c,E)},createURL:C,encodeLocation(E){let k=C(E);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:w,replace:y,go(E){return d.go(E)}};return S}function P3(t,n,a=!1){let o="http://localhost";t&&(o=t.location.origin!=="null"?t.location.origin:t.location.href),Nt(o,"No window.location.(origin|href) available to create URL");let c=typeof n=="string"?n:Il(n);return c=c.replace(/ $/,"%20"),!a&&i2.test(c)&&(c=o+c),new URL(c,o)}function l2(t,n,a="/"){return I3(t,n,a,!1)}function I3(t,n,a,o,c){let l=typeof n=="string"?vi(n):n,d=Na(l.pathname||"/",a);if(d==null)return null;let m=U3(t),p=null,g=X3(d);for(let v=0;p==null&&v{let v={relativePath:g===void 0?d.path||"":g,caseSensitive:d.caseSensitive===!0,childrenIndex:m,route:d};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(o)&&p)return;Nt(v.relativePath.startsWith(o),`Absolute route path "${v.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(o.length)}let b=Cr([o,v.relativePath]),w=a.concat(v);d.children&&d.children.length>0&&(Nt(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${b}".`),c2(d.children,n,w,b,p)),!(d.path==null&&!d.index)&&n.push({path:b,score:q3(b,d.index),routesMeta:w.map((y,C)=>{let[S,E]=f2(y.relativePath,y.caseSensitive,C===w.length-1);return{...y,matcher:S,compiledParams:E}})})};return t.forEach((d,m)=>{var p;if(d.path===""||!((p=d.path)!=null&&p.includes("?")))l(d,m);else for(let g of u2(d.path))l(d,m,!0,g)}),n}function u2(t){let n=t.split("/");if(n.length===0)return[];let[a,...o]=n,c=a.endsWith("?"),l=a.replace(/\?$/,"");if(o.length===0)return c?[l,""]:[l];let d=u2(o.join("/")),m=[];return m.push(...d.map(p=>p===""?l:[l,p].join("/"))),c&&m.push(...d),m.map(p=>t.startsWith("/")&&p===""?"/":p)}function B3(t){t.sort((n,a)=>n.score!==a.score?a.score-n.score:K3(n.routesMeta.map(o=>o.childrenIndex),a.routesMeta.map(o=>o.childrenIndex)))}var $3=/^:[\w-]+$/,H3=3,G3=2,V3=1,F3=10,Y3=-2,Oy=t=>t==="*";function q3(t,n){let a=t.split("/"),o=a.length;return a.some(Oy)&&(o+=Y3),n&&(o+=G3),a.filter(c=>!Oy(c)).reduce((c,l)=>c+($3.test(l)?H3:l===""?V3:F3),o)}function K3(t,n){return t.length===n.length&&t.slice(0,-1).every((o,c)=>o===n[c])?t[t.length-1]-n[n.length-1]:0}function W3(t,n,a=!1){let{routesMeta:o}=t,c={},l="/",d=[];for(let m=0;m{if(v==="*"){let C=m[w]||"";d=l.slice(0,l.length-C.length).replace(/(.)\/+$/,"$1")}const y=m[w];return b&&!y?g[v]=void 0:g[v]=(y||"").replace(/%2F/g,"/"),g},{}),pathname:l,pathnameBase:d,pattern:t}}function f2(t,n=!1,a=!0){fr(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let o=[],c="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,m,p,g,v)=>{if(o.push({paramName:m,isOptional:p!=null}),p){let b=v.charAt(g+d.length);return b&&b!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(o.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,n?void 0:"i"),o]}function X3(t){try{return t.split("/").map(n=>decodeURIComponent(n).replace(/\//g,"%2F")).join("/")}catch(n){return fr(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${n}).`),t}}function Na(t,n){if(n==="/")return t;if(!t.toLowerCase().startsWith(n.toLowerCase()))return null;let a=n.endsWith("/")?n.length-1:n.length,o=t.charAt(a);return o&&o!=="/"?null:t.slice(a)||"/"}function Z3(t,n="/"){let{pathname:a,search:o="",hash:c=""}=typeof t=="string"?vi(t):t,l;return a?(a=m2(a),a.startsWith("/")?l=Ly(a.substring(1),"/"):l=Ly(a,n)):l=n,{pathname:l,search:eN(o),hash:tN(c)}}function Ly(t,n){let a=ad(n).split("/");return t.split("/").forEach(c=>{c===".."?a.length>1&&a.pop():c!=="."&&a.push(c)}),a.length>1?a.join("/"):"/"}function vp(t,n,a,o){return`Cannot include a '${t}' 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 Q3(t){return t.filter((n,a)=>a===0||n.route.path&&n.route.path.length>0)}function Qh(t){let n=Q3(t);return n.map((a,o)=>o===n.length-1?a.pathname:a.pathnameBase)}function xd(t,n,a,o=!1){let c;typeof t=="string"?c=vi(t):(c={...t},Nt(!c.pathname||!c.pathname.includes("?"),vp("?","pathname","search",c)),Nt(!c.pathname||!c.pathname.includes("#"),vp("#","pathname","hash",c)),Nt(!c.search||!c.search.includes("#"),vp("#","search","hash",c)));let l=t===""||c.pathname==="",d=l?"/":c.pathname,m;if(d==null)m=a;else{let b=n.length-1;if(!o&&d.startsWith("..")){let w=d.split("/");for(;w[0]==="..";)w.shift(),b-=1;c.pathname=w.join("/")}m=b>=0?n[b]:"/"}let p=Z3(c,m),g=d&&d!=="/"&&d.endsWith("/"),v=(l||d===".")&&a.endsWith("/");return!p.pathname.endsWith("/")&&(g||v)&&(p.pathname+="/"),p}var m2=t=>t.replace(/[\\/]{2,}/g,"/"),Cr=t=>m2(t.join("/")),ad=t=>t.replace(/\/+$/,""),J3=t=>ad(t).replace(/^\/*/,"/"),eN=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,tN=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,nN=class{constructor(t,n,a,o=!1){this.status=t,this.statusText=n||"",this.internal=o,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function rN(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function aN(t){let n=t.map(a=>a.route.path).filter(Boolean);return Cr(n)||"/"}var p2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function h2(t,n){let a=t;if(typeof a!="string"||!Zh.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let o=a,c=!1;if(p2)try{let l=new URL(window.location.href),d=i2.test(a)?new URL(D3(a,l.protocol)):new URL(a),m=Na(d.pathname,n);d.origin===l.origin&&m!=null?a=m+d.search+d.hash:c=!0}catch{fr(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:c,to:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var g2=["POST","PUT","PATCH","DELETE"];new Set(g2);var sN=["GET",...g2];new Set(sN);var oN=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function iN(t){try{return oN.includes(new URL(t).protocol)}catch{return!1}}var bi=f.createContext(null);bi.displayName="DataRouter";var vd=f.createContext(null);vd.displayName="DataRouterState";var x2=f.createContext(!1);function lN(){return f.useContext(x2)}var v2=f.createContext({isTransitioning:!1});v2.displayName="ViewTransition";var cN=f.createContext(new Map);cN.displayName="Fetchers";var uN=f.createContext(null);uN.displayName="Await";var qn=f.createContext(null);qn.displayName="Navigation";var Jl=f.createContext(null);Jl.displayName="Location";var Er=f.createContext({outlet:null,matches:[],isDataRoute:!1});Er.displayName="Route";var Jh=f.createContext(null);Jh.displayName="RouteError";var b2="REACT_ROUTER_ERROR",dN="REDIRECT",fN="ROUTE_ERROR_RESPONSE";function mN(t){if(t.startsWith(`${b2}:${dN}:{`))try{let n=JSON.parse(t.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 pN(t){if(t.startsWith(`${b2}:${fN}:{`))try{let n=JSON.parse(t.slice(40));if(typeof n=="object"&&n&&typeof n.status=="number"&&typeof n.statusText=="string")return new nN(n.status,n.statusText,n.data)}catch{}}function hN(t,{relative:n}={}){Nt(yi(),"useHref() may be used only in the context of a component.");let{basename:a,navigator:o}=f.useContext(qn),{hash:c,pathname:l,search:d}=ec(t,{relative:n}),m=l;return a!=="/"&&(m=l==="/"?a:Cr([a,l])),o.createHref({pathname:m,search:d,hash:c})}function yi(){return f.useContext(Jl)!=null}function Kn(){return Nt(yi(),"useLocation() may be used only in the context of a component."),f.useContext(Jl).location}var y2="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function w2(t){f.useContext(qn).static||f.useLayoutEffect(t)}function ao(){let{isDataRoute:t}=f.useContext(Er);return t?RN():gN()}function gN(){Nt(yi(),"useNavigate() may be used only in the context of a component.");let t=f.useContext(bi),{basename:n,navigator:a}=f.useContext(qn),{matches:o}=f.useContext(Er),{pathname:c}=Kn(),l=JSON.stringify(Qh(o)),d=f.useRef(!1);return w2(()=>{d.current=!0}),f.useCallback((p,g={})=>{if(fr(d.current,y2),!d.current)return;if(typeof p=="number"){a.go(p);return}let v=xd(p,JSON.parse(l),c,g.relative==="path");t==null&&n!=="/"&&(v.pathname=v.pathname==="/"?n:Cr([n,v.pathname])),(g.replace?a.replace:a.push)(v,g.state,g)},[n,a,l,c,t])}var xN=f.createContext(null);function vN(t){let n=f.useContext(Er).outlet;return f.useMemo(()=>n&&f.createElement(xN.Provider,{value:t},n),[n,t])}function ec(t,{relative:n}={}){let{matches:a}=f.useContext(Er),{pathname:o}=Kn(),c=JSON.stringify(Qh(a));return f.useMemo(()=>xd(t,JSON.parse(c),o,n==="path"),[t,c,o,n])}function bN(t,n){return j2(t,n)}function j2(t,n,a){var E;Nt(yi(),"useRoutes() may be used only in the context of a component.");let{navigator:o}=f.useContext(qn),{matches:c}=f.useContext(Er),l=c[c.length-1],d=l?l.params:{},m=l?l.pathname:"/",p=l?l.pathnameBase:"/",g=l&&l.route;{let k=g&&g.path||"";S2(m,!g||k.endsWith("*")||k.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. + */var Zh=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,i2=/^[\\/]{2}/;function D3(t,n){return n+t.replace(/\\/g,"/")}var Ay="popstate";function _y(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function O3(t={}){function n(o,c){var g;let l=(g=c.state)==null?void 0:g.masked,{pathname:d,search:m,hash:p}=l||o.location;return Qp("",{pathname:d,search:m,hash:p},c.state&&c.state.usr||null,c.state&&c.state.key||"default",l?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function a(o,c){return typeof c=="string"?c:Il(c)}return z3(n,a,null,t)}function kt(t,n){if(t===!1||t===null||typeof t>"u")throw new Error(n)}function pr(t,n){if(!t){typeof console<"u"&&console.warn(n);try{throw new Error(n)}catch{}}}function L3(){return Math.random().toString(36).substring(2,10)}function Dy(t,n){return{usr:t.state,key:t.key,idx:n,masked:t.mask?{pathname:t.pathname,search:t.search,hash:t.hash}:void 0}}function Qp(t,n,a=null,o,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof n=="string"?hi(n):n,state:a,key:n&&n.key||o||L3(),mask:c}}function Il({pathname:t="/",search:n="",hash:a=""}){return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),a&&a!=="#"&&(t+=a.charAt(0)==="#"?a:"#"+a),t}function hi(t){let n={};if(t){let a=t.indexOf("#");a>=0&&(n.hash=t.substring(a),t=t.substring(0,a));let o=t.indexOf("?");o>=0&&(n.search=t.substring(o),t=t.substring(0,o)),t&&(n.pathname=t)}return n}function z3(t,n,a,o={}){let{window:c=document.defaultView,v5Compat:l=!1}=o,d=c.history,m="POP",p=null,g=b();g==null&&(g=0,d.replaceState({...d.state,idx:g},""));function b(){return(d.state||{idx:null}).idx}function v(){m="POP";let N=b(),E=N==null?null:N-g;g=N,p&&p({action:m,location:S.location,delta:E})}function w(N,E){m="PUSH";let T=_y(N)?N:Qp(S.location,N,E);g=b()+1;let M=Dy(T,g),k=S.createHref(T.mask||T);try{d.pushState(M,"",k)}catch(_){if(_ instanceof DOMException&&_.name==="DataCloneError")throw _;c.location.assign(k)}l&&p&&p({action:m,location:S.location,delta:1})}function y(N,E){m="REPLACE";let T=_y(N)?N:Qp(S.location,N,E);g=b();let M=Dy(T,g),k=S.createHref(T.mask||T);d.replaceState(M,"",k),l&&p&&p({action:m,location:S.location,delta:0})}function C(N){return P3(c,N)}let S={get action(){return m},get location(){return t(c,d)},listen(N){if(p)throw new Error("A history only accepts one active listener");return c.addEventListener(Ay,v),p=N,()=>{c.removeEventListener(Ay,v),p=null}},createHref(N){return n(c,N)},createURL:C,encodeLocation(N){let E=C(N);return{pathname:E.pathname,search:E.search,hash:E.hash}},push:w,replace:y,go(N){return d.go(N)}};return S}function P3(t,n,a=!1){let o="http://localhost";t&&(o=t.location.origin!=="null"?t.location.origin:t.location.href),kt(o,"No window.location.(origin|href) available to create URL");let c=typeof n=="string"?n:Il(n);return c=c.replace(/ $/,"%20"),!a&&i2.test(c)&&(c=o+c),new URL(c,o)}function l2(t,n,a="/"){return I3(t,n,a,!1)}function I3(t,n,a,o,c){let l=typeof n=="string"?hi(n):n,d=Na(l.pathname||"/",a);if(d==null)return null;let m=U3(t),p=null,g=X3(d);for(let b=0;p==null&&b{let b={relativePath:g===void 0?d.path||"":g,caseSensitive:d.caseSensitive===!0,childrenIndex:m,route:d};if(b.relativePath.startsWith("/")){if(!b.relativePath.startsWith(o)&&p)return;kt(b.relativePath.startsWith(o),`Absolute route path "${b.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),b.relativePath=b.relativePath.slice(o.length)}let v=Sr([o,b.relativePath]),w=a.concat(b);d.children&&d.children.length>0&&(kt(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),c2(d.children,n,w,v,p)),!(d.path==null&&!d.index)&&n.push({path:v,score:q3(v,d.index),routesMeta:w.map((y,C)=>{let[S,N]=f2(y.relativePath,y.caseSensitive,C===w.length-1);return{...y,matcher:S,compiledParams:N}})})};return t.forEach((d,m)=>{var p;if(d.path===""||!((p=d.path)!=null&&p.includes("?")))l(d,m);else for(let g of u2(d.path))l(d,m,!0,g)}),n}function u2(t){let n=t.split("/");if(n.length===0)return[];let[a,...o]=n,c=a.endsWith("?"),l=a.replace(/\?$/,"");if(o.length===0)return c?[l,""]:[l];let d=u2(o.join("/")),m=[];return m.push(...d.map(p=>p===""?l:[l,p].join("/"))),c&&m.push(...d),m.map(p=>t.startsWith("/")&&p===""?"/":p)}function B3(t){t.sort((n,a)=>n.score!==a.score?a.score-n.score:K3(n.routesMeta.map(o=>o.childrenIndex),a.routesMeta.map(o=>o.childrenIndex)))}var $3=/^:[\w-]+$/,H3=3,G3=2,V3=1,F3=10,Y3=-2,Oy=t=>t==="*";function q3(t,n){let a=t.split("/"),o=a.length;return a.some(Oy)&&(o+=Y3),n&&(o+=G3),a.filter(c=>!Oy(c)).reduce((c,l)=>c+($3.test(l)?H3:l===""?V3:F3),o)}function K3(t,n){return t.length===n.length&&t.slice(0,-1).every((o,c)=>o===n[c])?t[t.length-1]-n[n.length-1]:0}function W3(t,n,a=!1){let{routesMeta:o}=t,c={},l="/",d=[];for(let m=0;m{if(b==="*"){let C=m[w]||"";d=l.slice(0,l.length-C.length).replace(/(.)\/+$/,"$1")}const y=m[w];return v&&!y?g[b]=void 0:g[b]=(y||"").replace(/%2F/g,"/"),g},{}),pathname:l,pathnameBase:d,pattern:t}}function f2(t,n=!1,a=!0){pr(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let o=[],c="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,m,p,g,b)=>{if(o.push({paramName:m,isOptional:p!=null}),p){let v=b.charAt(g+d.length);return v&&v!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(o.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,n?void 0:"i"),o]}function X3(t){try{return t.split("/").map(n=>decodeURIComponent(n).replace(/\//g,"%2F")).join("/")}catch(n){return pr(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${n}).`),t}}function Na(t,n){if(n==="/")return t;if(!t.toLowerCase().startsWith(n.toLowerCase()))return null;let a=n.endsWith("/")?n.length-1:n.length,o=t.charAt(a);return o&&o!=="/"?null:t.slice(a)||"/"}function Z3(t,n="/"){let{pathname:a,search:o="",hash:c=""}=typeof t=="string"?hi(t):t,l;return a?(a=m2(a),a.startsWith("/")?l=Ly(a.substring(1),"/"):l=Ly(a,n)):l=n,{pathname:l,search:eN(o),hash:tN(c)}}function Ly(t,n){let a=ad(n).split("/");return t.split("/").forEach(c=>{c===".."?a.length>1&&a.pop():c!=="."&&a.push(c)}),a.length>1?a.join("/"):"/"}function bp(t,n,a,o){return`Cannot include a '${t}' 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 Q3(t){return t.filter((n,a)=>a===0||n.route.path&&n.route.path.length>0)}function Qh(t){let n=Q3(t);return n.map((a,o)=>o===n.length-1?a.pathname:a.pathnameBase)}function xd(t,n,a,o=!1){let c;typeof t=="string"?c=hi(t):(c={...t},kt(!c.pathname||!c.pathname.includes("?"),bp("?","pathname","search",c)),kt(!c.pathname||!c.pathname.includes("#"),bp("#","pathname","hash",c)),kt(!c.search||!c.search.includes("#"),bp("#","search","hash",c)));let l=t===""||c.pathname==="",d=l?"/":c.pathname,m;if(d==null)m=a;else{let v=n.length-1;if(!o&&d.startsWith("..")){let w=d.split("/");for(;w[0]==="..";)w.shift(),v-=1;c.pathname=w.join("/")}m=v>=0?n[v]:"/"}let p=Z3(c,m),g=d&&d!=="/"&&d.endsWith("/"),b=(l||d===".")&&a.endsWith("/");return!p.pathname.endsWith("/")&&(g||b)&&(p.pathname+="/"),p}var m2=t=>t.replace(/[\\/]{2,}/g,"/"),Sr=t=>m2(t.join("/")),ad=t=>t.replace(/\/+$/,""),J3=t=>ad(t).replace(/^\/*/,"/"),eN=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,tN=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,nN=class{constructor(t,n,a,o=!1){this.status=t,this.statusText=n||"",this.internal=o,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function rN(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function aN(t){let n=t.map(a=>a.route.path).filter(Boolean);return Sr(n)||"/"}var p2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function h2(t,n){let a=t;if(typeof a!="string"||!Zh.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let o=a,c=!1;if(p2)try{let l=new URL(window.location.href),d=i2.test(a)?new URL(D3(a,l.protocol)):new URL(a),m=Na(d.pathname,n);d.origin===l.origin&&m!=null?a=m+d.search+d.hash:c=!0}catch{pr(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:c,to:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var g2=["POST","PUT","PATCH","DELETE"];new Set(g2);var sN=["GET",...g2];new Set(sN);var oN=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function iN(t){try{return oN.includes(new URL(t).protocol)}catch{return!1}}var gi=f.createContext(null);gi.displayName="DataRouter";var bd=f.createContext(null);bd.displayName="DataRouterState";var x2=f.createContext(!1);function lN(){return f.useContext(x2)}var b2=f.createContext({isTransitioning:!1});b2.displayName="ViewTransition";var cN=f.createContext(new Map);cN.displayName="Fetchers";var uN=f.createContext(null);uN.displayName="Await";var qn=f.createContext(null);qn.displayName="Navigation";var Jl=f.createContext(null);Jl.displayName="Location";var Tr=f.createContext({outlet:null,matches:[],isDataRoute:!1});Tr.displayName="Route";var Jh=f.createContext(null);Jh.displayName="RouteError";var v2="REACT_ROUTER_ERROR",dN="REDIRECT",fN="ROUTE_ERROR_RESPONSE";function mN(t){if(t.startsWith(`${v2}:${dN}:{`))try{let n=JSON.parse(t.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 pN(t){if(t.startsWith(`${v2}:${fN}:{`))try{let n=JSON.parse(t.slice(40));if(typeof n=="object"&&n&&typeof n.status=="number"&&typeof n.statusText=="string")return new nN(n.status,n.statusText,n.data)}catch{}}function hN(t,{relative:n}={}){kt(xi(),"useHref() may be used only in the context of a component.");let{basename:a,navigator:o}=f.useContext(qn),{hash:c,pathname:l,search:d}=ec(t,{relative:n}),m=l;return a!=="/"&&(m=l==="/"?a:Sr([a,l])),o.createHref({pathname:m,search:d,hash:c})}function xi(){return f.useContext(Jl)!=null}function Kn(){return kt(xi(),"useLocation() may be used only in the context of a component."),f.useContext(Jl).location}var y2="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function w2(t){f.useContext(qn).static||f.useLayoutEffect(t)}function ao(){let{isDataRoute:t}=f.useContext(Tr);return t?RN():gN()}function gN(){kt(xi(),"useNavigate() may be used only in the context of a component.");let t=f.useContext(gi),{basename:n,navigator:a}=f.useContext(qn),{matches:o}=f.useContext(Tr),{pathname:c}=Kn(),l=JSON.stringify(Qh(o)),d=f.useRef(!1);return w2(()=>{d.current=!0}),f.useCallback((p,g={})=>{if(pr(d.current,y2),!d.current)return;if(typeof p=="number"){a.go(p);return}let b=xd(p,JSON.parse(l),c,g.relative==="path");t==null&&n!=="/"&&(b.pathname=b.pathname==="/"?n:Sr([n,b.pathname])),(g.replace?a.replace:a.push)(b,g.state,g)},[n,a,l,c,t])}var xN=f.createContext(null);function bN(t){let n=f.useContext(Tr).outlet;return f.useMemo(()=>n&&f.createElement(xN.Provider,{value:t},n),[n,t])}function ec(t,{relative:n}={}){let{matches:a}=f.useContext(Tr),{pathname:o}=Kn(),c=JSON.stringify(Qh(a));return f.useMemo(()=>xd(t,JSON.parse(c),o,n==="path"),[t,c,o,n])}function vN(t,n){return j2(t,n)}function j2(t,n,a){var N;kt(xi(),"useRoutes() may be used only in the context of a component.");let{navigator:o}=f.useContext(qn),{matches:c}=f.useContext(Tr),l=c[c.length-1],d=l?l.params:{},m=l?l.pathname:"/",p=l?l.pathnameBase:"/",g=l&&l.route;{let E=g&&g.path||"";S2(m,!g||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 v=Kn(),b;if(n){let k=typeof n=="string"?vi(n):n;Nt(p==="/"||((E=k.pathname)==null?void 0:E.startsWith(p)),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${p}" but pathname "${k.pathname}" was given in the \`location\` prop.`),b=k}else b=v;let w=b.pathname||"/",y=w;if(p!=="/"){let k=p.replace(/^\//,"").split("/");y="/"+w.replace(/^\//,"").split("/").slice(k.length).join("/")}let C=a&&a.state.matches.length?a.state.matches.map(k=>Object.assign(k,{route:a.manifest[k.route.id]||k.route})):l2(t,{pathname:y});fr(g||C!=null,`No routes matched location "${b.pathname}${b.search}${b.hash}" `),fr(C==null||C[C.length-1].route.element!==void 0||C[C.length-1].route.Component!==void 0||C[C.length-1].route.lazy!==void 0,`Matched leaf route at location "${b.pathname}${b.search}${b.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 S=SN(C&&C.map(k=>Object.assign({},k,{params:Object.assign({},d,k.params),pathname:Cr([p,o.encodeLocation?o.encodeLocation(k.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:k.pathname]),pathnameBase:k.pathnameBase==="/"?p:Cr([p,o.encodeLocation?o.encodeLocation(k.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:k.pathnameBase])})),c,a);return n&&S?f.createElement(Jl.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...b},navigationType:"POP"}},S):S}function yN(){let t=MN(),n=rN(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),a=t instanceof Error?t.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},l={padding:"2px 4px",backgroundColor:o},d=null;return console.error("Error handled by React Router default ErrorBoundary:",t),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:l},"ErrorBoundary")," or"," ",f.createElement("code",{style:l},"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:c},a):null,d)}var wN=f.createElement(yN,null),C2=class extends f.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){this.props.onError?this.props.onError(t,n):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const a=pN(t.digest);a&&(t=a)}let n=t!==void 0?f.createElement(Er.Provider,{value:this.props.routeContext},f.createElement(Jh.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?f.createElement(jN,{error:t},n):n}};C2.contextType=x2;var bp=new WeakMap;function jN({children:t,error:n}){let{basename:a}=f.useContext(qn);if(typeof n=="object"&&n&&"digest"in n&&typeof n.digest=="string"){let o=mN(n.digest);if(o){let c=bp.get(n);if(c)throw c;let l=h2(o.location,a),d=l.absoluteURL||l.to;if(iN(d))throw new Error("Invalid redirect location");if(p2&&!bp.get(n))if(l.isExternal||o.reloadDocument)window.location.href=d;else{const m=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(l.to,{replace:o.replace}));throw bp.set(n,m),m}return f.createElement("meta",{httpEquiv:"refresh",content:`0;url=${d}`})}}return t}function CN({routeContext:t,match:n,children:a}){let o=f.useContext(bi);return o&&o.static&&o.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=n.route.id),f.createElement(Er.Provider,{value:t},a)}function SN(t,n=[],a){let o=a==null?void 0:a.state;if(t==null){if(!o)return null;if(o.errors)t=o.matches;else if(n.length===0&&!o.initialized&&o.matches.length>0)t=o.matches;else return null}let c=t,l=o==null?void 0:o.errors;if(l!=null){let v=c.findIndex(b=>b.route.id&&(l==null?void 0:l[b.route.id])!==void 0);Nt(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),c=c.slice(0,Math.min(c.length,v+1))}let d=!1,m=-1;if(a&&o){d=o.renderFallback;for(let v=0;v=0?c=c.slice(0,m+1):c=[c[0]];break}}}}let p=a==null?void 0:a.onError,g=o&&p?(v,b)=>{var w,y;p(v,{location:o.location,params:((y=(w=o.matches)==null?void 0:w[0])==null?void 0:y.params)??{},pattern:aN(o.matches),errorInfo:b})}:void 0;return c.reduceRight((v,b,w)=>{let y,C=!1,S=null,E=null;o&&(y=l&&b.route.id?l[b.route.id]:void 0,S=b.route.errorElement||wN,d&&(m<0&&w===0?(S2("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,E=null):m===w&&(C=!0,E=b.route.hydrateFallbackElement||null)));let k=n.concat(c.slice(0,w+1)),N=()=>{let T;return y?T=S:C?T=E:b.route.Component?T=f.createElement(b.route.Component,null):b.route.element?T=b.route.element:T=v,f.createElement(CN,{match:b,routeContext:{outlet:v,matches:k,isDataRoute:o!=null},children:T})};return o&&(b.route.ErrorBoundary||b.route.errorElement||w===0)?f.createElement(C2,{location:o.location,revalidation:o.revalidation,component:S,error:y,children:N(),routeContext:{outlet:null,matches:k,isDataRoute:!0},onError:g}):N()},null)}function eg(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function NN(t){let n=f.useContext(bi);return Nt(n,eg(t)),n}function EN(t){let n=f.useContext(vd);return Nt(n,eg(t)),n}function kN(t){let n=f.useContext(Er);return Nt(n,eg(t)),n}function tg(t){let n=kN(t),a=n.matches[n.matches.length-1];return Nt(a.route.id,`${t} can only be used on routes that contain a unique "id"`),a.route.id}function TN(){return tg("useRouteId")}function MN(){var o;let t=f.useContext(Jh),n=EN("useRouteError"),a=tg("useRouteError");return t!==void 0?t:(o=n.errors)==null?void 0:o[a]}function RN(){let{router:t}=NN("useNavigate"),n=tg("useNavigate"),a=f.useRef(!1);return w2(()=>{a.current=!0}),f.useCallback(async(c,l={})=>{fr(a.current,y2),a.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:n,...l}))},[t,n])}var zy={};function S2(t,n,a){!n&&!zy[t]&&(zy[t]=!0,fr(!1,a))}f.memo(AN);function AN({routes:t,manifest:n,future:a,state:o,isStatic:c,onError:l}){return j2(t,void 0,{manifest:n,state:o,isStatic:c,onError:l})}function ya({to:t,replace:n,state:a,relative:o}){Nt(yi()," may be used only in the context of a component.");let{static:c}=f.useContext(qn);fr(!c," 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:l}=f.useContext(Er),{pathname:d}=Kn(),m=ao(),p=xd(t,Qh(l),d,o==="path"),g=JSON.stringify(p);return f.useEffect(()=>{m(JSON.parse(g),{replace:n,state:a,relative:o})},[m,g,o,n,a]),null}function _N(t){return vN(t.context)}function cn(t){Nt(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function DN({basename:t="/",children:n=null,location:a,navigationType:o="POP",navigator:c,static:l=!1,useTransitions:d}){Nt(!yi(),"You cannot render a inside another . You should never have more than one in your app.");let m=t.replace(/^\/*/,"/"),p=f.useMemo(()=>({basename:m,navigator:c,static:l,useTransitions:d,future:{}}),[m,c,l,d]);typeof a=="string"&&(a=vi(a));let{pathname:g="/",search:v="",hash:b="",state:w=null,key:y="default",mask:C}=a,S=f.useMemo(()=>{let E=Na(g,m);return E==null?null:{location:{pathname:E,search:v,hash:b,state:w,key:y,mask:C},navigationType:o}},[m,g,v,b,w,y,o,C]);return fr(S!=null,` is not able to match the URL "${g}${v}${b}" because it does not start with the basename, so the won't render anything.`),S==null?null:f.createElement(qn.Provider,{value:p},f.createElement(Jl.Provider,{children:n,value:S}))}function Py({children:t,location:n}){return bN(Jp(t),n)}function Jp(t,n=[]){let a=[];return f.Children.forEach(t,(o,c)=>{if(!f.isValidElement(o))return;let l=[...n,c];if(o.type===f.Fragment){a.push.apply(a,Jp(o.props.children,l));return}Nt(o.type===cn,`[${typeof o.type=="string"?o.type:o.type.name}] is not a component. All component children of must be a or `),Nt(!o.props.index||!o.props.children,"An index route cannot have child routes.");let d={id:o.props.id||l.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=Jp(o.props.children,l)),a.push(d)}),a}var Fu="get",Yu="application/x-www-form-urlencoded";function bd(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function ON(t){return bd(t)&&t.tagName.toLowerCase()==="button"}function LN(t){return bd(t)&&t.tagName.toLowerCase()==="form"}function zN(t){return bd(t)&&t.tagName.toLowerCase()==="input"}function PN(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function IN(t,n){return t.button===0&&(!n||n==="_self")&&!PN(t)}function eh(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((n,a)=>{let o=t[a];return n.concat(Array.isArray(o)?o.map(c=>[a,c]):[[a,o]])},[]))}function UN(t,n){let a=eh(t);return n&&n.forEach((o,c)=>{a.has(c)||n.getAll(c).forEach(l=>{a.append(c,l)})}),a}var ku=null;function BN(){if(ku===null)try{new FormData(document.createElement("form"),0),ku=!1}catch{ku=!0}return ku}var $N=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function yp(t){return t!=null&&!$N.has(t)?(fr(!1,`"${t}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${Yu}"`),null):t}function HN(t,n){let a,o,c,l,d;if(LN(t)){let m=t.getAttribute("action");o=m?Na(m,n):null,a=t.getAttribute("method")||Fu,c=yp(t.getAttribute("enctype"))||Yu,l=new FormData(t)}else if(ON(t)||zN(t)&&(t.type==="submit"||t.type==="image")){let m=t.form;if(m==null)throw new Error('Cannot submit a `,_=>`${M}-${_.id}`)}const E=w`
${n.i18n.searchDescription}
${n.i18n.skinToneDescription}
${y(n.skinTones,(N,T)=>w`
${N}
`,N=>N)}
${y(n.currentEmojisWithCategories,(N,T)=>w`
${C(N.emojis,n.searchMode,"emo")}
`,N=>N.category)}
`,k=(N,T)=>{for(const M of t.querySelectorAll(`[${N}]`))T(M,M.getAttribute(N))};if(p){t.appendChild(E);for(const N of["click","focusout","input","keydown","keyup"])k(`data-on-${N}`,(T,M)=>{T.addEventListener(N,o[M])});k("data-ref",(N,T)=>{l[T]=N}),d.addEventListener("abort",()=>{t.removeChild(E)})}k("data-action",(N,T)=>{let M=m.get(T);M||m.set(T,M=new WeakSet),M.has(N)||(M.add(N),c[T](N))})}const md=typeof queueMicrotask=="function"?queueMicrotask:t=>Promise.resolve().then(t);function oO(t){let n=!1,a;const o=new Map,c=new Set;let l;const d=()=>{if(n)return;const g=[...c];c.clear();try{for(const v of g)v()}finally{l=!1,c.size&&(l=!0,md(d))}},m=new Proxy({},{get(g,v){if(a){let b=o.get(v);b||(b=new Set,o.set(v,b)),b.add(a)}return g[v]},set(g,v,b){if(g[v]!==b){g[v]=b;const w=o.get(v);if(w){for(const y of w)c.add(y);l||(l=!0,md(d))}}return!0}}),p=g=>{const v=()=>{const b=a;a=v;try{return g()}finally{a=b}};return v()};return t.addEventListener("abort",()=>{n=!0}),{state:m,createEffect:p}}function qp(t,n,a){if(t.length!==n.length)return!1;for(let o=0;o{c.disconnect()})),c.observe(t)}}const Kp=[],{assign:$u}=Object;function lO(t,n){const a={},o=new AbortController,c=o.signal,{state:l,createEffect:d}=oO(c),m=new Map;$u(l,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),$u(l,n),$u(l,{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:kD,isRtl:!1,currentGroupIndex:0,groups:Hp,databaseLoaded:!1,activeSearchItemId:void 0}),d(()=>{l.currentGroup!==l.groups[l.currentGroupIndex]&&(l.currentGroup=l.groups[l.currentGroupIndex])});const p=B=>{t.getElementById(B).focus()},g=B=>t.getElementById(`emo-${B.id}`),v=(B,ie)=>{a.rootElement.dispatchEvent(new CustomEvent(B,{detail:ie,bubbles:!0,composed:!0}))},b=(B,ie)=>B.id===ie.id,w=(B,ie)=>{const{category:we,emojis:Ce}=B,{category:ze,emojis:Ke}=ie;return we!==ze?!1:qp(Ce,Ke,b)},y=B=>{qp(l.currentEmojis,B,b)||(l.currentEmojis=B)},C=B=>{l.searchMode!==B&&(l.searchMode=B)},S=B=>{qp(l.currentEmojisWithCategories,B,w)||(l.currentEmojisWithCategories=B)},E=(B,ie)=>ie&&B.skins&&B.skins[ie]||B.unicode,T={labelWithSkin:(B,ie)=>VD([B.name||E(B,ie),B.annotation,...B.shortcodes||Kp].filter(Boolean)).join(", "),titleForEmoji:B=>B.annotation||(B.shortcodes||Kp).join(", "),unicodeWithSkin:E},M={onClickSkinToneButton:X,onEmojiClick:D,onNavClick:ae,onNavKeydown:re,onSearchKeydown:Z,onSkinToneOptionsClick:H,onSkinToneOptionsFocusOut:ge,onSkinToneOptionsKeydown:xe,onSkinToneOptionsKeyup:q,onSearchInput:me},_={calculateEmojiGridStyle:te,updateOnIntersection:K};let R=!0;d(()=>{sO(t,l,T,M,_,a,c,m,R),R=!1}),l.emojiVersion||Vp().then(B=>{B||(l.message=l.i18n.emojiUnsupportedMessage)}),d(()=>{async function B(){let ie=!1;const we=setTimeout(()=>{ie=!0,l.message=l.i18n.loadingMessage},ND);try{await l.database.ready(),l.databaseLoaded=!0}catch(Ce){console.error(Ce),l.message=l.i18n.networkErrorMessage}finally{clearTimeout(we),ie&&(ie=!1,l.message="")}}l.database&&B()}),d(()=>{l.pickerStyle=` + */const FT=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],zj=Ra("X",FT),zg=ET,Pg=kT,YT=f.forwardRef(({className:t,inset:n,children:a,...o},c)=>s.jsxs(Aj,{ref:c,className:pe("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",n&&"pl-8",t),...o,children:[a,s.jsx(LT,{className:"ml-auto"})]}));YT.displayName=Aj.displayName;const qT=f.forwardRef(({className:t,...n},a)=>s.jsx(_j,{ref:a,className:pe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...n}));qT.displayName=_j.displayName;const Fd=f.forwardRef(({className:t,sideOffset:n=4,...a},o)=>s.jsx(TT,{children:s.jsx(Sj,{ref:o,sideOffset:n,className:pe("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...a})}));Fd.displayName=Sj.displayName;const Vl=f.forwardRef(({className:t,inset:n,...a},o)=>s.jsx(Ej,{ref:o,className:pe("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",n&&"pl-8",t),...a}));Vl.displayName=Ej.displayName;const KT=f.forwardRef(({className:t,children:n,checked:a,...o},c)=>s.jsxs(kj,{ref:c,className:pe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:a,...o,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(Mj,{children:s.jsx(Oj,{className:"h-4 w-4"})})}),n]}));KT.displayName=kj.displayName;const WT=f.forwardRef(({className:t,children:n,...a},o)=>s.jsxs(Tj,{ref:o,className:pe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(Mj,{children:s.jsx(BT,{className:"h-2 w-2 fill-current"})})}),n]}));WT.displayName=Tj.displayName;const Ig=f.forwardRef(({className:t,inset:n,...a},o)=>s.jsx(Nj,{ref:o,className:pe("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...a}));Ig.displayName=Nj.displayName;const Fl=f.forwardRef(({className:t,...n},a)=>s.jsx(Rj,{ref:a,className:pe("-mx-1 my-1 h-px bg-muted",t),...n}));Fl.displayName=Rj.displayName;const zp=768;function XT(){const[t,n]=f.useState(void 0);return f.useEffect(()=>{const a=window.matchMedia(`(max-width: ${zp-1}px)`),o=()=>{n(window.innerWidtha.removeEventListener("change",o)},[]),!!t}const _e=f.forwardRef(({className:t,type:n,...a},o)=>s.jsx("input",{type:n,className:pe("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:o,...a}));_e.displayName="Input";var ZT=Object.defineProperty,Pj=(t,n)=>ZT(t,"name",{value:n,configurable:!0}),b0="horizontal",QT=["horizontal","vertical"],JT=f.forwardRef(Pj(function(n,a){const{decorative:o,orientation:c=b0,...l}=n,d=Ij(c)?c:b0,p=o?{role:"none"}:{"aria-orientation":d==="vertical"?d:void 0,role:"separator"};return s.jsx(Me.div,{"data-orientation":d,...p,...l,ref:a})},"Separator"));function Ij(t){return QT.includes(t)}Pj(Ij,"isValidOrientation");var Uj=JT;const Bj=f.forwardRef(({className:t,orientation:n="horizontal",decorative:a=!0,...o},c)=>s.jsx(Uj,{ref:c,decorative:a,orientation:n,className:pe("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...o}));Bj.displayName=Uj.displayName;var e7=Object.defineProperty,Wn=(t,n)=>e7(t,"name",{value:n,configurable:!0}),Ug="Dialog",[$j,BP]=bn(Ug),[t7,Rr]=$j(Ug),Bg=Wn(t=>{const{__scopeDialog:n,children:a,open:o,defaultOpen:c,onOpenChange:l,modal:d=!0}=t,m=f.useRef(null),p=f.useRef(null),[g,b]=Vr({prop:o,defaultProp:c??!1,onChange:l,caller:Ug}),[v,w]=f.useState(0),[y,C]=f.useState(0);return s.jsx(t7,{scope:n,triggerRef:m,contentRef:p,contentId:nn(),titleId:nn(),descriptionId:nn(),titlePresent:v>0,descriptionPresent:y>0,setTitleCount:w,setDescriptionCount:C,open:g,onOpenChange:b,onOpenToggle:f.useCallback(()=>b(S=>!S),[b]),modal:d,children:a})},"Dialog"),n7="DialogTrigger",r7=f.forwardRef(Wn(function(n,a){const{__scopeDialog:o,...c}=n,l=Rr(n7,o),d=Pe(a,l.triggerRef);return s.jsx(Me.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.open?l.contentId:void 0,"data-state":Kd(l.open),...c,ref:d,onClick:Ce(n.onClick,l.onOpenToggle)})},"DialogTrigger")),Hj="DialogPortal",[a7,Gj]=$j(Hj,{forceMount:void 0}),$g=Wn(t=>{const{__scopeDialog:n,forceMount:a,children:o,container:c}=t,l=Rr(Hj,n);return s.jsx(a7,{scope:n,forceMount:a,children:f.Children.map(o,d=>s.jsx(fn,{present:a||l.open,children:s.jsx(rc,{asChild:!0,container:c,children:d})}))})},"DialogPortal"),jh="DialogOverlay",oc=f.forwardRef(Wn(function(n,a){const o=Gj(jh,n.__scopeDialog),{forceMount:c=o.forceMount,...l}=n,d=Rr(jh,n.__scopeDialog);return d.modal?s.jsx(fn,{present:c||d.open,children:s.jsx(o7,{...l,ref:a})}):null},"DialogOverlay")),s7=Er("DialogOverlay.RemoveScroll"),o7=f.forwardRef(Wn(function(n,a){const{__scopeDialog:o,...c}=n,l=Rr(jh,o),d=hw(),m=Pe(a,d);return s.jsx(ac,{as:s7,allowPinchZoom:!0,shards:[l.contentRef],children:s.jsx(Me.div,{"data-state":Kd(l.open),...c,ref:m,style:{pointerEvents:"auto",...c.style}})})},"DialogOverlayImpl")),Yl="DialogContent",ic=f.forwardRef(Wn(function(n,a){const o=Gj(Yl,n.__scopeDialog),{forceMount:c=o.forceMount,...l}=n,d=Rr(Yl,n.__scopeDialog);return s.jsx(fn,{present:c||d.open,children:d.modal?s.jsx(i7,{...l,ref:a}):s.jsx(l7,{...l,ref:a})})},"DialogContent")),i7=f.forwardRef(Wn(function(n,a){const o=Rr(Yl,n.__scopeDialog),c=f.useRef(null),l=Pe(a,o.contentRef,c);return f.useEffect(()=>{const d=c.current;if(d)return $d(d)},[]),s.jsx(Vj,{...n,ref:l,trapFocus:o.open,disableOutsidePointerEvents:o.open,onCloseAutoFocus:Ce(n.onCloseAutoFocus,d=>{var m;d.preventDefault(),(m=o.triggerRef.current)==null||m.focus()}),onPointerDownOutside:Ce(n.onPointerDownOutside,d=>{const m=d.detail.originalEvent,p=m.button===0&&m.ctrlKey===!0;(m.button===2||p)&&d.preventDefault()}),onFocusOutside:Ce(n.onFocusOutside,d=>d.preventDefault())})},"DialogContentModal")),l7=f.forwardRef(Wn(function(n,a){const o=Rr(Yl,n.__scopeDialog),c=f.useRef(!1),l=f.useRef(!1);return s.jsx(Vj,{...n,ref:a,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:d=>{var m,p;(m=n.onCloseAutoFocus)==null||m.call(n,d),d.defaultPrevented||(c.current||(p=o.triggerRef.current)==null||p.focus(),d.preventDefault()),c.current=!1,l.current=!1},onInteractOutside:d=>{var g,b;(g=n.onInteractOutside)==null||g.call(n,d),d.defaultPrevented||(c.current=!0,d.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const m=d.target;((b=o.triggerRef.current)==null?void 0:b.contains(m))&&d.preventDefault(),d.detail.originalEvent.type==="focusin"&&l.current&&d.preventDefault()}})},"DialogContentNonModal")),Vj=f.forwardRef(Wn(function(n,a){const{__scopeDialog:o,trapFocus:c,onOpenAutoFocus:l,onCloseAutoFocus:d,...m}=n,p=Rr(Yl,o);return Ni(),s.jsx(s.Fragment,{children:s.jsx(Md,{asChild:!0,loop:!0,trapped:c,onMountAutoFocus:l,onUnmountAutoFocus:d,children:s.jsx(nc,{role:"dialog",id:p.contentId,"aria-describedby":p.descriptionPresent?p.descriptionId:void 0,"aria-labelledby":p.titlePresent?p.titleId:void 0,"data-state":Kd(p.open),...m,ref:a,deferPointerDownOutside:!0,onDismiss:()=>p.onOpenChange(!1)})})})},"DialogContentImpl")),c7="DialogTitle",Yd=f.forwardRef(Wn(function(n,a){const{__scopeDialog:o,...c}=n,l=Rr(c7,o),{setTitleCount:d}=l;return St(()=>(d(m=>m+1),()=>d(m=>m-1)),[d]),s.jsx(Me.h2,{id:l.titleId,...c,ref:a})},"DialogTitle")),u7="DialogDescription",qd=f.forwardRef(Wn(function(n,a){const{__scopeDialog:o,...c}=n,l=Rr(u7,o),{setDescriptionCount:d}=l;return St(()=>(d(m=>m+1),()=>d(m=>m-1)),[d]),s.jsx(Me.p,{id:l.descriptionId,...c,ref:a})},"DialogDescription")),d7="DialogClose",Fj=f.forwardRef(Wn(function(n,a){const{__scopeDialog:o,...c}=n,l=Rr(d7,o);return s.jsx(Me.button,{type:"button",...c,ref:a,onClick:Ce(n.onClick,()=>l.onOpenChange(!1))})},"DialogClose"));function Kd(t){return t?"open":"closed"}Wn(Kd,"getState");const Yj=Bg,f7=$g,qj=f.forwardRef(({className:t,...n},a)=>s.jsx(oc,{className:pe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...n,ref:a}));qj.displayName=oc.displayName;const m7=ji("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Hg=f.forwardRef(({side:t="right",className:n,children:a,...o},c)=>s.jsxs(f7,{children:[s.jsx(qj,{}),s.jsxs(ic,{ref:c,className:pe(m7({side:t}),n),...o,children:[s.jsxs(Fj,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[s.jsx(zj,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]}),a]})]}));Hg.displayName=ic.displayName;const Gg=({className:t,...n})=>s.jsx("div",{className:pe("flex flex-col space-y-2 text-center sm:text-left",t),...n});Gg.displayName="SheetHeader";const Vg=f.forwardRef(({className:t,...n},a)=>s.jsx(Yd,{ref:a,className:pe("text-lg font-semibold text-foreground",t),...n}));Vg.displayName=Yd.displayName;const Fg=f.forwardRef(({className:t,...n},a)=>s.jsx(qd,{ref:a,className:pe("text-sm text-muted-foreground",t),...n}));Fg.displayName=qd.displayName;function Ue({className:t,...n}){return s.jsx("div",{className:pe("animate-pulse rounded-md bg-primary/10",t),...n})}var p7=Object.defineProperty,h7=(t,n)=>p7(t,"name",{value:n,configurable:!0}),Kj=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),g7=f.forwardRef(h7(function(n,a){return s.jsx(Me.span,{...n,ref:a,style:{...Kj,...n.style}})},"VisuallyHidden")),x7=g7,b7=Object.defineProperty,tn=(t,n)=>b7(t,"name",{value:n,configurable:!0}),[Yg,$P]=bn("Tooltip",[Cs]),qg=Cs(),v7="TooltipProvider",y7=700,Ch="tooltip.open",[w7,Kg]=Yg(v7),j7=tn(t=>{const{__scopeTooltip:n,delayDuration:a=y7,skipDelayDuration:o=300,disableHoverableContent:c=!1,children:l}=t,d=f.useRef(!0),m=f.useRef(!1),p=f.useRef(0);return f.useEffect(()=>{const g=p.current;return()=>window.clearTimeout(g)},[]),s.jsx(w7,{scope:n,isOpenDelayedRef:d,delayDuration:a,onOpen:f.useCallback(()=>{o<=0||(window.clearTimeout(p.current),d.current=!1)},[o]),onClose:f.useCallback(()=>{o<=0||(window.clearTimeout(p.current),p.current=window.setTimeout(()=>d.current=!0,o))},[o]),isPointerInTransitRef:m,onPointerInTransitChange:f.useCallback(g=>{m.current=g},[]),disableHoverableContent:c,children:l})},"TooltipProvider"),Sh="Tooltip",[C7,lc]=Yg(Sh),S7=tn(t=>{const{__scopeTooltip:n,children:a,open:o,defaultOpen:c,onOpenChange:l,disableHoverableContent:d,delayDuration:m}=t,p=Kg(Sh,t.__scopeTooltip),g=qg(n),[b,v]=f.useState(null),[w,y]=f.useState(void 0),C=nn(),S=f.useRef(0),N=d??p.disableHoverableContent,E=m??p.delayDuration,T=f.useRef(!1),[M,k]=Vr({prop:o,defaultProp:c??!1,onChange:tn(I=>{I?(p.onOpen(),document.dispatchEvent(new CustomEvent(Ch))):p.onClose(),l==null||l(I)},"onChange"),caller:Sh}),_=f.useMemo(()=>M?T.current?"delayed-open":"instant-open":"closed",[M]),R=f.useCallback(()=>{window.clearTimeout(S.current),S.current=0,T.current=!1,k(!0)},[k]),L=f.useCallback(()=>{window.clearTimeout(S.current),S.current=0,k(!1)},[k]),ne=f.useCallback(()=>{window.clearTimeout(S.current),S.current=window.setTimeout(()=>{T.current=!0,k(!0),S.current=0},E)},[E,k]);f.useEffect(()=>()=>{S.current&&(window.clearTimeout(S.current),S.current=0)},[]);const X=w??C;return s.jsx(zd,{...g,children:s.jsx(C7,{scope:n,contentId:X,setContentId:y,open:M,stateAttribute:_,trigger:b,onTriggerChange:v,onTriggerEnter:f.useCallback(()=>{p.isOpenDelayedRef.current?ne():R()},[p.isOpenDelayedRef,ne,R]),onTriggerLeave:f.useCallback(()=>{N?L():(window.clearTimeout(S.current),S.current=0)},[L,N]),onOpen:R,onClose:L,disableHoverableContent:N,children:a})})},"Tooltip"),v0="TooltipTrigger",N7=f.forwardRef(tn(function(n,a){const{__scopeTooltip:o,...c}=n,l=lc(v0,o),d=Kg(v0,o),m=qg(o),p=f.useRef(null),g=Pe(a,p,l.onTriggerChange),b=f.useRef(!1),v=f.useRef(!1),w=f.useCallback(()=>b.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",w),[w]),s.jsx(Pd,{asChild:!0,...m,children:s.jsx(Me.button,{"aria-describedby":l.open?l.contentId:void 0,"data-state":l.stateAttribute,...c,ref:g,onPointerMove:Ce(n.onPointerMove,y=>{y.pointerType!=="touch"&&!v.current&&!d.isPointerInTransitRef.current&&(l.onTriggerEnter(),v.current=!0)}),onPointerLeave:Ce(n.onPointerLeave,()=>{l.onTriggerLeave(),v.current=!1}),onPointerDown:Ce(n.onPointerDown,()=>{l.open&&l.onClose(),b.current=!0,document.addEventListener("pointerup",w,{once:!0})}),onFocus:Ce(n.onFocus,()=>{b.current||l.onOpen()}),onBlur:Ce(n.onBlur,l.onClose),onClick:Ce(n.onClick,l.onClose)})})},"TooltipTrigger")),Wj="TooltipPortal",[E7,k7]=Yg(Wj,{forceMount:void 0}),T7=tn(t=>{const{__scopeTooltip:n,forceMount:a,children:o,container:c}=t,l=lc(Wj,n);return s.jsx(E7,{scope:n,forceMount:a,children:s.jsx(fn,{present:a||l.open,children:s.jsx(rc,{asChild:!0,container:c,children:o})})})},"TooltipPortal"),ql="TooltipContent",M7=f.forwardRef(tn(function(n,a){const o=k7(ql,n.__scopeTooltip),{forceMount:c=o.forceMount,side:l="top",...d}=n,m=lc(ql,n.__scopeTooltip);return s.jsx(fn,{present:c||m.open,children:m.disableHoverableContent?s.jsx(Xj,{side:l,...d,ref:a}):s.jsx(R7,{side:l,...d,ref:a})})},"TooltipContent")),R7=f.forwardRef(tn(function(n,a){const o=lc(ql,n.__scopeTooltip),c=Kg(ql,n.__scopeTooltip),l=f.useRef(null),d=Pe(a,l),[m,p]=f.useState(null),{trigger:g,onClose:b}=o,v=l.current,{onPointerInTransitChange:w}=c,y=f.useCallback(()=>{p(null),w(!1)},[w]),C=f.useCallback((S,N)=>{const E=S.currentTarget,T={x:S.clientX,y:S.clientY},M=Zj(T,E.getBoundingClientRect()),k=Qj(T,M),_=Jj(N.getBoundingClientRect()),R=tC([...k,..._]);p(R),w(!0)},[w]);return f.useEffect(()=>()=>y(),[y]),f.useEffect(()=>{if(g&&v){const S=tn(E=>C(E,v),"handleTriggerLeave"),N=tn(E=>C(E,g),"handleContentLeave");return g.addEventListener("pointerleave",S),v.addEventListener("pointerleave",N),()=>{g.removeEventListener("pointerleave",S),v.removeEventListener("pointerleave",N)}}},[g,v,C,y]),f.useEffect(()=>{if(m){const S=tn(N=>{const E=N.target,T={x:N.clientX,y:N.clientY},M=(g==null?void 0:g.contains(E))||(v==null?void 0:v.contains(E)),k=!eC(T,m);M?y():k&&(y(),b())},"handleTrackPointerGrace");return document.addEventListener("pointermove",S),()=>document.removeEventListener("pointermove",S)}},[g,v,m,b,y]),s.jsx(Xj,{...n,ref:d})},"TooltipContentHoverable")),A7=Q2("TooltipContent"),Xj=f.forwardRef(tn(function(n,a){const{__scopeTooltip:o,children:c,"aria-label":l,id:d,onEscapeKeyDown:m,onPointerDownOutside:p,...g}=n,b=lc(ql,o),v=qg(o),{onClose:w}=b;f.useEffect(()=>(document.addEventListener(Ch,w),()=>document.removeEventListener(Ch,w)),[w]),f.useEffect(()=>{if(b.trigger){const C=tn(S=>{S.target instanceof Node&&S.target.contains(b.trigger)&&w()},"handleScroll");return window.addEventListener("scroll",C,{capture:!0}),()=>window.removeEventListener("scroll",C,{capture:!0})}},[b.trigger,w]);const{setContentId:y}=b;return St(()=>(y(d),()=>{y(void 0)}),[d,y]),s.jsx(nc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:m,onPointerDownOutside:p,onFocusOutside:C=>C.preventDefault(),onDismiss:w,children:s.jsxs(Id,{"data-state":b.stateAttribute,role:l?void 0:"tooltip",id:l?void 0:b.contentId,...v,...g,ref:a,style:{...g.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(A7,{children:c}),l?s.jsx(x7,{id:b.contentId,role:"tooltip",children:l}):null]})})},"TooltipContentImpl"));function Zj(t,n){const a=Math.abs(n.top-t.y),o=Math.abs(n.bottom-t.y),c=Math.abs(n.right-t.x),l=Math.abs(n.left-t.x);switch(Math.min(a,o,c,l)){case l:return"left";case c:return"right";case a:return"top";case o:return"bottom";default:throw new Error("unreachable")}}tn(Zj,"getExitSideFromRect");function Qj(t,n,a=5){const o=[];switch(n){case"top":o.push({x:t.x-a,y:t.y+a},{x:t.x+a,y:t.y+a});break;case"bottom":o.push({x:t.x-a,y:t.y-a},{x:t.x+a,y:t.y-a});break;case"left":o.push({x:t.x+a,y:t.y-a},{x:t.x+a,y:t.y+a});break;case"right":o.push({x:t.x-a,y:t.y-a},{x:t.x-a,y:t.y+a});break}return o}tn(Qj,"getPaddedExitPoints");function Jj(t){const{top:n,right:a,bottom:o,left:c}=t;return[{x:c,y:n},{x:a,y:n},{x:a,y:o},{x:c,y:o}]}tn(Jj,"getPointsFromRect");function eC(t,n){const{x:a,y:o}=t;let c=!1;for(let l=0,d=n.length-1;lo!=w>o&&a<(v-g)*(o-b)/(w-b)+g&&(c=!c)}return c}tn(eC,"isPointInPolygon");function tC(t){const n=t.slice();return n.sort((a,o)=>a.xo.x?1:a.yo.y?1:0),nC(n)}tn(tC,"getHull");function nC(t){if(t.length<=1)return t.slice();const n=[];for(let o=0;o=2;){const l=n[n.length-1],d=n[n.length-2];if((l.x-d.x)*(c.y-d.y)>=(l.y-d.y)*(c.x-d.x))n.pop();else break}n.push(c)}n.pop();const a=[];for(let o=t.length-1;o>=0;o--){const c=t[o];for(;a.length>=2;){const l=a[a.length-1],d=a[a.length-2];if((l.x-d.x)*(c.y-d.y)>=(l.y-d.y)*(c.x-d.x))a.pop();else break}a.push(c)}return a.pop(),n.length===1&&a.length===1&&n[0].x===a[0].x&&n[0].y===a[0].y?n:n.concat(a)}tn(nC,"getHullPresorted");var _7=j7,D7=S7,O7=N7,L7=T7,rC=M7;const aC=_7,z7=D7,P7=O7,sC=f.forwardRef(({className:t,sideOffset:n=4,...a},o)=>s.jsx(L7,{children:s.jsx(rC,{ref:o,sideOffset:n,className:pe("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...a})}));sC.displayName=rC.displayName;const I7="sidebar_state",U7=3600*24*7,B7="16rem",$7="18rem",H7="3rem",G7="b",oC=f.createContext(null);function Wd(){const t=f.useContext(oC);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}const iC=f.forwardRef(({defaultOpen:t=!0,open:n,onOpenChange:a,className:o,style:c,children:l,...d},m)=>{const p=XT(),[g,b]=f.useState(!1),[v,w]=f.useState(t),y=n??v,C=f.useCallback(T=>{const M=typeof T=="function"?T(y):T;a?a(M):w(M),document.cookie=`${I7}=${M}; path=/; max-age=${U7}`},[a,y]),S=f.useCallback(()=>p?b(T=>!T):C(T=>!T),[p,C,b]);f.useEffect(()=>{const T=M=>{M.key===G7&&(M.metaKey||M.ctrlKey)&&(M.preventDefault(),S())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[S]);const N=y?"expanded":"collapsed",E=f.useMemo(()=>({state:N,open:y,setOpen:C,isMobile:p,openMobile:g,setOpenMobile:b,toggleSidebar:S}),[N,y,C,p,g,b,S]);return s.jsx(oC.Provider,{value:E,children:s.jsx(aC,{delayDuration:0,children:s.jsx("div",{style:{"--sidebar-width":B7,"--sidebar-width-icon":H7,...c},className:pe("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",o),ref:m,...d,children:l})})})});iC.displayName="SidebarProvider";const lC=f.forwardRef(({side:t="left",variant:n="sidebar",collapsible:a="offcanvas",className:o,children:c,...l},d)=>{const{isMobile:m,state:p,openMobile:g,setOpenMobile:b}=Wd();return a==="none"?s.jsx("div",{className:pe("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",o),ref:d,...l,children:c}):m?s.jsx(Yj,{open:g,onOpenChange:b,...l,children:s.jsxs(Hg,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":$7},side:t,children:[s.jsxs(Gg,{className:"sr-only",children:[s.jsx(Vg,{children:"Sidebar"}),s.jsx(Fg,{children:"Displays the mobile sidebar."})]}),s.jsx("div",{className:"flex h-full w-full flex-col",children:c})]})}):s.jsxs("div",{ref:d,className:"group peer hidden text-sidebar-foreground md:block","data-state":p,"data-collapsible":p==="collapsed"?a:"","data-variant":n,"data-side":t,children:[s.jsx("div",{className:pe("relative w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",n==="floating"||n==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),s.jsx("div",{className:pe("fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",t==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",n==="floating"||n==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",o),...l,children:s.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:c})})]})});lC.displayName="Sidebar";const cC=f.forwardRef(({className:t,onClick:n,...a},o)=>{const{toggleSidebar:c}=Wd();return s.jsxs(ue,{ref:o,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:pe("h-7 w-7",t),onClick:l=>{n==null||n(l),c()},...a,children:[s.jsx(HT,{}),s.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});cC.displayName="SidebarTrigger";const uC=f.forwardRef(({className:t,...n},a)=>{const{toggleSidebar:o}=Wd();return s.jsx("button",{ref:a,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:o,title:"Toggle Sidebar",className:pe("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",t),...n})});uC.displayName="SidebarRail";const dC=f.forwardRef(({className:t,...n},a)=>s.jsx("main",{ref:a,className:pe("relative flex w-full flex-1 flex-col bg-background","md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",t),...n}));dC.displayName="SidebarInset";const V7=f.forwardRef(({className:t,...n},a)=>s.jsx(_e,{ref:a,"data-sidebar":"input",className:pe("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",t),...n}));V7.displayName="SidebarInput";const fC=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,"data-sidebar":"header",className:pe("flex flex-col gap-2 p-2",t),...n}));fC.displayName="SidebarHeader";const F7=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,"data-sidebar":"footer",className:pe("flex flex-col gap-2 p-2",t),...n}));F7.displayName="SidebarFooter";const Y7=f.forwardRef(({className:t,...n},a)=>s.jsx(Bj,{ref:a,"data-sidebar":"separator",className:pe("mx-2 w-auto bg-sidebar-border",t),...n}));Y7.displayName="SidebarSeparator";const mC=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,"data-sidebar":"content",className:pe("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...n}));mC.displayName="SidebarContent";const Nh=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,"data-sidebar":"group",className:pe("relative flex w-full min-w-0 flex-col p-2",t),...n}));Nh.displayName="SidebarGroup";const pC=f.forwardRef(({className:t,asChild:n=!1,...a},o)=>{const c=n?wi:"div";return s.jsx(c,{ref:o,"data-sidebar":"group-label",className:pe("flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t),...a})});pC.displayName="SidebarGroupLabel";const q7=f.forwardRef(({className:t,asChild:n=!1,...a},o)=>{const c=n?wi:"button";return s.jsx(c,{ref:o,"data-sidebar":"group-action",className:pe("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",t),...a})});q7.displayName="SidebarGroupAction";const Eh=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,"data-sidebar":"group-content",className:pe("w-full text-sm",t),...n}));Eh.displayName="SidebarGroupContent";const kh=f.forwardRef(({className:t,...n},a)=>s.jsx("ul",{ref:a,"data-sidebar":"menu",className:pe("flex w-full min-w-0 flex-col gap-1",t),...n}));kh.displayName="SidebarMenu";const Th=f.forwardRef(({className:t,...n},a)=>s.jsx("li",{ref:a,"data-sidebar":"menu-item",className:pe("group/menu-item relative",t),...n}));Th.displayName="SidebarMenuItem";const K7=ji("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),Mh=f.forwardRef(({asChild:t=!1,isActive:n=!1,variant:a="default",size:o="default",tooltip:c,className:l,...d},m)=>{const p=t?wi:"button",{isMobile:g,state:b}=Wd(),v=s.jsx(p,{ref:m,"data-sidebar":"menu-button","data-size":o,"data-active":n,className:pe(K7({variant:a,size:o}),l),...d});return c?(typeof c=="string"&&(c={children:c}),s.jsxs(z7,{children:[s.jsx(P7,{asChild:!0,children:v}),s.jsx(sC,{side:"right",align:"center",hidden:b!=="collapsed"||g,...c})]})):v});Mh.displayName="SidebarMenuButton";const W7=f.forwardRef(({className:t,asChild:n=!1,showOnHover:a=!1,...o},c)=>{const l=n?wi:"button";return s.jsx(l,{ref:c,"data-sidebar":"menu-action",className:pe("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",a&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",t),...o})});W7.displayName="SidebarMenuAction";const X7=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,"data-sidebar":"menu-badge",className:pe("pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",t),...n}));X7.displayName="SidebarMenuBadge";const Z7=f.forwardRef(({className:t,showIcon:n=!1,...a},o)=>{const c=f.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return s.jsxs("div",{ref:o,"data-sidebar":"menu-skeleton",className:pe("flex h-8 items-center gap-2 rounded-md px-2",t),...a,children:[n&&s.jsx(Ue,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),s.jsx(Ue,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":c}})]})});Z7.displayName="SidebarMenuSkeleton";const Q7=f.forwardRef(({className:t,...n},a)=>s.jsx("ul",{ref:a,"data-sidebar":"menu-sub",className:pe("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",t),...n}));Q7.displayName="SidebarMenuSub";const J7=f.forwardRef(({...t},n)=>s.jsx("li",{ref:n,...t}));J7.displayName="SidebarMenuSubItem";const eM=f.forwardRef(({asChild:t=!1,size:n="md",isActive:a,className:o,...c},l)=>{const d=t?wi:"a";return s.jsx(d,{ref:l,"data-sidebar":"menu-sub-button","data-size":n,"data-active":a,className:pe("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",n==="sm"&&"text-xs",n==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",o),...c})});eM.displayName="SidebarMenuSubButton";const tM=[],nM=[{label:"Overview",items:[{title:"Dashboard",url:"/",icon:A2,end:!0,permission:"overview"},{title:"Console",url:"/logs",icon:M2,permission:"logs"}]},{label:"Access & Logs",items:[{title:"Users",url:"/users",icon:rh,permission:"users.view"},{title:"Groups",url:"/groups",icon:qu,permission:"users.view"},{title:"Tickets",url:"/tickets",icon:is,permission:"overview"},{title:"Transcripts",url:"/transcripts",icon:Ul,permission:"transcripts"}]},{label:"Configuration",items:[{title:"Bot Settings",url:"/configs?file=supportbot",icon:cg},{title:"Ticket Panel",url:"/configs?file=ticket-panel",icon:is},{title:"AI Assistant",url:"/configs?file=supportbot-ai",icon:og},{title:"Messages",url:"/configs?file=messages",icon:ug},{title:"Staff Roles",url:"/configs?file=supportbot&tab=Roles",icon:rh},{title:"Commands",url:"/configs?file=commands",icon:ds}]},{label:"System",items:[{title:"Addons",url:"/addons",icon:dg,permission:"settings.view"},{title:"Addon Builder",url:"/addons/builder",icon:ds,permission:"settings.update"},{title:"Dashboard Settings",url:"/settings",icon:qs,permission:"settings.view"}]}];function y0(t){return new URL(t,"http://x").searchParams.get("file")}function rM(){const{branding:t}=Ed(),{permissions:n}=Yt(),{stats:a}=kd(),{files:o}=$2(),[c]=wd(),l=c.get("file"),d=sd(n,"supportbot")&&o.length>0?{label:"Addons",items:o.map(C=>({title:H2(C),url:`/configs?file=${_l(C)}`,icon:dg,end:!1}))}:null,m=tM.filter(C=>!C.permission||Rn(n,C.permission)),p=nM.map(C=>({...C,items:C.items.filter(S=>{if(S.permission)return Rn(n,S.permission);const N=y0(S.url);return N&&S.url.includes("/configs")?sd(n,N):!0})})).filter(C=>C.items.length>0),g=d?[...p,d]:p,[b,v]=f.useState(null);f.useEffect(()=>{let C=!1;return Ne.getGuildResources().then(S=>{!C&&S.data&&v(S.data)}).catch(()=>{}),()=>{C=!0}},[]);const w=(b==null?void 0:b.guildName)||(a?`${a.servers} Server${a.servers===1?"":"s"}`:"Connected Guild"),y=b==null?void 0:b.guildIcon;return s.jsxs(lC,{collapsible:"icon",className:"border-r border-sidebar-border",children:[s.jsxs(fC,{className:"gap-3 p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 px-1",children:[t.hasFavicon&&t.faviconUrl?s.jsx("img",{src:`${t.faviconUrl}${t.updatedAt?`?v=${t.updatedAt}`:""}`,alt:"",className:"size-7 shrink-0 rounded-md object-contain"}):null,s.jsx("span",{className:"truncate text-lg font-bold tracking-tight",children:t.title})]}),s.jsxs(zg,{children:[s.jsx(Pg,{asChild:!0,children:s.jsxs(ue,{variant:"outline",className:"h-10 w-full justify-between border-border bg-secondary/40 px-3 font-normal hover:bg-secondary/60",children:[s.jsxs("span",{className:"flex items-center gap-2 truncate min-w-0",children:[y?s.jsx("img",{src:y,alt:"",className:"size-5 rounded-full object-cover shrink-0"}):s.jsx("div",{className:"size-5 rounded-full bg-primary/20 text-primary flex items-center justify-center text-[10px] font-bold shrink-0",children:w.charAt(0).toUpperCase()}),s.jsx("span",{className:"truncate text-xs font-semibold text-foreground",children:w})]}),s.jsx(xe,{icon:k2,size:14,className:"text-muted-foreground shrink-0 ml-1"})]})}),s.jsxs(Fd,{className:"w-[--radix-dropdown-menu-trigger-width]",children:[s.jsxs(Vl,{disabled:!0,className:"text-xs font-medium",children:["Connected Guild: ",w]}),a?s.jsxs(Vl,{disabled:!0,className:"text-xs text-muted-foreground",children:[a.users.toLocaleString()," members tracked"]}):null]})]})]}),s.jsxs(mC,{className:"px-2",children:[s.jsx(Nh,{children:s.jsx(Eh,{children:s.jsx(kh,{children:m.map(C=>s.jsx(Th,{children:s.jsx(Mh,{asChild:!0,tooltip:C.title,children:s.jsxs(th,{to:C.url,end:C.end,className:({isActive:S})=>pe(S&&"bg-sidebar-accent font-medium"),children:[s.jsx(xe,{icon:C.icon,size:18}),s.jsx("span",{children:C.title})]})})},C.title))})})}),g.map(C=>s.jsxs(Nh,{children:[s.jsx(pC,{className:"text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/80",children:C.label}),s.jsx(Eh,{children:s.jsx(kh,{children:C.items.map(S=>{const N=y0(S.url),E=!!N&&l===N&&S.url.includes("/configs");return s.jsx(Th,{children:s.jsx(Mh,{asChild:!0,tooltip:S.title,children:s.jsxs(th,{to:S.url,end:S.end,className:({isActive:T})=>pe((T||E)&&"bg-sidebar-accent font-medium"),children:[s.jsx(xe,{icon:S.icon,size:18}),s.jsx("span",{children:S.title})]})})},`${C.label}-${S.title}`)})})})]},C.label))]}),s.jsx(uC,{})]})}var w0=1,aM=.9,sM=.8,oM=.17,Pp=.1,Ip=.999,iM=.9999,lM=.99,cM=/[\\\/_+.#"@\[\(\{&]/,uM=/[\\\/_+.#"@\[\(\{&]/g,dM=/[\s-]/,hC=/[\s-]/g;function Rh(t,n,a,o,c,l,d){if(l===n.length)return c===t.length?w0:lM;var m=`${c},${l}`;if(d[m]!==void 0)return d[m];for(var p=o.charAt(l),g=a.indexOf(p,c),b=0,v,w,y,C;g>=0;)v=Rh(t,n,a,o,g+1,l+1,d),v>b&&(g===c?v*=w0:cM.test(t.charAt(g-1))?(v*=sM,y=t.slice(c,g-1).match(uM),y&&c>0&&(v*=Math.pow(Ip,y.length))):dM.test(t.charAt(g-1))?(v*=aM,C=t.slice(c,g-1).match(hC),C&&c>0&&(v*=Math.pow(Ip,C.length))):(v*=oM,c>0&&(v*=Math.pow(Ip,g-c))),t.charAt(g)!==n.charAt(l)&&(v*=iM)),(vv&&(v=w*Pp)),v>b&&(b=v),g=a.indexOf(p,g+1);return d[m]=b,b}function j0(t){return t.toLowerCase().replace(hC," ")}function fM(t,n,a){return t=a&&a.length>0?`${t+" "+a.join(" ")}`:t,Rh(t,n,j0(t),j0(n),0,0,{})}var Ml='[cmdk-group=""]',Up='[cmdk-group-items=""]',mM='[cmdk-group-heading=""]',gC='[cmdk-item=""]',C0=`${gC}:not([aria-disabled="true"])`,Ah="cmdk-item-select",ni="data-value",pM=(t,n,a)=>fM(t,n,a),xC=f.createContext(void 0),cc=()=>f.useContext(xC),bC=f.createContext(void 0),Wg=()=>f.useContext(bC),vC=f.createContext(void 0),yC=f.forwardRef((t,n)=>{let a=ri(()=>{var D,B;return{search:"",value:(B=(D=t.value)!=null?D:t.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),o=ri(()=>new Set),c=ri(()=>new Map),l=ri(()=>new Map),d=ri(()=>new Set),m=wC(t),{label:p,children:g,value:b,onValueChange:v,filter:w,shouldFilter:y,loop:C,disablePointerSelection:S=!1,vimBindings:N=!0,...E}=t,T=nn(),M=nn(),k=nn(),_=f.useRef(null),R=NM();Zs(()=>{if(b!==void 0){let D=b.trim();a.current.value=D,L.emit()}},[b]),Zs(()=>{R(6,ce)},[]);let L=f.useMemo(()=>({subscribe:D=>(d.current.add(D),()=>d.current.delete(D)),snapshot:()=>a.current,setState:(D,B,V)=>{var Z,be,K,ge;if(!Object.is(a.current[D],B)){if(a.current[D]=B,D==="search")q(),I(),R(1,H);else if(D==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let me=document.getElementById(k);me?me.focus():(Z=document.getElementById(T))==null||Z.focus()}if(R(7,()=>{var me;a.current.selectedItemId=(me=de())==null?void 0:me.id,L.emit()}),V||R(5,ce),((be=m.current)==null?void 0:be.value)!==void 0){let me=B??"";(ge=(K=m.current).onValueChange)==null||ge.call(K,me);return}}L.emit()}},emit:()=>{d.current.forEach(D=>D())}}),[]),ne=f.useMemo(()=>({value:(D,B,V)=>{var Z;B!==((Z=l.current.get(D))==null?void 0:Z.value)&&(l.current.set(D,{value:B,keywords:V}),a.current.filtered.items.set(D,X(B,V)),R(2,()=>{I(),L.emit()}))},item:(D,B)=>(o.current.add(D),B&&(c.current.has(B)?c.current.get(B).add(D):c.current.set(B,new Set([D]))),R(3,()=>{q(),I(),a.current.value||H(),L.emit()}),()=>{l.current.delete(D),o.current.delete(D),a.current.filtered.items.delete(D);let V=de();R(4,()=>{q(),(V==null?void 0:V.getAttribute("id"))===D&&H(),L.emit()})}),group:D=>(c.current.has(D)||c.current.set(D,new Set),()=>{l.current.delete(D),c.current.delete(D)}),filter:()=>m.current.shouldFilter,label:p||t["aria-label"],getDisablePointerSelection:()=>m.current.disablePointerSelection,listId:T,inputId:k,labelId:M,listInnerRef:_}),[]);function X(D,B){var V,Z;let be=(Z=(V=m.current)==null?void 0:V.filter)!=null?Z:pM;return D?be(D,a.current.search,B):0}function I(){if(!a.current.search||m.current.shouldFilter===!1)return;let D=a.current.filtered.items,B=[];a.current.filtered.groups.forEach(Z=>{let be=c.current.get(Z),K=0;be.forEach(ge=>{let me=D.get(ge);K=Math.max(me,K)}),B.push([Z,K])});let V=_.current;se().sort((Z,be)=>{var K,ge;let me=Z.getAttribute("id"),$=be.getAttribute("id");return((K=D.get($))!=null?K:0)-((ge=D.get(me))!=null?ge:0)}).forEach(Z=>{let be=Z.closest(Up);be?be.appendChild(Z.parentElement===be?Z:Z.closest(`${Up} > *`)):V.appendChild(Z.parentElement===V?Z:Z.closest(`${Up} > *`))}),B.sort((Z,be)=>be[1]-Z[1]).forEach(Z=>{var be;let K=(be=_.current)==null?void 0:be.querySelector(`${Ml}[${ni}="${encodeURIComponent(Z[0])}"]`);K==null||K.parentElement.appendChild(K)})}function H(){let D=se().find(V=>V.getAttribute("aria-disabled")!=="true"),B=D==null?void 0:D.getAttribute(ni);L.setState("value",B||void 0)}function q(){var D,B,V,Z;if(!a.current.search||m.current.shouldFilter===!1){a.current.filtered.count=o.current.size;return}a.current.filtered.groups=new Set;let be=0;for(let K of o.current){let ge=(B=(D=l.current.get(K))==null?void 0:D.value)!=null?B:"",me=(Z=(V=l.current.get(K))==null?void 0:V.keywords)!=null?Z:[],$=X(ge,me);a.current.filtered.items.set(K,$),$>0&&be++}for(let[K,ge]of c.current)for(let me of ge)if(a.current.filtered.items.get(me)>0){a.current.filtered.groups.add(K);break}a.current.filtered.count=be}function ce(){var D,B,V;let Z=de();Z&&(((D=Z.parentElement)==null?void 0:D.firstChild)===Z&&((V=(B=Z.closest(Ml))==null?void 0:B.querySelector(mM))==null||V.scrollIntoView({block:"nearest"})),Z.scrollIntoView({block:"nearest"}))}function de(){var D;return(D=_.current)==null?void 0:D.querySelector(`${gC}[aria-selected="true"]`)}function se(){var D;return Array.from(((D=_.current)==null?void 0:D.querySelectorAll(C0))||[])}function P(D){let B=se()[D];B&&L.setState("value",B.getAttribute(ni))}function W(D){var B;let V=de(),Z=se(),be=Z.findIndex(ge=>ge===V),K=Z[be+D];(B=m.current)!=null&&B.loop&&(K=be+D<0?Z[Z.length-1]:be+D===Z.length?Z[0]:Z[be+D]),K&&L.setState("value",K.getAttribute(ni))}function oe(D){let B=de(),V=B==null?void 0:B.closest(Ml),Z;for(;V&&!Z;)V=D>0?CM(V,Ml):SM(V,Ml),Z=V==null?void 0:V.querySelector(C0);Z?L.setState("value",Z.getAttribute(ni)):W(D)}let ae=()=>P(se().length-1),G=D=>{D.preventDefault(),D.metaKey?ae():D.altKey?oe(1):W(1)},O=D=>{D.preventDefault(),D.metaKey?P(0):D.altKey?oe(-1):W(-1)};return f.createElement(Me.div,{ref:n,tabIndex:-1,...E,"cmdk-root":"",onKeyDown:D=>{var B;(B=E.onKeyDown)==null||B.call(E,D);let V=D.nativeEvent.isComposing||D.keyCode===229;if(!(D.defaultPrevented||V))switch(D.key){case"n":case"j":{N&&D.ctrlKey&&G(D);break}case"ArrowDown":{G(D);break}case"p":case"k":{N&&D.ctrlKey&&O(D);break}case"ArrowUp":{O(D);break}case"Home":{D.preventDefault(),P(0);break}case"End":{D.preventDefault(),ae();break}case"Enter":{D.preventDefault();let Z=de();if(Z){let be=new Event(Ah);Z.dispatchEvent(be)}}}}},f.createElement("label",{"cmdk-label":"",htmlFor:ne.inputId,id:ne.labelId,style:kM},p),Xd(t,D=>f.createElement(bC.Provider,{value:L},f.createElement(xC.Provider,{value:ne},D))))}),hM=f.forwardRef((t,n)=>{var a,o;let c=nn(),l=f.useRef(null),d=f.useContext(vC),m=cc(),p=wC(t),g=(o=(a=p.current)==null?void 0:a.forceMount)!=null?o:d==null?void 0:d.forceMount;Zs(()=>{if(!g)return m.item(c,d==null?void 0:d.id)},[g]);let b=jC(c,l,[t.value,t.children,l],t.keywords),v=Wg(),w=ps(R=>R.value&&R.value===b.current),y=ps(R=>g||m.filter()===!1?!0:R.search?R.filtered.items.get(c)>0:!0);f.useEffect(()=>{let R=l.current;if(!(!R||t.disabled))return R.addEventListener(Ah,C),()=>R.removeEventListener(Ah,C)},[y,t.onSelect,t.disabled]);function C(){var R,L;S(),(L=(R=p.current).onSelect)==null||L.call(R,b.current)}function S(){v.setState("value",b.current,!0)}if(!y)return null;let{disabled:N,value:E,onSelect:T,forceMount:M,keywords:k,..._}=t;return f.createElement(Me.div,{ref:Ks(l,n),..._,id:c,"cmdk-item":"",role:"option","aria-disabled":!!N,"aria-selected":!!w,"data-disabled":!!N,"data-selected":!!w,onPointerMove:N||m.getDisablePointerSelection()?void 0:S,onClick:N?void 0:C},t.children)}),gM=f.forwardRef((t,n)=>{let{heading:a,children:o,forceMount:c,...l}=t,d=nn(),m=f.useRef(null),p=f.useRef(null),g=nn(),b=cc(),v=ps(y=>c||b.filter()===!1?!0:y.search?y.filtered.groups.has(d):!0);Zs(()=>b.group(d),[]),jC(d,m,[t.value,t.heading,p]);let w=f.useMemo(()=>({id:d,forceMount:c}),[c]);return f.createElement(Me.div,{ref:Ks(m,n),...l,"cmdk-group":"",role:"presentation",hidden:v?void 0:!0},a&&f.createElement("div",{ref:p,"cmdk-group-heading":"","aria-hidden":!0,id:g},a),Xd(t,y=>f.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":a?g:void 0},f.createElement(vC.Provider,{value:w},y))))}),xM=f.forwardRef((t,n)=>{let{alwaysRender:a,...o}=t,c=f.useRef(null),l=ps(d=>!d.search);return!a&&!l?null:f.createElement(Me.div,{ref:Ks(c,n),...o,"cmdk-separator":"",role:"separator"})}),bM=f.forwardRef((t,n)=>{let{onValueChange:a,...o}=t,c=t.value!=null,l=Wg(),d=ps(g=>g.search),m=ps(g=>g.selectedItemId),p=cc();return f.useEffect(()=>{t.value!=null&&l.setState("search",t.value)},[t.value]),f.createElement(Me.input,{ref:n,...o,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":p.listId,"aria-labelledby":p.labelId,"aria-activedescendant":m,id:p.inputId,type:"text",value:c?t.value:d,onChange:g=>{c||l.setState("search",g.target.value),a==null||a(g.target.value)}})}),vM=f.forwardRef((t,n)=>{let{children:a,label:o="Suggestions",...c}=t,l=f.useRef(null),d=f.useRef(null),m=ps(g=>g.selectedItemId),p=cc();return f.useEffect(()=>{if(d.current&&l.current){let g=d.current,b=l.current,v,w=new ResizeObserver(()=>{v=requestAnimationFrame(()=>{let y=g.offsetHeight;b.style.setProperty("--cmdk-list-height",y.toFixed(1)+"px")})});return w.observe(g),()=>{cancelAnimationFrame(v),w.unobserve(g)}}},[]),f.createElement(Me.div,{ref:Ks(l,n),...c,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":m,"aria-label":o,id:p.listId},Xd(t,g=>f.createElement("div",{ref:Ks(d,p.listInnerRef),"cmdk-list-sizer":""},g)))}),yM=f.forwardRef((t,n)=>{let{open:a,onOpenChange:o,overlayClassName:c,contentClassName:l,container:d,...m}=t;return f.createElement(Bg,{open:a,onOpenChange:o},f.createElement($g,{container:d},f.createElement(oc,{"cmdk-overlay":"",className:c}),f.createElement(ic,{"aria-label":t.label,"cmdk-dialog":"",className:l},f.createElement(yC,{ref:n,...m}))))}),wM=f.forwardRef((t,n)=>ps(a=>a.filtered.count===0)?f.createElement(Me.div,{ref:n,...t,"cmdk-empty":"",role:"presentation"}):null),jM=f.forwardRef((t,n)=>{let{progress:a,children:o,label:c="Loading...",...l}=t;return f.createElement(Me.div,{ref:n,...l,"cmdk-loading":"",role:"progressbar","aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,"aria-label":c},Xd(t,d=>f.createElement("div",{"aria-hidden":!0},d)))}),_n=Object.assign(yC,{List:vM,Item:hM,Input:bM,Group:gM,Separator:xM,Dialog:yM,Empty:wM,Loading:jM});function CM(t,n){let a=t.nextElementSibling;for(;a;){if(a.matches(n))return a;a=a.nextElementSibling}}function SM(t,n){let a=t.previousElementSibling;for(;a;){if(a.matches(n))return a;a=a.previousElementSibling}}function wC(t){let n=f.useRef(t);return Zs(()=>{n.current=t}),n}var Zs=typeof window>"u"?f.useEffect:f.useLayoutEffect;function ri(t){let n=f.useRef();return n.current===void 0&&(n.current=t()),n}function ps(t){let n=Wg(),a=()=>t(n.snapshot());return f.useSyncExternalStore(n.subscribe,a,a)}function jC(t,n,a,o=[]){let c=f.useRef(),l=cc();return Zs(()=>{var d;let m=(()=>{var g;for(let b of a){if(typeof b=="string")return b.trim();if(typeof b=="object"&&"current"in b)return b.current?(g=b.current.textContent)==null?void 0:g.trim():c.current}})(),p=o.map(g=>g.trim());l.value(t,m,p),(d=n.current)==null||d.setAttribute(ni,m),c.current=m}),c}var NM=()=>{let[t,n]=f.useState(),a=ri(()=>new Map);return Zs(()=>{a.current.forEach(o=>o()),a.current=new Map},[t]),(o,c)=>{a.current.set(o,c),n({})}};function EM(t){let n=t.type;return typeof n=="function"?n(t.props):"render"in n?n.render(t.props):t}function Xd({asChild:t,children:n},a){return t&&f.isValidElement(n)?f.cloneElement(EM(n),{ref:n.ref},a(n.props.children)):a(n)}var kM={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Qs=Bg,TM=r7,MM=$g,CC=f.forwardRef(({className:t,...n},a)=>s.jsx(oc,{ref:a,className:pe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...n}));CC.displayName=oc.displayName;const hs=f.forwardRef(({className:t,children:n,...a},o)=>s.jsxs(MM,{children:[s.jsx(CC,{}),s.jsxs(ic,{ref:o,className:pe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...a,children:[n,s.jsxs(Fj,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[s.jsx(zj,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hs.displayName=ic.displayName;const gs=({className:t,...n})=>s.jsx("div",{className:pe("flex flex-col space-y-1.5 text-center sm:text-left",t),...n});gs.displayName="DialogHeader";const Js=({className:t,...n})=>s.jsx("div",{className:pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...n});Js.displayName="DialogFooter";const xs=f.forwardRef(({className:t,...n},a)=>s.jsx(Yd,{ref:a,className:pe("text-lg font-semibold leading-none tracking-tight",t),...n}));xs.displayName=Yd.displayName;const bs=f.forwardRef(({className:t,...n},a)=>s.jsx(qd,{ref:a,className:pe("text-sm text-muted-foreground",t),...n}));bs.displayName=qd.displayName;const SC=f.forwardRef(({className:t,...n},a)=>s.jsx(_n,{ref:a,className:pe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...n}));SC.displayName=_n.displayName;const RM=f.forwardRef(({className:t,...n},a)=>s.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[s.jsx(VT,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),s.jsx(_n.Input,{ref:a,className:pe("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...n})]}));RM.displayName=_n.Input.displayName;const NC=f.forwardRef(({className:t,...n},a)=>s.jsx(_n.List,{ref:a,className:pe("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...n}));NC.displayName=_n.List.displayName;const EC=f.forwardRef((t,n)=>s.jsx(_n.Empty,{ref:n,className:"py-6 text-center text-sm",...t}));EC.displayName=_n.Empty.displayName;const kC=f.forwardRef(({className:t,...n},a)=>s.jsx(_n.Group,{ref:a,className:pe("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...n}));kC.displayName=_n.Group.displayName;const AM=f.forwardRef(({className:t,...n},a)=>s.jsx(_n.Separator,{ref:a,className:pe("-mx-1 h-px bg-border",t),...n}));AM.displayName=_n.Separator.displayName;const TC=f.forwardRef(({className:t,...n},a)=>s.jsx(_n.Item,{ref:a,className:pe("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t),...n}));TC.displayName=_n.Item.displayName;const _M=[{title:"Info command",fields:[{path:"Info.Title",label:"Title",type:"text"},{path:"Info.Description",label:"Description",type:"textarea"},{path:"Info.Button",label:"Button label",type:"text"},{path:"Info.URL",label:"Button URL",type:"text"},{path:"Info.Colour",label:"Colour",type:"color"}]},{title:"Welcome message",fields:[{path:"Welcome.Enabled",label:"Enabled",type:"boolean"},{path:"Welcome.LayoutStyle",label:"Layout style",type:"select",options:[{value:"modern",label:"Modern (components)"},{value:"classic",label:"Classic embed"}]},{path:"Welcome.Embed.Colour",label:"Embed colour",type:"color"},{path:"Welcome.Embed.Title",label:"Embed title",type:"text"},{path:"Welcome.Embed.Message",label:"Embed message",type:"textarea"}]},{title:"Leave message",fields:[{path:"Leave.Enabled",label:"Enabled",type:"boolean"},{path:"Leave.Embed.Colour",label:"Embed colour",type:"color"},{path:"Leave.Embed.Title",label:"Embed title",type:"text"},{path:"Leave.Embed.Message",label:"Embed message",type:"textarea"}]}],DM=[{value:"Playing",label:"Playing"},{value:"Watching",label:"Watching"},{value:"Listening",label:"Listening"},{value:"Competing",label:"Competing"},{value:"Streaming",label:"Streaming"}],OM=[{value:"Channel",label:"Channel"},{value:"Forum",label:"Forum"}],LM=[{value:"channels",label:"Channels"},{value:"threads",label:"Threads"}],zM=[{value:"description",label:"Channel description"},{value:"embed",label:"Embed"}],ei=[{value:"1",label:"Blurple"},{value:"2",label:"Grey"},{value:"3",label:"Green"},{value:"4",label:"Red"}],PM=[{title:"General",fields:[{path:"General.Name",label:"Bot name",type:"text"},{path:"General.Token",label:"Bot token",type:"secret",description:"Masked in the dashboard. Your real token is preserved on save."},{path:"General.GuildId",label:"Server (guild) ID",type:"discordId",description:"Right-click your Discord server icon → Copy Server ID. The bot should only stay in this server.",placeholder:"Discord server snowflake ID"},{path:"General.Addons.Enabled",label:"Addons enabled",type:"boolean"}]},{title:"Database",fields:[{path:"Database.Driver",label:"Database Engine",type:"select",options:[{value:"sqlite",label:"SQLite (Local File)"},{value:"mysql",label:"MySQL / MariaDB"}],description:"Select SQLite for zero-config file storage, or MySQL for external host servers."},{path:"Database.MySQL.Host",label:"MySQL Host",type:"text",placeholder:"127.0.0.1 or localhost",description:"Hostname or IP address of your MySQL database server."},{path:"Database.MySQL.Port",label:"MySQL Port",type:"number",placeholder:"3306"},{path:"Database.MySQL.Database",label:"Database Name",type:"text",placeholder:"supportbot"},{path:"Database.MySQL.User",label:"Database User",type:"text",placeholder:"root"},{path:"Database.MySQL.Password",label:"Database Password",type:"secret",placeholder:"••••••••••••"},{path:"Database.MySQL.ConnectionLimit",label:"Connection Pool Limit",type:"number",placeholder:"10",description:"Maximum simultaneous connections in the MySQL pool (default 10)."},{path:"Database.SQLite.File",label:"SQLite Database File Path",type:"text",placeholder:"./Data/supportbot.db"}]},{title:"Activity",fields:[{path:"Activity.Status",label:"Status text",type:"text"},{path:"Activity.Type",label:"Activity type",type:"select",options:DM},{path:"Activity.StreamingURL",label:"Streaming URL",type:"text",description:"Required when type is Streaming."}]},{title:"Embeds",fields:[{path:"Embed.Colours.General",label:"General colour",type:"color"},{path:"Embed.Colours.Success",label:"Success colour",type:"color"},{path:"Embed.Colours.Error",label:"Error colour",type:"color"},{path:"Embed.Colours.Warn",label:"Warn colour",type:"color"},{path:"Embed.Footer",label:"Footer text",type:"text"}]},{title:"Roles",fields:[{path:"Roles.AutoRole.Enabled",label:"Auto role enabled",type:"boolean"},{path:"Roles.AutoRole.Role",label:"Auto role",type:"discordRole"},{path:"Roles.StaffMember.Staff",label:"Staff role",type:"discordRole"},{path:"Roles.StaffMember.Admin",label:"Admin role",type:"discordRole"},{path:"Roles.StaffMember.Moderator",label:"Moderator role",type:"discordRole"},{path:"Roles.Mod.AllowSupportStaff",label:"Allow support staff /mod",type:"boolean"}]},{title:"Welcome & leave",fields:[{path:"Welcome.Enabled",label:"Welcome enabled",type:"boolean"},{path:"Welcome.Channel",label:"Welcome channel",type:"discordChannel"},{path:"Leave.Enabled",label:"Leave enabled",type:"boolean"},{path:"Leave.Channel",label:"Leave channel",type:"discordChannel"}]},{title:"Suggestions",fields:[{path:"Suggestions.Mode",label:"Mode",type:"select",options:OM},{path:"Suggestions.Channel",label:"Suggestions channel",type:"discordChannel"},{path:"Suggestions.ForumChannel",label:"Forum channel",type:"discordChannel"},{path:"Suggestions.UpvoteEmoji",label:"Upvote emoji",type:"emoji"},{path:"Suggestions.DownvoteEmoji",label:"Downvote emoji",type:"emoji"},{path:"Suggestions.OwnSuggestion",label:"Own suggestion votes",type:"boolean"},{path:"Suggestions.ShowUsers",label:"Show users",type:"boolean"},{path:"Suggestions.UpvoteTitle",label:"Upvote button title",type:"text"},{path:"Suggestions.DownvoteTitle",label:"Downvote button title",type:"text"},{path:"Suggestions.Threads.Enabled",label:"Suggestion threads",type:"boolean"},{path:"Suggestions.Threads.Title",label:"Thread title",type:"text"},{path:"Suggestions.Threads.Reason",label:"Thread reason",type:"text"},{path:"Suggestions.Buttons.Upvote",label:"Upvote button style",type:"select",options:ei},{path:"Suggestions.Buttons.Downvote",label:"Downvote button style",type:"select",options:ei},{path:"Suggestions.Buttons.RemoveVote",label:"Remove vote button style",type:"select",options:ei},{path:"Suggestions.Buttons.RemoveVote_Title",label:"Remove vote title",type:"text"},{path:"Suggestions.Tags.Created",label:"Tag: created",type:"text"},{path:"Suggestions.Tags.Considering",label:"Tag: considering",type:"text"},{path:"Suggestions.Tags.Solved",label:"Tag: solved",type:"text"},{path:"Suggestions.Tags.Denied",label:"Tag: denied",type:"text"}]},{title:"Tickets",fields:[{path:"Ticket.TicketType",label:"Ticket type",type:"select",options:LM},{path:"Ticket.UserManagement.DMOnAdd",label:"DM when added to ticket",type:"boolean"},{path:"Ticket.UserManagement.DMOnRemove",label:"DM when removed from ticket",type:"boolean"},{path:"Ticket.UserManagement.DMTranscript",label:"DM transcript on close",type:"boolean"},{path:"Ticket.TicketHome",label:"Ticket home channel",type:"discordChannel"},{path:"Ticket.TicketChannelsCategory",label:"Ticket category",type:"discordCategory"},{path:"Ticket.TicketChannelsCategory2",label:"Overflow ticket category",type:"discordCategory",description:"Used when the first category is full."},{path:"Ticket.TicketArchiveCategory",label:"Archive category",type:"discordCategory"},{path:"Ticket.Channel",label:"Channel prefix",type:"text"},{path:"Ticket.TicketSubject",label:"Ticket subject display",type:"select",options:zM},{path:"Ticket.Timeout",label:"Close timeout (minutes)",type:"number"},{path:"Ticket.TicketsPerUser",label:"Tickets per user",type:"number"},{path:"Ticket.TicketReason",label:"Require reason",type:"boolean"},{path:"Ticket.Close.StaffOnly",label:"Close staff only",type:"boolean"},{path:"Ticket.Invites.StaffOnly",label:"Ticket invites staff only",type:"boolean"},{path:"Ticket.ClaimTickets.Enabled",label:"Claim tickets",type:"boolean"},{path:"Ticket.ClaimTickets.Channel",label:"Claim log channel",type:"discordChannel"},{path:"Ticket.ClaimTickets.ClaimAcceptTime",label:"Claim accept time (ms)",type:"number"},{path:"Ticket.ClaimTickets.ButtonTitle",label:"Claim button title",type:"text"},{path:"Ticket.ClaimTickets.ButtonEmoji",label:"Claim button emoji",type:"emoji"},{path:"Ticket.ClaimTickets.Button",label:"Claim button style",type:"select",options:ei},{path:"Ticket.ReviewSystem.Enabled",label:"Review system",type:"boolean"},{path:"Ticket.ReviewSystem.Channel",label:"Review channel",type:"discordChannel"},{path:"Ticket.ReviewSystem.UseModal",label:"Review uses modal",type:"boolean"},{path:"Ticket.Log.TicketDataLog",label:"Ticket data log channel",type:"discordChannel"},{path:"Ticket.Log.TickeDataTitle",label:"Ticket data log title",type:"text"},{path:"Ticket.Log.TicketBlacklistLog",label:"Blacklist log channel",type:"discordChannel"},{path:"Ticket.AIMode.Enabled",label:"AI mode in tickets",type:"boolean"},{path:"Ticket.AIMode.ThreadName",label:"AI thread name",type:"text"},{path:"Ticket.AIMode.WelcomeMessage",label:"AI welcome message",type:"textarea"},{path:"Ticket.Questions.Enabled",label:"Ticket questions",type:"boolean"},{path:"Ticket.Questions.List",label:"Default questions",type:"stringList"}]},{title:"Ticket Departments",description:"Configure ticket department channels, emojis, staff roles, and custom department questions.",fields:[{path:"Ticket.DepartmentSystem.Enabled",label:"Departments enabled",type:"boolean"},{path:"Ticket.DepartmentSystem.Placeholder",label:"Department placeholder",type:"text"},{path:"Ticket.DepartmentSystem.DefaultDepartment",label:"Default department key",type:"text"}]},{title:"Ticket Priorities",description:"Configure ticket priority levels and emojis.",fields:[{path:"Ticket.PrioritySystem.Enabled",label:"Priority system",type:"boolean"},{path:"Ticket.PrioritySystem.DefaultPriority",label:"Default priority",type:"text"},{path:"Ticket.PrioritySystem.AllowUsersToChooseOnOpen",label:"User picks priority on open",type:"boolean"}]},{title:"Voice tickets",fields:[{path:"VoiceTickets.Name",label:"VC name format",type:"text"},{path:"VoiceTickets.Category",label:"VC category",type:"discordCategory"}]},{title:"Logging",fields:[{path:"MessageDelete.Channel",label:"Message delete log channel",type:"discordChannel"},{path:"MessageDelete.Colour",label:"Message delete embed colour",type:"color"},{path:"MessageUpdate.Channel",label:"Message update log channel",type:"discordChannel"},{path:"MessageUpdate.Colour",label:"Message update embed colour",type:"color"},{path:"Translate.TranslateLog",label:"Translate log channel",type:"discordChannel"}]},{title:"Buttons & menus",description:"Ticket panel and control button labels and styles.",fields:[{path:"Buttons.General.Delete",label:"Delete emoji",type:"emoji"},{path:"Buttons.General.DeleteStyle",label:"Delete button style",type:"select",options:ei},{path:"Buttons.Voice.TicketDeleteText",label:"Voice delete label",type:"text"},{path:"Buttons.Tickets.ClaimEmoji",label:"Ticket claim emoji",type:"emoji"},{path:"Buttons.Tickets.ClaimStyle",label:"Ticket claim style",type:"select",options:ei},{path:"SelectMenus.Tickets.PanelEmoji",label:"Panel menu emoji",type:"emoji"},{path:"SelectMenus.Tickets.CloseEmoji",label:"Close menu emoji",type:"emoji"}]}],IM=[{value:"openai",label:"OpenAI"},{value:"groq",label:"Groq"},{value:"claude",label:"Claude"}],UM=[{value:"text",label:"Plain text"},{value:"embed",label:"Embed"},{value:"components_v2",label:"Components v2"}],BM=[{value:"channel",label:"Per channel"},{value:"guild",label:"Per server"}],$M=[{title:"General",fields:[{path:"Enabled",label:"AI enabled",type:"boolean"},{path:"General.Provider",label:"Provider",type:"select",options:IM},{path:"General.Model",label:"Model",type:"text"},{path:"General.Model_API_Key",label:"API key",type:"secret",placeholder:"MODEL_API_KEY"},{path:"General.Tokens",label:"Max tokens",type:"number"},{path:"General.Temperature",label:"Temperature",type:"number"},{path:"General.Name",label:"Display name",type:"text"},{path:"General.PastebinAPI_Key",label:"Pastebin API key",type:"secret",placeholder:"PASTEBIN_API_KEY"},{path:"General.PastebinAPI_URL",label:"Pastebin API URL",type:"text"}]},{title:"Style & channel",fields:[{path:"Style.MessageType",label:"Message type",type:"select",options:UM},{path:"Features.SuggestTickets",label:"Suggest tickets",type:"boolean"},{path:"Channels.AIChannel",label:"AI channel ID",type:"discordId"},{path:"Embed.Color",label:"Embed colour",type:"color"},{path:"Embed.Footer",label:"Embed footer",type:"text"}]},{title:"Memory",fields:[{path:"Memory.Enabled",label:"Memory enabled",type:"boolean"},{path:"Memory.StoreFacts",label:"Store facts",type:"boolean"},{path:"Memory.StoreSummaries",label:"Store summaries",type:"boolean"},{path:"Memory.MaxRecentMessages",label:"Max recent messages",type:"number"},{path:"Memory.Scope",label:"Memory scope",type:"select",options:BM}]},{title:"Custom instructions",fields:[{path:"CustomInstructions",label:"Instruction lines",type:"stringList",description:"One instruction per line sent to the AI."}]},{title:"Messages",fields:[{path:"Messages.ErrorResponse",label:"Error response",type:"text"},{path:"Messages.AIError",label:"AI error",type:"text"},{path:"Messages.AIDisabled",label:"AI disabled",type:"text"},{path:"Messages.MessageTooLong",label:"Message too long",type:"text"},{path:"Messages.SuggestTicketText",label:"Suggest ticket text",type:"text"},{path:"Messages.SuggestTicketReaction",label:"Suggest ticket emoji",type:"emoji"}]}],HM=[{value:"1",label:"Blurple"},{value:"2",label:"Grey"},{value:"3",label:"Green"},{value:"4",label:"Red"}],GM=[{value:"1",label:"Style 1"},{value:"2",label:"Style 2"},{value:"3",label:"Style 3"},{value:"4",label:"Style 4 (classic embed)"}],VM=[{title:"Panel",fields:[{path:"Panel",label:"Panel enabled",type:"boolean"}]},{title:"Embed style",fields:[{path:"Style.Title",label:"Title",type:"text"},{path:"Style.Description",label:"Description",type:"textarea"},{path:"Style.Image",label:"Image URL",type:"text"},{path:"Style.Color",label:"Embed colour",type:"color"},{path:"Style.Layout",label:"Layout",type:"select",options:GM}]},{title:"Create button",fields:[{path:"Button.Text",label:"Button text",type:"text"},{path:"Button.Emoji",label:"Button emoji",type:"emoji"},{path:"Button.Color",label:"Button style",type:"select",options:HM},{path:"Button.CustomId",label:"Custom ID",type:"text"}]},{title:"Department menu",fields:[{path:"DepartmentMenu.CustomId",label:"Custom ID",type:"text"},{path:"DepartmentMenu.Placeholder",label:"Placeholder",type:"text"},{path:"DepartmentMenu.DefaultDescription",label:"Default description",type:"text"},{path:"DepartmentMenu.DefaultEmoji",label:"Default emoji",type:"emoji"}]},{title:"Panel settings",fields:[{path:"Settings.Image",label:"Show image",type:"boolean"},{path:"Settings.TopTitle",label:"Top title",type:"boolean"},{path:"Settings.TopDivider",label:"Top divider",type:"boolean"},{path:"Settings.BottomTitle",label:"Bottom title",type:"boolean"},{path:"Settings.BottomDivider",label:"Bottom divider",type:"boolean"}]},{title:"Messages",description:"Bot messages when using the ticket panel command.",fields:[{path:"Messages.NotConfigured",label:"Not configured",type:"textarea"},{path:"Messages.InvalidChannel",label:"Invalid channel",type:"textarea"},{path:"Messages.PanelSent",label:"Panel sent",type:"text"},{path:"Messages.PanelSentWithDepartments",label:"Panel sent (departments)",type:"text"},{path:"Messages.SendError",label:"Send error",type:"text"}]}],_h={supportbot:PM,"ticket-panel":VM,commands:"commands",messages:_M,"supportbot-ai":$M};function FM(t){return t in _h?_h[t]:null}const ai=[{id:"tickets",title:"Ticket panel",description:"Create and manage support tickets with departments, priorities, and AI assistance.",icon:is,href:"/configs?file=ticket-panel",category:"tickets"},{id:"supportbot",title:"Core bot settings",description:"General bot options, activity status, embed colours, roles, and welcome messages.",icon:qs,href:"/configs?file=supportbot",category:"server"},{id:"transcripts",title:"Ticket transcripts",description:"Browse and preview HTML transcripts saved when tickets are closed.",icon:Ul,href:"/transcripts",category:"tickets"},{id:"suggestions",title:"Suggestions",description:"Configure suggestion channels, voting emojis, and forum thread behaviour.",icon:ug,href:"/configs?file=messages",category:"community"},{id:"ai",title:"AI assistant",description:"SupportBot AI mode settings for in-ticket conversational help.",icon:og,href:"/configs?file=supportbot-ai",category:"community"},{id:"commands",title:"Commands",description:"Enable or disable slash commands and customise command permissions.",icon:ds,href:"/configs?file=commands",category:"server"}],YM=[{id:"all",label:"All modules"},{id:"tickets",label:"Tickets"},{id:"community",label:"Community"},{id:"server",label:"Server"}],qM={supportbot:"Bot config","ticket-panel":"Ticket panel",commands:"Commands",messages:"Messages","supportbot-ai":"AI assistant"},KM=[{key:"Help",label:"Help",description:"List all slash commands"},{key:"Info",label:"Info",description:"Server information"},{key:"TicketPanel",label:"Ticket panel",description:"Create ticket panel"},{key:"OpenTicket",label:"Open ticket",description:"Open a support ticket"},{key:"CloseTicket",label:"Close ticket",description:"Close a ticket"},{key:"TicketManage",label:"Manage ticket",description:"Manage an existing ticket"},{key:"Suggestion",label:"Suggestion",description:"Submit a suggestion"},{key:"Embed",label:"Embed",description:"Send an embed message"},{key:"Translate",label:"Translate",description:"Translate text"},{key:"Ping",label:"Ping",description:"Check bot latency"},{key:"AI",label:"AI",description:"AI assistant command"},{key:"Settings",label:"Settings command",description:"Bot settings via Discord"},{key:"Mod",label:"Moderation",description:"Moderation tools"}];function WM(t,n,a){const o=qM[t];for(const c of n)for(const l of c.fields)a.push({id:`setting:${t}:${l.path}`,title:l.label,subtitle:`${o} · ${c.title}`,href:`/configs?file=${t}`,category:"setting",icon:XM(t),keywords:[l.path,l.label,c.title,o,t,l.description??"",l.type].map(d=>d.toLowerCase())})}function XM(t){switch(t){case"supportbot":return qs;case"ticket-panel":return is;case"messages":return ug;case"supportbot-ai":return og;case"commands":return ds;default:return qs}}function ZM(){const t=[{id:"page:dashboard",title:"Dashboard",subtitle:"Overview and module status",href:"/",category:"page",icon:A2,keywords:["home","overview","stats"]},{id:"page:logs",title:"Logs",subtitle:"Live bot console output",href:"/logs",category:"page",icon:M2,keywords:["console","output","errors","warn"]},{id:"page:settings",title:"Settings",subtitle:"Updates and maintenance",href:"/settings",category:"page",icon:qs,keywords:["update","version","software"]},{id:"page:transcripts",title:"Transcripts",subtitle:"Closed ticket transcripts",href:"/transcripts",category:"page",icon:Ul,keywords:["tickets","archive","html"]}];for(const n of ai)t.push({id:`module:${n.id}`,title:n.title,subtitle:n.description,href:n.href,category:"module",icon:n.icon,keywords:[n.id,n.title,n.description,n.category].map(a=>a.toLowerCase())});for(const[n,a]of Object.entries(_h))a!=="commands"&&WM(n,a,t);for(const n of KM)t.push({id:`command:${n.key}`,title:n.label,subtitle:`Command · ${n.description}`,href:"/configs?file=commands",category:"command",icon:ds,keywords:[n.key,n.label,n.description,"slash","commands"].map(a=>a.toLowerCase())});return t.push({id:"setting:commands:all",title:"Slash commands",subtitle:"Commands · Enable and configure all commands",href:"/configs?file=commands",category:"setting",icon:ds,keywords:["commands","slash","enable","permissions"]}),t}const QM=ZM(),JM={page:"Pages",module:"Modules",setting:"Settings",command:"Commands"};function eR(t,n=12){const a=t.trim().toLowerCase();return a?QM.map(c=>{let l=0;const d=c.title.toLowerCase(),m=(c.subtitle??"").toLowerCase();d===a?l+=100:d.startsWith(a)?l+=40:d.includes(a)&&(l+=20),m.includes(a)&&(l+=10);for(const p of c.keywords)p===a?l+=15:p.startsWith(a)?l+=8:p.includes(a)&&(l+=4);return{item:c,score:l}}).filter(c=>c.score>0).sort((c,l)=>l.score-c.score).slice(0,n).map(c=>c.item):[]}function tR(t){const n=[],a=["page","module","setting","command"];for(const o of a){const c=t.filter(l=>l.category===o);c.length&&n.push({category:o,label:JM[o],items:c})}return n}function nR({className:t}){const n=ao(),[a,o]=f.useState(""),[c,l]=f.useState(!1),d=f.useRef(null),m=f.useRef(null),p=f.useRef(null),[g,b]=f.useState(null),v=f.useMemo(()=>eR(a,14),[a]),w=f.useMemo(()=>tR(v),[v]),y=c&&a.trim().length>0,C=()=>{const N=p.current;if(!N)return;const E=N.getBoundingClientRect();b({top:E.bottom+6,left:E.left,width:E.width})};f.useLayoutEffect(()=>{if(!y){b(null);return}return C(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[y,a]),f.useEffect(()=>{function N(E){var M,k;const T=E.target;(M=d.current)!=null&&M.contains(T)||(k=m.current)!=null&&k.contains(T)||l(!1)}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]),f.useEffect(()=>{function N(E){var T;E.key==="k"&&(E.metaKey||E.ctrlKey)&&(E.preventDefault(),(T=p.current)==null||T.focus(),l(!0))}return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[]);function S(N){var E;n(N.href),o(""),l(!1),(E=p.current)==null||E.blur()}return s.jsxs("div",{ref:d,className:pe("relative w-full max-w-sm",t),children:[s.jsx(xe,{icon:vi,size:16,className:"pointer-events-none absolute left-3 top-1/2 z-10 -translate-y-1/2 text-muted-foreground"}),s.jsx(_e,{ref:p,value:a,onChange:N=>{o(N.target.value),l(!0)},onFocus:()=>l(!0),onKeyDown:N=>{var E;N.key==="Escape"&&(l(!1),o(""),(E=p.current)==null||E.blur())},placeholder:"Search modules, configs…",className:"h-9 border-border bg-secondary/50 pl-9",role:"combobox","aria-expanded":y,"aria-controls":"dashboard-search-results","aria-autocomplete":"list"}),s.jsxs("kbd",{className:"pointer-events-none absolute right-2 top-2 hidden h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100 sm:flex",children:[s.jsx("span",{className:"text-xs",children:"⌘"}),"K"]}),y&&g?so.createPortal(s.jsx("div",{ref:m,id:"dashboard-search-results",className:"overflow-hidden rounded-xl border border-border bg-popover shadow-lg shadow-black/20",style:{position:"fixed",top:g.top,left:g.left,width:g.width,zIndex:9999},role:"listbox",children:s.jsx(SC,{shouldFilter:!1,className:"bg-transparent",children:s.jsx(NC,{className:"max-h-[min(360px,50vh)]",children:v.length===0?s.jsxs(EC,{className:"py-8 text-muted-foreground",children:["No results for “",a.trim(),"”"]}):w.map(N=>s.jsx(kC,{heading:N.label,children:N.items.map(E=>s.jsxs(TC,{value:E.id,onSelect:()=>S(E),className:"cursor-pointer gap-3 rounded-lg py-2.5 aria-selected:bg-accent",children:[E.icon?s.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary/15 text-primary",children:s.jsx(xe,{icon:E.icon,size:16})}):null,s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate font-medium",children:E.title}),E.subtitle?s.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:E.subtitle}):null]})]},E.id))},N.category))})})}),document.body):null]})}var rR=Object.defineProperty,Ta=(t,n)=>rR(t,"name",{value:n,configurable:!0}),MC="Avatar",[aR,HP]=bn(MC),sR=[0,()=>{}],[oR,RC]=aR(MC),AC=f.forwardRef(Ta(function(n,a){const{__scopeAvatar:o,...c}=n,[l,d]=f.useState("idle"),[m,p]=LC();return s.jsx(oR,{scope:o,imageLoadingStatus:l,setImageLoadingStatus:d,imageCount:m,setImageCount:p,children:s.jsx(Me.span,{...c,ref:a})})},"Avatar")),iR="AvatarImage",_C=f.forwardRef(Ta(function(n,a){const{__scopeAvatar:o,src:c,onLoadingStatusChange:l,...d}=n,m=RC(iR,o);m.setImageCount;const p=OC(c,{referrerPolicy:d.referrerPolicy,crossOrigin:d.crossOrigin,loadingStatus:m.imageLoadingStatus,setLoadingStatus:m.setImageLoadingStatus}),g=Vt(v=>{l==null||l(v)}),b=f.useRef(p);return St(()=>{const v=b.current;b.current=p,p!==v&&g(p)},[p,g]),p==="loaded"?s.jsx(Me.img,{...d,ref:a,src:c}):null},"AvatarImage")),lR="AvatarFallback",DC=f.forwardRef(Ta(function(n,a){const{__scopeAvatar:o,delayMs:c,...l}=n,d=RC(lR,o),[m,p]=f.useState(c===void 0);return f.useEffect(()=>{if(c!==void 0){const g=window.setTimeout(()=>p(!0),c);return()=>window.clearTimeout(g)}},[c]),m&&d.imageLoadingStatus!=="loaded"?s.jsx(Me.span,{...l,ref:a}):null},"AvatarFallback"));function OC(t,{loadingStatus:n,setLoadingStatus:a,referrerPolicy:o,crossOrigin:c}){return St(()=>{if(!t){a("error");return}const l=new window.Image,d=Ta(p=>{const g=p.currentTarget;a(Dh(g))},"handleLoad"),m=Ta(()=>a("error"),"handleError");return l.addEventListener("load",d),l.addEventListener("error",m),o&&(l.referrerPolicy=o),l.crossOrigin=c??null,l.src=t,a(Dh(l)),()=>{l.removeEventListener("load",d),l.removeEventListener("error",m),a("idle")}},[t,c,o,a]),n}Ta(OC,"useImageLoadingStatus");function Dh(t){return t.complete?t.naturalWidth>0?"loaded":"error":"loading"}Ta(Dh,"getImageLoadingStatus");function LC(){return sR}Ta(LC,"useImageCount");function cR(t){}Ta(cR,"useUpdateImageCount");const vs=f.forwardRef(({className:t,...n},a)=>s.jsx(AC,{ref:a,className:pe("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...n}));vs.displayName=AC.displayName;const eo=f.forwardRef(({className:t,...n},a)=>s.jsx(_C,{ref:a,className:pe("aspect-square h-full w-full",t),...n}));eo.displayName=_C.displayName;const ys=f.forwardRef(({className:t,...n},a)=>s.jsx(DC,{ref:a,className:pe("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...n}));ys.displayName=DC.displayName;const zC=f.createContext(null);function uR({children:t}){const[n,a]=f.useState([]),[o,c]=f.useState(0),[l,d]=f.useState(!0),m=f.useCallback(async()=>{try{const v=await Ne.getNotifications();v.data&&(a(v.data.items),c(v.data.unreadCount))}catch{}finally{d(!1)}},[]),p=f.useCallback(async()=>{var v;try{const w=await Ne.markNotificationsRead("all");a(y=>y.map(C=>({...C,read:!0}))),c(((v=w.data)==null?void 0:v.unreadCount)??0)}catch{}},[]),g=f.useCallback(async v=>{var w;try{const y=await Ne.dismissNotification(v);a(C=>C.filter(S=>S.id!==v)),c(((w=y.data)==null?void 0:w.unreadCount)??0)}catch{}},[]);f.useEffect(()=>{m();const v=setInterval(m,3e4);return()=>clearInterval(v)},[m]);const b=f.useMemo(()=>({items:n,unreadCount:o,loading:l,refresh:m,markAllRead:p,dismiss:g}),[n,o,l,m,p,g]);return s.jsx(zC.Provider,{value:b,children:t})}function dR(){const t=f.useContext(zC);if(!t)throw new Error("useNotifications must be used within NotificationsProvider");return t}const fR=ji("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Fn({className:t,variant:n,...a}){return s.jsx("div",{className:pe(fR({variant:n}),t),...a})}var mR=Object.defineProperty,pR=(t,n)=>mR(t,"name",{value:n,configurable:!0});function ud(t,[n,a]){return Math.min(a,Math.max(n,t))}pR(ud,"clamp");var hR=Object.defineProperty,Fe=(t,n)=>hR(t,"name",{value:n,configurable:!0});function PC(t,n){return f.useReducer((a,o)=>n[a][o]??a,t)}Fe(PC,"useStateMachine");var IC="ScrollArea",[UC,GP]=bn(IC),[gR,xr]=UC(IC),xR=f.forwardRef(Fe(function(n,a){const{__scopeScrollArea:o,type:c="hover",dir:l,scrollHideDelay:d=600,...m}=n,[p,g]=f.useState(null),[b,v]=f.useState(null),[w,y]=f.useState(null),[C,S]=f.useState(null),[N,E]=f.useState(null),[T,M]=f.useState(0),[k,_]=f.useState(0),[R,L]=f.useState(!1),[ne,X]=f.useState(!1),I=Pe(a,g),H=Si(l);return s.jsx(gR,{scope:o,type:c,dir:H,scrollHideDelay:d,scrollArea:p,viewport:b,onViewportChange:v,content:w,onContentChange:y,scrollbarX:C,onScrollbarXChange:S,scrollbarXEnabled:R,onScrollbarXEnabledChange:L,scrollbarY:N,onScrollbarYChange:E,scrollbarYEnabled:ne,onScrollbarYEnabledChange:X,onCornerWidthChange:M,onCornerHeightChange:_,children:s.jsx(Me.div,{dir:H,...m,ref:I,style:{position:"relative","--radix-scroll-area-corner-width":T+"px","--radix-scroll-area-corner-height":k+"px",...n.style}})})},"ScrollArea")),bR="ScrollAreaViewport",vR=f.forwardRef(Fe(function(n,a){const{__scopeScrollArea:o,children:c,nonce:l,...d}=n,m=xr(bR,o),p=f.useRef(null),g=Pe(a,p,m.onViewportChange);return s.jsxs(s.Fragment,{children:[s.jsx(yR,{nonce:l}),s.jsx(Me.div,{"data-radix-scroll-area-viewport":"",...d,ref:g,style:{overflowX:m.scrollbarXEnabled?"scroll":"hidden",overflowY:m.scrollbarYEnabled?"scroll":"hidden",...n.style},children:s.jsx("div",{ref:m.onContentChange,style:{minWidth:"100%",display:"table"},children:c})})]})},"ScrollAreaViewport")),yR=f.memo(Fe(function({nonce:n}){return s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:n})},"ScrollAreaViewportStyle"),(t,n)=>t.nonce===n.nonce),Aa="ScrollAreaScrollbar",BC=f.forwardRef(Fe(function(n,a){const{forceMount:o,...c}=n,l=xr(Aa,n.__scopeScrollArea),{onScrollbarXEnabledChange:d,onScrollbarYEnabledChange:m}=l,p=n.orientation==="horizontal";return f.useEffect(()=>(p?d(!0):m(!0),()=>{p?d(!1):m(!1)}),[p,d,m]),l.type==="hover"?s.jsx(wR,{...c,ref:a,forceMount:o}):l.type==="scroll"?s.jsx(jR,{...c,ref:a,forceMount:o}):l.type==="auto"?s.jsx($C,{...c,ref:a,forceMount:o}):l.type==="always"?s.jsx(Xg,{...c,ref:a,"data-state":"visible"}):null},"ScrollAreaScrollbar")),wR=f.forwardRef(Fe(function(n,a){const{forceMount:o,...c}=n,l=xr(Aa,n.__scopeScrollArea),[d,m]=f.useState(!1);return f.useEffect(()=>{const p=l.scrollArea;let g=0;if(p){const b=Fe(()=>{window.clearTimeout(g),m(!0)},"handlePointerEnter"),v=Fe(()=>{g=window.setTimeout(()=>m(!1),l.scrollHideDelay)},"handlePointerLeave");return p.addEventListener("pointerenter",b),p.addEventListener("pointerleave",v),()=>{window.clearTimeout(g),p.removeEventListener("pointerenter",b),p.removeEventListener("pointerleave",v)}}},[l.scrollArea,l.scrollHideDelay]),s.jsx(fn,{present:o||d,children:s.jsx($C,{"data-state":d?"visible":"hidden",...c,ref:a})})},"ScrollAreaScrollbarHover")),jR=f.forwardRef(Fe(function(n,a){const{forceMount:o,...c}=n,l=xr(Aa,n.__scopeScrollArea),d=n.orientation==="horizontal",m=dc(()=>g("SCROLL_END"),100),[p,g]=PC("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return f.useEffect(()=>{if(p==="idle"){const b=window.setTimeout(()=>g("HIDE"),l.scrollHideDelay);return()=>window.clearTimeout(b)}},[p,l.scrollHideDelay,g]),f.useEffect(()=>{const b=l.viewport,v=d?"scrollLeft":"scrollTop";if(b){let w=b[v];const y=Fe(()=>{const C=b[v];w!==C&&(g("SCROLL"),m()),w=C},"handleScroll");return b.addEventListener("scroll",y),()=>b.removeEventListener("scroll",y)}},[l.viewport,d,g,m]),s.jsx(fn,{present:o||p!=="hidden",children:s.jsx(Xg,{"data-state":p==="hidden"?"hidden":"visible",...c,ref:a,onPointerEnter:Ce(n.onPointerEnter,()=>g("POINTER_ENTER")),onPointerLeave:Ce(n.onPointerLeave,()=>g("POINTER_LEAVE"))})})},"ScrollAreaScrollbarScroll")),$C=f.forwardRef(Fe(function(n,a){const o=xr(Aa,n.__scopeScrollArea),{forceMount:c,...l}=n,[d,m]=f.useState(!1),p=n.orientation==="horizontal",g=dc(()=>{if(o.viewport){const b=o.viewport.offsetWidth0&&b<1,onThumbChange:Fe(y=>d.current=y,"onThumbChange"),onThumbPointerUp:Fe(()=>m.current=0,"onThumbPointerUp"),onThumbPointerDown:Fe(y=>m.current=y,"onThumbPointerDown")};function w(y,C){return FC(y,m.current,p,C)}return Fe(w,"getScrollPosition"),o==="horizontal"?s.jsx(CR,{...v,ref:a,onThumbPositionChange:()=>{if(l.viewport&&d.current){const y=l.viewport.scrollLeft,C=Lh(y,p,l.dir);d.current.style.transform=`translate3d(${C}px, 0, 0)`}},onWheelScroll:y=>{l.viewport&&(l.viewport.scrollLeft=y)},onDragScroll:y=>{l.viewport&&(l.viewport.scrollLeft=w(y,l.dir))}}):o==="vertical"?s.jsx(SR,{...v,ref:a,onThumbPositionChange:()=>{if(l.viewport&&d.current){const y=l.viewport.scrollTop,C=Lh(y,p);d.current.style.transform=`translate3d(0, ${C}px, 0)`}},onWheelScroll:y=>{l.viewport&&(l.viewport.scrollTop=y)},onDragScroll:y=>{l.viewport&&(l.viewport.scrollTop=w(y))}}):null},"ScrollAreaScrollbarVisible")),CR=f.forwardRef(Fe(function(n,a){const{sizes:o,onSizesChange:c,...l}=n,d=xr(Aa,n.__scopeScrollArea),[m,p]=f.useState(),g=f.useRef(null),b=Pe(a,g,d.onScrollbarXChange);return f.useEffect(()=>{g.current&&p(getComputedStyle(g.current))},[g]),s.jsx(GC,{"data-orientation":"horizontal",...l,ref:b,sizes:o,style:{bottom:0,left:d.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:d.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":uc(o)+"px",...n.style},onThumbPointerDown:v=>n.onThumbPointerDown(v.x),onDragScroll:v=>n.onDragScroll(v.x),onWheelScroll:(v,w)=>{if(d.viewport){const y=d.viewport.scrollLeft+v.deltaX;n.onWheelScroll(y),Jg(y,w)&&v.preventDefault()}},onResize:()=>{g.current&&d.viewport&&m&&c({content:d.viewport.scrollWidth,viewport:d.viewport.offsetWidth,scrollbar:{size:g.current.clientWidth,paddingStart:Kl(m.paddingLeft),paddingEnd:Kl(m.paddingRight)}})}})},"ScrollAreaScrollbarX")),SR=f.forwardRef(Fe(function(n,a){const{sizes:o,onSizesChange:c,...l}=n,d=xr(Aa,n.__scopeScrollArea),[m,p]=f.useState(),g=f.useRef(null),b=Pe(a,g,d.onScrollbarYChange);return f.useEffect(()=>{g.current&&p(getComputedStyle(g.current))},[g]),s.jsx(GC,{"data-orientation":"vertical",...l,ref:b,sizes:o,style:{top:0,right:d.dir==="ltr"?0:void 0,left:d.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":uc(o)+"px",...n.style},onThumbPointerDown:v=>n.onThumbPointerDown(v.y),onDragScroll:v=>n.onDragScroll(v.y),onWheelScroll:(v,w)=>{if(d.viewport){const y=d.viewport.scrollTop+v.deltaY;n.onWheelScroll(y),Jg(y,w)&&v.preventDefault()}},onResize:()=>{g.current&&d.viewport&&m&&c({content:d.viewport.scrollHeight,viewport:d.viewport.offsetHeight,scrollbar:{size:g.current.clientHeight,paddingStart:Kl(m.paddingTop),paddingEnd:Kl(m.paddingBottom)}})}})},"ScrollAreaScrollbarY")),[NR,HC]=UC(Aa),GC=f.forwardRef(Fe(function(n,a){const{__scopeScrollArea:o,sizes:c,hasThumb:l,onThumbChange:d,onThumbPointerUp:m,onThumbPointerDown:p,onThumbPositionChange:g,onDragScroll:b,onWheelScroll:v,onResize:w,...y}=n,C=xr(Aa,o),[S,N]=f.useState(null),E=Pe(a,N),T=f.useRef(null),M=f.useRef(""),k=C.viewport,_=c.content-c.viewport,R=Vt(v),L=Vt(g),ne=dc(w,10);function X(I){if(T.current){const H=I.clientX-T.current.left,q=I.clientY-T.current.top;b({x:H,y:q})}}return Fe(X,"handleDragScroll"),f.useEffect(()=>{const I=Fe(H=>{const q=H.target;(S==null?void 0:S.contains(q))&&R(H,_)},"handleWheel");return document.addEventListener("wheel",I,{passive:!1}),()=>document.removeEventListener("wheel",I,{passive:!1})},[k,S,_,R]),f.useEffect(L,[c,L]),to(S,ne),to(C.content,ne),s.jsx(NR,{scope:o,scrollbar:S,hasThumb:l,onThumbChange:Vt(d),onThumbPointerUp:Vt(m),onThumbPositionChange:L,onThumbPointerDown:Vt(p),children:s.jsx(Me.div,{...y,ref:E,style:{position:"absolute",...y.style},onPointerDown:Ce(n.onPointerDown,I=>{I.button===0&&(I.target.setPointerCapture(I.pointerId),T.current=S.getBoundingClientRect(),M.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",C.viewport&&(C.viewport.style.scrollBehavior="auto"),X(I))}),onPointerMove:Ce(n.onPointerMove,X),onPointerUp:Ce(n.onPointerUp,I=>{const H=I.target;H.hasPointerCapture(I.pointerId)&&H.releasePointerCapture(I.pointerId),document.body.style.webkitUserSelect=M.current,C.viewport&&(C.viewport.style.scrollBehavior=""),T.current=null})})})},"ScrollAreaScrollbarImpl")),Oh="ScrollAreaThumb",ER=f.forwardRef(Fe(function(n,a){const{forceMount:o,...c}=n,l=HC(Oh,n.__scopeScrollArea);return s.jsx(fn,{present:o||l.hasThumb,children:s.jsx(kR,{ref:a,...c})})},"ScrollAreaThumb")),kR=f.forwardRef(Fe(function(n,a){const{__scopeScrollArea:o,style:c,...l}=n,d=xr(Oh,o),m=HC(Oh,o),{onThumbPositionChange:p}=m,g=Pe(a,m.onThumbChange),b=f.useRef(void 0),v=dc(()=>{b.current&&(b.current(),b.current=void 0)},100);return f.useEffect(()=>{const w=d.viewport;if(w){const y=Fe(()=>{if(v(),!b.current){const C=RR(w,p);b.current=C,p()}},"handleScroll");return p(),w.addEventListener("scroll",y),()=>w.removeEventListener("scroll",y)}},[d.viewport,v,p]),s.jsx(Me.div,{"data-state":m.hasThumb?"visible":"hidden",...l,ref:g,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...c},onPointerDownCapture:Ce(n.onPointerDownCapture,w=>{const C=w.target.getBoundingClientRect(),S=w.clientX-C.left,N=w.clientY-C.top;m.onThumbPointerDown({x:S,y:N})}),onPointerUp:Ce(n.onPointerUp,m.onThumbPointerUp)})},"ScrollAreaThumbImpl")),VC="ScrollAreaCorner",TR=f.forwardRef(Fe(function(n,a){const o=xr(VC,n.__scopeScrollArea),c=!!(o.scrollbarX&&o.scrollbarY);return o.type!=="scroll"&&c?s.jsx(MR,{...n,ref:a}):null},"ScrollAreaCorner")),MR=f.forwardRef(Fe(function(n,a){const{__scopeScrollArea:o,...c}=n,l=xr(VC,o),[d,m]=f.useState(0),[p,g]=f.useState(0),b=!!(d&&p),{onCornerWidthChange:v,onCornerHeightChange:w}=l;return to(l.scrollbarX,()=>{var C;const y=((C=l.scrollbarX)==null?void 0:C.offsetHeight)||0;l.onCornerHeightChange(y),g(y)}),to(l.scrollbarY,()=>{var C;const y=((C=l.scrollbarY)==null?void 0:C.offsetWidth)||0;l.onCornerWidthChange(y),m(y)}),f.useEffect(()=>()=>{v(0),w(0)},[v,w]),b?s.jsx(Me.div,{...c,ref:a,style:{width:d,height:p,position:"absolute",right:l.dir==="ltr"?0:void 0,left:l.dir==="rtl"?0:void 0,bottom:0,...n.style}}):null},"ScrollAreaCornerImpl"));function Kl(t){return t?parseInt(t,10):0}Fe(Kl,"toInt");function Zg(t,n){const a=t/n;return isNaN(a)?0:a}Fe(Zg,"getThumbRatio");function uc(t){const n=Zg(t.viewport,t.content),a=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,o=(t.scrollbar.size-a)*n;return Math.max(o,18)}Fe(uc,"getThumbSize");function FC(t,n,a,o="ltr"){const c=uc(a),l=c/2,d=n||l,m=c-d,p=a.scrollbar.paddingStart+d,g=a.scrollbar.size-a.scrollbar.paddingEnd-m,b=a.content-a.viewport,v=o==="ltr"?[0,b]:[b*-1,0];return Qg([p,g],v)(t)}Fe(FC,"getScrollPositionFromPointer");function Lh(t,n,a="ltr"){const o=uc(n),c=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,l=n.scrollbar.size-c,d=n.content-n.viewport,m=l-o,p=a==="ltr"?[0,d]:[d*-1,0],g=ud(t,p);return Qg([0,d],[0,m])(g)}Fe(Lh,"getThumbOffsetFromScroll");function Qg(t,n){return a=>{if(t[0]===t[1]||n[0]===n[1])return n[0];const o=(n[1]-n[0])/(t[1]-t[0]);return n[0]+o*(a-t[0])}}Fe(Qg,"linearScale");function Jg(t,n){return t>0&&t{})=>{let a={left:t.scrollLeft,top:t.scrollTop},o=0;return Fe((function c(){const l={left:t.scrollLeft,top:t.scrollTop},d=a.left!==l.left,m=a.top!==l.top;(d||m)&&n(),a=l,o=window.requestAnimationFrame(c)}),"loop")(),()=>window.cancelAnimationFrame(o)},"addUnlinkedScrollListener");function dc(t,n){const a=Vt(t),o=f.useRef(0);return f.useEffect(()=>()=>window.clearTimeout(o.current),[]),f.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(a,n)},[a,n])}Fe(dc,"useDebounceCallback");function to(t,n){const a=Vt(n);St(()=>{let o=0;if(t){const c=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(a)});return c.observe(t),()=>{window.cancelAnimationFrame(o),c.unobserve(t)}}},[t,a])}Fe(to,"useResizeObserver");var YC=xR,AR=vR,_R=TR;const fc=f.forwardRef(({className:t,children:n,...a},o)=>s.jsxs(YC,{ref:o,className:pe("relative overflow-hidden",t),...a,children:[s.jsx(AR,{className:"h-full w-full rounded-[inherit]",children:n}),s.jsx(qC,{}),s.jsx(_R,{})]}));fc.displayName=YC.displayName;const qC=f.forwardRef(({className:t,orientation:n="vertical",...a},o)=>s.jsx(BC,{ref:o,orientation:n,className:pe("flex touch-none select-none transition-colors",n==="vertical"&&"h-full w-2 border-l border-l-transparent p-px",n==="horizontal"&&"h-2 flex-col border-t border-t-transparent p-px",t),...a,children:s.jsx(ER,{className:"relative flex-1 rounded-full bg-[hsl(240_4%_32%)] transition-colors hover:bg-[hsl(240_4%_44%)]"})}));qC.displayName=BC.displayName;function DR(t){const n=Math.floor((Date.now()-t)/1e3);if(n<60)return"Just now";const a=Math.floor(n/60);if(a<60)return`${a}m ago`;const o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function OR(t){switch(t){case"error":return"bg-destructive";case"update":return"bg-amber-500";case"bot":return"bg-emerald-500";default:return"bg-primary"}}function LR(){const t=ao(),{items:n,unreadCount:a,loading:o,markAllRead:c,dismiss:l,refresh:d}=dR(),[m,p]=f.useState(!1),g=v=>{p(v),v&&(d(),a>0&&c())},b=v=>{p(!1),v.href&&t(v.href)};return s.jsxs(zg,{open:m,onOpenChange:g,children:[s.jsx(Pg,{asChild:!0,children:s.jsxs(ue,{variant:"ghost",size:"icon",className:"relative size-9 text-muted-foreground","aria-label":"Notifications",children:[s.jsx(xe,{icon:N8,size:18}),a>0&&s.jsx(Fn,{className:"absolute -right-0.5 -top-0.5 flex size-4 min-w-4 items-center justify-center rounded-full bg-destructive p-0 text-[10px] text-destructive-foreground",children:a>9?"9+":a})]})}),s.jsxs(Fd,{align:"end",className:"w-80 p-0",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[s.jsx(Ig,{className:"p-0 text-sm font-semibold",children:"Notifications"}),n.length>0&&s.jsx(ue,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground",onClick:()=>void c(),children:"Mark all read"})]}),s.jsx(Fl,{className:"m-0"}),s.jsx(fc,{className:"max-h-[min(360px,50vh)]",children:o&&n.length===0?s.jsx("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"Loading…"}):n.length===0?s.jsx("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"No notifications yet. Bot restarts and update checks will appear here."}):s.jsx("ul",{className:"py-1",children:n.map(v=>s.jsxs("li",{className:pe("group flex gap-2 border-b border-border/40 px-3 py-2.5 last:border-0",!v.read&&"bg-primary/5"),children:[s.jsx("span",{className:pe("mt-1.5 size-2 shrink-0 rounded-full",OR(v.type))}),s.jsxs("button",{type:"button",className:"min-w-0 flex-1 text-left",onClick:()=>b(v),children:[s.jsx("p",{className:"text-sm font-medium leading-tight",children:v.title}),s.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground line-clamp-2",children:v.message}),s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground/80",children:DR(v.createdAt)})]}),s.jsx(ue,{variant:"ghost",size:"icon",className:"size-7 shrink-0 opacity-0 group-hover:opacity-100","aria-label":"Dismiss",onClick:w=>{w.stopPropagation(),l(v.id)},children:s.jsx(xe,{icon:ba,size:14})})]},v.id))})}),s.jsx(Fl,{className:"m-0"}),s.jsx("div",{className:"p-2",children:s.jsx(ue,{variant:"ghost",size:"sm",className:"w-full text-xs",asChild:!0,children:s.jsx(en,{to:"/settings",onClick:()=>p(!1),children:"Open settings (updates)"})})})]})]})}var zR=Object.defineProperty,PR=(t,n)=>zR(t,"name",{value:n,configurable:!0});function KC(t){const n=f.useRef({value:t,previous:t});return f.useMemo(()=>(n.current.value!==t&&(n.current.previous=n.current.value,n.current.value=t),n.current.previous),[t])}PR(KC,"usePrevious");var IR=Object.defineProperty,nt=(t,n)=>IR(t,"name",{value:n,configurable:!0}),UR=[" ","Enter","ArrowUp","ArrowDown"],BR=[" ","Enter"],fi="Select",[Zd,Qd,$R]=Td(fi),[co,VP]=bn(fi,[$R,Cs]),ex=Cs(),[HR,Ss]=co(fi),[GR,VR]=co(fi);function WC(t){const{__scopeSelect:n,children:a,open:o,defaultOpen:c,onOpenChange:l,value:d,defaultValue:m,onValueChange:p,dir:g,name:b,autoComplete:v,disabled:w,required:y,form:C,internal_do_not_use_render:S}=t,N=ex(n),[E,T]=f.useState(null),[M,k]=f.useState(null),[_,R]=f.useState(!1),L=Si(g),[ne,X]=Vr({prop:o,defaultProp:c??!1,onChange:l,caller:fi}),[I,H]=Vr({prop:d,defaultProp:m,onChange:p,caller:fi}),q=f.useRef(null),ce=f.useRef(I);f.useEffect(()=>{const D=C?E==null?void 0:E.ownerDocument.getElementById(C):E==null?void 0:E.form;if(D instanceof HTMLFormElement){const B=nt(()=>H(ce.current),"reset");return D.addEventListener("reset",B),()=>D.removeEventListener("reset",B)}},[C,E,H]);const de=E?!!C||!!E.closest("form"):!0,[se,P]=f.useState(new Set),W=nn(),oe=Array.from(se).map(D=>D.props.value).join(";"),ae=f.useCallback(D=>{P(B=>new Set(B).add(D))},[]),G=f.useCallback(D=>{P(B=>{const V=new Set(B);return V.delete(D),V})},[]),O={required:y,trigger:E,onTriggerChange:T,valueNode:M,onValueNodeChange:k,valueNodeHasChildren:_,onValueNodeHasChildrenChange:R,contentId:W,value:I,onValueChange:H,open:ne,onOpenChange:X,dir:L,triggerPointerDownPosRef:q,disabled:w,name:b,autoComplete:v,form:C,nativeOptions:se,nativeSelectKey:oe,isFormControl:de};return s.jsx(zd,{...N,children:s.jsx(HR,{scope:n,...O,children:s.jsx(Zd.Provider,{scope:n,children:s.jsx(GR,{scope:n,onNativeOptionAdd:ae,onNativeOptionRemove:G,children:oS(S)?S(O):a})})})})}nt(WC,"SelectProvider");var FR=nt(t=>{const{__scopeSelect:n,children:a,...o}=t;return s.jsx(WC,{__scopeSelect:n,...o,internal_do_not_use_render:({isFormControl:c})=>s.jsxs(s.Fragment,{children:[a,c?s.jsx(pA,{__scopeSelect:n}):null]})})},"Select"),YR="SelectTrigger",XC=f.forwardRef(nt(function(n,a){const{__scopeSelect:o,disabled:c=!1,...l}=n,d=ex(o),m=Ss(YR,o),p=m.disabled||c,g=Pe(a,m.onTriggerChange),b=Qd(o),v=f.useRef("touch"),[w,y,C]=nx(N=>{const E=b().filter(k=>!k.disabled),T=E.find(k=>k.value===m.value),M=rx(E,N,T);M!==void 0&&m.onValueChange(M.value)}),S=nt(N=>{p||(m.onOpenChange(!0),C()),N&&(m.triggerPointerDownPosRef.current={x:Math.round(N.pageX),y:Math.round(N.pageY)})},"handleOpen");return s.jsx(Pd,{asChild:!0,...d,children:s.jsx(Me.button,{type:"button",role:"combobox","aria-controls":m.open?m.contentId:void 0,"aria-expanded":m.open,"aria-required":m.required,"aria-autocomplete":"none",dir:m.dir,"data-state":m.open?"open":"closed",disabled:p,"data-disabled":p?"":void 0,"data-placeholder":mc(m.value)?"":void 0,...l,ref:g,onClick:Ce(l.onClick,N=>{N.currentTarget.focus(),v.current!=="mouse"&&S(N)}),onPointerDown:Ce(l.onPointerDown,N=>{v.current=N.pointerType;const E=N.target;E.hasPointerCapture(N.pointerId)&&E.releasePointerCapture(N.pointerId),N.button===0&&N.ctrlKey===!1&&N.pointerType==="mouse"&&(S(N),N.preventDefault())}),onKeyDown:Ce(l.onKeyDown,N=>{const E=w.current!=="";!(N.ctrlKey||N.altKey||N.metaKey)&&N.key.length===1&&y(N.key),!(E&&N.key===" ")&&UR.includes(N.key)&&(S(),N.preventDefault())})})})},"SelectTrigger")),qR="SelectValue",KR=f.forwardRef(nt(function(n,a){const{__scopeSelect:o,className:c,style:l,children:d,placeholder:m="",...p}=n,g=Ss(qR,o),{onValueNodeHasChildrenChange:b}=g,v=d!==void 0,w=Pe(a,g.onValueNodeChange);St(()=>{b(v)},[b,v]);const y=mc(g.value);return s.jsx(Me.span,{...p,asChild:y?!1:p.asChild,ref:w,style:{pointerEvents:"none"},children:s.jsx(f.Fragment,{children:y?m:d},y?"placeholder":"value")})},"SelectValue")),WR=f.forwardRef(nt(function(n,a){const{__scopeSelect:o,children:c,...l}=n;return s.jsx(Me.span,{"aria-hidden":!0,...l,ref:a,children:c||"▼"})},"SelectIcon")),XR="SelectPortal",[ZR,QR]=co(XR,{forceMount:void 0}),JR=nt(t=>{const{__scopeSelect:n,forceMount:a,...o}=t;return s.jsx(ZR,{scope:t.__scopeSelect,forceMount:a,children:s.jsx(rc,{asChild:!0,...o})})},"SelectPortal"),no="SelectContent",ZC=f.forwardRef(nt(function(n,a){const o=QR(no,n.__scopeSelect),{forceMount:c=o.forceMount,...l}=n,d=Ss(no,n.__scopeSelect),[m,p]=f.useState();return St(()=>{p(new DocumentFragment)},[]),s.jsx(fn,{present:c||d.open,children:({present:g})=>g?s.jsx(nA,{...l,ref:a}):s.jsx(eA,{...l,fragment:m})})},"SelectContent")),eA=f.forwardRef(nt(function(n,a){const{__scopeSelect:o,children:c,fragment:l}=n;return l?so.createPortal(s.jsx(QC,{scope:o,children:s.jsx(Zd.Slot,{scope:o,children:s.jsx("div",{ref:a,children:c})})}),l):null},"SelectContentFragment")),Cr=10,[QC,uo]=co(no),tA=Er("SelectContent.RemoveScroll"),nA=f.forwardRef(nt(function(n,a){const{__scopeSelect:o}=n,{position:c="item-aligned",onCloseAutoFocus:l,onEscapeKeyDown:d,onPointerDownOutside:m,side:p,sideOffset:g,align:b,alignOffset:v,arrowPadding:w,collisionBoundary:y,collisionPadding:C,sticky:S,hideWhenDetached:N,avoidCollisions:E,...T}=n,M=Ss(no,o),[k,_]=f.useState(null),[R,L]=f.useState(null),ne=Pe(a,_),[X,I]=f.useState(null),[H,q]=f.useState(null),ce=Qd(o),[de,se]=f.useState(!1),P=f.useRef(!1);f.useEffect(()=>{if(k)return $d(k)},[k]),Ni();const W=f.useCallback(ge=>{const[me,...$]=ce().map(Se=>Se.ref.current),[ie]=$.slice(-1),ye=document.activeElement;for(const Se of ge)if(Se===ye||(Se==null||Se.scrollIntoView({block:"nearest"}),Se===me&&R&&(R.scrollTop=0),Se===ie&&R&&(R.scrollTop=R.scrollHeight),Se==null||Se.focus(),document.activeElement!==ye))return},[ce,R]),oe=f.useCallback(()=>W([X,k]),[W,X,k]);f.useEffect(()=>{de&&oe()},[de,oe]);const{onOpenChange:ae,triggerPointerDownPosRef:G}=M;f.useEffect(()=>{if(k){let ge={x:0,y:0};const me=nt(ie=>{var ye,Se;ge={x:Math.abs(Math.round(ie.pageX)-(((ye=G.current)==null?void 0:ye.x)??0)),y:Math.abs(Math.round(ie.pageY)-(((Se=G.current)==null?void 0:Se.y)??0))}},"handlePointerMove"),$=nt(ie=>{ge.x<=10&&ge.y<=10?ie.preventDefault():ie.composedPath().includes(k)||ae(!1),document.removeEventListener("pointermove",me),G.current=null},"handlePointerUp");return G.current!==null&&(document.addEventListener("pointermove",me),document.addEventListener("pointerup",$,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",me),document.removeEventListener("pointerup",$,{capture:!0})}}},[k,ae,G]),f.useEffect(()=>{const ge=nt(()=>ae(!1),"close");return window.addEventListener("blur",ge),window.addEventListener("resize",ge),()=>{window.removeEventListener("blur",ge),window.removeEventListener("resize",ge)}},[ae]);const[O,D]=nx(ge=>{const me=ce().filter(ye=>!ye.disabled),$=me.find(ye=>ye.ref.current===document.activeElement),ie=rx(me,ge,$);ie&&setTimeout(()=>{var ye;return(ye=ie.ref.current)==null?void 0:ye.focus()})}),B=f.useCallback((ge,me,$)=>{const ie=!P.current&&!$;(M.value!==void 0&&M.value===me||ie)&&(I(ge),ie&&(P.current=!0))},[M.value]),V=f.useCallback(()=>k==null?void 0:k.focus(),[k]),Z=f.useCallback((ge,me,$)=>{const ie=!P.current&&!$;(M.value!==void 0&&M.value===me||ie)&&q(ge)},[M.value]),be=c==="popper"?S0:rA,K=be===S0?{side:p,sideOffset:g,align:b,alignOffset:v,arrowPadding:w,collisionBoundary:y,collisionPadding:C,sticky:S,hideWhenDetached:N,avoidCollisions:E}:{};return s.jsx(QC,{scope:o,content:k,viewport:R,onViewportChange:L,itemRefCallback:B,selectedItem:X,onItemLeave:V,itemTextRefCallback:Z,focusSelectedItem:oe,selectedItemText:H,position:c,isPositioned:de,searchRef:O,children:s.jsx(ac,{as:tA,allowPinchZoom:!0,children:s.jsx(Md,{asChild:!0,trapped:M.open,onMountAutoFocus:ge=>{ge.preventDefault()},onUnmountAutoFocus:Ce(l,ge=>{var me;(me=M.trigger)==null||me.focus({preventScroll:!0}),ge.preventDefault()}),children:s.jsx(nc,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:ge=>ge.preventDefault(),onDismiss:()=>M.onOpenChange(!1),children:s.jsx(be,{role:"listbox",id:M.contentId,"data-state":M.open?"open":"closed",dir:M.dir,onContextMenu:ge=>ge.preventDefault(),...T,...K,onPlaced:()=>se(!0),ref:ne,style:{display:"flex",flexDirection:"column",outline:"none",...T.style},onKeyDown:Ce(T.onKeyDown,ge=>{const me=ge.ctrlKey||ge.altKey||ge.metaKey;if(ge.key==="Tab"&&ge.preventDefault(),!me&&ge.key.length===1&&D(ge.key),["ArrowUp","ArrowDown","Home","End"].includes(ge.key)){let ie=ce().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);if(["ArrowUp","End"].includes(ge.key)&&(ie=ie.slice().reverse()),["ArrowUp","ArrowDown"].includes(ge.key)){const ye=ge.target,Se=ie.indexOf(ye);ie=ie.slice(Se+1)}setTimeout(()=>W(ie)),ge.preventDefault()}})})})})})})},"SelectContentImpl")),rA=f.forwardRef(nt(function(n,a){const{__scopeSelect:o,onPlaced:c,...l}=n,d=Ss(no,o),m=uo(no,o),[p,g]=f.useState(null),[b,v]=f.useState(null),w=Pe(a,v),y=Qd(o),C=f.useRef(!1),S=f.useRef(!0),{viewport:N,selectedItem:E,selectedItemText:T,focusSelectedItem:M}=m,k=f.useCallback(()=>{if(d.trigger&&d.valueNode&&p&&b&&N&&E&&T){const ne=d.trigger.getBoundingClientRect(),X=b.getBoundingClientRect(),I=d.valueNode.getBoundingClientRect(),H=T.getBoundingClientRect();if(d.dir!=="rtl"){const ye=H.left-X.left,Se=I.left-ye,Be=ne.left-Se,Ke=ne.width+Be,We=Math.max(Ke,X.width),qt=window.innerWidth-Cr,vn=ud(Se,[Cr,Math.max(Cr,qt-We)]);p.style.minWidth=Ke+"px",p.style.left=vn+"px"}else{const ye=X.right-H.right,Se=window.innerWidth-I.right-ye,Be=window.innerWidth-ne.right-Se,Ke=ne.width+Be,We=Math.max(Ke,X.width),qt=window.innerWidth-Cr,vn=ud(Se,[Cr,Math.max(Cr,qt-We)]);p.style.minWidth=Ke+"px",p.style.right=vn+"px"}const q=y(),ce=window.innerHeight-Cr*2,de=N.scrollHeight,se=window.getComputedStyle(b),P=parseInt(se.borderTopWidth,10),W=parseInt(se.paddingTop,10),oe=parseInt(se.borderBottomWidth,10),ae=parseInt(se.paddingBottom,10),G=P+W+de+ae+oe,O=Math.min(E.offsetHeight*5,G),D=window.getComputedStyle(N),B=parseInt(D.paddingTop,10),V=parseInt(D.paddingBottom,10),Z=ne.top+ne.height/2-Cr,be=ce-Z,K=E.offsetHeight/2,ge=E.offsetTop+K,me=P+W+ge,$=G-me;if(me<=Z){const ye=q.length>0&&E===q[q.length-1].ref.current;p.style.bottom="0px";const Se=b.clientHeight-N.offsetTop-N.offsetHeight,Be=Math.max(be,K+(ye?V:0)+Se+oe),Ke=me+Be;p.style.height=Ke+"px"}else{const ye=q.length>0&&E===q[0].ref.current;p.style.top="0px";const Be=Math.max(Z,P+N.offsetTop+(ye?B:0)+K)+$;p.style.height=Be+"px",N.scrollTop=me-Z+N.offsetTop}p.style.margin=`${Cr}px 0`,p.style.minHeight=O+"px",p.style.maxHeight=ce+"px",c==null||c(),requestAnimationFrame(()=>C.current=!0)}},[y,d.trigger,d.valueNode,p,b,N,E,T,d.dir,c]);St(()=>k(),[k]);const[_,R]=f.useState();St(()=>{b&&R(window.getComputedStyle(b).zIndex)},[b]);const L=f.useCallback(ne=>{ne&&S.current===!0&&(k(),M==null||M(),S.current=!1)},[k,M]);return s.jsx(aA,{scope:o,contentWrapper:p,shouldExpandOnScrollRef:C,onScrollButtonChange:L,children:s.jsx("div",{ref:g,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:_},children:s.jsx(Me.div,{...l,ref:w,style:{boxSizing:"border-box",maxHeight:"100%",...l.style}})})})},"SelectItemAlignedPosition")),S0=f.forwardRef(nt(function(n,a){const{__scopeSelect:o,align:c="start",collisionPadding:l=Cr,...d}=n,m=ex(o);return s.jsx(Id,{...m,...d,ref:a,align:c,collisionPadding:l,style:{boxSizing:"border-box",...d.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[aA,tx]=co(no,{}),N0="SelectViewport",sA=f.forwardRef(nt(function(n,a){const{__scopeSelect:o,nonce:c,...l}=n,d=uo(N0,o),m=tx(N0,o),p=Pe(a,d.onViewportChange),g=f.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:c}),s.jsx(Zd.Slot,{scope:o,children:s.jsx(Me.div,{"data-radix-select-viewport":"",role:"presentation",...l,ref:p,style:{position:"relative",flex:1,overflow:"hidden auto",...l.style},onScroll:Ce(l.onScroll,b=>{const v=b.currentTarget,{contentWrapper:w,shouldExpandOnScrollRef:y}=m;if(y!=null&&y.current&&w){const C=Math.abs(g.current-v.scrollTop);if(C>0){const S=window.innerHeight-Cr*2,N=parseFloat(w.style.minHeight),E=parseFloat(w.style.height),T=Math.max(N,E);if(T0?_:0,w.style.justifyContent="flex-end")}}}g.current=v.scrollTop})})})]})},"SelectViewport")),oA="SelectGroup",[FP,iA]=co(oA),lA="SelectLabel",JC=f.forwardRef(nt(function(n,a){const{__scopeSelect:o,...c}=n,l=iA(lA,o);return s.jsx(Me.div,{id:l.id,...c,ref:a})},"SelectLabel")),zh="SelectItem",[cA,eS]=co(zh),tS=f.forwardRef(nt(function(n,a){const{__scopeSelect:o,value:c,disabled:l=!1,textValue:d,...m}=n,p=Ss(zh,o),g=uo(zh,o),b=p.value===c,[v,w]=f.useState(d??""),[y,C]=f.useState(!1),S=Vt(k=>{var _;return(_=g.itemRefCallback)==null?void 0:_.call(g,k,c,l)}),N=Pe(a,S),E=nn(),T=f.useRef("touch"),M=nt(()=>{l||(p.onValueChange(c),p.onOpenChange(!1))},"handleSelect");return s.jsx(cA,{scope:o,value:c,disabled:l,textId:E,isSelected:b,onItemTextChange:f.useCallback(k=>{w(_=>_||((k==null?void 0:k.textContent)??"").trim())},[]),children:s.jsx(Zd.ItemSlot,{scope:o,value:c,disabled:l,textValue:v,children:s.jsx(Me.div,{role:"option","aria-labelledby":E,"data-highlighted":y?"":void 0,"aria-selected":b&&y,"data-state":b?"checked":"unchecked","aria-disabled":l||void 0,"data-disabled":l?"":void 0,tabIndex:l?void 0:-1,...m,ref:N,onFocus:Ce(m.onFocus,()=>C(!0)),onBlur:Ce(m.onBlur,()=>C(!1)),onClick:Ce(m.onClick,()=>{T.current!=="mouse"&&M()}),onPointerUp:Ce(m.onPointerUp,()=>{T.current==="mouse"&&M()}),onPointerDown:Ce(m.onPointerDown,k=>{T.current=k.pointerType}),onPointerMove:Ce(m.onPointerMove,k=>{var _;T.current=k.pointerType,l?(_=g.onItemLeave)==null||_.call(g):T.current==="mouse"&&k.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ce(m.onPointerLeave,k=>{var _;k.currentTarget===document.activeElement&&((_=g.onItemLeave)==null||_.call(g))}),onKeyDown:Ce(m.onKeyDown,k=>{var R;l||k.target!==k.currentTarget||((R=g.searchRef)==null?void 0:R.current)!==""&&k.key===" "||(BR.includes(k.key)&&M(),k.key===" "&&k.preventDefault())})})})})},"SelectItem")),Pu="SelectItemText",uA=f.forwardRef(nt(function(n,a){const{__scopeSelect:o,className:c,style:l,...d}=n,m=Ss(Pu,o),p=uo(Pu,o),g=eS(Pu,o),b=VR(Pu,o),[v,w]=f.useState(null),y=Vt(M=>{var k;return(k=p.itemTextRefCallback)==null?void 0:k.call(p,M,g.value,g.disabled)}),C=Pe(a,w,g.onItemTextChange,y),S=v==null?void 0:v.textContent,N=f.useMemo(()=>s.jsx("option",{value:g.value,disabled:g.disabled,children:S},g.value),[g.disabled,g.value,S]),{onNativeOptionAdd:E,onNativeOptionRemove:T}=b;return St(()=>(E(N),()=>T(N)),[E,T,N]),s.jsxs(s.Fragment,{children:[s.jsx(Me.span,{id:g.textId,...d,ref:C}),g.isSelected&&m.valueNode&&!m.valueNodeHasChildren&&!mc(m.value)?so.createPortal(d.children,m.valueNode):null]})},"SelectItemText")),dA="SelectItemIndicator",fA=f.forwardRef(nt(function(n,a){const{__scopeSelect:o,...c}=n;return eS(dA,o).isSelected?s.jsx(Me.span,{"aria-hidden":!0,...c,ref:a}):null},"SelectItemIndicator")),E0="SelectScrollUpButton",nS=f.forwardRef(nt(function(n,a){const o=uo(E0,n.__scopeSelect),c=tx(E0,n.__scopeSelect),[l,d]=f.useState(!1),m=Pe(a,c.onScrollButtonChange);return St(()=>{if(o.viewport&&o.isPositioned){let p=function(){const b=g.scrollTop>0;d(b)};nt(p,"handleScroll");const g=o.viewport;return p(),g.addEventListener("scroll",p),()=>g.removeEventListener("scroll",p)}},[o.viewport,o.isPositioned]),l?s.jsx(aS,{...n,ref:m,onAutoScroll:()=>{const{viewport:p,selectedItem:g}=o;p&&g&&(p.scrollTop=p.scrollTop-g.offsetHeight)}}):null},"SelectScrollUpButton")),k0="SelectScrollDownButton",rS=f.forwardRef(nt(function(n,a){const o=uo(k0,n.__scopeSelect),c=tx(k0,n.__scopeSelect),[l,d]=f.useState(!1),m=Pe(a,c.onScrollButtonChange);return St(()=>{if(o.viewport&&o.isPositioned){let p=function(){const b=g.scrollHeight-g.clientHeight,v=Math.ceil(g.scrollTop)g.removeEventListener("scroll",p)}},[o.viewport,o.isPositioned]),l?s.jsx(aS,{...n,ref:m,onAutoScroll:()=>{const{viewport:p,selectedItem:g}=o;p&&g&&(p.scrollTop=p.scrollTop+g.offsetHeight)}}):null},"SelectScrollDownButton")),aS=f.forwardRef(nt(function(n,a){const{__scopeSelect:o,onAutoScroll:c,...l}=n,d=uo("SelectScrollButton",o),m=f.useRef(null),p=Qd(o),g=f.useCallback(()=>{m.current!==null&&(window.clearInterval(m.current),m.current=null)},[]);return f.useEffect(()=>()=>g(),[g]),St(()=>{var v;const b=p().find(w=>w.ref.current===document.activeElement);(v=b==null?void 0:b.ref.current)==null||v.scrollIntoView({block:"nearest"})},[p]),s.jsx(Me.div,{"aria-hidden":!0,...l,ref:a,style:{flexShrink:0,...l.style},onPointerDown:Ce(l.onPointerDown,()=>{m.current===null&&(m.current=window.setInterval(c,50))}),onPointerMove:Ce(l.onPointerMove,()=>{var b;(b=d.onItemLeave)==null||b.call(d),m.current===null&&(m.current=window.setInterval(c,50))}),onPointerLeave:Ce(l.onPointerLeave,()=>{g()})})},"SelectScrollButtonImpl")),sS=f.forwardRef(nt(function(n,a){const{__scopeSelect:o,...c}=n;return s.jsx(Me.div,{"aria-hidden":!0,...c,ref:a})},"SelectSeparator")),mA="SelectBubbleInput",pA=f.forwardRef(nt(function({__scopeSelect:n,...a},o){const c=Ss(mA,n),{value:l,onValueChange:d,required:m,disabled:p,name:g,autoComplete:b,form:v}=c,{nativeOptions:w,nativeSelectKey:y}=c,C=f.useRef(null),S=Pe(o,C),N=l??"",E=KC(N),T=Array.from(w).some(M=>(M.props.value??"")==="");return f.useEffect(()=>{const M=C.current;if(!M)return;const k=window.HTMLSelectElement.prototype,R=Object.getOwnPropertyDescriptor(k,"value").set;if(E!==N&&R){const L=new Event("change",{bubbles:!0});R.call(M,N),M.dispatchEvent(L)}},[E,N]),s.jsxs(Me.select,{"aria-hidden":!0,required:m,tabIndex:-1,name:g,autoComplete:b,disabled:p,form:v,onChange:M=>d(M.target.value),...a,style:{...Kj,...a.style},ref:S,defaultValue:N,children:[mc(l)&&!T?s.jsx("option",{value:""}):null,Array.from(w)]},y)},"SelectBubbleInput"));function oS(t){return typeof t=="function"}nt(oS,"isFunction");function mc(t){return t===""||t===void 0}nt(mc,"shouldShowPlaceholder");function nx(t){const n=Vt(t),a=f.useRef(""),o=f.useRef(0),c=f.useCallback(d=>{const m=a.current+d;n(m),nt((function p(g){a.current=g,window.clearTimeout(o.current),g!==""&&(o.current=window.setTimeout(()=>p(""),1e3))}),"updateSearch")(m)},[n]),l=f.useCallback(()=>{a.current="",window.clearTimeout(o.current)},[]);return f.useEffect(()=>()=>window.clearTimeout(o.current),[]),[a,c,l]}nt(nx,"useTypeaheadSearch");function rx(t,n,a){const c=n.length>1&&Array.from(n).every(g=>g===n[0])?n[0]:n,l=a?t.indexOf(a):-1;let d=iS(t,Math.max(l,0));c.length===1&&(d=d.filter(g=>g!==a));const p=d.find(g=>g.textValue.toLowerCase().startsWith(c.toLowerCase()));return p!==a?p:void 0}nt(rx,"findNextItem");function iS(t,n){return t.map((a,o)=>t[(n+o)%t.length])}nt(iS,"wrapArray");const Ca=FR,Sa=KR,Hr=f.forwardRef(({className:t,children:n,...a},o)=>s.jsxs(XC,{ref:o,className:pe("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...a,children:[n,s.jsx(WR,{asChild:!0,children:s.jsx(Lj,{className:"h-4 w-4 opacity-50"})})]}));Hr.displayName=XC.displayName;const lS=f.forwardRef(({className:t,...n},a)=>s.jsx(nS,{ref:a,className:pe("flex cursor-default items-center justify-center py-1",t),...n,children:s.jsx(PT,{className:"h-4 w-4"})}));lS.displayName=nS.displayName;const cS=f.forwardRef(({className:t,...n},a)=>s.jsx(rS,{ref:a,className:pe("flex cursor-default items-center justify-center py-1",t),...n,children:s.jsx(Lj,{className:"h-4 w-4"})}));cS.displayName=rS.displayName;const Gr=f.forwardRef(({className:t,children:n,position:a="popper",...o},c)=>s.jsx(JR,{children:s.jsxs(ZC,{ref:c,className:pe("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,...o,children:[s.jsx(lS,{}),s.jsx(sA,{className:pe("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),s.jsx(cS,{})]})}));Gr.displayName=ZC.displayName;const hA=f.forwardRef(({className:t,...n},a)=>s.jsx(JC,{ref:a,className:pe("px-2 py-1.5 text-sm font-semibold",t),...n}));hA.displayName=JC.displayName;const Et=f.forwardRef(({className:t,children:n,...a},o)=>s.jsxs(tS,{ref:o,className:pe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[s.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(fA,{children:s.jsx(Oj,{className:"h-4 w-4"})})}),s.jsx(uA,{children:n})]}));Et.displayName=tS.displayName;const gA=f.forwardRef(({className:t,...n},a)=>s.jsx(sS,{ref:a,className:pe("-mx-1 my-1 h-px bg-muted",t),...n}));gA.displayName=sS.displayName;function xA(){const{stats:t}=kd(),{user:n,logout:a,availableGroups:o,isImpersonating:c,impersonatedGroup:l,impersonateGroup:d,stopImpersonation:m,hasPermission:p}=Yt();n!=null&&n.isOwner||p("users.manage");const g=(t==null?void 0:t.bot.username)??"SupportBot",b=n?P2(n):g,v=(n==null?void 0:n.avatar)??(t==null?void 0:t.bot.avatar),w=t==null?void 0:t.bot.inviteUrl,y=new Intl.DateTimeFormat("en-US",{weekday:"short",month:"short",day:"numeric",year:"numeric"}).format(new Date);return s.jsxs(s.Fragment,{children:[c&&l&&s.jsxs("div",{className:"relative z-50 flex items-center justify-between gap-3 bg-gradient-to-r from-amber-500/10 via-amber-500/15 to-amber-500/10 border-b border-amber-500/30 px-4 py-2 text-xs backdrop-blur-md shadow-sm",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-amber-500/20 text-amber-300 text-[11px] font-bold tracking-wide uppercase border border-amber-500/30",children:[s.jsx("span",{className:"size-1.5 rounded-full bg-amber-400 animate-pulse"}),"Preview Mode"]}),s.jsxs("div",{className:"flex items-center gap-2 text-foreground font-medium",children:[s.jsx("span",{className:"text-muted-foreground",children:"Viewing dashboard as:"}),s.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-md bg-secondary/80 border border-border/80",children:[s.jsx("span",{className:"size-2 rounded-full shrink-0 shadow-sm",style:{backgroundColor:l.color||"#10B981"}}),s.jsx("span",{className:"font-semibold text-xs text-foreground",children:l.name})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2.5",children:[o.length>1&&s.jsxs(Ca,{value:l.id,onValueChange:C=>d(C),children:[s.jsx(Hr,{className:"h-7 text-xs bg-background/80 border-amber-500/30 text-amber-200 focus:ring-amber-500/40 w-[160px]",children:s.jsx(Sa,{})}),s.jsx(Gr,{className:"border-border bg-card",children:o.map(C=>s.jsx(Et,{value:C.id,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"size-2 rounded-full shrink-0",style:{backgroundColor:C.color||"#10B981"}}),s.jsx("span",{children:C.name})]})},C.id))})]}),s.jsx(ue,{size:"sm",variant:"outline",className:"h-7 px-3 text-xs bg-card border-amber-500/40 text-amber-300 hover:bg-amber-500/20 hover:text-white transition-all shadow-sm",onClick:m,children:"Exit Preview Mode"})]})]}),s.jsxs("header",{className:"relative z-40 flex h-14 shrink-0 items-center gap-3 border-b border-border bg-card px-4 md:px-6",children:[s.jsx(cC,{className:"-ml-1 text-muted-foreground hover:text-foreground md:hidden"}),s.jsx("p",{className:"hidden shrink-0 text-sm font-medium text-muted-foreground lg:block",children:y}),s.jsx(nR,{className:"min-w-0 flex-1"}),s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[w?s.jsx(ue,{variant:"ghost",size:"icon",className:"hidden size-9 text-muted-foreground sm:inline-flex",asChild:!0,children:s.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer","aria-label":"Invite bot to a server",title:"Invite bot to a server",children:s.jsx(xe,{icon:nh,size:18})})}):s.jsx(ue,{variant:"ghost",size:"icon",className:"hidden size-9 text-muted-foreground sm:inline-flex",disabled:!0,"aria-label":"Invite bot to a server",title:"Invite link available when the bot is online",children:s.jsx(xe,{icon:nh,size:18})}),s.jsx(LR,{}),s.jsxs(zg,{children:[s.jsx(Pg,{asChild:!0,children:s.jsxs(ue,{variant:"ghost",className:"h-9 gap-2 rounded-full px-2 hover:bg-secondary",children:[s.jsxs(vs,{className:"size-7",children:[s.jsx(eo,{src:v,alt:b}),s.jsx(ys,{className:"bg-primary/20 text-xs text-primary",children:b.slice(0,2).toUpperCase()})]}),s.jsx("span",{className:"hidden max-w-[100px] truncate text-sm font-medium sm:inline",children:b}),s.jsx(xe,{icon:k2,size:16,className:"text-muted-foreground"})]})}),s.jsxs(Fd,{align:"end",className:"w-56",children:[s.jsx(Ig,{children:"Account"}),s.jsx(Fl,{}),n?s.jsxs(Vl,{disabled:!0,className:"text-xs text-muted-foreground",children:[n.username,n.id?` · ${n.id}`:""]}):null,s.jsx(Fl,{}),s.jsx(Vl,{onClick:()=>{a()},children:"Sign out"})]})]})]})]})]})}const T0={error:0,warning:1,info:2};function bA(t){return[...t].sort((n,a)=>{const o=T0[n.severity]??9,c=T0[a.severity]??9;return o!==c?o-c:n.title.localeCompare(a.title)})}function vA(t){const n=new Set;return t.filter(a=>n.has(a.id)?!1:(n.add(a.id),!0))}class yA{constructor(){by(this,"clientProviders",new Map)}register(n){return this.clientProviders.set(n.id,n),this}unregister(n){this.clientProviders.delete(n)}async evaluateClientProviders(){const n=[];for(const a of this.clientProviders.values()){const o=await a.evaluate();Array.isArray(o)&&o.length&&n.push(...o)}return n}async loadAll(){const[n,a]=await Promise.all([Ne.getAlerts().catch(()=>({data:[]})),this.evaluateClientProviders()]),o=n.data??[];return bA(vA([...o,...a]))}}const wA=new yA,jA={error:{border:"border-destructive/40",bg:"bg-destructive/10",icon:"text-destructive",title:"text-destructive"},warning:{border:"border-amber-500/40",bg:"bg-amber-500/10",icon:"text-amber-500",title:"text-amber-200"},info:{border:"border-sky-500/40",bg:"bg-sky-500/10",icon:"text-sky-400",title:"text-sky-100"}},CA=ji("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Ye=f.forwardRef(({className:t,variant:n,...a},o)=>s.jsx("div",{ref:o,role:"alert",className:pe(CA({variant:n}),t),...a}));Ye.displayName="Alert";const uS=f.forwardRef(({className:t,...n},a)=>s.jsx("h5",{ref:a,className:pe("mb-1 font-medium leading-none tracking-tight",t),...n}));uS.displayName="AlertTitle";const qe=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,className:pe("text-sm [&_p]:leading-relaxed",t),...n}));qe.displayName="AlertDescription";function SA(t){return t==="info"?w8:ig}function NA({alert:t,context:n}){var d,m,p;const a=jA[t.severity],o=((d=t.meta)==null?void 0:d.extraGuilds)??[],c=(m=t.meta)==null?void 0:m.status,l=(p=t.meta)==null?void 0:p.progress;return s.jsxs(Ye,{variant:"destructive",className:`${a.border} ${a.bg} text-foreground`,children:[s.jsx(xe,{icon:SA(t.severity),size:18,className:a.icon}),s.jsx(uS,{className:a.title,children:t.title}),s.jsxs(qe,{className:"space-y-3 text-sm text-muted-foreground",children:[s.jsx("p",{children:t.message}),t.category==="guild"&&c==="missing_config"?s.jsxs("p",{children:["Open"," ",s.jsx(en,{to:"/configs?file=supportbot",className:"font-medium text-primary underline-offset-4 hover:underline",children:"Bot config"})," ","and set ",s.jsx("strong",{className:"text-foreground",children:"Server (guild) ID"})," ","(enable Developer Mode in Discord, then right-click your server → Copy Server ID)."]}):null,t.category==="modules"&&l?s.jsxs("p",{className:"text-xs",children:["Progress: ",s.jsx("span",{className:"text-foreground",children:l})]}):null,o.length>0?s.jsx("ul",{className:"space-y-2",children:o.map(g=>s.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-border bg-background/40 px-3 py-2",children:[s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-foreground",children:g.name}),s.jsx("span",{className:"ml-2 font-mono text-xs",children:g.id})]}),n.canLeaveGuild?s.jsxs(ue,{type:"button",size:"sm",variant:"outline",disabled:n.leavingGuildId===g.id,onClick:()=>void n.onLeaveGuild(g.id),children:[s.jsx(xe,{icon:j8,size:14,className:"mr-1.5"}),n.leavingGuildId===g.id?"Leaving…":"Leave server"]}):null]},g.id))}):null,n.actionError?s.jsx("p",{className:"text-destructive",children:n.actionError}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.action?s.jsx(ue,{asChild:!0,size:"sm",variant:"secondary",children:s.jsx(en,{to:t.action.href,children:t.action.label})}):null,t.category==="guild"?s.jsx("p",{className:"text-xs",children:"The dashboard stays online while you fix this. Some features may be limited until setup is complete."}):null]})]})]})}const EA=15e3;function kA(){const{hasPermission:t}=Yt(),n=t("settings.update"),[a,o]=f.useState([]),[c,l]=f.useState(null),[d,m]=f.useState(""),p=f.useCallback(async()=>{try{const v=await wA.loadAll();o(v),m("")}catch{}},[]);f.useEffect(()=>{p();const v=window.setInterval(()=>void p(),EA);return()=>window.clearInterval(v)},[p]);async function g(v){if(n){l(v),m("");try{await Ne.leaveGuild(v),await p()}catch(w){m(w instanceof Error?w.message:"Could not leave server")}finally{l(null)}}}if(a.length===0)return null;const b={canLeaveGuild:n,onLeaveGuild:g,leavingGuildId:c,actionError:d};return s.jsx("div",{className:"space-y-3",children:a.map(v=>s.jsx(NA,{alert:v,context:b},v.id))})}function TA(){return s.jsx($8,{children:s.jsx(uR,{children:s.jsxs(iC,{children:[s.jsx(rM,{}),s.jsxs(dC,{className:"min-h-svh bg-background",children:[s.jsx(xA,{}),s.jsxs("div",{className:"flex flex-1 flex-col gap-6 p-4 md:p-6 lg:p-8",children:[s.jsx(kA,{}),s.jsx(_N,{})]})]})]})})})}const dS=f.createContext(null);function MA({children:t}){const[n,a]=f.useState(null),[o,c]=f.useState(!0),[l,d]=f.useState(""),m=f.useCallback(async()=>{d("");try{const g=await Ne.getSetupStatus();a(g.data??null)}catch(g){d(g instanceof Error?g.message:"Could not load setup status"),a(null)}},[]);f.useEffect(()=>{m().finally(()=>c(!1))},[m]);const p=f.useMemo(()=>({status:n,loading:o,error:l,complete:!!(n!=null&&n.complete),refresh:m}),[n,o,l,m]);return s.jsx(dS.Provider,{value:p,children:t})}function fS(){const t=f.useContext(dS);if(!t)throw new Error("useSetup must be used within SetupProvider");return t}var RA=Object.defineProperty,AA=(t,n)=>RA(t,"name",{value:n,configurable:!0}),_A=f.forwardRef(AA(function(n,a){return s.jsx(Me.label,{...n,ref:a,onMouseDown:o=>{var l;o.target.closest("button, input, select, textarea")||((l=n.onMouseDown)==null||l.call(n,o),!o.defaultPrevented&&o.detail>1&&o.preventDefault())}})},"Label")),mS=_A;const DA=ji("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ae=f.forwardRef(({className:t,...n},a)=>s.jsx(mS,{ref:a,className:pe(DA(),t),...n}));Ae.displayName=mS.displayName;var OA=Object.defineProperty,ws=(t,n)=>OA(t,"name",{value:n,configurable:!0}),ax="Switch",[LA,YP]=bn(ax),[zA,sx]=LA(ax);function pS(t){const{__scopeSwitch:n,checked:a,children:o,defaultChecked:c,disabled:l,form:d,name:m,onCheckedChange:p,required:g,value:b="on",internal_do_not_use_render:v}=t,[w,y]=Vr({prop:a,defaultProp:c??!1,onChange:p,caller:ax}),[C,S]=f.useState(null),[N,E]=f.useState(null),T=f.useRef(!1),[M,k]=f.useReducer(L=>L+1,0),_=C?!!d||!!C.closest("form"):!0,R={checked:w,setChecked:y,disabled:l,control:C,setControl:S,name:m,form:d,value:b,hasConsumerStoppedPropagationRef:T,userInteractionCount:M,onUserInteraction:k,required:g,defaultChecked:c,isFormControl:_,bubbleInput:N,setBubbleInput:E};return s.jsx(zA,{scope:n,...R,children:gS(v)?v(R):o})}ws(pS,"SwitchProvider");var PA="SwitchTrigger",IA=f.forwardRef(ws(function({__scopeSwitch:n,onClick:a,...o},c){const{control:l,form:d,value:m,disabled:p,checked:g,required:b,setControl:v,setChecked:w,hasConsumerStoppedPropagationRef:y,onUserInteraction:C,isFormControl:S,bubbleInput:N}=sx(PA,n),E=Pe(c,v),T=f.useRef(g);return f.useEffect(()=>{const M=d?l==null?void 0:l.ownerDocument.getElementById(d):l==null?void 0:l.form;if(M instanceof HTMLFormElement){const k=ws(()=>w(T.current),"reset");return M.addEventListener("reset",k),()=>M.removeEventListener("reset",k)}},[l,d,w]),s.jsx(Me.button,{type:"button",role:"switch","aria-checked":g,"aria-required":b,"data-state":ox(g),"data-disabled":p?"":void 0,disabled:p,value:m,...o,ref:E,onClick:Ce(a,M=>{C(),w(k=>!k),N&&S&&(y.current=M.isPropagationStopped(),y.current||M.stopPropagation())})})},"SwitchTrigger")),hS=f.forwardRef(ws(function(n,a){const{__scopeSwitch:o,name:c,checked:l,defaultChecked:d,required:m,disabled:p,value:g,onCheckedChange:b,form:v,...w}=n;return s.jsx(pS,{__scopeSwitch:o,checked:l,defaultChecked:d,disabled:p,required:m,onCheckedChange:b,name:c,form:v,value:g,internal_do_not_use_render:({isFormControl:y})=>s.jsxs(s.Fragment,{children:[s.jsx(IA,{...w,ref:a,__scopeSwitch:o}),y&&s.jsx(HA,{__scopeSwitch:o})]})})},"Switch")),UA="SwitchThumb",BA=f.forwardRef(ws(function(n,a){const{__scopeSwitch:o,...c}=n,l=sx(UA,o);return s.jsx(Me.span,{"data-state":ox(l.checked),"data-disabled":l.disabled?"":void 0,...c,ref:a})},"SwitchThumb")),$A="SwitchBubbleInput",HA=f.forwardRef(ws(function({__scopeSwitch:n,onClick:a,...o},c){const{control:l,hasConsumerStoppedPropagationRef:d,userInteractionCount:m,checked:p,defaultChecked:g,required:b,disabled:v,name:w,value:y,form:C,bubbleInput:S,setBubbleInput:N}=sx($A,n),E=Pe(c,N),T=kg(l),M=f.useRef(!1),k=f.useRef(p),_=f.useRef(m);f.useEffect(()=>{const L=S;if(!L)return;const ne=window.HTMLInputElement.prototype,I=Object.getOwnPropertyDescriptor(ne,"checked").set,H=m!==_.current;_.current=m;const q=k.current!==p;k.current=p;const ce=!(H&&d.current);if(q&&I){M.current=!H;const de=new Event("click",{bubbles:ce});I.call(L,p),L.dispatchEvent(de),M.current=!1}},[S,p,d,m]);const R=f.useRef(p);return s.jsx(Me.input,{type:"checkbox","aria-hidden":!0,defaultChecked:g??R.current,required:b,disabled:v,name:w,value:y,form:C,...o,tabIndex:-1,ref:E,onClick:Ce(a,L=>{M.current&&L.stopPropagation()}),style:{...o.style,...T,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function gS(t){return typeof t=="function"}ws(gS,"isFunction");function ox(t){return t?"checked":"unchecked"}ws(ox,"getState");const Mt=f.forwardRef(({className:t,...n},a)=>s.jsx(hS,{className:pe("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...n,ref:a,children:s.jsx(BA,{className:pe("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Mt.displayName=hS.displayName;const Jd=f.forwardRef(({className:t,...n},a)=>s.jsx("textarea",{className:pe("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:a,...n}));Jd.displayName="Textarea";function ef(){return(ef=Object.assign||function(t){for(var n=1;n=0||(c[a]=t[a]);return c}function Dl(t){var n=f.useRef(t),a=f.useRef(function(o){n.current&&n.current(o)});return n.current=t,a.current}var Wl=function(t,n,a){return n===void 0&&(n=0),a===void 0&&(a=1),t>a?a:t0:M.buttons>0)&&l.current?d(M0(l.current,M,g.current)):(T(!1),p())},E=function(){T(!1),p()};function T(M){var k=b.current,_=Ph(l.current),R=M?_.addEventListener:_.removeEventListener;R(k?"touchmove":"mousemove",N),R(k?"touchend":"mouseup",E)}return[function(M){var k=M.nativeEvent,_=l.current;if(_&&(R0(k),!(function(L,ne){return ne&&!Ol(L)})(k,b.current)&&_)){if(Ol(k)){b.current=!0;var R=k.changedTouches||[];R.length&&(g.current=R[0].identifier)}_.focus(),d(M0(_,k,g.current)),T(!0)}},function(M){var k=M.which||M.keyCode;k<37||k>40||(M.preventDefault(),m({left:k===39?.05:k===37?-.05:0,top:k===40?.05:k===38?-.05:0}))},function(M){var k=M.which||M.keyCode;k>=37&&k<=40&&p()},T]},[m,d,p]),w=v[0],y=v[1],C=v[2],S=v[3];return f.useEffect(function(){return S},[S]),ve.createElement("div",ef({},c,{onTouchStart:w,onMouseDown:w,className:"react-colorful__interactive",ref:l,onKeyDown:y,onKeyUp:C,tabIndex:0,role:"slider"}))}),ix=function(t){return t.filter(Boolean).join(" ")},vS=function(t){var n=t.color,a=t.left,o=t.top,c=o===void 0?.5:o,l=ix(["react-colorful__pointer",t.className]);return ve.createElement("div",{className:l,style:{top:100*c+"%",left:100*a+"%"}},ve.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:n}}))},dn=function(t,n,a){return n===void 0&&(n=0),a===void 0&&(a=Math.pow(10,n)),Math.round(a*t)/a},GA=function(t){return KA(Ih(t))},Ih=function(t){return t[0]==="#"&&(t=t.substring(1)),t.length<6?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?dn(parseInt(t[3]+t[3],16)/255,2):1}:{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16),a:t.length===8?dn(parseInt(t.substring(6,8),16)/255,2):1}},VA=function(t){return qA(YA(t))},FA=function(t){var n=t.s,a=t.v,o=t.a,c=(200-n)*a/100;return{h:dn(t.h),s:dn(c>0&&c<200?n*a/100/(c<=100?c:200-c)*100:0),l:dn(c/2),a:dn(o,2)}},Uh=function(t){var n=FA(t);return"hsl("+n.h+", "+n.s+"%, "+n.l+"%)"},YA=function(t){var n=t.h,a=t.s,o=t.v,c=t.a;n=n/360*6,a/=100,o/=100;var l=Math.floor(n),d=o*(1-a),m=o*(1-(n-l)*a),p=o*(1-(1-n+l)*a),g=l%6;return{r:dn(255*[o,m,d,d,p,o][g]),g:dn(255*[p,o,o,m,d,d][g]),b:dn(255*[d,d,p,o,o,m][g]),a:dn(c,2)}},Iu=function(t){var n=t.toString(16);return n.length<2?"0"+n:n},qA=function(t){var n=t.r,a=t.g,o=t.b,c=t.a,l=c<1?Iu(dn(255*c)):"";return"#"+Iu(n)+Iu(a)+Iu(o)+l},KA=function(t){var n=t.r,a=t.g,o=t.b,c=t.a,l=Math.max(n,a,o),d=l-Math.min(n,a,o),m=d?l===n?(a-o)/d:l===a?2+(o-n)/d:4+(n-a)/d:0;return{h:dn(60*(m<0?m+6:m)),s:dn(l?d/l*100:0),v:dn(l/255*100),a:c}},WA=ve.memo(function(t){var n=t.hue,a=t.onChange,o=t.onChangeEnd,c=ix(["react-colorful__hue",t.className]);return ve.createElement("div",{className:c},ve.createElement(bS,{onMove:function(l){a({h:360*l.left})},onKey:function(l){a({h:Wl(n+360*l.left,0,360)})},onEnd:o,"aria-label":"Hue","aria-valuenow":dn(n),"aria-valuemax":"360","aria-valuemin":"0"},ve.createElement(vS,{className:"react-colorful__hue-pointer",left:n/360,color:Uh({h:n,s:100,v:100,a:1})})))}),XA=ve.memo(function(t){var n=t.hsva,a=t.onChange,o=t.onChangeEnd,c={backgroundColor:Uh({h:n.h,s:100,v:100,a:1})};return ve.createElement("div",{className:"react-colorful__saturation",style:c},ve.createElement(bS,{onMove:function(l){a({s:100*l.left,v:100-100*l.top})},onKey:function(l){a({s:Wl(n.s+100*l.left,0,100),v:Wl(n.v-100*l.top,0,100)})},onEnd:o,"aria-label":"Color","aria-valuetext":"Saturation "+dn(n.s)+"%, Brightness "+dn(n.v)+"%"},ve.createElement(vS,{className:"react-colorful__saturation-pointer",top:1-n.v/100,left:n.s/100,color:Uh(n)})))}),yS=function(t,n){if(t===n)return!0;for(var a in t)if(t[a]!==n[a])return!1;return!0},ZA=function(t,n){return t.toLowerCase()===n.toLowerCase()||yS(Ih(t),Ih(n))};function QA(t,n,a,o){var c=Dl(a),l=Dl(o),d=f.useState(function(){return t.toHsva(n)}),m=d[0],p=d[1],g=f.useRef({color:n,hsva:m}),b=f.useRef(!1);f.useEffect(function(){if(!t.equal(n,g.current.color)){var y=t.toHsva(n);g.current={hsva:y,color:n},p(y),b.current=!1}},[n,t]),f.useEffect(function(){var y;yS(m,g.current.hsva)||t.equal(y=t.fromHsva(m),g.current.color)||(g.current={hsva:m,color:y},c(y),b.current=!0)},[m,t,c]);var v=f.useCallback(function(y){p(function(C){return Object.assign({},C,y)})},[]),w=f.useCallback(function(){b.current&&(b.current=!1,l(g.current.color))},[l]);return[m,v,w]}var JA=typeof window<"u"?f.useLayoutEffect:f.useEffect,e_=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},A0=new WeakMap,t_=function(t){JA(function(){var n=t.current;if(typeof document<"u"&&n){var a=n.getRootNode?n.getRootNode():n.ownerDocument,o=a&&("head"in a||"host"in a)?a:n.ownerDocument;if(!A0.has(o)){var c="head"in o?o.head:o,l=(c.ownerDocument||document).createElement("style");l.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`;var d=e_();d&&l.setAttribute("nonce",d),A0.set(o,l),c.appendChild(l)}}},[])},n_=function(t){var n=t.className,a=t.colorModel,o=t.color,c=o===void 0?a.defaultColor:o,l=t.onChange,d=t.onChangeEnd,m=xS(t,["className","colorModel","color","onChange","onChangeEnd"]),p=f.useRef(null);t_(p);var g=QA(a,c,l,d),b=g[0],v=g[1],w=g[2],y=ix(["react-colorful",n]);return ve.createElement("div",ef({},m,{ref:p,className:y}),ve.createElement(XA,{hsva:b,onChange:v,onChangeEnd:w}),ve.createElement(WA,{hue:b.h,onChange:v,onChangeEnd:w,className:"react-colorful__last-control"}))},r_={defaultColor:"000",toHsva:GA,fromHsva:function(t){return VA({h:t.h,s:t.s,v:t.v,a:1})},equal:ZA},a_=function(t){return ve.createElement(n_,ef({},t,{colorModel:r_}))};function $r(t,n="#000000"){let a=String(t??"").trim();if(!a)return n;a.startsWith("#")||(a=`#${a}`);const o=a.slice(1);return/^[0-9a-fA-F]{3}$/.test(o)?`#${o.split("").map(c=>c+c).join("").toLowerCase()}`:/^[0-9a-fA-F]{6}$/.test(o)?`#${o.toLowerCase()}`:n}function Bh(t){const n=String(t??"").trim();return/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(n)||/^[0-9a-fA-F]{6}$/.test(n)}function s_(t){const n=f.useRef(null);return f.useEffect(()=>{t&&(typeof t=="function"?t(n.current):t.current=n.current)}),n}var o_=Object.defineProperty,Ns=(t,n)=>o_(t,"name",{value:n,configurable:!0}),lx="Popover",[wS,qP]=bn(lx,[Cs]),cx=Cs(),[i_,Ti]=wS(lx),l_=Ns(t=>{const{__scopePopover:n,children:a,open:o,defaultOpen:c,onOpenChange:l,modal:d=!1}=t,m=cx(n),p=f.useRef(null),[g,b]=f.useState(!1),[v,w]=Vr({prop:o,defaultProp:c??!1,onChange:l,caller:lx});return s.jsx(zd,{...m,children:s.jsx(i_,{scope:n,contentId:nn(),triggerRef:p,open:v,onOpenChange:w,onOpenToggle:f.useCallback(()=>w(y=>!y),[w]),hasCustomAnchor:g,onCustomAnchorAdd:f.useCallback(()=>b(!0),[]),onCustomAnchorRemove:f.useCallback(()=>b(!1),[]),modal:d,children:a})})},"Popover"),c_="PopoverTrigger",u_=f.forwardRef(Ns(function(n,a){const{__scopePopover:o,...c}=n,l=Ti(c_,o),d=cx(o),m=Pe(a,l.triggerRef),p=s.jsx(Me.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.open?l.contentId:void 0,"data-state":ux(l.open),...c,ref:m,onClick:Ce(n.onClick,l.onOpenToggle)});return l.hasCustomAnchor?p:s.jsx(Pd,{asChild:!0,...d,children:p})},"PopoverTrigger")),jS="PopoverPortal",[d_,f_]=wS(jS,{forceMount:void 0}),m_=Ns(t=>{const{__scopePopover:n,forceMount:a,children:o,container:c}=t,l=Ti(jS,n);return s.jsx(d_,{scope:n,forceMount:a,children:s.jsx(fn,{present:a||l.open,children:s.jsx(rc,{asChild:!0,container:c,children:o})})})},"PopoverPortal"),Xl="PopoverContent",p_=f.forwardRef(Ns(function(n,a){const o=f_(Xl,n.__scopePopover),{forceMount:c=o.forceMount,...l}=n,d=Ti(Xl,n.__scopePopover);return s.jsx(fn,{present:c||d.open,children:d.modal?s.jsx(g_,{...l,ref:a}):s.jsx(x_,{...l,ref:a})})},"PopoverContent")),h_=Er("PopoverContent.RemoveScroll"),g_=f.forwardRef(Ns(function(n,a){const o=Ti(Xl,n.__scopePopover),c=f.useRef(null),l=Pe(a,c),d=f.useRef(!1);return f.useEffect(()=>{const m=c.current;if(m)return $d(m)},[]),s.jsx(ac,{as:h_,allowPinchZoom:!0,children:s.jsx(CS,{...n,ref:l,trapFocus:o.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ce(n.onCloseAutoFocus,m=>{var p;m.preventDefault(),d.current||(p=o.triggerRef.current)==null||p.focus()}),onPointerDownOutside:Ce(n.onPointerDownOutside,m=>{const p=m.detail.originalEvent,g=p.button===0&&p.ctrlKey===!0,b=p.button===2||g;d.current=b},{checkForDefaultPrevented:!1}),onFocusOutside:Ce(n.onFocusOutside,m=>m.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),x_=f.forwardRef(Ns(function(n,a){const o=Ti(Xl,n.__scopePopover),c=f.useRef(!1),l=f.useRef(!1);return s.jsx(CS,{...n,ref:a,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:d=>{var m,p;(m=n.onCloseAutoFocus)==null||m.call(n,d),d.defaultPrevented||(c.current||(p=o.triggerRef.current)==null||p.focus(),d.preventDefault()),c.current=!1,l.current=!1},onInteractOutside:d=>{var g,b;(g=n.onInteractOutside)==null||g.call(n,d),d.defaultPrevented||(c.current=!0,d.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const m=d.target;((b=o.triggerRef.current)==null?void 0:b.contains(m))&&d.preventDefault(),d.detail.originalEvent.type==="focusin"&&l.current&&d.preventDefault()}})},"PopoverContentNonModal")),CS=f.forwardRef(Ns(function(n,a){const{__scopePopover:o,trapFocus:c,onOpenAutoFocus:l,onCloseAutoFocus:d,disableOutsidePointerEvents:m,onEscapeKeyDown:p,onPointerDownOutside:g,onFocusOutside:b,onInteractOutside:v,...w}=n,y=Ti(Xl,o),C=cx(o);return Ni(),s.jsx(Md,{asChild:!0,loop:!0,trapped:c,onMountAutoFocus:l,onUnmountAutoFocus:d,children:s.jsx(nc,{asChild:!0,disableOutsidePointerEvents:m,onInteractOutside:v,onEscapeKeyDown:p,onPointerDownOutside:g,onFocusOutside:b,onDismiss:()=>y.onOpenChange(!1),deferPointerDownOutside:!0,children:s.jsx(Id,{"data-state":ux(y.open),role:"dialog",id:y.contentId,...C,...w,ref:a,style:{...w.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})},"PopoverContentImpl"));function ux(t){return t?"open":"closed"}Ns(ux,"getState");var b_=l_,v_=u_,y_=m_,SS=p_;const NS=b_,ES=v_,dx=f.forwardRef(({className:t,align:n="center",sideOffset:a=4,...o},c)=>s.jsx(y_,{children:s.jsx(SS,{ref:c,align:n,sideOffset:a,className:pe("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",t),...o})}));dx.displayName=SS.displayName;const tf=f.forwardRef(({disabled:t,value:n,onChange:a,onBlur:o,name:c,className:l,size:d,...m},p)=>{const g=s_(p),[b,v]=f.useState(!1),[w,y]=f.useState(""),C=f.useMemo(()=>$r(n,"#ffffff"),[n]),S=b&&w?w:C;function N(E){Bh(E)&&a($r(E)),y("")}return s.jsxs(NS,{open:b,onOpenChange:E=>{E||N(w||C),v(E)},children:[s.jsx(ES,{asChild:!0,disabled:t,onBlur:o,children:s.jsx(ue,{...m,type:"button",className:pe("size-10 shrink-0 overflow-hidden rounded-md border border-border p-0 shadow-sm",l),name:c,onClick:()=>v(!0),size:d??"icon",style:{backgroundColor:C},variant:"outline","aria-label":"Pick colour",children:s.jsx("span",{className:"sr-only",children:C})})}),s.jsxs(dx,{className:"w-auto border-border bg-card p-3",align:"start",children:[s.jsx(a_,{className:"color-picker-swatch",color:C,onChange:E=>{y(""),a($r(E))}}),s.jsx(_e,{ref:g,maxLength:7,value:S,onChange:E=>{const T=E.currentTarget.value;y(T),Bh(T)&&a($r(T))},onBlur:()=>N(w||C),onKeyDown:E=>{E.key==="Enter"&&(N(w||C),v(!1))},className:"mt-3 border-border bg-secondary/30 font-mono text-sm uppercase",placeholder:"#000000"})]})]})});tf.displayName="ColorPicker";function w_({value:t,onChange:n,placeholder:a="Add item…"}){const o=Array.isArray(t)?t:[];return s.jsxs("div",{className:"space-y-2",children:[o.map((c,l)=>s.jsxs("div",{className:"flex gap-2",children:[s.jsx(_e,{value:c,onChange:d=>{const m=[...o];m[l]=d.target.value,n(m)},placeholder:a,className:"border-border bg-secondary/30"}),s.jsx(ue,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-destructive hover:bg-destructive/10",onClick:()=>n(o.filter((d,m)=>m!==l)),children:s.jsx(xe,{icon:bi,size:16})})]},l)),s.jsxs(ue,{type:"button",variant:"outline",size:"sm",className:"w-full border-dashed border-border",onClick:()=>n([...o,""]),children:[s.jsx(xe,{icon:nh,size:16,className:"mr-2"}),"Add line"]})]})}const Zl="system",fx=[{id:"Inter",label:"Inter"},{id:"Roboto",label:"Roboto"},{id:"Open Sans",label:"Open Sans"},{id:"Lato",label:"Lato"},{id:"Montserrat",label:"Montserrat"},{id:"Poppins",label:"Poppins"},{id:"Nunito",label:"Nunito"},{id:"Raleway",label:"Raleway"},{id:"Work Sans",label:"Work Sans"},{id:"Source Sans 3",label:"Source Sans 3"},{id:"DM Sans",label:"DM Sans"},{id:"Manrope",label:"Manrope"},{id:"Outfit",label:"Outfit"},{id:"Rubik",label:"Rubik"},{id:"Ubuntu",label:"Ubuntu"},{id:"Fira Sans",label:"Fira Sans"},{id:"PT Sans",label:"PT Sans"},{id:"Noto Sans",label:"Noto Sans"},{id:"Oswald",label:"Oswald"},{id:"Merriweather",label:"Merriweather"},{id:"Playfair Display",label:"Playfair Display"},{id:"Libre Baskerville",label:"Libre Baskerville"},{id:"JetBrains Mono",label:"JetBrains Mono"},{id:"Fira Code",label:"Fira Code"}],_0=new Set(fx.map(t=>t.id));function j_(t){return`https://fonts.googleapis.com/css2?${t.map(a=>`family=${encodeURIComponent(a).replace(/%20/g,"+")}:wght@400;600;700;800`).join("&")}&display=swap`}function C_(){const t="supportbot-google-fonts";if(document.getElementById(t))return;const n=document.createElement("link");n.id=t,n.rel="stylesheet",n.href=j_(fx.map(a=>a.id)),document.head.appendChild(n)}function kS(t){var c;if(!t||typeof t!="string")return"Inter";const n=t.trim();if(n===Zl)return Zl;if(!n.includes(","))return _0.has(n)?n:"Inter";const a=n.match(/^["']?([^"',]+)["']?/),o=(c=a==null?void 0:a[1])==null?void 0:c.trim();return o&&_0.has(o)?o:"Inter"}function Bp(t){return t===Zl?'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif':`"${t}", ui-sans-serif, system-ui, sans-serif`}function S_({field:t,value:n,onChange:a,readOnly:o}){const c=t.path.replace(/\./g,"-"),l=kS(n);return f.useEffect(()=>{C_()},[]),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:c,children:t.label}),t.description?s.jsx("p",{className:"text-xs text-muted-foreground",children:t.description}):null,s.jsxs(Ca,{value:l,disabled:o,onValueChange:a,children:[s.jsx(Hr,{id:c,className:"border-border bg-secondary/30",style:{fontFamily:Bp(l)},children:s.jsx(Sa,{placeholder:"Choose a font…"})}),s.jsxs(Gr,{className:"max-h-[min(320px,50vh)]",children:[s.jsx(Et,{value:Zl,style:{fontFamily:Bp(Zl)},children:"System default"}),fx.map(d=>s.jsx(Et,{value:d.id,style:{fontFamily:Bp(d.id)},children:d.label},d.id))]})]})]})}function TS({id:t,label:n,description:a,kind:o,value:c,onChange:l,readOnly:d}){const[m,p]=f.useState(null),[g,b]=f.useState(""),[v,w]=f.useState(!0),[y,C]=f.useState(!1),[S,N]=f.useState("");f.useEffect(()=>{let _=!1;return w(!0),Ne.getGuildResources().then(R=>{_||R.data&&(p(R.data),b(""))}).catch(R=>{_||b(R instanceof Error?R.message:"Could not load server list")}).finally(()=>{_||w(!1)}),()=>{_=!0}},[]);const E=f.useMemo(()=>m?o==="role"?m.roles:o==="category"?m.categories:m.channels:[],[m,o]),T=String(c??""),M=E.find(_=>_.id===T),k=f.useMemo(()=>{if(!S.trim())return E;const _=S.toLowerCase().trim();return E.filter(R=>R.name.toLowerCase().includes(_)||R.id.includes(_))},[E,S]);return s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:t,children:n}),a?s.jsx("p",{className:"text-xs text-muted-foreground",children:a}):null,m?s.jsxs(NS,{open:y,onOpenChange:C,children:[s.jsx(ES,{asChild:!0,children:s.jsxs(ue,{id:t,type:"button",variant:"outline",role:"combobox","aria-expanded":y,disabled:d||v,className:"w-full justify-between border-border bg-secondary/30 text-left font-normal h-10 px-3 hover:bg-secondary/50",children:[s.jsx("span",{className:"truncate",children:M?s.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium text-foreground truncate",children:M.name}),s.jsx("span",{className:"font-mono text-[11px] text-muted-foreground shrink-0",children:M.id})]}):s.jsx("span",{className:"text-muted-foreground",children:v?"Loading server list…":`Select ${o} from ${m.guildName}…`})}),s.jsx(xe,{icon:O8,size:16,className:"shrink-0 opacity-50 ml-2"})]})}),s.jsxs(dx,{className:"w-[var(--radix-popover-trigger-width)] p-2 bg-popover border-border shadow-2xl rounded-xl flex flex-col gap-2 z-50",children:[s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(xe,{icon:vi,size:14,className:"absolute left-2.5 text-muted-foreground"}),s.jsx(_e,{placeholder:`Search ${o}s by name or ID…`,value:S,onChange:_=>N(_.target.value),className:"h-8 pl-8 text-xs border-border bg-secondary/20 focus-visible:ring-1",autoFocus:!0})]}),s.jsx("div",{className:"overflow-y-auto max-h-56 space-y-1 pr-1",children:k.length===0?s.jsxs("div",{className:"p-3 text-center text-xs text-muted-foreground",children:["No ",o,'s found matching "',S,'"']}):k.map(_=>s.jsxs("button",{type:"button",onClick:()=>{l(_.id),C(!1),N("")},className:pe("w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs transition-colors text-left",_.id===T?"bg-primary/15 text-primary font-semibold border border-primary/20":"hover:bg-secondary/60 text-foreground"),children:[s.jsx("span",{className:"truncate mr-2 font-medium",children:_.name}),s.jsx("span",{className:"font-mono text-[11px] text-muted-foreground shrink-0",children:_.id})]},_.id))})]})]}):null,s.jsx(_e,{value:T,disabled:d,onChange:_=>l(_.target.value),placeholder:o==="role"?"Role ID (ROLE_ID)":o==="category"?"Category ID":"Channel ID",className:"border-border bg-secondary/30 font-mono text-xs"}),g?s.jsx("p",{className:"text-xs text-amber-500",children:g}):null,!g&&!m&&!v?s.jsx("p",{className:"text-xs text-muted-foreground",children:"Set General.GuildId and invite the bot to pick from a list."}):null]})}var N_=Object.defineProperty,Mi=(t,n)=>N_(t,"name",{value:n,configurable:!0}),mx="Tabs",[E_,KP]=bn(mx,[Bd]),MS=Bd(),[k_,px]=E_(mx),T_=f.forwardRef(Mi(function(n,a){const{__scopeTabs:o,value:c,onValueChange:l,defaultValue:d,orientation:m="horizontal",dir:p,activationMode:g="automatic",...b}=n,v=Si(p),[w,y]=Vr({prop:c,onChange:l,defaultProp:d??"",caller:mx});return s.jsx(k_,{scope:o,baseId:nn(),value:w,onValueChange:y,orientation:m,dir:v,activationMode:g,children:s.jsx(Me.div,{dir:v,"data-orientation":m,...b,ref:a})})},"Tabs")),M_="TabsList",R_=f.forwardRef(Mi(function(n,a){const{__scopeTabs:o,loop:c=!0,...l}=n,d=px(M_,o),m=MS(o);return s.jsx(Qw,{asChild:!0,...m,orientation:d.orientation,dir:d.dir,loop:c,children:s.jsx(Me.div,{role:"tablist","aria-orientation":d.orientation,...l,ref:a})})},"TabsList")),A_="TabsTrigger",__=f.forwardRef(Mi(function(n,a){const{__scopeTabs:o,value:c,disabled:l=!1,...d}=n,m=px(A_,o),p=MS(o),g=hx(m.baseId,c),b=gx(m.baseId,c),v=c===m.value;return s.jsx(Jw,{asChild:!0,...p,focusable:!l,active:v,children:s.jsx(Me.button,{type:"button",role:"tab","aria-selected":v,"aria-controls":b,"data-state":v?"active":"inactive","data-disabled":l?"":void 0,disabled:l,id:g,...d,ref:a,onMouseDown:Ce(n.onMouseDown,w=>{!l&&w.button===0&&w.ctrlKey===!1?m.onValueChange(c):w.preventDefault()}),onKeyDown:Ce(n.onKeyDown,w=>{l||w.target!==w.currentTarget||[" ","Enter"].includes(w.key)&&m.onValueChange(c)}),onFocus:Ce(n.onFocus,()=>{const w=m.activationMode!=="manual";!v&&!l&&w&&m.onValueChange(c)})})})},"TabsTrigger")),D_="TabsContent",O_=f.forwardRef(Mi(function(n,a){const{__scopeTabs:o,value:c,forceMount:l,children:d,...m}=n,p=px(D_,o),g=hx(p.baseId,c),b=gx(p.baseId,c),v=c===p.value,w=f.useRef(v);return f.useEffect(()=>{const y=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(y)},[]),s.jsx(fn,{present:l||v,children:({present:y})=>s.jsx(Me.div,{"data-state":v?"active":"inactive","data-orientation":p.orientation,role:"tabpanel","aria-labelledby":g,hidden:!y,id:b,tabIndex:0,...m,ref:a,style:{...n.style,animationDuration:w.current?"0s":void 0},children:y&&d})})},"TabsContent"));function hx(t,n){return`${t}-trigger-${n}`}Mi(hx,"makeTriggerId");function gx(t,n){return`${t}-content-${n}`}Mi(gx,"makeContentId");var L_=T_,RS=R_,AS=__,_S=O_;const DS=L_,xx=f.forwardRef(({className:t,...n},a)=>s.jsx(RS,{ref:a,className:pe("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...n}));xx.displayName=RS.displayName;const Ys=f.forwardRef(({className:t,...n},a)=>s.jsx(AS,{ref:a,className:pe("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...n}));Ys.displayName=AS.displayName;const $h=f.forwardRef(({className:t,...n},a)=>s.jsx(_S,{ref:a,className:pe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...n}));$h.displayName=_S.displayName;function Uu(t){if(typeof t!="string"||!t)throw new Error("expected a non-empty string, got: "+t)}function $p(t){if(typeof t!="number")throw new Error("expected a number, got: "+t)}const z_=1,P_=1,fo="emoji",mi="keyvalue",bx="favorites",I_="tokens",OS="tokens",U_="unicode",LS="count",B_="group",$_="order",zS="group-order",Hh="eTag",dd="url",D0="skinTone",Ri="readonly",vx="readwrite",PS="skinUnicodes",H_="skinUnicodes",G_="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",V_="en";function F_(t,n){const a=new Set,o=[];for(const c of t){const l=n(c);a.has(l)||(a.add(l),o.push(c))}return o}function O0(t){return F_(t,n=>n.unicode)}function Y_(t){function n(a,o,c){const l=o?t.createObjectStore(a,{keyPath:o}):t.createObjectStore(a);if(c)for(const[d,[m,p]]of Object.entries(c))l.createIndex(d,m,{multiEntry:p});return l}n(mi),n(fo,U_,{[OS]:[I_,!0],[zS]:[[B_,$_]],[PS]:[H_,!0]}),n(bx,void 0,{[LS]:[""]})}const Gh={},Ju={},fd={};function IS(t,n,a){a.onerror=()=>n(a.error),a.onblocked=()=>n(new Error("IDB blocked")),a.onsuccess=()=>t(a.result)}async function q_(t){const n=await new Promise((a,o)=>{const c=indexedDB.open(t,z_);Gh[t]=c,c.onupgradeneeded=l=>{l.oldVersionyx(t),n}function K_(t){return Ju[t]||(Ju[t]=q_(t)),Ju[t]}function _a(t,n,a,o){return new Promise((c,l)=>{const d=t.transaction(n,a,{durability:"relaxed"}),m=typeof n=="string"?d.objectStore(n):n.map(g=>d.objectStore(g));let p;o(m,d,g=>{p=g}),d.oncomplete=()=>c(p),d.onerror=()=>l(d.error)})}function yx(t){const n=Gh[t],a=n&&n.result;if(a){a.close();const o=fd[t];if(o)for(const c of o)c()}delete Gh[t],delete Ju[t],delete fd[t]}function W_(t){return new Promise((n,a)=>{yx(t);const o=indexedDB.deleteDatabase(t);IS(n,a,o)})}function X_(t,n){let a=fd[t];a||(a=fd[t]=[]),a.push(n)}const Z_=new Set([":D","XD",":'D","O:)",":X",":P",";P","XP",":L",":Z",":j","8D","XO","8)",":B",":O",":S",":'o","Dx","X(","D:",":C",">0)",":3","!n.match(/\w/)||Z_.has(n)?n.toLowerCase():n.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const Q_=2;function US(t){return t.filter(Boolean).map(n=>n.toLowerCase()).filter(n=>n.length>=Q_)}function J_(t){return t.map(({annotation:a,emoticon:o,group:c,order:l,shortcodes:d,skins:m,tags:p,emoji:g,version:b})=>{const v=[...new Set(US([...(d||[]).map(ci).flat(),...(p||[]).map(ci).flat(),...ci(a),o]))].sort(),w={annotation:a,group:c,order:l,tags:p,tokens:v,unicode:g,version:b};if(o&&(w.emoticon=o),d&&(w.shortcodes=d),m){w.skinTones=[],w.skinUnicodes=[],w.skinVersions=[];for(const{tone:y,emoji:C,version:S}of m)w.skinTones.push(y),w.skinUnicodes.push(C),w.skinVersions.push(S)}return w})}function BS(t,n,a,o){t[n](a).onsuccess=c=>o&&o(c.target.result)}function ro(t,n,a){BS(t,"get",n,a)}function $S(t,n,a){BS(t,"getAll",n,a)}function wx(t){t.commit&&t.commit()}function eD(t,n){let a=t[0];for(let o=1;on(c)&&(a=c)}return a}function HS(t,n){const a=eD(t,c=>c.length),o=[];for(const c of a)t.some(l=>l.findIndex(d=>n(d)===n(c))===-1)||o.push(c);return o}async function tD(t){return!await jx(t,mi,dd)}async function nD(t,n,a){const[o,c]=await Promise.all([Hh,dd].map(l=>jx(t,mi,l)));return o===a&&c===n}async function rD(t,n){return _a(t,fo,Ri,(o,c,l)=>{let d;const m=()=>{o.getAll(d&&IDBKeyRange.lowerBound(d,!0),50).onsuccess=p=>{const g=p.target.result;for(const b of g)if(d=b.unicode,n(b))return l(b);if(g.length<50)return l();m()}};m()})}async function GS(t,n,a,o){try{const c=J_(n);await _a(t,[fo,mi],vx,([l,d],m)=>{let p,g,b=0;function v(){++b===2&&w()}function w(){if(!(p===o&&g===a)){l.clear();for(const y of c)l.put(y);d.put(o,Hh),d.put(a,dd),wx(m)}}ro(d,Hh,y=>{p=y,v()}),ro(d,dd,y=>{g=y,v()})})}finally{}}async function aD(t,n){return _a(t,fo,Ri,(a,o,c)=>{const l=IDBKeyRange.bound([n,0],[n+1,0],!1,!0);$S(a.index(zS),l,c)})}async function VS(t,n){const a=US(ci(n));return a.length?_a(t,fo,Ri,(o,c,l)=>{const d=[],m=()=>{d.length===a.length&&p()},p=()=>{const g=HS(d,b=>b.unicode);l(g.sort((b,v)=>b.order{d.push(w),m()})}}):[]}async function sD(t,n){const a=await VS(t,n);return a.length?a.filter(o=>(o.shortcodes||[]).map(l=>l.toLowerCase()).includes(n.toLowerCase()))[0]||null:await rD(t,c=>(c.shortcodes||[]).includes(n.toLowerCase()))||null}async function oD(t,n){return _a(t,fo,Ri,(a,o,c)=>ro(a,n,l=>{if(l)return c(l);ro(a.index(PS),n,d=>c(d||null))}))}function jx(t,n,a){return _a(t,n,Ri,(o,c,l)=>ro(o,a,l))}function iD(t,n,a,o){return _a(t,n,vx,(c,l)=>{c.put(o,a),wx(l)})}function lD(t,n){return _a(t,bx,vx,(a,o)=>ro(a,n,c=>{a.put((c||0)+1,n),wx(o)}))}function cD(t,n,a){return a===0?[]:_a(t,[bx,fo],Ri,([o,c],l,d)=>{const m=[];o.index(LS).openCursor(void 0,"prev").onsuccess=p=>{const g=p.target.result;if(!g)return d(m);function b(y){if(m.push(y),m.length===a)return d(m);g.continue()}const v=g.primaryKey,w=n.byName(v);if(w)return b(w);ro(c,v,y=>{if(y)return b(y);g.continue()})}})}const Bu="";function uD(t,n){const a=new Map;for(const c of t){const l=n(c);for(const d of l){let m=a;for(let g=0;g{let d=a;for(let g=0;gv[0]!(o in t[0])));if(!n||a)throw new Error("Custom emojis are in the wrong format")}function L0(t){fD(t);const n=(w,y)=>w.name.toLowerCase(){const y=new Set;if(w.shortcodes)for(const C of w.shortcodes)for(const S of ci(C))y.add(S);return y}),l=w=>c(w,!0),d=w=>c(w,!1),m=w=>{const y=ci(w),C=y.map((S,N)=>(NS.name).sort(n)},p=new Map,g=new Map;for(const w of t){g.set(w.name.toLowerCase(),w);for(const y of w.shortcodes||[])p.set(y.toLowerCase(),w)}return{all:a,search:m,byShortcode:w=>p.get(w.toLowerCase()),byName:w=>g.get(w.toLowerCase())}}const mD=typeof wrappedJSObject<"u";function Rl(t){if(!t)return t;if(mD&&(t=structuredClone(t)),delete t.tokens,t.skinTones){const n=t.skinTones.length;t.skins=Array(n);for(let a=0;a!(n in t[0])))throw new Error("Emoji data is in the wrong format")}function YS(t,n){if(Math.floor(t.status/100)!==2)throw new Error("Failed to fetch: "+n+": "+t.status)}async function gD(t){const n=await fetch(t,{method:"HEAD"});YS(n,t);const a=n.headers.get("etag");return FS(a),a}async function Vh(t){const n=await fetch(t);YS(n,t);const a=n.headers.get("etag");FS(a);const o=await n.json();return hD(o),[a,o]}function xD(t){for(var n="",a=new Uint8Array(t),o=a.byteLength,c=-1;++c(this._ready||(this._ready=this._init()),this._ready);await n(),this._db||await n()}async getEmojiByGroup(n){return $p(n),await this.ready(),O0(await aD(this._db,n)).map(Rl)}async getEmojiBySearchQuery(n){Uu(n),await this.ready();const a=this._custom.search(n),o=O0(await VS(this._db,n)).map(Rl);return[...a,...o]}async getEmojiByShortcode(n){Uu(n),await this.ready();const a=this._custom.byShortcode(n);return a||Rl(await sD(this._db,n))}async getEmojiByUnicodeOrName(n){Uu(n),await this.ready();const a=this._custom.byName(n);return a||Rl(await oD(this._db,n))}async getPreferredSkinTone(){return await this.ready(),await jx(this._db,mi,D0)||0}async setPreferredSkinTone(n){return $p(n),await this.ready(),iD(this._db,mi,D0,n)}async incrementFavoriteEmojiCount(n){return Uu(n),await this.ready(),lD(this._db,n)}async getTopFavoriteEmoji(n){return $p(n),await this.ready(),(await cD(this._db,this._custom,n)).map(Rl)}set customEmoji(n){this._custom=L0(n)}get customEmoji(){return this._custom.all}async _shutdown(){await this.ready();try{await this._lazyUpdate}catch{}}_clear(){this._db=this._ready=this._lazyUpdate=void 0}async close(){await this._shutdown(),await yx(this._dbName)}async delete(){await this._shutdown(),await W_(this._dbName)}}const Fh=[[-1,"✨","custom"],[0,"😀","smileys-emotion"],[1,"👋","people-body"],[3,"🐱","animals-nature"],[4,"🍎","food-drink"],[5,"🏠️","travel-places"],[6,"⚽","activities"],[7,"📝","objects"],[8,"⛔️","symbols"],[9,"🏁","flags"]].map(([t,n,a])=>({id:t,emoji:n,name:a})),Hp=Fh.slice(1),CD=2,z0=6,KS=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function P0(t){return t.unicode.includes("‍")}const SD={"🫪":17,"🫩":16,"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},ND=1e3,ED="🖐️",kD=8,TD=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],WS='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',MD=(t,n)=>tn?1:0,I0=(t,n)=>{const a=document.createElement("canvas");a.width=a.height=1;const o=a.getContext("2d",{willReadFrequently:!0});return o.textBaseline="top",o.font=`100px ${WS}`,o.fillStyle=n,o.scale(.01,.01),o.fillText(t,0,0),o.getImageData(0,0,1,1).data},RD=(t,n)=>{const a=[...t].join(","),o=[...n].join(",");return a===o&&!a.startsWith("0,0,0,")};function AD(t){const n=I0(t,"#000"),a=I0(t,"#fff");return n&&a&&RD(n,a)}function _D(){const t=Object.entries(SD);try{for(const[n,a]of t)if(AD(n))return a}catch{}finally{}return t[0][1]}let Gp;const Vp=()=>(Gp||(Gp=new Promise(t=>KS(()=>t(_D())))),Gp),Yh=new Map,DD="️",OD="\uD83C",LD="‍",zD=127995,PD=57339;function ID(t,n){if(n===0)return t;const a=t.indexOf(LD);return a!==-1?t.substring(0,a)+String.fromCodePoint(zD+n-1)+t.substring(a):(t.endsWith(DD)&&(t=t.substring(0,t.length-1)),t+OD+String.fromCodePoint(PD+n-1))}function Ir(t){t.preventDefault(),t.stopPropagation()}function Fp(t,n,a){return n+=t?-1:1,n<0?n=a.length-1:n>=a.length&&(n=0),n}function XS(t,n){const a=new Set,o=[];for(const c of t){const l=n(c);a.has(l)||(a.add(l),o.push(c))}return o}function UD(t,n){const a=o=>{const c={};for(const l of o)typeof l.tone=="number"&&l.version<=n&&(c[l.tone]=l.unicode);return c};return t.map(({unicode:o,skins:c,shortcodes:l,url:d,name:m,category:p,annotation:g})=>({unicode:o,name:m,shortcodes:l,url:d,category:p,annotation:g,id:o||m,skins:c&&a(c)}))}const ed=requestAnimationFrame;let BD=typeof ResizeObserver=="function";function $D(t,n,a){let o;BD?(o=new ResizeObserver(a),o.observe(t)):ed(a),n.addEventListener("abort",()=>{o&&o.disconnect()})}function U0(t){{const n=document.createRange();return n.selectNode(t.firstChild),n.getBoundingClientRect().width}}const HD="😀";let Yp,Fs;function B0(t,n,a){const o=U0(n);if(!o){if(!Fs){Fs=a.cloneNode(!0);const c=getComputedStyle(a);for(const l of["font-family","line-height","width","height","font-size","display","align-items","justify-content"])Fs.style.setProperty(l,c.getPropertyValue(l),"important")}try{return document.body.appendChild(Fs),Fs.firstChild.nodeValue=t,U0(Fs)}finally{Fs.remove()}}return o}function GD(t,n,a){let o=!0;for(const c of t){const l=a(c);if(!l)continue;typeof Yp>"u"&&(Yp=B0(HD,n,n));const m=B0(c.unicode,l,n)/1.8n)}function FD(t){t&&(t.scrollTop=0)}function Ll(t,n,a){let o=t.get(n);return o||(o=a(),t.set(n,o)),o}function $0(t){return""+t}function YD(t){const n=document.createElement("template");return n.innerHTML=t,n}const qD=new WeakMap,KD=new WeakMap,WD=Symbol("un-keyed"),XD="replaceChildren"in Element.prototype;function ZD(t,n){XD?t.replaceChildren(...n):(t.innerHTML="",t.append(...n))}function QD(t,n){let a=t.firstChild,o=0;for(;a;){if(n[o]!==a)return!0;a=a.nextSibling,o++}return o!==n.length}function JD(t,n){const{targetNode:a}=n;let{targetParentNode:o}=n,c=!1;o?c=QD(o,t):(c=!0,n.targetNode=void 0,n.targetParentNode=o=a.parentNode),c&&ZD(o,t)}function eO(t,n){for(const a of n){const{targetNode:o,currentExpression:c,binding:{expressionIndex:l,attributeName:d,attributeValuePre:m,attributeValuePost:p}}=a,g=t[l];if(c!==g)if(a.currentExpression=g,d)if(g===null)o.removeAttribute(d);else{const b=m+$0(g)+p;o.setAttribute(d,b)}else{let b;Array.isArray(g)?JD(g,a):g instanceof Element?(b=g,o.replaceWith(b)):o.nodeValue=$0(g),b&&(a.targetNode=b)}}}function tO(t){let n="",a=!1,o=!1,c=-1;const l=new Map,d=[];let m=0;for(let g=0,b=t.length;g":{a=!1,o=!1;break}case"=":{o=!0;break}}const w=d[d.length-1],y=Ll(l,w,()=>[]);let C,S,N;if(o){const T=/(\S+)="?([^"=]*)$/.exec(v);C=T[1],S=T[2];const M=/^([^">]*)("?)/.exec(t[g+1]);N=M[1],n=n.slice(0,-1*T[0].length),m=M[0].length}else m=0;const E={attributeName:C,attributeValuePre:S,attributeValuePost:N,expressionIndex:g};y.push(E),!a&&!o&&(n+=" ")}return{template:YD(n),elementsToBindings:l}}function H0(t,n,a){for(let o=0;otO(t)),o=n.cloneNode(!0).content.firstElementChild,c=nO(o,a);return function(d){return eO(d,c),o}}function aO(t){const n=Ll(KD,t,()=>new Map);let a=WD;function o(l,...d){const m=Ll(n,l,()=>new Map);return Ll(m,a,()=>rO(l))(d)}function c(l,d,m){return l.map((p,g)=>{const b=a;a=m(p);try{return d(p,g)}finally{a=b}})}return{map:c,html:o}}function sO(t,n,a,o,c,l,d,m,p){const{labelWithSkin:g,titleForEmoji:b,unicodeWithSkin:v}=a,{html:w,map:y}=aO(n);function C(T,M,k){return y(T,(_,R)=>w``,_=>`${k}-${_.id}`)}const N=w`
${n.i18n.searchDescription}
${n.i18n.skinToneDescription}
${y(n.skinTones,(T,M)=>w`
${T}
`,T=>T)}
${y(n.currentEmojisWithCategories,(T,M)=>w`
${C(T.emojis,n.searchMode,"emo")}
`,T=>T.category)}
`,E=(T,M)=>{for(const k of t.querySelectorAll(`[${T}]`))M(k,k.getAttribute(T))};if(p){t.appendChild(N);for(const T of["click","focusout","input","keydown","keyup"])E(`data-on-${T}`,(M,k)=>{M.addEventListener(T,o[k])});E("data-ref",(T,M)=>{l[M]=T}),d.addEventListener("abort",()=>{t.removeChild(N)})}E("data-action",(T,M)=>{let k=m.get(M);k||m.set(M,k=new WeakSet),k.has(T)||(k.add(T),c[M](T))})}const md=typeof queueMicrotask=="function"?queueMicrotask:t=>Promise.resolve().then(t);function oO(t){let n=!1,a;const o=new Map,c=new Set;let l;const d=()=>{if(n)return;const g=[...c];c.clear();try{for(const b of g)b()}finally{l=!1,c.size&&(l=!0,md(d))}},m=new Proxy({},{get(g,b){if(a){let v=o.get(b);v||(v=new Set,o.set(b,v)),v.add(a)}return g[b]},set(g,b,v){if(g[b]!==v){g[b]=v;const w=o.get(b);if(w){for(const y of w)c.add(y);l||(l=!0,md(d))}}return!0}}),p=g=>{const b=()=>{const v=a;a=b;try{return g()}finally{a=v}};return b()};return t.addEventListener("abort",()=>{n=!0}),{state:m,createEffect:p}}function qp(t,n,a){if(t.length!==n.length)return!1;for(let o=0;o{c.disconnect()})),c.observe(t)}}const Kp=[],{assign:$u}=Object;function lO(t,n){const a={},o=new AbortController,c=o.signal,{state:l,createEffect:d}=oO(c),m=new Map;$u(l,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),$u(l,n),$u(l,{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:kD,isRtl:!1,currentGroupIndex:0,groups:Hp,databaseLoaded:!1,activeSearchItemId:void 0}),d(()=>{l.currentGroup!==l.groups[l.currentGroupIndex]&&(l.currentGroup=l.groups[l.currentGroupIndex])});const p=$=>{t.getElementById($).focus()},g=$=>t.getElementById(`emo-${$.id}`),b=($,ie)=>{a.rootElement.dispatchEvent(new CustomEvent($,{detail:ie,bubbles:!0,composed:!0}))},v=($,ie)=>$.id===ie.id,w=($,ie)=>{const{category:ye,emojis:Se}=$,{category:Be,emojis:Ke}=ie;return ye!==Be?!1:qp(Se,Ke,v)},y=$=>{qp(l.currentEmojis,$,v)||(l.currentEmojis=$)},C=$=>{l.searchMode!==$&&(l.searchMode=$)},S=$=>{qp(l.currentEmojisWithCategories,$,w)||(l.currentEmojisWithCategories=$)},N=($,ie)=>ie&&$.skins&&$.skins[ie]||$.unicode,M={labelWithSkin:($,ie)=>VD([$.name||N($,ie),$.annotation,...$.shortcodes||Kp].filter(Boolean)).join(", "),titleForEmoji:$=>$.annotation||($.shortcodes||Kp).join(", "),unicodeWithSkin:N},k={onClickSkinToneButton:Z,onEmojiClick:D,onNavClick:oe,onNavKeydown:ae,onSearchKeydown:W,onSkinToneOptionsClick:V,onSkinToneOptionsFocusOut:ge,onSkinToneOptionsKeydown:be,onSkinToneOptionsKeyup:K,onSearchInput:me},_={calculateEmojiGridStyle:ne,updateOnIntersection:X};let R=!0;d(()=>{sO(t,l,M,k,_,a,c,m,R),R=!1}),l.emojiVersion||Vp().then($=>{$||(l.message=l.i18n.emojiUnsupportedMessage)}),d(()=>{async function $(){let ie=!1;const ye=setTimeout(()=>{ie=!0,l.message=l.i18n.loadingMessage},ND);try{await l.database.ready(),l.databaseLoaded=!0}catch(Se){console.error(Se),l.message=l.i18n.networkErrorMessage}finally{clearTimeout(ye),ie&&(ie=!1,l.message="")}}l.database&&$()}),d(()=>{l.pickerStyle=` --num-groups: ${l.groups.length}; --indicator-opacity: ${l.searchMode?0:1}; - --num-skintones: ${z0};`}),d(()=>{l.customEmoji&&l.database&&L()}),d(()=>{l.customEmoji&&l.customEmoji.length?l.groups!==Fh&&(l.groups=Fh):l.groups!==Hp&&(l.currentGroupIndex&&l.currentGroupIndex--,l.groups=Hp)}),d(()=>{async function B(){l.databaseLoaded&&(l.currentSkinTone=await l.database.getPreferredSkinTone())}B()}),d(()=>{l.skinTones=Array(z0).fill().map((B,ie)=>ID(l.skinToneEmoji,ie))}),d(()=>{l.skinToneButtonText=l.skinTones[l.currentSkinTone]}),d(()=>{l.skinToneButtonLabel=l.i18n.skinToneLabel.replace("{skinTone}",l.i18n.skinTones[l.currentSkinTone])}),d(()=>{async function B(){const{database:ie}=l,we=(await Promise.all(TD.map(Ce=>ie.getEmojiByUnicodeOrName(Ce)))).filter(Boolean);l.defaultFavoriteEmojis=we}l.databaseLoaded&&B()});function L(){const{customEmoji:B,database:ie}=l,we=B||Kp;ie.customEmoji!==we&&(ie.customEmoji=we)}d(()=>{async function B(){L();const{database:ie,defaultFavoriteEmojis:we,numColumns:Ce}=l,ze=await ie.getTopFavoriteEmoji(Ce),Ke=await fe(XS([...ze,...we],ft=>ft.unicode||ft.name).slice(0,Ce));l.currentFavorites=Ke}l.databaseLoaded&&l.defaultFavoriteEmojis&&B()});function te(B){$D(B,c,()=>{{const ie=getComputedStyle(a.rootElement),we=parseInt(ie.getPropertyValue("--num-columns"),10),Ce=ie.getPropertyValue("direction")==="rtl";l.numColumns=we,l.isRtl=Ce}})}function K(B){iO(B,c,ie=>{for(const{target:we,isIntersecting:Ce}of ie)we.classList.toggle("onscreen",Ce)})}d(()=>{async function B(){const{searchText:ie,currentGroup:we,databaseLoaded:Ce,customEmoji:ze}=l;if(!Ce)l.currentEmojis=[],l.searchMode=!1;else if(ie.length>=CD){const Ke=await P(ie);l.searchText===ie&&(y(Ke),C(!0))}else{const{id:Ke}=we;if(Ke!==-1||ze&&ze.length){const ft=await se(Ke);l.currentGroup.id===Ke&&(y(ft),C(!1))}}}B()});const I=()=>{ed(()=>FD(a.tabpanelElement))};d(()=>{const{currentEmojis:B,emojiVersion:ie}=l,we=B.filter(Ce=>Ce.unicode).filter(Ce=>P0(Ce)&&!Yh.has(Ce.unicode));if(!ie&&we.length)y(B),ed(()=>G(we));else{const Ce=ie?B:B.filter(Y);y(Ce),I()}});function G(B){GD(B,a.baselineEmoji,g)?I():l.currentEmojis=[...l.currentEmojis]}function Y(B){return!B.unicode||!P0(B)||Yh.get(B.unicode)}async function ce(B){const ie=l.emojiVersion||await Vp();return B.filter(({version:we})=>!we||we<=ie)}async function fe(B){return UD(B,l.emojiVersion||await Vp())}async function se(B){const ie=B===-1?l.customEmoji:await l.database.getEmojiByGroup(B);return fe(await ce(ie))}async function P(B){return fe(await ce(await l.database.getEmojiBySearchQuery(B)))}d(()=>{}),d(()=>{function B(){const{searchMode:we,currentEmojis:Ce}=l;if(we)return[{category:"",emojis:Ce}];const ze=new Map;for(const Ke of Ce){const ft=Ke.category||"";let Pt=ze.get(ft);Pt||(Pt=[],ze.set(ft,Pt)),Pt.push(Ke)}return[...ze.entries()].map(([Ke,ft])=>({category:Ke,emojis:ft})).sort((Ke,ft)=>l.customCategorySorting(Ke.category,ft.category))}const ie=B();S(ie)}),d(()=>{l.activeSearchItemId=l.activeSearchItem!==-1&&l.currentEmojis[l.activeSearchItem].id}),d(()=>{const{rawSearchText:B}=l;KS(()=>{l.searchText=(B||"").trim(),l.activeSearchItem=-1})});function Z(B){if(!l.searchMode||!l.currentEmojis.length)return;const ie=we=>{zr(B),l.activeSearchItem=Fp(we,l.activeSearchItem,l.currentEmojis)};switch(B.key){case"ArrowDown":return ie(!1);case"ArrowUp":return ie(!0);case"Enter":if(l.activeSearchItem===-1)l.activeSearchItem=0;else return zr(B),O(l.currentEmojis[l.activeSearchItem].id)}}function ae(B){const{target:ie}=B,we=ie.closest(".nav-button");if(!we)return;const Ce=parseInt(we.dataset.groupId,10);a.searchElement.value="",l.rawSearchText="",l.searchText="",l.activeSearchItem=-1,l.currentGroupIndex=l.groups.findIndex(ze=>ze.id===Ce)}function re(B){const{target:ie,key:we}=B,Ce=ze=>{ze&&(zr(B),ze.focus())};switch(we){case"ArrowLeft":return Ce(ie.previousElementSibling);case"ArrowRight":return Ce(ie.nextElementSibling);case"Home":return Ce(ie.parentElement.firstElementChild);case"End":return Ce(ie.parentElement.lastElementChild)}}async function V(B){const ie=await l.database.getEmojiByUnicodeOrName(B),we=[...l.currentEmojis,...l.currentFavorites].find(ze=>ze.id===B),Ce=we.unicode&&E(we,l.currentSkinTone);return await l.database.incrementFavoriteEmojiCount(B),{emoji:ie,skinTone:l.currentSkinTone,...Ce&&{unicode:Ce},...we.name&&{name:we.name}}}async function O(B){const ie=V(B);v("emoji-click-sync",ie),v("emoji-click",await ie)}function D(B){const{target:ie}=B;if(!ie.classList.contains("emoji"))return;zr(B);const we=ie.id.substring(4);O(we)}function $(B){l.currentSkinTone=B,l.skinTonePickerExpanded=!1,p("skintone-button"),v("skin-tone-change",{skinTone:B}),l.database.setPreferredSkinTone(B)}function H(B){const{target:{id:ie}}=B,we=ie&&ie.match(/^skintone-(\d)/);if(!we)return;zr(B);const Ce=parseInt(we[1],10);$(Ce)}function X(B){l.skinTonePickerExpanded=!l.skinTonePickerExpanded,l.activeSkinTone=l.currentSkinTone,l.skinTonePickerExpanded&&(zr(B),ed(()=>p("skintone-list")))}d(()=>{l.skinTonePickerExpanded?a.skinToneDropdown.addEventListener("transitionend",()=>{l.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):l.skinTonePickerExpandedAfterAnimation=!1});function xe(B){if(!l.skinTonePickerExpanded)return;const ie=async we=>{zr(B),l.activeSkinTone=we};switch(B.key){case"ArrowUp":return ie(Fp(!0,l.activeSkinTone,l.skinTones));case"ArrowDown":return ie(Fp(!1,l.activeSkinTone,l.skinTones));case"Home":return ie(0);case"End":return ie(l.skinTones.length-1);case"Enter":return zr(B),$(l.activeSkinTone);case"Escape":return zr(B),l.skinTonePickerExpanded=!1,p("skintone-button")}}function q(B){if(l.skinTonePickerExpanded)switch(B.key){case" ":return zr(B),$(l.activeSkinTone)}}async function ge(B){const{relatedTarget:ie}=B;(!ie||ie.id!=="skintone-list")&&(l.skinTonePickerExpanded=!1)}function me(B){l.rawSearchText=B.target.value}return{$set(B){$u(l,B)},$destroy(){o.abort()}}}const cO="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",uO="en";var dO={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"}},fO=':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 ZS=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],mO=`:host{--emoji-font-family:${WS}}`;class Cx extends HTMLElement{constructor(n){super(),this.attachShadow({mode:"open"});const a=document.createElement("style");a.textContent=fO+mO,this.shadowRoot.appendChild(a),this._ctx={locale:uO,dataSource:cO,skinToneEmoji:ED,customCategorySorting:MD,customEmoji:null,i18n:dO,emojiVersion:null,...n};for(const o of ZS)o!=="database"&&Object.prototype.hasOwnProperty.call(this,o)&&(this._ctx[o]=this[o],delete this[o]);this._dbFlush()}connectedCallback(){V0(this),this._cmp||(this._cmp=lO(this.shadowRoot,this._ctx))}disconnectedCallback(){V0(this),md(()=>{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,(c,l)=>l.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 jD({locale:n,dataSource:a}))}_dbFlush(){md(()=>this._dbCreate())}}const QS={};for(const t of ZS)QS[t]={get(){return t==="database"&&this._dbCreate(),this._ctx[t]},set(n){if(t==="database")throw new Error("database is read-only");this._set(t,n)}};Object.defineProperties(Cx.prototype,QS);function V0(t){t instanceof Cx||Object.setPrototypeOf(t,customElements.get(t.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Cx);function pO({onPick:t}){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 c=l=>{var p;const d=l.detail,m=(d==null?void 0:d.unicode)??((p=d==null?void 0:d.emoji)==null?void 0:p.unicode);m&&t(m)};return o.addEventListener("emoji-click",c),a.appendChild(o),()=>{o.removeEventListener("emoji-click",c),o.remove()}},[t]),s.jsx("div",{ref:n,className:"unicode-emoji-panel-host overflow-hidden rounded-lg border border-border/50"})}const hO=/^<(a?):([^:>]+):(\d{17,20})>$/;function td(t,n,a=!1){return`${a?"`}function JS(t){const n=String(t??"").trim();if(!n)return{kind:"empty",value:""};const a=n.match(hO);return a?{kind:"custom",value:n,animated:a[1]==="a",name:a[2],id:a[3]}:{kind:"unicode",value:n}}function e5(t,n=!1){return`https://cdn.discordapp.com/emojis/${t}.${n?"gif":"png"}?size=64`}function gO(t,n=[]){const a=JS(t);if(a.kind==="custom"&&a.id&&!a.name){const o=n.find(c=>c.id===a.id);if(o)return{kind:"custom",value:td(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(c=>c.id===a.id);if(o&&a.value!==td(o.name,o.id,o.animated))return{kind:"custom",value:td(o.name,o.id,o.animated),name:o.name,id:o.id,animated:o.animated}}return a}function xO({value:t,guildEmojis:n,size:a="md"}){const o=gO(t,n),c=a==="lg"?"size-10":"size-7",l=a==="lg"?"text-3xl":"text-2xl";return o.kind==="empty"?s.jsx("span",{className:"text-sm text-muted-foreground",children:"No emoji selected"}):o.kind==="custom"&&o.id?s.jsxs("span",{className:"inline-flex items-center gap-3",children:[s.jsx("img",{src:e5(o.id,o.animated),alt:o.name??"custom emoji",className:pe(c,"shrink-0 rounded-md"),loading:"lazy"}),s.jsxs("span",{className:"flex flex-col items-start gap-0.5",children:[s.jsxs("span",{className:"text-sm font-medium",children:[":",o.name,":"]}),s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:o.value})]})]}):s.jsx("span",{className:pe(l,"leading-none"),title:o.value,children:o.value})}function vO({id:t,label:n,description:a,value:o,onChange:c,readOnly:l}){const[d,m]=f.useState(!1),[p,g]=f.useState("server"),[v,b]=f.useState(null),[w,y]=f.useState(""),[C,S]=f.useState(!1),[E,k]=f.useState(""),N=f.useCallback(async(I=!1)=>{S(!0),y("");try{const G=await Ne.getGuildResources(I);G.data?(b(G.data),Array.isArray(G.data.emojis)||y("Server response is missing emojis. Restart the bot after updating.")):y("No guild data returned.")}catch(G){y(G instanceof Error?G.message:"Could not load server emojis")}finally{S(!1)}},[]);f.useEffect(()=>{d&&N(!0)},[d,N]);const T=f.useMemo(()=>Array.isArray(v==null?void 0:v.emojis)?v.emojis:[],[v]),M=f.useMemo(()=>{const I=E.trim().toLowerCase();return I?T.filter(G=>G.name.toLowerCase().includes(I)):T},[T,E]),_=String(o??""),R=JS(_);function L(I){c(I),m(!1)}function te(I){c(td(I.name,I.id,I.animated)),m(!1)}function K(){c("")}return s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:t,children:n}),a?s.jsx("p",{className:"text-xs text-muted-foreground",children:a}):null,s.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:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(xO,{value:o,guildEmojis:T,size:"lg"})}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx(ue,{type:"button",variant:"secondary",size:"sm",disabled:l,onClick:()=>m(!0),children:"Choose emoji"}),_?s.jsx(ue,{type:"button",variant:"ghost",size:"sm",disabled:l,onClick:K,children:"Clear"}):null]})]}),s.jsx(Qs,{open:d,onOpenChange:m,children:s.jsxs(hs,{className:"max-h-[min(90vh,720px)] max-w-lg gap-0 overflow-hidden p-0 sm:max-w-xl",children:[s.jsxs(gs,{className:"space-y-1 border-b border-border px-5 py-4",children:[s.jsx(xs,{children:"Choose emoji"}),s.jsxs(vs,{children:["Server emojis save as"," ",s.jsx("code",{className:"rounded bg-muted px-1 text-xs",children:"<:name:id>"}),". Standard emojis save as Unicode characters."]})]}),s.jsxs(DS,{value:p,onValueChange:I=>g(I),className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs(xx,{className:"mx-5 mt-3 grid h-9 w-auto grid-cols-2",children:[s.jsx(Ys,{value:"server",children:"Server"}),s.jsx(Ys,{value:"unicode",children:"All emojis"})]}),s.jsxs($h,{value:"server",className:"mt-0 flex-1 px-5 pb-4 pt-3",children:[s.jsxs("div",{className:"relative mb-3",children:[s.jsx(ve,{icon:ji,size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx(De,{placeholder:"Search by name…",value:E,onChange:I=>k(I.target.value),className:"h-9 border-border bg-secondary/30 pl-9"})]}),v?s.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:[v.guildName," · ",T.length," custom emoji",T.length===1?"":"s"]}):null,s.jsx(fc,{className:"h-[min(50vh,320px)] rounded-lg border border-border/50 bg-secondary/20",children:C?s.jsx("div",{className:"grid grid-cols-6 gap-2 p-3 sm:grid-cols-8",children:Array.from({length:24}).map((I,G)=>s.jsx(Be,{className:"aspect-square rounded-lg"},G))}):w?s.jsxs("div",{className:"space-y-3 p-4 text-center",children:[s.jsx("p",{className:"text-sm text-destructive",children:w}),s.jsx(ue,{type:"button",variant:"outline",size:"sm",onClick:()=>void N(!0),children:"Retry"})]}):M.length===0?s.jsx("p",{className:"p-6 text-center text-sm text-muted-foreground",children:T.length===0?"No custom emojis in this server, or the bot needs the Guild Emojis intent (restart after update).":"No emojis match your search."}):s.jsx("div",{className:"grid grid-cols-6 gap-1.5 p-2 sm:grid-cols-8",children:M.map(I=>{const G=R.kind==="custom"&&R.id===I.id;return s.jsx("button",{type:"button",title:`:${I.name}:`,className:pe("flex aspect-square items-center justify-center rounded-lg border border-transparent bg-background/50 transition-colors hover:border-primary/30 hover:bg-accent",G&&"border-primary/50 bg-primary/15 ring-2 ring-primary/30"),onClick:()=>te(I),children:s.jsx("img",{src:I.url??e5(I.id,I.animated),alt:I.name,className:"size-8 object-contain",loading:"lazy"})},I.id)})})})]}),s.jsx($h,{value:"unicode",className:"mt-0 px-5 pb-4 pt-3",children:s.jsx(pO,{onPick:L})})]})]})}),s.jsx(De,{value:_,disabled:l,onChange:I=>c(I.target.value),placeholder:"Unicode or <:name:id>",className:"border-border bg-secondary/30 font-mono text-xs"})]})}const F0="BOT_TOKEN",bO="MODEL_API_KEY";function pd({field:t,value:n,onChange:a,readOnly:o}){const c=t.path.replace(/\./g,"-");if(t.type==="googleFont")return s.jsx(S_,{field:t,value:n,onChange:a,readOnly:o});if(t.type==="boolean")return s.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-border bg-secondary/20 px-3 py-2.5",children:[s.jsxs("div",{children:[s.jsx(_e,{htmlFor:c,className:"font-medium",children:t.label}),t.description?s.jsx("p",{className:"text-xs text-muted-foreground",children:t.description}):null]}),s.jsx(kt,{id:c,checked:!!n,disabled:o,onCheckedChange:a})]});if(t.type==="stringList")return s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{children:t.label}),t.description?s.jsx("p",{className:"text-xs text-muted-foreground",children:t.description}):null,s.jsx(w_,{value:Array.isArray(n)?n:[],onChange:a})]});if(t.type==="select"&&t.options)return s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:c,children:t.label}),s.jsxs(Ca,{value:String(n??""),disabled:o,onValueChange:a,children:[s.jsx(Br,{id:c,className:"border-border bg-secondary/30",children:s.jsx(Sa,{placeholder:"Select…"})}),s.jsx($r,{children:t.options.map(d=>s.jsx(vt,{value:d.value,children:d.label},d.value))})]})]});if(t.type==="color"){const d=Ur(String(n??"#000000"));return s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:c,children:t.label}),t.description?s.jsx("p",{className:"text-xs text-muted-foreground",children:t.description}):null,s.jsxs("div",{className:"flex gap-2",children:[s.jsx(tf,{value:d,onChange:a}),s.jsx(De,{id:c,value:d,disabled:o,onChange:m=>a(m.target.value),onBlur:m=>a(Ur(m.target.value,d)),className:"border-border bg-secondary/30 font-mono uppercase",placeholder:"#000000",maxLength:7})]})]})}if(t.type==="emoji")return s.jsx(vO,{id:c,label:t.label,description:t.description,value:n,onChange:a,readOnly:o});if(t.type==="discordChannel"||t.type==="discordRole"||t.type==="discordCategory"){const d=t.type==="discordRole"?"role":t.type==="discordCategory"?"category":"channel";return s.jsx(TS,{id:c,label:t.label,description:t.description,kind:d,value:n,onChange:a,readOnly:o})}if(t.type==="secret"){const d=n===F0||n===bO||!n?"":"••••••••••••";return s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:c,children:t.label}),t.description?s.jsx("p",{className:"text-xs text-muted-foreground",children:t.description}):null,s.jsx(De,{id:c,type:"password",value:d,disabled:o,placeholder:t.placeholder??"Unchanged if empty",onChange:m=>{const p=m.target.value;a(p||(t.placeholder??F0))},className:"border-border bg-secondary/30"})]})}const l="border-border bg-secondary/30";return t.type==="textarea"?s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:c,children:t.label}),s.jsx(Jd,{id:c,value:String(n??""),disabled:o,onChange:d=>a(d.target.value),className:`min-h-[88px] ${l}`})]}):s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:c,children:t.label}),t.description?s.jsx("p",{className:"text-xs text-muted-foreground",children:t.description}):null,s.jsx(De,{id:c,type:t.type==="number"?"number":"text",value:n==null?"":String(n),disabled:o,onChange:d=>a(t.type==="number"?Number(d.target.value):d.target.value),placeholder:t.placeholder??(t.type==="discordId"?"Discord snowflake ID":void 0),className:l})]})}const Ze=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,className:pe("rounded-xl border border-border bg-card text-card-foreground shadow-none",t),...n}));Ze.displayName="Card";const ut=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,className:pe("flex flex-col space-y-1.5 p-6",t),...n}));ut.displayName="CardHeader";const dt=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,className:pe("font-semibold leading-none tracking-tight",t),...n}));dt.displayName="CardTitle";const Ot=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,className:pe("text-sm text-muted-foreground",t),...n}));Ot.displayName="CardDescription";const Qe=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,className:pe("p-6 pt-0",t),...n}));Qe.displayName="CardContent";const Sx=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,className:pe("flex items-center p-6 pt-0",t),...n}));Sx.displayName="CardFooter";function Y0(t){return t.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,n=>n.toUpperCase())}function yO(t,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=t.toLowerCase();return/prefix/.test(a)?"text":/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 Nx(t,n=""){const a=[];for(const[o,c]of Object.entries(t)){const l=n?`${n}.${o}`:o;if(Array.isArray(c)){if(c.length>0&&typeof c[0]=="object"&&c[0]!==null&&!Array.isArray(c[0]))continue;a.push({path:l,label:Y0(o),type:"stringList"});continue}if(c&&typeof c=="object"&&Object.keys(c).length>0){a.push(...Nx(c,l));continue}a.push({path:l,label:Y0(o),type:yO(o,c)})}return a}function wO(t){const n=Nx(t);return n.length===0?[{title:"Configuration",fields:[]}]:[{title:"Settings",description:"Values from this addon’s config file.",fields:n}]}function Fr(t,n){const a=n.split(".");let o=t;for(const c of a){if(o==null||typeof o!="object")return;o=o[c]}return o}function Gn(t,n,a){const o=n.split("."),c=structuredClone(t);let l=c;for(let d=0;d{switch(t){case"success":return NO;case"info":return kO;case"warning":return EO;case"error":return TO;default:return null}},CO=Array(12).fill(0),SO=({visible:t,className:n})=>be.createElement("div",{className:["sonner-loading-wrapper",n].filter(Boolean).join(" "),"data-visible":t},be.createElement("div",{className:"sonner-spinner"},CO.map((a,o)=>be.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${o}`})))),NO=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},be.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"})),EO=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},be.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"})),kO=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},be.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"})),TO=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},be.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"})),MO=be.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"},be.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),be.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),RO=()=>{let[t,n]=be.useState(document.hidden);return be.useEffect(()=>{let a=()=>{n(document.hidden)};return document.addEventListener("visibilitychange",a),()=>window.removeEventListener("visibilitychange",a)},[]),t},qh=1,AO=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;let{message:a,...o}=t,c=typeof(t==null?void 0:t.id)=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:qh++,l=this.toasts.find(m=>m.id===c),d=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(c)&&this.dismissedToasts.delete(c),l?this.toasts=this.toasts.map(m=>m.id===c?(this.publish({...m,...t,id:c,title:a}),{...m,...t,id:c,dismissible:d,title:a}):m):this.addToast({title:a,...o,dismissible:d,id:c}),c},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(n=>{this.subscribers.forEach(a=>a({id:n.id,dismiss:!0}))}),this.subscribers.forEach(n=>n({id:t,dismiss:!0})),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let a;n.loading!==void 0&&(a=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));let o=t instanceof Promise?t:t(),c=a!==void 0,l,d=o.then(async p=>{if(l=["resolve",p],be.isValidElement(p))c=!1,this.create({id:a,type:"default",message:p});else if(DO(p)&&!p.ok){c=!1;let g=typeof n.error=="function"?await n.error(`HTTP error! status: ${p.status}`):n.error,v=typeof n.description=="function"?await n.description(`HTTP error! status: ${p.status}`):n.description;this.create({id:a,type:"error",message:g,description:v})}else if(n.success!==void 0){c=!1;let g=typeof n.success=="function"?await n.success(p):n.success,v=typeof n.description=="function"?await n.description(p):n.description;this.create({id:a,type:"success",message:g,description:v})}}).catch(async p=>{if(l=["reject",p],n.error!==void 0){c=!1;let g=typeof n.error=="function"?await n.error(p):n.error,v=typeof n.description=="function"?await n.description(p):n.description;this.create({id:a,type:"error",message:g,description:v})}}).finally(()=>{var p;c&&(this.dismiss(a),a=void 0),(p=n.finally)==null||p.call(n)}),m=()=>new Promise((p,g)=>d.then(()=>l[0]==="reject"?g(l[1]):p(l[1])).catch(g));return typeof a!="string"&&typeof a!="number"?{unwrap:m}:Object.assign(a,{unwrap:m})},this.custom=(t,n)=>{let a=(n==null?void 0:n.id)||qh++;return this.create({jsx:t(a),id:a,...n}),a},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Tn=new AO,_O=(t,n)=>{let a=(n==null?void 0:n.id)||qh++;return Tn.addToast({title:t,...n,id:a}),a},DO=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",OO=_O,LO=()=>Tn.toasts,zO=()=>Tn.getActiveToasts(),Dt=Object.assign(OO,{success:Tn.success,info:Tn.info,warning:Tn.warning,error:Tn.error,custom:Tn.custom,message:Tn.message,promise:Tn.promise,dismiss:Tn.dismiss,loading:Tn.loading},{getHistory:LO,getToasts:zO});function PO(t,{insertAt:n}={}){if(typeof document>"u")return;let a=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",n==="top"&&a.firstChild?a.insertBefore(o,a.firstChild):a.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}PO(`:where(html[dir="ltr"]),:where([data-sonner-toaster][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%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][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%)}:where([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:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([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);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([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 #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([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)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([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;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([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);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-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([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}:where([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}:where([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, 0px)) translate(var(--swipe-amount-x, 0px));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{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{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{0%{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-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--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-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-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-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, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--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-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-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],[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],[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],[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],[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:nth-child(1){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)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{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 Hu(t){return t.label!==void 0}var IO=3,UO="32px",BO="16px",q0=4e3,$O=356,HO=14,GO=20,VO=200;function wr(...t){return t.filter(Boolean).join(" ")}function FO(t){let[n,a]=t.split("-"),o=[];return n&&o.push(n),a&&o.push(a),o}var YO=t=>{var n,a,o,c,l,d,m,p,g,v,b;let{invert:w,toast:y,unstyled:C,interacting:S,setHeights:E,visibleToasts:k,heights:N,index:T,toasts:M,expanded:_,removeToast:R,defaultRichColors:L,closeButton:te,style:K,cancelButtonStyle:I,actionButtonStyle:G,className:Y="",descriptionClassName:ce="",duration:fe,position:se,gap:P,loadingIcon:Z,expandByDefault:ae,classNames:re,icons:V,closeButtonAriaLabel:O="Close toast",pauseWhenPageIsHidden:D}=t,[$,H]=be.useState(null),[X,xe]=be.useState(null),[q,ge]=be.useState(!1),[me,B]=be.useState(!1),[ie,we]=be.useState(!1),[Ce,ze]=be.useState(!1),[Ke,ft]=be.useState(!1),[Pt,gn]=be.useState(0),[Yr,_n]=be.useState(0),wn=be.useRef(y.duration||fe||q0),Xn=be.useRef(null),Zn=be.useRef(null),It=T===0,po=T+1<=k,nn=y.type,Dn=y.dismissible!==!1,Da=y.className||"",ho=y.descriptionClassName||"",Qn=be.useMemo(()=>N.findIndex(Oe=>Oe.toastId===y.id)||0,[N,y.id]),Es=be.useMemo(()=>{var Oe;return(Oe=y.closeButton)!=null?Oe:te},[y.closeButton,te]),qr=be.useMemo(()=>y.duration||fe||q0,[y.duration,fe]),gr=be.useRef(0),Tt=be.useRef(0),On=be.useRef(0),Mt=be.useRef(null),[Oi,Li]=se.split("-"),go=be.useMemo(()=>N.reduce((Oe,tt,it)=>it>=Qn?Oe:Oe+tt.height,0),[N,Qn]),Kr=RO(),Oa=y.invert||w,Mr=nn==="loading";Tt.current=be.useMemo(()=>Qn*P+go,[Qn,go]),be.useEffect(()=>{wn.current=qr},[qr]),be.useEffect(()=>{ge(!0)},[]),be.useEffect(()=>{let Oe=Zn.current;if(Oe){let tt=Oe.getBoundingClientRect().height;return _n(tt),E(it=>[{toastId:y.id,height:tt,position:y.position},...it]),()=>E(it=>it.filter(rn=>rn.toastId!==y.id))}},[E,y.id]),be.useLayoutEffect(()=>{if(!q)return;let Oe=Zn.current,tt=Oe.style.height;Oe.style.height="auto";let it=Oe.getBoundingClientRect().height;Oe.style.height=tt,_n(it),E(rn=>rn.find(Ft=>Ft.toastId===y.id)?rn.map(Ft=>Ft.toastId===y.id?{...Ft,height:it}:Ft):[{toastId:y.id,height:it,position:y.position},...rn])},[q,y.title,y.description,E,y.id]);let Kt=be.useCallback(()=>{B(!0),gn(Tt.current),E(Oe=>Oe.filter(tt=>tt.toastId!==y.id)),setTimeout(()=>{R(y)},VO)},[y,R,E,Tt]);be.useEffect(()=>{if(y.promise&&nn==="loading"||y.duration===1/0||y.type==="loading")return;let Oe;return _||S||D&&Kr?(()=>{if(On.current{var tt;(tt=y.onAutoClose)==null||tt.call(y,y),Kt()},wn.current)),()=>clearTimeout(Oe)},[_,S,y,nn,D,Kr,Kt]),be.useEffect(()=>{y.delete&&Kt()},[Kt,y.delete]);function La(){var Oe,tt,it;return V!=null&&V.loading?be.createElement("div",{className:wr(re==null?void 0:re.loader,(Oe=y==null?void 0:y.classNames)==null?void 0:Oe.loader,"sonner-loader"),"data-visible":nn==="loading"},V.loading):Z?be.createElement("div",{className:wr(re==null?void 0:re.loader,(tt=y==null?void 0:y.classNames)==null?void 0:tt.loader,"sonner-loader"),"data-visible":nn==="loading"},Z):be.createElement(SO,{className:wr(re==null?void 0:re.loader,(it=y==null?void 0:y.classNames)==null?void 0:it.loader),visible:nn==="loading"})}return be.createElement("li",{tabIndex:0,ref:Zn,className:wr(Y,Da,re==null?void 0:re.toast,(n=y==null?void 0:y.classNames)==null?void 0:n.toast,re==null?void 0:re.default,re==null?void 0:re[nn],(a=y==null?void 0:y.classNames)==null?void 0:a[nn]),"data-sonner-toast":"","data-rich-colors":(o=y.richColors)!=null?o:L,"data-styled":!(y.jsx||y.unstyled||C),"data-mounted":q,"data-promise":!!y.promise,"data-swiped":Ke,"data-removed":me,"data-visible":po,"data-y-position":Oi,"data-x-position":Li,"data-index":T,"data-front":It,"data-swiping":ie,"data-dismissible":Dn,"data-type":nn,"data-invert":Oa,"data-swipe-out":Ce,"data-swipe-direction":X,"data-expanded":!!(_||ae&&q),style:{"--index":T,"--toasts-before":T,"--z-index":M.length-T,"--offset":`${me?Pt:Tt.current}px`,"--initial-height":ae?"auto":`${Yr}px`,...K,...y.style},onDragEnd:()=>{we(!1),H(null),Mt.current=null},onPointerDown:Oe=>{Mr||!Dn||(Xn.current=new Date,gn(Tt.current),Oe.target.setPointerCapture(Oe.pointerId),Oe.target.tagName!=="BUTTON"&&(we(!0),Mt.current={x:Oe.clientX,y:Oe.clientY}))},onPointerUp:()=>{var Oe,tt,it,rn;if(Ce||!Dn)return;Mt.current=null;let Ft=Number(((Oe=Zn.current)==null?void 0:Oe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Rt=Number(((tt=Zn.current)==null?void 0:tt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Jn=new Date().getTime()-((it=Xn.current)==null?void 0:it.getTime()),fn=$==="x"?Ft:Rt,Ln=Math.abs(fn)/Jn;if(Math.abs(fn)>=GO||Ln>.11){gn(Tt.current),(rn=y.onDismiss)==null||rn.call(y,y),xe($==="x"?Ft>0?"right":"left":Rt>0?"down":"up"),Kt(),ze(!0),ft(!1);return}we(!1),H(null)},onPointerMove:Oe=>{var tt,it,rn,Ft;if(!Mt.current||!Dn||((tt=window.getSelection())==null?void 0:tt.toString().length)>0)return;let Rt=Oe.clientY-Mt.current.y,Jn=Oe.clientX-Mt.current.x,fn=(it=t.swipeDirections)!=null?it:FO(se);!$&&(Math.abs(Jn)>1||Math.abs(Rt)>1)&&H(Math.abs(Jn)>Math.abs(Rt)?"x":"y");let Ln={x:0,y:0};$==="y"?(fn.includes("top")||fn.includes("bottom"))&&(fn.includes("top")&&Rt<0||fn.includes("bottom")&&Rt>0)&&(Ln.y=Rt):$==="x"&&(fn.includes("left")||fn.includes("right"))&&(fn.includes("left")&&Jn<0||fn.includes("right")&&Jn>0)&&(Ln.x=Jn),(Math.abs(Ln.x)>0||Math.abs(Ln.y)>0)&&ft(!0),(rn=Zn.current)==null||rn.style.setProperty("--swipe-amount-x",`${Ln.x}px`),(Ft=Zn.current)==null||Ft.style.setProperty("--swipe-amount-y",`${Ln.y}px`)}},Es&&!y.jsx?be.createElement("button",{"aria-label":O,"data-disabled":Mr,"data-close-button":!0,onClick:Mr||!Dn?()=>{}:()=>{var Oe;Kt(),(Oe=y.onDismiss)==null||Oe.call(y,y)},className:wr(re==null?void 0:re.closeButton,(c=y==null?void 0:y.classNames)==null?void 0:c.closeButton)},(l=V==null?void 0:V.close)!=null?l:MO):null,y.jsx||f.isValidElement(y.title)?y.jsx?y.jsx:typeof y.title=="function"?y.title():y.title:be.createElement(be.Fragment,null,nn||y.icon||y.promise?be.createElement("div",{"data-icon":"",className:wr(re==null?void 0:re.icon,(d=y==null?void 0:y.classNames)==null?void 0:d.icon)},y.promise||y.type==="loading"&&!y.icon?y.icon||La():null,y.type!=="loading"?y.icon||(V==null?void 0:V[nn])||jO(nn):null):null,be.createElement("div",{"data-content":"",className:wr(re==null?void 0:re.content,(m=y==null?void 0:y.classNames)==null?void 0:m.content)},be.createElement("div",{"data-title":"",className:wr(re==null?void 0:re.title,(p=y==null?void 0:y.classNames)==null?void 0:p.title)},typeof y.title=="function"?y.title():y.title),y.description?be.createElement("div",{"data-description":"",className:wr(ce,ho,re==null?void 0:re.description,(g=y==null?void 0:y.classNames)==null?void 0:g.description)},typeof y.description=="function"?y.description():y.description):null),f.isValidElement(y.cancel)?y.cancel:y.cancel&&Hu(y.cancel)?be.createElement("button",{"data-button":!0,"data-cancel":!0,style:y.cancelButtonStyle||I,onClick:Oe=>{var tt,it;Hu(y.cancel)&&Dn&&((it=(tt=y.cancel).onClick)==null||it.call(tt,Oe),Kt())},className:wr(re==null?void 0:re.cancelButton,(v=y==null?void 0:y.classNames)==null?void 0:v.cancelButton)},y.cancel.label):null,f.isValidElement(y.action)?y.action:y.action&&Hu(y.action)?be.createElement("button",{"data-button":!0,"data-action":!0,style:y.actionButtonStyle||G,onClick:Oe=>{var tt,it;Hu(y.action)&&((it=(tt=y.action).onClick)==null||it.call(tt,Oe),!Oe.defaultPrevented&&Kt())},className:wr(re==null?void 0:re.actionButton,(b=y==null?void 0:y.classNames)==null?void 0:b.actionButton)},y.action.label):null))};function K0(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function qO(t,n){let a={};return[t,n].forEach((o,c)=>{let l=c===1,d=l?"--mobile-offset":"--offset",m=l?BO:UO;function p(g){["top","right","bottom","left"].forEach(v=>{a[`${d}-${v}`]=typeof g=="number"?`${g}px`:g})}typeof o=="number"||typeof o=="string"?p(o):typeof o=="object"?["top","right","bottom","left"].forEach(g=>{o[g]===void 0?a[`${d}-${g}`]=m:a[`${d}-${g}`]=typeof o[g]=="number"?`${o[g]}px`:o[g]}):p(m)}),a}var KO=f.forwardRef(function(t,n){let{invert:a,position:o="bottom-right",hotkey:c=["altKey","KeyT"],expand:l,closeButton:d,className:m,offset:p,mobileOffset:g,theme:v="light",richColors:b,duration:w,style:y,visibleToasts:C=IO,toastOptions:S,dir:E=K0(),gap:k=HO,loadingIcon:N,icons:T,containerAriaLabel:M="Notifications",pauseWhenPageIsHidden:_}=t,[R,L]=be.useState([]),te=be.useMemo(()=>Array.from(new Set([o].concat(R.filter(D=>D.position).map(D=>D.position)))),[R,o]),[K,I]=be.useState([]),[G,Y]=be.useState(!1),[ce,fe]=be.useState(!1),[se,P]=be.useState(v!=="system"?v:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),Z=be.useRef(null),ae=c.join("+").replace(/Key/g,"").replace(/Digit/g,""),re=be.useRef(null),V=be.useRef(!1),O=be.useCallback(D=>{L($=>{var H;return(H=$.find(X=>X.id===D.id))!=null&&H.delete||Tn.dismiss(D.id),$.filter(({id:X})=>X!==D.id)})},[]);return be.useEffect(()=>Tn.subscribe(D=>{if(D.dismiss){L($=>$.map(H=>H.id===D.id?{...H,delete:!0}:H));return}setTimeout(()=>{m8.flushSync(()=>{L($=>{let H=$.findIndex(X=>X.id===D.id);return H!==-1?[...$.slice(0,H),{...$[H],...D},...$.slice(H+1)]:[D,...$]})})})}),[]),be.useEffect(()=>{if(v!=="system"){P(v);return}if(v==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?P("dark"):P("light")),typeof window>"u")return;let D=window.matchMedia("(prefers-color-scheme: dark)");try{D.addEventListener("change",({matches:$})=>{P($?"dark":"light")})}catch{D.addListener(({matches:H})=>{try{P(H?"dark":"light")}catch(X){console.error(X)}})}},[v]),be.useEffect(()=>{R.length<=1&&Y(!1)},[R]),be.useEffect(()=>{let D=$=>{var H,X;c.every(xe=>$[xe]||$.code===xe)&&(Y(!0),(H=Z.current)==null||H.focus()),$.code==="Escape"&&(document.activeElement===Z.current||(X=Z.current)!=null&&X.contains(document.activeElement))&&Y(!1)};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[c]),be.useEffect(()=>{if(Z.current)return()=>{re.current&&(re.current.focus({preventScroll:!0}),re.current=null,V.current=!1)}},[Z.current]),be.createElement("section",{ref:n,"aria-label":`${M} ${ae}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},te.map((D,$)=>{var H;let[X,xe]=D.split("-");return R.length?be.createElement("ol",{key:D,dir:E==="auto"?K0():E,tabIndex:-1,ref:Z,className:m,"data-sonner-toaster":!0,"data-theme":se,"data-y-position":X,"data-lifted":G&&R.length>1&&!l,"data-x-position":xe,style:{"--front-toast-height":`${((H=K[0])==null?void 0:H.height)||0}px`,"--width":`${$O}px`,"--gap":`${k}px`,...y,...qO(p,g)},onBlur:q=>{V.current&&!q.currentTarget.contains(q.relatedTarget)&&(V.current=!1,re.current&&(re.current.focus({preventScroll:!0}),re.current=null))},onFocus:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||V.current||(V.current=!0,re.current=q.relatedTarget)},onMouseEnter:()=>Y(!0),onMouseMove:()=>Y(!0),onMouseLeave:()=>{ce||Y(!1)},onDragEnd:()=>Y(!1),onPointerDown:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||fe(!0)},onPointerUp:()=>fe(!1)},R.filter(q=>!q.position&&$===0||q.position===D).map((q,ge)=>{var me,B;return be.createElement(YO,{key:q.id,icons:T,index:ge,toast:q,defaultRichColors:b,duration:(me=S==null?void 0:S.duration)!=null?me:w,className:S==null?void 0:S.className,descriptionClassName:S==null?void 0:S.descriptionClassName,invert:a,visibleToasts:C,closeButton:(B=S==null?void 0:S.closeButton)!=null?B:d,interacting:ce,position:D,style:S==null?void 0:S.style,unstyled:S==null?void 0:S.unstyled,classNames:S==null?void 0:S.classNames,cancelButtonStyle:S==null?void 0:S.cancelButtonStyle,actionButtonStyle:S==null?void 0:S.actionButtonStyle,removeToast:O,toasts:R.filter(ie=>ie.position==q.position),heights:K.filter(ie=>ie.position==q.position),setHeights:I,expandByDefault:l,gap:k,loadingIcon:N,expanded:G,pauseWhenPageIsHidden:_,swipeDirections:t.swipeDirections})})):null}))});async function nd(t){const n=Dt.loading("Saving changes…");try{const a=await t();if(Dt.success("Changes saved",{id:n}),a.botRestart){const o=Dt.loading("Restarting bot…");a.botRestart.success?Dt.success("Bot started",{id:o}):Dt.error(a.botRestart.error??"Could not start bot",{id:o})}return a}catch(a){throw Dt.error(a instanceof Error?a.message:"Save failed",{id:n}),a}}function WO({filename:t}){const{canEditConfig:n}=qt(),a=!n("supportbot"),[o,c]=f.useState(null),[l,d]=f.useState(null),[m,p]=f.useState(!0),[g,v]=f.useState(!1),[b,w]=f.useState(""),[y,C]=f.useState(""),S=f.useCallback(async()=>{p(!0),w(""),C("");try{const _=(await Ne.getAddonConfigJson(t)).data??{};c(_),d(structuredClone(_))}catch(M){w(M instanceof Error?M.message:"Failed to load config")}finally{p(!1)}},[t]);f.useEffect(()=>{S()},[S]);const E=o?wO(o):null;function k(M,_){c(R=>R&&Gn(R,M,_))}async function N(){if(!(a||!o)){v(!0),w(""),C("");try{const M=await nd(()=>Ne.saveAddonConfig(t,o));C(M.message||"Saved."),await S()}catch(M){w(M instanceof Error?M.message:"Save failed")}finally{v(!1)}}}if(m)return s.jsxs("div",{className:"space-y-4",children:[s.jsx(Be,{className:"h-24 w-full rounded-xl"}),s.jsx(Be,{className:"h-48 w-full rounded-xl"})]});if(!o||!E)return s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:b||"Failed to load"})});const T=l&&JSON.stringify(o)!==JSON.stringify(l);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[T?s.jsx("span",{className:"text-xs text-amber-500",children:"Unsaved changes"}):null,s.jsx(ue,{variant:"outline",size:"sm",onClick:S,disabled:m||g,children:"Reload"}),a?s.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}):s.jsxs(ue,{size:"sm",onClick:N,disabled:g||!T,children:[s.jsx(ve,{icon:Sd,size:16,className:"mr-1.5"}),g?"Saving…":"Save"]})]}),b?s.jsxs(Ye,{variant:"destructive",children:[s.jsx(ve,{icon:ig,size:18}),s.jsx(qe,{children:b})]}):null,y?s.jsx(Ye,{className:"border-primary/30 bg-primary/10 text-primary",children:s.jsx(qe,{children:y})}):null,E.map(M=>s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{className:"pb-3",children:[s.jsx(dt,{className:"text-base",children:M.title}),M.description?s.jsx(Ot,{children:M.description}):null]}),s.jsx(Qe,{className:"grid gap-4 sm:grid-cols-2",children:M.fields.map(_=>s.jsx("div",{className:_.type==="textarea"||_.type==="stringList"?"sm:col-span-2":"",children:s.jsx(pd,{field:_,value:Fr(o,_.path),readOnly:a,onChange:R=>k(_.path,R)})},_.path))})]},M.title))]})}function XO(t){return t.startsWith("Ticket.DepartmentSystem.")?"Ticket Departments":t.startsWith("Ticket.PrioritySystem.")?"Ticket Priorities":t.startsWith("Ticket.")?"Tickets":(t.split(".")[0]??"Other").replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,a=>a.toUpperCase())}function ZO(t,n){const a=new Set(t.flatMap(d=>d.fields.map(m=>m.path))),o=Nx(n).filter(d=>!a.has(d.path));if(o.length===0)return t;const c=t.map(d=>({...d,fields:[...d.fields]})),l=new Map;for(const d of o){const m=XO(d.path),p=l.get(m)??[];p.push(d),l.set(m,p)}for(const[d,m]of l.entries()){const p=c.find(g=>g.title.toLowerCase()===d.toLowerCase());p?p.fields.push(...m):c.push({title:d,description:"These options exist in your config file but are not in the main editor sections.",fields:m.sort((g,v)=>g.path.localeCompare(v.path))})}return c}function W0(t,n){(n==null||n>t.length)&&(n=t.length);for(var a=0,o=Array(n);a=t.length?t.apply(this,c):function(){for(var d=arguments.length,m=new Array(d),p=0;p1&&arguments[1]!==void 0?arguments[1]:{};Gu.initial(t),Gu.handler(n);var a={current:t},o=Al(wL)(a,n),c=Al(yL)(a),l=Al(Gu.changes)(t),d=Al(bL)(a);function m(){var g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(v){return v};return Gu.selector(g),g(a.current)}function p(g){cL(o,c,l,d)(g)}return[m,p]}function bL(t,n){return Ql(n)?n(t.current):n}function yL(t,n){return t.current=J0(J0({},t.current),n),n}function wL(t,n,a){return Ql(n)?n(t.current):Object.keys(a).forEach(function(o){var c;return(c=n[o])===null||c===void 0?void 0:c.call(n,t.current[o])}),a}var jL={create:vL},CL={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function SL(t){return function n(){for(var a=this,o=arguments.length,c=new Array(o),l=0;l=t.length?t.apply(this,c):function(){for(var d=arguments.length,m=new Array(d),p=0;p{l.customEmoji&&l.database&&L()}),d(()=>{l.customEmoji&&l.customEmoji.length?l.groups!==Fh&&(l.groups=Fh):l.groups!==Hp&&(l.currentGroupIndex&&l.currentGroupIndex--,l.groups=Hp)}),d(()=>{async function $(){l.databaseLoaded&&(l.currentSkinTone=await l.database.getPreferredSkinTone())}$()}),d(()=>{l.skinTones=Array(z0).fill().map(($,ie)=>ID(l.skinToneEmoji,ie))}),d(()=>{l.skinToneButtonText=l.skinTones[l.currentSkinTone]}),d(()=>{l.skinToneButtonLabel=l.i18n.skinToneLabel.replace("{skinTone}",l.i18n.skinTones[l.currentSkinTone])}),d(()=>{async function $(){const{database:ie}=l,ye=(await Promise.all(TD.map(Se=>ie.getEmojiByUnicodeOrName(Se)))).filter(Boolean);l.defaultFavoriteEmojis=ye}l.databaseLoaded&&$()});function L(){const{customEmoji:$,database:ie}=l,ye=$||Kp;ie.customEmoji!==ye&&(ie.customEmoji=ye)}d(()=>{async function $(){L();const{database:ie,defaultFavoriteEmojis:ye,numColumns:Se}=l,Be=await ie.getTopFavoriteEmoji(Se),Ke=await de(XS([...Be,...ye],We=>We.unicode||We.name).slice(0,Se));l.currentFavorites=Ke}l.databaseLoaded&&l.defaultFavoriteEmojis&&$()});function ne($){$D($,c,()=>{{const ie=getComputedStyle(a.rootElement),ye=parseInt(ie.getPropertyValue("--num-columns"),10),Se=ie.getPropertyValue("direction")==="rtl";l.numColumns=ye,l.isRtl=Se}})}function X($){iO($,c,ie=>{for(const{target:ye,isIntersecting:Se}of ie)ye.classList.toggle("onscreen",Se)})}d(()=>{async function $(){const{searchText:ie,currentGroup:ye,databaseLoaded:Se,customEmoji:Be}=l;if(!Se)l.currentEmojis=[],l.searchMode=!1;else if(ie.length>=CD){const Ke=await P(ie);l.searchText===ie&&(y(Ke),C(!0))}else{const{id:Ke}=ye;if(Ke!==-1||Be&&Be.length){const We=await se(Ke);l.currentGroup.id===Ke&&(y(We),C(!1))}}}$()});const I=()=>{ed(()=>FD(a.tabpanelElement))};d(()=>{const{currentEmojis:$,emojiVersion:ie}=l,ye=$.filter(Se=>Se.unicode).filter(Se=>P0(Se)&&!Yh.has(Se.unicode));if(!ie&&ye.length)y($),ed(()=>H(ye));else{const Se=ie?$:$.filter(q);y(Se),I()}});function H($){GD($,a.baselineEmoji,g)?I():l.currentEmojis=[...l.currentEmojis]}function q($){return!$.unicode||!P0($)||Yh.get($.unicode)}async function ce($){const ie=l.emojiVersion||await Vp();return $.filter(({version:ye})=>!ye||ye<=ie)}async function de($){return UD($,l.emojiVersion||await Vp())}async function se($){const ie=$===-1?l.customEmoji:await l.database.getEmojiByGroup($);return de(await ce(ie))}async function P($){return de(await ce(await l.database.getEmojiBySearchQuery($)))}d(()=>{}),d(()=>{function $(){const{searchMode:ye,currentEmojis:Se}=l;if(ye)return[{category:"",emojis:Se}];const Be=new Map;for(const Ke of Se){const We=Ke.category||"";let qt=Be.get(We);qt||(qt=[],Be.set(We,qt)),qt.push(Ke)}return[...Be.entries()].map(([Ke,We])=>({category:Ke,emojis:We})).sort((Ke,We)=>l.customCategorySorting(Ke.category,We.category))}const ie=$();S(ie)}),d(()=>{l.activeSearchItemId=l.activeSearchItem!==-1&&l.currentEmojis[l.activeSearchItem].id}),d(()=>{const{rawSearchText:$}=l;KS(()=>{l.searchText=($||"").trim(),l.activeSearchItem=-1})});function W($){if(!l.searchMode||!l.currentEmojis.length)return;const ie=ye=>{Ir($),l.activeSearchItem=Fp(ye,l.activeSearchItem,l.currentEmojis)};switch($.key){case"ArrowDown":return ie(!1);case"ArrowUp":return ie(!0);case"Enter":if(l.activeSearchItem===-1)l.activeSearchItem=0;else return Ir($),O(l.currentEmojis[l.activeSearchItem].id)}}function oe($){const{target:ie}=$,ye=ie.closest(".nav-button");if(!ye)return;const Se=parseInt(ye.dataset.groupId,10);a.searchElement.value="",l.rawSearchText="",l.searchText="",l.activeSearchItem=-1,l.currentGroupIndex=l.groups.findIndex(Be=>Be.id===Se)}function ae($){const{target:ie,key:ye}=$,Se=Be=>{Be&&(Ir($),Be.focus())};switch(ye){case"ArrowLeft":return Se(ie.previousElementSibling);case"ArrowRight":return Se(ie.nextElementSibling);case"Home":return Se(ie.parentElement.firstElementChild);case"End":return Se(ie.parentElement.lastElementChild)}}async function G($){const ie=await l.database.getEmojiByUnicodeOrName($),ye=[...l.currentEmojis,...l.currentFavorites].find(Be=>Be.id===$),Se=ye.unicode&&N(ye,l.currentSkinTone);return await l.database.incrementFavoriteEmojiCount($),{emoji:ie,skinTone:l.currentSkinTone,...Se&&{unicode:Se},...ye.name&&{name:ye.name}}}async function O($){const ie=G($);b("emoji-click-sync",ie),b("emoji-click",await ie)}function D($){const{target:ie}=$;if(!ie.classList.contains("emoji"))return;Ir($);const ye=ie.id.substring(4);O(ye)}function B($){l.currentSkinTone=$,l.skinTonePickerExpanded=!1,p("skintone-button"),b("skin-tone-change",{skinTone:$}),l.database.setPreferredSkinTone($)}function V($){const{target:{id:ie}}=$,ye=ie&&ie.match(/^skintone-(\d)/);if(!ye)return;Ir($);const Se=parseInt(ye[1],10);B(Se)}function Z($){l.skinTonePickerExpanded=!l.skinTonePickerExpanded,l.activeSkinTone=l.currentSkinTone,l.skinTonePickerExpanded&&(Ir($),ed(()=>p("skintone-list")))}d(()=>{l.skinTonePickerExpanded?a.skinToneDropdown.addEventListener("transitionend",()=>{l.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):l.skinTonePickerExpandedAfterAnimation=!1});function be($){if(!l.skinTonePickerExpanded)return;const ie=async ye=>{Ir($),l.activeSkinTone=ye};switch($.key){case"ArrowUp":return ie(Fp(!0,l.activeSkinTone,l.skinTones));case"ArrowDown":return ie(Fp(!1,l.activeSkinTone,l.skinTones));case"Home":return ie(0);case"End":return ie(l.skinTones.length-1);case"Enter":return Ir($),B(l.activeSkinTone);case"Escape":return Ir($),l.skinTonePickerExpanded=!1,p("skintone-button")}}function K($){if(l.skinTonePickerExpanded)switch($.key){case" ":return Ir($),B(l.activeSkinTone)}}async function ge($){const{relatedTarget:ie}=$;(!ie||ie.id!=="skintone-list")&&(l.skinTonePickerExpanded=!1)}function me($){l.rawSearchText=$.target.value}return{$set($){$u(l,$)},$destroy(){o.abort()}}}const cO="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",uO="en";var dO={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"}},fO=':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 ZS=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],mO=`:host{--emoji-font-family:${WS}}`;class Cx extends HTMLElement{constructor(n){super(),this.attachShadow({mode:"open"});const a=document.createElement("style");a.textContent=fO+mO,this.shadowRoot.appendChild(a),this._ctx={locale:uO,dataSource:cO,skinToneEmoji:ED,customCategorySorting:MD,customEmoji:null,i18n:dO,emojiVersion:null,...n};for(const o of ZS)o!=="database"&&Object.prototype.hasOwnProperty.call(this,o)&&(this._ctx[o]=this[o],delete this[o]);this._dbFlush()}connectedCallback(){V0(this),this._cmp||(this._cmp=lO(this.shadowRoot,this._ctx))}disconnectedCallback(){V0(this),md(()=>{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,(c,l)=>l.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 jD({locale:n,dataSource:a}))}_dbFlush(){md(()=>this._dbCreate())}}const QS={};for(const t of ZS)QS[t]={get(){return t==="database"&&this._dbCreate(),this._ctx[t]},set(n){if(t==="database")throw new Error("database is read-only");this._set(t,n)}};Object.defineProperties(Cx.prototype,QS);function V0(t){t instanceof Cx||Object.setPrototypeOf(t,customElements.get(t.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Cx);function pO({onPick:t}){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 c=l=>{var p;const d=l.detail,m=(d==null?void 0:d.unicode)??((p=d==null?void 0:d.emoji)==null?void 0:p.unicode);m&&t(m)};return o.addEventListener("emoji-click",c),a.appendChild(o),()=>{o.removeEventListener("emoji-click",c),o.remove()}},[t]),s.jsx("div",{ref:n,className:"unicode-emoji-panel-host overflow-hidden rounded-lg border border-border/50"})}const hO=/^<(a?):([^:>]+):(\d{17,20})>$/;function td(t,n,a=!1){return`${a?"`}function JS(t){const n=String(t??"").trim();if(!n)return{kind:"empty",value:""};const a=n.match(hO);return a?{kind:"custom",value:n,animated:a[1]==="a",name:a[2],id:a[3]}:{kind:"unicode",value:n}}function e5(t,n=!1){return`https://cdn.discordapp.com/emojis/${t}.${n?"gif":"png"}?size=64`}function gO(t,n=[]){const a=JS(t);if(a.kind==="custom"&&a.id&&!a.name){const o=n.find(c=>c.id===a.id);if(o)return{kind:"custom",value:td(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(c=>c.id===a.id);if(o&&a.value!==td(o.name,o.id,o.animated))return{kind:"custom",value:td(o.name,o.id,o.animated),name:o.name,id:o.id,animated:o.animated}}return a}function xO({value:t,guildEmojis:n,size:a="md"}){const o=gO(t,n),c=a==="lg"?"size-10":"size-7",l=a==="lg"?"text-3xl":"text-2xl";return o.kind==="empty"?s.jsx("span",{className:"text-sm text-muted-foreground",children:"No emoji selected"}):o.kind==="custom"&&o.id?s.jsxs("span",{className:"inline-flex items-center gap-3",children:[s.jsx("img",{src:e5(o.id,o.animated),alt:o.name??"custom emoji",className:pe(c,"shrink-0 rounded-md"),loading:"lazy"}),s.jsxs("span",{className:"flex flex-col items-start gap-0.5",children:[s.jsxs("span",{className:"text-sm font-medium",children:[":",o.name,":"]}),s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:o.value})]})]}):s.jsx("span",{className:pe(l,"leading-none"),title:o.value,children:o.value})}function bO({id:t,label:n,description:a,value:o,onChange:c,readOnly:l}){const[d,m]=f.useState(!1),[p,g]=f.useState("server"),[b,v]=f.useState(null),[w,y]=f.useState(""),[C,S]=f.useState(!1),[N,E]=f.useState(""),T=f.useCallback(async(I=!1)=>{S(!0),y("");try{const H=await Ne.getGuildResources(I);H.data?(v(H.data),Array.isArray(H.data.emojis)||y("Server response is missing emojis. Restart the bot after updating.")):y("No guild data returned.")}catch(H){y(H instanceof Error?H.message:"Could not load server emojis")}finally{S(!1)}},[]);f.useEffect(()=>{d&&T(!0)},[d,T]);const M=f.useMemo(()=>Array.isArray(b==null?void 0:b.emojis)?b.emojis:[],[b]),k=f.useMemo(()=>{const I=N.trim().toLowerCase();return I?M.filter(H=>H.name.toLowerCase().includes(I)):M},[M,N]),_=String(o??""),R=JS(_);function L(I){c(I),m(!1)}function ne(I){c(td(I.name,I.id,I.animated)),m(!1)}function X(){c("")}return s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:t,children:n}),a?s.jsx("p",{className:"text-xs text-muted-foreground",children:a}):null,s.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:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(xO,{value:o,guildEmojis:M,size:"lg"})}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx(ue,{type:"button",variant:"secondary",size:"sm",disabled:l,onClick:()=>m(!0),children:"Choose emoji"}),_?s.jsx(ue,{type:"button",variant:"ghost",size:"sm",disabled:l,onClick:X,children:"Clear"}):null]})]}),s.jsx(Qs,{open:d,onOpenChange:m,children:s.jsxs(hs,{className:"max-h-[min(90vh,720px)] max-w-lg gap-0 overflow-hidden p-0 sm:max-w-xl",children:[s.jsxs(gs,{className:"space-y-1 border-b border-border px-5 py-4",children:[s.jsx(xs,{children:"Choose emoji"}),s.jsxs(bs,{children:["Server emojis save as"," ",s.jsx("code",{className:"rounded bg-muted px-1 text-xs",children:"<:name:id>"}),". Standard emojis save as Unicode characters."]})]}),s.jsxs(DS,{value:p,onValueChange:I=>g(I),className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs(xx,{className:"mx-5 mt-3 grid h-9 w-auto grid-cols-2",children:[s.jsx(Ys,{value:"server",children:"Server"}),s.jsx(Ys,{value:"unicode",children:"All emojis"})]}),s.jsxs($h,{value:"server",className:"mt-0 flex-1 px-5 pb-4 pt-3",children:[s.jsxs("div",{className:"relative mb-3",children:[s.jsx(xe,{icon:vi,size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx(_e,{placeholder:"Search by name…",value:N,onChange:I=>E(I.target.value),className:"h-9 border-border bg-secondary/30 pl-9"})]}),b?s.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:[b.guildName," · ",M.length," custom emoji",M.length===1?"":"s"]}):null,s.jsx(fc,{className:"h-[min(50vh,320px)] rounded-lg border border-border/50 bg-secondary/20",children:C?s.jsx("div",{className:"grid grid-cols-6 gap-2 p-3 sm:grid-cols-8",children:Array.from({length:24}).map((I,H)=>s.jsx(Ue,{className:"aspect-square rounded-lg"},H))}):w?s.jsxs("div",{className:"space-y-3 p-4 text-center",children:[s.jsx("p",{className:"text-sm text-destructive",children:w}),s.jsx(ue,{type:"button",variant:"outline",size:"sm",onClick:()=>void T(!0),children:"Retry"})]}):k.length===0?s.jsx("p",{className:"p-6 text-center text-sm text-muted-foreground",children:M.length===0?"No custom emojis in this server, or the bot needs the Guild Emojis intent (restart after update).":"No emojis match your search."}):s.jsx("div",{className:"grid grid-cols-6 gap-1.5 p-2 sm:grid-cols-8",children:k.map(I=>{const H=R.kind==="custom"&&R.id===I.id;return s.jsx("button",{type:"button",title:`:${I.name}:`,className:pe("flex aspect-square items-center justify-center rounded-lg border border-transparent bg-background/50 transition-colors hover:border-primary/30 hover:bg-accent",H&&"border-primary/50 bg-primary/15 ring-2 ring-primary/30"),onClick:()=>ne(I),children:s.jsx("img",{src:I.url??e5(I.id,I.animated),alt:I.name,className:"size-8 object-contain",loading:"lazy"})},I.id)})})})]}),s.jsx($h,{value:"unicode",className:"mt-0 px-5 pb-4 pt-3",children:s.jsx(pO,{onPick:L})})]})]})}),s.jsx(_e,{value:_,disabled:l,onChange:I=>c(I.target.value),placeholder:"Unicode or <:name:id>",className:"border-border bg-secondary/30 font-mono text-xs"})]})}const F0="BOT_TOKEN",vO="MODEL_API_KEY";function pd({field:t,value:n,onChange:a,readOnly:o}){const c=t.path.replace(/\./g,"-");if(t.type==="googleFont")return s.jsx(S_,{field:t,value:n,onChange:a,readOnly:o});if(t.type==="boolean")return s.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-border bg-secondary/20 px-3 py-2.5",children:[s.jsxs("div",{children:[s.jsx(Ae,{htmlFor:c,className:"font-medium",children:t.label}),t.description?s.jsx("p",{className:"text-xs text-muted-foreground",children:t.description}):null]}),s.jsx(Mt,{id:c,checked:!!n,disabled:o,onCheckedChange:a})]});if(t.type==="stringList")return s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{children:t.label}),t.description?s.jsx("p",{className:"text-xs text-muted-foreground",children:t.description}):null,s.jsx(w_,{value:Array.isArray(n)?n:[],onChange:a})]});if(t.type==="select"&&t.options)return s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:c,children:t.label}),s.jsxs(Ca,{value:String(n??""),disabled:o,onValueChange:a,children:[s.jsx(Hr,{id:c,className:"border-border bg-secondary/30",children:s.jsx(Sa,{placeholder:"Select…"})}),s.jsx(Gr,{children:t.options.map(d=>s.jsx(Et,{value:d.value,children:d.label},d.value))})]})]});if(t.type==="color"){const d=$r(String(n??"#000000"));return s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:c,children:t.label}),t.description?s.jsx("p",{className:"text-xs text-muted-foreground",children:t.description}):null,s.jsxs("div",{className:"flex gap-2",children:[s.jsx(tf,{value:d,onChange:a}),s.jsx(_e,{id:c,value:d,disabled:o,onChange:m=>a(m.target.value),onBlur:m=>a($r(m.target.value,d)),className:"border-border bg-secondary/30 font-mono uppercase",placeholder:"#000000",maxLength:7})]})]})}if(t.type==="emoji")return s.jsx(bO,{id:c,label:t.label,description:t.description,value:n,onChange:a,readOnly:o});if(t.type==="discordChannel"||t.type==="discordRole"||t.type==="discordCategory"){const d=t.type==="discordRole"?"role":t.type==="discordCategory"?"category":"channel";return s.jsx(TS,{id:c,label:t.label,description:t.description,kind:d,value:n,onChange:a,readOnly:o})}if(t.type==="secret"){const d=n===F0||n===vO||!n?"":"••••••••••••";return s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:c,children:t.label}),t.description?s.jsx("p",{className:"text-xs text-muted-foreground",children:t.description}):null,s.jsx(_e,{id:c,type:"password",value:d,disabled:o,placeholder:t.placeholder??"Unchanged if empty",onChange:m=>{const p=m.target.value;a(p||(t.placeholder??F0))},className:"border-border bg-secondary/30"})]})}const l="border-border bg-secondary/30";return t.type==="textarea"?s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:c,children:t.label}),s.jsx(Jd,{id:c,value:String(n??""),disabled:o,onChange:d=>a(d.target.value),className:`min-h-[88px] ${l}`})]}):s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:c,children:t.label}),t.description?s.jsx("p",{className:"text-xs text-muted-foreground",children:t.description}):null,s.jsx(_e,{id:c,type:t.type==="number"?"number":"text",value:n==null?"":String(n),disabled:o,onChange:d=>a(t.type==="number"?Number(d.target.value):d.target.value),placeholder:t.placeholder??(t.type==="discordId"?"Discord snowflake ID":void 0),className:l})]})}const Je=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,className:pe("rounded-xl border border-border bg-card text-card-foreground shadow-none",t),...n}));Je.displayName="Card";const dt=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,className:pe("flex flex-col space-y-1.5 p-6",t),...n}));dt.displayName="CardHeader";const ft=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,className:pe("font-semibold leading-none tracking-tight",t),...n}));ft.displayName="CardTitle";const Ot=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,className:pe("text-sm text-muted-foreground",t),...n}));Ot.displayName="CardDescription";const et=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,className:pe("p-6 pt-0",t),...n}));et.displayName="CardContent";const Sx=f.forwardRef(({className:t,...n},a)=>s.jsx("div",{ref:a,className:pe("flex items-center p-6 pt-0",t),...n}));Sx.displayName="CardFooter";function Y0(t){return t.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,n=>n.toUpperCase())}function yO(t,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=t.toLowerCase();return/prefix/.test(a)?"text":/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 Nx(t,n=""){const a=[];for(const[o,c]of Object.entries(t)){const l=n?`${n}.${o}`:o;if(Array.isArray(c)){if(c.length>0&&typeof c[0]=="object"&&c[0]!==null&&!Array.isArray(c[0]))continue;a.push({path:l,label:Y0(o),type:"stringList"});continue}if(c&&typeof c=="object"&&Object.keys(c).length>0){a.push(...Nx(c,l));continue}a.push({path:l,label:Y0(o),type:yO(o,c)})}return a}function wO(t){const n=Nx(t);return n.length===0?[{title:"Configuration",fields:[]}]:[{title:"Settings",description:"Values from this addon’s config file.",fields:n}]}function kr(t,n){const a=n.split(".");let o=t;for(const c of a){if(o==null||typeof o!="object")return;o=o[c]}return o}function Gn(t,n,a){const o=n.split("."),c=structuredClone(t);let l=c;for(let d=0;d{switch(t){case"success":return NO;case"info":return kO;case"warning":return EO;case"error":return TO;default:return null}},CO=Array(12).fill(0),SO=({visible:t,className:n})=>ve.createElement("div",{className:["sonner-loading-wrapper",n].filter(Boolean).join(" "),"data-visible":t},ve.createElement("div",{className:"sonner-spinner"},CO.map((a,o)=>ve.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${o}`})))),NO=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.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"})),EO=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ve.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"})),kO=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.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"})),TO=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.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"})),MO=ve.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"},ve.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ve.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),RO=()=>{let[t,n]=ve.useState(document.hidden);return ve.useEffect(()=>{let a=()=>{n(document.hidden)};return document.addEventListener("visibilitychange",a),()=>window.removeEventListener("visibilitychange",a)},[]),t},qh=1,AO=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;let{message:a,...o}=t,c=typeof(t==null?void 0:t.id)=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:qh++,l=this.toasts.find(m=>m.id===c),d=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(c)&&this.dismissedToasts.delete(c),l?this.toasts=this.toasts.map(m=>m.id===c?(this.publish({...m,...t,id:c,title:a}),{...m,...t,id:c,dismissible:d,title:a}):m):this.addToast({title:a,...o,dismissible:d,id:c}),c},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(n=>{this.subscribers.forEach(a=>a({id:n.id,dismiss:!0}))}),this.subscribers.forEach(n=>n({id:t,dismiss:!0})),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let a;n.loading!==void 0&&(a=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));let o=t instanceof Promise?t:t(),c=a!==void 0,l,d=o.then(async p=>{if(l=["resolve",p],ve.isValidElement(p))c=!1,this.create({id:a,type:"default",message:p});else if(DO(p)&&!p.ok){c=!1;let g=typeof n.error=="function"?await n.error(`HTTP error! status: ${p.status}`):n.error,b=typeof n.description=="function"?await n.description(`HTTP error! status: ${p.status}`):n.description;this.create({id:a,type:"error",message:g,description:b})}else if(n.success!==void 0){c=!1;let g=typeof n.success=="function"?await n.success(p):n.success,b=typeof n.description=="function"?await n.description(p):n.description;this.create({id:a,type:"success",message:g,description:b})}}).catch(async p=>{if(l=["reject",p],n.error!==void 0){c=!1;let g=typeof n.error=="function"?await n.error(p):n.error,b=typeof n.description=="function"?await n.description(p):n.description;this.create({id:a,type:"error",message:g,description:b})}}).finally(()=>{var p;c&&(this.dismiss(a),a=void 0),(p=n.finally)==null||p.call(n)}),m=()=>new Promise((p,g)=>d.then(()=>l[0]==="reject"?g(l[1]):p(l[1])).catch(g));return typeof a!="string"&&typeof a!="number"?{unwrap:m}:Object.assign(a,{unwrap:m})},this.custom=(t,n)=>{let a=(n==null?void 0:n.id)||qh++;return this.create({jsx:t(a),id:a,...n}),a},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Mn=new AO,_O=(t,n)=>{let a=(n==null?void 0:n.id)||qh++;return Mn.addToast({title:t,...n,id:a}),a},DO=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",OO=_O,LO=()=>Mn.toasts,zO=()=>Mn.getActiveToasts(),Dt=Object.assign(OO,{success:Mn.success,info:Mn.info,warning:Mn.warning,error:Mn.error,custom:Mn.custom,message:Mn.message,promise:Mn.promise,dismiss:Mn.dismiss,loading:Mn.loading},{getHistory:LO,getToasts:zO});function PO(t,{insertAt:n}={}){if(typeof document>"u")return;let a=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",n==="top"&&a.firstChild?a.insertBefore(o,a.firstChild):a.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}PO(`:where(html[dir="ltr"]),:where([data-sonner-toaster][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%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][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%)}:where([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:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([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);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([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 #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([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)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([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;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([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);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-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([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}:where([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}:where([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, 0px)) translate(var(--swipe-amount-x, 0px));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{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{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{0%{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-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--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-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-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-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, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--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-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-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],[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],[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],[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],[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:nth-child(1){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)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{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 Hu(t){return t.label!==void 0}var IO=3,UO="32px",BO="16px",q0=4e3,$O=356,HO=14,GO=20,VO=200;function jr(...t){return t.filter(Boolean).join(" ")}function FO(t){let[n,a]=t.split("-"),o=[];return n&&o.push(n),a&&o.push(a),o}var YO=t=>{var n,a,o,c,l,d,m,p,g,b,v;let{invert:w,toast:y,unstyled:C,interacting:S,setHeights:N,visibleToasts:E,heights:T,index:M,toasts:k,expanded:_,removeToast:R,defaultRichColors:L,closeButton:ne,style:X,cancelButtonStyle:I,actionButtonStyle:H,className:q="",descriptionClassName:ce="",duration:de,position:se,gap:P,loadingIcon:W,expandByDefault:oe,classNames:ae,icons:G,closeButtonAriaLabel:O="Close toast",pauseWhenPageIsHidden:D}=t,[B,V]=ve.useState(null),[Z,be]=ve.useState(null),[K,ge]=ve.useState(!1),[me,$]=ve.useState(!1),[ie,ye]=ve.useState(!1),[Se,Be]=ve.useState(!1),[Ke,We]=ve.useState(!1),[qt,vn]=ve.useState(0),[Xn,br]=ve.useState(0),yn=ve.useRef(y.duration||de||q0),wn=ve.useRef(null),Zn=ve.useRef(null),Kt=M===0,po=M+1<=E,Pt=y.type,Qn=y.dismissible!==!1,Da=y.className||"",Es=y.descriptionClassName||"",qr=ve.useMemo(()=>T.findIndex(De=>De.toastId===y.id)||0,[T,y.id]),ho=ve.useMemo(()=>{var De;return(De=y.closeButton)!=null?De:ne},[y.closeButton,ne]),Kr=ve.useMemo(()=>y.duration||de||q0,[y.duration,de]),Dn=ve.useRef(0),yt=ve.useRef(0),On=ve.useRef(0),Rt=ve.useRef(null),[Ai,_i]=se.split("-"),go=ve.useMemo(()=>T.reduce((De,rt,lt)=>lt>=qr?De:De+rt.height,0),[T,qr]),Wr=RO(),Oa=y.invert||w,Ar=Pt==="loading";yt.current=ve.useMemo(()=>qr*P+go,[qr,go]),ve.useEffect(()=>{yn.current=Kr},[Kr]),ve.useEffect(()=>{ge(!0)},[]),ve.useEffect(()=>{let De=Zn.current;if(De){let rt=De.getBoundingClientRect().height;return br(rt),N(lt=>[{toastId:y.id,height:rt,position:y.position},...lt]),()=>N(lt=>lt.filter(rn=>rn.toastId!==y.id))}},[N,y.id]),ve.useLayoutEffect(()=>{if(!K)return;let De=Zn.current,rt=De.style.height;De.style.height="auto";let lt=De.getBoundingClientRect().height;De.style.height=rt,br(lt),N(rn=>rn.find(It=>It.toastId===y.id)?rn.map(It=>It.toastId===y.id?{...It,height:lt}:It):[{toastId:y.id,height:lt,position:y.position},...rn])},[K,y.title,y.description,N,y.id]);let Wt=ve.useCallback(()=>{$(!0),vn(yt.current),N(De=>De.filter(rt=>rt.toastId!==y.id)),setTimeout(()=>{R(y)},VO)},[y,R,N,yt]);ve.useEffect(()=>{if(y.promise&&Pt==="loading"||y.duration===1/0||y.type==="loading")return;let De;return _||S||D&&Wr?(()=>{if(On.current{var rt;(rt=y.onAutoClose)==null||rt.call(y,y),Wt()},yn.current)),()=>clearTimeout(De)},[_,S,y,Pt,D,Wr,Wt]),ve.useEffect(()=>{y.delete&&Wt()},[Wt,y.delete]);function La(){var De,rt,lt;return G!=null&&G.loading?ve.createElement("div",{className:jr(ae==null?void 0:ae.loader,(De=y==null?void 0:y.classNames)==null?void 0:De.loader,"sonner-loader"),"data-visible":Pt==="loading"},G.loading):W?ve.createElement("div",{className:jr(ae==null?void 0:ae.loader,(rt=y==null?void 0:y.classNames)==null?void 0:rt.loader,"sonner-loader"),"data-visible":Pt==="loading"},W):ve.createElement(SO,{className:jr(ae==null?void 0:ae.loader,(lt=y==null?void 0:y.classNames)==null?void 0:lt.loader),visible:Pt==="loading"})}return ve.createElement("li",{tabIndex:0,ref:Zn,className:jr(q,Da,ae==null?void 0:ae.toast,(n=y==null?void 0:y.classNames)==null?void 0:n.toast,ae==null?void 0:ae.default,ae==null?void 0:ae[Pt],(a=y==null?void 0:y.classNames)==null?void 0:a[Pt]),"data-sonner-toast":"","data-rich-colors":(o=y.richColors)!=null?o:L,"data-styled":!(y.jsx||y.unstyled||C),"data-mounted":K,"data-promise":!!y.promise,"data-swiped":Ke,"data-removed":me,"data-visible":po,"data-y-position":Ai,"data-x-position":_i,"data-index":M,"data-front":Kt,"data-swiping":ie,"data-dismissible":Qn,"data-type":Pt,"data-invert":Oa,"data-swipe-out":Se,"data-swipe-direction":Z,"data-expanded":!!(_||oe&&K),style:{"--index":M,"--toasts-before":M,"--z-index":k.length-M,"--offset":`${me?qt:yt.current}px`,"--initial-height":oe?"auto":`${Xn}px`,...X,...y.style},onDragEnd:()=>{ye(!1),V(null),Rt.current=null},onPointerDown:De=>{Ar||!Qn||(wn.current=new Date,vn(yt.current),De.target.setPointerCapture(De.pointerId),De.target.tagName!=="BUTTON"&&(ye(!0),Rt.current={x:De.clientX,y:De.clientY}))},onPointerUp:()=>{var De,rt,lt,rn;if(Se||!Qn)return;Rt.current=null;let It=Number(((De=Zn.current)==null?void 0:De.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Jn=Number(((rt=Zn.current)==null?void 0:rt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),er=new Date().getTime()-((lt=wn.current)==null?void 0:lt.getTime()),bt=B==="x"?It:Jn,Ln=Math.abs(bt)/er;if(Math.abs(bt)>=GO||Ln>.11){vn(yt.current),(rn=y.onDismiss)==null||rn.call(y,y),be(B==="x"?It>0?"right":"left":Jn>0?"down":"up"),Wt(),Be(!0),We(!1);return}ye(!1),V(null)},onPointerMove:De=>{var rt,lt,rn,It;if(!Rt.current||!Qn||((rt=window.getSelection())==null?void 0:rt.toString().length)>0)return;let Jn=De.clientY-Rt.current.y,er=De.clientX-Rt.current.x,bt=(lt=t.swipeDirections)!=null?lt:FO(se);!B&&(Math.abs(er)>1||Math.abs(Jn)>1)&&V(Math.abs(er)>Math.abs(Jn)?"x":"y");let Ln={x:0,y:0};B==="y"?(bt.includes("top")||bt.includes("bottom"))&&(bt.includes("top")&&Jn<0||bt.includes("bottom")&&Jn>0)&&(Ln.y=Jn):B==="x"&&(bt.includes("left")||bt.includes("right"))&&(bt.includes("left")&&er<0||bt.includes("right")&&er>0)&&(Ln.x=er),(Math.abs(Ln.x)>0||Math.abs(Ln.y)>0)&&We(!0),(rn=Zn.current)==null||rn.style.setProperty("--swipe-amount-x",`${Ln.x}px`),(It=Zn.current)==null||It.style.setProperty("--swipe-amount-y",`${Ln.y}px`)}},ho&&!y.jsx?ve.createElement("button",{"aria-label":O,"data-disabled":Ar,"data-close-button":!0,onClick:Ar||!Qn?()=>{}:()=>{var De;Wt(),(De=y.onDismiss)==null||De.call(y,y)},className:jr(ae==null?void 0:ae.closeButton,(c=y==null?void 0:y.classNames)==null?void 0:c.closeButton)},(l=G==null?void 0:G.close)!=null?l:MO):null,y.jsx||f.isValidElement(y.title)?y.jsx?y.jsx:typeof y.title=="function"?y.title():y.title:ve.createElement(ve.Fragment,null,Pt||y.icon||y.promise?ve.createElement("div",{"data-icon":"",className:jr(ae==null?void 0:ae.icon,(d=y==null?void 0:y.classNames)==null?void 0:d.icon)},y.promise||y.type==="loading"&&!y.icon?y.icon||La():null,y.type!=="loading"?y.icon||(G==null?void 0:G[Pt])||jO(Pt):null):null,ve.createElement("div",{"data-content":"",className:jr(ae==null?void 0:ae.content,(m=y==null?void 0:y.classNames)==null?void 0:m.content)},ve.createElement("div",{"data-title":"",className:jr(ae==null?void 0:ae.title,(p=y==null?void 0:y.classNames)==null?void 0:p.title)},typeof y.title=="function"?y.title():y.title),y.description?ve.createElement("div",{"data-description":"",className:jr(ce,Es,ae==null?void 0:ae.description,(g=y==null?void 0:y.classNames)==null?void 0:g.description)},typeof y.description=="function"?y.description():y.description):null),f.isValidElement(y.cancel)?y.cancel:y.cancel&&Hu(y.cancel)?ve.createElement("button",{"data-button":!0,"data-cancel":!0,style:y.cancelButtonStyle||I,onClick:De=>{var rt,lt;Hu(y.cancel)&&Qn&&((lt=(rt=y.cancel).onClick)==null||lt.call(rt,De),Wt())},className:jr(ae==null?void 0:ae.cancelButton,(b=y==null?void 0:y.classNames)==null?void 0:b.cancelButton)},y.cancel.label):null,f.isValidElement(y.action)?y.action:y.action&&Hu(y.action)?ve.createElement("button",{"data-button":!0,"data-action":!0,style:y.actionButtonStyle||H,onClick:De=>{var rt,lt;Hu(y.action)&&((lt=(rt=y.action).onClick)==null||lt.call(rt,De),!De.defaultPrevented&&Wt())},className:jr(ae==null?void 0:ae.actionButton,(v=y==null?void 0:y.classNames)==null?void 0:v.actionButton)},y.action.label):null))};function K0(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function qO(t,n){let a={};return[t,n].forEach((o,c)=>{let l=c===1,d=l?"--mobile-offset":"--offset",m=l?BO:UO;function p(g){["top","right","bottom","left"].forEach(b=>{a[`${d}-${b}`]=typeof g=="number"?`${g}px`:g})}typeof o=="number"||typeof o=="string"?p(o):typeof o=="object"?["top","right","bottom","left"].forEach(g=>{o[g]===void 0?a[`${d}-${g}`]=m:a[`${d}-${g}`]=typeof o[g]=="number"?`${o[g]}px`:o[g]}):p(m)}),a}var KO=f.forwardRef(function(t,n){let{invert:a,position:o="bottom-right",hotkey:c=["altKey","KeyT"],expand:l,closeButton:d,className:m,offset:p,mobileOffset:g,theme:b="light",richColors:v,duration:w,style:y,visibleToasts:C=IO,toastOptions:S,dir:N=K0(),gap:E=HO,loadingIcon:T,icons:M,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:_}=t,[R,L]=ve.useState([]),ne=ve.useMemo(()=>Array.from(new Set([o].concat(R.filter(D=>D.position).map(D=>D.position)))),[R,o]),[X,I]=ve.useState([]),[H,q]=ve.useState(!1),[ce,de]=ve.useState(!1),[se,P]=ve.useState(b!=="system"?b:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),W=ve.useRef(null),oe=c.join("+").replace(/Key/g,"").replace(/Digit/g,""),ae=ve.useRef(null),G=ve.useRef(!1),O=ve.useCallback(D=>{L(B=>{var V;return(V=B.find(Z=>Z.id===D.id))!=null&&V.delete||Mn.dismiss(D.id),B.filter(({id:Z})=>Z!==D.id)})},[]);return ve.useEffect(()=>Mn.subscribe(D=>{if(D.dismiss){L(B=>B.map(V=>V.id===D.id?{...V,delete:!0}:V));return}setTimeout(()=>{m8.flushSync(()=>{L(B=>{let V=B.findIndex(Z=>Z.id===D.id);return V!==-1?[...B.slice(0,V),{...B[V],...D},...B.slice(V+1)]:[D,...B]})})})}),[]),ve.useEffect(()=>{if(b!=="system"){P(b);return}if(b==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?P("dark"):P("light")),typeof window>"u")return;let D=window.matchMedia("(prefers-color-scheme: dark)");try{D.addEventListener("change",({matches:B})=>{P(B?"dark":"light")})}catch{D.addListener(({matches:V})=>{try{P(V?"dark":"light")}catch(Z){console.error(Z)}})}},[b]),ve.useEffect(()=>{R.length<=1&&q(!1)},[R]),ve.useEffect(()=>{let D=B=>{var V,Z;c.every(be=>B[be]||B.code===be)&&(q(!0),(V=W.current)==null||V.focus()),B.code==="Escape"&&(document.activeElement===W.current||(Z=W.current)!=null&&Z.contains(document.activeElement))&&q(!1)};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[c]),ve.useEffect(()=>{if(W.current)return()=>{ae.current&&(ae.current.focus({preventScroll:!0}),ae.current=null,G.current=!1)}},[W.current]),ve.createElement("section",{ref:n,"aria-label":`${k} ${oe}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},ne.map((D,B)=>{var V;let[Z,be]=D.split("-");return R.length?ve.createElement("ol",{key:D,dir:N==="auto"?K0():N,tabIndex:-1,ref:W,className:m,"data-sonner-toaster":!0,"data-theme":se,"data-y-position":Z,"data-lifted":H&&R.length>1&&!l,"data-x-position":be,style:{"--front-toast-height":`${((V=X[0])==null?void 0:V.height)||0}px`,"--width":`${$O}px`,"--gap":`${E}px`,...y,...qO(p,g)},onBlur:K=>{G.current&&!K.currentTarget.contains(K.relatedTarget)&&(G.current=!1,ae.current&&(ae.current.focus({preventScroll:!0}),ae.current=null))},onFocus:K=>{K.target instanceof HTMLElement&&K.target.dataset.dismissible==="false"||G.current||(G.current=!0,ae.current=K.relatedTarget)},onMouseEnter:()=>q(!0),onMouseMove:()=>q(!0),onMouseLeave:()=>{ce||q(!1)},onDragEnd:()=>q(!1),onPointerDown:K=>{K.target instanceof HTMLElement&&K.target.dataset.dismissible==="false"||de(!0)},onPointerUp:()=>de(!1)},R.filter(K=>!K.position&&B===0||K.position===D).map((K,ge)=>{var me,$;return ve.createElement(YO,{key:K.id,icons:M,index:ge,toast:K,defaultRichColors:v,duration:(me=S==null?void 0:S.duration)!=null?me:w,className:S==null?void 0:S.className,descriptionClassName:S==null?void 0:S.descriptionClassName,invert:a,visibleToasts:C,closeButton:($=S==null?void 0:S.closeButton)!=null?$:d,interacting:ce,position:D,style:S==null?void 0:S.style,unstyled:S==null?void 0:S.unstyled,classNames:S==null?void 0:S.classNames,cancelButtonStyle:S==null?void 0:S.cancelButtonStyle,actionButtonStyle:S==null?void 0:S.actionButtonStyle,removeToast:O,toasts:R.filter(ie=>ie.position==K.position),heights:X.filter(ie=>ie.position==K.position),setHeights:I,expandByDefault:l,gap:E,loadingIcon:T,expanded:H,pauseWhenPageIsHidden:_,swipeDirections:t.swipeDirections})})):null}))});async function nd(t){const n=Dt.loading("Saving changes…");try{const a=await t();if(Dt.success("Changes saved",{id:n}),a.botRestart){const o=Dt.loading("Restarting bot…");a.botRestart.success?Dt.success("Bot started",{id:o}):Dt.error(a.botRestart.error??"Could not start bot",{id:o})}return a}catch(a){throw Dt.error(a instanceof Error?a.message:"Save failed",{id:n}),a}}function WO({filename:t}){const{canEditConfig:n}=Yt(),a=!n("supportbot"),[o,c]=f.useState(null),[l,d]=f.useState(null),[m,p]=f.useState(!0),[g,b]=f.useState(!1),[v,w]=f.useState(""),[y,C]=f.useState(""),S=f.useCallback(async()=>{p(!0),w(""),C("");try{const _=(await Ne.getAddonConfigJson(t)).data??{};c(_),d(structuredClone(_))}catch(k){w(k instanceof Error?k.message:"Failed to load config")}finally{p(!1)}},[t]);f.useEffect(()=>{S()},[S]);const N=o?wO(o):null;function E(k,_){c(R=>R&&Gn(R,k,_))}async function T(){if(!(a||!o)){b(!0),w(""),C("");try{const k=await nd(()=>Ne.saveAddonConfig(t,o));C(k.message||"Saved."),await S()}catch(k){w(k instanceof Error?k.message:"Save failed")}finally{b(!1)}}}if(m)return s.jsxs("div",{className:"space-y-4",children:[s.jsx(Ue,{className:"h-24 w-full rounded-xl"}),s.jsx(Ue,{className:"h-48 w-full rounded-xl"})]});if(!o||!N)return s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:v||"Failed to load"})});const M=l&&JSON.stringify(o)!==JSON.stringify(l);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[M?s.jsx("span",{className:"text-xs text-amber-500",children:"Unsaved changes"}):null,s.jsx(ue,{variant:"outline",size:"sm",onClick:S,disabled:m||g,children:"Reload"}),a?s.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}):s.jsxs(ue,{size:"sm",onClick:T,disabled:g||!M,children:[s.jsx(xe,{icon:Sd,size:16,className:"mr-1.5"}),g?"Saving…":"Save"]})]}),v?s.jsxs(Ye,{variant:"destructive",children:[s.jsx(xe,{icon:ig,size:18}),s.jsx(qe,{children:v})]}):null,y?s.jsx(Ye,{className:"border-primary/30 bg-primary/10 text-primary",children:s.jsx(qe,{children:y})}):null,N.map(k=>s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{className:"pb-3",children:[s.jsx(ft,{className:"text-base",children:k.title}),k.description?s.jsx(Ot,{children:k.description}):null]}),s.jsx(et,{className:"grid gap-4 sm:grid-cols-2",children:k.fields.map(_=>s.jsx("div",{className:_.type==="textarea"||_.type==="stringList"?"sm:col-span-2":"",children:s.jsx(pd,{field:_,value:kr(o,_.path),readOnly:a,onChange:R=>E(_.path,R)})},_.path))})]},k.title))]})}function XO(t){return t.startsWith("Ticket.DepartmentSystem.")?"Ticket Departments":t.startsWith("Ticket.PrioritySystem.")?"Ticket Priorities":t.startsWith("Ticket.")?"Tickets":(t.split(".")[0]??"Other").replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,a=>a.toUpperCase())}function ZO(t,n){const a=new Set(t.flatMap(d=>d.fields.map(m=>m.path))),o=Nx(n).filter(d=>!a.has(d.path));if(o.length===0)return t;const c=t.map(d=>({...d,fields:[...d.fields]})),l=new Map;for(const d of o){const m=XO(d.path),p=l.get(m)??[];p.push(d),l.set(m,p)}for(const[d,m]of l.entries()){const p=c.find(g=>g.title.toLowerCase()===d.toLowerCase());p?p.fields.push(...m):c.push({title:d,description:"These options exist in your config file but are not in the main editor sections.",fields:m.sort((g,b)=>g.path.localeCompare(b.path))})}return c}function W0(t,n){(n==null||n>t.length)&&(n=t.length);for(var a=0,o=Array(n);a=t.length?t.apply(this,c):function(){for(var d=arguments.length,m=new Array(d),p=0;p1&&arguments[1]!==void 0?arguments[1]:{};Gu.initial(t),Gu.handler(n);var a={current:t},o=Al(wL)(a,n),c=Al(yL)(a),l=Al(Gu.changes)(t),d=Al(vL)(a);function m(){var g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(b){return b};return Gu.selector(g),g(a.current)}function p(g){cL(o,c,l,d)(g)}return[m,p]}function vL(t,n){return Ql(n)?n(t.current):n}function yL(t,n){return t.current=J0(J0({},t.current),n),n}function wL(t,n,a){return Ql(n)?n(t.current):Object.keys(a).forEach(function(o){var c;return(c=n[o])===null||c===void 0?void 0:c.call(n,t.current[o])}),a}var jL={create:bL},CL={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function SL(t){return function n(){for(var a=this,o=arguments.length,c=new Array(o),l=0;l=t.length?t.apply(this,c):function(){for(var d=arguments.length,m=new Array(d),p=0;p{o.current=!1}:t,n)}var Yn=XL;function zl(){}function li(t,n,a,o){return ZL(t,o)||QL(t,n,a,o)}function ZL(t,n){return t.editor.getModel(l5(t,n))}function QL(t,n,a,o){return t.editor.createModel(n,a,o?l5(t,o):void 0)}function l5(t,n){return t.Uri.parse(n)}function JL({original:t,modified:n,language:a,originalLanguage:o,modifiedLanguage:c,originalModelPath:l,modifiedModelPath:d,keepCurrentOriginalModel:m=!1,keepCurrentModifiedModel:p=!1,theme:g="light",loading:v="Loading...",options:b={},height:w="100%",width:y="100%",className:C,wrapperProps:S={},beforeMount:E=zl,onMount:k=zl}){let[N,T]=f.useState(!1),[M,_]=f.useState(!0),R=f.useRef(null),L=f.useRef(null),te=f.useRef(null),K=f.useRef(k),I=f.useRef(E),G=f.useRef(!1);i5(()=>{let se=s5.init();return se.then(P=>(L.current=P)&&_(!1)).catch(P=>(P==null?void 0:P.type)!=="cancelation"&&console.error("Monaco initialization: error:",P)),()=>R.current?fe():se.cancel()}),Yn(()=>{if(R.current&&L.current){let se=R.current.getOriginalEditor(),P=li(L.current,t||"",o||a||"text",l||"");P!==se.getModel()&&se.setModel(P)}},[l],N),Yn(()=>{if(R.current&&L.current){let se=R.current.getModifiedEditor(),P=li(L.current,n||"",c||a||"text",d||"");P!==se.getModel()&&se.setModel(P)}},[d],N),Yn(()=>{let se=R.current.getModifiedEditor();se.getOption(L.current.editor.EditorOption.readOnly)?se.setValue(n||""):n!==se.getValue()&&(se.executeEdits("",[{range:se.getModel().getFullModelRange(),text:n||"",forceMoveMarkers:!0}]),se.pushUndoStop())},[n],N),Yn(()=>{var se,P;(P=(se=R.current)==null?void 0:se.getModel())==null||P.original.setValue(t||"")},[t],N),Yn(()=>{let{original:se,modified:P}=R.current.getModel();L.current.editor.setModelLanguage(se,o||a||"text"),L.current.editor.setModelLanguage(P,c||a||"text")},[a,o,c],N),Yn(()=>{var se;(se=L.current)==null||se.editor.setTheme(g)},[g],N),Yn(()=>{var se;(se=R.current)==null||se.updateOptions(b)},[b],N);let Y=f.useCallback(()=>{var Z;if(!L.current)return;I.current(L.current);let se=li(L.current,t||"",o||a||"text",l||""),P=li(L.current,n||"",c||a||"text",d||"");(Z=R.current)==null||Z.setModel({original:se,modified:P})},[a,n,c,t,o,l,d]),ce=f.useCallback(()=>{var se;!G.current&&te.current&&(R.current=L.current.editor.createDiffEditor(te.current,{automaticLayout:!0,...b}),Y(),(se=L.current)==null||se.editor.setTheme(g),T(!0),G.current=!0)},[b,g,Y]);f.useEffect(()=>{N&&K.current(R.current,L.current)},[N]),f.useEffect(()=>{!M&&!N&&ce()},[M,N,ce]);function fe(){var P,Z,ae,re;let se=(P=R.current)==null?void 0:P.getModel();m||((Z=se==null?void 0:se.original)==null||Z.dispose()),p||((ae=se==null?void 0:se.modified)==null||ae.dispose()),(re=R.current)==null||re.dispose()}return be.createElement(o5,{width:y,height:w,isEditorReady:N,loading:v,_ref:te,className:C,wrapperProps:S})}var ez=JL;f.memo(ez);function tz(t){let n=f.useRef();return f.useEffect(()=>{n.current=t},[t]),n.current}var nz=tz,Vu=new Map;function rz({defaultValue:t,defaultLanguage:n,defaultPath:a,value:o,language:c,path:l,theme:d="light",line:m,loading:p="Loading...",options:g={},overrideServices:v={},saveViewState:b=!0,keepCurrentModel:w=!1,width:y="100%",height:C="100%",className:S,wrapperProps:E={},beforeMount:k=zl,onMount:N=zl,onChange:T,onValidate:M=zl}){let[_,R]=f.useState(!1),[L,te]=f.useState(!0),K=f.useRef(null),I=f.useRef(null),G=f.useRef(null),Y=f.useRef(N),ce=f.useRef(k),fe=f.useRef(),se=f.useRef(o),P=nz(l),Z=f.useRef(!1),ae=f.useRef(!1);i5(()=>{let O=s5.init();return O.then(D=>(K.current=D)&&te(!1)).catch(D=>(D==null?void 0:D.type)!=="cancelation"&&console.error("Monaco initialization: error:",D)),()=>I.current?V():O.cancel()}),Yn(()=>{var D,$,H,X;let O=li(K.current,t||o||"",n||c||"",l||a||"");O!==((D=I.current)==null?void 0:D.getModel())&&(b&&Vu.set(P,($=I.current)==null?void 0:$.saveViewState()),(H=I.current)==null||H.setModel(O),b&&((X=I.current)==null||X.restoreViewState(Vu.get(l))))},[l],_),Yn(()=>{var O;(O=I.current)==null||O.updateOptions(g)},[g],_),Yn(()=>{!I.current||o===void 0||(I.current.getOption(K.current.editor.EditorOption.readOnly)?I.current.setValue(o):o!==I.current.getValue()&&(ae.current=!0,I.current.executeEdits("",[{range:I.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),I.current.pushUndoStop(),ae.current=!1))},[o],_),Yn(()=>{var D,$;let O=(D=I.current)==null?void 0:D.getModel();O&&c&&(($=K.current)==null||$.editor.setModelLanguage(O,c))},[c],_),Yn(()=>{var O;m!==void 0&&((O=I.current)==null||O.revealLine(m))},[m],_),Yn(()=>{var O;(O=K.current)==null||O.editor.setTheme(d)},[d],_);let re=f.useCallback(()=>{var O;if(!(!G.current||!K.current)&&!Z.current){ce.current(K.current);let D=l||a,$=li(K.current,o||t||"",n||c||"",D||"");I.current=(O=K.current)==null?void 0:O.editor.create(G.current,{model:$,automaticLayout:!0,...g},v),b&&I.current.restoreViewState(Vu.get(D)),K.current.editor.setTheme(d),m!==void 0&&I.current.revealLine(m),R(!0),Z.current=!0}},[t,n,a,o,c,l,g,v,b,d,m]);f.useEffect(()=>{_&&Y.current(I.current,K.current)},[_]),f.useEffect(()=>{!L&&!_&&re()},[L,_,re]),se.current=o,f.useEffect(()=>{var O,D;_&&T&&((O=fe.current)==null||O.dispose(),fe.current=(D=I.current)==null?void 0:D.onDidChangeModelContent($=>{ae.current||T(I.current.getValue(),$)}))},[_,T]),f.useEffect(()=>{if(_){let O=K.current.editor.onDidChangeMarkers(D=>{var H;let $=(H=I.current.getModel())==null?void 0:H.uri;if($&&D.find(X=>X.path===$.path)){let X=K.current.editor.getModelMarkers({resource:$});M==null||M(X)}});return()=>{O==null||O.dispose()}}return()=>{}},[_,M]);function V(){var O,D;(O=fe.current)==null||O.dispose(),w?b&&Vu.set(l,I.current.saveViewState()):(D=I.current.getModel())==null||D.dispose(),I.current.dispose()}return be.createElement(o5,{width:y,height:C,isEditorReady:_,loading:p,_ref:G,className:S,wrapperProps:E})}var az=rz,sz=f.memo(az),oz=sz;function iz(t){return t!==null&&typeof t=="object"&&"Command"in t}function lz(t){return Object.entries(t).filter(([,n])=>iz(n)).map(([n,a])=>({key:n,...a}))}function cz({data:t,onChange:n}){const a=lz(t);function o(c,l){const d=t[c];n({...t,[c]:{...d,...l}})}return a.length===0?s.jsx("p",{className:"text-sm text-muted-foreground",children:"No commands found in this config."}):s.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:a.map(c=>s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{className:"flex flex-row items-center gap-2 space-y-0 pb-2",children:[s.jsx("div",{className:"flex size-9 items-center justify-center rounded-lg bg-primary/15 text-primary",children:s.jsx(ve,{icon:ds,size:18})}),s.jsx(dt,{className:"text-base",children:c.key})]}),s.jsxs(Qe,{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(_e,{htmlFor:`${c.key}-enabled`,children:"Enabled"}),s.jsx(kt,{id:`${c.key}-enabled`,checked:c.Enabled!==!1,onCheckedChange:l=>o(c.key,{Enabled:l})})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(_e,{children:"Slash command"}),s.jsx(De,{value:c.Command??"",onChange:l=>o(c.key,{Command:l.target.value}),className:"border-border bg-secondary/30 font-mono"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(_e,{children:"Description"}),s.jsx(De,{value:c.Description??"",onChange:l=>o(c.key,{Description:l.target.value}),className:"border-border bg-secondary/30"})]})]})]},c.key))})}function uz(t,n){let a=structuredClone(n);if(t==="supportbot"){const o=Fr(a,"General.Token");o&&o!=="BOT_TOKEN"&&(a=Gn(a,"General.Token","BOT_TOKEN"))}if(t==="supportbot-ai"){const o=Fr(a,"General.Model_API_Key");o&&o!=="MODEL_API_KEY"&&(a=Gn(a,"General.Model_API_Key","MODEL_API_KEY"))}return a}function dz(t,n,a,o){const c={};for(const l of n)for(const d of l.fields){const m=Fr(a,d.path),p=Fr(o,d.path);d.type==="secret"&&(m==="BOT_TOKEN"||m==="MODEL_API_KEY"||m===""||m===void 0)||JSON.stringify(m)!==JSON.stringify(p)&&(c[`${t}:${d.path}`]=m)}return c}function fz(t,n){const a=new Map,o=[];for(const l of t){const d=l.path.split(".");if(d.length>=5&&d[1]==="DepartmentSystem"&&d[2]==="Departments"){const m=d[3],p=a.get(m)??[];p.push(l),a.set(m,p)}else if(d.length>=3){const m=d[1],p=a.get(m)??[];p.push(l),a.set(m,p)}else o.push(l)}if(a.size===0)return{standalone:t,groups:[]};const c=[...a.entries()].map(([l,d])=>{const m=["enabled","name","description","emoji","category","role","channelprefix","defaultpriority","questions"];d.sort((v,b)=>{var E,k;const w=((E=v.path.split(".").pop())==null?void 0:E.toLowerCase())||"",y=((k=b.path.split(".").pop())==null?void 0:k.toLowerCase())||"",C=m.indexOf(w),S=m.indexOf(y);return C!==-1&&S!==-1?C-S:C!==-1?-1:S!==-1?1:w.localeCompare(y)});const p=d.find(v=>v.path.toLowerCase().endsWith(".name")||v.path.toLowerCase().endsWith(".title"));let g="";if(p&&n){const v=Fr(n,p.path);typeof v=="string"&&v.trim()&&(g=v.trim())}return g||(g=l.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,v=>v.toUpperCase())),{key:l,name:g,fields:d}});return{standalone:o,groups:c}}function mz({configFile:t}){const{permissions:n,canEditConfig:a}=qt(),o=Mn(n,"configs.raw_yaml"),c=!a(t),[l,d]=f.useState(null),[m,p]=f.useState(null),[g,v]=f.useState(!0),[b,w]=f.useState(!1),[y,C]=f.useState(""),[S,E]=f.useState(""),[k,N]=f.useState("visual");f.useEffect(()=>{!o&&k==="yaml"&&N("visual")},[o,k]);const[T,M]=f.useState(""),[_,R]=f.useState(""),[L]=wd(),[te,K]=f.useState(()=>L.get("tab")||null),[I,G]=f.useState(!1),[Y,ce]=f.useState(""),[fe,se]=f.useState(""),P=()=>{const q=Y.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"");if(!q||!l)return;const ge=fe.trim()||q,me=`Ticket.DepartmentSystem.Departments.${q}`,B={...l};Gn(B,`${me}.Name`,ge),Gn(B,`${me}.Description`,`Open a ${ge} ticket`),Gn(B,`${me}.Emoji`,"🎫"),Gn(B,`${me}.Category`,"CATEGORY_ID"),Gn(B,`${me}.Role`,"ROLE_ID"),Gn(B,`${me}.ChannelPrefix`,`${q}-`),Gn(B,`${me}.DefaultPriority`,"normal"),Gn(B,`${me}.Questions`,["What do you need assistance with?"]),d(B),G(!1),ce(""),se("")},Z=q=>{if(!l)return;const ge=`Ticket.DepartmentSystem.Departments.${q}`,me=JSON.parse(JSON.stringify(l));if(Object.keys(me).forEach(B=>{(B.startsWith(ge)||B===ge)&&delete me[B]}),me.Ticket&&typeof me.Ticket=="object"){const B=me.Ticket.DepartmentSystem;B&&typeof B=="object"&&B.Departments&&typeof B.Departments=="object"&&delete B.Departments[q]}d(me)},ae=FM(t),re=f.useMemo(()=>!ae||ae==="commands"||!l?ae:ZO(ae,l),[ae,l]);f.useEffect(()=>{var q;if(re&&re!=="commands"){const ge=L.get("tab");if(ge&&re.find(me=>me.title.toLowerCase()===ge.toLowerCase())){const me=re.find(B=>B.title.toLowerCase()===ge.toLowerCase());me&&me.title!==te&&K(me.title)}else(!te||!re.find(me=>me.title===te))&&K(((q=re[0])==null?void 0:q.title)||null)}},[re,te,L]);const V=f.useCallback(async()=>{v(!0),C(""),E("");try{const ge=(await Ne.getConfigJson(t)).data??{},me=uz(t,ge);d(me),p(me);const ie=(await Ne.getConfigRaw(t)).data??"",we=z8(ie,t);M(we),R(we)}catch(q){C(q instanceof Error?q.message:"Failed to load config")}finally{v(!1)}},[t]);f.useEffect(()=>{V()},[V]);function O(q,ge){d(me=>me&&Gn(me,q,ge))}async function D(){if(!(c||T===_)){w(!0),C(""),E("");try{const q=await nd(()=>Ne.saveConfigRaw(t,T));E(q.message||"Config saved."),await V()}catch(q){C(q instanceof Error?q.message:"Save failed")}finally{w(!1)}}}async function $(){if(!(c||!l||!m)){if(k==="yaml"){await D();return}w(!0),C(""),E("");try{if(ae==="commands"){const q={};for(const me of Object.keys(l))JSON.stringify(l[me])!==JSON.stringify(m[me])&&(q[`${t}:${me}`]=l[me]);if(Object.keys(q).length===0){E("No changes to save.");return}const ge=await nd(()=>Ne.updateConfigFields(q));E(ge.message||"")}else if(re&&re!=="commands"){const q=dz(t,re,l,m);if(Object.keys(q).length===0){E("No changes to save.");return}const ge=await nd(()=>Ne.updateConfigFields(q));E(ge.message||"")}await V()}catch(q){C(q instanceof Error?q.message:"Save failed")}finally{w(!1)}}}if(ae===null)return s.jsx(Ye,{children:s.jsx(qe,{children:"No visual editor available for this file."})});if(g)return s.jsxs("div",{className:"space-y-4",children:[s.jsx(Be,{className:"h-24 w-full rounded-xl"}),s.jsx(Be,{className:"h-48 w-full rounded-xl"})]});if(!l)return s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:y||"Failed to load"})});const H=m&&JSON.stringify(l)!==JSON.stringify(m),xe=k==="yaml"?T!==_:H;return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o?s.jsxs("div",{className:"flex rounded-lg border border-border p-0.5",children:[s.jsx(ue,{type:"button",variant:k==="visual"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>N("visual"),children:"Visual"}),s.jsx(ue,{type:"button",variant:k==="yaml"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>N("yaml"),children:"YAML"})]}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[xe?s.jsx("span",{className:"text-xs text-amber-500",children:"Unsaved changes"}):null,s.jsx(ue,{variant:"outline",size:"sm",onClick:V,disabled:g||b,children:"Reload"}),c?s.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}):s.jsxs(ue,{size:"sm",onClick:$,disabled:b||!xe,children:[s.jsx(ve,{icon:Sd,size:16,className:"mr-1.5"}),b?"Saving…":"Save"]})]})]}),y?s.jsxs(Ye,{variant:"destructive",children:[s.jsx(ve,{icon:ig,size:18}),s.jsx(qe,{children:y})]}):null,S?s.jsx(Ye,{className:"border-primary/30 bg-primary/10 text-primary",children:s.jsx(qe,{children:S})}):null,k==="yaml"?s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{className:"pb-3",children:[s.jsx(dt,{className:"text-base",children:"Raw YAML"}),s.jsx(Ot,{children:"Edit the full file. Use this for nested lists (e.g. welcome buttons) or any option not in Visual mode."})]}),s.jsx(Qe,{className:"h-[min(520px,60vh)] overflow-hidden rounded-b-xl border-t border-border p-0",children:s.jsx(oz,{height:"100%",language:"yaml",theme:"vs-dark",value:T,onChange:q=>M(q||""),options:{readOnly:c,minimap:{enabled:!1},fontSize:13,wordWrap:"on",scrollBeyondLastLine:!1,padding:{top:16},tabSize:2}})})]}):ae==="commands"?s.jsx(cz,{data:l,onChange:q=>d(q)}):re&&re!=="commands"?s.jsxs("div",{className:"grid gap-6 lg:grid-cols-[200px_1fr]",children:[s.jsx("nav",{className:"flex flex-col gap-1",children:re.map(q=>s.jsx("button",{onClick:()=>K(q.title),className:pe("text-left px-3 py-2 text-sm rounded-md transition-colors",te===q.title?"bg-primary text-primary-foreground font-medium":"text-muted-foreground hover:bg-secondary hover:text-foreground"),children:q.title},q.title))}),s.jsx("div",{className:"min-w-0",children:re.filter(q=>q.title===te).map(q=>s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{className:"pb-3 flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsx(dt,{className:"text-base",children:q.title}),q.description?s.jsx(Ot,{children:q.description}):null]}),q.title==="Ticket Departments"&&!c&&s.jsxs(ue,{type:"button",size:"sm",variant:"outline",onClick:()=>G(!0),className:"gap-1.5 text-xs h-8 shrink-0",children:[s.jsx(ve,{icon:sg,size:14})," Add Department"]})]}),s.jsx(Qe,{className:"space-y-6",children:(()=>{const{standalone:ge,groups:me}=fz(q.fields,l);return s.jsxs(s.Fragment,{children:[ge.length>0&&s.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:ge.map(B=>s.jsx("div",{className:B.type==="textarea"||B.type==="stringList"?"sm:col-span-2":"",children:s.jsx(pd,{field:B,value:Fr(l,B.path),readOnly:c,onChange:ie=>O(B.path,ie)})},B.path))}),me.map(B=>s.jsxs("div",{className:"rounded-xl border border-border bg-card/60 p-4 space-y-4 shadow-sm transition-all hover:border-primary/40",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 pb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-semibold text-base text-foreground",children:B.name}),s.jsx("span",{className:"text-xs font-mono px-2.5 py-0.5 rounded-full bg-primary/10 text-primary border border-primary/20 font-medium",children:q.title==="Ticket Departments"?`Ticket.${B.key}`:B.key})]}),q.title==="Ticket Departments"&&B.key!=="DepartmentSystem"&&!c&&s.jsx(ue,{type:"button",size:"sm",variant:"ghost",onClick:()=>Z(B.key),className:"h-7 w-7 p-0 text-muted-foreground hover:text-destructive",title:"Delete Department",children:s.jsx(ve,{icon:wi,size:14})})]}),s.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:B.fields.map(ie=>s.jsx("div",{className:ie.type==="textarea"||ie.type==="stringList"?"sm:col-span-2":"",children:s.jsx(pd,{field:ie,value:Fr(l,ie.path),readOnly:c,onChange:we=>O(ie.path,we)})},ie.path))})]},B.key))]})})()})]},q.title))})]}):null,s.jsx(Qs,{open:I,onOpenChange:G,children:s.jsxs(hs,{className:"sm:max-w-[400px]",children:[s.jsxs(gs,{children:[s.jsx(xs,{className:"text-base",children:"Add Ticket Department"}),s.jsx(vs,{className:"text-xs",children:"Create a new support department for ticket creation."})]}),s.jsxs("div",{className:"space-y-3 py-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(_e,{className:"text-xs font-semibold",children:"Department Key (Internal ID)"}),s.jsx(De,{placeholder:"billing",value:Y,onChange:q=>ce(q.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,"")),className:"text-xs font-mono border-border bg-secondary/30"}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["e.g. ",s.jsx("code",{children:"billing"}),", ",s.jsx("code",{children:"technical"}),", ",s.jsx("code",{children:"sales"})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(_e,{className:"text-xs font-semibold",children:"Department Display Name"}),s.jsx(De,{placeholder:"Billing & Sales Support",value:fe,onChange:q=>se(q.target.value),className:"text-xs border-border bg-secondary/30"})]})]}),s.jsxs(Js,{className:"gap-2 sm:gap-0",children:[s.jsx(ue,{variant:"outline",size:"sm",onClick:()=>G(!1),className:"text-xs",children:"Cancel"}),s.jsx(ue,{size:"sm",onClick:P,disabled:!Y.trim(),className:"text-xs bg-primary font-semibold",children:"Create Department"})]})]})})]})}const pz=Ne.listConfigs(),hz={supportbot:"Bot config","ticket-panel":"Ticket panel",commands:"Commands",messages:"Messages","supportbot-ai":"AI assistant"};function gz(){var T,M;const{permissions:t,canViewConfig:n}=qt(),{files:a}=$2(),[o,c]=wd(),l=o.get("file"),d=n("supportbot"),m=f.useMemo(()=>pz.filter(_=>n(_)),[n]),p=f.useMemo(()=>d?a:[],[d,a]),g=f.useMemo(()=>[...m,...p.map(_=>_l(_))],[m,p]),v=g[0]??"",[b,w]=f.useState(()=>l&&g.includes(l)?l:v);if(f.useEffect(()=>{l&&g.includes(l)?w(l):g.includes(b)||(w(v),v&&c({file:v}))},[l,g,b,v,c]),g.length===0)return s.jsx(ya,{to:mg(t),replace:!0});const y=H8(b),C=(y==null?void 0:y.type)==="addon",S=C?y.file:null,E=C?H2(S):hz[b]??"Configuration",k=C?!!((T=t==null?void 0:t.configs.supportbot)!=null&&T.edit):t?!!((M=t.configs[b])!=null&&M.edit):!1,N=C?S:`${b}.yml`;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:E}),s.jsx("p",{className:"text-muted-foreground",children:k?`Edit ${N} — changes apply to the running bot without restarting the dashboard.`:`Viewing ${N} — you do not have permission to save changes.`})]}),s.jsx("div",{className:"mt-6",children:C&&S?s.jsx(WO,{filename:S},S):s.jsx(mz,{configFile:b},b)})]})}const xz={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 vz(t){return t?xz[t]||"Sign-in failed. Please try again.":""}function bz(){const{branding:t}=Ed(),{isAuthenticated:n,loading:a,loginWithDiscord:o}=qt(),[c]=wd(),l=f.useMemo(()=>vz(c.get("error")),[c]);return!a&&n?s.jsx(ya,{to:"/",replace:!0}):s.jsx("div",{className:"relative flex min-h-svh items-center justify-center bg-[#0c0c10] p-4 overflow-hidden",children:s.jsxs(Ze,{className:"relative z-10 w-full max-w-md overflow-hidden rounded-3xl border border-white/10 bg-card/30 p-2 shadow-2xl backdrop-blur-2xl",children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-white/5 to-transparent pointer-events-none"}),s.jsxs(ut,{className:"space-y-6 pt-10 pb-4 text-center",children:[s.jsx("div",{className:"mx-auto flex size-28 items-center justify-center overflow-hidden rounded-3xl bg-white/5 p-4 shadow-inner ring-1 ring-white/10 transition-transform duration-500 hover:scale-105",children:s.jsx("img",{src:"/logo.png",alt:"SupportBot Logo",className:"h-full w-full object-contain drop-shadow-xl"})}),s.jsxs("div",{children:[s.jsx(dt,{className:"bg-gradient-to-br from-white to-white/50 bg-clip-text text-3xl font-extrabold tracking-tight text-transparent",children:t.title||"SupportBot"}),s.jsx(Ot,{className:"mt-2 text-base font-medium text-white/50",children:"Sign in to your dashboard"})]})]}),s.jsxs(Qe,{className:"space-y-6 pb-10",children:[s.jsxs("div",{className:"text-center space-y-1",children:[s.jsx("p",{className:"text-sm font-medium text-white/50",children:"Securely authenticate using your Discord account."}),s.jsxs("p",{className:"text-xs text-white/30",children:["Credentials are configured in ",s.jsx("code",{className:"rounded bg-white/5 px-1 py-0.5 text-white/40",children:"Configs/api.yml"})]})]}),l?s.jsx(Ye,{variant:"destructive",className:"border-red-500/50 bg-red-500/10 text-red-200 backdrop-blur-md",children:s.jsx(qe,{className:"font-medium",children:l})}):null,s.jsxs(ue,{type:"button",className:"group relative w-full overflow-hidden rounded-2xl bg-primary px-8 py-6 text-base font-bold text-primary-foreground shadow-[0_0_20px_rgba(var(--primary),0.3)] transition-all duration-300 hover:scale-[1.02] hover:shadow-[0_0_30px_rgba(var(--primary),0.5)] active:scale-95",disabled:a,onClick:o,children:[s.jsx("div",{className:"absolute inset-0 translate-x-[-100%] bg-gradient-to-r from-transparent via-white/20 to-transparent transition-transform duration-1000 group-hover:translate-x-[100%]"}),s.jsxs("span",{className:"relative flex items-center justify-center gap-2",children:[s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",viewBox:"0 0 127.14 96.36",fill:"currentColor",children:s.jsx("path",{d:"M107.7,8.07A105.15,105.15,0,0,0,81.47,0a72.06,72.06,0,0,0-3.36,6.83A97.68,97.68,0,0,0,49,6.83,72.37,72.37,0,0,0,45.64,0,105.89,105.89,0,0,0,19.39,8.09C2.79,32.65-1.71,56.6.54,80.21h0A105.73,105.73,0,0,0,32.71,96.36,77.7,77.7,0,0,0,39.6,85.25a68.42,68.42,0,0,1-10.85-5.18c.91-.66,1.8-1.34,2.66-2a75.57,75.57,0,0,0,64.32,0c.87.71,1.76,1.39,2.66,2a68.68,68.68,0,0,1-10.87,5.19,77,77,0,0,0,6.89,11.1,105.25,105.25,0,0,0,32.19-16.14c2.64-27.38-4.51-51.11-19.32-72.15ZM42.68,68.22c-5.28,0-9.66-4.9-9.66-10.89s4.29-10.89,9.66-10.89c5.41,0,9.75,4.9,9.66,10.89C52.34,63.32,48.09,68.22,42.68,68.22Zm41.76,0c-5.28,0-9.66-4.9-9.66-10.89s4.29-10.89,9.66-10.89c5.41,0,9.75,4.9,9.66,10.89C84.44,63.32,80.19,68.22,84.44,68.22Z"})}),a?"Authenticating...":"Continue with Discord"]})]})]})]})})}const mi=[{id:"botToken",title:"Bot token",subtitle:"Connect your Discord bot",icon:cg},{id:"database",title:"Database",subtitle:"SQLite or MySQL engine",icon:x8},{id:"secretKey",title:"Session secret",subtitle:"Secure dashboard logins",icon:M8},{id:"oauth",title:"Discord OAuth",subtitle:"Sign in with Discord",icon:By},{id:"redirectUri",title:"Redirect URL",subtitle:"OAuth callback address",icon:Nd},{id:"owners",title:"Dashboard owners",subtitle:"Who can access this panel",icon:rh},{id:"emeraldApi",title:"Emerald API",subtitle:"One-click addons",icon:By}];function yz(t){return t==="oauth"?"oauth":t==="owners"?"owners":t}function wz({brandingTitle:t,faviconUrl:n,faviconVersion:a,hasFavicon:o,children:c}){return s.jsx("div",{className:"min-h-svh bg-background",children:s.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:[s.jsxs("header",{className:"mb-8 flex items-center gap-4",children:[o&&n?s.jsx("img",{src:`${n}${a?`?v=${a}`:""}`,alt:"",className:"size-12 rounded-2xl border border-border object-contain"}):s.jsx("div",{className:"flex size-12 items-center justify-center rounded-2xl border border-border bg-primary text-primary-foreground",children:s.jsx(ve,{icon:cg,size:24})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"First-time setup"}),s.jsx("h1",{className:"text-2xl font-semibold tracking-tight md:text-3xl",children:t})]})]}),c]})})}function jz({currentIndex:t,validation:n}){const a=(t+1)/mi.length*100;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[s.jsxs("span",{children:["Step ",t+1," of ",mi.length]}),s.jsxs("span",{children:[Math.round(a),"%"]})]}),s.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-secondary",children:s.jsx("div",{className:"h-full rounded-full bg-primary transition-all duration-300 ease-out",style:{width:`${a}%`}})})]}),s.jsx("nav",{className:"hidden space-y-1 md:block","aria-label":"Setup steps",children:mi.map((o,c)=>{var g;const l=yz(o.id),d=(g=n[l])==null?void 0:g.ok,m=c===t,p=cs.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx(ve,{icon:jd,size:14}),o.globalName||o.username,s.jsx("span",{className:"font-mono text-xs opacity-80",children:o.id})]},o.id))}):null,!t.bot&&!((a=t.users)!=null&&a.length)?s.jsx("p",{children:t.warning||"Verified successfully."}):null]})}):s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:t.error})}):null}function Sz({values:t,setValues:n,validation:a,validating:o,onValidate:c}){return s.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[s.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Open the"," ",s.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 ",s.jsx("strong",{children:"Bot"}),", and reset or copy the token."]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"botToken",children:"Bot token"}),s.jsx(De,{id:"botToken",type:"password",autoComplete:"off",value:t.botToken,onChange:l=>n({...t,botToken:l.target.value}),placeholder:"MTI…",className:"h-11 font-mono text-sm"})]}),s.jsx(mo,{result:a.botToken}),s.jsx("div",{className:"mt-auto",children:s.jsx(ue,{type:"button",variant:"secondary",disabled:o||!t.botToken,onClick:c,children:o?"Checking with Discord…":"Verify bot token"})})]})}function Nz({values:t,setValues:n,validation:a,validating:o,onValidate:c,onGenerate:l}){return s.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[s.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."}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"secretKey",children:"Session secret"}),s.jsx(De,{id:"secretKey",type:"password",autoComplete:"off",value:t.secretKey,onChange:d=>n({...t,secretKey:d.target.value}),className:"h-11 font-mono text-sm"})]}),s.jsx(mo,{result:a.secretKey}),s.jsxs("div",{className:"mt-auto flex flex-wrap gap-2",children:[s.jsx(ue,{type:"button",variant:"outline",onClick:l,children:"Generate secure secret"}),s.jsx(ue,{type:"button",variant:"secondary",disabled:o||!t.secretKey,onClick:c,children:o?"Checking…":"Validate"})]})]})}function Ez({values:t,setValues:n,validation:a,validating:o,onValidate:c}){return s.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[s.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Use the ",s.jsx("strong",{children:"same application"})," as your bot. Under OAuth2, copy the Client ID and Client Secret."]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[s.jsx(_e,{htmlFor:"clientId",children:"Client ID"}),s.jsx(De,{id:"clientId",value:t.clientId,onChange:l=>n({...t,clientId:l.target.value}),className:"h-11 font-mono text-sm"})]}),s.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[s.jsx(_e,{htmlFor:"clientSecret",children:"Client Secret"}),s.jsx(De,{id:"clientSecret",type:"password",autoComplete:"off",value:t.clientSecret,onChange:l=>n({...t,clientSecret:l.target.value}),className:"h-11 font-mono text-sm"})]})]}),s.jsx(mo,{result:a.oauth}),s.jsx("div",{className:"mt-auto",children:s.jsx(ue,{type:"button",variant:"secondary",disabled:o||!t.clientId||!t.clientSecret,onClick:c,children:o?"Checking with Discord…":"Verify OAuth credentials"})})]})}function kz({values:t,setValues:n,validation:a}){async function o(){if(t.redirectUri)try{await navigator.clipboard.writeText(t.redirectUri)}catch{}}return s.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[s.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Add this exact URL under ",s.jsx("strong",{children:"OAuth2 → Redirects"})," in the Developer Portal. It must match character-for-character."]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"redirectUri",children:"Redirect URI"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(De,{id:"redirectUri",value:t.redirectUri,onChange:c=>n({...t,redirectUri:c.target.value}),className:"h-11 flex-1 font-mono text-xs"}),s.jsx(ue,{type:"button",variant:"outline",size:"icon",className:"size-11 shrink-0",onClick:()=>void o(),title:"Copy URL",children:s.jsx(ve,{icon:R2,size:18})})]})]}),a.redirectUri&&!a.redirectUri.ok?s.jsx(mo,{result:a.redirectUri}):s.jsx(Ye,{className:"border-border bg-secondary",children:s.jsx(qe,{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 Tz({values:t,setValues:n,validation:a,validating:o,onValidate:c}){return s.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[s.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Enable ",s.jsx("strong",{children:"Developer Mode"})," in Discord (Settings → Advanced), then right-click your profile and ",s.jsx("strong",{children:"Copy User ID"}),". Add one ID per line."]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"owners",children:"Owner user IDs"}),s.jsx(Jd,{id:"owners",value:t.ownerUserIds,onChange:l=>n({...t,ownerUserIds:l.target.value}),placeholder:`829112572816130058 -987654321098765432`,className:"min-h-[120px] font-mono text-sm"})]}),s.jsx(mo,{result:a.owners}),s.jsx("div",{className:"mt-auto",children:s.jsx(ue,{type:"button",variant:"secondary",disabled:o||!t.ownerUserIds.trim(),onClick:c,children:o?"Checking with Discord…":"Verify owner IDs"})})]})}function Mz({onContinue:t}){return s.jsx("div",{className:"mx-auto flex w-full max-w-lg flex-1 flex-col justify-center py-8",children:s.jsxs("div",{className:"rounded-2xl border border-border bg-card px-6 py-10 text-center md:px-10",children:[s.jsx("div",{className:"mx-auto mb-6 flex size-16 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:s.jsx(ve,{icon:jd,size:40})}),s.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Setup complete"}),s.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"," ",s.jsx("code",{className:"rounded-md bg-muted px-1.5 py-0.5 font-mono text-xs",children:"npm start"}),")."]}),s.jsx(Ye,{className:"mt-6 text-left",children:s.jsx(qe,{children:"After restarting, sign in with Discord to open the dashboard."})}),s.jsx(ue,{type:"button",size:"lg",className:"mt-8 min-w-[220px]",onClick:t,children:"Continue to sign in"})]})})}function Rz({currentIndex:t,validating:n,saving:a,onBack:o,onNext:c,onFinish:l}){const d=t===mi.length-1;return s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs(ue,{type:"button",variant:"ghost",disabled:t===0||a,onClick:o,children:[s.jsx(ve,{icon:T2,size:18,className:"mr-1"}),"Back"]}),s.jsx("div",{className:"flex flex-1 justify-end gap-2",children:d?s.jsx(ue,{type:"button",size:"lg",disabled:a||n,onClick:l,className:"min-w-[200px]",children:a?"Saving…":"Finish setup"}):s.jsxs(ue,{type:"button",size:"lg",disabled:n||a,onClick:c,children:["Continue",s.jsx(ve,{icon:lg,size:18,className:"ml-1"})]})})]})}function Az({values:t,setValues:n,validation:a,validating:o,onValidate:c}){return s.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[s.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["An Emerald Services API key is optional, but required to use the one-click addon installer in the dashboard. You can get yours from the"," ",s.jsx("a",{href:"https://emeraldsrv.dev",target:"_blank",rel:"noreferrer",className:"font-medium text-primary hover:underline",children:"Emerald Services Marketplace"}),"."]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"emeraldApiKey",children:"Emerald API key (Optional)"}),s.jsx(De,{id:"emeraldApiKey",type:"password",autoComplete:"off",value:t.emeraldApiKey,onChange:l=>n({...t,emeraldApiKey:l.target.value}),placeholder:"em_...",className:"h-11 font-mono text-sm"})]}),s.jsx(mo,{result:a.emeraldApi}),s.jsx("div",{className:"mt-auto",children:s.jsx(ue,{type:"button",variant:"secondary",disabled:o,onClick:c,children:o?"Checking…":t.emeraldApiKey?"Verify key":"Skip step"})})]})}function _z({values:t,setValues:n,validation:a,validating:o,onValidate:c}){const l=a.database,d=t.dbDriver==="mysql";return s.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[s.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Choose your database storage engine. Select ",s.jsx("strong",{children:"SQLite"})," for instant zero-config local storage, or ",s.jsx("strong",{children:"MySQL / MariaDB"})," for external host databases."]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{onClick:()=>n(m=>({...m,dbDriver:"sqlite"})),className:pe("cursor-pointer rounded-xl border p-4 transition-all hover:border-primary",t.dbDriver==="sqlite"?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-border bg-card"),children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"font-semibold text-foreground",children:"SQLite"}),s.jsx("span",{className:"rounded-full bg-emerald-500/10 px-2.5 py-0.5 text-xs font-medium text-emerald-500",children:"Zero Config"})]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Single-file SQL database stored locally at ",s.jsx("code",{className:"font-mono",children:"./Data/supportbot.db"}),". Zero extra setup required."]})]}),s.jsxs("div",{onClick:()=>n(m=>({...m,dbDriver:"mysql"})),className:pe("cursor-pointer rounded-xl border p-4 transition-all hover:border-primary",t.dbDriver==="mysql"?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-border bg-card"),children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"font-semibold text-foreground",children:"MySQL / MariaDB"}),s.jsx("span",{className:"rounded-full bg-blue-500/10 px-2.5 py-0.5 text-xs font-medium text-blue-500",children:"External Database"})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Connect to a remote or local MySQL database server."})]})]}),d&&s.jsxs("div",{className:"space-y-4 rounded-xl border border-border bg-card/50 p-4",children:[s.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"MySQL Connection Settings"}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[s.jsx(_e,{htmlFor:"dbHost",children:"Database Host"}),s.jsx(De,{id:"dbHost",placeholder:"127.0.0.1 or localhost",value:t.dbHost,onChange:m=>n(p=>({...p,dbHost:m.target.value})),className:"h-11 text-sm"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"dbPort",children:"Port"}),s.jsx(De,{id:"dbPort",placeholder:"3306",value:t.dbPort,onChange:m=>n(p=>({...p,dbPort:m.target.value})),className:"h-11 text-sm font-mono"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"dbDatabase",children:"Database Name"}),s.jsx(De,{id:"dbDatabase",placeholder:"supportbot",value:t.dbDatabase,onChange:m=>n(p=>({...p,dbDatabase:m.target.value})),className:"h-11 text-sm"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"dbUser",children:"Database User"}),s.jsx(De,{id:"dbUser",placeholder:"root",value:t.dbUser,onChange:m=>n(p=>({...p,dbUser:m.target.value})),className:"h-11 text-sm font-mono"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"dbPassword",children:"Password"}),s.jsx(De,{id:"dbPassword",type:"password",placeholder:"••••••••••••",value:t.dbPassword,onChange:m=>n(p=>({...p,dbPassword:m.target.value})),className:"h-11 text-sm font-mono"})]})]})]}),s.jsx(mo,{result:l}),s.jsx("div",{className:"mt-auto",children:s.jsx(ue,{type:"button",variant:"secondary",disabled:o,onClick:c,children:o?"Testing Connection...":"Test Connection & Validate"})})]})}function Dz(){const t=crypto.randomUUID().replace(/-/g,""),n=crypto.randomUUID().replace(/-/g,"");return t+n}function Oz(t){return t.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean)}function t2(t){return t==="oauth"?"oauth":t==="owners"?"owners":t==="database"?"database":t==="emeraldApi"?"emeraldApi":t}function Lz(){const t=ao(),{branding:n}=Ed(),{loading:a,error:o,refresh:c,status:l}=fS(),[d,m]=f.useState(0),[p,g]=f.useState({botToken:"",dbDriver:"sqlite",dbHost:"127.0.0.1",dbPort:"3306",dbUser:"",dbPassword:"",dbDatabase:"supportbot",secretKey:"",clientId:"",clientSecret:"",redirectUri:"",ownerUserIds:"",emeraldApiKey:""}),[v,b]=f.useState({}),[w,y]=f.useState(!1),[C,S]=f.useState(!1),[E,k]=f.useState(""),[N,T]=f.useState(!1),M=mi[d];f.useEffect(()=>{l!=null&&l.suggestedRedirectUri&&!p.redirectUri&&g(G=>({...G,redirectUri:l.suggestedRedirectUri}))},[l==null?void 0:l.suggestedRedirectUri,p.redirectUri]);const _=f.useMemo(()=>({botToken:p.botToken,dbDriver:p.dbDriver,dbHost:p.dbHost,dbPort:p.dbPort,dbUser:p.dbUser,dbPassword:p.dbPassword,dbDatabase:p.dbDatabase,secretKey:p.secretKey,clientId:p.clientId,clientSecret:p.clientSecret,redirectUri:p.redirectUri,ownerUserIds:Oz(p.ownerUserIds),emeraldApiKey:p.emeraldApiKey}),[p]);async function R(){y(!0),k("");try{const G=await Ne.validateSetup(_);return b(Y=>{var ce;return{...Y,...(ce=G.data)==null?void 0:ce.results}}),G.data}catch(G){return k(G instanceof Error?G.message:"Validation failed"),null}finally{y(!1)}}async function L(){var ce,fe;const G=t2(M.id),Y=await R();return!!((fe=(ce=Y==null?void 0:Y.results)==null?void 0:ce[G])!=null&&fe.ok)}async function te(){const G=t2(M.id),Y=v[G];!(Y!=null&&Y.ok)&&!await L()||m(ce=>Math.min(ce+1,mi.length-1))}async function K(){S(!0),k("");try{const G=await R();if(!(G!=null&&G.ok)){k("Fix the steps marked with errors before finishing.");return}await Ne.completeSetup(_),T(!0)}catch(G){k(G instanceof Error?G.message:"Could not save setup")}finally{S(!1)}}function I(){const G={values:p,setValues:g,validation:v,validating:w};switch(M.id){case"botToken":return s.jsx(Sz,{...G,onValidate:()=>void L()});case"database":return s.jsx(_z,{...G,onValidate:()=>void L()});case"secretKey":return s.jsx(Nz,{...G,onGenerate:()=>g(Y=>({...Y,secretKey:Dz()})),onValidate:()=>void L()});case"oauth":return s.jsx(Ez,{...G,onValidate:()=>void L()});case"redirectUri":return s.jsx(kz,{values:p,setValues:g,validation:v});case"owners":return s.jsx(Tz,{...G,onValidate:()=>void L()});case"emeraldApi":return s.jsx(Az,{...G,onValidate:()=>void L()})}}return a?s.jsx("div",{className:"min-h-svh bg-background px-4 py-10",children:s.jsxs("div",{className:"mx-auto max-w-6xl space-y-8",children:[s.jsx(Be,{className:"h-14 w-64"}),s.jsxs("div",{className:"grid gap-8 lg:grid-cols-[280px_1fr]",children:[s.jsx(Be,{className:"hidden h-80 lg:block"}),s.jsx(Be,{className:"h-[520px] rounded-2xl"})]})]})}):s.jsxs(wz,{brandingTitle:n.title,faviconUrl:n.faviconUrl,faviconVersion:n.updatedAt??void 0,hasFavicon:n.hasFavicon,children:[o?s.jsx(Ye,{variant:"destructive",className:"mb-6",children:s.jsx(qe,{children:o})}):null,E?s.jsx(Ye,{variant:"destructive",className:"mb-6",children:s.jsx(qe,{children:E})}):null,N?s.jsx(Mz,{onContinue:async()=>{await c(),t("/login",{replace:!0})}}):s.jsxs("div",{className:"grid flex-1 gap-8 lg:grid-cols-[minmax(0,280px)_1fr]",children:[s.jsx(jz,{currentIndex:d,validation:v}),s.jsx(Cz,{step:M,footer:s.jsx(Rz,{currentIndex:d,validating:w,saving:C,onBack:()=>m(G=>Math.max(0,G-1)),onNext:()=>void te(),onFinish:()=>void K()}),children:I()})]})]})}const zz={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 Pz({title:t,icon:n,href:a,badge:o="Configured",status:c="done"}){return s.jsxs(Jt,{to:a,className:pe("flex items-center gap-3 rounded-2xl border border-border bg-card p-4 transition-colors","hover:border-primary hover:bg-secondary"),children:[s.jsx("div",{className:"flex size-11 shrink-0 items-center justify-center rounded-full bg-secondary text-primary",children:s.jsx(ve,{icon:n,size:20})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate font-semibold",children:t}),s.jsx("span",{className:pe("mt-1 inline-flex rounded-md px-2 py-0.5 text-[10px] font-semibold",zz[c]),children:o})]})]})}function Iz({percent:t,size:n=128,className:a,trackClassName:o="stroke-white/20",strokeClassName:c="stroke-white"}){const d=2*Math.PI*42,m=Math.min(100,Math.max(0,t)),p=d-m/100*d;return s.jsxs("div",{className:pe("relative inline-flex",a),children:[s.jsxs("svg",{width:n,height:n,viewBox:"0 0 100 100",className:"-rotate-90","aria-hidden":!0,children:[s.jsx("circle",{cx:"50",cy:"50",r:42,fill:"none",strokeWidth:"9",className:o}),s.jsx("circle",{cx:"50",cy:"50",r:42,fill:"none",strokeWidth:"9",strokeLinecap:"round",strokeDasharray:d,strokeDashoffset:p,className:c})]}),s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-center",children:[s.jsxs("span",{className:"text-2xl font-bold tabular-nums leading-none",children:[Math.round(m),"%"]}),s.jsx("span",{className:"mt-0.5 text-[10px] font-medium uppercase tracking-wide opacity-80",children:"Complete"})]})]})}const Uz={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 Bz({title:t,subtitle:n,icon:a,href:o,status:c,meta:l="Open in dashboard"}){const d=Uz[c];return s.jsxs(Jt,{to:o,className:pe("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:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("span",{className:pe("mt-1.5 size-2 shrink-0 rounded-full",d.dot)}),s.jsx("span",{className:"text-xs text-muted-foreground",children:n})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-semibold leading-snug tracking-tight",children:t}),s.jsx("span",{className:pe("mt-2 inline-flex rounded-md px-2 py-0.5 text-[11px] font-semibold",d.badge),children:d.label})]}),s.jsxs("div",{className:"mt-auto flex items-center justify-between border-t border-border pt-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex size-8 items-center justify-center rounded-lg bg-secondary text-primary",children:s.jsx(ve,{icon:a,size:16})}),s.jsx("span",{className:"text-xs text-muted-foreground",children:l})]}),s.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[s.jsx(ve,{icon:Nd,size:14,className:"opacity-60"}),s.jsx(ve,{icon:qs,size:14,className:"opacity-60 group-hover:text-primary"}),s.jsx(ve,{icon:lg,size:14,className:"text-primary opacity-0 transition-opacity group-hover:opacity-100"})]})]})]})}function $z({stats:t}){const n=[{id:"ping",label:"Gateway latency",detail:`${t.bot.ping}ms`,badge:t.bot.ping<200?"Good":"High",badgeClass:t.bot.ping<200?"bg-emerald-500/15 text-emerald-400":"bg-amber-500/15 text-amber-400"},{id:"uptime",label:"Bot uptime",detail:fg(t.bot.uptime),badge:"Live",badgeClass:"bg-primary/20 text-primary"},{id:"ram",label:"Memory usage",detail:`${t.hosting.ram_used} / ${t.hosting.ram_total}`,badge:`${t.hosting.ram_percent}%`,badgeClass:"bg-sky-500/15 text-sky-400"}];return s.jsxs("aside",{className:"hidden w-[min(100%,320px)] shrink-0 space-y-4 xl:block",children:[s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{className:"flex flex-row items-center justify-between space-y-0 pb-3",children:[s.jsxs(dt,{className:"text-sm font-semibold",children:["Connected servers (",t.servers,")"]}),s.jsx(ue,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",children:s.jsx("span",{className:"text-lg leading-none",children:"+"})})]}),s.jsxs(Qe,{className:"pt-0",children:[s.jsxs("div",{className:"flex -space-x-2",children:[Array.from({length:Math.min(6,t.servers)}).map((a,o)=>s.jsxs(bs,{className:"size-9 border-2 border-card ring-0",children:[s.jsx(eo,{src:t.bot.avatar,alt:""}),s.jsx(ys,{className:"bg-primary/25 text-[10px] text-primary",children:String(o+1)})]},o)),t.servers>6?s.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:["+",t.servers-6]}):null]}),s.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:[t.users.toLocaleString()," members across your guilds"]})]})]}),s.jsx(Ze,{className:"overflow-hidden border-border bg-secondary",children:s.jsx(Qe,{className:"p-5",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"flex size-10 items-center justify-center rounded-xl bg-primary text-primary-foreground",children:s.jsx(ve,{icon:T8,size:22})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold",children:"Keep SupportBot up to date"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Check for releases and install updates from settings."})]}),s.jsx(ue,{asChild:!0,size:"sm",className:"w-full",children:s.jsxs(Jt,{to:"/settings",children:[s.jsx(ve,{icon:Cd,size:16,className:"mr-2"}),"Open settings"]})})]})})}),s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[s.jsx(dt,{className:"text-sm font-semibold",children:"System activity"}),s.jsx(ue,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",children:s.jsx("span",{className:"text-base leading-none",children:"⋯"})})]}),s.jsxs(Qe,{className:"space-y-1 p-0 pb-2",children:[n.map(a=>s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 transition-colors hover:bg-secondary/40",children:[s.jsxs(bs,{className:"size-9",children:[s.jsx(eo,{src:t.bot.avatar,alt:t.bot.username}),s.jsx(ys,{className:"bg-secondary text-xs",children:"SB"})]}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-sm font-medium",children:a.label}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.detail})]}),s.jsx("span",{className:`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold ${a.badgeClass}`,children:a.badge})]},a.id)),s.jsx(ue,{asChild:!0,variant:"ghost",className:"mx-2 mt-1 w-[calc(100%-1rem)] justify-between text-xs text-muted-foreground",children:s.jsxs(Jt,{to:"/system",children:["All system details",s.jsx(ve,{icon:lg,size:14})]})})]})]}),s.jsx(Ze,{className:"border-border bg-card",children:s.jsxs(Qe,{className:"flex items-center gap-3 p-4",children:[s.jsx("div",{className:"flex size-9 items-center justify-center rounded-lg bg-secondary text-primary",children:s.jsx(ve,{icon:qs,size:18})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"text-sm font-medium",children:["v",t.bot.version]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["CPU ",t.hosting.cpu_load]})]})]})})]})}const c5={todo:"Needs setup",progress:"In progress",done:"Active"};function Kh(t,n,a="Configure module"){const o=n==null?void 0:n[t];return o||{status:"todo",subtitle:a}}function Hz(){return s.jsxs("div",{className:"flex gap-6",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-6",children:[s.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[s.jsx(Be,{className:"h-44 rounded-2xl"}),s.jsx(Be,{className:"h-44 rounded-2xl"})]}),s.jsx(Be,{className:"h-8 w-48"}),s.jsx("div",{className:"flex gap-4 overflow-hidden",children:Array.from({length:3}).map((t,n)=>s.jsx(Be,{className:"h-40 min-w-[280px] rounded-2xl"},n))}),s.jsx(Be,{className:"h-8 w-56"}),s.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:Array.from({length:4}).map((t,n)=>s.jsx(Be,{className:"h-20 rounded-2xl"},n))})]}),s.jsx(Be,{className:"hidden h-[520px] w-80 shrink-0 rounded-2xl xl:block"})]})}function Gz(){const{stats:t,loading:n,error:a}=kd(),[o,c]=f.useState("all"),l=f.useMemo(()=>{if(!t)return 0;const v=t.tickets.total||0;return v===0?100:Math.round(t.tickets.closed/v*100)},[t]),d=f.useMemo(()=>o==="open"||o==="closed"?ii.filter(v=>v.category==="tickets"):o==="all"?ii:ii.filter(v=>v.category===o),[o]);if(n)return s.jsx(Hz,{});if(a||!t)return s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:a||"No stats available"})});const m=t.tickets.open,p=t.tickets.closed,g=t.tickets.total;return s.jsxs("div",{className:"flex flex-col gap-6 xl:flex-row xl:items-start",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-6",children:[s.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[s.jsx(Ze,{className:"overflow-hidden border-border bg-card",children:s.jsxs(Qe,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("p",{className:"text-lg font-semibold leading-snug",children:["You have"," ",s.jsx("span",{className:"text-primary",children:m})," open ticket",m===1?"":"s"]}),s.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."}),s.jsx(ue,{asChild:!0,size:"sm",className:"rounded-lg px-5",children:s.jsx(Jt,{to:"/transcripts",children:"Review"})})]}),s.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:[s.jsx("div",{className:"absolute inset-0 rounded-2xl bg-secondary"}),s.jsx("span",{className:"relative text-6xl",children:"🎫"})]})]})}),s.jsx(Ze,{className:"overflow-hidden border-border bg-primary text-primary-foreground",children:s.jsxs(Qe,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm font-medium text-white/80",children:"Ticket summary"}),s.jsxs("ul",{className:"space-y-1.5 text-sm",children:[s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"size-1.5 rounded-full bg-white/70"}),s.jsxs("span",{className:"text-white/90",children:[g," total"]})]}),s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"size-1.5 rounded-full bg-white/70"}),s.jsxs("span",{className:"text-white/90",children:[p," closed"]})]}),s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"size-1.5 rounded-full bg-white/70"}),s.jsxs("span",{className:"text-white/90",children:[m," open"]})]})]})]}),s.jsx(Iz,{percent:l,size:120})]})})]}),s.jsxs("section",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[s.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Module overview"}),s.jsx(DS,{value:o,onValueChange:v=>c(v),children:s.jsxs(xx,{className:"h-auto flex-wrap rounded-xl bg-secondary/60 p-1",children:[s.jsx(Ys,{value:"all",className:"rounded-lg text-xs data-[state=active]:bg-background data-[state=active]:shadow-sm",children:"All"}),s.jsx(Ys,{value:"open",className:"rounded-lg text-xs data-[state=active]:bg-background",children:"Open"}),s.jsx(Ys,{value:"closed",className:"rounded-lg text-xs data-[state=active]:bg-background",children:"Closed"}),YM.filter(v=>v.id!=="all").map(v=>s.jsx(Ys,{value:v.id,className:"rounded-lg text-xs data-[state=active]:bg-background",children:v.label},v.id))]})})]}),s.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:is,href:"/tickets",status:"done",meta:"View live tickets"}]:o==="closed"?[{id:"closed-archive",title:"Closed tickets",subtitle:`${p} resolved`,icon:jd,href:"/transcripts",status:"done",meta:"Browse archive"}]:d.map(v=>{const b=Kh(v.id,t.modules,v.description);return{id:v.id,title:v.title,subtitle:b.subtitle,icon:v.icon,href:v.href,status:b.status,meta:b.status==="done"?"View settings":"Configure"}})).map(v=>s.jsx(Bz,{title:v.title,subtitle:v.subtitle,icon:v.icon,href:v.href,status:v.status,meta:v.meta},v.id))})]}),s.jsxs("section",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Active modules"}),s.jsx(Jt,{to:"/configs",className:"text-sm font-medium text-primary hover:underline",children:"See all"})]}),s.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:ii.slice(0,4).map(v=>{const b=Kh(v.id,t.modules);return s.jsx(Pz,{title:v.title,icon:v.icon,href:v.href,badge:c5[b.status],status:b.status},v.id)})})]})]}),s.jsx($z,{stats:t})]})}function Vz(){const{permissions:t}=qt();return Mn(t,"overview")?s.jsx(Gz,{}):s.jsx(ya,{to:mg(t),replace:!0})}function ga({permission:t,children:n}){const{loading:a,isAuthenticated:o,permissions:c}=qt();return a?s.jsx("div",{className:"flex flex-1 items-center justify-center py-16 text-sm text-muted-foreground",children:"Loading…"}):o?Mn(c,t)?s.jsx(s.Fragment,{children:n}):s.jsx(ya,{to:mg(c),replace:!0}):s.jsx(ya,{to:"/login",replace:!0})}function Fz(){const{hasPermission:t}=qt(),n=t("settings.update"),a=ao(),[o,c]=f.useState([]),[l,d]=f.useState(""),[m,p]=f.useState(!0),[g,v]=f.useState(""),[b,w]=f.useState(""),[y,C]=f.useState(null),S=f.useCallback(async()=>{p(!0),v("");try{const k=await Ne.getAddonsCatalog();k.data&&(c(k.data.addons),d(k.data.repository))}catch(k){v(k instanceof Error?k.message:"Failed to load addons")}finally{p(!1)}},[]);f.useEffect(()=>{S()},[S]);async function E(k){if(n){C(k.id),w(""),v("");try{const N=await Ne.installAddon(k.id);w(N.message||`${k.name} installed.`),await S();const T=k.configFiles[0];T&&a(`/configs?file=${_l(T)}`)}catch(N){v(N instanceof Error?N.message:"Install failed")}finally{C(null)}}}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Addons"}),s.jsxs("p",{className:"text-muted-foreground",children:["Requires an API key from"," ",s.jsx("a",{href:"https://emeraldsrv.dev",target:"_blank",rel:"noreferrer",className:"text-primary underline-offset-4 hover:underline",children:"emeraldsrv.dev"})," ","to browse and install addons. Configs will appear in the sidebar once installed."]})]}),s.jsxs(ue,{variant:"outline",size:"sm",onClick:S,disabled:m,children:[s.jsx(ve,{icon:_2,size:16,className:pe("mr-1.5",m&&"animate-spin")}),"Refresh"]})]}),g?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:g})}):null,b?s.jsx(Ye,{className:"border-primary/30 bg-primary/10 text-primary",children:s.jsx(qe,{children:b})}):null,s.jsxs("section",{className:"space-y-4",children:[s.jsx("h2",{className:"text-sm font-semibold uppercase tracking-widest text-muted-foreground",children:"Marketplace"}),m?s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsx(Be,{className:"h-40 rounded-xl"}),s.jsx(Be,{className:"h-40 rounded-xl"}),s.jsx(Be,{className:"h-40 rounded-xl"})]}):s.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:o.map(k=>s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{className:"pb-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs(dt,{className:"flex items-center gap-2 text-lg",children:[s.jsx(ve,{icon:dg,size:20,className:"text-primary"}),k.name]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Fn,{variant:"outline",className:"shrink-0 uppercase tracking-widest text-[10px]",children:k.price===0||!k.price?"Free":`$${k.price}`}),k.installed?s.jsxs(Fn,{variant:"secondary",className:"shrink-0 gap-1",children:[s.jsx(ve,{icon:D8,size:14}),"Installed"]}):null]})]}),s.jsx(Ot,{children:k.description})]}),s.jsxs(Qe,{className:"space-y-2 text-xs text-muted-foreground",children:[k.is_external?s.jsxs("p",{children:["Available on: ",s.jsx("span",{className:"font-medium text-foreground",children:k.external_store||"External Store"})]}):null,k.configFiles&&k.configFiles.length>0?s.jsxs("p",{children:["Config:"," ",k.configFiles.map((N,T)=>s.jsxs("span",{children:[T>0?", ":null,s.jsx(Jt,{to:`/configs?file=${_l(N)}`,className:"font-mono text-primary hover:underline",children:N})]},N))]}):null]}),s.jsxs(Sx,{className:"flex flex-wrap gap-2",children:[k.is_external?s.jsx(ue,{variant:"outline",size:"sm",asChild:!0,children:s.jsx("a",{href:k.repositoryUrl,target:"_blank",rel:"noreferrer",children:"View Store"})}):null,k.installed&&k.configFiles&&k.configFiles[0]?s.jsx(ue,{size:"sm",variant:"secondary",asChild:!0,children:s.jsx(Jt,{to:`/configs?file=${_l(k.configFiles[0])}`,children:"Edit config"})}):null,k.installed?s.jsx(ue,{size:"sm",disabled:!0,variant:"secondary",children:"Installed"}):k.is_external?null:s.jsxs(ue,{size:"sm",disabled:!n||y===k.id,onClick:()=>E(k),children:[s.jsx(ve,{icon:Cd,size:14,className:"mr-1"}),y===k.id?"Installing…":"Install"]})]})]},k.id))})]})]})}function Yz(){const{permissions:t}=qt(),[n,a]=f.useState(!1),[o,c]=f.useState(!1),[l,d]=f.useState(""),[m,p]=f.useState(""),[g,v]=f.useState(""),[b,w]=f.useState("Administrator"),[y,C]=f.useState(""),[S,E]=f.useState(""),[k,N]=f.useState("General"),T=z2(t,"supportbot"),M=async()=>{if(!m.match(/^[a-z0-9_-]+$/i)){Dt.error("Command name can only contain letters, numbers, underscores and dashes.");return}a(!0),c(!1);try{const _=await Ne.buildAddon({name:m.toLowerCase(),description:g||"A custom command",permission:b,embed:{title:y,description:S||"Hello from your custom command!",color:k}});c(!0),d(_.message||"Restart required."),Dt.success(`Addon ${m}.js created successfully!`)}catch(_){Dt.error(_ instanceof Error?_.message:"Failed to build addon")}finally{a(!1)}};return T?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Addon Builder"}),s.jsx("p",{className:"text-muted-foreground",children:"Visually scaffold a custom slash command addon for your bot."})]}),o?s.jsxs(Ye,{className:"border-green-500/20 bg-green-500/10 text-green-600 dark:text-green-400",children:[s.jsx(x0,{className:"h-4 w-4"}),s.jsxs(qe,{className:"ml-2",children:["Successfully built ",s.jsxs("strong",{children:[m,".js"]}),"! ",l]})]}):null,s.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Ze,{children:[s.jsxs(ut,{children:[s.jsx(dt,{className:"text-lg",children:"Command Details"}),s.jsx(Ot,{children:"Configure how users trigger the command."})]}),s.jsxs(Qe,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{children:"Command Name"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-muted-foreground",children:"/"}),s.jsx(De,{placeholder:"ping",value:m,onChange:_=>p(_.target.value.replace(/[^a-z0-9_-]/gi,"").toLowerCase())})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{children:"Description"}),s.jsx(De,{placeholder:"Replies with a custom embed",value:g,onChange:_=>v(_.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{children:"Required Permission"}),s.jsxs(Ca,{value:b,onValueChange:w,children:[s.jsx(Br,{children:s.jsx(Sa,{})}),s.jsxs($r,{children:[s.jsx(vt,{value:"none",children:"@everyone"}),s.jsx(vt,{value:"Administrator",children:"Administrator"}),s.jsx(vt,{value:"ManageMessages",children:"Manage Messages"}),s.jsx(vt,{value:"ManageGuild",children:"Manage Server"})]})]})]})]})]}),s.jsxs(Ze,{children:[s.jsxs(ut,{children:[s.jsx(dt,{className:"text-lg",children:"Response Embed"}),s.jsx(Ot,{children:"What the bot will reply with."})]}),s.jsxs(Qe,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{children:"Embed Title (Optional)"}),s.jsx(De,{placeholder:"Hello!",value:y,onChange:_=>C(_.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{children:"Embed Description"}),s.jsx(Jd,{placeholder:"Type your message here...",className:"resize-none",rows:4,value:S,onChange:_=>E(_.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{children:"Embed Color"}),s.jsxs(Ca,{value:k,onValueChange:N,children:[s.jsx(Br,{children:s.jsx(Sa,{})}),s.jsxs($r,{children:[s.jsx(vt,{value:"General",children:"Theme General"}),s.jsx(vt,{value:"Success",children:"Theme Success"}),s.jsx(vt,{value:"Warning",children:"Theme Warning"}),s.jsx(vt,{value:"Error",children:"Theme Error"})]})]})]})]})]})]}),s.jsx("div",{className:"space-y-6",children:s.jsxs(Ze,{className:"sticky top-6 border-primary/20",children:[s.jsx(ut,{children:s.jsxs(dt,{className:"text-sm font-medium flex items-center gap-2",children:[s.jsx(ve,{icon:A8,size:16,className:"text-primary"}),"Live Preview"]})}),s.jsx(Qe,{children:s.jsx("div",{className:"rounded-md border bg-[#313338] p-4 font-sans text-sm text-[#dbdee1]",children:s.jsxs("div",{className:"flex gap-4",children:[s.jsx("div",{className:"size-10 shrink-0 rounded-full bg-indigo-500 flex items-center justify-center font-bold text-white",children:"B"}),s.jsxs("div",{className:"flex-1 space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-medium text-white",children:"SupportBot"}),s.jsxs("span",{className:"text-[10px] text-white font-medium uppercase px-1.5 py-0.5 rounded bg-[#5865F2] flex items-center gap-1",children:[s.jsx(x0,{size:10})," BOT"]}),s.jsx("span",{className:"text-xs text-[#949ba4]",children:"Today at 12:00 PM"})]}),s.jsxs("div",{className:"mt-2 rounded bg-[#2b2d31] border-l-4 border-l-[#5865F2] px-4 py-3 max-w-[432px]",children:[y&&s.jsx("div",{className:"mb-1 font-semibold text-white",children:y}),s.jsx("div",{className:"whitespace-pre-wrap",children:S||"Hello from your custom command!"})]})]})]})})}),s.jsx(Sx,{children:s.jsxs(ue,{className:"w-full gap-2",size:"lg",disabled:!m||n,onClick:M,children:[s.jsx(ve,{icon:ds,size:18}),n?"Building...":"Generate Addon"]})})]})})]})]}):s.jsx("div",{className:"flex h-[50vh] items-center justify-center text-muted-foreground",children:"You don't have permission to build addons."})}const Ex="supportbot-dashboard-accent",Pl="#45b46c",qz=["--primary","--ring","--chart-1","--sidebar-primary","--sidebar-ring","--accent","--accent-foreground","--sidebar-accent","--sidebar-accent-foreground"];function Kz(t){const n=Ur(t,Pl),a=parseInt(n.slice(1,3),16)/255,o=parseInt(n.slice(3,5),16)/255,c=parseInt(n.slice(5,7),16)/255,l=Math.max(a,o,c),d=Math.min(a,o,c),m=(l+d)/2;let p=0,g=0;if(l!==d){const v=l-d;switch(g=m>.5?v/(2-l-d):v/(l+d),l){case a:p=((o-c)/v+(o{const o=new FileReader;o.onload=()=>n(String(o.result)),o.onerror=()=>a(new Error("Could not read file")),o.readAsDataURL(t)})}function Jz({canEdit:t}){const[n,a]=f.useState(!1),[o,c]=f.useState(""),[l,d]=f.useState(!1);async function m(){if(t){a(!0),c("");try{const p=await Ne.resetDashboard();c(p.message||"Dashboard reset successfully."),setTimeout(()=>{window.location.href="/setup"},1500)}catch(p){c(p instanceof Error?p.message:"Reset failed"),a(!1)}}}return t?s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"Reset the dashboard to factory settings. This clears the configuration and returns you to the initial setup screen."}),s.jsxs(Qs,{open:l,onOpenChange:d,children:[s.jsx(TM,{asChild:!0,children:s.jsx(ue,{type:"button",variant:"destructive",children:"Reset Dashboard"})}),s.jsxs(hs,{children:[s.jsxs(gs,{children:[s.jsx(xs,{children:"Are you absolutely sure?"}),s.jsx(vs,{children:"This action cannot be undone. This will reset the dashboard to setup mode. You will need to reconnect the Discord OAuth and reconfigure the dashboard owners."})]}),o&&s.jsx("p",{className:"text-sm font-medium text-destructive",children:o}),s.jsxs(Js,{children:[s.jsx(ue,{variant:"outline",onClick:()=>d(!1),disabled:n,children:"Cancel"}),s.jsx(ue,{variant:"destructive",onClick:()=>void m(),disabled:n,children:n?"Resetting...":"Yes, reset dashboard"})]})]})]})]}):null}function eP({canEdit:t}){const{branding:n,setBrandingLocal:a}=Ed(),o=f.useRef(null),[c,l]=f.useState(n.title),[d,m]=f.useState(n.pageTitle),[p,g]=f.useState(!1),[v,b]=f.useState(!1),[w,y]=f.useState("");f.useEffect(()=>{l(n.title),m(n.pageTitle)},[n.title,n.pageTitle]);const C=n.hasFavicon&&n.faviconUrl?`${n.faviconUrl}${n.updatedAt?`?v=${n.updatedAt}`:""}`:null;async function S(){if(t){g(!0),y("");try{const T=await Ne.updateBranding({title:c,pageTitle:d});T.data&&a(T.data),y(T.message||"Branding saved.")}catch(T){y(T instanceof Error?T.message:"Save failed")}finally{g(!1)}}}async function E(T){if(!(!t||!T)){b(!0),y("");try{const M=await Qz(T),_=await Ne.uploadBrandingFavicon(M);_.data&&a(_.data),y(_.message||"Favicon uploaded.")}catch(M){y(M instanceof Error?M.message:"Upload failed")}finally{b(!1),o.current&&(o.current.value="")}}}async function k(){if(t){b(!0),y("");try{const T=await Ne.removeBrandingFavicon();T.data&&a(T.data),y(T.message||"Favicon removed.")}catch(T){y(T instanceof Error?T.message:"Remove failed")}finally{b(!1)}}}const N=c.trim()!==n.title||d.trim()!==n.pageTitle;return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:"Branding Text"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Sidebar title and browser tab title — saved on the server for everyone using this dashboard."})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"brand-title",children:"Sidebar title"}),s.jsx(De,{id:"brand-title",value:c,disabled:!t,maxLength:64,onChange:T=>l(T.target.value),className:"border-border bg-secondary/30",placeholder:"SupportBot"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"brand-page-title",children:"Browser tab title"}),s.jsx(De,{id:"brand-page-title",value:d,disabled:!t,maxLength:80,onChange:T=>m(T.target.value),className:"border-border bg-secondary/30",placeholder:"SupportBot Dashboard"})]})]}),t?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ue,{type:"button",disabled:p||!N,onClick:()=>void S(),children:p?"Saving…":"Save titles"}),w&&N?s.jsx("span",{className:"text-xs text-muted-foreground",children:w}):null]}):null]}),s.jsxs("div",{className:"space-y-4 border-t border-border pt-6",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:"Favicon"}),s.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."})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[s.jsx("div",{className:"flex size-16 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary/30",children:C?s.jsx("img",{src:C,alt:"Favicon preview",className:"size-full object-contain p-2"}):s.jsx(ve,{icon:y8,size:24,className:"text-muted-foreground/50"})}),s.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:!t||v,onChange:T=>{var M;return void E(((M=T.target.files)==null?void 0:M[0])??null)}}),s.jsxs("div",{className:"flex flex-col gap-2",children:[t?s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ue,{type:"button",variant:"secondary",disabled:v,onClick:()=>{var T;return(T=o.current)==null?void 0:T.click()},children:v?"Uploading…":"Upload Favicon"}),n.hasFavicon?s.jsx(ue,{type:"button",variant:"destructive",disabled:v,onClick:()=>void k(),children:"Remove"}):null]}):s.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}),!N&&w?s.jsx("span",{className:"text-xs text-muted-foreground",children:w}):null]})]})]})]})}function tP(){var b,w,y,C,S,E,k,N,T,M,_;const{hasPermission:t}=qt(),n=t("settings.update"),[a,o]=f.useState(!0),[c,l]=f.useState(!1),[d,m]=f.useState(""),[p,g]=f.useState(null);f.useEffect(()=>{Ne.getConfigJson("api").then(R=>{R.data&&g(R.data)}).catch(()=>m("Failed to load API config")).finally(()=>o(!1))},[]);async function v(){var R,L,te,K,I,G,Y,ce,fe,se,P;if(!(!n||!p)){l(!0),m("");try{const Z={"api:API.Port":(R=p.API)==null?void 0:R.Port,"api:API.EmeraldAPIKey":(L=p.API)==null?void 0:L.EmeraldAPIKey,"api:API.TrustProxy":(te=p.API)==null?void 0:te.TrustProxy,"api:API.OAuth.Enabled":(I=(K=p.API)==null?void 0:K.OAuth)==null?void 0:I.Enabled,"api:API.OAuth.ClientId":(Y=(G=p.API)==null?void 0:G.OAuth)==null?void 0:Y.ClientId,"api:API.OAuth.ClientSecret":(fe=(ce=p.API)==null?void 0:ce.OAuth)==null?void 0:fe.ClientSecret,"api:API.OAuth.RedirectUri":(P=(se=p.API)==null?void 0:se.OAuth)==null?void 0:P.RedirectUri};await Ne.updateConfigFields(Z),m("API settings saved and backend restarted.")}catch(Z){m(Z instanceof Error?Z.message:"Save failed")}finally{l(!1)}}}return a?s.jsx("div",{className:"animate-pulse h-32 bg-secondary/20 rounded-md"}):p?s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:"Core API Settings"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Configure the internal API that powers this dashboard."})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{children:"API Port"}),s.jsx(De,{type:"number",value:((b=p.API)==null?void 0:b.Port)||"",disabled:!n,onChange:R=>g({...p,API:{...p.API,Port:parseInt(R.target.value)||3e3}}),className:"border-border bg-secondary/30"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{children:"Emerald API Key"}),s.jsx(De,{type:"password",value:((w=p.API)==null?void 0:w.EmeraldAPIKey)||"",disabled:!n,onChange:R=>g({...p,API:{...p.API,EmeraldAPIKey:R.target.value}}),className:"border-border bg-secondary/30"})]})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsx(kt,{checked:((y=p.API)==null?void 0:y.TrustProxy)||!1,disabled:!n,onCheckedChange:R=>g({...p,API:{...p.API,TrustProxy:R}})}),s.jsx(_e,{className:"text-sm",children:"Trust Proxy (Enable if using Cloudflare/Nginx)"})]})]}),s.jsxs("div",{className:"space-y-4 border-t border-border pt-6",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:"OAuth Authentication"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Discord application credentials for dashboard login."})]}),s.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[s.jsx(kt,{checked:((S=(C=p.API)==null?void 0:C.OAuth)==null?void 0:S.Enabled)||!1,disabled:!n,onCheckedChange:R=>{var L;return g({...p,API:{...p.API,OAuth:{...(L=p.API)==null?void 0:L.OAuth,Enabled:R}}})}}),s.jsx(_e,{className:"text-sm",children:"Enable OAuth"})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{children:"Client ID"}),s.jsx(De,{value:((k=(E=p.API)==null?void 0:E.OAuth)==null?void 0:k.ClientId)||"",disabled:!n,onChange:R=>{var L;return g({...p,API:{...p.API,OAuth:{...(L=p.API)==null?void 0:L.OAuth,ClientId:R.target.value}}})},className:"border-border bg-secondary/30"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{children:"Client Secret"}),s.jsx(De,{type:"password",value:((T=(N=p.API)==null?void 0:N.OAuth)==null?void 0:T.ClientSecret)||"",disabled:!n,onChange:R=>{var L;return g({...p,API:{...p.API,OAuth:{...(L=p.API)==null?void 0:L.OAuth,ClientSecret:R.target.value}}})},className:"border-border bg-secondary/30"})]}),s.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[s.jsx(_e,{children:"Redirect URI"}),s.jsx(De,{value:((_=(M=p.API)==null?void 0:M.OAuth)==null?void 0:_.RedirectUri)||"",disabled:!n,onChange:R=>{var L;return g({...p,API:{...p.API,OAuth:{...(L=p.API)==null?void 0:L.OAuth,RedirectUri:R.target.value}}})},className:"border-border bg-secondary/30"}),s.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Must match the OAuth2 callback URL registered in the Discord Developer Portal exactly."})]})]})]}),n?s.jsxs("div",{className:"flex items-center gap-2 border-t border-border pt-6",children:[s.jsx(ue,{type:"button",disabled:c,onClick:()=>void v(),children:c?"Saving…":"Save API Config"}),d?s.jsx("span",{className:"text-xs text-muted-foreground",children:d}):null]}):null]}):null}function nP(){const{hasPermission:t}=qt(),n=t("settings.update"),[a,o]=f.useState(null),[c,l]=f.useState(!0),[d,m]=f.useState(!1),[p,g]=f.useState(""),[v,b]=f.useState(""),[w,y]=f.useState(()=>d5()??Pl),[C,S]=f.useState(""),[E,k]=f.useState("appearance"),N=f.useCallback(async()=>{l(!0),g("");try{const M=await Ne.checkForUpdates();M.data&&o(M.data)}catch(M){g(M instanceof Error?M.message:"Could not check for updates")}finally{l(!1)}},[]);f.useEffect(()=>{N()},[N]);async function T(M){if(M.updateAvailable){m(!0),g(""),b("");try{const _=await Ne.runUpdate(M.id,M.latest,M.zipUrl);b(_.message||"Update installed. Restart your server (stop and run npm start again) to finish applying changes."),await N()}catch(_){g(_ instanceof Error?_.message:"Update failed")}finally{m(!1)}}}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Settings"}),s.jsx("p",{className:"text-muted-foreground",children:"Application updates and maintenance — config files are edited under each module in the sidebar."})]}),s.jsxs("div",{className:"flex flex-col md:flex-row gap-8 items-start",children:[s.jsx("aside",{className:"w-full md:w-56 shrink-0 sticky top-6",children:s.jsxs("nav",{className:"flex flex-row md:flex-col overflow-x-auto space-x-2 md:space-x-0 md:space-y-1 pb-2 md:pb-0",children:[s.jsx(ue,{variant:E==="appearance"?"secondary":"ghost",className:"justify-start w-full",onClick:()=>k("appearance"),children:"Appearance"}),s.jsx(ue,{variant:E==="api"?"secondary":"ghost",className:"justify-start w-full",onClick:()=>k("api"),children:"API Config"}),s.jsx(ue,{variant:E==="updates"?"secondary":"ghost",className:"justify-start w-full",onClick:()=>k("updates"),children:"Update Checker"}),n&&s.jsx(ue,{variant:"ghost",className:`justify-start w-full text-destructive hover:bg-destructive/10 hover:text-destructive ${E==="danger"?"bg-destructive/10 border-l-2 border-destructive rounded-l-none":""}`,onClick:()=>k("danger"),children:"Danger Zone"})]})}),s.jsxs("main",{className:"flex-1 w-full max-w-4xl space-y-6",children:[E==="appearance"&&s.jsx("div",{className:"space-y-6",children:s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{children:[s.jsx(dt,{className:"text-lg",children:"Dashboard appearance"}),s.jsx(Ot,{children:"Customise branding for all users, and pick an accent colour for this browser only."})]}),s.jsxs(Qe,{className:"space-y-4",children:[s.jsx(eP,{canEdit:n}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("p",{className:"mb-1 text-sm font-medium",children:"Accent colour"}),s.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:"Buttons, links, and highlights — saved in this browser only."}),s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(tf,{value:w,onChange:M=>{y(M),n2(M),S("Accent updated.")}}),s.jsx(De,{id:"accent-colour",value:w,onChange:M=>y(M.target.value),onBlur:()=>{const M=Ur(w,Pl);y(M),n2(M),S("Accent updated.")},className:"w-32 border-border bg-secondary/30 font-mono uppercase",maxLength:7})]}),s.jsx(ue,{type:"button",variant:"outline",onClick:()=>{Xz(),y(Pl),S("Reset to default purple.")},children:"Reset to default"})]}),s.jsxs("div",{className:"flex flex-wrap gap-2 text-sm mt-5",children:[s.jsx("span",{className:"rounded-md bg-primary px-3 py-1.5 font-medium text-primary-foreground",children:"Primary button"}),s.jsx("span",{className:"rounded-md bg-primary/15 px-3 py-1.5 text-primary",children:"Highlight"}),s.jsx("span",{className:"rounded-md bg-accent px-3 py-1.5 text-accent-foreground",children:"Accent surface"})]}),C?s.jsx("p",{className:"text-xs text-muted-foreground",children:C}):null]})]})]})}),E==="danger"&&n&&s.jsxs(Ze,{className:"border-destructive/50 bg-destructive/5",children:[s.jsxs(ut,{children:[s.jsx(dt,{className:"text-lg text-destructive",children:"Danger Zone"}),s.jsx(Ot,{className:"text-destructive/80",children:"Destructive actions that reset or permanently alter your dashboard."})]}),s.jsx(Qe,{children:s.jsx(Jz,{canEdit:n})})]}),E==="api"&&s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{children:[s.jsx(dt,{className:"text-lg",children:"API Configuration"}),s.jsx(Ot,{children:"Configure the internal API settings, Emerald API key, and OAuth."})]}),s.jsx(Qe,{children:s.jsx(tP,{})})]}),E==="updates"&&s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{children:[s.jsx(dt,{className:"text-lg",children:"Software updates"}),s.jsx(Ot,{children:"Manage updates for the bot and dashboard."})]}),s.jsxs(Qe,{className:"space-y-4",children:[c?s.jsx(Be,{className:"h-24 w-full"}):a&&a.length>0?s.jsx("div",{className:"space-y-4",children:a.map(M=>s.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-secondary/20 p-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("p",{className:"font-medium text-sm",children:[s.jsx("a",{href:M.repository,target:"_blank",rel:"noreferrer",className:"text-primary underline-offset-4 hover:underline",children:M.name})," ","(",M.branch," branch)"]}),s.jsxs("div",{className:"flex gap-x-4 text-sm",children:[s.jsxs("p",{children:[s.jsx("span",{className:"text-muted-foreground",children:"Installed: "}),s.jsxs("span",{className:"font-mono font-medium",children:["v",M.current]})]}),s.jsxs("p",{children:[s.jsx("span",{className:"text-muted-foreground",children:"Latest: "}),s.jsxs("span",{className:"font-mono font-medium",children:["v",M.latest]})]})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[M.updateAvailable?s.jsx("p",{className:"text-sm text-amber-500",children:"A newer version is available. Update downloads files while keeping your Configs and Data."}):s.jsx("p",{className:"text-sm text-emerald-500",children:"You are on the latest release."}),M.updateAvailable&&n?s.jsxs(ue,{type:"button",size:"sm",onClick:()=>void T(M),disabled:d,children:[d?s.jsx(ve,{icon:_2,size:16,className:"mr-2 animate-spin"}):s.jsx(ve,{icon:Cd,size:16,className:"mr-2"}),d?"Installing…":"Update now"]}):null,M.updateAvailable&&!n?s.jsx("p",{className:"text-xs text-muted-foreground",children:"You cannot install updates with your role."}):null]})]},M.id))}):null,p?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:p})}):null,v?s.jsx(Ye,{children:s.jsx(qe,{children:v})}):null,s.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:s.jsxs(ue,{type:"button",variant:"outline",onClick:N,disabled:c||d,children:[s.jsx(ve,{icon:ur,size:16,className:"mr-2"}),"Check again"]})})]})]})]})]})]})}function kx(t){const[n,a]=f.useState(!1),o=f.useRef(t);return o.current=t,f.useEffect(()=>{let c=null,l=null;const d=()=>{c=new EventSource("/api/stream"),c.onopen=()=>{a(!0)},c.addEventListener("connected",()=>{a(!0)}),c.addEventListener("metrics",m=>{var p,g;try{const v=JSON.parse(m.data);(g=(p=o.current).onMetrics)==null||g.call(p,v)}catch{}}),c.addEventListener("log",m=>{var p,g;try{const v=JSON.parse(m.data);(g=(p=o.current).onLog)==null||g.call(p,v)}catch{}}),c.addEventListener("ticket_message",m=>{var p,g;try{const v=JSON.parse(m.data);(g=(p=o.current).onTicketMessage)==null||g.call(p,v)}catch{}}),c.addEventListener("ticket_message_deleted",m=>{var p,g;try{const v=JSON.parse(m.data);(g=(p=o.current).onTicketMessageDeleted)==null||g.call(p,v)}catch{}}),c.addEventListener("ticket_message_updated",m=>{var p,g;try{const v=JSON.parse(m.data);(g=(p=o.current).onTicketMessageUpdated)==null||g.call(p,v)}catch{}}),c.addEventListener("ticket_created",m=>{var p,g;try{const v=JSON.parse(m.data);(g=(p=o.current).onTicketCreated)==null||g.call(p,v)}catch{}}),c.addEventListener("ticket_closed",m=>{var p,g;try{const v=JSON.parse(m.data);(g=(p=o.current).onTicketClosed)==null||g.call(p,v)}catch{}}),c.onerror=()=>{a(!1),c==null||c.close(),l=window.setTimeout(d,4e3)}};return d(),()=>{l&&window.clearTimeout(l),c&&c.close()}},[]),{connected:n}}function Et({label:t,value:n,mono:a=!1}){return s.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:[s.jsx("dt",{className:"text-sm text-muted-foreground",children:t}),s.jsx("dd",{className:`text-sm font-medium text-foreground ${a?"font-mono text-xs sm:text-sm":""}`,children:n})]})}const rP={ok:"Healthy",missing_config:"Guild ID not set",not_in_guild:"Not in configured server",extra_guilds:"Extra servers joined",offline:"Bot offline"};function aP(t){return t==="ok"?"text-emerald-500":t==="offline"?"text-destructive":"text-amber-500"}function sP(){var E;const{stats:t,loading:n,error:a,refresh:o}=kd(),[c,l]=f.useState(null),[d,m]=f.useState(null),[p,g]=f.useState(!1),[v,b]=f.useState(null),{connected:w}=kx({onMetrics:k=>{b(k)}}),y=f.useCallback(async()=>{const[k,N]=await Promise.all([Ne.getGuildStatus().catch(()=>null),Ne.health().catch(()=>null)]);k!=null&&k.data&&l(k.data),N!=null&&N.success&&N.data&&m({dashboard:N.data.dashboard,botReady:N.data.botReady,oauthEnabled:N.data.oauthEnabled,setupComplete:N.data.setupComplete})},[]);f.useEffect(()=>{y()},[y]);async function C(){g(!0);try{await Promise.all([o(),y()])}finally{g(!1)}}if(n&&!t)return s.jsxs("div",{className:"space-y-6",children:[s.jsx(Be,{className:"h-10 w-64"}),s.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[s.jsx(Be,{className:"h-56 rounded-2xl"}),s.jsx(Be,{className:"h-56 rounded-2xl"})]})]});if(a||!t)return s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:a||"Could not load system details."})});const S=t.bot.ping<200;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ue,{asChild:!0,variant:"ghost",size:"sm",className:"-ml-2 h-8 px-2 text-muted-foreground",children:s.jsxs(Jt,{to:"/",children:[s.jsx(ve,{icon:T2,size:16,className:"mr-1.5"}),"Back to dashboard"]})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"System details"}),s.jsx("p",{className:"text-muted-foreground",children:"Live bot, host, and dashboard status — refreshed every 30 seconds."})]})]}),s.jsxs(ue,{type:"button",variant:"outline",disabled:p,onClick:()=>void C(),children:[s.jsx(ve,{icon:ur,size:16,className:"mr-2"}),p?"Refreshing…":"Refresh now"]})]}),s.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{children:[s.jsx(dt,{className:"text-lg",children:"Discord bot"}),s.jsx(Ot,{children:"Connection and identity"})]}),s.jsxs(Qe,{children:[s.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[s.jsxs(bs,{className:"size-12",children:[s.jsx(eo,{src:t.bot.avatar,alt:t.bot.username}),s.jsx(ys,{children:"SB"})]}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold",children:t.bot.username}),s.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:t.bot.id})]})]}),s.jsxs("dl",{children:[s.jsx(Et,{label:"Version",value:`v${t.bot.version}`,mono:!0}),s.jsx(Et,{label:"Gateway latency",value:s.jsxs("span",{className:S?"text-emerald-500":"text-amber-500",children:[t.bot.ping," ms"]})}),s.jsx(Et,{label:"Process uptime",value:fg(t.bot.uptime)}),s.jsx(Et,{label:"Connected servers",value:t.servers.toLocaleString()}),s.jsx(Et,{label:"Members tracked",value:t.users.toLocaleString()}),t.bot.inviteUrl?s.jsx(Et,{label:"Invite link",value:s.jsx("a",{href:t.bot.inviteUrl,target:"_blank",rel:"noreferrer",className:"text-primary underline-offset-4 hover:underline",children:"Open in Discord"})}):null]})]})]}),s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsx(dt,{className:"text-lg",children:"Host machine"}),s.jsx(Ot,{children:"Server resources running this instance"})]}),s.jsxs(Fn,{variant:w?"default":"outline",className:"text-xs",children:[s.jsx("span",{className:`mr-1.5 inline-block h-2 w-2 rounded-full ${w?"bg-emerald-500 animate-pulse":"bg-muted"}`}),w?"Live Stream":"Polling"]})]}),s.jsx(Qe,{children:s.jsxs("dl",{children:[s.jsx(Et,{label:"Memory used",value:v?`${(v.ram_used_mb/1024).toFixed(2)} GB / ${(v.ram_total_mb/1024).toFixed(2)} GB`:`${t.hosting.ram_used} / ${t.hosting.ram_total}`}),s.jsx(Et,{label:"Memory usage",value:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:(v?v.ram_percent:t.hosting.ram_percent)>85?"text-amber-500 font-bold":"text-foreground font-medium",children:[v?v.ram_percent:t.hosting.ram_percent,"%"]}),s.jsx("div",{className:"w-24 h-2 bg-secondary rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-primary transition-all duration-500",style:{width:`${v?v.ram_percent:t.hosting.ram_percent}%`}})})]})}),s.jsx(Et,{label:"CPU load (1 min avg)",value:v?String(v.cpu_load):t.hosting.cpu_load,mono:!0}),s.jsx(Et,{label:"Host uptime",value:t.hosting.uptime})]})})]}),s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{children:[s.jsx(dt,{className:"text-lg",children:"Tickets"}),s.jsx(Ot,{children:"Database snapshot"})]}),s.jsx(Qe,{children:s.jsxs("dl",{children:[s.jsx(Et,{label:"Total tickets",value:t.tickets.total}),s.jsx(Et,{label:"Open",value:s.jsx("span",{className:"text-primary",children:t.tickets.open})}),s.jsx(Et,{label:"Closed",value:t.tickets.closed}),s.jsx(Et,{label:"Transcripts",value:s.jsx(Jt,{to:"/transcripts",className:"text-primary underline-offset-4 hover:underline",children:"Browse archive"})})]})})]}),s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{children:[s.jsx(dt,{className:"text-lg",children:"Guild health"}),s.jsx(Ot,{children:"Configured server and membership"})]}),s.jsx(Qe,{children:c?s.jsxs("dl",{children:[s.jsx(Et,{label:"Status",value:s.jsx("span",{className:aP(c.status),children:rP[c.status]})}),s.jsx(Et,{label:"Configured guild ID",value:c.configuredGuildId||"Not set",mono:!0}),c.configuredGuild?s.jsx(Et,{label:"Configured server",value:`${c.configuredGuild.name} (${((E=c.configuredGuild.memberCount)==null?void 0:E.toLocaleString())??"?"} members)`}):null,c.message?s.jsx("div",{className:"mt-3 rounded-lg border border-border bg-secondary/30 px-3 py-2 text-sm text-muted-foreground",children:c.message}):null,c.extraGuilds.length>0?s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Extra servers"}),s.jsx("ul",{className:"space-y-1 text-sm",children:c.extraGuilds.map(k=>s.jsxs("li",{className:"font-mono text-xs",children:[k.name," · ",k.id]},k.id))})]}):null]}):s.jsx(Be,{className:"h-24 w-full"})})]})]}),s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{children:[s.jsx(dt,{className:"text-lg",children:"Dashboard services"}),s.jsx(Ot,{children:"API and authentication"})]}),s.jsx(Qe,{children:d?s.jsxs("dl",{className:"max-w-xl",children:[s.jsx(Et,{label:"Dashboard UI",value:d.dashboard?"Available":"Missing build"}),s.jsx(Et,{label:"Bot connection",value:d.botReady?"Online":"Starting or offline"}),s.jsx(Et,{label:"Discord OAuth",value:d.oauthEnabled?"Configured":"Not configured"}),s.jsx(Et,{label:"Initial setup",value:d.setupComplete?"Complete":"Incomplete"}),s.jsx(Et,{label:"Software updates",value:s.jsx(Jt,{to:"/settings",className:"text-primary underline-offset-4 hover:underline",children:"Open settings"})}),s.jsx(Et,{label:"Logs",value:s.jsx(Jt,{to:"/logs",className:"text-primary underline-offset-4 hover:underline",children:"View log files"})})]}):s.jsx(Be,{className:"h-32 w-full max-w-xl"})})]}),t.modules?s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{children:[s.jsx(dt,{className:"text-lg",children:"Module setup status"}),s.jsx(Ot,{children:"Which features are configured and active"})]}),s.jsx(Qe,{children:s.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:ii.map(k=>{const N=Kh(k.id,t.modules);return s.jsxs(Jt,{to:k.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:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm font-medium",children:k.title}),s.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:N.subtitle})]}),s.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:c5[N.status]})]},k.id)})})})]}):null]})}function oP(t){if(!t)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?t:n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}const iP=[{id:"all",label:"All"},{id:"Output",label:"Output"},{id:"Warn",label:"Warn"},{id:"Error",label:"Error"}],lP=["Output","Warn","Error"],cP={Output:"text-foreground/90",Warn:"text-amber-400",Error:"text-rose-400"},uP={Output:"bg-muted text-muted-foreground",Warn:"bg-amber-500/15 text-amber-400",Error:"bg-rose-500/15 text-rose-400"},gd=2e3,dP=2e3;function Wh(t,n){return`${t.type}-${t.timestamp??"na"}-${n}-${t.message.slice(0,32)}`}function fP(t,n,a){const o=a?[]:t,c=new Set(o.map((m,p)=>Wh(m,p))),l=[];for(let m=0;mgd?d.slice(d.length-gd):d}function mP(){const[t,n]=f.useState([]),[a,o]=f.useState(!0),[c,l]=f.useState(""),[d,m]=f.useState(!1),[p,g]=f.useState(!0),[v,b]=f.useState("all"),[w,y]=f.useState(""),[C,S]=f.useState(!0),[E,k]=f.useState(""),N=f.useRef(null),T=f.useRef(null),M=f.useRef(d);M.current=d;const _=f.useMemo(()=>v==="all"?lP:[v],[v]),R=f.useCallback(I=>{M.current||v!=="all"&&I.type!==v||(n(G=>{const Y=[...G,I];return Y.length>gd?Y.slice(Y.length-gd):Y}),S(!0))},[v]);kx({onLog:R});const L=f.useCallback(async I=>{var ce,fe;const G=await Ne.getLogs({types:_,cursor:I?void 0:N.current??void 0,tail:I?500:0}),Y=((ce=G.data)==null?void 0:ce.entries)??[];return N.current=((fe=G.data)==null?void 0:fe.cursor)??{},n(se=>fP(se,Y,I)),Y.length},[_]),te=f.useCallback(async()=>{var I;o(!0),l(""),N.current=null;try{const ce=(((I=(await Ne.getLogsMeta()).data)==null?void 0:I.files)??[]).filter(fe=>fe.file).map(fe=>`${fe.type}: ${fe.file}`).join(" · ");k(ce||"No log files yet — output appears when the bot runs."),await L(!0),S(!0)}catch(G){l(G instanceof Error?G.message:"Failed to load logs"),S(!1)}finally{o(!1)}},[L]);f.useEffect(()=>{te()},[te]),f.useEffect(()=>{if(d||a)return;const I=window.setInterval(async()=>{if(!M.current)try{await L(!1),S(!0),l("")}catch(G){S(!1),l(G instanceof Error?G.message:"Live update failed")}},dP);return()=>window.clearInterval(I)},[d,a,L]),f.useEffect(()=>{if(!p||d)return;const I=T.current;I&&(I.scrollTop=I.scrollHeight)},[t,p,d]);const K=f.useMemo(()=>t.filter(I=>{var Y;if(v!=="all"&&I.type!==v)return!1;if(!w.trim())return!0;const G=w.toLowerCase();return I.message.toLowerCase().includes(G)||(((Y=I.timestamp)==null?void 0:Y.toLowerCase().includes(G))??!1)}),[t,v,w]);return s.jsxs("div",{className:"flex h-[calc(100svh-8rem)] min-h-[480px] flex-col gap-4",children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Logs"}),s.jsx("p",{className:"text-muted-foreground",children:"Live bot output — updates every 2 seconds"}),E?s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:E}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:pe("size-2 rounded-full",C&&!d?"animate-pulse bg-emerald-500":"bg-muted-foreground")}),s.jsx("span",{className:"text-xs text-muted-foreground",children:d?"Paused":C?"Live":"Disconnected"})]})]}),c?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:c})}):null,s.jsxs(Ze,{className:"flex min-h-0 flex-1 flex-col border-border bg-card",children:[s.jsxs(ut,{className:"shrink-0 space-y-4 border-b border-border pb-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs(dt,{className:"text-base font-medium",children:["Console",a?null:s.jsxs("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:[K.length," line",K.length===1?"":"s"]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border px-2 py-1",children:[s.jsx(kt,{id:"auto-scroll",checked:p,onCheckedChange:g}),s.jsx(_e,{htmlFor:"auto-scroll",className:"text-xs font-normal",children:"Auto-scroll"})]}),s.jsxs(ue,{type:"button",variant:"outline",size:"sm",onClick:()=>m(I=>!I),children:[s.jsx(ve,{icon:d?k8:E8,size:16,className:"mr-1.5"}),d?"Resume":"Pause"]}),s.jsxs(ue,{type:"button",variant:"outline",size:"sm",onClick:()=>{n([]),te()},disabled:a,children:[s.jsx(ve,{icon:ur,size:16,className:"mr-1.5"}),"Refresh"]})]})]}),s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[s.jsx("div",{className:"flex flex-wrap gap-1 rounded-xl bg-secondary/50 p-1",children:iP.map(I=>s.jsx(ue,{type:"button",variant:v===I.id?"secondary":"ghost",size:"sm",className:"h-8 rounded-lg text-xs",onClick:()=>b(I.id),children:I.label},I.id))}),s.jsxs("div",{className:"relative flex-1 sm:max-w-xs",children:[s.jsx(ve,{icon:ji,size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx(De,{placeholder:"Filter lines…",value:w,onChange:I=>y(I.target.value),className:"h-9 pl-9"})]})]})]}),s.jsx(Qe,{className:"min-h-0 flex-1 p-0",children:a?s.jsx("div",{className:"space-y-2 p-4",children:Array.from({length:8}).map((I,G)=>s.jsx(Be,{className:"h-4 w-full"},G))}):s.jsx("div",{ref:T,className:"h-full max-h-[calc(100svh-18rem)] overflow-y-auto bg-[#0d0d12] p-4 font-mono text-[13px] leading-relaxed",children:K.length===0?s.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)."}):s.jsx("ul",{className:"space-y-1",children:K.map((I,G)=>s.jsxs("li",{className:"flex gap-2 rounded px-1 py-0.5 hover:bg-white/[0.03]",children:[s.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:oP(I.timestamp)}),s.jsx("span",{className:pe("shrink-0 rounded px-1.5 py-0 text-[10px] font-semibold uppercase",uP[I.type]),children:I.type}),s.jsx("span",{className:pe("min-w-0 flex-1 whitespace-pre-wrap break-words",cP[I.type]),children:I.message||" "})]},Wh(I,G)))})})})]})]})}const pP=[{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; }"}]}],hP=450;function gP(t,n){return n&&t!=="viewer"}function xP(){const{user:t,hasPermission:n}=qt(),a=!gP(t==null?void 0:t.role,n("transcripts")),[o,c]=f.useState(null),[l,d]=f.useState(null),[m,p]=f.useState(!0),[g,v]=f.useState(!1),[b,w]=f.useState(""),[y,C]=f.useState(""),[S,E]=f.useState(""),[k,N]=f.useState(!1),T=f.useRef(null),M=f.useCallback(async()=>{var K;p(!0),w(""),C("");try{const G=(await Ne.getTranscriptTemplate()).data??null;if(G){const Y={...G,Typography:{...G.Typography,FontFamily:kS((K=G.Typography)==null?void 0:K.FontFamily)}};c(Y),d(structuredClone(Y))}}catch(I){w(I instanceof Error?I.message:"Failed to load template")}finally{p(!1)}},[]);f.useEffect(()=>{M()},[M]);const _=f.useCallback(async K=>{N(!0);try{const I=await Ne.previewTranscriptTemplate(K);E(I)}catch{E("

Preview failed to load.

")}finally{N(!1)}},[]);f.useEffect(()=>{if(o)return T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{_(o)},hP),()=>{T.current&&clearTimeout(T.current)}},[o,_]);function R(K,I){c(G=>G&&Gn(G,K,I))}async function L(){if(!(a||!o)){v(!0),w(""),C("");try{const K=await Ne.saveTranscriptTemplate(o);C(K.message||"Saved."),d(structuredClone(o))}catch(K){w(K instanceof Error?K.message:"Save failed")}finally{v(!1)}}}const te=o&&l&&JSON.stringify(o)!==JSON.stringify(l);return m?s.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[s.jsx(Be,{className:"h-96 rounded-xl"}),s.jsx(Be,{className:"h-96 rounded-xl"})]}):o?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"Customize how new ticket transcripts look. Existing saved transcripts are not changed."}),s.jsxs("div",{className:"flex items-center gap-2",children:[te?s.jsx("span",{className:"text-xs text-amber-500",children:"Unsaved changes"}):null,a?s.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}):s.jsxs(ue,{size:"sm",onClick:L,disabled:g||!te,children:[s.jsx(ve,{icon:Sd,size:16,className:"mr-1.5"}),g?"Saving…":"Save appearance"]})]})]}),b?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:b})}):null,y?s.jsx(Ye,{className:"border-primary/30 bg-primary/10 text-primary",children:s.jsx(qe,{children:y})}):null,s.jsxs("div",{className:"grid min-h-0 gap-4 xl:grid-cols-[minmax(320px,420px)_1fr]",children:[s.jsx(vP,{data:o,readOnly:a,onPatch:R}),s.jsxs(Ze,{className:"flex min-h-[520px] flex-col overflow-hidden border-border bg-card",children:[s.jsxs(ut,{className:"pb-2",children:[s.jsx(dt,{className:"text-base",children:"Live preview"}),s.jsxs(Ot,{children:["Sample ticket with your current settings",k?" · updating…":""]})]}),s.jsx(Qe,{className:"min-h-0 flex-1 p-4 pt-0",children:s.jsx("iframe",{title:"Transcript template preview",srcDoc:S,className:pe("h-[min(640px,calc(100svh-14rem))] w-full rounded-lg border border-border bg-background",k&&"opacity-60"),sandbox:"allow-same-origin"})})]})]})]}):s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:b||"Failed to load template"})})}function vP({data:t,readOnly:n,onPatch:a}){return s.jsx("div",{className:"max-h-[min(720px,calc(100svh-12rem))] space-y-4 overflow-y-auto pr-1",children:pP.map(o=>s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{className:"pb-3",children:[s.jsx(dt,{className:"text-base",children:o.title}),o.description?s.jsx(Ot,{children:o.description}):null]}),s.jsx(Qe,{className:"grid gap-4 sm:grid-cols-2",children:o.fields.map(c=>s.jsx("div",{className:c.type==="textarea"?"sm:col-span-2":"",children:s.jsx(pd,{field:c,value:Fr(t,c.path),readOnly:n,onChange:l=>a(c.path,l)})},c.path))})]},o.title))})}function bP(t,n){return n&&t!=="viewer"}function yP(){const{user:t,hasPermission:n}=qt(),a=!bP(t==null?void 0:t.role,n("transcripts")),[o,c]=f.useState(null),[l,d]=f.useState(!0),[m,p]=f.useState(!1),[g,v]=f.useState(!1),[b,w]=f.useState(""),[y,C]=f.useState(""),S=f.useCallback(async()=>{var N,T,M;d(!0),w(""),C("");try{const R=(await Ne.getTranscriptSettings()).data;R&&c({autoDelete:{enabled:!!((N=R.autoDelete)!=null&&N.enabled),afterDays:((T=R.autoDelete)==null?void 0:T.afterDays)??30},publicAccess:{enabled:!!((M=R.publicAccess)!=null&&M.enabled)}})}catch(_){w(_ instanceof Error?_.message:"Failed to load settings")}finally{d(!1)}},[]);f.useEffect(()=>{S()},[S]);async function E(){if(!(!o||a)){p(!0),w(""),C("");try{const N=await Ne.updateTranscriptSettings(o);N.data&&c({autoDelete:{enabled:N.data.autoDelete.enabled,afterDays:N.data.autoDelete.afterDays},publicAccess:{enabled:N.data.publicAccess.enabled}}),C(N.message??"Settings saved.")}catch(N){w(N instanceof Error?N.message:"Failed to save settings")}finally{p(!1)}}}async function k(){var N,T;if(!a){v(!0),w(""),C("");try{const M=await Ne.purgeTranscripts();C(M.message??((N=M.data)!=null&&N.skipped?"Auto-delete is disabled.":`Removed ${((T=M.data)==null?void 0:T.deleted)??0} transcript(s).`))}catch(M){w(M instanceof Error?M.message:"Purge failed")}finally{v(!1)}}}return l?s.jsxs("div",{className:"space-y-4",children:[s.jsx(Be,{className:"h-40 w-full rounded-xl"}),s.jsx(Be,{className:"h-40 w-full rounded-xl"})]}):o?s.jsxs("div",{className:"mx-auto max-w-2xl space-y-4",children:[a?s.jsx(Ye,{children:s.jsx(qe,{children:"You have view-only access. An admin or editor can change these settings."})}):null,b?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:b})}):null,y?s.jsx(Ye,{children:s.jsx(qe,{children:y})}):null,s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{children:[s.jsx(dt,{className:"text-base",children:"Auto-delete"}),s.jsx(Ot,{children:"Remove transcript files automatically after they reach a certain age. The server checks hourly and whenever you open the library."})]}),s.jsxs(Qe,{className:"space-y-4",children:[s.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 size-4 rounded border-border accent-primary",checked:o.autoDelete.enabled,disabled:a,onChange:N=>c(T=>T&&{...T,autoDelete:{...T.autoDelete,enabled:N.target.checked}})}),s.jsxs("span",{className:"text-sm",children:[s.jsx("span",{className:"font-medium",children:"Enable auto-delete"}),s.jsx("span",{className:"mt-0.5 block text-muted-foreground",children:"Deletes HTML files in Data/Transcripts based on last modified time."})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-sm font-medium",htmlFor:"transcript-after-days",children:"Delete after (days)"}),s.jsx(De,{id:"transcript-after-days",type:"number",min:1,max:3650,disabled:a||!o.autoDelete.enabled,value:o.autoDelete.afterDays,onChange:N=>c(T=>T&&{...T,autoDelete:{...T.autoDelete,afterDays:Math.min(3650,Math.max(1,parseInt(N.target.value,10)||1))}}),className:"max-w-[8rem]"})]}),s.jsxs(ue,{type:"button",variant:"outline",size:"sm",disabled:a||g,onClick:()=>void k(),children:[s.jsx(ve,{icon:ur,size:16,className:pe(g&&"animate-spin")}),"Run cleanup now"]})]})]}),s.jsxs(Ze,{className:"border-border bg-card",children:[s.jsxs(ut,{children:[s.jsx(dt,{className:"text-base",children:"Public transcripts"}),s.jsxs(Ot,{children:["When enabled, anyone with the link can view a transcript at"," ",s.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."]})]}),s.jsx(Qe,{children:s.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 size-4 rounded border-border accent-primary",checked:o.publicAccess.enabled,disabled:a,onChange:N=>c(T=>T&&{...T,publicAccess:{enabled:N.target.checked}})}),s.jsxs("span",{className:"text-sm",children:[s.jsx("span",{className:"font-medium",children:"Allow public transcript URLs"}),s.jsx("span",{className:"mt-0.5 block text-muted-foreground",children:"Dashboard preview and download still require login."})]})]})})]}),a?null:s.jsxs(ue,{type:"button",disabled:m,onClick:()=>void E(),children:[s.jsx(ve,{icon:Sd,size:16}),m?"Saving…":"Save settings"]})]}):s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:"Could not load transcript settings."})})}function wP(t,n){return n&&t!=="viewer"}function r2(t){return t==null?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function a2(t){const n=new Date(t);return Number.isNaN(n.getTime())?t:n.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function jP(){var $;const{user:t,hasPermission:n}=qt(),a=wP(t==null?void 0:t.role,n("transcripts")),[o,c]=f.useState("browse"),[l,d]=f.useState([]),[m,p]=f.useState(null),[g,v]=f.useState(!0),[b,w]=f.useState(""),[y,C]=f.useState(""),[S,E]=f.useState(""),[k,N]=f.useState(0),[T,M]=f.useState(!1),[_,R]=f.useState(!1),[L,te]=f.useState(!1),[K,I]=f.useState(!1),G=f.useCallback(async()=>{v(!0),C("");try{const X=(await Ne.listTranscripts()).data??[];d(X),p(xe=>{var q;return xe&&X.some(ge=>ge.id===xe)?xe:((q=X[0])==null?void 0:q.id)??null})}catch(H){C(H instanceof Error?H.message:"Failed to load transcripts")}finally{v(!1)}},[]);f.useEffect(()=>{G()},[G]),f.useEffect(()=>{o==="browse"&&Ne.getTranscriptSettings().then(H=>{var X,xe;te(!!((xe=(X=H.data)==null?void 0:X.publicAccess)!=null&&xe.enabled))}).catch(()=>te(!1))},[o]);const Y=f.useMemo(()=>{if(!S.trim())return l;const H=S.toLowerCase();return l.filter(X=>X.id.includes(H)||X.filename.toLowerCase().includes(H)||X.ticketName&&X.ticketName.toLowerCase().includes(H))},[l,S]),ce=f.useMemo(()=>l.find(H=>H.id===m)??null,[l,m]),fe=m?`/api/system/transcripts/${encodeURIComponent(m)}/view`:null,se=m?`/api/system/transcripts/${encodeURIComponent(m)}/download`:null,P=m&&L?`${window.location.origin}/transcripts/${encodeURIComponent(m)}`:null;function Z(H){w(""),p(H),N(X=>X+1)}function ae(){fe&&window.open(fe,"_blank","noopener,noreferrer")}function re(){P&&window.open(P,"_blank","noopener,noreferrer")}async function V(){if(P)try{await navigator.clipboard.writeText(P),I(!0),window.setTimeout(()=>I(!1),2e3)}catch{w("Could not copy link to clipboard.")}}async function O(){var X;if(!m||!a)return;const H=((X=ce==null?void 0:ce.ticketName)==null?void 0:X.trim())||`channel ${m}`;if(window.confirm(`Delete the transcript for ${H}? This cannot be undone.`)){R(!0),w("");try{await Ne.deleteTranscript(m),await G()}catch(xe){w(xe instanceof Error?xe.message:"Failed to delete transcript")}finally{R(!1)}}}async function D(){if(!(!se||!ce)){M(!0),w("");try{const H=await fetch(se,{credentials:"include"});if(!H.ok){const ge=await H.json().catch(()=>({}));throw new Error(ge.error||`Download failed (${H.status})`)}const X=await H.blob(),xe=URL.createObjectURL(X),q=document.createElement("a");q.href=xe,q.download=ce.filename,q.click(),URL.revokeObjectURL(xe)}catch(H){w(H instanceof Error?H.message:"Failed to download transcript")}finally{M(!1)}}}return s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Transcripts"}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Browse saved transcripts or customize how new ones look when tickets close."})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("div",{className:"flex rounded-lg border border-border p-0.5",children:[s.jsx(ue,{type:"button",variant:o==="browse"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>c("browse"),children:"Library"}),s.jsx(ue,{type:"button",variant:o==="appearance"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>c("appearance"),children:"Appearance"}),s.jsx(ue,{type:"button",variant:o==="settings"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>c("settings"),children:"Settings"})]}),o==="browse"?s.jsxs(ue,{variant:"outline",size:"sm",onClick:()=>G(),disabled:g,children:[s.jsx(ve,{icon:ur,size:16,className:pe(g&&"animate-spin")}),"Refresh"]}):null]})]}),o==="appearance"?s.jsx(xP,{}):o==="settings"?s.jsx(yP,{}):s.jsxs(s.Fragment,{children:[y?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:y})}):null,s.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 lg:grid-cols-[minmax(240px,320px)_1fr]",children:[s.jsxs(Ze,{className:"flex min-h-[420px] flex-col border-border bg-card",children:[s.jsxs(ut,{className:"space-y-3 pb-3",children:[s.jsxs(dt,{className:"text-base font-medium",children:["Saved transcripts",!g&&l.length>0?s.jsxs("span",{className:"ml-2 font-normal text-muted-foreground",children:["(",l.length,")"]}):null]}),s.jsxs("div",{className:"relative",children:[s.jsx(ve,{icon:ji,size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx(De,{placeholder:"Search by ticket name or channel ID…",value:S,onChange:H=>E(H.target.value),className:"pl-9"})]})]}),s.jsx(Qe,{className:"min-h-0 flex-1 p-0 pb-4",children:s.jsx(fc,{className:"h-[min(520px,calc(100svh-16rem))] px-4",children:g?s.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((H,X)=>s.jsx(Be,{className:"h-16 w-full rounded-lg"},X))}):Y.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center text-sm text-muted-foreground",children:[s.jsx(ve,{icon:Ul,size:32,className:"opacity-40"}),s.jsx("p",{children:l.length===0?"No transcripts yet. They appear when tickets are closed.":"No transcripts match your search."})]}):s.jsx("ul",{className:"space-y-1.5",children:Y.map(H=>{var q;const X=H.id===m,xe=((q=H.ticketName)==null?void 0:q.trim())||`Channel ${H.id}`;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>Z(H.id),className:pe("w-full rounded-lg border px-3 py-2.5 text-left transition-colors",X?"border-primary/50 bg-primary/10":"border-transparent bg-secondary/30 hover:bg-secondary/50"),children:[s.jsx("p",{className:"truncate text-sm font-medium",children:xe}),s.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[a2(H.createdAt),H.size!=null?` · ${r2(H.size)}`:""]})]})},H.id)})})})})]}),s.jsxs(Ze,{className:"flex min-h-[420px] flex-col overflow-hidden border-border bg-card",children:[s.jsxs(ut,{className:"flex flex-row flex-wrap items-center justify-between gap-2 space-y-0 pb-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx(dt,{className:"truncate text-base font-medium",children:ce?(($=ce.ticketName)==null?void 0:$.trim())||`Channel ${ce.id}`:"Preview"}),ce?s.jsxs("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[a2(ce.createdAt),ce.size!=null?` · ${r2(ce.size)}`:""]}):null]}),s.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2",children:[P?s.jsxs(s.Fragment,{children:[s.jsxs(ue,{variant:"outline",size:"sm",onClick:()=>void V(),children:[s.jsx(ve,{icon:R2,size:16}),K?"Copied":"Copy link"]}),s.jsxs(ue,{variant:"outline",size:"sm",onClick:re,children:[s.jsx(ve,{icon:Nd,size:16}),"Public page"]})]}):null,s.jsxs(ue,{variant:"outline",size:"sm",disabled:!fe,onClick:ae,children:[s.jsx(ve,{icon:p8,size:16}),"Open tab"]}),s.jsxs(ue,{variant:"outline",size:"sm",disabled:!se||T,onClick:()=>void D(),children:[s.jsx(ve,{icon:Cd,size:16}),T?"Saving…":"Download"]}),a?s.jsxs(ue,{variant:"outline",size:"sm",disabled:!m||_,className:"text-destructive hover:text-destructive",onClick:()=>void O(),children:[s.jsx(ve,{icon:wi,size:16}),_?"Deleting…":"Delete"]}):null]})]}),s.jsxs(Qe,{className:"flex min-h-0 flex-1 flex-col gap-2 p-4 pt-0",children:[b?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:b})}):null,ce&&fe?s.jsx("iframe",{title:`Transcript ${ce.id}`,src:fe,className:"min-h-[min(560px,calc(100svh-18rem))] w-full flex-1 rounded-lg border border-border bg-background",sandbox:"allow-same-origin"},k):s.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:[s.jsx(ve,{icon:Ul,size:40,className:"opacity-30"}),s.jsx("p",{children:"Select a transcript from the list to preview it here."})]})]})]})]})]})]})}function CP(){const[t,n]=f.useState([]),[a,o]=f.useState(""),[c,l]=f.useState(!0),[d,m]=f.useState(""),[p,g]=f.useState(!0);f.useEffect(()=>{try{Ne.getConfigJson("supportbot").then(W=>{if(W&&W.data&&typeof W.data=="object"){const oe=Fr(W.data,"Ticket.DepartmentSystem.Enabled");typeof oe=="boolean"&&g(oe)}}).catch(()=>{})}catch{}},[]);const[v,b]=f.useState("all"),[w,y]=f.useState("all"),[C,S]=f.useState(""),E=f.useMemo(()=>{const W=new Set;return Array.isArray(t)&&t.forEach(oe=>{if(oe&&oe.department&&typeof oe.department=="string"){const Se=oe.department.trim().toLowerCase();Se&&W.add(Se)}}),Array.from(W).sort()},[t]),k=f.useMemo(()=>Array.isArray(t)?t.filter(W=>{var oe,Se,ye,Re,nt,mt;if(!W||p&&v!=="all"&&((oe=W.department)==null?void 0:oe.toLowerCase())!==v.toLowerCase()||w!=="all"&&((Se=W.priority)==null?void 0:Se.toLowerCase())!==w.toLowerCase())return!1;if(C.trim()){const bt=C.toLowerCase().trim(),Rr=(ye=W.subject)==null?void 0:ye.toLowerCase().includes(bt),xn=(Re=W.ticket_id)==null?void 0:Re.toLowerCase().includes(bt),mn=(nt=W.user_id)==null?void 0:nt.toLowerCase().includes(bt),Wr=p&&((mt=W.department)==null?void 0:mt.toLowerCase().includes(bt));if(!Rr&&!xn&&!mn&&!Wr)return!1}return!0}):[],[t,p,v,w,C]),[N,T]=f.useState(null),[M,_]=f.useState(!1),[R,L]=f.useState(!1),[te,K]=f.useState([]),[I,G]=f.useState(!1),[Y,ce]=f.useState(""),[fe,se]=f.useState([]),[P,Z]=f.useState(!1),[ae,re]=f.useState(null),[V,O]=f.useState(!1),[D,$]=f.useState(""),[H,X]=f.useState(null),[xe,q]=f.useState(""),[ge,me]=f.useState(!1),[B,ie]=f.useState(null),[we,Ce]=f.useState(""),[ze,Ke]=f.useState(null),[ft,Pt]=f.useState(!1),[gn,Yr]=f.useState("general"),[_n,wn]=f.useState(""),[Xn,Zn]=f.useState(""),[It,po]=f.useState(!1),nn=async()=>{if(!_n.trim()){Dt.error("Please enter a subject or reason for the ticket.");return}po(!0);try{const W=await Ne.createTicket({department:gn,subject:_n.trim(),userId:Xn.trim()||void 0});Dt.success(W.message||"Ticket opened successfully!"),Pt(!1),wn(""),Zn(""),qr()}catch(W){Dt.error(W instanceof Error?W.message:"Failed to open ticket.")}finally{po(!1)}},Dn=W=>{ie(W),Ce("Closed via Web Dashboard"),me(!0)},Da=async()=>{if(!B)return;const W=B.ticket_id;Ke(W);try{await Ne.closeTicket(W,we||"Closed via Web Dashboard"),Dt.success("Ticket closed and transcript saved."),n(oe=>oe.filter(Se=>Se.ticket_id!==W)),(N==null?void 0:N.ticket_id)===W&&(_(!1),L(!1),T(null)),me(!1),ie(null)}catch(oe){Dt.error(oe instanceof Error?oe.message:"Failed to close ticket.")}finally{Ke(null)}},ho=f.useRef(null),Qn=f.useRef(null),Es=()=>{var W;(W=ho.current)==null||W.scrollIntoView({behavior:"smooth"})},qr=f.useCallback(async()=>{l(!0),m("");try{const W=await Ne.listOpenTickets();W.data&&(o(W.data.guildId),n(W.data.tickets.sort((oe,Se)=>Se.created_at-oe.created_at)))}catch(W){m(W instanceof Error?W.message:"Failed to load open tickets")}finally{l(!1)}},[]);f.useEffect(()=>{qr()},[qr]),f.useEffect(()=>{Ne.getGuildResources().then(W=>{W.data&&re(W.data)}).catch(()=>{})},[]);const gr=f.useCallback(W=>{N&&W.ticketId===N.ticket_id&&(K(oe=>oe.some(Se=>Se.id===W.message.id)?oe:[...oe,W.message]),setTimeout(Es,100))},[N]),Tt=f.useCallback(W=>{N&&W.ticketId===N.ticket_id&&K(oe=>oe.filter(Se=>Se.id!==W.messageId))},[N]),On=f.useCallback(W=>{N&&W.ticketId===N.ticket_id&&K(oe=>oe.map(Se=>Se.id===W.messageId?{...Se,content:W.content}:Se))},[N]),Mt=f.useCallback(W=>{n(oe=>oe.some(Se=>Se.ticket_id===W.ticket_id)?oe:[W,...oe]),Dt.info("New Ticket Created",{description:`#${W.ticket_id} - ${W.subject||"No Subject"}`})},[]),Oi=f.useCallback(W=>{n(oe=>oe.filter(Se=>Se.ticket_id!==W.ticket_id)),(N==null?void 0:N.ticket_id)===W.ticket_id&&Dt.warning("Active ticket was closed in Discord.")},[N]);kx({onTicketMessage:gr,onTicketMessageDeleted:Tt,onTicketMessageUpdated:On,onTicketCreated:Mt,onTicketClosed:Oi});const Li=async W=>{var oe;T(W),_(!0),G(!0),K([]),se([]),X(null);try{const Se=await Ne.getTicketMessages(W.ticket_id);(oe=Se.data)!=null&&oe.messages&&(K(Se.data.messages),setTimeout(Es,150))}catch(Se){Dt.error(Se instanceof Error?Se.message:"Failed to fetch messages")}finally{G(!1)}},go=W=>{const oe=Array.from(W.target.files||[]);oe.length&&(oe.forEach(Se=>{const ye=new FileReader;ye.onload=Re=>{var mt;const nt=(mt=Re.target)==null?void 0:mt.result;se(bt=>[...bt,{filename:Se.name,data:nt,previewUrl:Se.type.startsWith("image/")?nt:void 0,sizeMb:(Se.size/1024/1024).toFixed(2)}])},ye.readAsDataURL(Se)}),Qn.current&&(Qn.current.value=""))},Kr=W=>{se(oe=>oe.filter((Se,ye)=>ye!==W))},Oa=async W=>{var ye;if(W.preventDefault(),!Y.trim()&&!fe.length||!N||P)return;const oe=Y.trim(),Se=[...fe];Z(!0),ce(""),se([]),O(!1);try{const Re=await Ne.me().catch(()=>null),nt=((ye=Re==null?void 0:Re.data)==null?void 0:ye.username)||"Staff",mt=await Ne.sendTicketReply(N.ticket_id,oe,nt,Se.map(bt=>({filename:bt.filename,data:bt.data})));mt.data&&(K(bt=>bt.some(Rr=>Rr.id===mt.data.id)?bt:[...bt,{id:mt.data.id,author:mt.data.author,content:mt.data.content,attachments:mt.data.attachments||[],createdAt:mt.data.createdAt}]),setTimeout(Es,100))}catch(Re){Dt.error(Re instanceof Error?Re.message:"Failed to send reply to Discord."),ce(oe),se(Se)}finally{Z(!1)}},Mr=async W=>{if(N)try{await Ne.deleteTicketMessage(N.ticket_id,W),K(oe=>oe.filter(Se=>Se.id!==W)),Dt.success("Message deleted in Discord.")}catch(oe){Dt.error(oe instanceof Error?oe.message:"Failed to delete message.")}},Kt=W=>{X(W.id),q(W.content)},La=()=>{X(null),q("")},Oe=async W=>{if(!(!N||!xe.trim()))try{await Ne.editTicketMessage(N.ticket_id,W,xe.trim()),K(oe=>oe.map(Se=>Se.id===W?{...Se,content:xe.trim()}:Se)),X(null),Dt.success("Message updated in Discord.")}catch(oe){Dt.error(oe instanceof Error?oe.message:"Failed to edit message.")}},tt=W=>{const oe=W.target.value;ce(oe);const Se=W.target.selectionStart||oe.length,ye=oe.slice(0,Se),Re=ye.lastIndexOf("@");if(Re!==-1&&!ye.slice(Re).includes(" ")){const nt=ye.slice(Re+1).toLowerCase();$(nt),O(!0)}else O(!1)},it=(W,oe,Se)=>{const ye=Y.lastIndexOf("@"),Re=Y.slice(0,ye),nt=Se?`<@&${oe}>`:`<@${oe}>`;ce(`${Re}${nt} `),O(!1)},rn=W=>{const oe=Math.floor((Date.now()-W)/1e3);return fg(oe)},Ft=W=>new Date(W).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),Rt=W=>{if(!W)return null;const oe=/(```[\s\S]*?```|`[^`]+`|\*\*\*[\s\S]+?\*\*\*|\*\*[\s\S]+?\*\*|__[\s\S]+?__|~~[\s\S]+?~~|\|\|[\s\S]+?\|\||<@!?&?\d+>|^###\s[^\n]+|^##\s[^\n]+|^-#\s[^\n]+|\[[^\]]+\]\(https?:\/\/[^\s)]+\)|https?:\/\/[^\s]+)/gm;return W.split(oe).map((ye,Re)=>{var Rr;if(!ye)return null;if(ye.startsWith("-# "))return s.jsx("span",{className:"text-xs text-muted-foreground font-medium block my-0.5 opacity-80",children:Rt(ye.slice(3))},Re);if(ye.startsWith("## "))return s.jsx("span",{className:"text-base font-bold text-foreground block my-1 tracking-tight",children:Rt(ye.slice(3))},Re);if(ye.startsWith("### "))return s.jsx("span",{className:"text-sm font-bold text-foreground block my-0.5",children:Rt(ye.slice(4))},Re);if(ye.startsWith("```")&&ye.endsWith("```")&&ye.length>=6){const xn=ye.slice(3,-3).replace(/^[a-z0-9_-]+\n/i,"");return s.jsx("pre",{className:"bg-black/60 p-2.5 rounded-lg text-xs font-mono my-1.5 border border-border overflow-x-auto text-emerald-400 font-mono",children:s.jsx("code",{children:xn})},Re)}if(ye.startsWith("`")&&ye.endsWith("`")&&ye.length>2)return s.jsx("code",{className:"bg-black/50 px-1.5 py-0.5 rounded text-xs font-mono text-emerald-300 border border-border/40",children:ye.slice(1,-1)},Re);if(ye.startsWith("***")&&ye.endsWith("***")&&ye.length>6)return s.jsx("strong",{className:"font-bold italic",children:Rt(ye.slice(3,-3))},Re);if(ye.startsWith("**")&&ye.endsWith("**")&&ye.length>4)return s.jsx("strong",{className:"font-bold",children:Rt(ye.slice(2,-2))},Re);if(ye.startsWith("__")&&ye.endsWith("__")&&ye.length>4)return s.jsx("span",{className:"underline underline-offset-2",children:Rt(ye.slice(2,-2))},Re);if(ye.startsWith("~~")&&ye.endsWith("~~")&&ye.length>4)return s.jsx("span",{className:"line-through opacity-80",children:Rt(ye.slice(2,-2))},Re);if(ye.startsWith("||")&&ye.endsWith("||")&&ye.length>4)return s.jsx("span",{className:"bg-secondary text-transparent hover:text-foreground hover:bg-secondary/50 px-1.5 py-0.5 rounded transition-all cursor-pointer select-none border border-border/30",title:"Click to reveal spoiler",children:ye.slice(2,-2)},Re);const nt=ye.match(/^<@!?(\d+)>$/);if(nt){const xn=nt[1],mn=new Map;N&&mn.set(N.user_id,"Ticket Author"),te.forEach(xr=>{var Xr;(Xr=xr.author)!=null&&Xr.id&&mn.set(xr.author.id,xr.author.globalName||xr.author.username)});const Wr=mn.get(xn);return s.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded font-semibold text-xs bg-primary/20 text-primary mx-0.5",title:`User ID: ${xn}`,children:["@",Wr||"User"]},Re)}const mt=ye.match(/^<@&(\d+)>$/);if(mt){const xn=mt[1],mn=(Rr=ae==null?void 0:ae.roles)==null?void 0:Rr.find(Wr=>Wr.id===xn);return s.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded font-semibold text-xs bg-amber-500/20 text-amber-400 mx-0.5",children:["@",mn?mn.name:`Role (${xn})`]},Re)}const bt=ye.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)$/);if(bt){const xn=bt[1],mn=bt[2];return s.jsx("a",{href:mn,target:"_blank",rel:"noreferrer",className:"text-primary underline hover:opacity-80 break-all",children:xn},Re)}return/^https?:\/\/[^\s]+$/i.test(ye)?/\.(gif|jpe?g|png|webp)(\?[^\s]*)?$/i.test(ye)||/cdn\.discordapp\.com\/(emojis|attachments)\//i.test(ye)||/images\.discordapp\.net\//i.test(ye)||/media\d*\.giphy\.com\//i.test(ye)?s.jsx("span",{className:"block my-1",children:s.jsx("img",{src:ye,alt:"GIF/Image",className:"max-h-64 rounded-lg border border-border object-contain hover:opacity-95 transition-opacity",loading:"lazy"})},Re):s.jsx("a",{href:ye,target:"_blank",rel:"noreferrer",className:"text-primary underline hover:opacity-80 break-all",children:ye},Re):ye})},Jn=W=>!W||W.length===0?null:s.jsx("div",{className:"space-y-2 mt-1",children:W.map(oe=>{var nt,mt,bt;const Se=((nt=oe.contentType)==null?void 0:nt.startsWith("image/"))||/\.(png|jpe?g|gif|webp|svg)$/i.test(oe.name),ye=((mt=oe.contentType)==null?void 0:mt.startsWith("video/"))||/\.(mp4|webm|mov|mkv)$/i.test(oe.name),Re=((bt=oe.contentType)==null?void 0:bt.startsWith("audio/"))||/\.(mp3|wav|ogg|m4a)$/i.test(oe.name);return Se?s.jsx("div",{className:"rounded-lg overflow-hidden border border-border bg-black/40",children:s.jsx("a",{href:oe.url,target:"_blank",rel:"noreferrer",children:s.jsx("img",{src:oe.url,alt:oe.name,className:"max-h-80 max-w-full object-contain hover:opacity-95 transition-opacity",loading:"lazy"})})},oe.id):ye?s.jsx("div",{className:"rounded-lg overflow-hidden border border-border bg-black",children:s.jsx("video",{src:oe.url,controls:!0,className:"max-h-80 max-w-full"})},oe.id):Re?s.jsx("div",{className:"p-2 border border-border rounded-lg bg-secondary/20",children:s.jsx("audio",{src:oe.url,controls:!0,className:"w-full h-8"})},oe.id):s.jsxs("div",{className:"p-2.5 rounded-lg border border-border bg-secondary/20 flex items-center justify-between text-xs gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 truncate",children:[s.jsx(ve,{icon:Uy,size:16,className:"text-primary shrink-0"}),s.jsx("span",{className:"truncate font-medium",children:oe.name})]}),s.jsx(ue,{variant:"ghost",size:"sm",asChild:!0,className:"h-7 px-2 text-xs",children:s.jsx("a",{href:oe.url,target:"_blank",rel:"noreferrer",download:!0,children:"Download"})})]},oe.id)})}),fn=W=>!W||W.length===0?null:s.jsx("div",{className:"space-y-3 mt-1.5 w-full",children:W.map((oe,Se)=>{var ye,Re,nt,mt;return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-secondary/30 p-3.5 text-xs space-y-2 border-l-4 shadow-sm relative overflow-hidden max-w-xl",style:{borderLeftColor:oe.color||"#5865F2"},children:[oe.author&&s.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-foreground",children:[oe.author.iconURL&&s.jsx("img",{src:oe.author.iconURL,alt:"",className:"h-4 w-4 rounded-full"}),s.jsx("span",{children:oe.author.name})]}),((ye=oe.thumbnail)==null?void 0:ye.url)&&s.jsx("img",{src:oe.thumbnail.url,alt:"",className:"h-12 w-12 rounded object-cover absolute top-3 right-3 border border-border"}),oe.title&&s.jsx("h4",{className:"font-bold text-sm text-foreground tracking-tight pr-12",children:Rt(oe.title)}),oe.description&&s.jsx("div",{className:"text-muted-foreground whitespace-pre-wrap leading-relaxed pr-12",children:Rt(oe.description)}),oe.fields&&oe.fields.length>0&&s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2.5 pt-2 border-t border-border/30",children:oe.fields.map((bt,Rr)=>s.jsxs("div",{className:`space-y-0.5 ${bt.inline?"":"sm:col-span-2"}`,children:[s.jsx("p",{className:"font-semibold text-foreground text-[11px] uppercase tracking-wider",children:bt.name}),s.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:Rt(bt.value)})]},Rr))}),((Re=oe.image)==null?void 0:Re.url)&&s.jsx("div",{className:"rounded-md overflow-hidden border border-border mt-2",children:s.jsx("img",{src:oe.image.url,alt:"",className:"max-h-64 w-full object-cover"})}),(oe.footer||oe.timestamp)&&s.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-border/20 text-[10px] text-muted-foreground",children:[((nt=oe.footer)==null?void 0:nt.iconURL)&&s.jsx("img",{src:oe.footer.iconURL,alt:"",className:"h-3.5 w-3.5 rounded-full"}),((mt=oe.footer)==null?void 0:mt.text)&&s.jsx("span",{children:oe.footer.text}),oe.timestamp&&s.jsxs("span",{children:[new Date(oe.timestamp).toLocaleDateString()," ",new Date(oe.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]})]},Se)})}),Ln=W=>{if(!W||W.length===0)return null;const oe=W.map(Se=>({...Se,components:(Se.components||[]).filter(ye=>ye.customId||ye.url||ye.type===2||ye.type===3||ye.type==="BUTTON"||ye.type==="STRING_SELECT")})).filter(Se=>Se.components&&Se.components.length>0);return oe.length===0?null:s.jsx("div",{className:"space-y-2 mt-2.5 w-full",children:oe.map((Se,ye)=>{var Re;return s.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:(Re=Se.components)==null?void 0:Re.map((nt,mt)=>s.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary/80 text-secondary-foreground text-xs font-semibold border border-border/80 shadow-sm hover:bg-secondary transition-colors cursor-pointer",children:[nt.emoji&&s.jsx("span",{children:nt.emoji}),s.jsx("span",{children:nt.label||nt.customId||"Button"})]},mt))},ye)})})},xo=()=>s.jsx(fc,{className:"flex-1 p-4 sm:p-6",children:s.jsxs("div",{className:"max-w-4xl mx-auto w-full space-y-4",children:[I?s.jsxs("div",{className:"space-y-4 p-4",children:[s.jsx(Be,{className:"h-10 w-3/4"}),s.jsx(Be,{className:"h-10 w-1/2 ml-auto"}),s.jsx(Be,{className:"h-10 w-2/3"})]}):te.length===0?s.jsx("div",{className:"p-12 text-center text-muted-foreground text-sm",children:"No recent messages in this ticket channel."}):te.map(W=>{var oe;return s.jsxs("div",{className:`group flex items-start gap-3 ${W.author.isDashboard?"flex-row-reverse":""}`,children:[s.jsxs(bs,{className:"h-8 w-8 shrink-0",children:[s.jsx(eo,{src:W.author.avatar,alt:W.author.username}),s.jsx(ys,{children:s.jsx(ve,{icon:L8,size:16})})]}),s.jsxs("div",{className:`flex flex-col space-y-1 max-w-[80%] ${W.author.isDashboard?"items-end":"items-start"}`,children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("span",{className:"font-semibold text-foreground",children:W.author.globalName||W.author.username}),W.author.bot&&s.jsx(Fn,{variant:"secondary",className:"px-1 py-0 text-[10px]",children:"BOT"}),W.author.isDashboard&&s.jsx(Fn,{variant:"default",className:"px-1 py-0 text-[10px]",children:"STAFF"}),s.jsx("span",{children:Ft(W.createdAt)}),s.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-1",children:[s.jsx(ue,{variant:"ghost",size:"icon",className:"h-5 w-5 text-muted-foreground hover:text-foreground",onClick:()=>Kt(W),title:"Edit Message",children:s.jsx(ve,{icon:D2,size:12})}),s.jsx(ue,{variant:"ghost",size:"icon",className:"h-5 w-5 text-muted-foreground hover:text-destructive",onClick:()=>Mr(W.id),title:"Delete Message",children:s.jsx(ve,{icon:wi,size:12})})]})]}),H===W.id?s.jsxs("div",{className:"flex items-center gap-2 w-full mt-1",children:[s.jsx(De,{value:xe,onChange:Se=>q(Se.target.value),className:"h-8 text-sm",autoFocus:!0}),s.jsx(ue,{size:"sm",className:"h-8 px-2 bg-primary",onClick:()=>Oe(W.id),children:s.jsx(ve,{icon:_8,size:14})}),s.jsx(ue,{size:"sm",variant:"ghost",className:"h-8 px-2",onClick:La,children:s.jsx(ve,{icon:va,size:14})})]}):W.content?s.jsx("div",{className:`rounded-lg px-3.5 py-2.5 text-sm whitespace-pre-wrap ${W.author.isDashboard?"bg-primary text-primary-foreground":"bg-secondary/40 text-secondary-foreground border border-border/50"}`,style:W.containerColor||W.author.bot&&!((oe=W.embeds)!=null&&oe.length)?{borderLeftWidth:"4px",borderLeftColor:W.containerColor||"#5865F2"}:void 0,children:Rt(W.content)}):null,Jn(W.attachments),fn(W.embeds),Ln(W.components)]})]},W.id)}),s.jsx("div",{ref:ho})]})}),vo=()=>{var W;return s.jsxs("div",{className:"p-4 border-t border-border bg-secondary/10 flex flex-col gap-2 relative",children:[fe.length>0&&s.jsx("div",{className:"max-w-4xl mx-auto w-full flex items-center gap-2 flex-wrap mb-1",children:fe.map((oe,Se)=>s.jsxs("div",{className:"flex items-center gap-2 p-1.5 px-3 rounded-lg border border-border bg-secondary text-xs",children:[oe.previewUrl?s.jsx("img",{src:oe.previewUrl,alt:"",className:"h-6 w-6 rounded object-cover"}):s.jsx(ve,{icon:Uy,size:14,className:"text-primary"}),s.jsx("span",{className:"font-medium max-w-[120px] truncate",children:oe.filename}),s.jsxs("span",{className:"text-muted-foreground text-[10px]",children:[oe.sizeMb,"MB"]}),s.jsx("button",{type:"button",onClick:()=>Kr(Se),className:"text-muted-foreground hover:text-destructive ml-1",children:s.jsx(ve,{icon:va,size:12})})]},Se))}),V&&s.jsxs("div",{className:"max-w-4xl mx-auto w-full absolute bottom-full mb-2 z-50 bg-popover text-popover-foreground border border-border rounded-xl shadow-xl overflow-hidden max-h-48 overflow-y-auto",children:[s.jsx("div",{className:"p-2 text-[11px] font-semibold text-muted-foreground uppercase tracking-wider border-b",children:"Mentions (@)"}),N&&s.jsxs("button",{type:"button",onClick:()=>it("Ticket Author",N.user_id,!1),className:"w-full text-left p-2 hover:bg-secondary flex items-center justify-between text-xs",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(bs,{className:"h-5 w-5",children:s.jsx(ys,{children:"U"})}),s.jsx("span",{className:"font-medium",children:"Ticket Author"})]}),s.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground",children:["@",N.user_id]})]}),(W=ae==null?void 0:ae.roles)==null?void 0:W.filter(oe=>oe.name.toLowerCase().includes(D)).slice(0,5).map(oe=>s.jsxs("button",{type:"button",onClick:()=>it(oe.name,oe.id,!0),className:"w-full text-left p-2 hover:bg-secondary flex items-center justify-between text-xs",children:[s.jsxs("span",{className:"font-medium text-amber-400",children:["@",oe.name]}),s.jsx("span",{className:"text-[10px] font-mono text-muted-foreground",children:"Role"})]},oe.id))]}),s.jsxs("form",{onSubmit:Oa,className:"max-w-4xl mx-auto w-full flex items-center gap-2",children:[s.jsx("input",{type:"file",ref:Qn,multiple:!0,onChange:go,className:"hidden",accept:"image/*,video/*,audio/*,.pdf,.zip,.txt,.json"}),s.jsx(ue,{type:"button",variant:"outline",size:"sm",onClick:()=>{var oe;return(oe=Qn.current)==null?void 0:oe.click()},title:"Attach files or media",className:"h-9 px-2.5",children:s.jsx(ve,{icon:b8,size:16})}),s.jsx(De,{value:Y,onChange:tt,placeholder:"Type a reply... Use @ to tag roles or users",disabled:P||I,className:"flex-1"}),s.jsx(ue,{type:"submit",size:"sm",disabled:P||!Y.trim()&&!fe.length||I,children:P?s.jsx(ve,{icon:ur,size:16,className:"animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(ve,{icon:R8,size:16,className:"mr-1.5"}),"Send"]})})]})]})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Open Tickets"}),s.jsx("p",{className:"text-muted-foreground",children:"Manage open support tickets & reply live to Discord channels from the web dashboard."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ue,{onClick:()=>Pt(!0),className:"gap-2 bg-primary font-semibold text-xs h-9",children:[s.jsx(ve,{icon:is,size:15})," Open Ticket"]}),s.jsxs(ue,{onClick:()=>void qr(),disabled:c,variant:"outline",size:"sm",children:[s.jsx(ve,{icon:ur,size:16,className:c?"animate-spin mr-2":"mr-2"}),"Refresh"]})]})]}),s.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-3 bg-card/60 p-3.5 rounded-xl border border-border/80 shadow-sm",children:[s.jsxs("div",{className:"relative w-full md:w-80",children:[s.jsx(ve,{icon:ji,size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx(De,{placeholder:"Search tickets by ID, user, subject...",value:C,onChange:W=>S(W.target.value),className:"pl-9 text-xs h-9 bg-secondary/30 border-border"})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 w-full md:w-auto justify-end",children:[p&&s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Department:"}),s.jsxs(Ca,{value:v,onValueChange:b,children:[s.jsx(Br,{className:"text-xs h-9 w-[160px] bg-secondary/30 border-border capitalize",children:s.jsx(Sa,{placeholder:"All Departments"})}),s.jsxs($r,{children:[s.jsx(vt,{value:"all",children:"All Departments"}),E.map(W=>s.jsx(vt,{value:W,className:"capitalize",children:W},W))]})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Priority:"}),s.jsxs(Ca,{value:w,onValueChange:y,children:[s.jsx(Br,{className:"text-xs h-9 w-[140px] bg-secondary/30 border-border capitalize",children:s.jsx(Sa,{placeholder:"All Priorities"})}),s.jsxs($r,{children:[s.jsx(vt,{value:"all",children:"All Priorities"}),s.jsx(vt,{value:"low",children:"Low"}),s.jsx(vt,{value:"medium",children:"Medium / Normal"}),s.jsx(vt,{value:"high",children:"High"}),s.jsx(vt,{value:"urgent",children:"Urgent"})]})]})]}),(v!=="all"||w!=="all"||C.trim())&&s.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>{b("all"),y("all"),S("")},className:"h-9 text-xs text-muted-foreground hover:text-foreground px-2",children:"Reset"})]})]}),s.jsx(Ze,{className:"border-border bg-card",children:s.jsx(Qe,{className:"p-0",children:c?s.jsxs("div",{className:"space-y-4 p-6",children:[s.jsx(Be,{className:"h-12 w-full"}),s.jsx(Be,{className:"h-12 w-full"}),s.jsx(Be,{className:"h-12 w-full"})]}):d?s.jsx("div",{className:"p-6",children:s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:d})})}):k.length===0?s.jsxs("div",{className:"p-12 text-center text-muted-foreground space-y-2",children:[s.jsx("p",{children:"No open tickets found matching your filter criteria."}),(v!=="all"||w!=="all"||C.trim())&&s.jsx(ue,{variant:"outline",size:"sm",onClick:()=>{b("all"),y("all"),S("")},className:"text-xs mt-2",children:"Clear Filters"})]}):s.jsx("div",{className:"divide-y divide-border",children:k.map(W=>s.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between p-4 hover:bg-secondary/10 transition-colors gap-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("p",{className:"font-medium text-primary",children:W.subject||"Untitled Ticket"}),s.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:["#",W.ticket_id]}),p&&W.department&&s.jsx(Fn,{variant:"outline",className:"text-xs capitalize",children:W.department}),s.jsxs(Fn,{variant:W.priority==="high"?"destructive":W.priority==="medium"?"secondary":"outline",className:"text-xs capitalize",children:[W.priority," priority"]})]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["User ID: ",s.jsx("span",{className:"font-mono",children:W.user_id}),W.description&&` • ${W.description}`]})]}),s.jsxs("div",{className:"flex items-center gap-3 w-full sm:w-auto justify-end",children:[s.jsxs("div",{className:"text-sm text-muted-foreground flex items-center whitespace-nowrap mr-2",children:[s.jsx(ve,{icon:h8,size:14,className:"mr-1.5"}),rn(W.created_at)]}),s.jsxs(ue,{variant:"default",size:"sm",onClick:()=>Li(W),className:"bg-primary text-primary-foreground hover:bg-primary/90",children:[s.jsx(ve,{icon:g8,size:16,className:"mr-2"}),"Live Chat"]}),s.jsxs(ue,{variant:"destructive",size:"sm",onClick:()=>Dn(W),disabled:ze===W.ticket_id,children:[ze===W.ticket_id?s.jsx(ve,{icon:ur,size:14,className:"animate-spin mr-1.5"}):s.jsx(ve,{icon:va,size:14,className:"mr-1.5"}),"Close"]}),a&&s.jsx(ue,{variant:"secondary",size:"sm",asChild:!0,children:s.jsx("a",{href:`https://discord.com/channels/${a}/${W.ticket_id}`,target:"_blank",rel:"noreferrer",children:s.jsx(ve,{icon:Nd,size:16})})})]})]},W.ticket_id))})})}),M&&R&&s.jsx("div",{className:"fixed inset-0 z-50 bg-black/65 backdrop-blur-sm flex items-center justify-center p-4 sm:p-6 lg:p-8 animate-in fade-in-0",onClick:W=>{W.target===W.currentTarget&&L(!1)},children:s.jsxs("div",{className:"bg-card text-card-foreground border border-border rounded-2xl shadow-2xl flex flex-col w-full max-w-5xl h-[88vh] overflow-hidden animate-in zoom-in-95",children:[s.jsxs("div",{className:"p-4 border-b border-border bg-secondary/20 flex flex-col space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap min-w-0",children:[s.jsx("h2",{className:"text-lg font-bold tracking-tight truncate",children:(N==null?void 0:N.subject)||"Ticket Live Chat"}),s.jsxs(Fn,{variant:"outline",className:"font-mono text-xs shrink-0",children:["#",N==null?void 0:N.ticket_id]}),(N==null?void 0:N.department)&&s.jsx(Fn,{variant:"secondary",className:"text-xs capitalize shrink-0",children:N.department})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[N&&s.jsxs(ue,{variant:"destructive",size:"sm",onClick:()=>Dn(N),disabled:ze===N.ticket_id,className:"h-8 px-2.5 text-xs",children:[ze===N.ticket_id?s.jsx(ve,{icon:ur,size:14,className:"animate-spin mr-1.5"}):s.jsx(ve,{icon:va,size:14,className:"mr-1.5"}),"Close Ticket"]}),s.jsxs(ue,{variant:"outline",size:"sm",onClick:()=>L(!1),className:"h-8 px-3 text-xs flex items-center gap-1.5",children:[s.jsx(ve,{icon:S8,size:14}),s.jsx("span",{children:"Collapse"})]}),s.jsx(ue,{variant:"ghost",size:"icon",onClick:()=>{_(!1),L(!1)},className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:s.jsx(ve,{icon:va,size:18})})]})]}),(N==null?void 0:N.description)&&s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:N.description})]}),xo(),vo()]})}),M&&!R&&s.jsx(Yj,{open:M,onOpenChange:_,children:s.jsxs(Hg,{side:"right",className:"w-full sm:max-w-xl p-0 flex flex-col h-full bg-card",children:[s.jsxs(Gg,{className:"p-4 border-b border-border space-y-1 bg-secondary/20",children:[s.jsxs("div",{className:"flex items-center justify-between pr-8",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap min-w-0",children:[s.jsx(Vg,{className:"text-base font-bold truncate",children:(N==null?void 0:N.subject)||"Ticket Live Chat"}),s.jsxs(Fn,{variant:"outline",className:"font-mono text-xs shrink-0",children:["#",N==null?void 0:N.ticket_id]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[N&&s.jsxs(ue,{variant:"destructive",size:"sm",onClick:()=>Dn(N),disabled:ze===N.ticket_id,className:"h-7 px-2 text-xs",children:[ze===N.ticket_id?s.jsx(ve,{icon:ur,size:13,className:"animate-spin mr-1"}):s.jsx(ve,{icon:va,size:13,className:"mr-1"}),"Close"]}),s.jsxs(ue,{variant:"outline",size:"sm",onClick:()=>L(!0),className:"h-7 px-2 text-xs flex items-center gap-1",title:"Open in Full View",children:[s.jsx(ve,{icon:C8,size:13}),s.jsx("span",{children:"Full View"})]})]})]}),(N==null?void 0:N.description)&&s.jsx(Fg,{className:"text-xs text-muted-foreground truncate",children:N.description})]}),xo(),vo()]})}),s.jsx(Qs,{open:ge,onOpenChange:me,children:s.jsxs(hs,{className:"sm:max-w-md bg-card border-border rounded-xl",children:[s.jsxs(gs,{children:[s.jsxs(xs,{className:"text-lg font-bold flex items-center gap-2",children:[s.jsx(ve,{icon:va,className:"text-destructive",size:20}),"Close Ticket #",B==null?void 0:B.ticket_id]}),s.jsx(vs,{className:"text-xs text-muted-foreground pt-1",children:"Are you sure you want to close this ticket? A transcript will be created and the channel will be deleted in Discord."})]}),s.jsxs("div",{className:"space-y-2 py-2",children:[s.jsx("label",{className:"text-xs font-semibold text-foreground",children:"Reason for closing (Optional)"}),s.jsx(De,{value:we,onChange:W=>Ce(W.target.value),placeholder:"e.g. Issue resolved by support team",className:"text-sm"})]}),s.jsxs(Js,{className:"gap-2 sm:gap-0 mt-2",children:[s.jsx(ue,{variant:"outline",size:"sm",onClick:()=>me(!1),disabled:!!ze,children:"Cancel"}),s.jsxs(ue,{variant:"destructive",size:"sm",onClick:Da,disabled:!!ze,children:[ze?s.jsx(ve,{icon:ur,size:14,className:"animate-spin mr-1.5"}):s.jsx(ve,{icon:va,size:14,className:"mr-1.5"}),"Confirm Close"]})]})]})}),s.jsx(Qs,{open:ft,onOpenChange:Pt,children:s.jsxs(hs,{className:"sm:max-w-[450px]",children:[s.jsxs(gs,{children:[s.jsxs(xs,{className:"text-base flex items-center gap-2",children:[s.jsx(ve,{icon:is,size:18,className:"text-primary"}),"Open Direct Ticket"]}),s.jsx(vs,{className:"text-xs",children:"Select a support department to create a new ticket channel in Discord immediately."})]}),s.jsxs("div",{className:"space-y-4 py-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(_e,{className:"text-xs font-semibold",children:"Department"}),s.jsxs(Ca,{value:gn,onValueChange:Yr,children:[s.jsx(Br,{className:"text-xs border-border bg-secondary/30",children:s.jsx(Sa,{})}),s.jsxs($r,{children:[s.jsx(vt,{value:"general",children:"🎫 General Support"}),s.jsx(vt,{value:"purchase",children:"💳 Purchase & Billing Support"}),s.jsx(vt,{value:"reports",children:"🚨 Player Report"}),s.jsx(vt,{value:"appeals",children:"⚖️ Ban Appeals"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(_e,{className:"text-xs font-semibold",children:"Ticket Subject / Reason"}),s.jsx(De,{value:_n,onChange:W=>wn(W.target.value),placeholder:"e.g. Assistance with server permissions",className:"text-xs border-border bg-secondary/30"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(_e,{className:"text-xs font-semibold",children:"Discord User ID (Optional)"}),s.jsx(De,{value:Xn,onChange:W=>Zn(W.target.value),placeholder:"e.g. 123456789012345678 (Leave blank for yourself)",className:"text-xs font-mono border-border bg-secondary/30"}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"If specified, the ticket channel will be created for this user."})]})]}),s.jsxs(Js,{className:"gap-2 sm:gap-0",children:[s.jsx(ue,{variant:"outline",size:"sm",onClick:()=>Pt(!1),disabled:It,className:"text-xs",children:"Cancel"}),s.jsxs(ue,{size:"sm",onClick:nn,disabled:It||!_n.trim(),className:"gap-1.5 text-xs bg-primary font-semibold",children:[It?s.jsx(ve,{icon:ur,size:14,className:"animate-spin"}):s.jsx(ve,{icon:is,size:14}),It?"Opening Ticket...":"Open Ticket"]})]})]})})]})}const SP=["admin","moderator","editor","viewer","custom"];function NP(){return{mode:"add",id:"",username:"",globalName:"",role:"viewer",enabled:!0,permissions:ls("viewer"),yamlOwner:!1}}function EP({permissions:t,onChange:n,disabled:a}){const o=d=>n({...t,...d}),c=[{key:"overview",title:"Dashboard Overview",description:"Access to system metrics, bot health status, and main dashboard stats."},{key:"tickets",title:"Support Tickets",description:"View open support tickets, live web chat, send staff replies, and close tickets."},{key:"transcripts",title:"Ticket Transcripts",description:"Access saved ticket HTML transcripts and configure public transcript options."},{key:"logs",title:"Console Terminal Logs",description:"View real-time bot terminal output, system logs, and runtime error traces."}],l=[["supportbot","Bot config","Main bot token, prefix, channels, categories, and core settings."],["ticket-panel","Ticket panel","Ticket home embed, button labels, dropdown options, and panel styling."],["commands","Commands","Enable/disable slash commands, descriptions, and custom names."],["messages","Messages","Custom bot response messages, welcome embeds, and embed colors."],["supportbot-ai","AI assistant","Configure AI support rules, model API keys, and auto-response channels."]];return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"General & Modules Access"}),s.jsx("div",{className:"grid gap-2.5",children:c.map(({key:d,title:m,description:p})=>s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:m}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:p})]}),s.jsx(kt,{checked:t[d]??(d==="tickets"?t.overview:!1),disabled:a,onCheckedChange:g=>o({[d]:g}),className:"shrink-0"})]},d))})]}),s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Administration & Settings"}),s.jsxs("div",{className:"grid gap-2.5",children:[s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Settings (View)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"View system branding, OAuth configurations, and system health details."})]}),s.jsx(kt,{checked:t.settings.view,disabled:a,onCheckedChange:d=>o({settings:{...t.settings,view:d}}),className:"shrink-0"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Settings (Install Updates)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"Perform 1-click bot system updates and trigger bot server restarts."})]}),s.jsx(kt,{checked:t.settings.update,disabled:a,onCheckedChange:d=>o({settings:{...t.settings,update:d}}),className:"shrink-0"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Users & Groups (View)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"View dashboard staff accounts and permission group listings."})]}),s.jsx(kt,{checked:t.users.view,disabled:a,onCheckedChange:d=>o({users:{...t.users,view:d}}),className:"shrink-0"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Users & Groups (Manage)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"Create, edit, assign, and delete staff accounts and permission groups."})]}),s.jsx(kt,{checked:t.users.manage,disabled:a,onCheckedChange:d=>o({users:{...t.users,manage:d}}),className:"shrink-0"})]})]})]}),s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Configuration Files Access"}),s.jsxs("div",{className:"grid gap-2.5",children:[l.map(([d,m,p])=>{var v;const g=((v=t.configs)==null?void 0:v[d])??{view:!1,edit:!1};return s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:m}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:p})]}),s.jsxs("div",{className:"flex items-center gap-4 shrink-0",children:[s.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground cursor-pointer",children:[s.jsx("span",{children:"View"}),s.jsx(kt,{checked:g.view,disabled:a,onCheckedChange:b=>o({configs:{...t.configs,[d]:{...g,view:b}}})})]}),s.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground cursor-pointer",children:[s.jsx("span",{children:"Edit"}),s.jsx(kt,{checked:g.edit,disabled:a,onCheckedChange:b=>o({configs:{...t.configs,[d]:{...g,edit:b,view:b?!0:g.view}}})})]})]})]},d)}),s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Raw YAML Code Editor"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"Access the raw YAML code editor tab to view or edit full raw configuration files."})]}),s.jsx("div",{className:"flex items-center gap-4 shrink-0",children:s.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground cursor-pointer",children:[s.jsx("span",{children:"Access"}),s.jsx(kt,{checked:t.rawYaml??!1,disabled:a,onCheckedChange:d=>o({rawYaml:d})})]})})]})]})]})]})}function kP(t){return t.permissions.users.manage?"Full + user management":t.permissions.settings.update?"Configs + settings updates":Object.values(t.permissions.configs).some(n=>n.edit)?"Can edit configs":"View only"}function TP(){const{user:t,hasPermission:n}=qt(),a=n("users.manage"),[o,c]=f.useState([]),[l,d]=f.useState([]),[m,p]=f.useState(!0),[g,v]=f.useState(""),[b,w]=f.useState(null),[y,C]=f.useState(!1),S=f.useCallback(async()=>{p(!0),v("");try{const[R,L]=await Promise.all([Ne.listDashboardUsers(),Ne.listGroups().catch(()=>({data:{groups:[]}}))]);R.data&&c(R.data.users),L.data&&d(L.data.groups)}catch(R){v(R instanceof Error?R.message:"Failed to load users")}finally{p(!1)}},[]);f.useEffect(()=>{S()},[S]);const E=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 k(){w(NP())}function N(R){w({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:ls(R.role),yamlOwner:R.yamlOwner})}function T(R){b&&w({...b,role:R,permissions:ls(R,b.permissions)})}async function M(){if(!(!b||!a)){C(!0),v("");try{b.mode==="add"?await Ne.addDashboardUser({id:b.id.trim(),role:b.role,username:b.username||void 0,globalName:b.globalName||void 0,enabled:b.enabled,permissions:b.role==="custom"?b.permissions:void 0}):await Ne.updateDashboardUser(b.id,{role:b.yamlOwner?void 0:b.role,enabled:b.enabled,username:b.username||void 0,globalName:b.globalName||void 0,permissions:b.role==="custom"?b.permissions:void 0}),w(null),await S()}catch(R){v(R instanceof Error?R.message:"Could not save user")}finally{C(!1)}}}async function _(R){if(a&&window.confirm("Remove this user from the dashboard?")){v("");try{await Ne.removeDashboardUser(R),await S()}catch(L){v(L instanceof Error?L.message:"Could not remove user")}}}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Users"}),s.jsxs("p",{className:"text-muted-foreground",children:["Control who can sign in and what they can view or edit. Owners in"," ",s.jsx("code",{className:"rounded bg-primary/10 px-1 text-xs text-primary",children:"api.yml"})," ","always have full access."]})]}),a?s.jsxs(ue,{onClick:k,children:[s.jsx(ve,{icon:sg,size:16,className:"mr-2"}),"Add user"]}):null]}),g?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:g})}):null,s.jsx(Ze,{className:"border-border bg-card overflow-hidden",children:s.jsx(Qe,{className:"p-0",children:m?s.jsxs("div",{className:"p-4 space-y-2",children:[s.jsx(Be,{className:"h-8 w-full rounded-md"}),s.jsx(Be,{className:"h-8 w-full rounded-md"})]}):E.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-muted-foreground",children:"No users found."}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-left text-xs",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/80 bg-secondary/30 text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:[s.jsx("th",{className:"px-4 py-2.5",children:"User"}),s.jsx("th",{className:"px-4 py-2.5",children:"Group"}),s.jsx("th",{className:"px-4 py-2.5",children:"Access Summary"}),s.jsx("th",{className:"px-4 py-2.5",children:"Status"}),a&&s.jsx("th",{className:"px-4 py-2.5 text-right",children:"Actions"})]})}),s.jsx("tbody",{className:"divide-y divide-border/40",children:E.map(R=>{const L=l.find(I=>I.id===R.groupId||I.id===R.role),te=(L==null?void 0:L.color)||"#10B981",K=(L==null?void 0:L.name)||$y[R.yamlOwner?"owner":R.role]||R.role;return s.jsxs("tr",{className:"transition-colors hover:bg-secondary/25",children:[s.jsx("td",{className:"px-4 py-2.5 font-medium whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsxs(bs,{className:"size-7",children:[s.jsx(eo,{src:R.avatar,alt:R.username}),s.jsx(ys,{className:"text-[10px]",children:(R.username||R.id).slice(0,2).toUpperCase()})]}),s.jsxs("div",{className:"min-w-0 leading-tight",children:[s.jsxs("p",{className:"truncate font-semibold text-foreground text-xs",children:[P2(R),R.id===(t==null?void 0:t.id)?s.jsx("span",{className:"text-[11px] text-primary font-normal ml-1",children:"(you)"}):""]}),s.jsx("p",{className:"truncate text-[10px] text-muted-foreground font-mono",children:R.id})]})]})}),s.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"size-2 rounded-full shrink-0 shadow-sm",style:{backgroundColor:te}}),s.jsx("span",{className:"font-medium text-xs text-foreground",children:K}),R.yamlOwner&&s.jsx("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded bg-primary/10 text-primary border border-primary/20",children:"Config Owner"})]})}),s.jsx("td",{className:"px-4 py-2.5 text-xs text-muted-foreground max-w-xs truncate",children:kP(R)}),s.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:R.enabled?s.jsx(Fn,{className:"text-[10px] px-2 py-0.5 bg-emerald-500/15 text-emerald-400 hover:bg-emerald-500/15 border-emerald-500/20",children:"Active"}):s.jsx(Fn,{variant:"outline",className:"text-[10px] px-2 py-0.5",children:"Disabled"})}),a&&s.jsx("td",{className:"px-4 py-2.5 text-right whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsxs(ue,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs gap-1 text-muted-foreground hover:text-foreground",onClick:()=>N(R),children:[s.jsx(ve,{icon:v8,size:13}),"Edit"]}),!R.yamlOwner&&s.jsxs(ue,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs gap-1 text-muted-foreground hover:text-destructive",onClick:()=>_(R.id),children:[s.jsx(ve,{icon:wi,size:13}),"Remove"]})]})})]},R.id)})})]})})})}),s.jsx(Qs,{open:!!b,onOpenChange:R=>!R&&w(null),children:s.jsxs(hs,{className:"max-h-[90vh] max-w-lg overflow-y-auto",children:[s.jsxs(gs,{children:[s.jsx(xs,{children:(b==null?void 0:b.mode)==="add"?"Add dashboard user":"Edit user"}),s.jsx(vs,{children:b!=null&&b.yamlOwner?"This user is an owner in api.yml. Role and removal are managed in the config file.":P8[(b==null?void 0:b.role)??"viewer"]})]}),b?s.jsxs("div",{className:"space-y-4",children:[b.mode==="add"?s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"discord-id",children:"Discord user ID"}),s.jsx(De,{id:"discord-id",value:b.id,onChange:R=>w({...b,id:R.target.value}),placeholder:"829112572816130058"})]}):null,s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{children:"Display name (optional)"}),s.jsx(De,{value:b.globalName,onChange:R=>w({...b,globalName:R.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{children:"Username (optional)"}),s.jsx(De,{value:b.username,onChange:R=>w({...b,username:R.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{children:"Permission Group"}),s.jsxs(Ca,{value:b.role,disabled:b.yamlOwner,onValueChange:R=>{const L=l.find(te=>te.id===R);L?w({...b,role:R,permissions:L.permissions}):T(R)},children:[s.jsx(Br,{children:s.jsx(Sa,{})}),s.jsx($r,{children:b.yamlOwner?s.jsx(vt,{value:"owner",children:"Owner"}):l.length>0?l.map(R=>s.jsx(vt,{value:R.id,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"size-2.5 rounded-full shrink-0",style:{backgroundColor:R.color||"#10B981"}}),s.jsx("span",{children:R.name})]})},R.id)):SP.map(R=>s.jsx(vt,{value:R,children:$y[R]},R))})]})]}),s.jsxs("label",{className:"flex items-center justify-between rounded-lg border border-border px-3 py-2",children:[s.jsx("span",{className:"text-sm",children:"Account enabled"}),s.jsx(kt,{checked:b.enabled,disabled:b.yamlOwner,onCheckedChange:R=>w({...b,enabled:R})})]}),b.role==="custom"&&!b.yamlOwner?s.jsx(EP,{permissions:b.permissions,onChange:R=>w({...b,permissions:R})}):null]}):null,s.jsxs(Js,{children:[s.jsx(ue,{variant:"outline",onClick:()=>w(null),children:"Cancel"}),s.jsx(ue,{disabled:y||!a||(b==null?void 0:b.mode)==="add"&&!/^\d{17,20}$/.test(b.id.trim()),onClick:()=>void M(),children:y?"Saving…":"Save"})]})]})})]})}const MP=[{name:"Emerald",hex:"#10B981"},{name:"Blue",hex:"#3B82F6"},{name:"Purple",hex:"#8B5CF6"},{name:"Amber",hex:"#F59E0B"},{name:"Red",hex:"#EF4444"},{name:"Cyan",hex:"#06B6D4"},{name:"Gray",hex:"#6B7280"}];function RP({permissions:t,onChange:n,disabled:a}){const o=d=>n({...t,...d}),c=[{key:"overview",title:"Dashboard Overview",description:"Access to system metrics, bot health status, and main dashboard stats."},{key:"tickets",title:"Support Tickets",description:"View open support tickets, live web chat, send staff replies, and close tickets."},{key:"transcripts",title:"Ticket Transcripts",description:"Access saved ticket HTML transcripts and configure public transcript options."},{key:"logs",title:"Console Terminal Logs",description:"View real-time bot terminal output, system logs, and runtime error traces."}],l=[["supportbot","Bot config","Main bot token, prefix, channels, categories, and core settings."],["ticket-panel","Ticket panel","Ticket home embed, button labels, dropdown options, and panel styling."],["commands","Commands","Enable/disable slash commands, descriptions, and custom names."],["messages","Messages","Custom bot response messages, welcome embeds, and embed colors."],["supportbot-ai","AI assistant","Configure AI support rules, model API keys, and auto-response channels."]];return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"General & Modules Access"}),s.jsx("div",{className:"grid gap-2.5",children:c.map(({key:d,title:m,description:p})=>s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:m}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:p})]}),s.jsx(kt,{checked:t[d]??(d==="tickets"?t.overview:!1),disabled:a,onCheckedChange:g=>o({[d]:g}),className:"shrink-0"})]},d))})]}),s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Administration & Settings"}),s.jsxs("div",{className:"grid gap-2.5",children:[s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Settings (View)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"View system branding, OAuth configurations, and system health details."})]}),s.jsx(kt,{checked:t.settings.view,disabled:a,onCheckedChange:d=>o({settings:{...t.settings,view:d}}),className:"shrink-0"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Settings (Install Updates)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"Perform 1-click bot system updates and trigger bot server restarts."})]}),s.jsx(kt,{checked:t.settings.update,disabled:a,onCheckedChange:d=>o({settings:{...t.settings,update:d}}),className:"shrink-0"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Users & Groups (View)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"View dashboard staff accounts and permission group listings."})]}),s.jsx(kt,{checked:t.users.view,disabled:a,onCheckedChange:d=>o({users:{...t.users,view:d}}),className:"shrink-0"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Users & Groups (Manage)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"Create, edit, assign, and delete staff accounts and permission groups."})]}),s.jsx(kt,{checked:t.users.manage,disabled:a,onCheckedChange:d=>o({users:{...t.users,manage:d}}),className:"shrink-0"})]})]})]}),s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Configuration Files Access"}),s.jsxs("div",{className:"grid gap-2.5",children:[l.map(([d,m,p])=>{var v;const g=((v=t.configs)==null?void 0:v[d])??{view:!1,edit:!1};return s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:m}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:p})]}),s.jsxs("div",{className:"flex items-center gap-4 shrink-0",children:[s.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground cursor-pointer",children:[s.jsx("span",{children:"View"}),s.jsx(kt,{checked:g.view,disabled:a,onCheckedChange:b=>o({configs:{...t.configs,[d]:{...g,view:b}}})})]}),s.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground cursor-pointer",children:[s.jsx("span",{children:"Edit"}),s.jsx(kt,{checked:g.edit,disabled:a,onCheckedChange:b=>o({configs:{...t.configs,[d]:{...g,edit:b,view:b?!0:g.view}}})})]})]})]},d)}),s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Raw YAML Code Editor"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"Access the raw YAML code editor tab to view or edit full raw configuration files."})]}),s.jsx("div",{className:"flex items-center gap-4 shrink-0",children:s.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground cursor-pointer",children:[s.jsx("span",{children:"Access"}),s.jsx(kt,{checked:t.rawYaml??!1,disabled:a,onCheckedChange:d=>o({rawYaml:d})})]})})]})]})]})]})}function AP(){const{permissions:t,impersonateGroup:n,impersonatedGroup:a,stopImpersonation:o}=qt(),c=Mn(t,"users.manage"),[l,d]=f.useState([]),[m,p]=f.useState(!0),[g,v]=f.useState(null),[b,w]=f.useState(null),[y,C]=f.useState(!1),[S,E]=f.useState("add"),[k,N]=f.useState(!1),[T,M]=f.useState(""),[_,R]=f.useState(""),[L,te]=f.useState(""),[K,I]=f.useState("#10B981"),[G,Y]=f.useState(""),[ce,fe]=f.useState(ls("viewer")),se=async()=>{var V;p(!0),v(null);try{const O=await Ne.listGroups();d(((V=O.data)==null?void 0:V.groups)||[])}catch(O){v(O instanceof Error?O.message:"Failed to load groups")}finally{p(!1)}};f.useEffect(()=>{se()},[]);const P=()=>{E("add"),M(""),R(""),te(""),I("#10B981"),Y(""),fe(ls("viewer")),C(!0)},Z=V=>{E("edit"),M(V.id),R(V.name),te(V.description||""),I(V.color||"#10B981"),Y(V.discordRoleId||""),fe(V.permissions||ls("viewer")),C(!0)},ae=async()=>{if(!_.trim()){v("Group name is required");return}N(!0),v(null);try{S==="add"?(await Ne.createGroup({name:_.trim(),description:L.trim(),color:K,discordRoleId:G.trim()||null,permissions:ce}),w(`Group "${_}" created successfully.`)):(await Ne.updateGroup(T,{name:_.trim(),description:L.trim(),color:K,discordRoleId:G.trim()||null,permissions:ce}),w(`Group "${_}" updated successfully.`)),C(!1),await se()}catch(V){v(V instanceof Error?V.message:"Failed to save group")}finally{N(!1)}},re=async V=>{if(!V.isSystem&&confirm(`Are you sure you want to delete the group "${V.name}"?`))try{await Ne.deleteGroup(V.id),w(`Group "${V.name}" deleted.`),await se()}catch(O){v(O instanceof Error?O.message:"Failed to delete group")}};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Permission Groups"}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Create custom permission groups, assign staff members, and optionally sync with Discord Role IDs."})]}),c&&s.jsxs(ue,{onClick:P,className:"shrink-0 gap-2 bg-primary",children:[s.jsx(ve,{icon:sg,size:18}),"Create Group"]})]}),g&&s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:g})}),b&&s.jsx(Ye,{className:"border-emerald-500/30 bg-emerald-500/10 text-emerald-500",children:s.jsxs(qe,{className:"flex items-center justify-between",children:[s.jsx("span",{children:b}),s.jsx(ue,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:()=>w(null),children:"Dismiss"})]})}),s.jsx(Ze,{className:"border-border bg-card overflow-hidden",children:s.jsx(Qe,{className:"p-0",children:m?s.jsxs("div",{className:"p-4 space-y-2",children:[s.jsx(Be,{className:"h-8 w-full rounded-md"}),s.jsx(Be,{className:"h-8 w-full rounded-md"})]}):l.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-muted-foreground",children:'No permission groups found. Click "Create Group" to add one.'}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-left text-xs",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/80 bg-secondary/30 text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:[s.jsx("th",{className:"px-4 py-2.5",children:"Group"}),s.jsx("th",{className:"px-4 py-2.5",children:"Description"}),s.jsx("th",{className:"px-4 py-2.5",children:"Discord Role ID"}),s.jsx("th",{className:"px-4 py-2.5",children:"Enabled Permissions"}),s.jsx("th",{className:"px-4 py-2.5 text-right",children:"Actions"})]})}),s.jsx("tbody",{className:"divide-y divide-border/40",children:l.map(V=>{var O,D,$,H,X,xe,q;return s.jsxs("tr",{className:"transition-colors hover:bg-secondary/25",children:[s.jsx("td",{className:"px-4 py-2.5 font-medium whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"size-2.5 rounded-full shrink-0 shadow-sm",style:{backgroundColor:V.color||"#10B981"}}),s.jsx("span",{className:"text-foreground font-semibold text-xs",children:V.name}),V.isSystem&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold px-1.5 py-0.5 rounded-full bg-secondary text-secondary-foreground border border-border/80",children:[s.jsx(ve,{icon:qu,size:10}),"System"]})]})}),s.jsx("td",{className:"px-4 py-2.5 text-xs text-muted-foreground max-w-xs truncate",children:V.description||"—"}),s.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:V.discordRoleId?s.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground font-mono bg-secondary/50 px-2 py-0.5 rounded border border-border/50",children:[s.jsx(ve,{icon:qu,size:12,className:"text-primary"}),V.discordRoleId]}):s.jsx("span",{className:"text-xs text-muted-foreground/60",children:"—"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsxs("div",{className:"flex flex-wrap gap-1 max-w-md",children:[((O=V.permissions)==null?void 0:O.overview)&&s.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-primary/10 text-primary border border-primary/20",children:"Overview"}),(((D=V.permissions)==null?void 0:D.tickets)??(($=V.permissions)==null?void 0:$.overview))&&s.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:"Tickets"}),((H=V.permissions)==null?void 0:H.transcripts)&&s.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-purple-500/10 text-purple-400 border border-purple-500/20",children:"Transcripts"}),((X=V.permissions)==null?void 0:X.logs)&&s.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400 border border-blue-500/20",children:"Logs"}),((q=(xe=V.permissions)==null?void 0:xe.users)==null?void 0:q.manage)&&s.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"User Mgmt"})]})}),s.jsx("td",{className:"px-4 py-2.5 text-right whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsxs(ue,{size:"sm",variant:"ghost",className:`h-7 px-2 text-xs gap-1 ${(a==null?void 0:a.id)===V.id?"text-amber-400 font-bold bg-amber-500/15 border border-amber-500/30":"text-amber-400 hover:text-amber-300 hover:bg-amber-500/10"}`,onClick:()=>(a==null?void 0:a.id)===V.id?o():n(V.id),children:[s.jsx(ve,{icon:qu,size:13}),(a==null?void 0:a.id)===V.id?"Active Preview":"View as Group"]}),c&&V.id!=="owner"&&s.jsxs(ue,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs gap-1 text-muted-foreground hover:text-foreground",onClick:()=>Z(V),children:[s.jsx(ve,{icon:D2,size:13}),"Edit"]}),c&&!V.isSystem&&s.jsxs(ue,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs gap-1 text-muted-foreground hover:text-destructive",onClick:()=>re(V),children:[s.jsx(ve,{icon:wi,size:13}),"Delete"]})]})})]},V.id)})})]})})})}),s.jsx(Qs,{open:y,onOpenChange:C,children:s.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsxs(gs,{children:[s.jsx(xs,{children:S==="add"?"Create Permission Group":`Edit Group: ${_}`}),s.jsx(vs,{children:"Configure group metadata, custom color badge, Discord role sync, and permission rules."})]}),s.jsxs("div",{className:"space-y-4 py-2",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"group-name",children:"Group Name"}),s.jsx(De,{id:"group-name",placeholder:"e.g. Support Staff",value:_,onChange:V=>R(V.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"group-color",children:"Color Badge"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(tf,{value:K,onChange:I}),s.jsx(De,{value:K,onChange:V=>I(V.target.value),placeholder:"#10B981",className:"w-28 font-mono text-sm uppercase"}),s.jsx("div",{className:"flex flex-wrap gap-1 ml-auto",children:MP.map(V=>s.jsx("button",{type:"button",className:"size-6 rounded-full border border-white/20 transition-transform hover:scale-110",style:{backgroundColor:V.hex},onClick:()=>I(V.hex),title:V.name},V.hex))})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(_e,{htmlFor:"group-desc",children:"Description"}),s.jsx(De,{id:"group-desc",placeholder:"Brief description of what members in this group can access...",value:L,onChange:V=>te(V.target.value)})]}),s.jsx(TS,{id:"discord-role-id",label:"Discord Role ID (Optional Auto-Sync)",description:"If provided, Discord users with this Role ID will automatically inherit this group upon login.",kind:"role",value:G,onChange:V=>Y(String(V??""))}),s.jsxs("div",{className:"pt-2",children:[s.jsx("h4",{className:"text-sm font-semibold mb-3",children:"Group Permission Matrix"}),s.jsx(RP,{permissions:ce,onChange:fe})]})]}),s.jsxs(Js,{className:"gap-2 sm:gap-0",children:[s.jsx(ue,{variant:"outline",onClick:()=>C(!1),disabled:k,children:"Cancel"}),s.jsx(ue,{onClick:ae,disabled:k,className:"bg-primary",children:k?"Saving...":S==="add"?"Create Group":"Save Changes"})]})]})})]})}function _P({children:t}){const{isAuthenticated:n,loading:a}=qt();return a?s.jsx("div",{className:"flex min-h-svh items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):n?s.jsx(s.Fragment,{children:t}):s.jsx(ya,{to:"/login",replace:!0})}function DP(){const{complete:t,loading:n}=fS(),a=Kn();return n?s.jsx("div",{className:"flex min-h-svh items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):t?a.pathname==="/setup"?s.jsx(ya,{to:"/login",replace:!0}):s.jsxs(Py,{children:[s.jsx(cn,{path:"/login",element:s.jsx(bz,{})}),s.jsxs(cn,{element:s.jsx(_P,{children:s.jsx(TA,{})}),children:[s.jsx(cn,{index:!0,element:s.jsx(Vz,{})}),s.jsx(cn,{path:"system",element:s.jsx(ga,{permission:"overview",children:s.jsx(sP,{})})}),s.jsx(cn,{path:"settings",element:s.jsx(ga,{permission:"settings.view",children:s.jsx(nP,{})})}),s.jsx(cn,{path:"configs",element:s.jsx(gz,{})}),s.jsx(cn,{path:"logs",element:s.jsx(ga,{permission:"logs",children:s.jsx(mP,{})})}),s.jsx(cn,{path:"tickets",element:s.jsx(ga,{permission:"transcripts",children:s.jsx(CP,{})})}),s.jsx(cn,{path:"transcripts",element:s.jsx(ga,{permission:"transcripts",children:s.jsx(jP,{})})}),s.jsx(cn,{path:"users",element:s.jsx(ga,{permission:"users.view",children:s.jsx(TP,{})})}),s.jsx(cn,{path:"groups",element:s.jsx(ga,{permission:"users.view",children:s.jsx(AP,{})})}),s.jsx(cn,{path:"addons",element:s.jsx(ga,{permission:"settings.view",children:s.jsx(Fz,{})})}),s.jsx(cn,{path:"addons/builder",element:s.jsx(ga,{permission:"settings.update",children:s.jsx(Yz,{})})})]}),s.jsx(cn,{path:"*",element:s.jsx(ya,{to:"/",replace:!0})})]}):s.jsxs(Py,{children:[s.jsx(cn,{path:"/setup",element:s.jsx(Lz,{})}),s.jsx(cn,{path:"*",element:s.jsx(ya,{to:"/setup",replace:!0})})]})}function OP({...t}){return s.jsx(KO,{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"}},...t})}Zz();_3.createRoot(document.getElementById("root")).render(s.jsx(f.StrictMode,{children:s.jsx(a8,{children:s.jsx(aC,{children:s.jsx(B8,{children:s.jsx(MA,{children:s.jsxs(U8,{children:[s.jsx(DP,{}),s.jsx(OP,{})]})})})})})})); + `},e2=SL(TL)(t5),ML={config:EL},RL=function(){for(var n=arguments.length,a=new Array(n),o=0;o{o.current=!1}:t,n)}var Yn=XL;function zl(){}function si(t,n,a,o){return ZL(t,o)||QL(t,n,a,o)}function ZL(t,n){return t.editor.getModel(l5(t,n))}function QL(t,n,a,o){return t.editor.createModel(n,a,o?l5(t,o):void 0)}function l5(t,n){return t.Uri.parse(n)}function JL({original:t,modified:n,language:a,originalLanguage:o,modifiedLanguage:c,originalModelPath:l,modifiedModelPath:d,keepCurrentOriginalModel:m=!1,keepCurrentModifiedModel:p=!1,theme:g="light",loading:b="Loading...",options:v={},height:w="100%",width:y="100%",className:C,wrapperProps:S={},beforeMount:N=zl,onMount:E=zl}){let[T,M]=f.useState(!1),[k,_]=f.useState(!0),R=f.useRef(null),L=f.useRef(null),ne=f.useRef(null),X=f.useRef(E),I=f.useRef(N),H=f.useRef(!1);i5(()=>{let se=s5.init();return se.then(P=>(L.current=P)&&_(!1)).catch(P=>(P==null?void 0:P.type)!=="cancelation"&&console.error("Monaco initialization: error:",P)),()=>R.current?de():se.cancel()}),Yn(()=>{if(R.current&&L.current){let se=R.current.getOriginalEditor(),P=si(L.current,t||"",o||a||"text",l||"");P!==se.getModel()&&se.setModel(P)}},[l],T),Yn(()=>{if(R.current&&L.current){let se=R.current.getModifiedEditor(),P=si(L.current,n||"",c||a||"text",d||"");P!==se.getModel()&&se.setModel(P)}},[d],T),Yn(()=>{let se=R.current.getModifiedEditor();se.getOption(L.current.editor.EditorOption.readOnly)?se.setValue(n||""):n!==se.getValue()&&(se.executeEdits("",[{range:se.getModel().getFullModelRange(),text:n||"",forceMoveMarkers:!0}]),se.pushUndoStop())},[n],T),Yn(()=>{var se,P;(P=(se=R.current)==null?void 0:se.getModel())==null||P.original.setValue(t||"")},[t],T),Yn(()=>{let{original:se,modified:P}=R.current.getModel();L.current.editor.setModelLanguage(se,o||a||"text"),L.current.editor.setModelLanguage(P,c||a||"text")},[a,o,c],T),Yn(()=>{var se;(se=L.current)==null||se.editor.setTheme(g)},[g],T),Yn(()=>{var se;(se=R.current)==null||se.updateOptions(v)},[v],T);let q=f.useCallback(()=>{var W;if(!L.current)return;I.current(L.current);let se=si(L.current,t||"",o||a||"text",l||""),P=si(L.current,n||"",c||a||"text",d||"");(W=R.current)==null||W.setModel({original:se,modified:P})},[a,n,c,t,o,l,d]),ce=f.useCallback(()=>{var se;!H.current&&ne.current&&(R.current=L.current.editor.createDiffEditor(ne.current,{automaticLayout:!0,...v}),q(),(se=L.current)==null||se.editor.setTheme(g),M(!0),H.current=!0)},[v,g,q]);f.useEffect(()=>{T&&X.current(R.current,L.current)},[T]),f.useEffect(()=>{!k&&!T&&ce()},[k,T,ce]);function de(){var P,W,oe,ae;let se=(P=R.current)==null?void 0:P.getModel();m||((W=se==null?void 0:se.original)==null||W.dispose()),p||((oe=se==null?void 0:se.modified)==null||oe.dispose()),(ae=R.current)==null||ae.dispose()}return ve.createElement(o5,{width:y,height:w,isEditorReady:T,loading:b,_ref:ne,className:C,wrapperProps:S})}var ez=JL;f.memo(ez);function tz(t){let n=f.useRef();return f.useEffect(()=>{n.current=t},[t]),n.current}var nz=tz,Vu=new Map;function rz({defaultValue:t,defaultLanguage:n,defaultPath:a,value:o,language:c,path:l,theme:d="light",line:m,loading:p="Loading...",options:g={},overrideServices:b={},saveViewState:v=!0,keepCurrentModel:w=!1,width:y="100%",height:C="100%",className:S,wrapperProps:N={},beforeMount:E=zl,onMount:T=zl,onChange:M,onValidate:k=zl}){let[_,R]=f.useState(!1),[L,ne]=f.useState(!0),X=f.useRef(null),I=f.useRef(null),H=f.useRef(null),q=f.useRef(T),ce=f.useRef(E),de=f.useRef(),se=f.useRef(o),P=nz(l),W=f.useRef(!1),oe=f.useRef(!1);i5(()=>{let O=s5.init();return O.then(D=>(X.current=D)&&ne(!1)).catch(D=>(D==null?void 0:D.type)!=="cancelation"&&console.error("Monaco initialization: error:",D)),()=>I.current?G():O.cancel()}),Yn(()=>{var D,B,V,Z;let O=si(X.current,t||o||"",n||c||"",l||a||"");O!==((D=I.current)==null?void 0:D.getModel())&&(v&&Vu.set(P,(B=I.current)==null?void 0:B.saveViewState()),(V=I.current)==null||V.setModel(O),v&&((Z=I.current)==null||Z.restoreViewState(Vu.get(l))))},[l],_),Yn(()=>{var O;(O=I.current)==null||O.updateOptions(g)},[g],_),Yn(()=>{!I.current||o===void 0||(I.current.getOption(X.current.editor.EditorOption.readOnly)?I.current.setValue(o):o!==I.current.getValue()&&(oe.current=!0,I.current.executeEdits("",[{range:I.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),I.current.pushUndoStop(),oe.current=!1))},[o],_),Yn(()=>{var D,B;let O=(D=I.current)==null?void 0:D.getModel();O&&c&&((B=X.current)==null||B.editor.setModelLanguage(O,c))},[c],_),Yn(()=>{var O;m!==void 0&&((O=I.current)==null||O.revealLine(m))},[m],_),Yn(()=>{var O;(O=X.current)==null||O.editor.setTheme(d)},[d],_);let ae=f.useCallback(()=>{var O;if(!(!H.current||!X.current)&&!W.current){ce.current(X.current);let D=l||a,B=si(X.current,o||t||"",n||c||"",D||"");I.current=(O=X.current)==null?void 0:O.editor.create(H.current,{model:B,automaticLayout:!0,...g},b),v&&I.current.restoreViewState(Vu.get(D)),X.current.editor.setTheme(d),m!==void 0&&I.current.revealLine(m),R(!0),W.current=!0}},[t,n,a,o,c,l,g,b,v,d,m]);f.useEffect(()=>{_&&q.current(I.current,X.current)},[_]),f.useEffect(()=>{!L&&!_&&ae()},[L,_,ae]),se.current=o,f.useEffect(()=>{var O,D;_&&M&&((O=de.current)==null||O.dispose(),de.current=(D=I.current)==null?void 0:D.onDidChangeModelContent(B=>{oe.current||M(I.current.getValue(),B)}))},[_,M]),f.useEffect(()=>{if(_){let O=X.current.editor.onDidChangeMarkers(D=>{var V;let B=(V=I.current.getModel())==null?void 0:V.uri;if(B&&D.find(Z=>Z.path===B.path)){let Z=X.current.editor.getModelMarkers({resource:B});k==null||k(Z)}});return()=>{O==null||O.dispose()}}return()=>{}},[_,k]);function G(){var O,D;(O=de.current)==null||O.dispose(),w?v&&Vu.set(l,I.current.saveViewState()):(D=I.current.getModel())==null||D.dispose(),I.current.dispose()}return ve.createElement(o5,{width:y,height:C,isEditorReady:_,loading:p,_ref:H,className:S,wrapperProps:N})}var az=rz,sz=f.memo(az),oz=sz;function iz(t){return t!==null&&typeof t=="object"&&"Command"in t}function lz(t){return Object.entries(t).filter(([,n])=>iz(n)).map(([n,a])=>({key:n,...a}))}function cz({data:t,onChange:n}){const a=lz(t);function o(c,l){const d=t[c];n({...t,[c]:{...d,...l}})}return a.length===0?s.jsx("p",{className:"text-sm text-muted-foreground",children:"No commands found in this config."}):s.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:a.map(c=>s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{className:"flex flex-row items-center gap-2 space-y-0 pb-2",children:[s.jsx("div",{className:"flex size-9 items-center justify-center rounded-lg bg-primary/15 text-primary",children:s.jsx(xe,{icon:ds,size:18})}),s.jsx(ft,{className:"text-base",children:c.key})]}),s.jsxs(et,{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Ae,{htmlFor:`${c.key}-enabled`,children:"Enabled"}),s.jsx(Mt,{id:`${c.key}-enabled`,checked:c.Enabled!==!1,onCheckedChange:l=>o(c.key,{Enabled:l})})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Ae,{children:"Slash command"}),s.jsx(_e,{value:c.Command??"",onChange:l=>o(c.key,{Command:l.target.value}),className:"border-border bg-secondary/30 font-mono"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Ae,{children:"Description"}),s.jsx(_e,{value:c.Description??"",onChange:l=>o(c.key,{Description:l.target.value}),className:"border-border bg-secondary/30"})]})]})]},c.key))})}function uz(t,n){let a=structuredClone(n);if(t==="supportbot"){const o=kr(a,"General.Token");o&&o!=="BOT_TOKEN"&&(a=Gn(a,"General.Token","BOT_TOKEN"))}if(t==="supportbot-ai"){const o=kr(a,"General.Model_API_Key");o&&o!=="MODEL_API_KEY"&&(a=Gn(a,"General.Model_API_Key","MODEL_API_KEY"))}return a}function dz(t,n,a,o){const c={};for(const l of n)for(const d of l.fields){const m=kr(a,d.path),p=kr(o,d.path);d.type==="secret"&&(m==="BOT_TOKEN"||m==="MODEL_API_KEY"||m===""||m===void 0)||JSON.stringify(m)!==JSON.stringify(p)&&(c[`${t}:${d.path}`]=m)}return c}function fz(t,n){const a=new Map,o=[];for(const l of t){const d=l.path.split(".");if(d.length>=5&&d[1]==="DepartmentSystem"&&d[2]==="Departments"){const m=d[3],p=a.get(m)??[];p.push(l),a.set(m,p)}else if(d.length>=3){const m=d[1],p=a.get(m)??[];p.push(l),a.set(m,p)}else o.push(l)}if(a.size===0)return{standalone:t,groups:[]};const c=[...a.entries()].map(([l,d])=>{const m=["enabled","name","description","emoji","category","role","channelprefix","defaultpriority","questions"];d.sort((b,v)=>{var N,E;const w=((N=b.path.split(".").pop())==null?void 0:N.toLowerCase())||"",y=((E=v.path.split(".").pop())==null?void 0:E.toLowerCase())||"",C=m.indexOf(w),S=m.indexOf(y);return C!==-1&&S!==-1?C-S:C!==-1?-1:S!==-1?1:w.localeCompare(y)});const p=d.find(b=>b.path.toLowerCase().endsWith(".name")||b.path.toLowerCase().endsWith(".title"));let g="";if(p&&n){const b=kr(n,p.path);typeof b=="string"&&b.trim()&&(g=b.trim())}return g||(g=l.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,b=>b.toUpperCase())),{key:l,name:g,fields:d}});return{standalone:o,groups:c}}function mz({configFile:t}){const{permissions:n,canEditConfig:a}=Yt(),o=Rn(n,"configs.raw_yaml"),c=!a(t),[l,d]=f.useState(null),[m,p]=f.useState(null),[g,b]=f.useState(!0),[v,w]=f.useState(!1),[y,C]=f.useState(""),[S,N]=f.useState(""),[E,T]=f.useState("visual");f.useEffect(()=>{!o&&E==="yaml"&&T("visual")},[o,E]);const[M,k]=f.useState(""),[_,R]=f.useState(""),[L]=wd(),[ne,X]=f.useState(()=>L.get("tab")||null),[I,H]=f.useState(!1),[q,ce]=f.useState(""),[de,se]=f.useState(""),P=()=>{const K=q.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"");if(!K||!l)return;const ge=de.trim()||K,me=`Ticket.DepartmentSystem.Departments.${K}`,$={...l};Gn($,`${me}.Name`,ge),Gn($,`${me}.Description`,`Open a ${ge} ticket`),Gn($,`${me}.Emoji`,"🎫"),Gn($,`${me}.Category`,"CATEGORY_ID"),Gn($,`${me}.Role`,"ROLE_ID"),Gn($,`${me}.ChannelPrefix`,`${K}-`),Gn($,`${me}.DefaultPriority`,"normal"),Gn($,`${me}.Questions`,["What do you need assistance with?"]),d($),H(!1),ce(""),se("")},W=K=>{if(!l)return;const ge=`Ticket.DepartmentSystem.Departments.${K}`,me=JSON.parse(JSON.stringify(l));if(Object.keys(me).forEach($=>{($.startsWith(ge)||$===ge)&&delete me[$]}),me.Ticket&&typeof me.Ticket=="object"){const $=me.Ticket.DepartmentSystem;$&&typeof $=="object"&&$.Departments&&typeof $.Departments=="object"&&delete $.Departments[K]}d(me)},oe=FM(t),ae=f.useMemo(()=>!oe||oe==="commands"||!l?oe:ZO(oe,l),[oe,l]);f.useEffect(()=>{var K;if(ae&&ae!=="commands"){const ge=L.get("tab");if(ge&&ae.find(me=>me.title.toLowerCase()===ge.toLowerCase())){const me=ae.find($=>$.title.toLowerCase()===ge.toLowerCase());me&&me.title!==ne&&X(me.title)}else(!ne||!ae.find(me=>me.title===ne))&&X(((K=ae[0])==null?void 0:K.title)||null)}},[ae,ne,L]);const G=f.useCallback(async()=>{b(!0),C(""),N("");try{const ge=(await Ne.getConfigJson(t)).data??{},me=uz(t,ge);d(me),p(me);const ie=(await Ne.getConfigRaw(t)).data??"",ye=z8(ie,t);k(ye),R(ye)}catch(K){C(K instanceof Error?K.message:"Failed to load config")}finally{b(!1)}},[t]);f.useEffect(()=>{G()},[G]);function O(K,ge){d(me=>me&&Gn(me,K,ge))}async function D(){if(!(c||M===_)){w(!0),C(""),N("");try{const K=await nd(()=>Ne.saveConfigRaw(t,M));N(K.message||"Config saved."),await G()}catch(K){C(K instanceof Error?K.message:"Save failed")}finally{w(!1)}}}async function B(){if(!(c||!l||!m)){if(E==="yaml"){await D();return}w(!0),C(""),N("");try{if(oe==="commands"){const K={};for(const me of Object.keys(l))JSON.stringify(l[me])!==JSON.stringify(m[me])&&(K[`${t}:${me}`]=l[me]);if(Object.keys(K).length===0){N("No changes to save.");return}const ge=await nd(()=>Ne.updateConfigFields(K));N(ge.message||"")}else if(ae&&ae!=="commands"){const K=dz(t,ae,l,m);if(Object.keys(K).length===0){N("No changes to save.");return}const ge=await nd(()=>Ne.updateConfigFields(K));N(ge.message||"")}await G()}catch(K){C(K instanceof Error?K.message:"Save failed")}finally{w(!1)}}}if(oe===null)return s.jsx(Ye,{children:s.jsx(qe,{children:"No visual editor available for this file."})});if(g)return s.jsxs("div",{className:"space-y-4",children:[s.jsx(Ue,{className:"h-24 w-full rounded-xl"}),s.jsx(Ue,{className:"h-48 w-full rounded-xl"})]});if(!l)return s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:y||"Failed to load"})});const V=m&&JSON.stringify(l)!==JSON.stringify(m),be=E==="yaml"?M!==_:V;return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o?s.jsxs("div",{className:"flex rounded-lg border border-border p-0.5",children:[s.jsx(ue,{type:"button",variant:E==="visual"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>T("visual"),children:"Visual"}),s.jsx(ue,{type:"button",variant:E==="yaml"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>T("yaml"),children:"YAML"})]}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[be?s.jsx("span",{className:"text-xs text-amber-500",children:"Unsaved changes"}):null,s.jsx(ue,{variant:"outline",size:"sm",onClick:G,disabled:g||v,children:"Reload"}),c?s.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}):s.jsxs(ue,{size:"sm",onClick:B,disabled:v||!be,children:[s.jsx(xe,{icon:Sd,size:16,className:"mr-1.5"}),v?"Saving…":"Save"]})]})]}),y?s.jsxs(Ye,{variant:"destructive",children:[s.jsx(xe,{icon:ig,size:18}),s.jsx(qe,{children:y})]}):null,S?s.jsx(Ye,{className:"border-primary/30 bg-primary/10 text-primary",children:s.jsx(qe,{children:S})}):null,E==="yaml"?s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{className:"pb-3",children:[s.jsx(ft,{className:"text-base",children:"Raw YAML"}),s.jsx(Ot,{children:"Edit the full file. Use this for nested lists (e.g. welcome buttons) or any option not in Visual mode."})]}),s.jsx(et,{className:"h-[min(520px,60vh)] overflow-hidden rounded-b-xl border-t border-border p-0",children:s.jsx(oz,{height:"100%",language:"yaml",theme:"vs-dark",value:M,onChange:K=>k(K||""),options:{readOnly:c,minimap:{enabled:!1},fontSize:13,wordWrap:"on",scrollBeyondLastLine:!1,padding:{top:16},tabSize:2}})})]}):oe==="commands"?s.jsx(cz,{data:l,onChange:K=>d(K)}):ae&&ae!=="commands"?s.jsxs("div",{className:"grid gap-6 lg:grid-cols-[200px_1fr]",children:[s.jsx("nav",{className:"flex flex-col gap-1",children:ae.map(K=>s.jsx("button",{onClick:()=>X(K.title),className:pe("text-left px-3 py-2 text-sm rounded-md transition-colors",ne===K.title?"bg-primary text-primary-foreground font-medium":"text-muted-foreground hover:bg-secondary hover:text-foreground"),children:K.title},K.title))}),s.jsx("div",{className:"min-w-0",children:ae.filter(K=>K.title===ne).map(K=>s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{className:"pb-3 flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsx(ft,{className:"text-base",children:K.title}),K.description?s.jsx(Ot,{children:K.description}):null]}),K.title==="Ticket Departments"&&!c&&s.jsxs(ue,{type:"button",size:"sm",variant:"outline",onClick:()=>H(!0),className:"gap-1.5 text-xs h-8 shrink-0",children:[s.jsx(xe,{icon:sg,size:14})," Add Department"]})]}),s.jsx(et,{className:"space-y-6",children:(()=>{const{standalone:ge,groups:me}=fz(K.fields,l);return s.jsxs(s.Fragment,{children:[ge.length>0&&s.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:ge.map($=>s.jsx("div",{className:$.type==="textarea"||$.type==="stringList"?"sm:col-span-2":"",children:s.jsx(pd,{field:$,value:kr(l,$.path),readOnly:c,onChange:ie=>O($.path,ie)})},$.path))}),me.map($=>s.jsxs("div",{className:"rounded-xl border border-border bg-card/60 p-4 space-y-4 shadow-sm transition-all hover:border-primary/40",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 pb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-semibold text-base text-foreground",children:$.name}),s.jsx("span",{className:"text-xs font-mono px-2.5 py-0.5 rounded-full bg-primary/10 text-primary border border-primary/20 font-medium",children:K.title==="Ticket Departments"?`Ticket.${$.key}`:$.key})]}),K.title==="Ticket Departments"&&$.key!=="DepartmentSystem"&&!c&&s.jsx(ue,{type:"button",size:"sm",variant:"ghost",onClick:()=>W($.key),className:"h-7 w-7 p-0 text-muted-foreground hover:text-destructive",title:"Delete Department",children:s.jsx(xe,{icon:bi,size:14})})]}),s.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:$.fields.map(ie=>s.jsx("div",{className:ie.type==="textarea"||ie.type==="stringList"?"sm:col-span-2":"",children:s.jsx(pd,{field:ie,value:kr(l,ie.path),readOnly:c,onChange:ye=>O(ie.path,ye)})},ie.path))})]},$.key))]})})()})]},K.title))})]}):null,s.jsx(Qs,{open:I,onOpenChange:H,children:s.jsxs(hs,{className:"sm:max-w-[400px]",children:[s.jsxs(gs,{children:[s.jsx(xs,{className:"text-base",children:"Add Ticket Department"}),s.jsx(bs,{className:"text-xs",children:"Create a new support department for ticket creation."})]}),s.jsxs("div",{className:"space-y-3 py-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(Ae,{className:"text-xs font-semibold",children:"Department Key (Internal ID)"}),s.jsx(_e,{placeholder:"billing",value:q,onChange:K=>ce(K.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,"")),className:"text-xs font-mono border-border bg-secondary/30"}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["e.g. ",s.jsx("code",{children:"billing"}),", ",s.jsx("code",{children:"technical"}),", ",s.jsx("code",{children:"sales"})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Ae,{className:"text-xs font-semibold",children:"Department Display Name"}),s.jsx(_e,{placeholder:"Billing & Sales Support",value:de,onChange:K=>se(K.target.value),className:"text-xs border-border bg-secondary/30"})]})]}),s.jsxs(Js,{className:"gap-2 sm:gap-0",children:[s.jsx(ue,{variant:"outline",size:"sm",onClick:()=>H(!1),className:"text-xs",children:"Cancel"}),s.jsx(ue,{size:"sm",onClick:P,disabled:!q.trim(),className:"text-xs bg-primary font-semibold",children:"Create Department"})]})]})})]})}const pz=Ne.listConfigs(),hz={supportbot:"Bot config","ticket-panel":"Ticket panel",commands:"Commands",messages:"Messages","supportbot-ai":"AI assistant"};function gz(){var M,k;const{permissions:t,canViewConfig:n}=Yt(),{files:a}=$2(),[o,c]=wd(),l=o.get("file"),d=n("supportbot"),m=f.useMemo(()=>pz.filter(_=>n(_)),[n]),p=f.useMemo(()=>d?a:[],[d,a]),g=f.useMemo(()=>[...m,...p.map(_=>_l(_))],[m,p]),b=g[0]??"",[v,w]=f.useState(()=>l&&g.includes(l)?l:b);if(f.useEffect(()=>{l&&g.includes(l)?w(l):g.includes(v)||(w(b),b&&c({file:b}))},[l,g,v,b,c]),g.length===0)return s.jsx(ya,{to:mg(t),replace:!0});const y=H8(v),C=(y==null?void 0:y.type)==="addon",S=C?y.file:null,N=C?H2(S):hz[v]??"Configuration",E=C?!!((M=t==null?void 0:t.configs.supportbot)!=null&&M.edit):t?!!((k=t.configs[v])!=null&&k.edit):!1,T=C?S:`${v}.yml`;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:N}),s.jsx("p",{className:"text-muted-foreground",children:E?`Edit ${T} — changes apply to the running bot without restarting the dashboard.`:`Viewing ${T} — you do not have permission to save changes.`})]}),s.jsx("div",{className:"mt-6",children:C&&S?s.jsx(WO,{filename:S},S):s.jsx(mz,{configFile:v},v)})]})}const xz={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 bz(t){return t?xz[t]||"Sign-in failed. Please try again.":""}function vz(){const{branding:t}=Ed(),{isAuthenticated:n,loading:a,loginWithDiscord:o}=Yt(),[c]=wd(),l=f.useMemo(()=>bz(c.get("error")),[c]);return!a&&n?s.jsx(ya,{to:"/",replace:!0}):s.jsx("div",{className:"relative flex min-h-svh items-center justify-center bg-[#0c0c10] p-4 overflow-hidden",children:s.jsxs(Je,{className:"relative z-10 w-full max-w-md overflow-hidden rounded-3xl border border-white/10 bg-card/30 p-2 shadow-2xl backdrop-blur-2xl",children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-white/5 to-transparent pointer-events-none"}),s.jsxs(dt,{className:"space-y-6 pt-10 pb-4 text-center",children:[s.jsx("div",{className:"mx-auto flex size-28 items-center justify-center overflow-hidden rounded-3xl bg-white/5 p-4 shadow-inner ring-1 ring-white/10 transition-transform duration-500 hover:scale-105",children:s.jsx("img",{src:"/logo.png",alt:"SupportBot Logo",className:"h-full w-full object-contain drop-shadow-xl"})}),s.jsxs("div",{children:[s.jsx(ft,{className:"bg-gradient-to-br from-white to-white/50 bg-clip-text text-3xl font-extrabold tracking-tight text-transparent",children:t.title||"SupportBot"}),s.jsx(Ot,{className:"mt-2 text-base font-medium text-white/50",children:"Sign in to your dashboard"})]})]}),s.jsxs(et,{className:"space-y-6 pb-10",children:[s.jsxs("div",{className:"text-center space-y-1",children:[s.jsx("p",{className:"text-sm font-medium text-white/50",children:"Securely authenticate using your Discord account."}),s.jsxs("p",{className:"text-xs text-white/30",children:["Credentials are configured in ",s.jsx("code",{className:"rounded bg-white/5 px-1 py-0.5 text-white/40",children:"Configs/api.yml"})]})]}),l?s.jsx(Ye,{variant:"destructive",className:"border-red-500/50 bg-red-500/10 text-red-200 backdrop-blur-md",children:s.jsx(qe,{className:"font-medium",children:l})}):null,s.jsxs(ue,{type:"button",className:"group relative w-full overflow-hidden rounded-2xl bg-primary px-8 py-6 text-base font-bold text-primary-foreground shadow-[0_0_20px_rgba(var(--primary),0.3)] transition-all duration-300 hover:scale-[1.02] hover:shadow-[0_0_30px_rgba(var(--primary),0.5)] active:scale-95",disabled:a,onClick:o,children:[s.jsx("div",{className:"absolute inset-0 translate-x-[-100%] bg-gradient-to-r from-transparent via-white/20 to-transparent transition-transform duration-1000 group-hover:translate-x-[100%]"}),s.jsxs("span",{className:"relative flex items-center justify-center gap-2",children:[s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",viewBox:"0 0 127.14 96.36",fill:"currentColor",children:s.jsx("path",{d:"M107.7,8.07A105.15,105.15,0,0,0,81.47,0a72.06,72.06,0,0,0-3.36,6.83A97.68,97.68,0,0,0,49,6.83,72.37,72.37,0,0,0,45.64,0,105.89,105.89,0,0,0,19.39,8.09C2.79,32.65-1.71,56.6.54,80.21h0A105.73,105.73,0,0,0,32.71,96.36,77.7,77.7,0,0,0,39.6,85.25a68.42,68.42,0,0,1-10.85-5.18c.91-.66,1.8-1.34,2.66-2a75.57,75.57,0,0,0,64.32,0c.87.71,1.76,1.39,2.66,2a68.68,68.68,0,0,1-10.87,5.19,77,77,0,0,0,6.89,11.1,105.25,105.25,0,0,0,32.19-16.14c2.64-27.38-4.51-51.11-19.32-72.15ZM42.68,68.22c-5.28,0-9.66-4.9-9.66-10.89s4.29-10.89,9.66-10.89c5.41,0,9.75,4.9,9.66,10.89C52.34,63.32,48.09,68.22,42.68,68.22Zm41.76,0c-5.28,0-9.66-4.9-9.66-10.89s4.29-10.89,9.66-10.89c5.41,0,9.75,4.9,9.66,10.89C84.44,63.32,80.19,68.22,84.44,68.22Z"})}),a?"Authenticating...":"Continue with Discord"]})]})]})]})})}const ui=[{id:"botToken",title:"Bot token",subtitle:"Connect your Discord bot",icon:cg},{id:"database",title:"Database",subtitle:"SQLite or MySQL engine",icon:x8},{id:"secretKey",title:"Session secret",subtitle:"Secure dashboard logins",icon:M8},{id:"oauth",title:"Discord OAuth",subtitle:"Sign in with Discord",icon:By},{id:"redirectUri",title:"Redirect URL",subtitle:"OAuth callback address",icon:Nd},{id:"owners",title:"Dashboard owners",subtitle:"Who can access this panel",icon:rh},{id:"emeraldApi",title:"Emerald API",subtitle:"One-click addons",icon:By}];function yz(t){return t==="oauth"?"oauth":t==="owners"?"owners":t}function wz({brandingTitle:t,faviconUrl:n,faviconVersion:a,hasFavicon:o,children:c}){return s.jsx("div",{className:"min-h-svh bg-background",children:s.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:[s.jsxs("header",{className:"mb-8 flex items-center gap-4",children:[o&&n?s.jsx("img",{src:`${n}${a?`?v=${a}`:""}`,alt:"",className:"size-12 rounded-2xl border border-border object-contain"}):s.jsx("div",{className:"flex size-12 items-center justify-center rounded-2xl border border-border bg-primary text-primary-foreground",children:s.jsx(xe,{icon:cg,size:24})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"First-time setup"}),s.jsx("h1",{className:"text-2xl font-semibold tracking-tight md:text-3xl",children:t})]})]}),c]})})}function jz({currentIndex:t,validation:n}){const a=(t+1)/ui.length*100;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[s.jsxs("span",{children:["Step ",t+1," of ",ui.length]}),s.jsxs("span",{children:[Math.round(a),"%"]})]}),s.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-secondary",children:s.jsx("div",{className:"h-full rounded-full bg-primary transition-all duration-300 ease-out",style:{width:`${a}%`}})})]}),s.jsx("nav",{className:"hidden space-y-1 md:block","aria-label":"Setup steps",children:ui.map((o,c)=>{var g;const l=yz(o.id),d=(g=n[l])==null?void 0:g.ok,m=c===t,p=cs.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx(xe,{icon:jd,size:14}),o.globalName||o.username,s.jsx("span",{className:"font-mono text-xs opacity-80",children:o.id})]},o.id))}):null,!t.bot&&!((a=t.users)!=null&&a.length)?s.jsx("p",{children:t.warning||"Verified successfully."}):null]})}):s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:t.error})}):null}function Sz({values:t,setValues:n,validation:a,validating:o,onValidate:c}){return s.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[s.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Open the"," ",s.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 ",s.jsx("strong",{children:"Bot"}),", and reset or copy the token."]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"botToken",children:"Bot token"}),s.jsx(_e,{id:"botToken",type:"password",autoComplete:"off",value:t.botToken,onChange:l=>n({...t,botToken:l.target.value}),placeholder:"MTI…",className:"h-11 font-mono text-sm"})]}),s.jsx(mo,{result:a.botToken}),s.jsx("div",{className:"mt-auto",children:s.jsx(ue,{type:"button",variant:"secondary",disabled:o||!t.botToken,onClick:c,children:o?"Checking with Discord…":"Verify bot token"})})]})}function Nz({values:t,setValues:n,validation:a,validating:o,onValidate:c,onGenerate:l}){return s.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[s.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."}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"secretKey",children:"Session secret"}),s.jsx(_e,{id:"secretKey",type:"password",autoComplete:"off",value:t.secretKey,onChange:d=>n({...t,secretKey:d.target.value}),className:"h-11 font-mono text-sm"})]}),s.jsx(mo,{result:a.secretKey}),s.jsxs("div",{className:"mt-auto flex flex-wrap gap-2",children:[s.jsx(ue,{type:"button",variant:"outline",onClick:l,children:"Generate secure secret"}),s.jsx(ue,{type:"button",variant:"secondary",disabled:o||!t.secretKey,onClick:c,children:o?"Checking…":"Validate"})]})]})}function Ez({values:t,setValues:n,validation:a,validating:o,onValidate:c}){return s.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[s.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Use the ",s.jsx("strong",{children:"same application"})," as your bot. Under OAuth2, copy the Client ID and Client Secret."]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[s.jsx(Ae,{htmlFor:"clientId",children:"Client ID"}),s.jsx(_e,{id:"clientId",value:t.clientId,onChange:l=>n({...t,clientId:l.target.value}),className:"h-11 font-mono text-sm"})]}),s.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[s.jsx(Ae,{htmlFor:"clientSecret",children:"Client Secret"}),s.jsx(_e,{id:"clientSecret",type:"password",autoComplete:"off",value:t.clientSecret,onChange:l=>n({...t,clientSecret:l.target.value}),className:"h-11 font-mono text-sm"})]})]}),s.jsx(mo,{result:a.oauth}),s.jsx("div",{className:"mt-auto",children:s.jsx(ue,{type:"button",variant:"secondary",disabled:o||!t.clientId||!t.clientSecret,onClick:c,children:o?"Checking with Discord…":"Verify OAuth credentials"})})]})}function kz({values:t,setValues:n,validation:a}){async function o(){if(t.redirectUri)try{await navigator.clipboard.writeText(t.redirectUri)}catch{}}return s.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[s.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Add this exact URL under ",s.jsx("strong",{children:"OAuth2 → Redirects"})," in the Developer Portal. It must match character-for-character."]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"redirectUri",children:"Redirect URI"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(_e,{id:"redirectUri",value:t.redirectUri,onChange:c=>n({...t,redirectUri:c.target.value}),className:"h-11 flex-1 font-mono text-xs"}),s.jsx(ue,{type:"button",variant:"outline",size:"icon",className:"size-11 shrink-0",onClick:()=>void o(),title:"Copy URL",children:s.jsx(xe,{icon:R2,size:18})})]})]}),a.redirectUri&&!a.redirectUri.ok?s.jsx(mo,{result:a.redirectUri}):s.jsx(Ye,{className:"border-border bg-secondary",children:s.jsx(qe,{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 Tz({values:t,setValues:n,validation:a,validating:o,onValidate:c}){return s.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[s.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Enable ",s.jsx("strong",{children:"Developer Mode"})," in Discord (Settings → Advanced), then right-click your profile and ",s.jsx("strong",{children:"Copy User ID"}),". Add one ID per line."]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"owners",children:"Owner user IDs"}),s.jsx(Jd,{id:"owners",value:t.ownerUserIds,onChange:l=>n({...t,ownerUserIds:l.target.value}),placeholder:`829112572816130058 +987654321098765432`,className:"min-h-[120px] font-mono text-sm"})]}),s.jsx(mo,{result:a.owners}),s.jsx("div",{className:"mt-auto",children:s.jsx(ue,{type:"button",variant:"secondary",disabled:o||!t.ownerUserIds.trim(),onClick:c,children:o?"Checking with Discord…":"Verify owner IDs"})})]})}function Mz({onContinue:t}){return s.jsx("div",{className:"mx-auto flex w-full max-w-lg flex-1 flex-col justify-center py-8",children:s.jsxs("div",{className:"rounded-2xl border border-border bg-card px-6 py-10 text-center md:px-10",children:[s.jsx("div",{className:"mx-auto mb-6 flex size-16 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:s.jsx(xe,{icon:jd,size:40})}),s.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Setup complete"}),s.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"," ",s.jsx("code",{className:"rounded-md bg-muted px-1.5 py-0.5 font-mono text-xs",children:"npm start"}),")."]}),s.jsx(Ye,{className:"mt-6 text-left",children:s.jsx(qe,{children:"After restarting, sign in with Discord to open the dashboard."})}),s.jsx(ue,{type:"button",size:"lg",className:"mt-8 min-w-[220px]",onClick:t,children:"Continue to sign in"})]})})}function Rz({currentIndex:t,validating:n,saving:a,onBack:o,onNext:c,onFinish:l}){const d=t===ui.length-1;return s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs(ue,{type:"button",variant:"ghost",disabled:t===0||a,onClick:o,children:[s.jsx(xe,{icon:T2,size:18,className:"mr-1"}),"Back"]}),s.jsx("div",{className:"flex flex-1 justify-end gap-2",children:d?s.jsx(ue,{type:"button",size:"lg",disabled:a||n,onClick:l,className:"min-w-[200px]",children:a?"Saving…":"Finish setup"}):s.jsxs(ue,{type:"button",size:"lg",disabled:n||a,onClick:c,children:["Continue",s.jsx(xe,{icon:lg,size:18,className:"ml-1"})]})})]})}function Az({values:t,setValues:n,validation:a,validating:o,onValidate:c}){return s.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[s.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["An Emerald Services API key is optional, but required to use the one-click addon installer in the dashboard. You can get yours from the"," ",s.jsx("a",{href:"https://emeraldsrv.dev",target:"_blank",rel:"noreferrer",className:"font-medium text-primary hover:underline",children:"Emerald Services Marketplace"}),"."]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"emeraldApiKey",children:"Emerald API key (Optional)"}),s.jsx(_e,{id:"emeraldApiKey",type:"password",autoComplete:"off",value:t.emeraldApiKey,onChange:l=>n({...t,emeraldApiKey:l.target.value}),placeholder:"em_...",className:"h-11 font-mono text-sm"})]}),s.jsx(mo,{result:a.emeraldApi}),s.jsx("div",{className:"mt-auto",children:s.jsx(ue,{type:"button",variant:"secondary",disabled:o,onClick:c,children:o?"Checking…":t.emeraldApiKey?"Verify key":"Skip step"})})]})}function _z({values:t,setValues:n,validation:a,validating:o,onValidate:c}){const l=a.database,d=t.dbDriver==="mysql";return s.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[s.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Choose your database storage engine. Select ",s.jsx("strong",{children:"SQLite"})," for instant zero-config local storage, or ",s.jsx("strong",{children:"MySQL / MariaDB"})," for external host databases."]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{onClick:()=>n(m=>({...m,dbDriver:"sqlite"})),className:pe("cursor-pointer rounded-xl border p-4 transition-all hover:border-primary",t.dbDriver==="sqlite"?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-border bg-card"),children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"font-semibold text-foreground",children:"SQLite"}),s.jsx("span",{className:"rounded-full bg-emerald-500/10 px-2.5 py-0.5 text-xs font-medium text-emerald-500",children:"Zero Config"})]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Single-file SQL database stored locally at ",s.jsx("code",{className:"font-mono",children:"./Data/supportbot.db"}),". Zero extra setup required."]})]}),s.jsxs("div",{onClick:()=>n(m=>({...m,dbDriver:"mysql"})),className:pe("cursor-pointer rounded-xl border p-4 transition-all hover:border-primary",t.dbDriver==="mysql"?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-border bg-card"),children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"font-semibold text-foreground",children:"MySQL / MariaDB"}),s.jsx("span",{className:"rounded-full bg-blue-500/10 px-2.5 py-0.5 text-xs font-medium text-blue-500",children:"External Database"})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Connect to a remote or local MySQL database server."})]})]}),d&&s.jsxs("div",{className:"space-y-4 rounded-xl border border-border bg-card/50 p-4",children:[s.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"MySQL Connection Settings"}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[s.jsx(Ae,{htmlFor:"dbHost",children:"Database Host"}),s.jsx(_e,{id:"dbHost",placeholder:"127.0.0.1 or localhost",value:t.dbHost,onChange:m=>n(p=>({...p,dbHost:m.target.value})),className:"h-11 text-sm"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"dbPort",children:"Port"}),s.jsx(_e,{id:"dbPort",placeholder:"3306",value:t.dbPort,onChange:m=>n(p=>({...p,dbPort:m.target.value})),className:"h-11 text-sm font-mono"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"dbDatabase",children:"Database Name"}),s.jsx(_e,{id:"dbDatabase",placeholder:"supportbot",value:t.dbDatabase,onChange:m=>n(p=>({...p,dbDatabase:m.target.value})),className:"h-11 text-sm"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"dbUser",children:"Database User"}),s.jsx(_e,{id:"dbUser",placeholder:"root",value:t.dbUser,onChange:m=>n(p=>({...p,dbUser:m.target.value})),className:"h-11 text-sm font-mono"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"dbPassword",children:"Password"}),s.jsx(_e,{id:"dbPassword",type:"password",placeholder:"••••••••••••",value:t.dbPassword,onChange:m=>n(p=>({...p,dbPassword:m.target.value})),className:"h-11 text-sm font-mono"})]})]})]}),s.jsx(mo,{result:l}),s.jsx("div",{className:"mt-auto",children:s.jsx(ue,{type:"button",variant:"secondary",disabled:o,onClick:c,children:o?"Testing Connection...":"Test Connection & Validate"})})]})}function Dz(){const t=crypto.randomUUID().replace(/-/g,""),n=crypto.randomUUID().replace(/-/g,"");return t+n}function Oz(t){return t.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean)}function t2(t){return t==="oauth"?"oauth":t==="owners"?"owners":t==="database"?"database":t==="emeraldApi"?"emeraldApi":t}function Lz(){const t=ao(),{branding:n}=Ed(),{loading:a,error:o,refresh:c,status:l}=fS(),[d,m]=f.useState(0),[p,g]=f.useState({botToken:"",dbDriver:"sqlite",dbHost:"127.0.0.1",dbPort:"3306",dbUser:"",dbPassword:"",dbDatabase:"supportbot",secretKey:"",clientId:"",clientSecret:"",redirectUri:"",ownerUserIds:"",emeraldApiKey:""}),[b,v]=f.useState({}),[w,y]=f.useState(!1),[C,S]=f.useState(!1),[N,E]=f.useState(""),[T,M]=f.useState(!1),k=ui[d];f.useEffect(()=>{l!=null&&l.suggestedRedirectUri&&!p.redirectUri&&g(H=>({...H,redirectUri:l.suggestedRedirectUri}))},[l==null?void 0:l.suggestedRedirectUri,p.redirectUri]);const _=f.useMemo(()=>({botToken:p.botToken,dbDriver:p.dbDriver,dbHost:p.dbHost,dbPort:p.dbPort,dbUser:p.dbUser,dbPassword:p.dbPassword,dbDatabase:p.dbDatabase,secretKey:p.secretKey,clientId:p.clientId,clientSecret:p.clientSecret,redirectUri:p.redirectUri,ownerUserIds:Oz(p.ownerUserIds),emeraldApiKey:p.emeraldApiKey}),[p]);async function R(){y(!0),E("");try{const H=await Ne.validateSetup(_);return v(q=>{var ce;return{...q,...(ce=H.data)==null?void 0:ce.results}}),H.data}catch(H){return E(H instanceof Error?H.message:"Validation failed"),null}finally{y(!1)}}async function L(){var ce,de;const H=t2(k.id),q=await R();return!!((de=(ce=q==null?void 0:q.results)==null?void 0:ce[H])!=null&&de.ok)}async function ne(){const H=t2(k.id),q=b[H];!(q!=null&&q.ok)&&!await L()||m(ce=>Math.min(ce+1,ui.length-1))}async function X(){S(!0),E("");try{const H=await R();if(!(H!=null&&H.ok)){E("Fix the steps marked with errors before finishing.");return}await Ne.completeSetup(_),M(!0)}catch(H){E(H instanceof Error?H.message:"Could not save setup")}finally{S(!1)}}function I(){const H={values:p,setValues:g,validation:b,validating:w};switch(k.id){case"botToken":return s.jsx(Sz,{...H,onValidate:()=>void L()});case"database":return s.jsx(_z,{...H,onValidate:()=>void L()});case"secretKey":return s.jsx(Nz,{...H,onGenerate:()=>g(q=>({...q,secretKey:Dz()})),onValidate:()=>void L()});case"oauth":return s.jsx(Ez,{...H,onValidate:()=>void L()});case"redirectUri":return s.jsx(kz,{values:p,setValues:g,validation:b});case"owners":return s.jsx(Tz,{...H,onValidate:()=>void L()});case"emeraldApi":return s.jsx(Az,{...H,onValidate:()=>void L()})}}return a?s.jsx("div",{className:"min-h-svh bg-background px-4 py-10",children:s.jsxs("div",{className:"mx-auto max-w-6xl space-y-8",children:[s.jsx(Ue,{className:"h-14 w-64"}),s.jsxs("div",{className:"grid gap-8 lg:grid-cols-[280px_1fr]",children:[s.jsx(Ue,{className:"hidden h-80 lg:block"}),s.jsx(Ue,{className:"h-[520px] rounded-2xl"})]})]})}):s.jsxs(wz,{brandingTitle:n.title,faviconUrl:n.faviconUrl,faviconVersion:n.updatedAt??void 0,hasFavicon:n.hasFavicon,children:[o?s.jsx(Ye,{variant:"destructive",className:"mb-6",children:s.jsx(qe,{children:o})}):null,N?s.jsx(Ye,{variant:"destructive",className:"mb-6",children:s.jsx(qe,{children:N})}):null,T?s.jsx(Mz,{onContinue:async()=>{await c(),t("/login",{replace:!0})}}):s.jsxs("div",{className:"grid flex-1 gap-8 lg:grid-cols-[minmax(0,280px)_1fr]",children:[s.jsx(jz,{currentIndex:d,validation:b}),s.jsx(Cz,{step:k,footer:s.jsx(Rz,{currentIndex:d,validating:w,saving:C,onBack:()=>m(H=>Math.max(0,H-1)),onNext:()=>void ne(),onFinish:()=>void X()}),children:I()})]})]})}const zz={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 Pz({title:t,icon:n,href:a,badge:o="Configured",status:c="done"}){return s.jsxs(en,{to:a,className:pe("flex items-center gap-3 rounded-2xl border border-border bg-card p-4 transition-colors","hover:border-primary hover:bg-secondary"),children:[s.jsx("div",{className:"flex size-11 shrink-0 items-center justify-center rounded-full bg-secondary text-primary",children:s.jsx(xe,{icon:n,size:20})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate font-semibold",children:t}),s.jsx("span",{className:pe("mt-1 inline-flex rounded-md px-2 py-0.5 text-[10px] font-semibold",zz[c]),children:o})]})]})}function Iz({percent:t,size:n=128,className:a,trackClassName:o="stroke-white/20",strokeClassName:c="stroke-white"}){const d=2*Math.PI*42,m=Math.min(100,Math.max(0,t)),p=d-m/100*d;return s.jsxs("div",{className:pe("relative inline-flex",a),children:[s.jsxs("svg",{width:n,height:n,viewBox:"0 0 100 100",className:"-rotate-90","aria-hidden":!0,children:[s.jsx("circle",{cx:"50",cy:"50",r:42,fill:"none",strokeWidth:"9",className:o}),s.jsx("circle",{cx:"50",cy:"50",r:42,fill:"none",strokeWidth:"9",strokeLinecap:"round",strokeDasharray:d,strokeDashoffset:p,className:c})]}),s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-center",children:[s.jsxs("span",{className:"text-2xl font-bold tabular-nums leading-none",children:[Math.round(m),"%"]}),s.jsx("span",{className:"mt-0.5 text-[10px] font-medium uppercase tracking-wide opacity-80",children:"Complete"})]})]})}const Uz={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 Bz({title:t,subtitle:n,icon:a,href:o,status:c,meta:l="Open in dashboard"}){const d=Uz[c];return s.jsxs(en,{to:o,className:pe("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:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("span",{className:pe("mt-1.5 size-2 shrink-0 rounded-full",d.dot)}),s.jsx("span",{className:"text-xs text-muted-foreground",children:n})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-semibold leading-snug tracking-tight",children:t}),s.jsx("span",{className:pe("mt-2 inline-flex rounded-md px-2 py-0.5 text-[11px] font-semibold",d.badge),children:d.label})]}),s.jsxs("div",{className:"mt-auto flex items-center justify-between border-t border-border pt-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex size-8 items-center justify-center rounded-lg bg-secondary text-primary",children:s.jsx(xe,{icon:a,size:16})}),s.jsx("span",{className:"text-xs text-muted-foreground",children:l})]}),s.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[s.jsx(xe,{icon:Nd,size:14,className:"opacity-60"}),s.jsx(xe,{icon:qs,size:14,className:"opacity-60 group-hover:text-primary"}),s.jsx(xe,{icon:lg,size:14,className:"text-primary opacity-0 transition-opacity group-hover:opacity-100"})]})]})]})}function $z({stats:t}){const n=[{id:"ping",label:"Gateway latency",detail:`${t.bot.ping}ms`,badge:t.bot.ping<200?"Good":"High",badgeClass:t.bot.ping<200?"bg-emerald-500/15 text-emerald-400":"bg-amber-500/15 text-amber-400"},{id:"uptime",label:"Bot uptime",detail:fg(t.bot.uptime),badge:"Live",badgeClass:"bg-primary/20 text-primary"},{id:"ram",label:"Memory usage",detail:`${t.hosting.ram_used} / ${t.hosting.ram_total}`,badge:`${t.hosting.ram_percent}%`,badgeClass:"bg-sky-500/15 text-sky-400"}];return s.jsxs("aside",{className:"hidden w-[min(100%,320px)] shrink-0 space-y-4 xl:block",children:[s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between space-y-0 pb-3",children:[s.jsxs(ft,{className:"text-sm font-semibold",children:["Connected servers (",t.servers,")"]}),s.jsx(ue,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",children:s.jsx("span",{className:"text-lg leading-none",children:"+"})})]}),s.jsxs(et,{className:"pt-0",children:[s.jsxs("div",{className:"flex -space-x-2",children:[Array.from({length:Math.min(6,t.servers)}).map((a,o)=>s.jsxs(vs,{className:"size-9 border-2 border-card ring-0",children:[s.jsx(eo,{src:t.bot.avatar,alt:""}),s.jsx(ys,{className:"bg-primary/25 text-[10px] text-primary",children:String(o+1)})]},o)),t.servers>6?s.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:["+",t.servers-6]}):null]}),s.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:[t.users.toLocaleString()," members across your guilds"]})]})]}),s.jsx(Je,{className:"overflow-hidden border-border bg-secondary",children:s.jsx(et,{className:"p-5",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"flex size-10 items-center justify-center rounded-xl bg-primary text-primary-foreground",children:s.jsx(xe,{icon:T8,size:22})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold",children:"Keep SupportBot up to date"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Check for releases and install updates from settings."})]}),s.jsx(ue,{asChild:!0,size:"sm",className:"w-full",children:s.jsxs(en,{to:"/settings",children:[s.jsx(xe,{icon:Cd,size:16,className:"mr-2"}),"Open settings"]})})]})})}),s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[s.jsx(ft,{className:"text-sm font-semibold",children:"System activity"}),s.jsx(ue,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",children:s.jsx("span",{className:"text-base leading-none",children:"⋯"})})]}),s.jsxs(et,{className:"space-y-1 p-0 pb-2",children:[n.map(a=>s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 transition-colors hover:bg-secondary/40",children:[s.jsxs(vs,{className:"size-9",children:[s.jsx(eo,{src:t.bot.avatar,alt:t.bot.username}),s.jsx(ys,{className:"bg-secondary text-xs",children:"SB"})]}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-sm font-medium",children:a.label}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.detail})]}),s.jsx("span",{className:`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold ${a.badgeClass}`,children:a.badge})]},a.id)),s.jsx(ue,{asChild:!0,variant:"ghost",className:"mx-2 mt-1 w-[calc(100%-1rem)] justify-between text-xs text-muted-foreground",children:s.jsxs(en,{to:"/system",children:["All system details",s.jsx(xe,{icon:lg,size:14})]})})]})]}),s.jsx(Je,{className:"border-border bg-card",children:s.jsxs(et,{className:"flex items-center gap-3 p-4",children:[s.jsx("div",{className:"flex size-9 items-center justify-center rounded-lg bg-secondary text-primary",children:s.jsx(xe,{icon:qs,size:18})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"text-sm font-medium",children:["v",t.bot.version]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["CPU ",t.hosting.cpu_load]})]})]})})]})}const c5={todo:"Needs setup",progress:"In progress",done:"Active"};function Kh(t,n,a="Configure module"){const o=n==null?void 0:n[t];return o||{status:"todo",subtitle:a}}function Hz(){return s.jsxs("div",{className:"flex gap-6",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-6",children:[s.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[s.jsx(Ue,{className:"h-44 rounded-2xl"}),s.jsx(Ue,{className:"h-44 rounded-2xl"})]}),s.jsx(Ue,{className:"h-8 w-48"}),s.jsx("div",{className:"flex gap-4 overflow-hidden",children:Array.from({length:3}).map((t,n)=>s.jsx(Ue,{className:"h-40 min-w-[280px] rounded-2xl"},n))}),s.jsx(Ue,{className:"h-8 w-56"}),s.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:Array.from({length:4}).map((t,n)=>s.jsx(Ue,{className:"h-20 rounded-2xl"},n))})]}),s.jsx(Ue,{className:"hidden h-[520px] w-80 shrink-0 rounded-2xl xl:block"})]})}function Gz(){const{stats:t,loading:n,error:a}=kd(),[o,c]=f.useState("all"),l=f.useMemo(()=>{if(!t)return 0;const b=t.tickets.total||0;return b===0?100:Math.round(t.tickets.closed/b*100)},[t]),d=f.useMemo(()=>o==="open"||o==="closed"?ai.filter(b=>b.category==="tickets"):o==="all"?ai:ai.filter(b=>b.category===o),[o]);if(n)return s.jsx(Hz,{});if(a||!t)return s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:a||"No stats available"})});const m=t.tickets.open,p=t.tickets.closed,g=t.tickets.total;return s.jsxs("div",{className:"flex flex-col gap-6 xl:flex-row xl:items-start",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-6",children:[s.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[s.jsx(Je,{className:"overflow-hidden border-border bg-card",children:s.jsxs(et,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("p",{className:"text-lg font-semibold leading-snug",children:["You have"," ",s.jsx("span",{className:"text-primary",children:m})," open ticket",m===1?"":"s"]}),s.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."}),s.jsx(ue,{asChild:!0,size:"sm",className:"rounded-lg px-5",children:s.jsx(en,{to:"/transcripts",children:"Review"})})]}),s.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:[s.jsx("div",{className:"absolute inset-0 rounded-2xl bg-secondary"}),s.jsx("span",{className:"relative text-6xl",children:"🎫"})]})]})}),s.jsx(Je,{className:"overflow-hidden border-border bg-primary text-primary-foreground",children:s.jsxs(et,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm font-medium text-white/80",children:"Ticket summary"}),s.jsxs("ul",{className:"space-y-1.5 text-sm",children:[s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"size-1.5 rounded-full bg-white/70"}),s.jsxs("span",{className:"text-white/90",children:[g," total"]})]}),s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"size-1.5 rounded-full bg-white/70"}),s.jsxs("span",{className:"text-white/90",children:[p," closed"]})]}),s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"size-1.5 rounded-full bg-white/70"}),s.jsxs("span",{className:"text-white/90",children:[m," open"]})]})]})]}),s.jsx(Iz,{percent:l,size:120})]})})]}),s.jsxs("section",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[s.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Module overview"}),s.jsx(DS,{value:o,onValueChange:b=>c(b),children:s.jsxs(xx,{className:"h-auto flex-wrap rounded-xl bg-secondary/60 p-1",children:[s.jsx(Ys,{value:"all",className:"rounded-lg text-xs data-[state=active]:bg-background data-[state=active]:shadow-sm",children:"All"}),s.jsx(Ys,{value:"open",className:"rounded-lg text-xs data-[state=active]:bg-background",children:"Open"}),s.jsx(Ys,{value:"closed",className:"rounded-lg text-xs data-[state=active]:bg-background",children:"Closed"}),YM.filter(b=>b.id!=="all").map(b=>s.jsx(Ys,{value:b.id,className:"rounded-lg text-xs data-[state=active]:bg-background",children:b.label},b.id))]})})]}),s.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:is,href:"/tickets",status:"done",meta:"View live tickets"}]:o==="closed"?[{id:"closed-archive",title:"Closed tickets",subtitle:`${p} resolved`,icon:jd,href:"/transcripts",status:"done",meta:"Browse archive"}]:d.map(b=>{const v=Kh(b.id,t.modules,b.description);return{id:b.id,title:b.title,subtitle:v.subtitle,icon:b.icon,href:b.href,status:v.status,meta:v.status==="done"?"View settings":"Configure"}})).map(b=>s.jsx(Bz,{title:b.title,subtitle:b.subtitle,icon:b.icon,href:b.href,status:b.status,meta:b.meta},b.id))})]}),s.jsxs("section",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Active modules"}),s.jsx(en,{to:"/configs",className:"text-sm font-medium text-primary hover:underline",children:"See all"})]}),s.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:ai.slice(0,4).map(b=>{const v=Kh(b.id,t.modules);return s.jsx(Pz,{title:b.title,icon:b.icon,href:b.href,badge:c5[v.status],status:v.status},b.id)})})]})]}),s.jsx($z,{stats:t})]})}function Vz(){const{permissions:t}=Yt();return Rn(t,"overview")?s.jsx(Gz,{}):s.jsx(ya,{to:mg(t),replace:!0})}function ga({permission:t,children:n}){const{loading:a,isAuthenticated:o,permissions:c}=Yt();return a?s.jsx("div",{className:"flex flex-1 items-center justify-center py-16 text-sm text-muted-foreground",children:"Loading…"}):o?Rn(c,t)?s.jsx(s.Fragment,{children:n}):s.jsx(ya,{to:mg(c),replace:!0}):s.jsx(ya,{to:"/login",replace:!0})}function Fz(){const{hasPermission:t}=Yt(),n=t("settings.update"),a=ao(),[o,c]=f.useState([]),[l,d]=f.useState(""),[m,p]=f.useState(!0),[g,b]=f.useState(""),[v,w]=f.useState(""),[y,C]=f.useState(null),S=f.useCallback(async()=>{p(!0),b("");try{const E=await Ne.getAddonsCatalog();E.data&&(c(E.data.addons),d(E.data.repository))}catch(E){b(E instanceof Error?E.message:"Failed to load addons")}finally{p(!1)}},[]);f.useEffect(()=>{S()},[S]);async function N(E){if(n){C(E.id),w(""),b("");try{const T=await Ne.installAddon(E.id);w(T.message||`${E.name} installed.`),await S();const M=E.configFiles[0];M&&a(`/configs?file=${_l(M)}`)}catch(T){b(T instanceof Error?T.message:"Install failed")}finally{C(null)}}}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Addons"}),s.jsxs("p",{className:"text-muted-foreground",children:["Requires an API key from"," ",s.jsx("a",{href:"https://emeraldsrv.dev",target:"_blank",rel:"noreferrer",className:"text-primary underline-offset-4 hover:underline",children:"emeraldsrv.dev"})," ","to browse and install addons. Configs will appear in the sidebar once installed."]})]}),s.jsxs(ue,{variant:"outline",size:"sm",onClick:S,disabled:m,children:[s.jsx(xe,{icon:_2,size:16,className:pe("mr-1.5",m&&"animate-spin")}),"Refresh"]})]}),g?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:g})}):null,v?s.jsx(Ye,{className:"border-primary/30 bg-primary/10 text-primary",children:s.jsx(qe,{children:v})}):null,s.jsxs("section",{className:"space-y-4",children:[s.jsx("h2",{className:"text-sm font-semibold uppercase tracking-widest text-muted-foreground",children:"Marketplace"}),m?s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsx(Ue,{className:"h-40 rounded-xl"}),s.jsx(Ue,{className:"h-40 rounded-xl"}),s.jsx(Ue,{className:"h-40 rounded-xl"})]}):s.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:o.map(E=>s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{className:"pb-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs(ft,{className:"flex items-center gap-2 text-lg",children:[s.jsx(xe,{icon:dg,size:20,className:"text-primary"}),E.name]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Fn,{variant:"outline",className:"shrink-0 uppercase tracking-widest text-[10px]",children:E.price===0||!E.price?"Free":`$${E.price}`}),E.installed?s.jsxs(Fn,{variant:"secondary",className:"shrink-0 gap-1",children:[s.jsx(xe,{icon:D8,size:14}),"Installed"]}):null]})]}),s.jsx(Ot,{children:E.description})]}),s.jsxs(et,{className:"space-y-2 text-xs text-muted-foreground",children:[E.is_external?s.jsxs("p",{children:["Available on: ",s.jsx("span",{className:"font-medium text-foreground",children:E.external_store||"External Store"})]}):null,E.configFiles&&E.configFiles.length>0?s.jsxs("p",{children:["Config:"," ",E.configFiles.map((T,M)=>s.jsxs("span",{children:[M>0?", ":null,s.jsx(en,{to:`/configs?file=${_l(T)}`,className:"font-mono text-primary hover:underline",children:T})]},T))]}):null]}),s.jsxs(Sx,{className:"flex flex-wrap gap-2",children:[E.is_external?s.jsx(ue,{variant:"outline",size:"sm",asChild:!0,children:s.jsx("a",{href:E.repositoryUrl,target:"_blank",rel:"noreferrer",children:"View Store"})}):null,E.installed&&E.configFiles&&E.configFiles[0]?s.jsx(ue,{size:"sm",variant:"secondary",asChild:!0,children:s.jsx(en,{to:`/configs?file=${_l(E.configFiles[0])}`,children:"Edit config"})}):null,E.installed?s.jsx(ue,{size:"sm",disabled:!0,variant:"secondary",children:"Installed"}):E.is_external?null:s.jsxs(ue,{size:"sm",disabled:!n||y===E.id,onClick:()=>N(E),children:[s.jsx(xe,{icon:Cd,size:14,className:"mr-1"}),y===E.id?"Installing…":"Install"]})]})]},E.id))})]})]})}function Yz(){const{permissions:t}=Yt(),[n,a]=f.useState(!1),[o,c]=f.useState(!1),[l,d]=f.useState(""),[m,p]=f.useState(""),[g,b]=f.useState(""),[v,w]=f.useState("Administrator"),[y,C]=f.useState(""),[S,N]=f.useState(""),[E,T]=f.useState("General"),M=z2(t,"supportbot"),k=async()=>{if(!m.match(/^[a-z0-9_-]+$/i)){Dt.error("Command name can only contain letters, numbers, underscores and dashes.");return}a(!0),c(!1);try{const _=await Ne.buildAddon({name:m.toLowerCase(),description:g||"A custom command",permission:v,embed:{title:y,description:S||"Hello from your custom command!",color:E}});c(!0),d(_.message||"Restart required."),Dt.success(`Addon ${m}.js created successfully!`)}catch(_){Dt.error(_ instanceof Error?_.message:"Failed to build addon")}finally{a(!1)}};return M?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Addon Builder"}),s.jsx("p",{className:"text-muted-foreground",children:"Visually scaffold a custom slash command addon for your bot."})]}),o?s.jsxs(Ye,{className:"border-green-500/20 bg-green-500/10 text-green-600 dark:text-green-400",children:[s.jsx(x0,{className:"h-4 w-4"}),s.jsxs(qe,{className:"ml-2",children:["Successfully built ",s.jsxs("strong",{children:[m,".js"]}),"! ",l]})]}):null,s.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Je,{children:[s.jsxs(dt,{children:[s.jsx(ft,{className:"text-lg",children:"Command Details"}),s.jsx(Ot,{children:"Configure how users trigger the command."})]}),s.jsxs(et,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{children:"Command Name"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-muted-foreground",children:"/"}),s.jsx(_e,{placeholder:"ping",value:m,onChange:_=>p(_.target.value.replace(/[^a-z0-9_-]/gi,"").toLowerCase())})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{children:"Description"}),s.jsx(_e,{placeholder:"Replies with a custom embed",value:g,onChange:_=>b(_.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{children:"Required Permission"}),s.jsxs(Ca,{value:v,onValueChange:w,children:[s.jsx(Hr,{children:s.jsx(Sa,{})}),s.jsxs(Gr,{children:[s.jsx(Et,{value:"none",children:"@everyone"}),s.jsx(Et,{value:"Administrator",children:"Administrator"}),s.jsx(Et,{value:"ManageMessages",children:"Manage Messages"}),s.jsx(Et,{value:"ManageGuild",children:"Manage Server"})]})]})]})]})]}),s.jsxs(Je,{children:[s.jsxs(dt,{children:[s.jsx(ft,{className:"text-lg",children:"Response Embed"}),s.jsx(Ot,{children:"What the bot will reply with."})]}),s.jsxs(et,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{children:"Embed Title (Optional)"}),s.jsx(_e,{placeholder:"Hello!",value:y,onChange:_=>C(_.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{children:"Embed Description"}),s.jsx(Jd,{placeholder:"Type your message here...",className:"resize-none",rows:4,value:S,onChange:_=>N(_.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{children:"Embed Color"}),s.jsxs(Ca,{value:E,onValueChange:T,children:[s.jsx(Hr,{children:s.jsx(Sa,{})}),s.jsxs(Gr,{children:[s.jsx(Et,{value:"General",children:"Theme General"}),s.jsx(Et,{value:"Success",children:"Theme Success"}),s.jsx(Et,{value:"Warning",children:"Theme Warning"}),s.jsx(Et,{value:"Error",children:"Theme Error"})]})]})]})]})]})]}),s.jsx("div",{className:"space-y-6",children:s.jsxs(Je,{className:"sticky top-6 border-primary/20",children:[s.jsx(dt,{children:s.jsxs(ft,{className:"text-sm font-medium flex items-center gap-2",children:[s.jsx(xe,{icon:A8,size:16,className:"text-primary"}),"Live Preview"]})}),s.jsx(et,{children:s.jsx("div",{className:"rounded-md border bg-[#313338] p-4 font-sans text-sm text-[#dbdee1]",children:s.jsxs("div",{className:"flex gap-4",children:[s.jsx("div",{className:"size-10 shrink-0 rounded-full bg-indigo-500 flex items-center justify-center font-bold text-white",children:"B"}),s.jsxs("div",{className:"flex-1 space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-medium text-white",children:"SupportBot"}),s.jsxs("span",{className:"text-[10px] text-white font-medium uppercase px-1.5 py-0.5 rounded bg-[#5865F2] flex items-center gap-1",children:[s.jsx(x0,{size:10})," BOT"]}),s.jsx("span",{className:"text-xs text-[#949ba4]",children:"Today at 12:00 PM"})]}),s.jsxs("div",{className:"mt-2 rounded bg-[#2b2d31] border-l-4 border-l-[#5865F2] px-4 py-3 max-w-[432px]",children:[y&&s.jsx("div",{className:"mb-1 font-semibold text-white",children:y}),s.jsx("div",{className:"whitespace-pre-wrap",children:S||"Hello from your custom command!"})]})]})]})})}),s.jsx(Sx,{children:s.jsxs(ue,{className:"w-full gap-2",size:"lg",disabled:!m||n,onClick:k,children:[s.jsx(xe,{icon:ds,size:18}),n?"Building...":"Generate Addon"]})})]})})]})]}):s.jsx("div",{className:"flex h-[50vh] items-center justify-center text-muted-foreground",children:"You don't have permission to build addons."})}const Ex="supportbot-dashboard-accent",Pl="#45b46c",qz=["--primary","--ring","--chart-1","--sidebar-primary","--sidebar-ring","--accent","--accent-foreground","--sidebar-accent","--sidebar-accent-foreground"];function Kz(t){const n=$r(t,Pl),a=parseInt(n.slice(1,3),16)/255,o=parseInt(n.slice(3,5),16)/255,c=parseInt(n.slice(5,7),16)/255,l=Math.max(a,o,c),d=Math.min(a,o,c),m=(l+d)/2;let p=0,g=0;if(l!==d){const b=l-d;switch(g=m>.5?b/(2-l-d):b/(l+d),l){case a:p=((o-c)/b+(o{const o=new FileReader;o.onload=()=>n(String(o.result)),o.onerror=()=>a(new Error("Could not read file")),o.readAsDataURL(t)})}function Jz({canEdit:t}){const[n,a]=f.useState(!1),[o,c]=f.useState(""),[l,d]=f.useState(!1);async function m(){if(t){a(!0),c("");try{const p=await Ne.resetDashboard();c(p.message||"Dashboard reset successfully."),setTimeout(()=>{window.location.href="/setup"},1500)}catch(p){c(p instanceof Error?p.message:"Reset failed"),a(!1)}}}return t?s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"Reset the dashboard to factory settings. This clears the configuration and returns you to the initial setup screen."}),s.jsxs(Qs,{open:l,onOpenChange:d,children:[s.jsx(TM,{asChild:!0,children:s.jsx(ue,{type:"button",variant:"destructive",children:"Reset Dashboard"})}),s.jsxs(hs,{children:[s.jsxs(gs,{children:[s.jsx(xs,{children:"Are you absolutely sure?"}),s.jsx(bs,{children:"This action cannot be undone. This will reset the dashboard to setup mode. You will need to reconnect the Discord OAuth and reconfigure the dashboard owners."})]}),o&&s.jsx("p",{className:"text-sm font-medium text-destructive",children:o}),s.jsxs(Js,{children:[s.jsx(ue,{variant:"outline",onClick:()=>d(!1),disabled:n,children:"Cancel"}),s.jsx(ue,{variant:"destructive",onClick:()=>void m(),disabled:n,children:n?"Resetting...":"Yes, reset dashboard"})]})]})]})]}):null}function eP({canEdit:t}){const{branding:n,setBrandingLocal:a}=Ed(),o=f.useRef(null),[c,l]=f.useState(n.title),[d,m]=f.useState(n.pageTitle),[p,g]=f.useState(!1),[b,v]=f.useState(!1),[w,y]=f.useState("");f.useEffect(()=>{l(n.title),m(n.pageTitle)},[n.title,n.pageTitle]);const C=n.hasFavicon&&n.faviconUrl?`${n.faviconUrl}${n.updatedAt?`?v=${n.updatedAt}`:""}`:null;async function S(){if(t){g(!0),y("");try{const M=await Ne.updateBranding({title:c,pageTitle:d});M.data&&a(M.data),y(M.message||"Branding saved.")}catch(M){y(M instanceof Error?M.message:"Save failed")}finally{g(!1)}}}async function N(M){if(!(!t||!M)){v(!0),y("");try{const k=await Qz(M),_=await Ne.uploadBrandingFavicon(k);_.data&&a(_.data),y(_.message||"Favicon uploaded.")}catch(k){y(k instanceof Error?k.message:"Upload failed")}finally{v(!1),o.current&&(o.current.value="")}}}async function E(){if(t){v(!0),y("");try{const M=await Ne.removeBrandingFavicon();M.data&&a(M.data),y(M.message||"Favicon removed.")}catch(M){y(M instanceof Error?M.message:"Remove failed")}finally{v(!1)}}}const T=c.trim()!==n.title||d.trim()!==n.pageTitle;return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:"Branding Text"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Sidebar title and browser tab title — saved on the server for everyone using this dashboard."})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"brand-title",children:"Sidebar title"}),s.jsx(_e,{id:"brand-title",value:c,disabled:!t,maxLength:64,onChange:M=>l(M.target.value),className:"border-border bg-secondary/30",placeholder:"SupportBot"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"brand-page-title",children:"Browser tab title"}),s.jsx(_e,{id:"brand-page-title",value:d,disabled:!t,maxLength:80,onChange:M=>m(M.target.value),className:"border-border bg-secondary/30",placeholder:"SupportBot Dashboard"})]})]}),t?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ue,{type:"button",disabled:p||!T,onClick:()=>void S(),children:p?"Saving…":"Save titles"}),w&&T?s.jsx("span",{className:"text-xs text-muted-foreground",children:w}):null]}):null]}),s.jsxs("div",{className:"space-y-4 border-t border-border pt-6",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:"Favicon"}),s.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."})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[s.jsx("div",{className:"flex size-16 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary/30",children:C?s.jsx("img",{src:C,alt:"Favicon preview",className:"size-full object-contain p-2"}):s.jsx(xe,{icon:y8,size:24,className:"text-muted-foreground/50"})}),s.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:!t||b,onChange:M=>{var k;return void N(((k=M.target.files)==null?void 0:k[0])??null)}}),s.jsxs("div",{className:"flex flex-col gap-2",children:[t?s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ue,{type:"button",variant:"secondary",disabled:b,onClick:()=>{var M;return(M=o.current)==null?void 0:M.click()},children:b?"Uploading…":"Upload Favicon"}),n.hasFavicon?s.jsx(ue,{type:"button",variant:"destructive",disabled:b,onClick:()=>void E(),children:"Remove"}):null]}):s.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}),!T&&w?s.jsx("span",{className:"text-xs text-muted-foreground",children:w}):null]})]})]})]})}function tP(){var v,w,y,C,S,N,E,T,M,k,_;const{hasPermission:t}=Yt(),n=t("settings.update"),[a,o]=f.useState(!0),[c,l]=f.useState(!1),[d,m]=f.useState(""),[p,g]=f.useState(null);f.useEffect(()=>{Ne.getConfigJson("api").then(R=>{R.data&&g(R.data)}).catch(()=>m("Failed to load API config")).finally(()=>o(!1))},[]);async function b(){var R,L,ne,X,I,H,q,ce,de,se,P;if(!(!n||!p)){l(!0),m("");try{const W={"api:API.Port":(R=p.API)==null?void 0:R.Port,"api:API.EmeraldAPIKey":(L=p.API)==null?void 0:L.EmeraldAPIKey,"api:API.TrustProxy":(ne=p.API)==null?void 0:ne.TrustProxy,"api:API.OAuth.Enabled":(I=(X=p.API)==null?void 0:X.OAuth)==null?void 0:I.Enabled,"api:API.OAuth.ClientId":(q=(H=p.API)==null?void 0:H.OAuth)==null?void 0:q.ClientId,"api:API.OAuth.ClientSecret":(de=(ce=p.API)==null?void 0:ce.OAuth)==null?void 0:de.ClientSecret,"api:API.OAuth.RedirectUri":(P=(se=p.API)==null?void 0:se.OAuth)==null?void 0:P.RedirectUri};await Ne.updateConfigFields(W),m("API settings saved and backend restarted.")}catch(W){m(W instanceof Error?W.message:"Save failed")}finally{l(!1)}}}return a?s.jsx("div",{className:"animate-pulse h-32 bg-secondary/20 rounded-md"}):p?s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:"Core API Settings"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Configure the internal API that powers this dashboard."})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{children:"API Port"}),s.jsx(_e,{type:"number",value:((v=p.API)==null?void 0:v.Port)||"",disabled:!n,onChange:R=>g({...p,API:{...p.API,Port:parseInt(R.target.value)||3e3}}),className:"border-border bg-secondary/30"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{children:"Emerald API Key"}),s.jsx(_e,{type:"password",value:((w=p.API)==null?void 0:w.EmeraldAPIKey)||"",disabled:!n,onChange:R=>g({...p,API:{...p.API,EmeraldAPIKey:R.target.value}}),className:"border-border bg-secondary/30"})]})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsx(Mt,{checked:((y=p.API)==null?void 0:y.TrustProxy)||!1,disabled:!n,onCheckedChange:R=>g({...p,API:{...p.API,TrustProxy:R}})}),s.jsx(Ae,{className:"text-sm",children:"Trust Proxy (Enable if using Cloudflare/Nginx)"})]})]}),s.jsxs("div",{className:"space-y-4 border-t border-border pt-6",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:"OAuth Authentication"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Discord application credentials for dashboard login."})]}),s.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[s.jsx(Mt,{checked:((S=(C=p.API)==null?void 0:C.OAuth)==null?void 0:S.Enabled)||!1,disabled:!n,onCheckedChange:R=>{var L;return g({...p,API:{...p.API,OAuth:{...(L=p.API)==null?void 0:L.OAuth,Enabled:R}}})}}),s.jsx(Ae,{className:"text-sm",children:"Enable OAuth"})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{children:"Client ID"}),s.jsx(_e,{value:((E=(N=p.API)==null?void 0:N.OAuth)==null?void 0:E.ClientId)||"",disabled:!n,onChange:R=>{var L;return g({...p,API:{...p.API,OAuth:{...(L=p.API)==null?void 0:L.OAuth,ClientId:R.target.value}}})},className:"border-border bg-secondary/30"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{children:"Client Secret"}),s.jsx(_e,{type:"password",value:((M=(T=p.API)==null?void 0:T.OAuth)==null?void 0:M.ClientSecret)||"",disabled:!n,onChange:R=>{var L;return g({...p,API:{...p.API,OAuth:{...(L=p.API)==null?void 0:L.OAuth,ClientSecret:R.target.value}}})},className:"border-border bg-secondary/30"})]}),s.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[s.jsx(Ae,{children:"Redirect URI"}),s.jsx(_e,{value:((_=(k=p.API)==null?void 0:k.OAuth)==null?void 0:_.RedirectUri)||"",disabled:!n,onChange:R=>{var L;return g({...p,API:{...p.API,OAuth:{...(L=p.API)==null?void 0:L.OAuth,RedirectUri:R.target.value}}})},className:"border-border bg-secondary/30"}),s.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Must match the OAuth2 callback URL registered in the Discord Developer Portal exactly."})]})]})]}),n?s.jsxs("div",{className:"flex items-center gap-2 border-t border-border pt-6",children:[s.jsx(ue,{type:"button",disabled:c,onClick:()=>void b(),children:c?"Saving…":"Save API Config"}),d?s.jsx("span",{className:"text-xs text-muted-foreground",children:d}):null]}):null]}):null}function nP(){const{hasPermission:t}=Yt(),n=t("settings.update"),[a,o]=f.useState(null),[c,l]=f.useState(!0),[d,m]=f.useState(!1),[p,g]=f.useState(""),[b,v]=f.useState(""),[w,y]=f.useState(()=>d5()??Pl),[C,S]=f.useState(""),[N,E]=f.useState("appearance"),T=f.useCallback(async()=>{l(!0),g("");try{const k=await Ne.checkForUpdates();k.data&&o(k.data)}catch(k){g(k instanceof Error?k.message:"Could not check for updates")}finally{l(!1)}},[]);f.useEffect(()=>{T()},[T]);async function M(k){if(k.updateAvailable){m(!0),g(""),v("");try{const _=await Ne.runUpdate(k.id,k.latest,k.zipUrl);v(_.message||"Update installed. Restart your server (stop and run npm start again) to finish applying changes."),await T()}catch(_){g(_ instanceof Error?_.message:"Update failed")}finally{m(!1)}}}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Settings"}),s.jsx("p",{className:"text-muted-foreground",children:"Application updates and maintenance — config files are edited under each module in the sidebar."})]}),s.jsxs("div",{className:"flex flex-col md:flex-row gap-8 items-start",children:[s.jsx("aside",{className:"w-full md:w-56 shrink-0 sticky top-6",children:s.jsxs("nav",{className:"flex flex-row md:flex-col overflow-x-auto space-x-2 md:space-x-0 md:space-y-1 pb-2 md:pb-0",children:[s.jsx(ue,{variant:N==="appearance"?"secondary":"ghost",className:"justify-start w-full",onClick:()=>E("appearance"),children:"Appearance"}),s.jsx(ue,{variant:N==="api"?"secondary":"ghost",className:"justify-start w-full",onClick:()=>E("api"),children:"API Config"}),s.jsx(ue,{variant:N==="updates"?"secondary":"ghost",className:"justify-start w-full",onClick:()=>E("updates"),children:"Update Checker"}),n&&s.jsx(ue,{variant:"ghost",className:`justify-start w-full text-destructive hover:bg-destructive/10 hover:text-destructive ${N==="danger"?"bg-destructive/10 border-l-2 border-destructive rounded-l-none":""}`,onClick:()=>E("danger"),children:"Danger Zone"})]})}),s.jsxs("main",{className:"flex-1 w-full max-w-4xl space-y-6",children:[N==="appearance"&&s.jsx("div",{className:"space-y-6",children:s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{children:[s.jsx(ft,{className:"text-lg",children:"Dashboard appearance"}),s.jsx(Ot,{children:"Customise branding for all users, and pick an accent colour for this browser only."})]}),s.jsxs(et,{className:"space-y-4",children:[s.jsx(eP,{canEdit:n}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("p",{className:"mb-1 text-sm font-medium",children:"Accent colour"}),s.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:"Buttons, links, and highlights — saved in this browser only."}),s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(tf,{value:w,onChange:k=>{y(k),n2(k),S("Accent updated.")}}),s.jsx(_e,{id:"accent-colour",value:w,onChange:k=>y(k.target.value),onBlur:()=>{const k=$r(w,Pl);y(k),n2(k),S("Accent updated.")},className:"w-32 border-border bg-secondary/30 font-mono uppercase",maxLength:7})]}),s.jsx(ue,{type:"button",variant:"outline",onClick:()=>{Xz(),y(Pl),S("Reset to default purple.")},children:"Reset to default"})]}),s.jsxs("div",{className:"flex flex-wrap gap-2 text-sm mt-5",children:[s.jsx("span",{className:"rounded-md bg-primary px-3 py-1.5 font-medium text-primary-foreground",children:"Primary button"}),s.jsx("span",{className:"rounded-md bg-primary/15 px-3 py-1.5 text-primary",children:"Highlight"}),s.jsx("span",{className:"rounded-md bg-accent px-3 py-1.5 text-accent-foreground",children:"Accent surface"})]}),C?s.jsx("p",{className:"text-xs text-muted-foreground",children:C}):null]})]})]})}),N==="danger"&&n&&s.jsxs(Je,{className:"border-destructive/50 bg-destructive/5",children:[s.jsxs(dt,{children:[s.jsx(ft,{className:"text-lg text-destructive",children:"Danger Zone"}),s.jsx(Ot,{className:"text-destructive/80",children:"Destructive actions that reset or permanently alter your dashboard."})]}),s.jsx(et,{children:s.jsx(Jz,{canEdit:n})})]}),N==="api"&&s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{children:[s.jsx(ft,{className:"text-lg",children:"API Configuration"}),s.jsx(Ot,{children:"Configure the internal API settings, Emerald API key, and OAuth."})]}),s.jsx(et,{children:s.jsx(tP,{})})]}),N==="updates"&&s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{children:[s.jsx(ft,{className:"text-lg",children:"Software updates"}),s.jsx(Ot,{children:"Manage updates for the bot and dashboard."})]}),s.jsxs(et,{className:"space-y-4",children:[c?s.jsx(Ue,{className:"h-24 w-full"}):a&&a.length>0?s.jsx("div",{className:"space-y-4",children:a.map(k=>s.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-secondary/20 p-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("p",{className:"font-medium text-sm",children:[s.jsx("a",{href:k.repository,target:"_blank",rel:"noreferrer",className:"text-primary underline-offset-4 hover:underline",children:k.name})," ","(",k.branch," branch)"]}),s.jsxs("div",{className:"flex gap-x-4 text-sm",children:[s.jsxs("p",{children:[s.jsx("span",{className:"text-muted-foreground",children:"Installed: "}),s.jsxs("span",{className:"font-mono font-medium",children:["v",k.current]})]}),s.jsxs("p",{children:[s.jsx("span",{className:"text-muted-foreground",children:"Latest: "}),s.jsxs("span",{className:"font-mono font-medium",children:["v",k.latest]})]})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[k.updateAvailable?s.jsx("p",{className:"text-sm text-amber-500",children:"A newer version is available. Update downloads files while keeping your Configs and Data."}):s.jsx("p",{className:"text-sm text-emerald-500",children:"You are on the latest release."}),k.updateAvailable&&n?s.jsxs(ue,{type:"button",size:"sm",onClick:()=>void M(k),disabled:d,children:[d?s.jsx(xe,{icon:_2,size:16,className:"mr-2 animate-spin"}):s.jsx(xe,{icon:Cd,size:16,className:"mr-2"}),d?"Installing…":"Update now"]}):null,k.updateAvailable&&!n?s.jsx("p",{className:"text-xs text-muted-foreground",children:"You cannot install updates with your role."}):null]})]},k.id))}):null,p?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:p})}):null,b?s.jsx(Ye,{children:s.jsx(qe,{children:b})}):null,s.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:s.jsxs(ue,{type:"button",variant:"outline",onClick:T,disabled:c||d,children:[s.jsx(xe,{icon:fr,size:16,className:"mr-2"}),"Check again"]})})]})]})]})]})]})}function kx(t){const[n,a]=f.useState(!1),o=f.useRef(t);return o.current=t,f.useEffect(()=>{let c=null,l=null;const d=()=>{c=new EventSource("/api/stream"),c.onopen=()=>{a(!0)},c.addEventListener("connected",()=>{a(!0)}),c.addEventListener("metrics",m=>{var p,g;try{const b=JSON.parse(m.data);(g=(p=o.current).onMetrics)==null||g.call(p,b)}catch{}}),c.addEventListener("log",m=>{var p,g;try{const b=JSON.parse(m.data);(g=(p=o.current).onLog)==null||g.call(p,b)}catch{}}),c.addEventListener("ticket_message",m=>{var p,g;try{const b=JSON.parse(m.data);(g=(p=o.current).onTicketMessage)==null||g.call(p,b)}catch{}}),c.addEventListener("ticket_message_deleted",m=>{var p,g;try{const b=JSON.parse(m.data);(g=(p=o.current).onTicketMessageDeleted)==null||g.call(p,b)}catch{}}),c.addEventListener("ticket_message_updated",m=>{var p,g;try{const b=JSON.parse(m.data);(g=(p=o.current).onTicketMessageUpdated)==null||g.call(p,b)}catch{}}),c.addEventListener("ticket_created",m=>{var p,g;try{const b=JSON.parse(m.data);(g=(p=o.current).onTicketCreated)==null||g.call(p,b)}catch{}}),c.addEventListener("ticket_closed",m=>{var p,g;try{const b=JSON.parse(m.data);(g=(p=o.current).onTicketClosed)==null||g.call(p,b)}catch{}}),c.onerror=()=>{a(!1),c==null||c.close(),l=window.setTimeout(d,4e3)}};return d(),()=>{l&&window.clearTimeout(l),c&&c.close()}},[]),{connected:n}}function Tt({label:t,value:n,mono:a=!1}){return s.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:[s.jsx("dt",{className:"text-sm text-muted-foreground",children:t}),s.jsx("dd",{className:`text-sm font-medium text-foreground ${a?"font-mono text-xs sm:text-sm":""}`,children:n})]})}const rP={ok:"Healthy",missing_config:"Guild ID not set",not_in_guild:"Not in configured server",extra_guilds:"Extra servers joined",offline:"Bot offline"};function aP(t){return t==="ok"?"text-emerald-500":t==="offline"?"text-destructive":"text-amber-500"}function sP(){var N;const{stats:t,loading:n,error:a,refresh:o}=kd(),[c,l]=f.useState(null),[d,m]=f.useState(null),[p,g]=f.useState(!1),[b,v]=f.useState(null),{connected:w}=kx({onMetrics:E=>{v(E)}}),y=f.useCallback(async()=>{const[E,T]=await Promise.all([Ne.getGuildStatus().catch(()=>null),Ne.health().catch(()=>null)]);E!=null&&E.data&&l(E.data),T!=null&&T.success&&T.data&&m({dashboard:T.data.dashboard,botReady:T.data.botReady,oauthEnabled:T.data.oauthEnabled,setupComplete:T.data.setupComplete})},[]);f.useEffect(()=>{y()},[y]);async function C(){g(!0);try{await Promise.all([o(),y()])}finally{g(!1)}}if(n&&!t)return s.jsxs("div",{className:"space-y-6",children:[s.jsx(Ue,{className:"h-10 w-64"}),s.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[s.jsx(Ue,{className:"h-56 rounded-2xl"}),s.jsx(Ue,{className:"h-56 rounded-2xl"})]})]});if(a||!t)return s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:a||"Could not load system details."})});const S=t.bot.ping<200;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(ue,{asChild:!0,variant:"ghost",size:"sm",className:"-ml-2 h-8 px-2 text-muted-foreground",children:s.jsxs(en,{to:"/",children:[s.jsx(xe,{icon:T2,size:16,className:"mr-1.5"}),"Back to dashboard"]})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"System details"}),s.jsx("p",{className:"text-muted-foreground",children:"Live bot, host, and dashboard status — refreshed every 30 seconds."})]})]}),s.jsxs(ue,{type:"button",variant:"outline",disabled:p,onClick:()=>void C(),children:[s.jsx(xe,{icon:fr,size:16,className:"mr-2"}),p?"Refreshing…":"Refresh now"]})]}),s.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{children:[s.jsx(ft,{className:"text-lg",children:"Discord bot"}),s.jsx(Ot,{children:"Connection and identity"})]}),s.jsxs(et,{children:[s.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[s.jsxs(vs,{className:"size-12",children:[s.jsx(eo,{src:t.bot.avatar,alt:t.bot.username}),s.jsx(ys,{children:"SB"})]}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold",children:t.bot.username}),s.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:t.bot.id})]})]}),s.jsxs("dl",{children:[s.jsx(Tt,{label:"Version",value:`v${t.bot.version}`,mono:!0}),s.jsx(Tt,{label:"Gateway latency",value:s.jsxs("span",{className:S?"text-emerald-500":"text-amber-500",children:[t.bot.ping," ms"]})}),s.jsx(Tt,{label:"Process uptime",value:fg(t.bot.uptime)}),s.jsx(Tt,{label:"Connected servers",value:t.servers.toLocaleString()}),s.jsx(Tt,{label:"Members tracked",value:t.users.toLocaleString()}),t.bot.inviteUrl?s.jsx(Tt,{label:"Invite link",value:s.jsx("a",{href:t.bot.inviteUrl,target:"_blank",rel:"noreferrer",className:"text-primary underline-offset-4 hover:underline",children:"Open in Discord"})}):null]})]})]}),s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsx(ft,{className:"text-lg",children:"Host machine"}),s.jsx(Ot,{children:"Server resources running this instance"})]}),s.jsxs(Fn,{variant:w?"default":"outline",className:"text-xs",children:[s.jsx("span",{className:`mr-1.5 inline-block h-2 w-2 rounded-full ${w?"bg-emerald-500 animate-pulse":"bg-muted"}`}),w?"Live Stream":"Polling"]})]}),s.jsx(et,{children:s.jsxs("dl",{children:[s.jsx(Tt,{label:"Memory used",value:b?`${(b.ram_used_mb/1024).toFixed(2)} GB / ${(b.ram_total_mb/1024).toFixed(2)} GB`:`${t.hosting.ram_used} / ${t.hosting.ram_total}`}),s.jsx(Tt,{label:"Memory usage",value:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:(b?b.ram_percent:t.hosting.ram_percent)>85?"text-amber-500 font-bold":"text-foreground font-medium",children:[b?b.ram_percent:t.hosting.ram_percent,"%"]}),s.jsx("div",{className:"w-24 h-2 bg-secondary rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-primary transition-all duration-500",style:{width:`${b?b.ram_percent:t.hosting.ram_percent}%`}})})]})}),s.jsx(Tt,{label:"CPU load (1 min avg)",value:b?String(b.cpu_load):t.hosting.cpu_load,mono:!0}),s.jsx(Tt,{label:"Host uptime",value:t.hosting.uptime})]})})]}),s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{children:[s.jsx(ft,{className:"text-lg",children:"Tickets"}),s.jsx(Ot,{children:"Database snapshot"})]}),s.jsx(et,{children:s.jsxs("dl",{children:[s.jsx(Tt,{label:"Total tickets",value:t.tickets.total}),s.jsx(Tt,{label:"Open",value:s.jsx("span",{className:"text-primary",children:t.tickets.open})}),s.jsx(Tt,{label:"Closed",value:t.tickets.closed}),s.jsx(Tt,{label:"Transcripts",value:s.jsx(en,{to:"/transcripts",className:"text-primary underline-offset-4 hover:underline",children:"Browse archive"})})]})})]}),s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{children:[s.jsx(ft,{className:"text-lg",children:"Guild health"}),s.jsx(Ot,{children:"Configured server and membership"})]}),s.jsx(et,{children:c?s.jsxs("dl",{children:[s.jsx(Tt,{label:"Status",value:s.jsx("span",{className:aP(c.status),children:rP[c.status]})}),s.jsx(Tt,{label:"Configured guild ID",value:c.configuredGuildId||"Not set",mono:!0}),c.configuredGuild?s.jsx(Tt,{label:"Configured server",value:`${c.configuredGuild.name} (${((N=c.configuredGuild.memberCount)==null?void 0:N.toLocaleString())??"?"} members)`}):null,c.message?s.jsx("div",{className:"mt-3 rounded-lg border border-border bg-secondary/30 px-3 py-2 text-sm text-muted-foreground",children:c.message}):null,c.extraGuilds.length>0?s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Extra servers"}),s.jsx("ul",{className:"space-y-1 text-sm",children:c.extraGuilds.map(E=>s.jsxs("li",{className:"font-mono text-xs",children:[E.name," · ",E.id]},E.id))})]}):null]}):s.jsx(Ue,{className:"h-24 w-full"})})]})]}),s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{children:[s.jsx(ft,{className:"text-lg",children:"Dashboard services"}),s.jsx(Ot,{children:"API and authentication"})]}),s.jsx(et,{children:d?s.jsxs("dl",{className:"max-w-xl",children:[s.jsx(Tt,{label:"Dashboard UI",value:d.dashboard?"Available":"Missing build"}),s.jsx(Tt,{label:"Bot connection",value:d.botReady?"Online":"Starting or offline"}),s.jsx(Tt,{label:"Discord OAuth",value:d.oauthEnabled?"Configured":"Not configured"}),s.jsx(Tt,{label:"Initial setup",value:d.setupComplete?"Complete":"Incomplete"}),s.jsx(Tt,{label:"Software updates",value:s.jsx(en,{to:"/settings",className:"text-primary underline-offset-4 hover:underline",children:"Open settings"})}),s.jsx(Tt,{label:"Logs",value:s.jsx(en,{to:"/logs",className:"text-primary underline-offset-4 hover:underline",children:"View log files"})})]}):s.jsx(Ue,{className:"h-32 w-full max-w-xl"})})]}),t.modules?s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{children:[s.jsx(ft,{className:"text-lg",children:"Module setup status"}),s.jsx(Ot,{children:"Which features are configured and active"})]}),s.jsx(et,{children:s.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:ai.map(E=>{const T=Kh(E.id,t.modules);return s.jsxs(en,{to:E.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:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm font-medium",children:E.title}),s.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:T.subtitle})]}),s.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:c5[T.status]})]},E.id)})})})]}):null]})}function oP(t){if(!t)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?t:n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}const iP=[{id:"all",label:"All"},{id:"Output",label:"Output"},{id:"Warn",label:"Warn"},{id:"Error",label:"Error"}],lP=["Output","Warn","Error"],cP={Output:"text-foreground/90",Warn:"text-amber-400",Error:"text-rose-400"},uP={Output:"bg-muted text-muted-foreground",Warn:"bg-amber-500/15 text-amber-400",Error:"bg-rose-500/15 text-rose-400"},gd=2e3,dP=2e3;function Wh(t,n){return`${t.type}-${t.timestamp??"na"}-${n}-${t.message.slice(0,32)}`}function fP(t,n,a){const o=a?[]:t,c=new Set(o.map((m,p)=>Wh(m,p))),l=[];for(let m=0;mgd?d.slice(d.length-gd):d}function mP(){const[t,n]=f.useState([]),[a,o]=f.useState(!0),[c,l]=f.useState(""),[d,m]=f.useState(!1),[p,g]=f.useState(!0),[b,v]=f.useState("all"),[w,y]=f.useState(""),[C,S]=f.useState(!0),[N,E]=f.useState(""),T=f.useRef(null),M=f.useRef(null),k=f.useRef(d);k.current=d;const _=f.useMemo(()=>b==="all"?lP:[b],[b]),R=f.useCallback(I=>{k.current||b!=="all"&&I.type!==b||(n(H=>{const q=[...H,I];return q.length>gd?q.slice(q.length-gd):q}),S(!0))},[b]);kx({onLog:R});const L=f.useCallback(async I=>{var ce,de;const H=await Ne.getLogs({types:_,cursor:I?void 0:T.current??void 0,tail:I?500:0}),q=((ce=H.data)==null?void 0:ce.entries)??[];return T.current=((de=H.data)==null?void 0:de.cursor)??{},n(se=>fP(se,q,I)),q.length},[_]),ne=f.useCallback(async()=>{var I;o(!0),l(""),T.current=null;try{const ce=(((I=(await Ne.getLogsMeta()).data)==null?void 0:I.files)??[]).filter(de=>de.file).map(de=>`${de.type}: ${de.file}`).join(" · ");E(ce||"No log files yet — output appears when the bot runs."),await L(!0),S(!0)}catch(H){l(H instanceof Error?H.message:"Failed to load logs"),S(!1)}finally{o(!1)}},[L]);f.useEffect(()=>{ne()},[ne]),f.useEffect(()=>{if(d||a)return;const I=window.setInterval(async()=>{if(!k.current)try{await L(!1),S(!0),l("")}catch(H){S(!1),l(H instanceof Error?H.message:"Live update failed")}},dP);return()=>window.clearInterval(I)},[d,a,L]),f.useEffect(()=>{if(!p||d)return;const I=M.current;I&&(I.scrollTop=I.scrollHeight)},[t,p,d]);const X=f.useMemo(()=>t.filter(I=>{var q;if(b!=="all"&&I.type!==b)return!1;if(!w.trim())return!0;const H=w.toLowerCase();return I.message.toLowerCase().includes(H)||(((q=I.timestamp)==null?void 0:q.toLowerCase().includes(H))??!1)}),[t,b,w]);return s.jsxs("div",{className:"flex h-[calc(100svh-8rem)] min-h-[480px] flex-col gap-4",children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Logs"}),s.jsx("p",{className:"text-muted-foreground",children:"Live bot output — updates every 2 seconds"}),N?s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:N}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:pe("size-2 rounded-full",C&&!d?"animate-pulse bg-emerald-500":"bg-muted-foreground")}),s.jsx("span",{className:"text-xs text-muted-foreground",children:d?"Paused":C?"Live":"Disconnected"})]})]}),c?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:c})}):null,s.jsxs(Je,{className:"flex min-h-0 flex-1 flex-col border-border bg-card",children:[s.jsxs(dt,{className:"shrink-0 space-y-4 border-b border-border pb-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs(ft,{className:"text-base font-medium",children:["Console",a?null:s.jsxs("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:[X.length," line",X.length===1?"":"s"]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border px-2 py-1",children:[s.jsx(Mt,{id:"auto-scroll",checked:p,onCheckedChange:g}),s.jsx(Ae,{htmlFor:"auto-scroll",className:"text-xs font-normal",children:"Auto-scroll"})]}),s.jsxs(ue,{type:"button",variant:"outline",size:"sm",onClick:()=>m(I=>!I),children:[s.jsx(xe,{icon:d?k8:E8,size:16,className:"mr-1.5"}),d?"Resume":"Pause"]}),s.jsxs(ue,{type:"button",variant:"outline",size:"sm",onClick:()=>{n([]),ne()},disabled:a,children:[s.jsx(xe,{icon:fr,size:16,className:"mr-1.5"}),"Refresh"]})]})]}),s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[s.jsx("div",{className:"flex flex-wrap gap-1 rounded-xl bg-secondary/50 p-1",children:iP.map(I=>s.jsx(ue,{type:"button",variant:b===I.id?"secondary":"ghost",size:"sm",className:"h-8 rounded-lg text-xs",onClick:()=>v(I.id),children:I.label},I.id))}),s.jsxs("div",{className:"relative flex-1 sm:max-w-xs",children:[s.jsx(xe,{icon:vi,size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx(_e,{placeholder:"Filter lines…",value:w,onChange:I=>y(I.target.value),className:"h-9 pl-9"})]})]})]}),s.jsx(et,{className:"min-h-0 flex-1 p-0",children:a?s.jsx("div",{className:"space-y-2 p-4",children:Array.from({length:8}).map((I,H)=>s.jsx(Ue,{className:"h-4 w-full"},H))}):s.jsx("div",{ref:M,className:"h-full max-h-[calc(100svh-18rem)] overflow-y-auto bg-[#0d0d12] p-4 font-mono text-[13px] leading-relaxed",children:X.length===0?s.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)."}):s.jsx("ul",{className:"space-y-1",children:X.map((I,H)=>s.jsxs("li",{className:"flex gap-2 rounded px-1 py-0.5 hover:bg-white/[0.03]",children:[s.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:oP(I.timestamp)}),s.jsx("span",{className:pe("shrink-0 rounded px-1.5 py-0 text-[10px] font-semibold uppercase",uP[I.type]),children:I.type}),s.jsx("span",{className:pe("min-w-0 flex-1 whitespace-pre-wrap break-words",cP[I.type]),children:I.message||" "})]},Wh(I,H)))})})})]})]})}const pP=[{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; }"}]}],hP=450;function gP(t,n){return n&&t!=="viewer"}function xP(){const{user:t,hasPermission:n}=Yt(),a=!gP(t==null?void 0:t.role,n("transcripts")),[o,c]=f.useState(null),[l,d]=f.useState(null),[m,p]=f.useState(!0),[g,b]=f.useState(!1),[v,w]=f.useState(""),[y,C]=f.useState(""),[S,N]=f.useState(""),[E,T]=f.useState(!1),M=f.useRef(null),k=f.useCallback(async()=>{var X;p(!0),w(""),C("");try{const H=(await Ne.getTranscriptTemplate()).data??null;if(H){const q={...H,Typography:{...H.Typography,FontFamily:kS((X=H.Typography)==null?void 0:X.FontFamily)}};c(q),d(structuredClone(q))}}catch(I){w(I instanceof Error?I.message:"Failed to load template")}finally{p(!1)}},[]);f.useEffect(()=>{k()},[k]);const _=f.useCallback(async X=>{T(!0);try{const I=await Ne.previewTranscriptTemplate(X);N(I)}catch{N("

Preview failed to load.

")}finally{T(!1)}},[]);f.useEffect(()=>{if(o)return M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{_(o)},hP),()=>{M.current&&clearTimeout(M.current)}},[o,_]);function R(X,I){c(H=>H&&Gn(H,X,I))}async function L(){if(!(a||!o)){b(!0),w(""),C("");try{const X=await Ne.saveTranscriptTemplate(o);C(X.message||"Saved."),d(structuredClone(o))}catch(X){w(X instanceof Error?X.message:"Save failed")}finally{b(!1)}}}const ne=o&&l&&JSON.stringify(o)!==JSON.stringify(l);return m?s.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[s.jsx(Ue,{className:"h-96 rounded-xl"}),s.jsx(Ue,{className:"h-96 rounded-xl"})]}):o?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"Customize how new ticket transcripts look. Existing saved transcripts are not changed."}),s.jsxs("div",{className:"flex items-center gap-2",children:[ne?s.jsx("span",{className:"text-xs text-amber-500",children:"Unsaved changes"}):null,a?s.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}):s.jsxs(ue,{size:"sm",onClick:L,disabled:g||!ne,children:[s.jsx(xe,{icon:Sd,size:16,className:"mr-1.5"}),g?"Saving…":"Save appearance"]})]})]}),v?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:v})}):null,y?s.jsx(Ye,{className:"border-primary/30 bg-primary/10 text-primary",children:s.jsx(qe,{children:y})}):null,s.jsxs("div",{className:"grid min-h-0 gap-4 xl:grid-cols-[minmax(320px,420px)_1fr]",children:[s.jsx(bP,{data:o,readOnly:a,onPatch:R}),s.jsxs(Je,{className:"flex min-h-[520px] flex-col overflow-hidden border-border bg-card",children:[s.jsxs(dt,{className:"pb-2",children:[s.jsx(ft,{className:"text-base",children:"Live preview"}),s.jsxs(Ot,{children:["Sample ticket with your current settings",E?" · updating…":""]})]}),s.jsx(et,{className:"min-h-0 flex-1 p-4 pt-0",children:s.jsx("iframe",{title:"Transcript template preview",srcDoc:S,className:pe("h-[min(640px,calc(100svh-14rem))] w-full rounded-lg border border-border bg-background",E&&"opacity-60"),sandbox:"allow-same-origin"})})]})]})]}):s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:v||"Failed to load template"})})}function bP({data:t,readOnly:n,onPatch:a}){return s.jsx("div",{className:"max-h-[min(720px,calc(100svh-12rem))] space-y-4 overflow-y-auto pr-1",children:pP.map(o=>s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{className:"pb-3",children:[s.jsx(ft,{className:"text-base",children:o.title}),o.description?s.jsx(Ot,{children:o.description}):null]}),s.jsx(et,{className:"grid gap-4 sm:grid-cols-2",children:o.fields.map(c=>s.jsx("div",{className:c.type==="textarea"?"sm:col-span-2":"",children:s.jsx(pd,{field:c,value:kr(t,c.path),readOnly:n,onChange:l=>a(c.path,l)})},c.path))})]},o.title))})}function vP(t,n){return n&&t!=="viewer"}function yP(){const{user:t,hasPermission:n}=Yt(),a=!vP(t==null?void 0:t.role,n("transcripts")),[o,c]=f.useState(null),[l,d]=f.useState(!0),[m,p]=f.useState(!1),[g,b]=f.useState(!1),[v,w]=f.useState(""),[y,C]=f.useState(""),S=f.useCallback(async()=>{var T,M,k;d(!0),w(""),C("");try{const R=(await Ne.getTranscriptSettings()).data;R&&c({autoDelete:{enabled:!!((T=R.autoDelete)!=null&&T.enabled),afterDays:((M=R.autoDelete)==null?void 0:M.afterDays)??30},publicAccess:{enabled:!!((k=R.publicAccess)!=null&&k.enabled)}})}catch(_){w(_ instanceof Error?_.message:"Failed to load settings")}finally{d(!1)}},[]);f.useEffect(()=>{S()},[S]);async function N(){if(!(!o||a)){p(!0),w(""),C("");try{const T=await Ne.updateTranscriptSettings(o);T.data&&c({autoDelete:{enabled:T.data.autoDelete.enabled,afterDays:T.data.autoDelete.afterDays},publicAccess:{enabled:T.data.publicAccess.enabled}}),C(T.message??"Settings saved.")}catch(T){w(T instanceof Error?T.message:"Failed to save settings")}finally{p(!1)}}}async function E(){var T,M;if(!a){b(!0),w(""),C("");try{const k=await Ne.purgeTranscripts();C(k.message??((T=k.data)!=null&&T.skipped?"Auto-delete is disabled.":`Removed ${((M=k.data)==null?void 0:M.deleted)??0} transcript(s).`))}catch(k){w(k instanceof Error?k.message:"Purge failed")}finally{b(!1)}}}return l?s.jsxs("div",{className:"space-y-4",children:[s.jsx(Ue,{className:"h-40 w-full rounded-xl"}),s.jsx(Ue,{className:"h-40 w-full rounded-xl"})]}):o?s.jsxs("div",{className:"mx-auto max-w-2xl space-y-4",children:[a?s.jsx(Ye,{children:s.jsx(qe,{children:"You have view-only access. An admin or editor can change these settings."})}):null,v?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:v})}):null,y?s.jsx(Ye,{children:s.jsx(qe,{children:y})}):null,s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{children:[s.jsx(ft,{className:"text-base",children:"Auto-delete"}),s.jsx(Ot,{children:"Remove transcript files automatically after they reach a certain age. The server checks hourly and whenever you open the library."})]}),s.jsxs(et,{className:"space-y-4",children:[s.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 size-4 rounded border-border accent-primary",checked:o.autoDelete.enabled,disabled:a,onChange:T=>c(M=>M&&{...M,autoDelete:{...M.autoDelete,enabled:T.target.checked}})}),s.jsxs("span",{className:"text-sm",children:[s.jsx("span",{className:"font-medium",children:"Enable auto-delete"}),s.jsx("span",{className:"mt-0.5 block text-muted-foreground",children:"Deletes HTML files in Data/Transcripts based on last modified time."})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-sm font-medium",htmlFor:"transcript-after-days",children:"Delete after (days)"}),s.jsx(_e,{id:"transcript-after-days",type:"number",min:1,max:3650,disabled:a||!o.autoDelete.enabled,value:o.autoDelete.afterDays,onChange:T=>c(M=>M&&{...M,autoDelete:{...M.autoDelete,afterDays:Math.min(3650,Math.max(1,parseInt(T.target.value,10)||1))}}),className:"max-w-[8rem]"})]}),s.jsxs(ue,{type:"button",variant:"outline",size:"sm",disabled:a||g,onClick:()=>void E(),children:[s.jsx(xe,{icon:fr,size:16,className:pe(g&&"animate-spin")}),"Run cleanup now"]})]})]}),s.jsxs(Je,{className:"border-border bg-card",children:[s.jsxs(dt,{children:[s.jsx(ft,{className:"text-base",children:"Public transcripts"}),s.jsxs(Ot,{children:["When enabled, anyone with the link can view a transcript at"," ",s.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."]})]}),s.jsx(et,{children:s.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[s.jsx("input",{type:"checkbox",className:"mt-1 size-4 rounded border-border accent-primary",checked:o.publicAccess.enabled,disabled:a,onChange:T=>c(M=>M&&{...M,publicAccess:{enabled:T.target.checked}})}),s.jsxs("span",{className:"text-sm",children:[s.jsx("span",{className:"font-medium",children:"Allow public transcript URLs"}),s.jsx("span",{className:"mt-0.5 block text-muted-foreground",children:"Dashboard preview and download still require login."})]})]})})]}),a?null:s.jsxs(ue,{type:"button",disabled:m,onClick:()=>void N(),children:[s.jsx(xe,{icon:Sd,size:16}),m?"Saving…":"Save settings"]})]}):s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:"Could not load transcript settings."})})}function wP(t,n){return n&&t!=="viewer"}function r2(t){return t==null?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function a2(t){const n=new Date(t);return Number.isNaN(n.getTime())?t:n.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function jP(){var B;const{user:t,hasPermission:n}=Yt(),a=wP(t==null?void 0:t.role,n("transcripts")),[o,c]=f.useState("browse"),[l,d]=f.useState([]),[m,p]=f.useState(null),[g,b]=f.useState(!0),[v,w]=f.useState(""),[y,C]=f.useState(""),[S,N]=f.useState(""),[E,T]=f.useState(0),[M,k]=f.useState(!1),[_,R]=f.useState(!1),[L,ne]=f.useState(!1),[X,I]=f.useState(!1),H=f.useCallback(async()=>{b(!0),C("");try{const Z=(await Ne.listTranscripts()).data??[];d(Z),p(be=>{var K;return be&&Z.some(ge=>ge.id===be)?be:((K=Z[0])==null?void 0:K.id)??null})}catch(V){C(V instanceof Error?V.message:"Failed to load transcripts")}finally{b(!1)}},[]);f.useEffect(()=>{H()},[H]),f.useEffect(()=>{o==="browse"&&Ne.getTranscriptSettings().then(V=>{var Z,be;ne(!!((be=(Z=V.data)==null?void 0:Z.publicAccess)!=null&&be.enabled))}).catch(()=>ne(!1))},[o]);const q=f.useMemo(()=>{if(!S.trim())return l;const V=S.toLowerCase();return l.filter(Z=>Z.id.includes(V)||Z.filename.toLowerCase().includes(V)||Z.ticketName&&Z.ticketName.toLowerCase().includes(V))},[l,S]),ce=f.useMemo(()=>l.find(V=>V.id===m)??null,[l,m]),de=m?`/api/system/transcripts/${encodeURIComponent(m)}/view`:null,se=m?`/api/system/transcripts/${encodeURIComponent(m)}/download`:null,P=m&&L?`${window.location.origin}/transcripts/${encodeURIComponent(m)}`:null;function W(V){w(""),p(V),T(Z=>Z+1)}function oe(){de&&window.open(de,"_blank","noopener,noreferrer")}function ae(){P&&window.open(P,"_blank","noopener,noreferrer")}async function G(){if(P)try{await navigator.clipboard.writeText(P),I(!0),window.setTimeout(()=>I(!1),2e3)}catch{w("Could not copy link to clipboard.")}}async function O(){var Z;if(!m||!a)return;const V=((Z=ce==null?void 0:ce.ticketName)==null?void 0:Z.trim())||`channel ${m}`;if(window.confirm(`Delete the transcript for ${V}? This cannot be undone.`)){R(!0),w("");try{await Ne.deleteTranscript(m),await H()}catch(be){w(be instanceof Error?be.message:"Failed to delete transcript")}finally{R(!1)}}}async function D(){if(!(!se||!ce)){k(!0),w("");try{const V=await fetch(se,{credentials:"include"});if(!V.ok){const ge=await V.json().catch(()=>({}));throw new Error(ge.error||`Download failed (${V.status})`)}const Z=await V.blob(),be=URL.createObjectURL(Z),K=document.createElement("a");K.href=be,K.download=ce.filename,K.click(),URL.revokeObjectURL(be)}catch(V){w(V instanceof Error?V.message:"Failed to download transcript")}finally{k(!1)}}}return s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Transcripts"}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Browse saved transcripts or customize how new ones look when tickets close."})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("div",{className:"flex rounded-lg border border-border p-0.5",children:[s.jsx(ue,{type:"button",variant:o==="browse"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>c("browse"),children:"Library"}),s.jsx(ue,{type:"button",variant:o==="appearance"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>c("appearance"),children:"Appearance"}),s.jsx(ue,{type:"button",variant:o==="settings"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>c("settings"),children:"Settings"})]}),o==="browse"?s.jsxs(ue,{variant:"outline",size:"sm",onClick:()=>H(),disabled:g,children:[s.jsx(xe,{icon:fr,size:16,className:pe(g&&"animate-spin")}),"Refresh"]}):null]})]}),o==="appearance"?s.jsx(xP,{}):o==="settings"?s.jsx(yP,{}):s.jsxs(s.Fragment,{children:[y?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:y})}):null,s.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 lg:grid-cols-[minmax(240px,320px)_1fr]",children:[s.jsxs(Je,{className:"flex min-h-[420px] flex-col border-border bg-card",children:[s.jsxs(dt,{className:"space-y-3 pb-3",children:[s.jsxs(ft,{className:"text-base font-medium",children:["Saved transcripts",!g&&l.length>0?s.jsxs("span",{className:"ml-2 font-normal text-muted-foreground",children:["(",l.length,")"]}):null]}),s.jsxs("div",{className:"relative",children:[s.jsx(xe,{icon:vi,size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx(_e,{placeholder:"Search by ticket name or channel ID…",value:S,onChange:V=>N(V.target.value),className:"pl-9"})]})]}),s.jsx(et,{className:"min-h-0 flex-1 p-0 pb-4",children:s.jsx(fc,{className:"h-[min(520px,calc(100svh-16rem))] px-4",children:g?s.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((V,Z)=>s.jsx(Ue,{className:"h-16 w-full rounded-lg"},Z))}):q.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center text-sm text-muted-foreground",children:[s.jsx(xe,{icon:Ul,size:32,className:"opacity-40"}),s.jsx("p",{children:l.length===0?"No transcripts yet. They appear when tickets are closed.":"No transcripts match your search."})]}):s.jsx("ul",{className:"space-y-1.5",children:q.map(V=>{var K;const Z=V.id===m,be=((K=V.ticketName)==null?void 0:K.trim())||`Channel ${V.id}`;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>W(V.id),className:pe("w-full rounded-lg border px-3 py-2.5 text-left transition-colors",Z?"border-primary/50 bg-primary/10":"border-transparent bg-secondary/30 hover:bg-secondary/50"),children:[s.jsx("p",{className:"truncate text-sm font-medium",children:be}),s.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[a2(V.createdAt),V.size!=null?` · ${r2(V.size)}`:""]})]})},V.id)})})})})]}),s.jsxs(Je,{className:"flex min-h-[420px] flex-col overflow-hidden border-border bg-card",children:[s.jsxs(dt,{className:"flex flex-row flex-wrap items-center justify-between gap-2 space-y-0 pb-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx(ft,{className:"truncate text-base font-medium",children:ce?((B=ce.ticketName)==null?void 0:B.trim())||`Channel ${ce.id}`:"Preview"}),ce?s.jsxs("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[a2(ce.createdAt),ce.size!=null?` · ${r2(ce.size)}`:""]}):null]}),s.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2",children:[P?s.jsxs(s.Fragment,{children:[s.jsxs(ue,{variant:"outline",size:"sm",onClick:()=>void G(),children:[s.jsx(xe,{icon:R2,size:16}),X?"Copied":"Copy link"]}),s.jsxs(ue,{variant:"outline",size:"sm",onClick:ae,children:[s.jsx(xe,{icon:Nd,size:16}),"Public page"]})]}):null,s.jsxs(ue,{variant:"outline",size:"sm",disabled:!de,onClick:oe,children:[s.jsx(xe,{icon:p8,size:16}),"Open tab"]}),s.jsxs(ue,{variant:"outline",size:"sm",disabled:!se||M,onClick:()=>void D(),children:[s.jsx(xe,{icon:Cd,size:16}),M?"Saving…":"Download"]}),a?s.jsxs(ue,{variant:"outline",size:"sm",disabled:!m||_,className:"text-destructive hover:text-destructive",onClick:()=>void O(),children:[s.jsx(xe,{icon:bi,size:16}),_?"Deleting…":"Delete"]}):null]})]}),s.jsxs(et,{className:"flex min-h-0 flex-1 flex-col gap-2 p-4 pt-0",children:[v?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:v})}):null,ce&&de?s.jsx("iframe",{title:`Transcript ${ce.id}`,src:de,className:"min-h-[min(560px,calc(100svh-18rem))] w-full flex-1 rounded-lg border border-border bg-background",sandbox:"allow-same-origin"},E):s.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:[s.jsx(xe,{icon:Ul,size:40,className:"opacity-30"}),s.jsx("p",{children:"Select a transcript from the list to preview it here."})]})]})]})]})]})]})}function CP(){const[t,n]=f.useState([]),[a,o]=f.useState(""),[c,l]=f.useState(!0),[d,m]=f.useState(""),[p,g]=f.useState(!0),[b,v]=f.useState([]);f.useEffect(()=>{try{Ne.getConfigJson("supportbot").then(Y=>{if(Y&&Y.data&&typeof Y.data=="object"){const te=kr(Y.data,"Ticket.DepartmentSystem.Enabled");typeof te=="boolean"&&g(te);const je=kr(Y.data,"Ticket.DepartmentSystem.Departments");if(je&&typeof je=="object"){const we=Object.entries(je).map(([Le,Xe])=>({id:Le,name:Xe&&typeof Xe=="object"&&Xe.Name?Xe.Name:Le,emoji:Xe&&typeof Xe=="object"&&Xe.Emoji?Xe.Emoji:"🎫"}));we.length>0&&(v(we),yn(we[0].id))}}}).catch(()=>{})}catch{}},[]);const[w,y]=f.useState("all"),[C,S]=f.useState("all"),[N,E]=f.useState(""),T=f.useMemo(()=>{const Y=new Set;return Array.isArray(t)&&t.forEach(te=>{if(te&&te.department&&typeof te.department=="string"){const je=te.department.trim().toLowerCase();je&&Y.add(je)}}),Array.from(Y).sort()},[t]),M=f.useMemo(()=>Array.isArray(t)?t.filter(Y=>{var te,je,we,Le,Xe,vt;if(!Y||p&&w!=="all"&&((te=Y.department)==null?void 0:te.toLowerCase())!==w.toLowerCase()||C!=="all"&&((je=Y.priority)==null?void 0:je.toLowerCase())!==C.toLowerCase())return!1;if(N.trim()){const gt=N.toLowerCase().trim(),jn=(we=Y.subject)==null?void 0:we.toLowerCase().includes(gt),mn=(Le=Y.ticket_id)==null?void 0:Le.toLowerCase().includes(gt),an=(Xe=Y.user_id)==null?void 0:Xe.toLowerCase().includes(gt),tr=p&&((vt=Y.department)==null?void 0:vt.toLowerCase().includes(gt));if(!jn&&!mn&&!an&&!tr)return!1}return!0}):[],[t,p,w,C,N]),[k,_]=f.useState(null),[R,L]=f.useState(!1),[ne,X]=f.useState(!1),[I,H]=f.useState([]),[q,ce]=f.useState(!1),[de,se]=f.useState(""),[P,W]=f.useState([]),[oe,ae]=f.useState(!1),[G,O]=f.useState(null),[D,B]=f.useState(!1),[V,Z]=f.useState(""),[be,K]=f.useState(null),[ge,me]=f.useState(""),[$,ie]=f.useState(!1),[ye,Se]=f.useState(null),[Be,Ke]=f.useState(""),[We,qt]=f.useState(null),[vn,Xn]=f.useState(!1),[br,yn]=f.useState("general"),[wn,Zn]=f.useState(""),[Kt,po]=f.useState(""),[Pt,Qn]=f.useState(!1),Da=async()=>{if(!wn.trim()){Dt.error("Please enter a subject or reason for the ticket.");return}Qn(!0);try{const Y=await Ne.createTicket({department:p?br:"general",subject:wn.trim(),userId:Kt.trim()||void 0});Dt.success(Y.message||"Ticket opened successfully!"),Xn(!1),Zn(""),po(""),yt()}catch(Y){Dt.error(Y instanceof Error?Y.message:"Failed to open ticket.")}finally{Qn(!1)}},Es=Y=>{Se(Y),Ke("Closed via Web Dashboard"),ie(!0)},qr=async()=>{if(!ye)return;const Y=ye.ticket_id;qt(Y);try{await Ne.closeTicket(Y,Be||"Closed via Web Dashboard"),Dt.success("Ticket closed and transcript saved."),n(te=>te.filter(je=>je.ticket_id!==Y)),(k==null?void 0:k.ticket_id)===Y&&(L(!1),X(!1),_(null)),ie(!1),Se(null)}catch(te){Dt.error(te instanceof Error?te.message:"Failed to close ticket.")}finally{qt(null)}},ho=f.useRef(null),Kr=f.useRef(null),Dn=()=>{var Y;(Y=ho.current)==null||Y.scrollIntoView({behavior:"smooth"})},yt=f.useCallback(async()=>{l(!0),m("");try{const Y=await Ne.listOpenTickets();Y.data&&(o(Y.data.guildId),n(Y.data.tickets.sort((te,je)=>je.created_at-te.created_at)))}catch(Y){m(Y instanceof Error?Y.message:"Failed to load open tickets")}finally{l(!1)}},[]);f.useEffect(()=>{yt()},[yt]),f.useEffect(()=>{Ne.getGuildResources().then(Y=>{Y.data&&O(Y.data)}).catch(()=>{})},[]);const On=f.useCallback(Y=>{k&&Y.ticketId===k.ticket_id&&(H(te=>te.some(je=>je.id===Y.message.id)?te:[...te,Y.message]),setTimeout(Dn,100))},[k]),Rt=f.useCallback(Y=>{k&&Y.ticketId===k.ticket_id&&H(te=>te.filter(je=>je.id!==Y.messageId))},[k]),Ai=f.useCallback(Y=>{k&&Y.ticketId===k.ticket_id&&H(te=>te.map(je=>je.id===Y.messageId?{...je,content:Y.content}:je))},[k]),_i=f.useCallback(Y=>{n(te=>te.some(je=>je.ticket_id===Y.ticket_id)?te:[Y,...te]),Dt.info("New Ticket Created",{description:`#${Y.ticket_id} - ${Y.subject||"No Subject"}`})},[]),go=f.useCallback(Y=>{n(te=>te.filter(je=>je.ticket_id!==Y.ticket_id)),(k==null?void 0:k.ticket_id)===Y.ticket_id&&Dt.warning("Active ticket was closed in Discord.")},[k]);kx({onTicketMessage:On,onTicketMessageDeleted:Rt,onTicketMessageUpdated:Ai,onTicketCreated:_i,onTicketClosed:go});const Wr=async Y=>{var te;_(Y),L(!0),ce(!0),H([]),W([]),K(null);try{const je=await Ne.getTicketMessages(Y.ticket_id);(te=je.data)!=null&&te.messages&&(H(je.data.messages),setTimeout(Dn,150))}catch(je){Dt.error(je instanceof Error?je.message:"Failed to fetch messages")}finally{ce(!1)}},Oa=Y=>{const te=Array.from(Y.target.files||[]);te.length&&(te.forEach(je=>{const we=new FileReader;we.onload=Le=>{var vt;const Xe=(vt=Le.target)==null?void 0:vt.result;W(gt=>[...gt,{filename:je.name,data:Xe,previewUrl:je.type.startsWith("image/")?Xe:void 0,sizeMb:(je.size/1024/1024).toFixed(2)}])},we.readAsDataURL(je)}),Kr.current&&(Kr.current.value=""))},Ar=Y=>{W(te=>te.filter((je,we)=>we!==Y))},Wt=async Y=>{var we;if(Y.preventDefault(),!de.trim()&&!P.length||!k||oe)return;const te=de.trim(),je=[...P];ae(!0),se(""),W([]),B(!1);try{const Le=await Ne.me().catch(()=>null),Xe=((we=Le==null?void 0:Le.data)==null?void 0:we.username)||"Staff",vt=await Ne.sendTicketReply(k.ticket_id,te,Xe,je.map(gt=>({filename:gt.filename,data:gt.data})));vt.data&&(H(gt=>gt.some(jn=>jn.id===vt.data.id)?gt:[...gt,{id:vt.data.id,author:vt.data.author,content:vt.data.content,attachments:vt.data.attachments||[],createdAt:vt.data.createdAt}]),setTimeout(Dn,100))}catch(Le){Dt.error(Le instanceof Error?Le.message:"Failed to send reply to Discord."),se(te),W(je)}finally{ae(!1)}},La=async Y=>{if(k)try{await Ne.deleteTicketMessage(k.ticket_id,Y),H(te=>te.filter(je=>je.id!==Y)),Dt.success("Message deleted in Discord.")}catch(te){Dt.error(te instanceof Error?te.message:"Failed to delete message.")}},De=Y=>{K(Y.id),me(Y.content)},rt=()=>{K(null),me("")},lt=async Y=>{if(!(!k||!ge.trim()))try{await Ne.editTicketMessage(k.ticket_id,Y,ge.trim()),H(te=>te.map(je=>je.id===Y?{...je,content:ge.trim()}:je)),K(null),Dt.success("Message updated in Discord.")}catch(te){Dt.error(te instanceof Error?te.message:"Failed to edit message.")}},rn=Y=>{const te=Y.target.value;se(te);const je=Y.target.selectionStart||te.length,we=te.slice(0,je),Le=we.lastIndexOf("@");if(Le!==-1&&!we.slice(Le).includes(" ")){const Xe=we.slice(Le+1).toLowerCase();Z(Xe),B(!0)}else B(!1)},It=(Y,te,je)=>{const we=de.lastIndexOf("@"),Le=de.slice(0,we),Xe=je?`<@&${te}>`:`<@${te}>`;se(`${Le}${Xe} `),B(!1)},Jn=Y=>{const te=Math.floor((Date.now()-Y)/1e3);return fg(te)},er=Y=>new Date(Y).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),bt=Y=>{if(!Y)return null;const te=/(```[\s\S]*?```|`[^`]+`|\*\*\*[\s\S]+?\*\*\*|\*\*[\s\S]+?\*\*|__[\s\S]+?__|~~[\s\S]+?~~|\|\|[\s\S]+?\|\||<@!?&?\d+>|^###\s[^\n]+|^##\s[^\n]+|^-#\s[^\n]+|\[[^\]]+\]\(https?:\/\/[^\s)]+\)|https?:\/\/[^\s]+)/gm;return Y.split(te).map((we,Le)=>{var jn;if(!we)return null;if(we.startsWith("-# "))return s.jsx("span",{className:"text-xs text-muted-foreground font-medium block my-0.5 opacity-80",children:bt(we.slice(3))},Le);if(we.startsWith("## "))return s.jsx("span",{className:"text-base font-bold text-foreground block my-1 tracking-tight",children:bt(we.slice(3))},Le);if(we.startsWith("### "))return s.jsx("span",{className:"text-sm font-bold text-foreground block my-0.5",children:bt(we.slice(4))},Le);if(we.startsWith("```")&&we.endsWith("```")&&we.length>=6){const mn=we.slice(3,-3).replace(/^[a-z0-9_-]+\n/i,"");return s.jsx("pre",{className:"bg-black/60 p-2.5 rounded-lg text-xs font-mono my-1.5 border border-border overflow-x-auto text-emerald-400 font-mono",children:s.jsx("code",{children:mn})},Le)}if(we.startsWith("`")&&we.endsWith("`")&&we.length>2)return s.jsx("code",{className:"bg-black/50 px-1.5 py-0.5 rounded text-xs font-mono text-emerald-300 border border-border/40",children:we.slice(1,-1)},Le);if(we.startsWith("***")&&we.endsWith("***")&&we.length>6)return s.jsx("strong",{className:"font-bold italic",children:bt(we.slice(3,-3))},Le);if(we.startsWith("**")&&we.endsWith("**")&&we.length>4)return s.jsx("strong",{className:"font-bold",children:bt(we.slice(2,-2))},Le);if(we.startsWith("__")&&we.endsWith("__")&&we.length>4)return s.jsx("span",{className:"underline underline-offset-2",children:bt(we.slice(2,-2))},Le);if(we.startsWith("~~")&&we.endsWith("~~")&&we.length>4)return s.jsx("span",{className:"line-through opacity-80",children:bt(we.slice(2,-2))},Le);if(we.startsWith("||")&&we.endsWith("||")&&we.length>4)return s.jsx("span",{className:"bg-secondary text-transparent hover:text-foreground hover:bg-secondary/50 px-1.5 py-0.5 rounded transition-all cursor-pointer select-none border border-border/30",title:"Click to reveal spoiler",children:we.slice(2,-2)},Le);const Xe=we.match(/^<@!?(\d+)>$/);if(Xe){const mn=Xe[1],an=new Map;k&&an.set(k.user_id,"Ticket Author"),I.forEach(_r=>{var Xr;(Xr=_r.author)!=null&&Xr.id&&an.set(_r.author.id,_r.author.globalName||_r.author.username)});const tr=an.get(mn);return s.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded font-semibold text-xs bg-primary/20 text-primary mx-0.5",title:`User ID: ${mn}`,children:["@",tr||"User"]},Le)}const vt=we.match(/^<@&(\d+)>$/);if(vt){const mn=vt[1],an=(jn=G==null?void 0:G.roles)==null?void 0:jn.find(tr=>tr.id===mn);return s.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded font-semibold text-xs bg-amber-500/20 text-amber-400 mx-0.5",children:["@",an?an.name:`Role (${mn})`]},Le)}const gt=we.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)$/);if(gt){const mn=gt[1],an=gt[2];return s.jsx("a",{href:an,target:"_blank",rel:"noreferrer",className:"text-primary underline hover:opacity-80 break-all",children:mn},Le)}return/^https?:\/\/[^\s]+$/i.test(we)?/\.(gif|jpe?g|png|webp)(\?[^\s]*)?$/i.test(we)||/cdn\.discordapp\.com\/(emojis|attachments)\//i.test(we)||/images\.discordapp\.net\//i.test(we)||/media\d*\.giphy\.com\//i.test(we)?s.jsx("span",{className:"block my-1",children:s.jsx("img",{src:we,alt:"GIF/Image",className:"max-h-64 rounded-lg border border-border object-contain hover:opacity-95 transition-opacity",loading:"lazy"})},Le):s.jsx("a",{href:we,target:"_blank",rel:"noreferrer",className:"text-primary underline hover:opacity-80 break-all",children:we},Le):we})},Ln=Y=>!Y||Y.length===0?null:s.jsx("div",{className:"space-y-2 mt-1",children:Y.map(te=>{var Xe,vt,gt;const je=((Xe=te.contentType)==null?void 0:Xe.startsWith("image/"))||/\.(png|jpe?g|gif|webp|svg)$/i.test(te.name),we=((vt=te.contentType)==null?void 0:vt.startsWith("video/"))||/\.(mp4|webm|mov|mkv)$/i.test(te.name),Le=((gt=te.contentType)==null?void 0:gt.startsWith("audio/"))||/\.(mp3|wav|ogg|m4a)$/i.test(te.name);return je?s.jsx("div",{className:"rounded-lg overflow-hidden border border-border bg-black/40",children:s.jsx("a",{href:te.url,target:"_blank",rel:"noreferrer",children:s.jsx("img",{src:te.url,alt:te.name,className:"max-h-80 max-w-full object-contain hover:opacity-95 transition-opacity",loading:"lazy"})})},te.id):we?s.jsx("div",{className:"rounded-lg overflow-hidden border border-border bg-black",children:s.jsx("video",{src:te.url,controls:!0,className:"max-h-80 max-w-full"})},te.id):Le?s.jsx("div",{className:"p-2 border border-border rounded-lg bg-secondary/20",children:s.jsx("audio",{src:te.url,controls:!0,className:"w-full h-8"})},te.id):s.jsxs("div",{className:"p-2.5 rounded-lg border border-border bg-secondary/20 flex items-center justify-between text-xs gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 truncate",children:[s.jsx(xe,{icon:Uy,size:16,className:"text-primary shrink-0"}),s.jsx("span",{className:"truncate font-medium",children:te.name})]}),s.jsx(ue,{variant:"ghost",size:"sm",asChild:!0,className:"h-7 px-2 text-xs",children:s.jsx("a",{href:te.url,target:"_blank",rel:"noreferrer",download:!0,children:"Download"})})]},te.id)})}),Di=Y=>!Y||Y.length===0?null:s.jsx("div",{className:"space-y-3 mt-1.5 w-full",children:Y.map((te,je)=>{var we,Le,Xe,vt;return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-secondary/30 p-3.5 text-xs space-y-2 border-l-4 shadow-sm relative overflow-hidden max-w-xl",style:{borderLeftColor:te.color||"#5865F2"},children:[te.author&&s.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-foreground",children:[te.author.iconURL&&s.jsx("img",{src:te.author.iconURL,alt:"",className:"h-4 w-4 rounded-full"}),s.jsx("span",{children:te.author.name})]}),((we=te.thumbnail)==null?void 0:we.url)&&s.jsx("img",{src:te.thumbnail.url,alt:"",className:"h-12 w-12 rounded object-cover absolute top-3 right-3 border border-border"}),te.title&&s.jsx("h4",{className:"font-bold text-sm text-foreground tracking-tight pr-12",children:bt(te.title)}),te.description&&s.jsx("div",{className:"text-muted-foreground whitespace-pre-wrap leading-relaxed pr-12",children:bt(te.description)}),te.fields&&te.fields.length>0&&s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2.5 pt-2 border-t border-border/30",children:te.fields.map((gt,jn)=>s.jsxs("div",{className:`space-y-0.5 ${gt.inline?"":"sm:col-span-2"}`,children:[s.jsx("p",{className:"font-semibold text-foreground text-[11px] uppercase tracking-wider",children:gt.name}),s.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:bt(gt.value)})]},jn))}),((Le=te.image)==null?void 0:Le.url)&&s.jsx("div",{className:"rounded-md overflow-hidden border border-border mt-2",children:s.jsx("img",{src:te.image.url,alt:"",className:"max-h-64 w-full object-cover"})}),(te.footer||te.timestamp)&&s.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-border/20 text-[10px] text-muted-foreground",children:[((Xe=te.footer)==null?void 0:Xe.iconURL)&&s.jsx("img",{src:te.footer.iconURL,alt:"",className:"h-3.5 w-3.5 rounded-full"}),((vt=te.footer)==null?void 0:vt.text)&&s.jsx("span",{children:te.footer.text}),te.timestamp&&s.jsxs("span",{children:[new Date(te.timestamp).toLocaleDateString()," ",new Date(te.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]})]},je)})}),Oi=Y=>{if(!Y||Y.length===0)return null;const te=Y.map(je=>({...je,components:(je.components||[]).filter(we=>we.customId||we.url||we.type===2||we.type===3||we.type==="BUTTON"||we.type==="STRING_SELECT")})).filter(je=>je.components&&je.components.length>0);return te.length===0?null:s.jsx("div",{className:"space-y-2 mt-2.5 w-full",children:te.map((je,we)=>{var Le;return s.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:(Le=je.components)==null?void 0:Le.map((Xe,vt)=>s.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-secondary/80 text-secondary-foreground text-xs font-semibold border border-border/80 shadow-sm hover:bg-secondary transition-colors cursor-pointer",children:[Xe.emoji&&s.jsx("span",{children:Xe.emoji}),s.jsx("span",{children:Xe.label||Xe.customId||"Button"})]},vt))},we)})})},Li=()=>s.jsx(fc,{className:"flex-1 p-4 sm:p-6",children:s.jsxs("div",{className:"max-w-4xl mx-auto w-full space-y-4",children:[q?s.jsxs("div",{className:"space-y-4 p-4",children:[s.jsx(Ue,{className:"h-10 w-3/4"}),s.jsx(Ue,{className:"h-10 w-1/2 ml-auto"}),s.jsx(Ue,{className:"h-10 w-2/3"})]}):I.length===0?s.jsx("div",{className:"p-12 text-center text-muted-foreground text-sm",children:"No recent messages in this ticket channel."}):I.map(Y=>{var te;return s.jsxs("div",{className:`group flex items-start gap-3 ${Y.author.isDashboard?"flex-row-reverse":""}`,children:[s.jsxs(vs,{className:"h-8 w-8 shrink-0",children:[s.jsx(eo,{src:Y.author.avatar,alt:Y.author.username}),s.jsx(ys,{children:s.jsx(xe,{icon:L8,size:16})})]}),s.jsxs("div",{className:`flex flex-col space-y-1 max-w-[80%] ${Y.author.isDashboard?"items-end":"items-start"}`,children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("span",{className:"font-semibold text-foreground",children:Y.author.globalName||Y.author.username}),Y.author.bot&&s.jsx(Fn,{variant:"secondary",className:"px-1 py-0 text-[10px]",children:"BOT"}),Y.author.isDashboard&&s.jsx(Fn,{variant:"default",className:"px-1 py-0 text-[10px]",children:"STAFF"}),s.jsx("span",{children:er(Y.createdAt)}),s.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-1",children:[s.jsx(ue,{variant:"ghost",size:"icon",className:"h-5 w-5 text-muted-foreground hover:text-foreground",onClick:()=>De(Y),title:"Edit Message",children:s.jsx(xe,{icon:D2,size:12})}),s.jsx(ue,{variant:"ghost",size:"icon",className:"h-5 w-5 text-muted-foreground hover:text-destructive",onClick:()=>La(Y.id),title:"Delete Message",children:s.jsx(xe,{icon:bi,size:12})})]})]}),be===Y.id?s.jsxs("div",{className:"flex items-center gap-2 w-full mt-1",children:[s.jsx(_e,{value:ge,onChange:je=>me(je.target.value),className:"h-8 text-sm",autoFocus:!0}),s.jsx(ue,{size:"sm",className:"h-8 px-2 bg-primary",onClick:()=>lt(Y.id),children:s.jsx(xe,{icon:_8,size:14})}),s.jsx(ue,{size:"sm",variant:"ghost",className:"h-8 px-2",onClick:rt,children:s.jsx(xe,{icon:ba,size:14})})]}):Y.content?s.jsx("div",{className:`rounded-lg px-3.5 py-2.5 text-sm whitespace-pre-wrap ${Y.author.isDashboard?"bg-primary text-primary-foreground":"bg-secondary/40 text-secondary-foreground border border-border/50"}`,style:Y.containerColor||Y.author.bot&&!((te=Y.embeds)!=null&&te.length)?{borderLeftWidth:"4px",borderLeftColor:Y.containerColor||"#5865F2"}:void 0,children:bt(Y.content)}):null,Ln(Y.attachments),Di(Y.embeds),Oi(Y.components)]})]},Y.id)}),s.jsx("div",{ref:ho})]})}),zi=()=>{var Y;return s.jsxs("div",{className:"p-4 border-t border-border bg-secondary/10 flex flex-col gap-2 relative",children:[P.length>0&&s.jsx("div",{className:"max-w-4xl mx-auto w-full flex items-center gap-2 flex-wrap mb-1",children:P.map((te,je)=>s.jsxs("div",{className:"flex items-center gap-2 p-1.5 px-3 rounded-lg border border-border bg-secondary text-xs",children:[te.previewUrl?s.jsx("img",{src:te.previewUrl,alt:"",className:"h-6 w-6 rounded object-cover"}):s.jsx(xe,{icon:Uy,size:14,className:"text-primary"}),s.jsx("span",{className:"font-medium max-w-[120px] truncate",children:te.filename}),s.jsxs("span",{className:"text-muted-foreground text-[10px]",children:[te.sizeMb,"MB"]}),s.jsx("button",{type:"button",onClick:()=>Ar(je),className:"text-muted-foreground hover:text-destructive ml-1",children:s.jsx(xe,{icon:ba,size:12})})]},je))}),D&&s.jsxs("div",{className:"max-w-4xl mx-auto w-full absolute bottom-full mb-2 z-50 bg-popover text-popover-foreground border border-border rounded-xl shadow-xl overflow-hidden max-h-48 overflow-y-auto",children:[s.jsx("div",{className:"p-2 text-[11px] font-semibold text-muted-foreground uppercase tracking-wider border-b",children:"Mentions (@)"}),k&&s.jsxs("button",{type:"button",onClick:()=>It("Ticket Author",k.user_id,!1),className:"w-full text-left p-2 hover:bg-secondary flex items-center justify-between text-xs",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(vs,{className:"h-5 w-5",children:s.jsx(ys,{children:"U"})}),s.jsx("span",{className:"font-medium",children:"Ticket Author"})]}),s.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground",children:["@",k.user_id]})]}),(Y=G==null?void 0:G.roles)==null?void 0:Y.filter(te=>te.name.toLowerCase().includes(V)).slice(0,5).map(te=>s.jsxs("button",{type:"button",onClick:()=>It(te.name,te.id,!0),className:"w-full text-left p-2 hover:bg-secondary flex items-center justify-between text-xs",children:[s.jsxs("span",{className:"font-medium text-amber-400",children:["@",te.name]}),s.jsx("span",{className:"text-[10px] font-mono text-muted-foreground",children:"Role"})]},te.id))]}),s.jsxs("form",{onSubmit:Wt,className:"max-w-4xl mx-auto w-full flex items-center gap-2",children:[s.jsx("input",{type:"file",ref:Kr,multiple:!0,onChange:Oa,className:"hidden",accept:"image/*,video/*,audio/*,.pdf,.zip,.txt,.json"}),s.jsx(ue,{type:"button",variant:"outline",size:"sm",onClick:()=>{var te;return(te=Kr.current)==null?void 0:te.click()},title:"Attach files or media",className:"h-9 px-2.5",children:s.jsx(xe,{icon:v8,size:16})}),s.jsx(_e,{value:de,onChange:rn,placeholder:"Type a reply... Use @ to tag roles or users",disabled:oe||q,className:"flex-1"}),s.jsx(ue,{type:"submit",size:"sm",disabled:oe||!de.trim()&&!P.length||q,children:oe?s.jsx(xe,{icon:fr,size:16,className:"animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(xe,{icon:R8,size:16,className:"mr-1.5"}),"Send"]})})]})]})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Open Tickets"}),s.jsx("p",{className:"text-muted-foreground",children:"Manage open support tickets & reply live to Discord channels from the web dashboard."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ue,{onClick:()=>Xn(!0),className:"gap-2 bg-primary font-semibold text-xs h-9",children:[s.jsx(xe,{icon:is,size:15})," Open Ticket"]}),s.jsxs(ue,{onClick:()=>void yt(),disabled:c,variant:"outline",size:"sm",children:[s.jsx(xe,{icon:fr,size:16,className:c?"animate-spin mr-2":"mr-2"}),"Refresh"]})]})]}),s.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-3 bg-card/60 p-3.5 rounded-xl border border-border/80 shadow-sm",children:[s.jsxs("div",{className:"relative w-full md:w-80",children:[s.jsx(xe,{icon:vi,size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx(_e,{placeholder:"Search tickets by ID, user, subject...",value:N,onChange:Y=>E(Y.target.value),className:"pl-9 text-xs h-9 bg-secondary/30 border-border"})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 w-full md:w-auto justify-end",children:[p&&s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Department:"}),s.jsxs(Ca,{value:w,onValueChange:y,children:[s.jsx(Hr,{className:"text-xs h-9 w-[160px] bg-secondary/30 border-border capitalize",children:s.jsx(Sa,{placeholder:"All Departments"})}),s.jsxs(Gr,{children:[s.jsx(Et,{value:"all",children:"All Departments"}),T.map(Y=>s.jsx(Et,{value:Y,className:"capitalize",children:Y},Y))]})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Priority:"}),s.jsxs(Ca,{value:C,onValueChange:S,children:[s.jsx(Hr,{className:"text-xs h-9 w-[140px] bg-secondary/30 border-border capitalize",children:s.jsx(Sa,{placeholder:"All Priorities"})}),s.jsxs(Gr,{children:[s.jsx(Et,{value:"all",children:"All Priorities"}),s.jsx(Et,{value:"low",children:"Low"}),s.jsx(Et,{value:"medium",children:"Medium / Normal"}),s.jsx(Et,{value:"high",children:"High"}),s.jsx(Et,{value:"urgent",children:"Urgent"})]})]})]}),(w!=="all"||C!=="all"||N.trim())&&s.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>{y("all"),S("all"),E("")},className:"h-9 text-xs text-muted-foreground hover:text-foreground px-2",children:"Reset"})]})]}),s.jsx(Je,{className:"border-border bg-card",children:s.jsx(et,{className:"p-0",children:c?s.jsxs("div",{className:"space-y-4 p-6",children:[s.jsx(Ue,{className:"h-12 w-full"}),s.jsx(Ue,{className:"h-12 w-full"}),s.jsx(Ue,{className:"h-12 w-full"})]}):d?s.jsx("div",{className:"p-6",children:s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:d})})}):M.length===0?s.jsxs("div",{className:"p-12 text-center text-muted-foreground space-y-2",children:[s.jsx("p",{children:"No open tickets found matching your filter criteria."}),(w!=="all"||C!=="all"||N.trim())&&s.jsx(ue,{variant:"outline",size:"sm",onClick:()=>{y("all"),S("all"),E("")},className:"text-xs mt-2",children:"Clear Filters"})]}):s.jsx("div",{className:"divide-y divide-border",children:M.map(Y=>s.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between p-4 hover:bg-secondary/10 transition-colors gap-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("p",{className:"font-medium text-primary",children:Y.subject||"Untitled Ticket"}),s.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:["#",Y.ticket_id]}),p&&Y.department&&s.jsx(Fn,{variant:"outline",className:"text-xs capitalize",children:Y.department}),s.jsxs(Fn,{variant:Y.priority==="high"?"destructive":Y.priority==="medium"?"secondary":"outline",className:"text-xs capitalize",children:[Y.priority," priority"]})]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["User ID: ",s.jsx("span",{className:"font-mono",children:Y.user_id}),Y.description&&` • ${Y.description}`]})]}),s.jsxs("div",{className:"flex items-center gap-3 w-full sm:w-auto justify-end",children:[s.jsxs("div",{className:"text-sm text-muted-foreground flex items-center whitespace-nowrap mr-2",children:[s.jsx(xe,{icon:h8,size:14,className:"mr-1.5"}),Jn(Y.created_at)]}),s.jsxs(ue,{variant:"default",size:"sm",onClick:()=>Wr(Y),className:"bg-primary text-primary-foreground hover:bg-primary/90",children:[s.jsx(xe,{icon:g8,size:16,className:"mr-2"}),"Live Chat"]}),s.jsxs(ue,{variant:"destructive",size:"sm",onClick:()=>Es(Y),disabled:We===Y.ticket_id,children:[We===Y.ticket_id?s.jsx(xe,{icon:fr,size:14,className:"animate-spin mr-1.5"}):s.jsx(xe,{icon:ba,size:14,className:"mr-1.5"}),"Close"]}),a&&s.jsx(ue,{variant:"secondary",size:"sm",asChild:!0,children:s.jsx("a",{href:`https://discord.com/channels/${a}/${Y.ticket_id}`,target:"_blank",rel:"noreferrer",children:s.jsx(xe,{icon:Nd,size:16})})})]})]},Y.ticket_id))})})}),R&&ne&&s.jsx("div",{className:"fixed inset-0 z-50 bg-black/65 backdrop-blur-sm flex items-center justify-center p-4 sm:p-6 lg:p-8 animate-in fade-in-0",onClick:Y=>{Y.target===Y.currentTarget&&X(!1)},children:s.jsxs("div",{className:"bg-card text-card-foreground border border-border rounded-2xl shadow-2xl flex flex-col w-full max-w-5xl h-[88vh] overflow-hidden animate-in zoom-in-95",children:[s.jsxs("div",{className:"p-4 border-b border-border bg-secondary/20 flex flex-col space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap min-w-0",children:[s.jsx("h2",{className:"text-lg font-bold tracking-tight truncate",children:(k==null?void 0:k.subject)||"Ticket Live Chat"}),s.jsxs(Fn,{variant:"outline",className:"font-mono text-xs shrink-0",children:["#",k==null?void 0:k.ticket_id]}),p&&(k==null?void 0:k.department)&&s.jsx(Fn,{variant:"secondary",className:"text-xs capitalize shrink-0",children:k.department})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[k&&s.jsxs(ue,{variant:"destructive",size:"sm",onClick:()=>Es(k),disabled:We===k.ticket_id,className:"h-8 px-2.5 text-xs",children:[We===k.ticket_id?s.jsx(xe,{icon:fr,size:14,className:"animate-spin mr-1.5"}):s.jsx(xe,{icon:ba,size:14,className:"mr-1.5"}),"Close Ticket"]}),s.jsxs(ue,{variant:"outline",size:"sm",onClick:()=>X(!1),className:"h-8 px-3 text-xs flex items-center gap-1.5",children:[s.jsx(xe,{icon:S8,size:14}),s.jsx("span",{children:"Collapse"})]}),s.jsx(ue,{variant:"ghost",size:"icon",onClick:()=>{L(!1),X(!1)},className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:s.jsx(xe,{icon:ba,size:18})})]})]}),(k==null?void 0:k.description)&&s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:k.description})]}),Li(),zi()]})}),R&&!ne&&s.jsx(Yj,{open:R,onOpenChange:L,children:s.jsxs(Hg,{side:"right",className:"w-full sm:max-w-xl p-0 flex flex-col h-full bg-card",children:[s.jsxs(Gg,{className:"p-4 border-b border-border space-y-1 bg-secondary/20",children:[s.jsxs("div",{className:"flex items-center justify-between pr-8",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap min-w-0",children:[s.jsx(Vg,{className:"text-base font-bold truncate",children:(k==null?void 0:k.subject)||"Ticket Live Chat"}),s.jsxs(Fn,{variant:"outline",className:"font-mono text-xs shrink-0",children:["#",k==null?void 0:k.ticket_id]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[k&&s.jsxs(ue,{variant:"destructive",size:"sm",onClick:()=>Es(k),disabled:We===k.ticket_id,className:"h-7 px-2 text-xs",children:[We===k.ticket_id?s.jsx(xe,{icon:fr,size:13,className:"animate-spin mr-1"}):s.jsx(xe,{icon:ba,size:13,className:"mr-1"}),"Close"]}),s.jsxs(ue,{variant:"outline",size:"sm",onClick:()=>X(!0),className:"h-7 px-2 text-xs flex items-center gap-1",title:"Open in Full View",children:[s.jsx(xe,{icon:C8,size:13}),s.jsx("span",{children:"Full View"})]})]})]}),(k==null?void 0:k.description)&&s.jsx(Fg,{className:"text-xs text-muted-foreground truncate",children:k.description})]}),Li(),zi()]})}),s.jsx(Qs,{open:$,onOpenChange:ie,children:s.jsxs(hs,{className:"sm:max-w-md bg-card border-border rounded-xl",children:[s.jsxs(gs,{children:[s.jsxs(xs,{className:"text-lg font-bold flex items-center gap-2",children:[s.jsx(xe,{icon:ba,className:"text-destructive",size:20}),"Close Ticket #",ye==null?void 0:ye.ticket_id]}),s.jsx(bs,{className:"text-xs text-muted-foreground pt-1",children:"Are you sure you want to close this ticket? A transcript will be created and the channel will be deleted in Discord."})]}),s.jsxs("div",{className:"space-y-2 py-2",children:[s.jsx("label",{className:"text-xs font-semibold text-foreground",children:"Reason for closing (Optional)"}),s.jsx(_e,{value:Be,onChange:Y=>Ke(Y.target.value),placeholder:"e.g. Issue resolved by support team",className:"text-sm"})]}),s.jsxs(Js,{className:"gap-2 sm:gap-0 mt-2",children:[s.jsx(ue,{variant:"outline",size:"sm",onClick:()=>ie(!1),disabled:!!We,children:"Cancel"}),s.jsxs(ue,{variant:"destructive",size:"sm",onClick:qr,disabled:!!We,children:[We?s.jsx(xe,{icon:fr,size:14,className:"animate-spin mr-1.5"}):s.jsx(xe,{icon:ba,size:14,className:"mr-1.5"}),"Confirm Close"]})]})]})}),s.jsx(Qs,{open:vn,onOpenChange:Xn,children:s.jsxs(hs,{className:"sm:max-w-[450px]",children:[s.jsxs(gs,{children:[s.jsxs(xs,{className:"text-base flex items-center gap-2",children:[s.jsx(xe,{icon:is,size:18,className:"text-primary"}),"Open Direct Ticket"]}),s.jsx(bs,{className:"text-xs",children:p?"Select a support department to create a new ticket channel in Discord immediately.":"Create a new ticket channel in Discord immediately."})]}),s.jsxs("div",{className:"space-y-4 py-2",children:[p&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Ae,{className:"text-xs font-semibold",children:"Department"}),s.jsxs(Ca,{value:br,onValueChange:yn,children:[s.jsx(Hr,{className:"text-xs border-border bg-secondary/30",children:s.jsx(Sa,{})}),s.jsx(Gr,{children:(b.length>0?b:[{id:"general",name:"General Support",emoji:"🎫"},{id:"purchase",name:"Purchase & Billing Support",emoji:"💳"},{id:"reports",name:"Player Report",emoji:"🚨"},{id:"appeals",name:"Ban Appeals",emoji:"⚖️"}]).map(Y=>s.jsxs(Et,{value:Y.id,children:[Y.emoji?`${Y.emoji} `:"",Y.name]},Y.id))})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Ae,{className:"text-xs font-semibold",children:"Ticket Subject / Reason"}),s.jsx(_e,{value:wn,onChange:Y=>Zn(Y.target.value),placeholder:"e.g. Assistance with server permissions",className:"text-xs border-border bg-secondary/30"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Ae,{className:"text-xs font-semibold",children:"Discord User ID (Optional)"}),s.jsx(_e,{value:Kt,onChange:Y=>po(Y.target.value),placeholder:"e.g. 123456789012345678 (Leave blank for yourself)",className:"text-xs font-mono border-border bg-secondary/30"}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"If specified, the ticket channel will be created for this user."})]})]}),s.jsxs(Js,{className:"gap-2 sm:gap-0",children:[s.jsx(ue,{variant:"outline",size:"sm",onClick:()=>Xn(!1),disabled:Pt,className:"text-xs",children:"Cancel"}),s.jsxs(ue,{size:"sm",onClick:Da,disabled:Pt||!wn.trim(),className:"gap-1.5 text-xs bg-primary font-semibold",children:[Pt?s.jsx(xe,{icon:fr,size:14,className:"animate-spin"}):s.jsx(xe,{icon:is,size:14}),Pt?"Opening Ticket...":"Open Ticket"]})]})]})})]})}const SP=["admin","moderator","editor","viewer","custom"];function NP(){return{mode:"add",id:"",username:"",globalName:"",role:"viewer",enabled:!0,permissions:ls("viewer"),yamlOwner:!1}}function EP({permissions:t,onChange:n,disabled:a}){const o=d=>n({...t,...d}),c=[{key:"overview",title:"Dashboard Overview",description:"Access to system metrics, bot health status, and main dashboard stats."},{key:"tickets",title:"Support Tickets",description:"View open support tickets, live web chat, send staff replies, and close tickets."},{key:"transcripts",title:"Ticket Transcripts",description:"Access saved ticket HTML transcripts and configure public transcript options."},{key:"logs",title:"Console Terminal Logs",description:"View real-time bot terminal output, system logs, and runtime error traces."}],l=[["supportbot","Bot config","Main bot token, prefix, channels, categories, and core settings."],["ticket-panel","Ticket panel","Ticket home embed, button labels, dropdown options, and panel styling."],["commands","Commands","Enable/disable slash commands, descriptions, and custom names."],["messages","Messages","Custom bot response messages, welcome embeds, and embed colors."],["supportbot-ai","AI assistant","Configure AI support rules, model API keys, and auto-response channels."]];return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"General & Modules Access"}),s.jsx("div",{className:"grid gap-2.5",children:c.map(({key:d,title:m,description:p})=>s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:m}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:p})]}),s.jsx(Mt,{checked:t[d]??(d==="tickets"?t.overview:!1),disabled:a,onCheckedChange:g=>o({[d]:g}),className:"shrink-0"})]},d))})]}),s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Administration & Settings"}),s.jsxs("div",{className:"grid gap-2.5",children:[s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Settings (View)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"View system branding, OAuth configurations, and system health details."})]}),s.jsx(Mt,{checked:t.settings.view,disabled:a,onCheckedChange:d=>o({settings:{...t.settings,view:d}}),className:"shrink-0"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Settings (Install Updates)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"Perform 1-click bot system updates and trigger bot server restarts."})]}),s.jsx(Mt,{checked:t.settings.update,disabled:a,onCheckedChange:d=>o({settings:{...t.settings,update:d}}),className:"shrink-0"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Users & Groups (View)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"View dashboard staff accounts and permission group listings."})]}),s.jsx(Mt,{checked:t.users.view,disabled:a,onCheckedChange:d=>o({users:{...t.users,view:d}}),className:"shrink-0"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Users & Groups (Manage)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"Create, edit, assign, and delete staff accounts and permission groups."})]}),s.jsx(Mt,{checked:t.users.manage,disabled:a,onCheckedChange:d=>o({users:{...t.users,manage:d}}),className:"shrink-0"})]})]})]}),s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Configuration Files Access"}),s.jsxs("div",{className:"grid gap-2.5",children:[l.map(([d,m,p])=>{var b;const g=((b=t.configs)==null?void 0:b[d])??{view:!1,edit:!1};return s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:m}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:p})]}),s.jsxs("div",{className:"flex items-center gap-4 shrink-0",children:[s.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground cursor-pointer",children:[s.jsx("span",{children:"View"}),s.jsx(Mt,{checked:g.view,disabled:a,onCheckedChange:v=>o({configs:{...t.configs,[d]:{...g,view:v}}})})]}),s.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground cursor-pointer",children:[s.jsx("span",{children:"Edit"}),s.jsx(Mt,{checked:g.edit,disabled:a,onCheckedChange:v=>o({configs:{...t.configs,[d]:{...g,edit:v,view:v?!0:g.view}}})})]})]})]},d)}),s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Raw YAML Code Editor"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"Access the raw YAML code editor tab to view or edit full raw configuration files."})]}),s.jsx("div",{className:"flex items-center gap-4 shrink-0",children:s.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground cursor-pointer",children:[s.jsx("span",{children:"Access"}),s.jsx(Mt,{checked:t.rawYaml??!1,disabled:a,onCheckedChange:d=>o({rawYaml:d})})]})})]})]})]})]})}function kP(t){return t.permissions.users.manage?"Full + user management":t.permissions.settings.update?"Configs + settings updates":Object.values(t.permissions.configs).some(n=>n.edit)?"Can edit configs":"View only"}function TP(){const{user:t,hasPermission:n}=Yt(),a=n("users.manage"),[o,c]=f.useState([]),[l,d]=f.useState([]),[m,p]=f.useState(!0),[g,b]=f.useState(""),[v,w]=f.useState(null),[y,C]=f.useState(!1),S=f.useCallback(async()=>{p(!0),b("");try{const[R,L]=await Promise.all([Ne.listDashboardUsers(),Ne.listGroups().catch(()=>({data:{groups:[]}}))]);R.data&&c(R.data.users),L.data&&d(L.data.groups)}catch(R){b(R instanceof Error?R.message:"Failed to load users")}finally{p(!1)}},[]);f.useEffect(()=>{S()},[S]);const N=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 E(){w(NP())}function T(R){w({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:ls(R.role),yamlOwner:R.yamlOwner})}function M(R){v&&w({...v,role:R,permissions:ls(R,v.permissions)})}async function k(){if(!(!v||!a)){C(!0),b("");try{v.mode==="add"?await Ne.addDashboardUser({id:v.id.trim(),role:v.role,username:v.username||void 0,globalName:v.globalName||void 0,enabled:v.enabled,permissions:v.role==="custom"?v.permissions:void 0}):await Ne.updateDashboardUser(v.id,{role:v.yamlOwner?void 0:v.role,enabled:v.enabled,username:v.username||void 0,globalName:v.globalName||void 0,permissions:v.role==="custom"?v.permissions:void 0}),w(null),await S()}catch(R){b(R instanceof Error?R.message:"Could not save user")}finally{C(!1)}}}async function _(R){if(a&&window.confirm("Remove this user from the dashboard?")){b("");try{await Ne.removeDashboardUser(R),await S()}catch(L){b(L instanceof Error?L.message:"Could not remove user")}}}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Users"}),s.jsxs("p",{className:"text-muted-foreground",children:["Control who can sign in and what they can view or edit. Owners in"," ",s.jsx("code",{className:"rounded bg-primary/10 px-1 text-xs text-primary",children:"api.yml"})," ","always have full access."]})]}),a?s.jsxs(ue,{onClick:E,children:[s.jsx(xe,{icon:sg,size:16,className:"mr-2"}),"Add user"]}):null]}),g?s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:g})}):null,s.jsx(Je,{className:"border-border bg-card overflow-hidden",children:s.jsx(et,{className:"p-0",children:m?s.jsxs("div",{className:"p-4 space-y-2",children:[s.jsx(Ue,{className:"h-8 w-full rounded-md"}),s.jsx(Ue,{className:"h-8 w-full rounded-md"})]}):N.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-muted-foreground",children:"No users found."}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-left text-xs",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/80 bg-secondary/30 text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:[s.jsx("th",{className:"px-4 py-2.5",children:"User"}),s.jsx("th",{className:"px-4 py-2.5",children:"Group"}),s.jsx("th",{className:"px-4 py-2.5",children:"Access Summary"}),s.jsx("th",{className:"px-4 py-2.5",children:"Status"}),a&&s.jsx("th",{className:"px-4 py-2.5 text-right",children:"Actions"})]})}),s.jsx("tbody",{className:"divide-y divide-border/40",children:N.map(R=>{const L=l.find(I=>I.id===R.groupId||I.id===R.role),ne=(L==null?void 0:L.color)||"#10B981",X=(L==null?void 0:L.name)||$y[R.yamlOwner?"owner":R.role]||R.role;return s.jsxs("tr",{className:"transition-colors hover:bg-secondary/25",children:[s.jsx("td",{className:"px-4 py-2.5 font-medium whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsxs(vs,{className:"size-7",children:[s.jsx(eo,{src:R.avatar,alt:R.username}),s.jsx(ys,{className:"text-[10px]",children:(R.username||R.id).slice(0,2).toUpperCase()})]}),s.jsxs("div",{className:"min-w-0 leading-tight",children:[s.jsxs("p",{className:"truncate font-semibold text-foreground text-xs",children:[P2(R),R.id===(t==null?void 0:t.id)?s.jsx("span",{className:"text-[11px] text-primary font-normal ml-1",children:"(you)"}):""]}),s.jsx("p",{className:"truncate text-[10px] text-muted-foreground font-mono",children:R.id})]})]})}),s.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"size-2 rounded-full shrink-0 shadow-sm",style:{backgroundColor:ne}}),s.jsx("span",{className:"font-medium text-xs text-foreground",children:X}),R.yamlOwner&&s.jsx("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded bg-primary/10 text-primary border border-primary/20",children:"Config Owner"})]})}),s.jsx("td",{className:"px-4 py-2.5 text-xs text-muted-foreground max-w-xs truncate",children:kP(R)}),s.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:R.enabled?s.jsx(Fn,{className:"text-[10px] px-2 py-0.5 bg-emerald-500/15 text-emerald-400 hover:bg-emerald-500/15 border-emerald-500/20",children:"Active"}):s.jsx(Fn,{variant:"outline",className:"text-[10px] px-2 py-0.5",children:"Disabled"})}),a&&s.jsx("td",{className:"px-4 py-2.5 text-right whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsxs(ue,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs gap-1 text-muted-foreground hover:text-foreground",onClick:()=>T(R),children:[s.jsx(xe,{icon:b8,size:13}),"Edit"]}),!R.yamlOwner&&s.jsxs(ue,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs gap-1 text-muted-foreground hover:text-destructive",onClick:()=>_(R.id),children:[s.jsx(xe,{icon:bi,size:13}),"Remove"]})]})})]},R.id)})})]})})})}),s.jsx(Qs,{open:!!v,onOpenChange:R=>!R&&w(null),children:s.jsxs(hs,{className:"max-h-[90vh] max-w-lg overflow-y-auto",children:[s.jsxs(gs,{children:[s.jsx(xs,{children:(v==null?void 0:v.mode)==="add"?"Add dashboard user":"Edit user"}),s.jsx(bs,{children:v!=null&&v.yamlOwner?"This user is an owner in api.yml. Role and removal are managed in the config file.":P8[(v==null?void 0:v.role)??"viewer"]})]}),v?s.jsxs("div",{className:"space-y-4",children:[v.mode==="add"?s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"discord-id",children:"Discord user ID"}),s.jsx(_e,{id:"discord-id",value:v.id,onChange:R=>w({...v,id:R.target.value}),placeholder:"829112572816130058"})]}):null,s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{children:"Display name (optional)"}),s.jsx(_e,{value:v.globalName,onChange:R=>w({...v,globalName:R.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{children:"Username (optional)"}),s.jsx(_e,{value:v.username,onChange:R=>w({...v,username:R.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{children:"Permission Group"}),s.jsxs(Ca,{value:v.role,disabled:v.yamlOwner,onValueChange:R=>{const L=l.find(ne=>ne.id===R);L?w({...v,role:R,permissions:L.permissions}):M(R)},children:[s.jsx(Hr,{children:s.jsx(Sa,{})}),s.jsx(Gr,{children:v.yamlOwner?s.jsx(Et,{value:"owner",children:"Owner"}):l.length>0?l.map(R=>s.jsx(Et,{value:R.id,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"size-2.5 rounded-full shrink-0",style:{backgroundColor:R.color||"#10B981"}}),s.jsx("span",{children:R.name})]})},R.id)):SP.map(R=>s.jsx(Et,{value:R,children:$y[R]},R))})]})]}),s.jsxs("label",{className:"flex items-center justify-between rounded-lg border border-border px-3 py-2",children:[s.jsx("span",{className:"text-sm",children:"Account enabled"}),s.jsx(Mt,{checked:v.enabled,disabled:v.yamlOwner,onCheckedChange:R=>w({...v,enabled:R})})]}),v.role==="custom"&&!v.yamlOwner?s.jsx(EP,{permissions:v.permissions,onChange:R=>w({...v,permissions:R})}):null]}):null,s.jsxs(Js,{children:[s.jsx(ue,{variant:"outline",onClick:()=>w(null),children:"Cancel"}),s.jsx(ue,{disabled:y||!a||(v==null?void 0:v.mode)==="add"&&!/^\d{17,20}$/.test(v.id.trim()),onClick:()=>void k(),children:y?"Saving…":"Save"})]})]})})]})}const MP=[{name:"Emerald",hex:"#10B981"},{name:"Blue",hex:"#3B82F6"},{name:"Purple",hex:"#8B5CF6"},{name:"Amber",hex:"#F59E0B"},{name:"Red",hex:"#EF4444"},{name:"Cyan",hex:"#06B6D4"},{name:"Gray",hex:"#6B7280"}];function RP({permissions:t,onChange:n,disabled:a}){const o=d=>n({...t,...d}),c=[{key:"overview",title:"Dashboard Overview",description:"Access to system metrics, bot health status, and main dashboard stats."},{key:"tickets",title:"Support Tickets",description:"View open support tickets, live web chat, send staff replies, and close tickets."},{key:"transcripts",title:"Ticket Transcripts",description:"Access saved ticket HTML transcripts and configure public transcript options."},{key:"logs",title:"Console Terminal Logs",description:"View real-time bot terminal output, system logs, and runtime error traces."}],l=[["supportbot","Bot config","Main bot token, prefix, channels, categories, and core settings."],["ticket-panel","Ticket panel","Ticket home embed, button labels, dropdown options, and panel styling."],["commands","Commands","Enable/disable slash commands, descriptions, and custom names."],["messages","Messages","Custom bot response messages, welcome embeds, and embed colors."],["supportbot-ai","AI assistant","Configure AI support rules, model API keys, and auto-response channels."]];return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"General & Modules Access"}),s.jsx("div",{className:"grid gap-2.5",children:c.map(({key:d,title:m,description:p})=>s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:m}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:p})]}),s.jsx(Mt,{checked:t[d]??(d==="tickets"?t.overview:!1),disabled:a,onCheckedChange:g=>o({[d]:g}),className:"shrink-0"})]},d))})]}),s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Administration & Settings"}),s.jsxs("div",{className:"grid gap-2.5",children:[s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Settings (View)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"View system branding, OAuth configurations, and system health details."})]}),s.jsx(Mt,{checked:t.settings.view,disabled:a,onCheckedChange:d=>o({settings:{...t.settings,view:d}}),className:"shrink-0"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Settings (Install Updates)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"Perform 1-click bot system updates and trigger bot server restarts."})]}),s.jsx(Mt,{checked:t.settings.update,disabled:a,onCheckedChange:d=>o({settings:{...t.settings,update:d}}),className:"shrink-0"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Users & Groups (View)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"View dashboard staff accounts and permission group listings."})]}),s.jsx(Mt,{checked:t.users.view,disabled:a,onCheckedChange:d=>o({users:{...t.users,view:d}}),className:"shrink-0"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-4 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Users & Groups (Manage)"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"Create, edit, assign, and delete staff accounts and permission groups."})]}),s.jsx(Mt,{checked:t.users.manage,disabled:a,onCheckedChange:d=>o({users:{...t.users,manage:d}}),className:"shrink-0"})]})]})]}),s.jsxs("div",{className:"space-y-2.5",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Configuration Files Access"}),s.jsxs("div",{className:"grid gap-2.5",children:[l.map(([d,m,p])=>{var b;const g=((b=t.configs)==null?void 0:b[d])??{view:!1,edit:!1};return s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:m}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:p})]}),s.jsxs("div",{className:"flex items-center gap-4 shrink-0",children:[s.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground cursor-pointer",children:[s.jsx("span",{children:"View"}),s.jsx(Mt,{checked:g.view,disabled:a,onCheckedChange:v=>o({configs:{...t.configs,[d]:{...g,view:v}}})})]}),s.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground cursor-pointer",children:[s.jsx("span",{children:"Edit"}),s.jsx(Mt,{checked:g.edit,disabled:a,onCheckedChange:v=>o({configs:{...t.configs,[d]:{...g,edit:v,view:v?!0:g.view}}})})]})]})]},d)}),s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 rounded-xl border border-border bg-secondary/20 p-3 transition-colors hover:bg-secondary/40",children:[s.jsxs("div",{className:"space-y-0.5 min-w-0",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Raw YAML Code Editor"}),s.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:"Access the raw YAML code editor tab to view or edit full raw configuration files."})]}),s.jsx("div",{className:"flex items-center gap-4 shrink-0",children:s.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground cursor-pointer",children:[s.jsx("span",{children:"Access"}),s.jsx(Mt,{checked:t.rawYaml??!1,disabled:a,onCheckedChange:d=>o({rawYaml:d})})]})})]})]})]})]})}function AP(){const{permissions:t,impersonateGroup:n,impersonatedGroup:a,stopImpersonation:o}=Yt(),c=Rn(t,"users.manage"),[l,d]=f.useState([]),[m,p]=f.useState(!0),[g,b]=f.useState(null),[v,w]=f.useState(null),[y,C]=f.useState(!1),[S,N]=f.useState("add"),[E,T]=f.useState(!1),[M,k]=f.useState(""),[_,R]=f.useState(""),[L,ne]=f.useState(""),[X,I]=f.useState("#10B981"),[H,q]=f.useState(""),[ce,de]=f.useState(ls("viewer")),se=async()=>{var G;p(!0),b(null);try{const O=await Ne.listGroups();d(((G=O.data)==null?void 0:G.groups)||[])}catch(O){b(O instanceof Error?O.message:"Failed to load groups")}finally{p(!1)}};f.useEffect(()=>{se()},[]);const P=()=>{N("add"),k(""),R(""),ne(""),I("#10B981"),q(""),de(ls("viewer")),C(!0)},W=G=>{N("edit"),k(G.id),R(G.name),ne(G.description||""),I(G.color||"#10B981"),q(G.discordRoleId||""),de(G.permissions||ls("viewer")),C(!0)},oe=async()=>{if(!_.trim()){b("Group name is required");return}T(!0),b(null);try{S==="add"?(await Ne.createGroup({name:_.trim(),description:L.trim(),color:X,discordRoleId:H.trim()||null,permissions:ce}),w(`Group "${_}" created successfully.`)):(await Ne.updateGroup(M,{name:_.trim(),description:L.trim(),color:X,discordRoleId:H.trim()||null,permissions:ce}),w(`Group "${_}" updated successfully.`)),C(!1),await se()}catch(G){b(G instanceof Error?G.message:"Failed to save group")}finally{T(!1)}},ae=async G=>{if(!G.isSystem&&confirm(`Are you sure you want to delete the group "${G.name}"?`))try{await Ne.deleteGroup(G.id),w(`Group "${G.name}" deleted.`),await se()}catch(O){b(O instanceof Error?O.message:"Failed to delete group")}};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Permission Groups"}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Create custom permission groups, assign staff members, and optionally sync with Discord Role IDs."})]}),c&&s.jsxs(ue,{onClick:P,className:"shrink-0 gap-2 bg-primary",children:[s.jsx(xe,{icon:sg,size:18}),"Create Group"]})]}),g&&s.jsx(Ye,{variant:"destructive",children:s.jsx(qe,{children:g})}),v&&s.jsx(Ye,{className:"border-emerald-500/30 bg-emerald-500/10 text-emerald-500",children:s.jsxs(qe,{className:"flex items-center justify-between",children:[s.jsx("span",{children:v}),s.jsx(ue,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:()=>w(null),children:"Dismiss"})]})}),s.jsx(Je,{className:"border-border bg-card overflow-hidden",children:s.jsx(et,{className:"p-0",children:m?s.jsxs("div",{className:"p-4 space-y-2",children:[s.jsx(Ue,{className:"h-8 w-full rounded-md"}),s.jsx(Ue,{className:"h-8 w-full rounded-md"})]}):l.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-muted-foreground",children:'No permission groups found. Click "Create Group" to add one.'}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-left text-xs",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/80 bg-secondary/30 text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:[s.jsx("th",{className:"px-4 py-2.5",children:"Group"}),s.jsx("th",{className:"px-4 py-2.5",children:"Description"}),s.jsx("th",{className:"px-4 py-2.5",children:"Discord Role ID"}),s.jsx("th",{className:"px-4 py-2.5",children:"Enabled Permissions"}),s.jsx("th",{className:"px-4 py-2.5 text-right",children:"Actions"})]})}),s.jsx("tbody",{className:"divide-y divide-border/40",children:l.map(G=>{var O,D,B,V,Z,be,K;return s.jsxs("tr",{className:"transition-colors hover:bg-secondary/25",children:[s.jsx("td",{className:"px-4 py-2.5 font-medium whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"size-2.5 rounded-full shrink-0 shadow-sm",style:{backgroundColor:G.color||"#10B981"}}),s.jsx("span",{className:"text-foreground font-semibold text-xs",children:G.name}),G.isSystem&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold px-1.5 py-0.5 rounded-full bg-secondary text-secondary-foreground border border-border/80",children:[s.jsx(xe,{icon:qu,size:10}),"System"]})]})}),s.jsx("td",{className:"px-4 py-2.5 text-xs text-muted-foreground max-w-xs truncate",children:G.description||"—"}),s.jsx("td",{className:"px-4 py-2.5 whitespace-nowrap",children:G.discordRoleId?s.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground font-mono bg-secondary/50 px-2 py-0.5 rounded border border-border/50",children:[s.jsx(xe,{icon:qu,size:12,className:"text-primary"}),G.discordRoleId]}):s.jsx("span",{className:"text-xs text-muted-foreground/60",children:"—"})}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsxs("div",{className:"flex flex-wrap gap-1 max-w-md",children:[((O=G.permissions)==null?void 0:O.overview)&&s.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-primary/10 text-primary border border-primary/20",children:"Overview"}),(((D=G.permissions)==null?void 0:D.tickets)??((B=G.permissions)==null?void 0:B.overview))&&s.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:"Tickets"}),((V=G.permissions)==null?void 0:V.transcripts)&&s.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-purple-500/10 text-purple-400 border border-purple-500/20",children:"Transcripts"}),((Z=G.permissions)==null?void 0:Z.logs)&&s.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400 border border-blue-500/20",children:"Logs"}),((K=(be=G.permissions)==null?void 0:be.users)==null?void 0:K.manage)&&s.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"User Mgmt"})]})}),s.jsx("td",{className:"px-4 py-2.5 text-right whitespace-nowrap",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsxs(ue,{size:"sm",variant:"ghost",className:`h-7 px-2 text-xs gap-1 ${(a==null?void 0:a.id)===G.id?"text-amber-400 font-bold bg-amber-500/15 border border-amber-500/30":"text-amber-400 hover:text-amber-300 hover:bg-amber-500/10"}`,onClick:()=>(a==null?void 0:a.id)===G.id?o():n(G.id),children:[s.jsx(xe,{icon:qu,size:13}),(a==null?void 0:a.id)===G.id?"Active Preview":"View as Group"]}),c&&G.id!=="owner"&&s.jsxs(ue,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs gap-1 text-muted-foreground hover:text-foreground",onClick:()=>W(G),children:[s.jsx(xe,{icon:D2,size:13}),"Edit"]}),c&&!G.isSystem&&s.jsxs(ue,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs gap-1 text-muted-foreground hover:text-destructive",onClick:()=>ae(G),children:[s.jsx(xe,{icon:bi,size:13}),"Delete"]})]})})]},G.id)})})]})})})}),s.jsx(Qs,{open:y,onOpenChange:C,children:s.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsxs(gs,{children:[s.jsx(xs,{children:S==="add"?"Create Permission Group":`Edit Group: ${_}`}),s.jsx(bs,{children:"Configure group metadata, custom color badge, Discord role sync, and permission rules."})]}),s.jsxs("div",{className:"space-y-4 py-2",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"group-name",children:"Group Name"}),s.jsx(_e,{id:"group-name",placeholder:"e.g. Support Staff",value:_,onChange:G=>R(G.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"group-color",children:"Color Badge"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(tf,{value:X,onChange:I}),s.jsx(_e,{value:X,onChange:G=>I(G.target.value),placeholder:"#10B981",className:"w-28 font-mono text-sm uppercase"}),s.jsx("div",{className:"flex flex-wrap gap-1 ml-auto",children:MP.map(G=>s.jsx("button",{type:"button",className:"size-6 rounded-full border border-white/20 transition-transform hover:scale-110",style:{backgroundColor:G.hex},onClick:()=>I(G.hex),title:G.name},G.hex))})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ae,{htmlFor:"group-desc",children:"Description"}),s.jsx(_e,{id:"group-desc",placeholder:"Brief description of what members in this group can access...",value:L,onChange:G=>ne(G.target.value)})]}),s.jsx(TS,{id:"discord-role-id",label:"Discord Role ID (Optional Auto-Sync)",description:"If provided, Discord users with this Role ID will automatically inherit this group upon login.",kind:"role",value:H,onChange:G=>q(String(G??""))}),s.jsxs("div",{className:"pt-2",children:[s.jsx("h4",{className:"text-sm font-semibold mb-3",children:"Group Permission Matrix"}),s.jsx(RP,{permissions:ce,onChange:de})]})]}),s.jsxs(Js,{className:"gap-2 sm:gap-0",children:[s.jsx(ue,{variant:"outline",onClick:()=>C(!1),disabled:E,children:"Cancel"}),s.jsx(ue,{onClick:oe,disabled:E,className:"bg-primary",children:E?"Saving...":S==="add"?"Create Group":"Save Changes"})]})]})})]})}function _P({children:t}){const{isAuthenticated:n,loading:a}=Yt();return a?s.jsx("div",{className:"flex min-h-svh items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):n?s.jsx(s.Fragment,{children:t}):s.jsx(ya,{to:"/login",replace:!0})}function DP(){const{complete:t,loading:n}=fS(),a=Kn();return n?s.jsx("div",{className:"flex min-h-svh items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):t?a.pathname==="/setup"?s.jsx(ya,{to:"/login",replace:!0}):s.jsxs(Py,{children:[s.jsx(un,{path:"/login",element:s.jsx(vz,{})}),s.jsxs(un,{element:s.jsx(_P,{children:s.jsx(TA,{})}),children:[s.jsx(un,{index:!0,element:s.jsx(Vz,{})}),s.jsx(un,{path:"system",element:s.jsx(ga,{permission:"overview",children:s.jsx(sP,{})})}),s.jsx(un,{path:"settings",element:s.jsx(ga,{permission:"settings.view",children:s.jsx(nP,{})})}),s.jsx(un,{path:"configs",element:s.jsx(gz,{})}),s.jsx(un,{path:"logs",element:s.jsx(ga,{permission:"logs",children:s.jsx(mP,{})})}),s.jsx(un,{path:"tickets",element:s.jsx(ga,{permission:"transcripts",children:s.jsx(CP,{})})}),s.jsx(un,{path:"transcripts",element:s.jsx(ga,{permission:"transcripts",children:s.jsx(jP,{})})}),s.jsx(un,{path:"users",element:s.jsx(ga,{permission:"users.view",children:s.jsx(TP,{})})}),s.jsx(un,{path:"groups",element:s.jsx(ga,{permission:"users.view",children:s.jsx(AP,{})})}),s.jsx(un,{path:"addons",element:s.jsx(ga,{permission:"settings.view",children:s.jsx(Fz,{})})}),s.jsx(un,{path:"addons/builder",element:s.jsx(ga,{permission:"settings.update",children:s.jsx(Yz,{})})})]}),s.jsx(un,{path:"*",element:s.jsx(ya,{to:"/",replace:!0})})]}):s.jsxs(Py,{children:[s.jsx(un,{path:"/setup",element:s.jsx(Lz,{})}),s.jsx(un,{path:"*",element:s.jsx(ya,{to:"/setup",replace:!0})})]})}function OP({...t}){return s.jsx(KO,{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"}},...t})}Zz();_3.createRoot(document.getElementById("root")).render(s.jsx(f.StrictMode,{children:s.jsx(a8,{children:s.jsx(aC,{children:s.jsx(B8,{children:s.jsx(MA,{children:s.jsxs(U8,{children:[s.jsx(DP,{}),s.jsx(OP,{})]})})})})})})); diff --git a/public/dashboard/index.html b/public/dashboard/index.html index 823007d..95d54fc 100644 --- a/public/dashboard/index.html +++ b/public/dashboard/index.html @@ -10,7 +10,7 @@ href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap" rel="stylesheet" /> - +