function ad(e,t){for(var n=0;nr[l]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const i of l)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(l){const i={};return l.integrity&&(i.integrity=l.integrity),l.referrerPolicy&&(i.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?i.credentials="include":l.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(l){if(l.ep)return;l.ep=!0;const i=n(l);fetch(l.href,i)}})();function ud(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Da={exports:{}},wl={},Ia={exports:{}},D={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var ar=Symbol.for("react.element"),cd=Symbol.for("react.portal"),dd=Symbol.for("react.fragment"),fd=Symbol.for("react.strict_mode"),pd=Symbol.for("react.profiler"),md=Symbol.for("react.provider"),hd=Symbol.for("react.context"),vd=Symbol.for("react.forward_ref"),xd=Symbol.for("react.suspense"),gd=Symbol.for("react.memo"),yd=Symbol.for("react.lazy"),ps=Symbol.iterator;function wd(e){return e===null||typeof e!="object"?null:(e=ps&&e[ps]||e["@@iterator"],typeof e=="function"?e:null)}var Ua={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Fa=Object.assign,Aa={};function xn(e,t,n){this.props=e,this.context=t,this.refs=Aa,this.updater=n||Ua}xn.prototype.isReactComponent={};xn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};xn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function $a(){}$a.prototype=xn.prototype;function mo(e,t,n){this.props=e,this.context=t,this.refs=Aa,this.updater=n||Ua}var ho=mo.prototype=new $a;ho.constructor=mo;Fa(ho,xn.prototype);ho.isPureReactComponent=!0;var ms=Array.isArray,Ba=Object.prototype.hasOwnProperty,vo={current:null},Wa={key:!0,ref:!0,__self:!0,__source:!0};function Va(e,t,n){var r,l={},i=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(i=""+t.key),t)Ba.call(t,r)&&!Wa.hasOwnProperty(r)&&(l[r]=t[r]);var s=arguments.length-2;if(s===1)l.children=n;else if(1>>1,Z=R[K];if(0>>1;Kl(Bl,M))Etl(xr,Bl)?(R[K]=xr,R[Et]=M,K=Et):(R[K]=Bl,R[Ct]=M,K=Ct);else if(Etl(xr,M))R[K]=xr,R[Et]=M,K=Et;else break e}}return O}function l(R,O){var M=R.sortIndex-O.sortIndex;return M!==0?M:R.id-O.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var u=[],c=[],h=1,v=null,p=3,y=!1,w=!1,S=!1,k=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function d(R){for(var O=n(c);O!==null;){if(O.callback===null)r(c);else if(O.startTime<=R)r(c),O.sortIndex=O.expirationTime,t(u,O);else break;O=n(c)}}function x(R){if(S=!1,d(R),!w)if(n(u)!==null)w=!0,Al(C);else{var O=n(c);O!==null&&$l(x,O.startTime-R)}}function C(R,O){w=!1,S&&(S=!1,m(P),P=-1),y=!0;var M=p;try{for(d(O),v=n(u);v!==null&&(!(v.expirationTime>O)||R&&!z());){var K=v.callback;if(typeof K=="function"){v.callback=null,p=v.priorityLevel;var Z=K(v.expirationTime<=O);O=e.unstable_now(),typeof Z=="function"?v.callback=Z:v===n(u)&&r(u),d(O)}else r(u);v=n(u)}if(v!==null)var vr=!0;else{var Ct=n(c);Ct!==null&&$l(x,Ct.startTime-O),vr=!1}return vr}finally{v=null,p=M,y=!1}}var N=!1,E=null,P=-1,_=5,T=-1;function z(){return!(e.unstable_now()-T<_)}function le(){if(E!==null){var R=e.unstable_now();T=R;var O=!0;try{O=E(!0,R)}finally{O?qe():(N=!1,E=null)}}else N=!1}var qe;if(typeof f=="function")qe=function(){f(le)};else if(typeof MessageChannel<"u"){var Sn=new MessageChannel,sd=Sn.port2;Sn.port1.onmessage=le,qe=function(){sd.postMessage(null)}}else qe=function(){k(le,0)};function Al(R){E=R,N||(N=!0,qe())}function $l(R,O){P=k(function(){R(e.unstable_now())},O)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(R){R.callback=null},e.unstable_continueExecution=function(){w||y||(w=!0,Al(C))},e.unstable_forceFrameRate=function(R){0>R||125K?(R.sortIndex=M,t(c,R),n(u)===null&&R===n(c)&&(S?(m(P),P=-1):S=!0,$l(x,M-K))):(R.sortIndex=Z,t(u,R),w||y||(w=!0,Al(C))),R},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(R){var O=p;return function(){var M=p;p=O;try{return R.apply(this,arguments)}finally{p=M}}}})(Ya);Ka.exports=Ya;var zd=Ka.exports;/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Od=g,Ne=zd;function j(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),xi=Object.prototype.hasOwnProperty,Md=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,vs={},xs={};function Dd(e){return xi.call(xs,e)?!0:xi.call(vs,e)?!1:Md.test(e)?xs[e]=!0:(vs[e]=!0,!1)}function Id(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Ud(e,t,n,r){if(t===null||typeof t>"u"||Id(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function fe(e,t,n,r,l,i,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=o}var re={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){re[e]=new fe(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];re[t]=new fe(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){re[e]=new fe(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){re[e]=new fe(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){re[e]=new fe(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){re[e]=new fe(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){re[e]=new fe(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){re[e]=new fe(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){re[e]=new fe(e,5,!1,e.toLowerCase(),null,!1,!1)});var yo=/[\-:]([a-z])/g;function wo(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(yo,wo);re[t]=new fe(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(yo,wo);re[t]=new fe(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(yo,wo);re[t]=new fe(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){re[e]=new fe(e,1,!1,e.toLowerCase(),null,!1,!1)});re.xlinkHref=new fe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){re[e]=new fe(e,1,!1,e.toLowerCase(),null,!0,!0)});function So(e,t,n,r){var l=re.hasOwnProperty(t)?re[t]:null;(l!==null?l.type!==0:r||!(2s||l[o]!==i[s]){var u=` `+l[o].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=o&&0<=s);break}}}finally{Hl=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Rn(e):""}function Fd(e){switch(e.tag){case 5:return Rn(e.type);case 16:return Rn("Lazy");case 13:return Rn("Suspense");case 19:return Rn("SuspenseList");case 0:case 2:case 15:return e=Ql(e.type,!1),e;case 11:return e=Ql(e.type.render,!1),e;case 1:return e=Ql(e.type,!0),e;default:return""}}function Si(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Qt:return"Fragment";case Ht:return"Portal";case gi:return"Profiler";case No:return"StrictMode";case yi:return"Suspense";case wi:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ja:return(e.displayName||"Context")+".Consumer";case Xa:return(e._context.displayName||"Context")+".Provider";case ko:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case jo:return t=e.displayName||null,t!==null?t:Si(e.type)||"Memo";case nt:t=e._payload,e=e._init;try{return Si(e(t))}catch{}}return null}function Ad(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Si(t);case 8:return t===No?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function gt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function qa(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function $d(e){var t=qa(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function wr(e){e._valueTracker||(e._valueTracker=$d(e))}function eu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=qa(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Kr(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ni(e,t){var n=t.checked;return H({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ys(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=gt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function tu(e,t){t=t.checked,t!=null&&So(e,"checked",t,!1)}function ki(e,t){tu(e,t);var n=gt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?ji(e,t.type,n):t.hasOwnProperty("defaultValue")&&ji(e,t.type,gt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function ws(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function ji(e,t,n){(t!=="number"||Kr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Tn=Array.isArray;function nn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Sr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Hn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Mn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Bd=["Webkit","ms","Moz","O"];Object.keys(Mn).forEach(function(e){Bd.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Mn[t]=Mn[e]})});function iu(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Mn.hasOwnProperty(e)&&Mn[e]?(""+t).trim():t+"px"}function ou(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=iu(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Wd=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function _i(e,t){if(t){if(Wd[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(j(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(j(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(j(61))}if(t.style!=null&&typeof t.style!="object")throw Error(j(62))}}function Pi(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Li=null;function Co(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ri=null,rn=null,ln=null;function ks(e){if(e=dr(e)){if(typeof Ri!="function")throw Error(j(280));var t=e.stateNode;t&&(t=Cl(t),Ri(e.stateNode,e.type,t))}}function su(e){rn?ln?ln.push(e):ln=[e]:rn=e}function au(){if(rn){var e=rn,t=ln;if(ln=rn=null,ks(e),t)for(e=0;e>>=0,e===0?32:31-(qd(e)/ef|0)|0}var Nr=64,kr=4194304;function zn(e){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: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Jr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,i=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~l;s!==0?r=zn(s):(i&=o,i!==0&&(r=zn(i)))}else o=n&~l,o!==0?r=zn(o):i!==0&&(r=zn(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,i=t&-t,l>=i||l===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function ur(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-De(t),e[t]=n}function lf(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=In),zs=" ",Os=!1;function Pu(e,t){switch(e){case"keyup":return Of.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Lu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bt=!1;function Df(e,t){switch(e){case"compositionend":return Lu(t);case"keypress":return t.which!==32?null:(Os=!0,zs);case"textInput":return e=t.data,e===zs&&Os?null:e;default:return null}}function If(e,t){if(bt)return e==="compositionend"||!Oo&&Pu(e,t)?(e=Eu(),Fr=Ro=ot=null,bt=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Us(n)}}function Ou(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ou(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Mu(){for(var e=window,t=Kr();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Kr(e.document)}return t}function Mo(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Qf(e){var t=Mu(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Ou(n.ownerDocument.documentElement,n)){if(r!==null&&Mo(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,i=Math.min(r.start,l);r=r.end===void 0?i:Math.min(r.end,l),!e.extend&&i>r&&(l=r,r=i,i=l),l=Fs(n,i);var o=Fs(n,r);l&&o&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Kt=null,Ii=null,Fn=null,Ui=!1;function As(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ui||Kt==null||Kt!==Kr(r)||(r=Kt,"selectionStart"in r&&Mo(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Fn&&Xn(Fn,r)||(Fn=r,r=el(Ii,"onSelect"),0Xt||(e.current=Vi[Xt],Vi[Xt]=null,Xt--)}function F(e,t){Xt++,Vi[Xt]=e.current,e.current=t}var yt={},ae=St(yt),ve=St(!1),Mt=yt;function cn(e,t){var n=e.type.contextTypes;if(!n)return yt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},i;for(i in n)l[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function xe(e){return e=e.childContextTypes,e!=null}function nl(){$(ve),$(ae)}function bs(e,t,n){if(ae.current!==yt)throw Error(j(168));F(ae,t),F(ve,n)}function Vu(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(j(108,Ad(e)||"Unknown",l));return H({},n,r)}function rl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||yt,Mt=ae.current,F(ae,e),F(ve,ve.current),!0}function Ks(e,t,n){var r=e.stateNode;if(!r)throw Error(j(169));n?(e=Vu(e,t,Mt),r.__reactInternalMemoizedMergedChildContext=e,$(ve),$(ae),F(ae,e)):$(ve),F(ve,n)}var He=null,El=!1,ii=!1;function Hu(e){He===null?He=[e]:He.push(e)}function rp(e){El=!0,Hu(e)}function Nt(){if(!ii&&He!==null){ii=!0;var e=0,t=U;try{var n=He;for(U=1;e>=o,l-=o,Qe=1<<32-De(t)+l|n<P?(_=E,E=null):_=E.sibling;var T=p(m,E,d[P],x);if(T===null){E===null&&(E=_);break}e&&E&&T.alternate===null&&t(m,E),f=i(T,f,P),N===null?C=T:N.sibling=T,N=T,E=_}if(P===d.length)return n(m,E),B&&_t(m,P),C;if(E===null){for(;PP?(_=E,E=null):_=E.sibling;var z=p(m,E,T.value,x);if(z===null){E===null&&(E=_);break}e&&E&&z.alternate===null&&t(m,E),f=i(z,f,P),N===null?C=z:N.sibling=z,N=z,E=_}if(T.done)return n(m,E),B&&_t(m,P),C;if(E===null){for(;!T.done;P++,T=d.next())T=v(m,T.value,x),T!==null&&(f=i(T,f,P),N===null?C=T:N.sibling=T,N=T);return B&&_t(m,P),C}for(E=r(m,E);!T.done;P++,T=d.next())T=y(E,m,P,T.value,x),T!==null&&(e&&T.alternate!==null&&E.delete(T.key===null?P:T.key),f=i(T,f,P),N===null?C=T:N.sibling=T,N=T);return e&&E.forEach(function(le){return t(m,le)}),B&&_t(m,P),C}function k(m,f,d,x){if(typeof d=="object"&&d!==null&&d.type===Qt&&d.key===null&&(d=d.props.children),typeof d=="object"&&d!==null){switch(d.$$typeof){case yr:e:{for(var C=d.key,N=f;N!==null;){if(N.key===C){if(C=d.type,C===Qt){if(N.tag===7){n(m,N.sibling),f=l(N,d.props.children),f.return=m,m=f;break e}}else if(N.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===nt&&Xs(C)===N.type){n(m,N.sibling),f=l(N,d.props),f.ref=_n(m,N,d),f.return=m,m=f;break e}n(m,N);break}else t(m,N);N=N.sibling}d.type===Qt?(f=Ot(d.props.children,m.mode,x,d.key),f.return=m,m=f):(x=br(d.type,d.key,d.props,null,m.mode,x),x.ref=_n(m,f,d),x.return=m,m=x)}return o(m);case Ht:e:{for(N=d.key;f!==null;){if(f.key===N)if(f.tag===4&&f.stateNode.containerInfo===d.containerInfo&&f.stateNode.implementation===d.implementation){n(m,f.sibling),f=l(f,d.children||[]),f.return=m,m=f;break e}else{n(m,f);break}else t(m,f);f=f.sibling}f=pi(d,m.mode,x),f.return=m,m=f}return o(m);case nt:return N=d._init,k(m,f,N(d._payload),x)}if(Tn(d))return w(m,f,d,x);if(Nn(d))return S(m,f,d,x);Rr(m,d)}return typeof d=="string"&&d!==""||typeof d=="number"?(d=""+d,f!==null&&f.tag===6?(n(m,f.sibling),f=l(f,d),f.return=m,m=f):(n(m,f),f=fi(d,m.mode,x),f.return=m,m=f),o(m)):n(m,f)}return k}var fn=Yu(!0),Gu=Yu(!1),ol=St(null),sl=null,qt=null,Fo=null;function Ao(){Fo=qt=sl=null}function $o(e){var t=ol.current;$(ol),e._currentValue=t}function bi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function sn(e,t){sl=e,Fo=qt=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(he=!0),e.firstContext=null)}function Le(e){var t=e._currentValue;if(Fo!==e)if(e={context:e,memoizedValue:t,next:null},qt===null){if(sl===null)throw Error(j(308));qt=e,sl.dependencies={lanes:0,firstContext:e}}else qt=qt.next=e;return t}var Rt=null;function Bo(e){Rt===null?Rt=[e]:Rt.push(e)}function Xu(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Bo(t)):(n.next=l.next,l.next=n),t.interleaved=n,Xe(e,r)}function Xe(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var rt=!1;function Wo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ju(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ke(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function pt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,I&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Xe(e,n)}return l=r.interleaved,l===null?(t.next=t,Bo(r)):(t.next=l.next,l.next=t),r.interleaved=t,Xe(e,n)}function $r(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_o(e,n)}}function Js(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?l=i=o:i=i.next=o,n=n.next}while(n!==null);i===null?l=i=t:i=i.next=t}else l=i=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function al(e,t,n,r){var l=e.updateQueue;rt=!1;var i=l.firstBaseUpdate,o=l.lastBaseUpdate,s=l.shared.pending;if(s!==null){l.shared.pending=null;var u=s,c=u.next;u.next=null,o===null?i=c:o.next=c,o=u;var h=e.alternate;h!==null&&(h=h.updateQueue,s=h.lastBaseUpdate,s!==o&&(s===null?h.firstBaseUpdate=c:s.next=c,h.lastBaseUpdate=u))}if(i!==null){var v=l.baseState;o=0,h=c=u=null,s=i;do{var p=s.lane,y=s.eventTime;if((r&p)===p){h!==null&&(h=h.next={eventTime:y,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var w=e,S=s;switch(p=t,y=n,S.tag){case 1:if(w=S.payload,typeof w=="function"){v=w.call(y,v,p);break e}v=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=S.payload,p=typeof w=="function"?w.call(y,v,p):w,p==null)break e;v=H({},v,p);break e;case 2:rt=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,p=l.effects,p===null?l.effects=[s]:p.push(s))}else y={eventTime:y,lane:p,tag:s.tag,payload:s.payload,callback:s.callback,next:null},h===null?(c=h=y,u=v):h=h.next=y,o|=p;if(s=s.next,s===null){if(s=l.shared.pending,s===null)break;p=s,s=p.next,p.next=null,l.lastBaseUpdate=p,l.shared.pending=null}}while(!0);if(h===null&&(u=v),l.baseState=u,l.firstBaseUpdate=c,l.lastBaseUpdate=h,t=l.shared.interleaved,t!==null){l=t;do o|=l.lane,l=l.next;while(l!==t)}else i===null&&(l.shared.lanes=0);Ut|=o,e.lanes=o,e.memoizedState=v}}function Zs(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=si.transition;si.transition={};try{e(!1),t()}finally{U=n,si.transition=r}}function mc(){return Re().memoizedState}function sp(e,t,n){var r=ht(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},hc(e))vc(t,n);else if(n=Xu(e,t,n,r),n!==null){var l=ce();Ie(n,e,r,l),xc(n,t,r)}}function ap(e,t,n){var r=ht(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(hc(e))vc(t,l);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var o=t.lastRenderedState,s=i(o,n);if(l.hasEagerState=!0,l.eagerState=s,Ue(s,o)){var u=t.interleaved;u===null?(l.next=l,Bo(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=Xu(e,t,l,r),n!==null&&(l=ce(),Ie(n,e,r,l),xc(n,t,r))}}function hc(e){var t=e.alternate;return e===V||t!==null&&t===V}function vc(e,t){An=cl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function xc(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_o(e,n)}}var dl={readContext:Le,useCallback:ie,useContext:ie,useEffect:ie,useImperativeHandle:ie,useInsertionEffect:ie,useLayoutEffect:ie,useMemo:ie,useReducer:ie,useRef:ie,useState:ie,useDebugValue:ie,useDeferredValue:ie,useTransition:ie,useMutableSource:ie,useSyncExternalStore:ie,useId:ie,unstable_isNewReconciler:!1},up={readContext:Le,useCallback:function(e,t){return Ae().memoizedState=[e,t===void 0?null:t],e},useContext:Le,useEffect:ea,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Wr(4194308,4,uc.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Wr(4194308,4,e,t)},useInsertionEffect:function(e,t){return Wr(4,2,e,t)},useMemo:function(e,t){var n=Ae();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ae();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=sp.bind(null,V,e),[r.memoizedState,e]},useRef:function(e){var t=Ae();return e={current:e},t.memoizedState=e},useState:qs,useDebugValue:Xo,useDeferredValue:function(e){return Ae().memoizedState=e},useTransition:function(){var e=qs(!1),t=e[0];return e=op.bind(null,e[1]),Ae().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=V,l=Ae();if(B){if(n===void 0)throw Error(j(407));n=n()}else{if(n=t(),ee===null)throw Error(j(349));It&30||tc(r,t,n)}l.memoizedState=n;var i={value:n,getSnapshot:t};return l.queue=i,ea(rc.bind(null,r,i,e),[e]),r.flags|=2048,lr(9,nc.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Ae(),t=ee.identifierPrefix;if(B){var n=be,r=Qe;n=(r&~(1<<32-De(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=nr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[$e]=t,e[qn]=r,_c(e,t,!1,!1),t.stateNode=e;e:{switch(o=Pi(n,r),n){case"dialog":A("cancel",e),A("close",e),l=r;break;case"iframe":case"object":case"embed":A("load",e),l=r;break;case"video":case"audio":for(l=0;lhn&&(t.flags|=128,r=!0,Pn(i,!1),t.lanes=4194304)}else{if(!r)if(e=ul(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Pn(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!B)return oe(t),null}else 2*Y()-i.renderingStartTime>hn&&n!==1073741824&&(t.flags|=128,r=!0,Pn(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(n=i.last,n!==null?n.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Y(),t.sibling=null,n=W.current,F(W,r?n&1|2:n&1),t):(oe(t),null);case 22:case 23:return ns(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ye&1073741824&&(oe(t),t.subtreeFlags&6&&(t.flags|=8192)):oe(t),null;case 24:return null;case 25:return null}throw Error(j(156,t.tag))}function xp(e,t){switch(Io(t),t.tag){case 1:return xe(t.type)&&nl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return pn(),$(ve),$(ae),Qo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ho(t),null;case 13:if($(W),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(j(340));dn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return $(W),null;case 4:return pn(),null;case 10:return $o(t.type._context),null;case 22:case 23:return ns(),null;case 24:return null;default:return null}}var zr=!1,se=!1,gp=typeof WeakSet=="function"?WeakSet:Set,L=null;function en(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Q(e,t,r)}else n.current=null}function to(e,t,n){try{n()}catch(r){Q(e,t,r)}}var da=!1;function yp(e,t){if(Fi=Zr,e=Mu(),Mo(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,s=-1,u=-1,c=0,h=0,v=e,p=null;t:for(;;){for(var y;v!==n||l!==0&&v.nodeType!==3||(s=o+l),v!==i||r!==0&&v.nodeType!==3||(u=o+r),v.nodeType===3&&(o+=v.nodeValue.length),(y=v.firstChild)!==null;)p=v,v=y;for(;;){if(v===e)break t;if(p===n&&++c===l&&(s=o),p===i&&++h===r&&(u=o),(y=v.nextSibling)!==null)break;v=p,p=v.parentNode}v=y}n=s===-1||u===-1?null:{start:s,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ai={focusedElem:e,selectionRange:n},Zr=!1,L=t;L!==null;)if(t=L,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,L=e;else for(;L!==null;){t=L;try{var w=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var S=w.memoizedProps,k=w.memoizedState,m=t.stateNode,f=m.getSnapshotBeforeUpdate(t.elementType===t.type?S:ze(t.type,S),k);m.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var d=t.stateNode.containerInfo;d.nodeType===1?d.textContent="":d.nodeType===9&&d.documentElement&&d.removeChild(d.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(j(163))}}catch(x){Q(t,t.return,x)}if(e=t.sibling,e!==null){e.return=t.return,L=e;break}L=t.return}return w=da,da=!1,w}function $n(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var i=l.destroy;l.destroy=void 0,i!==void 0&&to(t,n,i)}l=l.next}while(l!==r)}}function Ll(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function no(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Rc(e){var t=e.alternate;t!==null&&(e.alternate=null,Rc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[$e],delete t[qn],delete t[Wi],delete t[tp],delete t[np])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Tc(e){return e.tag===5||e.tag===3||e.tag===4}function fa(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Tc(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.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 ro(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=tl));else if(r!==4&&(e=e.child,e!==null))for(ro(e,t,n),e=e.sibling;e!==null;)ro(e,t,n),e=e.sibling}function lo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(lo(e,t,n),e=e.sibling;e!==null;)lo(e,t,n),e=e.sibling}var te=null,Oe=!1;function et(e,t,n){for(n=n.child;n!==null;)zc(e,t,n),n=n.sibling}function zc(e,t,n){if(Be&&typeof Be.onCommitFiberUnmount=="function")try{Be.onCommitFiberUnmount(Sl,n)}catch{}switch(n.tag){case 5:se||en(n,t);case 6:var r=te,l=Oe;te=null,et(e,t,n),te=r,Oe=l,te!==null&&(Oe?(e=te,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):te.removeChild(n.stateNode));break;case 18:te!==null&&(Oe?(e=te,n=n.stateNode,e.nodeType===8?li(e.parentNode,n):e.nodeType===1&&li(e,n),Yn(e)):li(te,n.stateNode));break;case 4:r=te,l=Oe,te=n.stateNode.containerInfo,Oe=!0,et(e,t,n),te=r,Oe=l;break;case 0:case 11:case 14:case 15:if(!se&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var i=l,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&to(n,t,o),l=l.next}while(l!==r)}et(e,t,n);break;case 1:if(!se&&(en(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){Q(n,t,s)}et(e,t,n);break;case 21:et(e,t,n);break;case 22:n.mode&1?(se=(r=se)||n.memoizedState!==null,et(e,t,n),se=r):et(e,t,n);break;default:et(e,t,n)}}function pa(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new gp),t.forEach(function(r){var l=Pp.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Te(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=o),r&=~i}if(r=l,r=Y()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Sp(r/1960))-r,10e?16:e,st===null)var r=!1;else{if(e=st,st=null,ml=0,I&6)throw Error(j(331));var l=I;for(I|=4,L=e.current;L!==null;){var i=L,o=i.child;if(L.flags&16){var s=i.deletions;if(s!==null){for(var u=0;uY()-es?zt(e,0):qo|=n),ge(e,t)}function $c(e,t){t===0&&(e.mode&1?(t=kr,kr<<=1,!(kr&130023424)&&(kr=4194304)):t=1);var n=ce();e=Xe(e,t),e!==null&&(ur(e,t,n),ge(e,n))}function _p(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),$c(e,n)}function Pp(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(j(314))}r!==null&&r.delete(t),$c(e,n)}var Bc;Bc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ve.current)he=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return he=!1,hp(e,t,n);he=!!(e.flags&131072)}else he=!1,B&&t.flags&1048576&&Qu(t,il,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Vr(e,t),e=t.pendingProps;var l=cn(t,ae.current);sn(t,n),l=Ko(null,t,r,e,l,n);var i=Yo();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,xe(r)?(i=!0,rl(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Wo(t),l.updater=Pl,t.stateNode=l,l._reactInternals=t,Yi(t,r,e,n),t=Ji(null,t,r,!0,i,n)):(t.tag=0,B&&i&&Do(t),ue(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Vr(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Rp(r),e=ze(r,e),l){case 0:t=Xi(null,t,r,e,n);break e;case 1:t=aa(null,t,r,e,n);break e;case 11:t=oa(null,t,r,e,n);break e;case 14:t=sa(null,t,r,ze(r.type,e),n);break e}throw Error(j(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:ze(r,l),Xi(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:ze(r,l),aa(e,t,r,l,n);case 3:e:{if(jc(t),e===null)throw Error(j(387));r=t.pendingProps,i=t.memoizedState,l=i.element,Ju(e,t),al(t,r,null,n);var o=t.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){l=mn(Error(j(423)),t),t=ua(e,t,r,n,l);break e}else if(r!==l){l=mn(Error(j(424)),t),t=ua(e,t,r,n,l);break e}else for(we=ft(t.stateNode.containerInfo.firstChild),Se=t,B=!0,Me=null,n=Gu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(dn(),r===l){t=Je(e,t,n);break e}ue(e,t,r,n)}t=t.child}return t;case 5:return Zu(t),e===null&&Qi(t),r=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,o=l.children,$i(r,l)?o=null:i!==null&&$i(r,i)&&(t.flags|=32),kc(e,t),ue(e,t,o,n),t.child;case 6:return e===null&&Qi(t),null;case 13:return Cc(e,t,n);case 4:return Vo(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=fn(t,null,r,n):ue(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:ze(r,l),oa(e,t,r,l,n);case 7:return ue(e,t,t.pendingProps,n),t.child;case 8:return ue(e,t,t.pendingProps.children,n),t.child;case 12:return ue(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,i=t.memoizedProps,o=l.value,F(ol,r._currentValue),r._currentValue=o,i!==null)if(Ue(i.value,o)){if(i.children===l.children&&!ve.current){t=Je(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var s=i.dependencies;if(s!==null){o=i.child;for(var u=s.firstContext;u!==null;){if(u.context===r){if(i.tag===1){u=Ke(-1,n&-n),u.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var h=c.pending;h===null?u.next=u:(u.next=h.next,h.next=u),c.pending=u}}i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),bi(i.return,n,t),s.lanes|=n;break}u=u.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(j(341));o.lanes|=n,s=o.alternate,s!==null&&(s.lanes|=n),bi(o,n,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}ue(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,sn(t,n),l=Le(l),r=r(l),t.flags|=1,ue(e,t,r,n),t.child;case 14:return r=t.type,l=ze(r,t.pendingProps),l=ze(r.type,l),sa(e,t,r,l,n);case 15:return Sc(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:ze(r,l),Vr(e,t),t.tag=1,xe(r)?(e=!0,rl(t)):e=!1,sn(t,n),gc(t,r,l),Yi(t,r,l,n),Ji(null,t,r,!0,e,n);case 19:return Ec(e,t,n);case 22:return Nc(e,t,n)}throw Error(j(156,t.tag))};function Wc(e,t){return hu(e,t)}function Lp(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _e(e,t,n,r){return new Lp(e,t,n,r)}function ls(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Rp(e){if(typeof e=="function")return ls(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ko)return 11;if(e===jo)return 14}return 2}function vt(e,t){var n=e.alternate;return n===null?(n=_e(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function br(e,t,n,r,l,i){var o=2;if(r=e,typeof e=="function")ls(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Qt:return Ot(n.children,l,i,t);case No:o=8,l|=8;break;case gi:return e=_e(12,n,t,l|2),e.elementType=gi,e.lanes=i,e;case yi:return e=_e(13,n,t,l),e.elementType=yi,e.lanes=i,e;case wi:return e=_e(19,n,t,l),e.elementType=wi,e.lanes=i,e;case Za:return Tl(n,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Xa:o=10;break e;case Ja:o=9;break e;case ko:o=11;break e;case jo:o=14;break e;case nt:o=16,r=null;break e}throw Error(j(130,e==null?e:typeof e,""))}return t=_e(o,n,t,l),t.elementType=e,t.type=r,t.lanes=i,t}function Ot(e,t,n,r){return e=_e(7,e,r,t),e.lanes=n,e}function Tl(e,t,n,r){return e=_e(22,e,r,t),e.elementType=Za,e.lanes=n,e.stateNode={isHidden:!1},e}function fi(e,t,n){return e=_e(6,e,null,t),e.lanes=n,e}function pi(e,t,n){return t=_e(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Tp(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Kl(0),this.expirationTimes=Kl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Kl(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function is(e,t,n,r,l,i,o,s,u){return e=new Tp(e,t,n,s,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=_e(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Wo(i),e}function zp(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(bc)}catch(e){console.error(e)}}bc(),ba.exports=ke;var Up=ba.exports,Sa=Up;vi.createRoot=Sa.createRoot,vi.hydrateRoot=Sa.hydrateRoot;/** * @remix-run/router v1.23.2 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function or(){return or=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function us(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Ap(){return Math.random().toString(36).substr(2,8)}function ka(e,t){return{usr:e.state,key:e.key,idx:t}}function uo(e,t,n,r){return n===void 0&&(n=null),or({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?wn(t):t,{state:n,key:t&&t.key||r||Ap()})}function xl(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function wn(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function $p(e,t,n,r){r===void 0&&(r={});let{window:l=document.defaultView,v5Compat:i=!1}=r,o=l.history,s=at.Pop,u=null,c=h();c==null&&(c=0,o.replaceState(or({},o.state,{idx:c}),""));function h(){return(o.state||{idx:null}).idx}function v(){s=at.Pop;let k=h(),m=k==null?null:k-c;c=k,u&&u({action:s,location:S.location,delta:m})}function p(k,m){s=at.Push;let f=uo(S.location,k,m);c=h()+1;let d=ka(f,c),x=S.createHref(f);try{o.pushState(d,"",x)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;l.location.assign(x)}i&&u&&u({action:s,location:S.location,delta:1})}function y(k,m){s=at.Replace;let f=uo(S.location,k,m);c=h();let d=ka(f,c),x=S.createHref(f);o.replaceState(d,"",x),i&&u&&u({action:s,location:S.location,delta:0})}function w(k){let m=l.location.origin!=="null"?l.location.origin:l.location.href,f=typeof k=="string"?k:xl(k);return f=f.replace(/ $/,"%20"),b(m,"No window.location.(origin|href) available to create URL for href: "+f),new URL(f,m)}let S={get action(){return s},get location(){return e(l,o)},listen(k){if(u)throw new Error("A history only accepts one active listener");return l.addEventListener(Na,v),u=k,()=>{l.removeEventListener(Na,v),u=null}},createHref(k){return t(l,k)},createURL:w,encodeLocation(k){let m=w(k);return{pathname:m.pathname,search:m.search,hash:m.hash}},push:p,replace:y,go(k){return o.go(k)}};return S}var ja;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(ja||(ja={}));function Bp(e,t,n){return n===void 0&&(n="/"),Wp(e,t,n)}function Wp(e,t,n,r){let l=typeof t=="string"?wn(t):t,i=vn(l.pathname||"/",n);if(i==null)return null;let o=Kc(e);Vp(o);let s=null;for(let u=0;s==null&&u{let u={relativePath:s===void 0?i.path||"":s,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};u.relativePath.startsWith("/")&&(b(u.relativePath.startsWith(r),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(r.length));let c=xt([r,u.relativePath]),h=n.concat(u);i.children&&i.children.length>0&&(b(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+c+'".')),Kc(i.children,t,h,c)),!(i.path==null&&!i.index)&&t.push({path:c,score:Xp(c,i.index),routesMeta:h})};return e.forEach((i,o)=>{var s;if(i.path===""||!((s=i.path)!=null&&s.includes("?")))l(i,o);else for(let u of Yc(i.path))l(i,o,u)}),t}function Yc(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,l=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return l?[i,""]:[i];let o=Yc(r.join("/")),s=[];return s.push(...o.map(u=>u===""?i:[i,u].join("/"))),l&&s.push(...o),s.map(u=>e.startsWith("/")&&u===""?"/":u)}function Vp(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Jp(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const Hp=/^:[\w-]+$/,Qp=3,bp=2,Kp=1,Yp=10,Gp=-2,Ca=e=>e==="*";function Xp(e,t){let n=e.split("/"),r=n.length;return n.some(Ca)&&(r+=Gp),t&&(r+=bp),n.filter(l=>!Ca(l)).reduce((l,i)=>l+(Hp.test(i)?Qp:i===""?Kp:Yp),r)}function Jp(e,t){return e.length===t.length&&e.slice(0,-1).every((r,l)=>r===t[l])?e[e.length-1]-t[t.length-1]:0}function Zp(e,t,n){let{routesMeta:r}=e,l={},i="/",o=[];for(let s=0;s{let{paramName:p,isOptional:y}=h;if(p==="*"){let S=s[v]||"";o=i.slice(0,i.length-S.length).replace(/(.)\/+$/,"$1")}const w=s[v];return y&&!w?c[p]=void 0:c[p]=(w||"").replace(/%2F/g,"/"),c},{}),pathname:i,pathnameBase:o,pattern:e}}function qp(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),us(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,s,u)=>(r.push({paramName:s,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,t?void 0:"i"),r]}function em(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return us(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function vn(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const tm=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,nm=e=>tm.test(e);function rm(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:l=""}=typeof e=="string"?wn(e):e,i;if(n)if(nm(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),us(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=Ea(n.substring(1),"/"):i=Ea(n,t)}else i=t;return{pathname:i,search:om(r),hash:sm(l)}}function Ea(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(l=>{l===".."?n.length>1&&n.pop():l!=="."&&n.push(l)}),n.length>1?n.join("/"):"/"}function mi(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function lm(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Gc(e,t){let n=lm(e);return t?n.map((r,l)=>l===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Xc(e,t,n,r){r===void 0&&(r=!1);let l;typeof e=="string"?l=wn(e):(l=or({},e),b(!l.pathname||!l.pathname.includes("?"),mi("?","pathname","search",l)),b(!l.pathname||!l.pathname.includes("#"),mi("#","pathname","hash",l)),b(!l.search||!l.search.includes("#"),mi("#","search","hash",l)));let i=e===""||l.pathname==="",o=i?"/":l.pathname,s;if(o==null)s=n;else{let v=t.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),v-=1;l.pathname=p.join("/")}s=v>=0?t[v]:"/"}let u=rm(l,s),c=o&&o!=="/"&&o.endsWith("/"),h=(i||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(c||h)&&(u.pathname+="/"),u}const xt=e=>e.join("/").replace(/\/\/+/g,"/"),im=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),om=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,sm=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function am(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const Jc=["post","put","patch","delete"];new Set(Jc);const um=["get",...Jc];new Set(um);/** * React Router v6.30.3 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function sr(){return sr=Object.assign?Object.assign.bind():function(e){for(var t=1;t{s.current=!0}),g.useCallback(function(c,h){if(h===void 0&&(h={}),!s.current)return;if(typeof c=="number"){r.go(c);return}let v=Xc(c,JSON.parse(o),i,h.relative==="path");e==null&&t!=="/"&&(v.pathname=v.pathname==="/"?t:xt([t,v.pathname])),(h.replace?r.replace:r.push)(v,h.state,h)},[t,r,o,i,e])}function td(){let{matches:e}=g.useContext(jt),t=e[e.length-1];return t?t.params:{}}function Fl(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=g.useContext(kt),{matches:l}=g.useContext(jt),{pathname:i}=mr(),o=JSON.stringify(Gc(l,r.v7_relativeSplatPath));return g.useMemo(()=>Xc(e,JSON.parse(o),i,n==="path"),[e,o,i,n])}function fm(e,t){return pm(e,t)}function pm(e,t,n,r){pr()||b(!1);let{navigator:l}=g.useContext(kt),{matches:i}=g.useContext(jt),o=i[i.length-1],s=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let c=mr(),h;if(t){var v;let k=typeof t=="string"?wn(t):t;u==="/"||(v=k.pathname)!=null&&v.startsWith(u)||b(!1),h=k}else h=c;let p=h.pathname||"/",y=p;if(u!=="/"){let k=u.replace(/^\//,"").split("/");y="/"+p.replace(/^\//,"").split("/").slice(k.length).join("/")}let w=Bp(e,{pathname:y}),S=gm(w&&w.map(k=>Object.assign({},k,{params:Object.assign({},s,k.params),pathname:xt([u,l.encodeLocation?l.encodeLocation(k.pathname).pathname:k.pathname]),pathnameBase:k.pathnameBase==="/"?u:xt([u,l.encodeLocation?l.encodeLocation(k.pathnameBase).pathname:k.pathnameBase])})),i,n,r);return t&&S?g.createElement(Ul.Provider,{value:{location:sr({pathname:"/",search:"",hash:"",state:null,key:"default"},h),navigationType:at.Pop}},S):S}function mm(){let e=Nm(),t=am(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,l={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return g.createElement(g.Fragment,null,g.createElement("h2",null,"Unexpected Application Error!"),g.createElement("h3",{style:{fontStyle:"italic"}},t),n?g.createElement("pre",{style:l},n):null,null)}const hm=g.createElement(mm,null);class vm extends g.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){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?g.createElement(jt.Provider,{value:this.props.routeContext},g.createElement(qc.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function xm(e){let{routeContext:t,match:n,children:r}=e,l=g.useContext(Il);return l&&l.static&&l.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(l.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(jt.Provider,{value:t},r)}function gm(e,t,n,r){var l;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,s=(l=n)==null?void 0:l.errors;if(s!=null){let h=o.findIndex(v=>v.route.id&&(s==null?void 0:s[v.route.id])!==void 0);h>=0||b(!1),o=o.slice(0,Math.min(o.length,h+1))}let u=!1,c=-1;if(n&&r&&r.v7_partialHydration)for(let h=0;h=0?o=o.slice(0,c+1):o=[o[0]];break}}}return o.reduceRight((h,v,p)=>{let y,w=!1,S=null,k=null;n&&(y=s&&v.route.id?s[v.route.id]:void 0,S=v.route.errorElement||hm,u&&(c<0&&p===0?(jm("route-fallback"),w=!0,k=null):c===p&&(w=!0,k=v.route.hydrateFallbackElement||null)));let m=t.concat(o.slice(0,p+1)),f=()=>{let d;return y?d=S:w?d=k:v.route.Component?d=g.createElement(v.route.Component,null):v.route.element?d=v.route.element:d=h,g.createElement(xm,{match:v,routeContext:{outlet:h,matches:m,isDataRoute:n!=null},children:d})};return n&&(v.route.ErrorBoundary||v.route.errorElement||p===0)?g.createElement(vm,{location:n.location,revalidation:n.revalidation,component:S,error:y,children:f(),routeContext:{outlet:null,matches:m,isDataRoute:!0}}):f()},null)}var nd=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(nd||{}),rd=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(rd||{});function ym(e){let t=g.useContext(Il);return t||b(!1),t}function wm(e){let t=g.useContext(Zc);return t||b(!1),t}function Sm(e){let t=g.useContext(jt);return t||b(!1),t}function ld(e){let t=Sm(),n=t.matches[t.matches.length-1];return n.route.id||b(!1),n.route.id}function Nm(){var e;let t=g.useContext(qc),n=wm(),r=ld();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function km(){let{router:e}=ym(nd.UseNavigateStable),t=ld(rd.UseNavigateStable),n=g.useRef(!1);return ed(()=>{n.current=!0}),g.useCallback(function(l,i){i===void 0&&(i={}),n.current&&(typeof l=="number"?e.navigate(l):e.navigate(l,sr({fromRouteId:t},i)))},[e,t])}const _a={};function jm(e,t,n){_a[e]||(_a[e]=!0)}function Cm(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function tt(e){b(!1)}function Em(e){let{basename:t="/",children:n=null,location:r,navigationType:l=at.Pop,navigator:i,static:o=!1,future:s}=e;pr()&&b(!1);let u=t.replace(/^\/*/,"/"),c=g.useMemo(()=>({basename:u,navigator:i,static:o,future:sr({v7_relativeSplatPath:!1},s)}),[u,s,i,o]);typeof r=="string"&&(r=wn(r));let{pathname:h="/",search:v="",hash:p="",state:y=null,key:w="default"}=r,S=g.useMemo(()=>{let k=vn(h,u);return k==null?null:{location:{pathname:k,search:v,hash:p,state:y,key:w},navigationType:l}},[u,h,v,p,y,w,l]);return S==null?null:g.createElement(kt.Provider,{value:c},g.createElement(Ul.Provider,{children:n,value:S}))}function _m(e){let{children:t,location:n}=e;return fm(fo(t),n)}new Promise(()=>{});function fo(e,t){t===void 0&&(t=[]);let n=[];return g.Children.forEach(e,(r,l)=>{if(!g.isValidElement(r))return;let i=[...t,l];if(r.type===g.Fragment){n.push.apply(n,fo(r.props.children,i));return}r.type!==tt&&b(!1),!r.props.index||!r.props.children||b(!1);let o={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=fo(r.props.children,i)),n.push(o)}),n}/** * React Router DOM v6.30.3 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function gl(){return gl=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[l]=e[l]);return n}function Pm(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Lm(e,t){return e.button===0&&(!t||t==="_self")&&!Pm(e)}const Rm=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Tm=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],zm="6";try{window.__reactRouterVersion=zm}catch{}const Om=g.createContext({isTransitioning:!1}),Mm="startTransition",Pa=Cd[Mm];function Dm(e){let{basename:t,children:n,future:r,window:l}=e,i=g.useRef();i.current==null&&(i.current=Fp({window:l,v5Compat:!0}));let o=i.current,[s,u]=g.useState({action:o.action,location:o.location}),{v7_startTransition:c}=r||{},h=g.useCallback(v=>{c&&Pa?Pa(()=>u(v)):u(v)},[u,c]);return g.useLayoutEffect(()=>o.listen(h),[o,h]),g.useEffect(()=>Cm(r),[r]),g.createElement(Em,{basename:t,children:n,location:s.location,navigationType:s.action,navigator:o,future:r})}const Im=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Um=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Fm=g.forwardRef(function(t,n){let{onClick:r,relative:l,reloadDocument:i,replace:o,state:s,target:u,to:c,preventScrollReset:h,viewTransition:v}=t,p=id(t,Rm),{basename:y}=g.useContext(kt),w,S=!1;if(typeof c=="string"&&Um.test(c)&&(w=c,Im))try{let d=new URL(window.location.href),x=c.startsWith("//")?new URL(d.protocol+c):new URL(c),C=vn(x.pathname,y);x.origin===d.origin&&C!=null?c=C+x.search+x.hash:S=!0}catch{}let k=cm(c,{relative:l}),m=$m(c,{replace:o,state:s,target:u,preventScrollReset:h,relative:l,viewTransition:v});function f(d){r&&r(d),d.defaultPrevented||m(d)}return g.createElement("a",gl({},p,{href:w||k,onClick:S||i?r:f,ref:n,target:u}))}),La=g.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:l=!1,className:i="",end:o=!1,style:s,to:u,viewTransition:c,children:h}=t,v=id(t,Tm),p=Fl(u,{relative:v.relative}),y=mr(),w=g.useContext(Zc),{navigator:S,basename:k}=g.useContext(kt),m=w!=null&&Bm(p)&&c===!0,f=S.encodeLocation?S.encodeLocation(p).pathname:p.pathname,d=y.pathname,x=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;l||(d=d.toLowerCase(),x=x?x.toLowerCase():null,f=f.toLowerCase()),x&&k&&(x=vn(x,k)||x);const C=f!=="/"&&f.endsWith("/")?f.length-1:f.length;let N=d===f||!o&&d.startsWith(f)&&d.charAt(C)==="/",E=x!=null&&(x===f||!o&&x.startsWith(f)&&x.charAt(f.length)==="/"),P={isActive:N,isPending:E,isTransitioning:m},_=N?r:void 0,T;typeof i=="function"?T=i(P):T=[i,N?"active":null,E?"pending":null,m?"transitioning":null].filter(Boolean).join(" ");let z=typeof s=="function"?s(P):s;return g.createElement(Fm,gl({},v,{"aria-current":_,className:T,ref:n,style:z,to:u,viewTransition:c}),typeof h=="function"?h(P):h)});var po;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(po||(po={}));var Ra;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Ra||(Ra={}));function Am(e){let t=g.useContext(Il);return t||b(!1),t}function $m(e,t){let{target:n,replace:r,state:l,preventScrollReset:i,relative:o,viewTransition:s}=t===void 0?{}:t,u=Bt(),c=mr(),h=Fl(e,{relative:o});return g.useCallback(v=>{if(Lm(v,n)){v.preventDefault();let p=r!==void 0?r:xl(c)===xl(h);u(e,{replace:p,state:l,preventScrollReset:i,relative:o,viewTransition:s})}},[c,u,h,r,l,n,e,i,o,s])}function Bm(e,t){t===void 0&&(t={});let n=g.useContext(Om);n==null&&b(!1);let{basename:r}=Am(po.useViewTransitionState),l=Fl(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=vn(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=vn(n.nextLocation.pathname,r)||n.nextLocation.pathname;return co(l.pathname,o)!=null||co(l.pathname,i)!=null}const Ta=[{path:"/",label:"Dashboard",icon:"📊"},{path:"/users",label:"Users",icon:"👥"},{path:"/roles",label:"Roles",icon:"🛡️"},{path:"/services",label:"Services",icon:"⚙️"},{path:"/audit",label:"Audit",icon:"📋"}];function Wm({children:e,user:t}){const[n,r]=g.useState(!1),l=Bt(),i=async()=>{try{await fetch("/auth/logout",{method:"POST",credentials:"include"})}catch{}window.location.href="/login.html"},o=((t==null?void 0:t.email)||"A").split("@")[0].split(/[._-]+/).map(s=>s[0]).join("").slice(0,2).toUpperCase();return a.jsxs("div",{className:"min-h-screen bg-surface-0",children:[a.jsx("header",{className:"bg-surface-1 border-b border-border sticky top-0 z-50",children:a.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:a.jsxs("div",{className:"flex items-center justify-between h-14",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{className:"sm:hidden p-1 text-txt-secondary hover:text-txt-primary",onClick:()=>r(!n),children:a.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:n?"M6 18L18 6M6 6l12 12":"M4 6h16M4 12h16M4 18h16"})})}),a.jsx("span",{className:"text-lg font-semibold text-txt-primary cursor-pointer",onClick:()=>l("/"),children:"🔐 Access Manager"})]}),a.jsx("nav",{className:"hidden sm:flex items-center gap-1",children:Ta.map(s=>a.jsxs(La,{to:s.path,end:s.path==="/",className:({isActive:u})=>`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${u?"bg-accent/10 text-accent":"text-txt-secondary hover:text-txt-primary hover:bg-surface-2"}`,children:[s.icon," ",s.label]},s.path))}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"hidden sm:block text-xs text-txt-muted",children:t==null?void 0:t.email}),a.jsxs("div",{className:"relative group",children:[a.jsx("button",{className:"w-8 h-8 rounded-full bg-accent/20 text-accent text-xs font-bold flex items-center justify-center",children:o}),a.jsxs("div",{className:"absolute right-0 top-full mt-1 w-40 bg-surface-2 border border-border rounded-lg shadow-xl opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all z-50",children:[a.jsx("div",{className:"p-2 text-xs text-txt-muted border-b border-border",children:t==null?void 0:t.email}),a.jsx("button",{onClick:i,className:"w-full text-left px-3 py-2 text-sm text-danger hover:bg-surface-3 rounded-b-lg transition-colors",children:"Logout"})]})]})]})]})})}),n&&a.jsx("nav",{className:"sm:hidden bg-surface-1 border-b border-border px-4 py-2 space-y-1",children:Ta.map(s=>a.jsxs(La,{to:s.path,end:s.path==="/",onClick:()=>r(!1),className:({isActive:u})=>`block px-3 py-2 rounded-md text-sm ${u?"bg-accent/10 text-accent":"text-txt-secondary hover:bg-surface-2"}`,children:[s.icon," ",s.label]},s.path))}),a.jsx("main",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6",children:e})]})}const Vm="";async function hr(e,t={}){const n=await fetch(Vm+e,{...t,credentials:"include",headers:{"Content-Type":"application/json",...t.headers}});if(n.status===401)throw window.location.href="/login.html",new Error("Unauthorized");if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}function me(e,t=[]){const[n,r]=g.useState(null),[l,i]=g.useState(!0),[o,s]=g.useState(null),u=g.useCallback(()=>{i(!0),s(null),hr(e).then(r).catch(c=>s(c.message)).finally(()=>i(!1))},[e]);return g.useEffect(()=>{u()},[u,...t]),{data:n,loading:l,error:o,refetch:u}}async function Hm(e){return hr(e)}async function cs(e,t){return hr(e,{method:"POST",body:JSON.stringify(t)})}async function za(e,t){return hr(e,{method:"PUT",body:JSON.stringify(t)})}async function Qm(e){return hr(e,{method:"DELETE"})}function Vt({label:e,value:t,icon:n,onClick:r}){return a.jsxs("div",{onClick:r,className:`bg-surface-1 border border-border rounded-xl p-5 ${r?"cursor-pointer hover:border-accent/40 hover:bg-surface-2":""} transition-all`,children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-2xl",children:n}),a.jsx("span",{className:"text-2xl font-bold text-txt-primary",children:t??"—"})]}),a.jsx("div",{className:"text-sm text-txt-muted",children:e})]})}function Oa(e){if(!e)return"Never";const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"Just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function bm(){const e=Bt(),{data:t}=me("/api/stats"),{data:n}=me("/api/audit?limit=10"),{data:r}=me("/api/users"),l=(r||[]).filter(o=>o.last_login).sort((o,s)=>new Date(s.last_login)-new Date(o.last_login)).slice(0,5),i=((n==null?void 0:n.events)||n||[]).slice(0,8);return a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-txt-primary mb-6",children:"Dashboard"}),a.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-4 mb-8",children:[a.jsx(Vt,{icon:"👥",label:"Users",value:t==null?void 0:t.users,onClick:()=>e("/users")}),a.jsx(Vt,{icon:"🛡️",label:"Roles",value:t==null?void 0:t.roles,onClick:()=>e("/roles")}),a.jsx(Vt,{icon:"🔑",label:"Permissions",value:t==null?void 0:t.permissions}),a.jsx(Vt,{icon:"⚙️",label:"Services",value:t==null?void 0:t.services,onClick:()=>e("/services")}),a.jsx(Vt,{icon:"🔗",label:"Assignments",value:t==null?void 0:t.user_roles}),a.jsx(Vt,{icon:"📋",label:"Audit Events",value:t==null?void 0:t.audit_events,onClick:()=>e("/audit")})]}),a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"bg-surface-1 border border-border rounded-xl overflow-hidden",children:[a.jsx("div",{className:"px-4 py-3 bg-surface-2 border-b border-border",children:a.jsx("h2",{className:"text-sm font-semibold text-txt-primary",children:"Recent Logins"})}),a.jsx("div",{className:"divide-y divide-border",children:l.length===0?a.jsx("div",{className:"px-4 py-6 text-center text-txt-muted text-sm",children:"No recent logins"}):l.map(o=>a.jsxs("div",{className:"px-4 py-3 flex items-center justify-between hover:bg-surface-2 cursor-pointer transition-colors",onClick:()=>e(`/users/${encodeURIComponent(o.email)}`),children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-sm text-txt-primary",children:o.email}),a.jsx("div",{className:"text-xs text-txt-muted",children:o.name||"—"})]}),a.jsx("div",{className:"text-xs text-txt-muted",children:Oa(o.last_login)})]},o.email))})]}),a.jsxs("div",{className:"bg-surface-1 border border-border rounded-xl overflow-hidden",children:[a.jsx("div",{className:"px-4 py-3 bg-surface-2 border-b border-border",children:a.jsx("h2",{className:"text-sm font-semibold text-txt-primary",children:"Recent Audit Events"})}),a.jsx("div",{className:"divide-y divide-border",children:i.length===0?a.jsx("div",{className:"px-4 py-6 text-center text-txt-muted text-sm",children:"No audit events"}):i.map((o,s)=>a.jsxs("div",{className:"px-4 py-3 hover:bg-surface-2 transition-colors",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-xs font-mono bg-surface-3 text-txt-secondary px-2 py-0.5 rounded",children:o.action}),a.jsx("span",{className:"text-xs text-txt-muted",children:Oa(o.created_at||o.timestamp)})]}),a.jsxs("div",{className:"text-xs text-txt-muted mt-1",children:[o.actor," → ",o.target_type,"/",o.target_id]})]},o.id||s))})]})]})]})}function ds({columns:e,data:t,onRowClick:n,emptyMessage:r="No data"}){const[l,i]=g.useState(null),[o,s]=g.useState("asc"),u=h=>{l===h?s(v=>v==="asc"?"desc":"asc"):(i(h),s("asc"))},c=g.useMemo(()=>!l||!t?t||[]:[...t].sort((h,v)=>{const p=h[l]??"",y=v[l]??"",w=typeof p=="number"?p-y:String(p).localeCompare(String(y));return o==="asc"?w:-w}),[t,l,o]);return t?a.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsx("tr",{className:"bg-surface-2",children:e.map(h=>a.jsx("th",{className:`px-4 py-3 text-left text-xs font-medium text-txt-muted uppercase tracking-wide ${h.sortable!==!1?"cursor-pointer hover:text-txt-secondary select-none":""}`,onClick:()=>h.sortable!==!1&&u(h.key),children:a.jsxs("span",{className:"flex items-center gap-1",children:[h.label,l===h.key&&a.jsx("span",{className:"text-accent",children:o==="asc"?"↑":"↓"})]})},h.key))})}),a.jsx("tbody",{className:"divide-y divide-border",children:c.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:e.length,className:"px-4 py-8 text-center text-txt-muted",children:r})}):c.map((h,v)=>a.jsx("tr",{className:`bg-surface-1 hover:bg-surface-2 transition-colors ${n?"cursor-pointer":""}`,onClick:()=>n==null?void 0:n(h),children:e.map(p=>a.jsx("td",{className:"px-4 py-3 text-txt-secondary",children:p.render?p.render(h[p.key],h):h[p.key]??"—"},p.key))},h.id||h.email||h.name||v))})]})}):null}const Km={super_admin:"bg-red-500/15 text-red-400 border-red-500/30",admin:"bg-orange-500/15 text-orange-400 border-orange-500/30",editor:"bg-blue-500/15 text-blue-400 border-blue-500/30",user:"bg-green-500/15 text-green-400 border-green-500/30",viewer:"bg-gray-500/15 text-gray-400 border-gray-500/30"};function yl({role:e,scope:t}){const n=Km[e]||"bg-purple-500/15 text-purple-400 border-purple-500/30";return a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium border ${n}`,children:[e,t&&t!=="*"&&a.jsxs("span",{className:"text-[10px] opacity-70",children:["(",t,")"]})]})}const Ym={active:"bg-green-500/15 text-green-400",suspended:"bg-yellow-500/15 text-yellow-400",deactivated:"bg-red-500/15 text-red-400"};function od({status:e}){const t=Ym[e]||"bg-gray-500/15 text-gray-400";return a.jsxs("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${t}`,children:[a.jsx("span",{className:`w-1.5 h-1.5 rounded-full mr-1.5 ${e==="active"?"bg-green-400":e==="suspended"?"bg-yellow-400":"bg-red-400"}`}),e||"active"]})}function fs({open:e,onClose:t,title:n,children:r,wide:l}){return g.useEffect(()=>{if(e){document.body.style.overflow="hidden";const i=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>{document.body.style.overflow="",window.removeEventListener("keydown",i)}}},[e,t]),e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:t}),a.jsxs("div",{className:`relative bg-surface-1 border border-border rounded-xl shadow-2xl ${l?"max-w-2xl":"max-w-md"} w-full max-h-[85vh] overflow-y-auto`,children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[a.jsx("h2",{className:"text-lg font-semibold text-txt-primary",children:n}),a.jsx("button",{onClick:t,className:"text-txt-muted hover:text-txt-primary text-xl leading-none",children:"×"})]}),a.jsx("div",{className:"p-4",children:r})]})]}):null}function Gm(e){if(!e)return"Never";const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Xm(){const e=Bt(),{data:t,loading:n,refetch:r}=me("/api/users"),[l,i]=g.useState(""),[o,s]=g.useState(""),[u,c]=g.useState(!1),[h,v]=g.useState(""),[p,y]=g.useState(""),[w,S]=g.useState(!1),[k,m]=g.useState(""),f=g.useMemo(()=>t?t.filter(N=>{var E,P;if(l){const _=l.toLowerCase();if(!((E=N.email)!=null&&E.toLowerCase().includes(_))&&!((P=N.name)!=null&&P.toLowerCase().includes(_)))return!1}return!(o&&N.role!==o)}):[],[t,l,o]),d=g.useMemo(()=>t?[...new Set(t.map(N=>N.role).filter(Boolean))]:[],[t]),x=async N=>{N.preventDefault(),S(!0),m("");try{await cs("/api/users",{email:h,password:p}),c(!1),v(""),y(""),r()}catch(E){m(E.message)}finally{S(!1)}},C=[{key:"email",label:"User",render:(N,E)=>a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 rounded-full bg-accent/20 text-accent text-xs font-bold flex items-center justify-center flex-shrink-0",children:(E.email||"?").split("@")[0].split(/[._-]+/).map(P=>P[0]).join("").slice(0,2).toUpperCase()}),a.jsxs("div",{children:[a.jsx("div",{className:"text-txt-primary font-medium",children:E.email}),E.name&&a.jsx("div",{className:"text-xs text-txt-muted",children:E.name})]})]})},{key:"role",label:"Role",render:N=>a.jsx(yl,{role:N})},{key:"status",label:"Status",render:N=>a.jsx(od,{status:N||"active"})},{key:"last_login",label:"Last Login",render:N=>a.jsx("span",{className:"text-xs",children:Gm(N)})}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-txt-primary",children:"Users"}),a.jsx("button",{onClick:()=>c(!0),className:"px-4 py-2 bg-accent text-white text-sm font-medium rounded-lg hover:bg-accent-hover transition-colors",children:"+ Add User"})]}),a.jsxs("div",{className:"flex flex-wrap gap-3 mb-4",children:[a.jsx("input",{type:"text",placeholder:"Search by email or name...",value:l,onChange:N=>i(N.target.value),className:"flex-1 min-w-[200px] px-3 py-2 bg-surface-1 border border-border rounded-lg text-sm text-txt-primary placeholder:text-txt-muted focus:outline-none focus:border-accent"}),a.jsxs("select",{value:o,onChange:N=>s(N.target.value),className:"px-3 py-2 bg-surface-1 border border-border rounded-lg text-sm text-txt-secondary focus:outline-none focus:border-accent",children:[a.jsx("option",{value:"",children:"All Roles"}),d.map(N=>a.jsx("option",{value:N,children:N},N))]})]}),n?a.jsx("div",{className:"text-center py-12 text-txt-muted",children:"Loading users..."}):a.jsx(ds,{columns:C,data:f,onRowClick:N=>e(`/users/${encodeURIComponent(N.email)}`),emptyMessage:"No users found"}),a.jsx(fs,{open:u,onClose:()=>c(!1),title:"Add User",children:a.jsxs("form",{onSubmit:x,className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-txt-secondary mb-1",children:"Email"}),a.jsx("input",{type:"email",required:!0,value:h,onChange:N=>v(N.target.value),className:"w-full px-3 py-2 bg-surface-2 border border-border rounded-lg text-sm text-txt-primary focus:outline-none focus:border-accent"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-txt-secondary mb-1",children:"Password"}),a.jsx("input",{type:"password",required:!0,minLength:8,value:p,onChange:N=>y(N.target.value),className:"w-full px-3 py-2 bg-surface-2 border border-border rounded-lg text-sm text-txt-primary focus:outline-none focus:border-accent"})]}),k&&a.jsx("div",{className:"text-sm text-danger",children:k}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx("button",{type:"button",onClick:()=>c(!1),className:"px-4 py-2 text-sm text-txt-secondary hover:text-txt-primary",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:w,className:"px-4 py-2 bg-accent text-white text-sm rounded-lg hover:bg-accent-hover disabled:opacity-50",children:w?"Creating...":"Create User"})]})]})})]})}function hi(e){if(!e)return"Never";const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Jm(){const{email:e}=td(),t=decodeURIComponent(e),n=Bt(),{data:r}=me("/api/users"),{data:l,refetch:i}=me(`/api/users/${encodeURIComponent(t)}/roles`),{data:o}=me(`/api/permissions/user/${encodeURIComponent(t)}`),{data:s}=me(`/api/audit/user/${encodeURIComponent(t)}`),{data:u}=me("/api/roles"),c=g.useMemo(()=>(r||[]).find(_=>_.email===t),[r,t]),[h,v]=g.useState(!1),[p,y]=g.useState(""),[w,S]=g.useState("*"),[k,m]=g.useState(!1),f=(t||"?").split("@")[0].split(/[._-]+/).map(_=>_[0]).join("").slice(0,2).toUpperCase(),d=async()=>{if(p){m(!0);try{await cs(`/api/users/${encodeURIComponent(t)}/roles`,{role:p,scope:w}),v(!1),y(""),S("*"),i()}catch(_){alert(_.message)}finally{m(!1)}}},x=async _=>{if(confirm(`Remove role "${_}" from ${t}?`))try{await Qm(`/api/users/${encodeURIComponent(t)}/roles/${_}`),i()}catch(T){alert(T.message)}},C=(l==null?void 0:l.roles)||l||[],N=(o==null?void 0:o.permissions)||[],E=(s==null?void 0:s.events)||s||[],P=g.useMemo(()=>{const _={};return N.forEach(T=>{const le=T.split(".")[0]||"*";_[le]||(_[le]=[]),_[le].push(T)}),_},[N]);return a.jsxs("div",{children:[a.jsx("button",{onClick:()=>n("/users"),className:"text-sm text-accent hover:text-accent-hover mb-4 inline-block",children:"← Back to Users"}),a.jsx("div",{className:"bg-surface-1 border border-border rounded-xl p-6 mb-6",children:a.jsxs("div",{className:"flex items-start gap-4",children:[a.jsx("div",{className:"w-16 h-16 rounded-full bg-accent/20 text-accent text-xl font-bold flex items-center justify-center flex-shrink-0",children:f}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("h1",{className:"text-xl font-bold text-txt-primary",children:(c==null?void 0:c.name)||t}),a.jsx("div",{className:"text-sm text-txt-muted mt-0.5",children:t}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[a.jsx(od,{status:(c==null?void 0:c.status)||"active"}),c!=null&&c.is_super?a.jsx(yl,{role:"super_admin"}):null,a.jsxs("span",{className:"text-xs text-txt-muted",children:["Created: ",c!=null&&c.created_at?new Date(c.created_at).toLocaleDateString():"—"]}),a.jsxs("span",{className:"text-xs text-txt-muted",children:["Last login: ",hi(c==null?void 0:c.last_login)]})]})]})]})}),a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"bg-surface-1 border border-border rounded-xl overflow-hidden",children:[a.jsxs("div",{className:"px-4 py-3 bg-surface-2 border-b border-border flex items-center justify-between",children:[a.jsx("h2",{className:"text-sm font-semibold text-txt-primary",children:"Assigned Roles"}),a.jsx("button",{onClick:()=>v(!0),className:"text-xs text-accent hover:text-accent-hover font-medium",children:"+ Assign Role"})]}),a.jsx("div",{className:"divide-y divide-border",children:C.length===0?a.jsx("div",{className:"px-4 py-6 text-center text-txt-muted text-sm",children:"No roles assigned"}):C.map((_,T)=>a.jsxs("div",{className:"px-4 py-3 flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(yl,{role:_.role,scope:_.scope}),_.granted_at&&a.jsx("span",{className:"text-xs text-txt-muted",children:hi(_.granted_at)})]}),a.jsx("button",{onClick:()=>x(_.role),className:"text-xs text-danger hover:text-red-300 font-medium",children:"Remove"})]},_.role||T))})]}),a.jsxs("div",{className:"bg-surface-1 border border-border rounded-xl overflow-hidden",children:[a.jsx("div",{className:"px-4 py-3 bg-surface-2 border-b border-border",children:a.jsxs("h2",{className:"text-sm font-semibold text-txt-primary",children:["Effective Permissions (",N.length,")"]})}),a.jsx("div",{className:"p-4 max-h-80 overflow-y-auto",children:N.length===0?a.jsx("div",{className:"text-center text-txt-muted text-sm py-4",children:"No permissions"}):Object.entries(P).map(([_,T])=>a.jsxs("div",{className:"mb-3",children:[a.jsx("div",{className:"text-xs font-medium text-txt-muted uppercase mb-1",children:_==="*"?"Global":_}),a.jsx("div",{className:"flex flex-wrap gap-1",children:T.map(z=>a.jsx("span",{className:"text-xs font-mono bg-surface-3 text-txt-secondary px-2 py-0.5 rounded",children:z},z))})]},_))})]})]}),a.jsxs("div",{className:"bg-surface-1 border border-border rounded-xl overflow-hidden mt-6",children:[a.jsx("div",{className:"px-4 py-3 bg-surface-2 border-b border-border",children:a.jsx("h2",{className:"text-sm font-semibold text-txt-primary",children:"Audit Log"})}),a.jsx("div",{className:"divide-y divide-border max-h-96 overflow-y-auto",children:E.length===0?a.jsx("div",{className:"px-4 py-6 text-center text-txt-muted text-sm",children:"No audit events"}):E.map((_,T)=>a.jsxs("div",{className:"px-4 py-3 hover:bg-surface-2 transition-colors",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-xs font-mono bg-surface-3 text-txt-secondary px-2 py-0.5 rounded",children:_.action}),a.jsx("span",{className:"text-xs text-txt-muted",children:hi(_.created_at||_.timestamp)})]}),a.jsxs("div",{className:"text-xs text-txt-muted mt-1",children:[_.actor," → ",_.target_type,"/",_.target_id,_.detail&&a.jsxs("span",{className:"text-txt-muted/60 ml-2",children:["— ",typeof _.detail=="string"?_.detail:JSON.stringify(_.detail)]})]})]},_.id||T))})]}),a.jsx(fs,{open:h,onClose:()=>v(!1),title:"Assign Role",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-txt-secondary mb-1",children:"Role"}),a.jsxs("select",{value:p,onChange:_=>y(_.target.value),className:"w-full px-3 py-2 bg-surface-2 border border-border rounded-lg text-sm text-txt-primary focus:outline-none focus:border-accent",children:[a.jsx("option",{value:"",children:"Select a role..."}),(u||[]).map(_=>a.jsx("option",{value:_.name,children:_.display_name||_.name},_.name))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-txt-secondary mb-1",children:"Scope"}),a.jsx("input",{type:"text",value:w,onChange:_=>S(_.target.value),placeholder:"* (global)",className:"w-full px-3 py-2 bg-surface-2 border border-border rounded-lg text-sm text-txt-primary focus:outline-none focus:border-accent"}),a.jsx("p",{className:"text-xs text-txt-muted mt-1",children:"Use * for global, or a specific app ID"})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx("button",{onClick:()=>v(!1),className:"px-4 py-2 text-sm text-txt-secondary",children:"Cancel"}),a.jsx("button",{onClick:d,disabled:!p||k,className:"px-4 py-2 bg-accent text-white text-sm rounded-lg hover:bg-accent-hover disabled:opacity-50",children:k?"Assigning...":"Assign"})]})]})})]})}function Zm(){const e=Bt(),{data:t,loading:n,refetch:r}=me("/api/roles"),[l,i]=g.useState(!1),[o,s]=g.useState(""),[u,c]=g.useState(""),[h,v]=g.useState(""),[p,y]=g.useState(100),[w,S]=g.useState(!1),[k,m]=g.useState(""),f=async x=>{x.preventDefault(),S(!0),m("");try{await cs("/api/roles",{name:o.toLowerCase().replace(/\s+/g,"_"),display_name:u,description:h,priority:Number(p)}),i(!1),s(""),c(""),v(""),y(100),r()}catch(C){m(C.message)}finally{S(!1)}},d=[{key:"name",label:"Role",render:(x,C)=>a.jsxs("div",{className:"flex items-center gap-2",children:[C.is_system&&a.jsx("span",{title:"System role",className:"text-txt-muted",children:"🔒"}),a.jsxs("div",{children:[a.jsx("div",{className:"text-txt-primary font-medium",children:C.display_name||x}),a.jsx("div",{className:"text-xs text-txt-muted font-mono",children:x})]})]})},{key:"is_system",label:"Type",render:x=>a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${x?"bg-yellow-500/15 text-yellow-400":"bg-surface-3 text-txt-muted"}`,children:x?"System":"Custom"})},{key:"user_count",label:"Users",render:x=>a.jsx("span",{className:"text-sm",children:x??0})},{key:"permission_count",label:"Permissions",render:x=>a.jsx("span",{className:"text-sm",children:x??0})},{key:"priority",label:"Priority",render:x=>a.jsx("span",{className:"text-xs text-txt-muted",children:x})}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-txt-primary",children:"Roles"}),a.jsx("button",{onClick:()=>i(!0),className:"px-4 py-2 bg-accent text-white text-sm font-medium rounded-lg hover:bg-accent-hover transition-colors",children:"+ Create Role"})]}),n?a.jsx("div",{className:"text-center py-12 text-txt-muted",children:"Loading roles..."}):a.jsx(ds,{columns:d,data:t,onRowClick:x=>e(`/roles/${x.name}`),emptyMessage:"No roles defined"}),a.jsx(fs,{open:l,onClose:()=>i(!1),title:"Create Role",children:a.jsxs("form",{onSubmit:f,className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-txt-secondary mb-1",children:"Name (slug)"}),a.jsx("input",{type:"text",required:!0,value:o,onChange:x=>s(x.target.value),placeholder:"e.g. content_editor",className:"w-full px-3 py-2 bg-surface-2 border border-border rounded-lg text-sm text-txt-primary focus:outline-none focus:border-accent"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-txt-secondary mb-1",children:"Display Name"}),a.jsx("input",{type:"text",required:!0,value:u,onChange:x=>c(x.target.value),placeholder:"e.g. Content Editor",className:"w-full px-3 py-2 bg-surface-2 border border-border rounded-lg text-sm text-txt-primary focus:outline-none focus:border-accent"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-txt-secondary mb-1",children:"Description"}),a.jsx("textarea",{value:h,onChange:x=>v(x.target.value),rows:2,className:"w-full px-3 py-2 bg-surface-2 border border-border rounded-lg text-sm text-txt-primary focus:outline-none focus:border-accent resize-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-txt-secondary mb-1",children:"Priority"}),a.jsx("input",{type:"number",value:p,onChange:x=>y(x.target.value),className:"w-full px-3 py-2 bg-surface-2 border border-border rounded-lg text-sm text-txt-primary focus:outline-none focus:border-accent"})]}),k&&a.jsx("div",{className:"text-sm text-danger",children:k}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx("button",{type:"button",onClick:()=>i(!1),className:"px-4 py-2 text-sm text-txt-secondary",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:w,className:"px-4 py-2 bg-accent text-white text-sm rounded-lg hover:bg-accent-hover disabled:opacity-50",children:w?"Creating...":"Create Role"})]})]})})]})}function qm({allPermissions:e,selectedIds:t,onChange:n,readOnly:r}){const[l,i]=g.useState("all"),o=g.useMemo(()=>{if(!e)return{};const p={};return e.forEach(y=>{const w=y.app||"*",S=y.category||"General";p[w]||(p[w]={}),p[w][S]||(p[w][S]={});const k=y.feature||"general";p[w][S][k]||(p[w][S][k]={}),p[w][S][k][y.action]=y}),p},[e]),s=g.useMemo(()=>Object.keys(o).sort(),[o]),u=["read","write","delete","admin","execute","manage"],c=l==="all"?s:[l],h=p=>t.has(p.id),v=p=>{if(r)return;const y=new Set(t);y.has(p.id)?y.delete(p.id):y.add(p.id),n(y)};return a.jsxs("div",{children:[a.jsxs("div",{className:"flex flex-wrap gap-1 mb-4 border-b border-border pb-2",children:[a.jsx("button",{onClick:()=>i("all"),className:`px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${l==="all"?"bg-accent text-white":"bg-surface-2 text-txt-secondary hover:bg-surface-3"}`,children:"All Apps"}),s.map(p=>a.jsx("button",{onClick:()=>i(p),className:`px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${l===p?"bg-accent text-white":"bg-surface-2 text-txt-secondary hover:bg-surface-3"}`,children:p==="*"?"Global":p},p))]}),c.map(p=>a.jsxs("div",{className:"mb-6",children:[l==="all"&&a.jsxs("h3",{className:"text-sm font-semibold text-txt-primary mb-2 flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 rounded-full bg-accent"}),p==="*"?"Global (Wildcard)":p]}),Object.entries(o[p]||{}).sort(([y],[w])=>y.localeCompare(w)).map(([y,w])=>a.jsxs("div",{className:"mb-4 bg-surface-1 rounded-lg border border-border overflow-hidden",children:[a.jsx("div",{className:"px-4 py-2 bg-surface-2 text-xs font-medium text-txt-muted uppercase tracking-wide",children:y}),a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-border",children:[a.jsx("th",{className:"px-4 py-2 text-left text-xs text-txt-muted font-medium w-1/3",children:"Feature"}),u.map(S=>a.jsx("th",{className:"px-2 py-2 text-center text-xs text-txt-muted font-medium capitalize w-16",children:S},S))]})}),a.jsx("tbody",{className:"divide-y divide-border/50",children:Object.entries(w).sort(([S],[k])=>S.localeCompare(k)).map(([S,k])=>a.jsxs("tr",{className:"hover:bg-surface-2/50",children:[a.jsx("td",{className:"px-4 py-2 text-txt-secondary font-mono text-xs",children:S}),u.map(m=>{const f=k[m];return f?a.jsx("td",{className:"px-2 py-2 text-center",children:a.jsx("input",{type:"checkbox",checked:h(f),onChange:()=>v(f),disabled:r,className:"w-4 h-4 rounded border-border cursor-pointer disabled:cursor-default disabled:opacity-50"})},m):a.jsx("td",{className:"px-2 py-2 text-center text-txt-muted/30",children:"—"},m)})]},S))})]})]},y))]},p))]})}function eh(){const{name:e}=td(),t=Bt(),{data:n,loading:r,refetch:l}=me(`/api/roles/${e}`),{data:i}=me("/api/permissions"),[o,s]=g.useState(new Set),[u,c]=g.useState(!1),[h,v]=g.useState(!1),[p,y]=g.useState(""),[w,S]=g.useState(""),[k,m]=g.useState(""),[f,d]=g.useState(100),[x,C]=g.useState(!1);g.useEffect(()=>{if(n){const z=new Set;n.permissions&&n.permissions.forEach(le=>{le.id&&z.add(le.id)}),s(z),c(!1),S(n.display_name||""),m(n.description||""),d(n.priority||100)}},[n]);const N=z=>{s(z),c(!0),y("")},E=async()=>{v(!0),y("");try{await za(`/api/roles/${e}/permissions`,{permission_ids:[...o]}),y("Permissions saved!"),c(!1),l()}catch(z){y(`Error: ${z.message}`)}finally{v(!1)}},P=async()=>{try{await za(`/api/roles/${e}`,{display_name:w,description:k,priority:Number(f)}),C(!1),l()}catch(z){alert(z.message)}},_=g.useMemo(()=>{if(!i)return[];if(Array.isArray(i))return i;const z=[];return Object.entries(i).forEach(([le,qe])=>{Array.isArray(qe)&&qe.forEach(Sn=>z.push({...Sn,app:Sn.app||le}))}),z},[i]);if(r)return a.jsx("div",{className:"text-center py-12 text-txt-muted",children:"Loading..."});if(!n)return a.jsx("div",{className:"text-center py-12 text-txt-muted",children:"Role not found"});const T=n.users||[];return a.jsxs("div",{children:[a.jsx("button",{onClick:()=>t("/roles"),className:"text-sm text-accent hover:text-accent-hover mb-4 inline-block",children:"← Back to Roles"}),a.jsx("div",{className:"bg-surface-1 border border-border rounded-xl p-6 mb-6",children:x?a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-txt-muted mb-1",children:"Display Name"}),a.jsx("input",{value:w,onChange:z=>S(z.target.value),className:"w-full px-3 py-2 bg-surface-2 border border-border rounded-lg text-sm text-txt-primary focus:outline-none focus:border-accent"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-txt-muted mb-1",children:"Description"}),a.jsx("textarea",{value:k,onChange:z=>m(z.target.value),rows:2,className:"w-full px-3 py-2 bg-surface-2 border border-border rounded-lg text-sm text-txt-primary focus:outline-none focus:border-accent resize-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-txt-muted mb-1",children:"Priority"}),a.jsx("input",{type:"number",value:f,onChange:z=>d(z.target.value),className:"w-32 px-3 py-2 bg-surface-2 border border-border rounded-lg text-sm text-txt-primary focus:outline-none focus:border-accent"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:P,className:"px-3 py-1.5 bg-accent text-white text-sm rounded-lg hover:bg-accent-hover",children:"Save"}),a.jsx("button",{onClick:()=>C(!1),className:"px-3 py-1.5 text-sm text-txt-secondary hover:text-txt-primary",children:"Cancel"})]})]}):a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("h1",{className:"text-xl font-bold text-txt-primary",children:n.display_name||n.name}),a.jsx(yl,{role:n.name}),n.is_system&&a.jsx("span",{className:"text-xs bg-yellow-500/15 text-yellow-400 px-2 py-0.5 rounded",children:"System"})]}),a.jsx("div",{className:"text-sm text-txt-muted font-mono mb-1",children:n.name}),n.description&&a.jsx("p",{className:"text-sm text-txt-secondary",children:n.description}),a.jsxs("div",{className:"text-xs text-txt-muted mt-2",children:["Priority: ",n.priority]})]}),a.jsx("button",{onClick:()=>C(!0),className:"text-xs text-accent hover:text-accent-hover font-medium",children:"Edit"})]})}),a.jsxs("div",{className:"bg-surface-1 border border-border rounded-xl overflow-hidden mb-6",children:[a.jsxs("div",{className:"px-4 py-3 bg-surface-2 border-b border-border flex items-center justify-between",children:[a.jsx("h2",{className:"text-sm font-semibold text-txt-primary",children:"Permission Matrix"}),a.jsxs("div",{className:"flex items-center gap-3",children:[p&&a.jsx("span",{className:`text-xs ${p.startsWith("Error")?"text-danger":"text-green-400"}`,children:p}),u&&a.jsx("button",{onClick:E,disabled:h,className:"px-4 py-1.5 bg-accent text-white text-sm rounded-lg hover:bg-accent-hover disabled:opacity-50 transition-colors",children:h?"Saving...":"Save Changes"})]})]}),a.jsx("div",{className:"p-4",children:a.jsx(qm,{allPermissions:_,selectedIds:o,onChange:N})})]}),a.jsxs("div",{className:"bg-surface-1 border border-border rounded-xl overflow-hidden",children:[a.jsx("div",{className:"px-4 py-3 bg-surface-2 border-b border-border",children:a.jsxs("h2",{className:"text-sm font-semibold text-txt-primary",children:["Users with this Role (",T.length,")"]})}),a.jsx("div",{className:"divide-y divide-border",children:T.length===0?a.jsx("div",{className:"px-4 py-6 text-center text-txt-muted text-sm",children:"No users have this role"}):T.map((z,le)=>a.jsxs("div",{className:"px-4 py-3 flex items-center justify-between hover:bg-surface-2 cursor-pointer transition-colors",onClick:()=>t(`/users/${encodeURIComponent(z.email)}`),children:[a.jsx("div",{className:"text-sm text-txt-primary",children:z.email}),a.jsx("div",{className:"text-xs text-txt-muted",children:z.scope==="*"?"Global":z.scope})]},z.email||le))})]})]})}function th(){const{data:e,loading:t}=me("/api/services/list"),{data:n}=me("/api/features"),[r,l]=g.useState(null),i=[{key:"id",label:"Service ID",render:s=>a.jsx("span",{className:"font-mono text-txt-primary",children:s})},{key:"display_name",label:"Name",render:(s,u)=>a.jsx("span",{className:"text-txt-secondary",children:s||u.name||u.id})},{key:"hostname",label:"Hostname",render:s=>s?a.jsx("span",{className:"text-xs font-mono text-accent",children:s}):a.jsx("span",{className:"text-txt-muted",children:"—"})},{key:"feature_count",label:"Features",render:(s,u)=>{const c=n?(Array.isArray(n)?n:[]).filter(h=>h.app===u.id).length:0;return a.jsx("span",{className:"text-sm",children:c})},sortable:!1}],o=s=>n?(Array.isArray(n)?n:[]).filter(c=>c.app===s):[];return a.jsxs("div",{children:[a.jsx("div",{className:"flex items-center justify-between mb-6",children:a.jsx("h1",{className:"text-2xl font-bold text-txt-primary",children:"Services"})}),t?a.jsx("div",{className:"text-center py-12 text-txt-muted",children:"Loading services..."}):a.jsxs(a.Fragment,{children:[a.jsx(ds,{columns:i,data:e||[],onRowClick:s=>l(r===s.id?null:s.id),emptyMessage:"No services registered"}),r&&a.jsxs("div",{className:"mt-4 bg-surface-1 border border-border rounded-xl overflow-hidden",children:[a.jsx("div",{className:"px-4 py-3 bg-surface-2 border-b border-border",children:a.jsxs("h2",{className:"text-sm font-semibold text-txt-primary",children:["Features for ",a.jsx("span",{className:"font-mono text-accent",children:r})]})}),a.jsx("div",{className:"p-4",children:o(r).length===0?a.jsx("div",{className:"text-center text-txt-muted text-sm py-4",children:"No features registered for this service"}):a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:o(r).map((s,u)=>a.jsxs("div",{className:"px-3 py-2 bg-surface-2 rounded-lg",children:[a.jsxs("div",{className:"text-sm font-mono text-txt-primary",children:[s.feature,".",s.action]}),a.jsx("div",{className:"text-xs text-txt-muted",children:s.category||"General"})]},s.id||u))})})]})]})]})}function nh(e){if(!e)return"—";const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"Just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function rh(){const[e,t]=g.useState([]),[n,r]=g.useState(!0),[l,i]=g.useState(""),[o,s]=g.useState(""),[u,c]=g.useState(""),[h,v]=g.useState(0),[p,y]=g.useState(null),w=50,S=g.useCallback(async()=>{r(!0);try{const d=new URLSearchParams({limit:String(w),offset:String(h)});l&&d.set("actor",l),o&&d.set("action",o);const x=await Hm(`/api/audit?${d}`);t(x.events||x||[])}catch(d){console.error("Audit fetch error:",d)}finally{r(!1)}},[h,l,o]);g.useEffect(()=>{S()},[S]);const k=g.useMemo(()=>{if(!u)return e;const d=u.toLowerCase();return e.filter(x=>{var C,N,E,P;return((C=x.actor)==null?void 0:C.toLowerCase().includes(d))||((N=x.action)==null?void 0:N.toLowerCase().includes(d))||((E=x.target_type)==null?void 0:E.toLowerCase().includes(d))||((P=x.target_id)==null?void 0:P.toLowerCase().includes(d))||JSON.stringify(x.detail||"").toLowerCase().includes(d)})},[e,u]),m=g.useMemo(()=>[...new Set(e.map(d=>d.actor).filter(Boolean))],[e]),f=g.useMemo(()=>[...new Set(e.map(d=>d.action).filter(Boolean))],[e]);return a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-txt-primary mb-6",children:"Audit Log"}),a.jsxs("div",{className:"flex flex-wrap gap-3 mb-4",children:[a.jsx("input",{type:"text",placeholder:"Search...",value:u,onChange:d=>c(d.target.value),className:"flex-1 min-w-[200px] px-3 py-2 bg-surface-1 border border-border rounded-lg text-sm text-txt-primary placeholder:text-txt-muted focus:outline-none focus:border-accent"}),a.jsxs("select",{value:l,onChange:d=>{i(d.target.value),v(0)},className:"px-3 py-2 bg-surface-1 border border-border rounded-lg text-sm text-txt-secondary focus:outline-none focus:border-accent",children:[a.jsx("option",{value:"",children:"All Actors"}),m.map(d=>a.jsx("option",{value:d,children:d},d))]}),a.jsxs("select",{value:o,onChange:d=>{s(d.target.value),v(0)},className:"px-3 py-2 bg-surface-1 border border-border rounded-lg text-sm text-txt-secondary focus:outline-none focus:border-accent",children:[a.jsx("option",{value:"",children:"All Actions"}),f.map(d=>a.jsx("option",{value:d,children:d},d))]})]}),n?a.jsx("div",{className:"text-center py-12 text-txt-muted",children:"Loading audit events..."}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"bg-surface-2",children:[a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-txt-muted uppercase",children:"Time"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-txt-muted uppercase",children:"Actor"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-txt-muted uppercase",children:"Action"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-txt-muted uppercase",children:"Target"}),a.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-txt-muted uppercase",children:"Detail"})]})}),a.jsx("tbody",{className:"divide-y divide-border",children:k.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:5,className:"px-4 py-8 text-center text-txt-muted",children:"No audit events"})}):k.map((d,x)=>a.jsxs(go.Fragment,{children:[a.jsxs("tr",{className:"bg-surface-1 hover:bg-surface-2 cursor-pointer transition-colors",onClick:()=>y(p===x?null:x),children:[a.jsx("td",{className:"px-4 py-3 text-xs text-txt-muted whitespace-nowrap",children:nh(d.created_at||d.timestamp)}),a.jsx("td",{className:"px-4 py-3 text-txt-secondary",children:d.actor||"—"}),a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-xs font-mono bg-surface-3 text-txt-secondary px-2 py-0.5 rounded",children:d.action})}),a.jsxs("td",{className:"px-4 py-3 text-txt-secondary text-xs",children:[d.target_type,"/",d.target_id]}),a.jsx("td",{className:"px-4 py-3 text-xs text-txt-muted truncate max-w-[200px]",children:typeof d.detail=="string"?d.detail:d.detail?JSON.stringify(d.detail).slice(0,60):"—"})]}),p===x&&d.detail&&a.jsx("tr",{children:a.jsx("td",{colSpan:5,className:"px-4 py-3 bg-surface-2",children:a.jsx("pre",{className:"text-xs text-txt-secondary font-mono whitespace-pre-wrap break-all",children:typeof d.detail=="string"?d.detail:JSON.stringify(d.detail,null,2)})})})]},d.id||x))})]})}),a.jsxs("div",{className:"flex items-center justify-between mt-4",children:[a.jsx("button",{onClick:()=>v(Math.max(0,h-w)),disabled:h===0,className:"px-3 py-1.5 bg-surface-2 text-txt-secondary text-sm rounded-lg hover:bg-surface-3 disabled:opacity-30 transition-colors",children:"← Previous"}),a.jsxs("span",{className:"text-xs text-txt-muted",children:["Showing ",h+1,"–",h+k.length]}),a.jsx("button",{onClick:()=>v(h+w),disabled:e.length{fetch("/api/whoami",{credentials:"include"}).then(l=>{if(l.status===401)throw new Error("Not authenticated");if(!l.ok)throw new Error("Not authenticated");return l.json()}).then(l=>{if(!l.authenticated)throw new Error("Not authenticated");const i=l;if(!(i!=null&&i.email))throw new Error("No user data");if(!(i.is_super||i.role==="admin"||(i.permissions||[]).some(s=>s==="*.*.*"||s.endsWith(".admin")))){r("denied");return}t(i),r("authenticated")}).catch(()=>{r("unauthenticated")})},[]),n==="loading"?a.jsx(Ma,{}):n==="unauthenticated"?(window.location.href="/login.html",a.jsx(Ma,{})):n==="denied"?a.jsx(lh,{}):a.jsx(Wm,{user:e,children:a.jsxs(_m,{children:[a.jsx(tt,{path:"/",element:a.jsx(bm,{})}),a.jsx(tt,{path:"/users",element:a.jsx(Xm,{})}),a.jsx(tt,{path:"/users/:email",element:a.jsx(Jm,{})}),a.jsx(tt,{path:"/roles",element:a.jsx(Zm,{})}),a.jsx(tt,{path:"/roles/:name",element:a.jsx(eh,{})}),a.jsx(tt,{path:"/services",element:a.jsx(th,{})}),a.jsx(tt,{path:"/audit",element:a.jsx(rh,{})})]})})}vi.createRoot(document.getElementById("root")).render(a.jsx(go.StrictMode,{children:a.jsx(Dm,{basename:"/app",children:a.jsx(ih,{})})}));