diff --git a/admin/dist/assets/index-CWq369vO.js b/admin/dist/assets/index-DFgMZhBE.js similarity index 94% rename from admin/dist/assets/index-CWq369vO.js rename to admin/dist/assets/index-DFgMZhBE.js index 698ad7194..725c9fd8a 100644 --- a/admin/dist/assets/index-CWq369vO.js +++ b/admin/dist/assets/index-DFgMZhBE.js @@ -46,7 +46,7 @@ `+s[a].replace(" at new "," at ");return l.displayName&&b.includes("")&&(b=b.replace("",l.displayName)),b}while(1<=a&&0<=n);break}}}finally{Vu=!1,Error.prepareStackTrace=e}return(e=l?l.displayName||l.name:"")?Ae(e):""}function Cr(l,t){switch(l.tag){case 26:case 27:case 5:return Ae(l.type);case 16:return Ae("Lazy");case 13:return l.child!==t&&t!==null?Ae("Suspense Fallback"):Ae("Suspense");case 19:return Ae("SuspenseList");case 0:case 15:return Ku(l.type,!1);case 11:return Ku(l.type.render,!1);case 1:return Ku(l.type,!0);case 31:return Ae("Activity");default:return""}}function vf(l){try{var t="",e=null;do t+=Cr(l,e),e=l,l=l.return;while(l);return t}catch(a){return` Error generating stack: `+a.message+` `+a.stack}}var Ju=Object.prototype.hasOwnProperty,wu=d.unstable_scheduleCallback,ku=d.unstable_cancelCallback,Ur=d.unstable_shouldYield,Rr=d.unstable_requestPaint,Pl=d.unstable_now,Hr=d.unstable_getCurrentPriorityLevel,gf=d.unstable_ImmediatePriority,Sf=d.unstable_UserBlockingPriority,En=d.unstable_NormalPriority,Br=d.unstable_LowPriority,bf=d.unstable_IdlePriority,qr=d.log,Yr=d.unstable_setDisableYieldValue,Na=null,lt=null;function It(l){if(typeof qr=="function"&&Yr(l),lt&&typeof lt.setStrictMode=="function")try{lt.setStrictMode(Na,l)}catch{}}var tt=Math.clz32?Math.clz32:Qr,Gr=Math.log,Xr=Math.LN2;function Qr(l){return l>>>=0,l===0?32:31-(Gr(l)/Xr|0)|0}var _n=256,jn=262144,On=4194304;function Ee(l){var t=l&42;if(t!==0)return t;switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return l&261888;case 262144:case 524288:case 1048576:case 2097152:return l&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function Nn(l,t,e){var a=l.pendingLanes;if(a===0)return 0;var n=0,u=l.suspendedLanes,i=l.pingedLanes;l=l.warmLanes;var c=a&134217727;return c!==0?(a=c&~u,a!==0?n=Ee(a):(i&=c,i!==0?n=Ee(i):e||(e=c&~l,e!==0&&(n=Ee(e))))):(c=a&~u,c!==0?n=Ee(c):i!==0?n=Ee(i):e||(e=a&~l,e!==0&&(n=Ee(e)))),n===0?0:t!==0&&t!==n&&(t&u)===0&&(u=n&-n,e=t&-t,u>=e||u===32&&(e&4194048)!==0)?t:n}function Ma(l,t){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&t)===0}function Zr(l,t){switch(l){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function pf(){var l=On;return On<<=1,(On&62914560)===0&&(On=4194304),l}function $u(l){for(var t=[],e=0;31>e;e++)t.push(l);return t}function Da(l,t){l.pendingLanes|=t,t!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function Lr(l,t,e,a,n,u){var i=l.pendingLanes;l.pendingLanes=e,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=e,l.entangledLanes&=e,l.errorRecoveryDisabledLanes&=e,l.shellSuspendCounter=0;var c=l.entanglements,s=l.expirationTimes,v=l.hiddenUpdates;for(e=i&~e;0"u")return null;try{return l.activeElement||l.body}catch{return l.body}}var $r=/[\n"\\]/g;function rt(l){return l.replace($r,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function ti(l,t,e,a,n,u,i,c){l.name="",i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"?l.type=i:l.removeAttribute("type"),t!=null?i==="number"?(t===0&&l.value===""||l.value!=t)&&(l.value=""+dt(t)):l.value!==""+dt(t)&&(l.value=""+dt(t)):i!=="submit"&&i!=="reset"||l.removeAttribute("value"),t!=null?ei(l,i,dt(t)):e!=null?ei(l,i,dt(e)):a!=null&&l.removeAttribute("value"),n==null&&u!=null&&(l.defaultChecked=!!u),n!=null&&(l.checked=n&&typeof n!="function"&&typeof n!="symbol"),c!=null&&typeof c!="function"&&typeof c!="symbol"&&typeof c!="boolean"?l.name=""+dt(c):l.removeAttribute("name")}function Uf(l,t,e,a,n,u,i,c){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(l.type=u),t!=null||e!=null){if(!(u!=="submit"&&u!=="reset"||t!=null)){li(l);return}e=e!=null?""+dt(e):"",t=t!=null?""+dt(t):e,c||t===l.value||(l.value=t),l.defaultValue=t}a=a??n,a=typeof a!="function"&&typeof a!="symbol"&&!!a,l.checked=c?l.checked:!!a,l.defaultChecked=!!a,i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"&&(l.name=i),li(l)}function ei(l,t,e){t==="number"&&Cn(l.ownerDocument)===l||l.defaultValue===""+e||(l.defaultValue=""+e)}function $e(l,t,e,a){if(l=l.options,t){t={};for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ci=!1;if(Bt)try{var Ha={};Object.defineProperty(Ha,"passive",{get:function(){ci=!0}}),window.addEventListener("test",Ha,Ha),window.removeEventListener("test",Ha,Ha)}catch{ci=!1}var le=null,fi=null,Rn=null;function Xf(){if(Rn)return Rn;var l,t=fi,e=t.length,a,n="value"in le?le.value:le.textContent,u=n.length;for(l=0;l=Ya),Jf=" ",wf=!1;function kf(l,t){switch(l){case"keyup":return xh.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $f(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Pe=!1;function Eh(l,t){switch(l){case"compositionend":return $f(t);case"keypress":return t.which!==32?null:(wf=!0,Jf);case"textInput":return l=t.data,l===Jf&&wf?null:l;default:return null}}function _h(l,t){if(Pe)return l==="compositionend"||!hi&&kf(l,t)?(l=Xf(),Rn=fi=le=null,Pe=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:e,offset:t-l};l=a}l:{for(;e;){if(e.nextSibling){e=e.nextSibling;break l}e=e.parentNode}e=void 0}e=as(e)}}function us(l,t){return l&&t?l===t?!0:l&&l.nodeType===3?!1:t&&t.nodeType===3?us(l,t.parentNode):"contains"in l?l.contains(t):l.compareDocumentPosition?!!(l.compareDocumentPosition(t)&16):!1:!1}function is(l){l=l!=null&&l.ownerDocument!=null&&l.ownerDocument.defaultView!=null?l.ownerDocument.defaultView:window;for(var t=Cn(l.document);t instanceof l.HTMLIFrameElement;){try{var e=typeof t.contentWindow.location.href=="string"}catch{e=!1}if(e)l=t.contentWindow;else break;t=Cn(l.document)}return t}function vi(l){var t=l&&l.nodeName&&l.nodeName.toLowerCase();return t&&(t==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||t==="textarea"||l.contentEditable==="true")}var Rh=Bt&&"documentMode"in document&&11>=document.documentMode,la=null,gi=null,Za=null,Si=!1;function cs(l,t,e){var a=e.window===e?e.document:e.nodeType===9?e:e.ownerDocument;Si||la==null||la!==Cn(a)||(a=la,"selectionStart"in a&&vi(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),Za&&Qa(Za,a)||(Za=a,a=ju(gi,"onSelect"),0>=i,n-=i,Nt=1<<32-tt(t)+n|e<w?(ll=q,q=null):ll=q.sibling;var il=g(m,q,y[w],z);if(il===null){q===null&&(q=ll);break}l&&q&&il.alternate===null&&t(m,q),o=u(il,o,w),ul===null?G=il:ul.sibling=il,ul=il,q=ll}if(w===y.length)return e(m,q),al&&Yt(m,w),G;if(q===null){for(;ww?(ll=q,q=null):ll=q.sibling;var ze=g(m,q,il.value,z);if(ze===null){q===null&&(q=ll);break}l&&q&&ze.alternate===null&&t(m,q),o=u(ze,o,w),ul===null?G=ze:ul.sibling=ze,ul=ze,q=ll}if(il.done)return e(m,q),al&&Yt(m,w),G;if(q===null){for(;!il.done;w++,il=y.next())il=x(m,il.value,z),il!==null&&(o=u(il,o,w),ul===null?G=il:ul.sibling=il,ul=il);return al&&Yt(m,w),G}for(q=a(q);!il.done;w++,il=y.next())il=S(q,m,w,il.value,z),il!==null&&(l&&il.alternate!==null&&q.delete(il.key===null?w:il.key),o=u(il,o,w),ul===null?G=il:ul.sibling=il,ul=il);return l&&q.forEach(function(ly){return t(m,ly)}),al&&Yt(m,w),G}function ml(m,o,y,z){if(typeof y=="object"&&y!==null&&y.type===nl&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case I:l:{for(var G=y.key;o!==null;){if(o.key===G){if(G=y.type,G===nl){if(o.tag===7){e(m,o.sibling),z=n(o,y.props.children),z.return=m,m=z;break l}}else if(o.elementType===G||typeof G=="object"&&G!==null&&G.$$typeof===Vl&&Be(G)===o.type){e(m,o.sibling),z=n(o,y.props),ka(z,y),z.return=m,m=z;break l}e(m,o);break}else t(m,o);o=o.sibling}y.type===nl?(z=De(y.props.children,m.mode,z,y.key),z.return=m,m=z):(z=Vn(y.type,y.key,y.props,null,m.mode,z),ka(z,y),z.return=m,m=z)}return i(m);case L:l:{for(G=y.key;o!==null;){if(o.key===G)if(o.tag===4&&o.stateNode.containerInfo===y.containerInfo&&o.stateNode.implementation===y.implementation){e(m,o.sibling),z=n(o,y.children||[]),z.return=m,m=z;break l}else{e(m,o);break}else t(m,o);o=o.sibling}z=Ei(y,m.mode,z),z.return=m,m=z}return i(m);case Vl:return y=Be(y),ml(m,o,y,z)}if(zt(y))return R(m,o,y,z);if(Kl(y)){if(G=Kl(y),typeof G!="function")throw Error(h(150));return y=G.call(y),X(m,o,y,z)}if(typeof y.then=="function")return ml(m,o,Fn(y),z);if(y.$$typeof===Gl)return ml(m,o,wn(m,y),z);In(m,y)}return typeof y=="string"&&y!==""||typeof y=="number"||typeof y=="bigint"?(y=""+y,o!==null&&o.tag===6?(e(m,o.sibling),z=n(o,y),z.return=m,m=z):(e(m,o),z=Ai(y,m.mode,z),z.return=m,m=z),i(m)):e(m,o)}return function(m,o,y,z){try{wa=0;var G=ml(m,o,y,z);return da=null,G}catch(q){if(q===oa||q===$n)throw q;var ul=at(29,q,null,m.mode);return ul.lanes=z,ul.return=m,ul}finally{}}}var Ye=Ms(!0),Ds=Ms(!1),ue=!1;function qi(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Yi(l,t){l=l.updateQueue,t.updateQueue===l&&(t.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function ie(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function ce(l,t,e){var a=l.updateQueue;if(a===null)return null;if(a=a.shared,(cl&2)!==0){var n=a.pending;return n===null?t.next=t:(t.next=n.next,n.next=t),a.pending=t,t=Ln(l),ms(l,null,e),t}return Zn(l,a,t,e),Ln(l)}function $a(l,t,e){if(t=t.updateQueue,t!==null&&(t=t.shared,(e&4194048)!==0)){var a=t.lanes;a&=l.pendingLanes,e|=a,t.lanes=e,zf(l,e)}}function Gi(l,t){var e=l.updateQueue,a=l.alternate;if(a!==null&&(a=a.updateQueue,e===a)){var n=null,u=null;if(e=e.firstBaseUpdate,e!==null){do{var i={lane:e.lane,tag:e.tag,payload:e.payload,callback:null,next:null};u===null?n=u=i:u=u.next=i,e=e.next}while(e!==null);u===null?n=u=t:u=u.next=t}else n=u=t;e={baseState:a.baseState,firstBaseUpdate:n,lastBaseUpdate:u,shared:a.shared,callbacks:a.callbacks},l.updateQueue=e;return}l=e.lastBaseUpdate,l===null?e.firstBaseUpdate=t:l.next=t,e.lastBaseUpdate=t}var Xi=!1;function Wa(){if(Xi){var l=sa;if(l!==null)throw l}}function Fa(l,t,e,a){Xi=!1;var n=l.updateQueue;ue=!1;var u=n.firstBaseUpdate,i=n.lastBaseUpdate,c=n.shared.pending;if(c!==null){n.shared.pending=null;var s=c,v=s.next;s.next=null,i===null?u=v:i.next=v,i=s;var b=l.alternate;b!==null&&(b=b.updateQueue,c=b.lastBaseUpdate,c!==i&&(c===null?b.firstBaseUpdate=v:c.next=v,b.lastBaseUpdate=s))}if(u!==null){var x=n.baseState;i=0,b=v=s=null,c=u;do{var g=c.lane&-536870913,S=g!==c.lane;if(S?(P&g)===g:(a&g)===g){g!==0&&g===fa&&(Xi=!0),b!==null&&(b=b.next={lane:0,tag:c.tag,payload:c.payload,callback:null,next:null});l:{var R=l,X=c;g=t;var ml=e;switch(X.tag){case 1:if(R=X.payload,typeof R=="function"){x=R.call(ml,x,g);break l}x=R;break l;case 3:R.flags=R.flags&-65537|128;case 0:if(R=X.payload,g=typeof R=="function"?R.call(ml,x,g):R,g==null)break l;x=j({},x,g);break l;case 2:ue=!0}}g=c.callback,g!==null&&(l.flags|=64,S&&(l.flags|=8192),S=n.callbacks,S===null?n.callbacks=[g]:S.push(g))}else S={lane:g,tag:c.tag,payload:c.payload,callback:c.callback,next:null},b===null?(v=b=S,s=x):b=b.next=S,i|=g;if(c=c.next,c===null){if(c=n.shared.pending,c===null)break;S=c,c=S.next,S.next=null,n.lastBaseUpdate=S,n.shared.pending=null}}while(!0);b===null&&(s=x),n.baseState=s,n.firstBaseUpdate=v,n.lastBaseUpdate=b,u===null&&(n.shared.lanes=0),re|=i,l.lanes=i,l.memoizedState=x}}function Cs(l,t){if(typeof l!="function")throw Error(h(191,l));l.call(t)}function Us(l,t){var e=l.callbacks;if(e!==null)for(l.callbacks=null,l=0;lu?u:8;var i=T.T,c={};T.T=c,uc(l,!1,t,e);try{var s=n(),v=T.S;if(v!==null&&v(c,s),s!==null&&typeof s=="object"&&typeof s.then=="function"){var b=Lh(s,a);ln(l,t,b,ft(l))}else ln(l,t,a,ft(l))}catch(x){ln(l,t,{then:function(){},status:"rejected",reason:x},ft())}finally{D.p=u,i!==null&&c.types!==null&&(i.types=c.types),T.T=i}}function $h(){}function ac(l,t,e,a){if(l.tag!==5)throw Error(h(476));var n=ro(l).queue;oo(l,n,t,Q,e===null?$h:function(){return ho(l),e(a)})}function ro(l){var t=l.memoizedState;if(t!==null)return t;t={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zt,lastRenderedState:Q},next:null};var e={};return t.next={memoizedState:e,baseState:e,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zt,lastRenderedState:e},next:null},l.memoizedState=t,l=l.alternate,l!==null&&(l.memoizedState=t),t}function ho(l){var t=ro(l);t.next===null&&(t=l.alternate.memoizedState),ln(l,t.next.queue,{},ft())}function nc(){return Bl(Sn)}function mo(){return El().memoizedState}function yo(){return El().memoizedState}function Wh(l){for(var t=l.return;t!==null;){switch(t.tag){case 24:case 3:var e=ft();l=ie(e);var a=ce(t,l,e);a!==null&&(Il(a,t,e),$a(a,t,e)),t={cache:Ui()},l.payload=t;return}t=t.return}}function Fh(l,t,e){var a=ft();e={lane:a,revertLane:0,gesture:null,action:e,hasEagerState:!1,eagerState:null,next:null},fu(l)?go(t,e):(e=zi(l,t,e,a),e!==null&&(Il(e,l,a),So(e,t,a)))}function vo(l,t,e){var a=ft();ln(l,t,e,a)}function ln(l,t,e,a){var n={lane:a,revertLane:0,gesture:null,action:e,hasEagerState:!1,eagerState:null,next:null};if(fu(l))go(t,n);else{var u=l.alternate;if(l.lanes===0&&(u===null||u.lanes===0)&&(u=t.lastRenderedReducer,u!==null))try{var i=t.lastRenderedState,c=u(i,e);if(n.hasEagerState=!0,n.eagerState=c,et(c,i))return Zn(l,t,n,0),vl===null&&Qn(),!1}catch{}finally{}if(e=zi(l,t,n,a),e!==null)return Il(e,l,a),So(e,t,a),!0}return!1}function uc(l,t,e,a){if(a={lane:2,revertLane:qc(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},fu(l)){if(t)throw Error(h(479))}else t=zi(l,e,a,2),t!==null&&Il(t,l,2)}function fu(l){var t=l.alternate;return l===J||t!==null&&t===J}function go(l,t){ha=tu=!0;var e=l.pending;e===null?t.next=t:(t.next=e.next,e.next=t),l.pending=t}function So(l,t,e){if((e&4194048)!==0){var a=t.lanes;a&=l.pendingLanes,e|=a,t.lanes=e,zf(l,e)}}var tn={readContext:Bl,use:nu,useCallback:Tl,useContext:Tl,useEffect:Tl,useImperativeHandle:Tl,useLayoutEffect:Tl,useInsertionEffect:Tl,useMemo:Tl,useReducer:Tl,useRef:Tl,useState:Tl,useDebugValue:Tl,useDeferredValue:Tl,useTransition:Tl,useSyncExternalStore:Tl,useId:Tl,useHostTransitionStatus:Tl,useFormState:Tl,useActionState:Tl,useOptimistic:Tl,useMemoCache:Tl,useCacheRefresh:Tl};tn.useEffectEvent=Tl;var bo={readContext:Bl,use:nu,useCallback:function(l,t){return Zl().memoizedState=[l,t===void 0?null:t],l},useContext:Bl,useEffect:to,useImperativeHandle:function(l,t,e){e=e!=null?e.concat([l]):null,iu(4194308,4,uo.bind(null,t,l),e)},useLayoutEffect:function(l,t){return iu(4194308,4,l,t)},useInsertionEffect:function(l,t){iu(4,2,l,t)},useMemo:function(l,t){var e=Zl();t=t===void 0?null:t;var a=l();if(Ge){It(!0);try{l()}finally{It(!1)}}return e.memoizedState=[a,t],a},useReducer:function(l,t,e){var a=Zl();if(e!==void 0){var n=e(t);if(Ge){It(!0);try{e(t)}finally{It(!1)}}}else n=t;return a.memoizedState=a.baseState=n,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:n},a.queue=l,l=l.dispatch=Fh.bind(null,J,l),[a.memoizedState,l]},useRef:function(l){var t=Zl();return l={current:l},t.memoizedState=l},useState:function(l){l=Ii(l);var t=l.queue,e=vo.bind(null,J,t);return t.dispatch=e,[l.memoizedState,e]},useDebugValue:tc,useDeferredValue:function(l,t){var e=Zl();return ec(e,l,t)},useTransition:function(){var l=Ii(!1);return l=oo.bind(null,J,l.queue,!0,!1),Zl().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,t,e){var a=J,n=Zl();if(al){if(e===void 0)throw Error(h(407));e=e()}else{if(e=t(),vl===null)throw Error(h(349));(P&127)!==0||Gs(a,t,e)}n.memoizedState=e;var u={value:e,getSnapshot:t};return n.queue=u,to(Qs.bind(null,a,u,l),[l]),a.flags|=2048,ya(9,{destroy:void 0},Xs.bind(null,a,u,e,t),null),e},useId:function(){var l=Zl(),t=vl.identifierPrefix;if(al){var e=Mt,a=Nt;e=(a&~(1<<32-tt(a)-1)).toString(32)+e,t="_"+t+"R_"+e,e=eu++,0<\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof a.is=="string"?i.createElement("select",{is:a.is}):i.createElement("select"),a.multiple?u.multiple=!0:a.size&&(u.size=a.size);break;default:u=typeof a.is=="string"?i.createElement(n,{is:a.is}):i.createElement(n)}}u[Rl]=t,u[Jl]=a;l:for(i=t.child;i!==null;){if(i.tag===5||i.tag===6)u.appendChild(i.stateNode);else if(i.tag!==4&&i.tag!==27&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===t)break l;for(;i.sibling===null;){if(i.return===null||i.return===t)break l;i=i.return}i.sibling.return=i.return,i=i.sibling}t.stateNode=u;l:switch(Yl(u,n,a),n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break l;case"img":a=!0;break l;default:a=!1}a&&Vt(t)}}return Sl(t),bc(t,t.type,l===null?null:l.memoizedProps,t.pendingProps,e),null;case 6:if(l&&t.stateNode!=null)l.memoizedProps!==a&&Vt(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(h(166));if(l=$.current,ia(t)){if(l=t.stateNode,e=t.memoizedProps,a=null,n=Hl,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}l[Rl]=t,l=!!(l.nodeValue===e||a!==null&&a.suppressHydrationWarning===!0||Yd(l.nodeValue,e)),l||ae(t,!0)}else l=Ou(l).createTextNode(a),l[Rl]=t,t.stateNode=l}return Sl(t),null;case 31:if(e=t.memoizedState,l===null||l.memoizedState!==null){if(a=ia(t),e!==null){if(l===null){if(!a)throw Error(h(318));if(l=t.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(h(557));l[Rl]=t}else Ce(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Sl(t),l=!1}else e=Ni(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=e),l=!0;if(!l)return t.flags&256?(ut(t),t):(ut(t),null);if((t.flags&128)!==0)throw Error(h(558))}return Sl(t),null;case 13:if(a=t.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(n=ia(t),a!==null&&a.dehydrated!==null){if(l===null){if(!n)throw Error(h(318));if(n=t.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(h(317));n[Rl]=t}else Ce(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Sl(t),n=!1}else n=Ni(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=n),n=!0;if(!n)return t.flags&256?(ut(t),t):(ut(t),null)}return ut(t),(t.flags&128)!==0?(t.lanes=e,t):(e=a!==null,l=l!==null&&l.memoizedState!==null,e&&(a=t.child,n=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(n=a.alternate.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==n&&(a.flags|=2048)),e!==l&&e&&(t.child.flags|=8192),hu(t,t.updateQueue),Sl(t),null);case 4:return xl(),l===null&&Qc(t.stateNode.containerInfo),Sl(t),null;case 10:return Xt(t.type),Sl(t),null;case 19:if(A(Al),a=t.memoizedState,a===null)return Sl(t),null;if(n=(t.flags&128)!==0,u=a.rendering,u===null)if(n)an(a,!1);else{if(zl!==0||l!==null&&(l.flags&128)!==0)for(l=t.child;l!==null;){if(u=lu(l),u!==null){for(t.flags|=128,an(a,!1),l=u.updateQueue,t.updateQueue=l,hu(t,l),t.subtreeFlags=0,l=e,e=t.child;e!==null;)ys(e,l),e=e.sibling;return C(Al,Al.current&1|2),al&&Yt(t,a.treeForkCount),t.child}l=l.sibling}a.tail!==null&&Pl()>Su&&(t.flags|=128,n=!0,an(a,!1),t.lanes=4194304)}else{if(!n)if(l=lu(u),l!==null){if(t.flags|=128,n=!0,l=l.updateQueue,t.updateQueue=l,hu(t,l),an(a,!0),a.tail===null&&a.tailMode==="hidden"&&!u.alternate&&!al)return Sl(t),null}else 2*Pl()-a.renderingStartTime>Su&&e!==536870912&&(t.flags|=128,n=!0,an(a,!1),t.lanes=4194304);a.isBackwards?(u.sibling=t.child,t.child=u):(l=a.last,l!==null?l.sibling=u:t.child=u,a.last=u)}return a.tail!==null?(l=a.tail,a.rendering=l,a.tail=l.sibling,a.renderingStartTime=Pl(),l.sibling=null,e=Al.current,C(Al,n?e&1|2:e&1),al&&Yt(t,a.treeForkCount),l):(Sl(t),null);case 22:case 23:return ut(t),Zi(),a=t.memoizedState!==null,l!==null?l.memoizedState!==null!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?(e&536870912)!==0&&(t.flags&128)===0&&(Sl(t),t.subtreeFlags&6&&(t.flags|=8192)):Sl(t),e=t.updateQueue,e!==null&&hu(t,e.retryQueue),e=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(e=l.memoizedState.cachePool.pool),a=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),a!==e&&(t.flags|=2048),l!==null&&A(He),null;case 24:return e=null,l!==null&&(e=l.memoizedState.cache),t.memoizedState.cache!==e&&(t.flags|=2048),Xt(_l),Sl(t),null;case 25:return null;case 30:return null}throw Error(h(156,t.tag))}function em(l,t){switch(ji(t),t.tag){case 1:return l=t.flags,l&65536?(t.flags=l&-65537|128,t):null;case 3:return Xt(_l),xl(),l=t.flags,(l&65536)!==0&&(l&128)===0?(t.flags=l&-65537|128,t):null;case 26:case 27:case 5:return An(t),null;case 31:if(t.memoizedState!==null){if(ut(t),t.alternate===null)throw Error(h(340));Ce()}return l=t.flags,l&65536?(t.flags=l&-65537|128,t):null;case 13:if(ut(t),l=t.memoizedState,l!==null&&l.dehydrated!==null){if(t.alternate===null)throw Error(h(340));Ce()}return l=t.flags,l&65536?(t.flags=l&-65537|128,t):null;case 19:return A(Al),null;case 4:return xl(),null;case 10:return Xt(t.type),null;case 22:case 23:return ut(t),Zi(),l!==null&&A(He),l=t.flags,l&65536?(t.flags=l&-65537|128,t):null;case 24:return Xt(_l),null;case 25:return null;default:return null}}function Lo(l,t){switch(ji(t),t.tag){case 3:Xt(_l),xl();break;case 26:case 27:case 5:An(t);break;case 4:xl();break;case 31:t.memoizedState!==null&&ut(t);break;case 13:ut(t);break;case 19:A(Al);break;case 10:Xt(t.type);break;case 22:case 23:ut(t),Zi(),l!==null&&A(He);break;case 24:Xt(_l)}}function nn(l,t){try{var e=t.updateQueue,a=e!==null?e.lastEffect:null;if(a!==null){var n=a.next;e=n;do{if((e.tag&l)===l){a=void 0;var u=e.create,i=e.inst;a=u(),i.destroy=a}e=e.next}while(e!==n)}}catch(c){ol(t,t.return,c)}}function oe(l,t,e){try{var a=t.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var u=n.next;a=u;do{if((a.tag&l)===l){var i=a.inst,c=i.destroy;if(c!==void 0){i.destroy=void 0,n=t;var s=e,v=c;try{v()}catch(b){ol(n,s,b)}}}a=a.next}while(a!==u)}}catch(b){ol(t,t.return,b)}}function Vo(l){var t=l.updateQueue;if(t!==null){var e=l.stateNode;try{Us(t,e)}catch(a){ol(l,l.return,a)}}}function Ko(l,t,e){e.props=Xe(l.type,l.memoizedProps),e.state=l.memoizedState;try{e.componentWillUnmount()}catch(a){ol(l,t,a)}}function un(l,t){try{var e=l.ref;if(e!==null){switch(l.tag){case 26:case 27:case 5:var a=l.stateNode;break;case 30:a=l.stateNode;break;default:a=l.stateNode}typeof e=="function"?l.refCleanup=e(a):e.current=a}}catch(n){ol(l,t,n)}}function Dt(l,t){var e=l.ref,a=l.refCleanup;if(e!==null)if(typeof a=="function")try{a()}catch(n){ol(l,t,n)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof e=="function")try{e(null)}catch(n){ol(l,t,n)}else e.current=null}function Jo(l){var t=l.type,e=l.memoizedProps,a=l.stateNode;try{l:switch(t){case"button":case"input":case"select":case"textarea":e.autoFocus&&a.focus();break l;case"img":e.src?a.src=e.src:e.srcSet&&(a.srcset=e.srcSet)}}catch(n){ol(l,l.return,n)}}function pc(l,t,e){try{var a=l.stateNode;Am(a,l.type,e,t),a[Jl]=t}catch(n){ol(l,l.return,n)}}function wo(l){return l.tag===5||l.tag===3||l.tag===26||l.tag===27&&ge(l.type)||l.tag===4}function Tc(l){l:for(;;){for(;l.sibling===null;){if(l.return===null||wo(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.tag===27&&ge(l.type)||l.flags&2||l.child===null||l.tag===4)continue l;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function zc(l,t,e){var a=l.tag;if(a===5||a===6)l=l.stateNode,t?(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e).insertBefore(l,t):(t=e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,t.appendChild(l),e=e._reactRootContainer,e!=null||t.onclick!==null||(t.onclick=Ht));else if(a!==4&&(a===27&&ge(l.type)&&(e=l.stateNode,t=null),l=l.child,l!==null))for(zc(l,t,e),l=l.sibling;l!==null;)zc(l,t,e),l=l.sibling}function mu(l,t,e){var a=l.tag;if(a===5||a===6)l=l.stateNode,t?e.insertBefore(l,t):e.appendChild(l);else if(a!==4&&(a===27&&ge(l.type)&&(e=l.stateNode),l=l.child,l!==null))for(mu(l,t,e),l=l.sibling;l!==null;)mu(l,t,e),l=l.sibling}function ko(l){var t=l.stateNode,e=l.memoizedProps;try{for(var a=l.type,n=t.attributes;n.length;)t.removeAttributeNode(n[0]);Yl(t,a,e),t[Rl]=l,t[Jl]=e}catch(u){ol(l,l.return,u)}}var Kt=!1,Nl=!1,xc=!1,$o=typeof WeakSet=="function"?WeakSet:Set,Ul=null;function am(l,t){if(l=l.containerInfo,Vc=Hu,l=is(l),vi(l)){if("selectionStart"in l)var e={start:l.selectionStart,end:l.selectionEnd};else l:{e=(e=l.ownerDocument)&&e.defaultView||window;var a=e.getSelection&&e.getSelection();if(a&&a.rangeCount!==0){e=a.anchorNode;var n=a.anchorOffset,u=a.focusNode;a=a.focusOffset;try{e.nodeType,u.nodeType}catch{e=null;break l}var i=0,c=-1,s=-1,v=0,b=0,x=l,g=null;t:for(;;){for(var S;x!==e||n!==0&&x.nodeType!==3||(c=i+n),x!==u||a!==0&&x.nodeType!==3||(s=i+a),x.nodeType===3&&(i+=x.nodeValue.length),(S=x.firstChild)!==null;)g=x,x=S;for(;;){if(x===l)break t;if(g===e&&++v===n&&(c=i),g===u&&++b===a&&(s=i),(S=x.nextSibling)!==null)break;x=g,g=x.parentNode}x=S}e=c===-1||s===-1?null:{start:c,end:s}}else e=null}e=e||{start:0,end:0}}else e=null;for(Kc={focusedElem:l,selectionRange:e},Hu=!1,Ul=t;Ul!==null;)if(t=Ul,l=t.child,(t.subtreeFlags&1028)!==0&&l!==null)l.return=t,Ul=l;else for(;Ul!==null;){switch(t=Ul,u=t.alternate,l=t.flags,t.tag){case 0:if((l&4)!==0&&(l=t.updateQueue,l=l!==null?l.events:null,l!==null))for(e=0;e title"))),Yl(u,a,e),u[Rl]=l,Cl(u),a=u;break l;case"link":var i=tr("link","href",n).get(a+(e.href||""));if(i){for(var c=0;cml&&(i=ml,ml=X,X=i);var m=ns(c,X),o=ns(c,ml);if(m&&o&&(S.rangeCount!==1||S.anchorNode!==m.node||S.anchorOffset!==m.offset||S.focusNode!==o.node||S.focusOffset!==o.offset)){var y=x.createRange();y.setStart(m.node,m.offset),S.removeAllRanges(),X>ml?(S.addRange(y),S.extend(o.node,o.offset)):(y.setEnd(o.node,o.offset),S.addRange(y))}}}}for(x=[],S=c;S=S.parentNode;)S.nodeType===1&&x.push({element:S,left:S.scrollLeft,top:S.scrollTop});for(typeof c.focus=="function"&&c.focus(),c=0;ce?32:e,T.T=null,e=Mc,Mc=null;var u=me,i=Wt;if(Dl=0,pa=me=null,Wt=0,(cl&6)!==0)throw Error(h(331));var c=cl;if(cl|=4,id(u.current),ad(u,u.current,i,e),cl=c,rn(0,!1),lt&&typeof lt.onPostCommitFiberRoot=="function")try{lt.onPostCommitFiberRoot(Na,u)}catch{}return!0}finally{D.p=n,T.T=a,Ad(l,t)}}function _d(l,t,e){t=mt(e,t),t=sc(l.stateNode,t,2),l=ce(l,t,2),l!==null&&(Da(l,2),Ct(l))}function ol(l,t,e){if(l.tag===3)_d(l,l,e);else for(;t!==null;){if(t.tag===3){_d(t,l,e);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(he===null||!he.has(a))){l=mt(e,l),e=jo(2),a=ce(t,e,2),a!==null&&(Oo(e,a,t,l),Da(a,2),Ct(a));break}}t=t.return}}function Rc(l,t,e){var a=l.pingCache;if(a===null){a=l.pingCache=new im;var n=new Set;a.set(t,n)}else n=a.get(t),n===void 0&&(n=new Set,a.set(t,n));n.has(e)||(_c=!0,n.add(e),l=dm.bind(null,l,t,e),t.then(l,l))}function dm(l,t,e){var a=l.pingCache;a!==null&&a.delete(t),l.pingedLanes|=l.suspendedLanes&e,l.warmLanes&=~e,vl===l&&(P&e)===e&&(zl===4||zl===3&&(P&62914560)===P&&300>Pl()-gu?(cl&2)===0&&Ta(l,0):jc|=e,ba===P&&(ba=0)),Ct(l)}function jd(l,t){t===0&&(t=pf()),l=Me(l,t),l!==null&&(Da(l,t),Ct(l))}function rm(l){var t=l.memoizedState,e=0;t!==null&&(e=t.retryLane),jd(l,e)}function hm(l,t){var e=0;switch(l.tag){case 31:case 13:var a=l.stateNode,n=l.memoizedState;n!==null&&(e=n.retryLane);break;case 19:a=l.stateNode;break;case 22:a=l.stateNode._retryCache;break;default:throw Error(h(314))}a!==null&&a.delete(t),jd(l,e)}function mm(l,t){return wu(l,t)}var Au=null,xa=null,Hc=!1,Eu=!1,Bc=!1,ve=0;function Ct(l){l!==xa&&l.next===null&&(xa===null?Au=xa=l:xa=xa.next=l),Eu=!0,Hc||(Hc=!0,vm())}function rn(l,t){if(!Bc&&Eu){Bc=!0;do for(var e=!1,a=Au;a!==null;){if(l!==0){var n=a.pendingLanes;if(n===0)var u=0;else{var i=a.suspendedLanes,c=a.pingedLanes;u=(1<<31-tt(42|l)+1)-1,u&=n&~(i&~c),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(e=!0,Dd(a,u))}else u=P,u=Nn(a,a===vl?u:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(u&3)===0||Ma(a,u)||(e=!0,Dd(a,u));a=a.next}while(e);Bc=!1}}function ym(){Od()}function Od(){Eu=Hc=!1;var l=0;ve!==0&&_m()&&(l=ve);for(var t=Pl(),e=null,a=Au;a!==null;){var n=a.next,u=Nd(a,t);u===0?(a.next=null,e===null?Au=n:e.next=n,n===null&&(xa=e)):(e=a,(l!==0||(u&3)!==0)&&(Eu=!0)),a=n}Dl!==0&&Dl!==5||rn(l),ve!==0&&(ve=0)}function Nd(l,t){for(var e=l.suspendedLanes,a=l.pingedLanes,n=l.expirationTimes,u=l.pendingLanes&-62914561;0c)break;var b=s.transferSize,x=s.initiatorType;b&&Gd(x)&&(s=s.responseEnd,i+=b*(s"u"?null:document;function Fd(l,t,e){var a=Aa;if(a&&typeof t=="string"&&t){var n=rt(t);n='link[rel="'+l+'"][href="'+n+'"]',typeof e=="string"&&(n+='[crossorigin="'+e+'"]'),Wd.has(n)||(Wd.add(n),l={rel:l,crossOrigin:e,href:t},a.querySelector(n)===null&&(t=a.createElement("link"),Yl(t,"link",l),Cl(t),a.head.appendChild(t)))}}function Hm(l){Ft.D(l),Fd("dns-prefetch",l,null)}function Bm(l,t){Ft.C(l,t),Fd("preconnect",l,t)}function qm(l,t,e){Ft.L(l,t,e);var a=Aa;if(a&&l&&t){var n='link[rel="preload"][as="'+rt(t)+'"]';t==="image"&&e&&e.imageSrcSet?(n+='[imagesrcset="'+rt(e.imageSrcSet)+'"]',typeof e.imageSizes=="string"&&(n+='[imagesizes="'+rt(e.imageSizes)+'"]')):n+='[href="'+rt(l)+'"]';var u=n;switch(t){case"style":u=Ea(l);break;case"script":u=_a(l)}pt.has(u)||(l=j({rel:"preload",href:t==="image"&&e&&e.imageSrcSet?void 0:l,as:t},e),pt.set(u,l),a.querySelector(n)!==null||t==="style"&&a.querySelector(vn(u))||t==="script"&&a.querySelector(gn(u))||(t=a.createElement("link"),Yl(t,"link",l),Cl(t),a.head.appendChild(t)))}}function Ym(l,t){Ft.m(l,t);var e=Aa;if(e&&l){var a=t&&typeof t.as=="string"?t.as:"script",n='link[rel="modulepreload"][as="'+rt(a)+'"][href="'+rt(l)+'"]',u=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=_a(l)}if(!pt.has(u)&&(l=j({rel:"modulepreload",href:l},t),pt.set(u,l),e.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(e.querySelector(gn(u)))return}a=e.createElement("link"),Yl(a,"link",l),Cl(a),e.head.appendChild(a)}}}function Gm(l,t,e){Ft.S(l,t,e);var a=Aa;if(a&&l){var n=we(a).hoistableStyles,u=Ea(l);t=t||"default";var i=n.get(u);if(!i){var c={loading:0,preload:null};if(i=a.querySelector(vn(u)))c.loading=5;else{l=j({rel:"stylesheet",href:l,"data-precedence":t},e),(e=pt.get(u))&&Ic(l,e);var s=i=a.createElement("link");Cl(s),Yl(s,"link",l),s._p=new Promise(function(v,b){s.onload=v,s.onerror=b}),s.addEventListener("load",function(){c.loading|=1}),s.addEventListener("error",function(){c.loading|=2}),c.loading|=4,Mu(i,t,a)}i={type:"stylesheet",instance:i,count:1,state:c},n.set(u,i)}}}function Xm(l,t){Ft.X(l,t);var e=Aa;if(e&&l){var a=we(e).hoistableScripts,n=_a(l),u=a.get(n);u||(u=e.querySelector(gn(n)),u||(l=j({src:l,async:!0},t),(t=pt.get(n))&&Pc(l,t),u=e.createElement("script"),Cl(u),Yl(u,"link",l),e.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function Qm(l,t){Ft.M(l,t);var e=Aa;if(e&&l){var a=we(e).hoistableScripts,n=_a(l),u=a.get(n);u||(u=e.querySelector(gn(n)),u||(l=j({src:l,async:!0,type:"module"},t),(t=pt.get(n))&&Pc(l,t),u=e.createElement("script"),Cl(u),Yl(u,"link",l),e.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function Id(l,t,e,a){var n=(n=$.current)?Nu(n):null;if(!n)throw Error(h(446));switch(l){case"meta":case"title":return null;case"style":return typeof e.precedence=="string"&&typeof e.href=="string"?(t=Ea(e.href),e=we(n).hoistableStyles,a=e.get(t),a||(a={type:"style",instance:null,count:0,state:null},e.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(e.rel==="stylesheet"&&typeof e.href=="string"&&typeof e.precedence=="string"){l=Ea(e.href);var u=we(n).hoistableStyles,i=u.get(l);if(i||(n=n.ownerDocument||n,i={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(l,i),(u=n.querySelector(vn(l)))&&!u._p&&(i.instance=u,i.state.loading=5),pt.has(l)||(e={rel:"preload",as:"style",href:e.href,crossOrigin:e.crossOrigin,integrity:e.integrity,media:e.media,hrefLang:e.hrefLang,referrerPolicy:e.referrerPolicy},pt.set(l,e),u||Zm(n,l,e,i.state))),t&&a===null)throw Error(h(528,""));return i}if(t&&a!==null)throw Error(h(529,""));return null;case"script":return t=e.async,e=e.src,typeof e=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=_a(e),e=we(n).hoistableScripts,a=e.get(t),a||(a={type:"script",instance:null,count:0,state:null},e.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(h(444,l))}}function Ea(l){return'href="'+rt(l)+'"'}function vn(l){return'link[rel="stylesheet"]['+l+"]"}function Pd(l){return j({},l,{"data-precedence":l.precedence,precedence:null})}function Zm(l,t,e,a){l.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=l.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),Yl(t,"link",e),Cl(t),l.head.appendChild(t))}function _a(l){return'[src="'+rt(l)+'"]'}function gn(l){return"script[async]"+l}function lr(l,t,e){if(t.count++,t.instance===null)switch(t.type){case"style":var a=l.querySelector('style[data-href~="'+rt(e.href)+'"]');if(a)return t.instance=a,Cl(a),a;var n=j({},e,{"data-href":e.href,"data-precedence":e.precedence,href:null,precedence:null});return a=(l.ownerDocument||l).createElement("style"),Cl(a),Yl(a,"style",n),Mu(a,e.precedence,l),t.instance=a;case"stylesheet":n=Ea(e.href);var u=l.querySelector(vn(n));if(u)return t.state.loading|=4,t.instance=u,Cl(u),u;a=Pd(e),(n=pt.get(n))&&Ic(a,n),u=(l.ownerDocument||l).createElement("link"),Cl(u);var i=u;return i._p=new Promise(function(c,s){i.onload=c,i.onerror=s}),Yl(u,"link",a),t.state.loading|=4,Mu(u,e.precedence,l),t.instance=u;case"script":return u=_a(e.src),(n=l.querySelector(gn(u)))?(t.instance=n,Cl(n),n):(a=e,(n=pt.get(u))&&(a=j({},e),Pc(a,n)),l=l.ownerDocument||l,n=l.createElement("script"),Cl(n),Yl(n,"link",a),l.head.appendChild(n),t.instance=n);case"void":return null;default:throw Error(h(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,Mu(a,e.precedence,l));return t.instance}function Mu(l,t,e){for(var a=e.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,u=n,i=0;i title"):null)}function Lm(l,t,e){if(e===1||t.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return l=t.disabled,typeof t.precedence=="string"&&l==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function ar(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function Vm(l,t,e,a){if(e.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(e.state.loading&4)===0){if(e.instance===null){var n=Ea(a.href),u=t.querySelector(vn(n));if(u){t=u._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(l.count++,l=Cu.bind(l),t.then(l,l)),e.state.loading|=4,e.instance=u,Cl(u);return}u=t.ownerDocument||t,a=Pd(a),(n=pt.get(n))&&Ic(a,n),u=u.createElement("link"),Cl(u);var i=u;i._p=new Promise(function(c,s){i.onload=c,i.onerror=s}),Yl(u,"link",a),e.instance=u}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(e,t),(t=e.state.preload)&&(e.state.loading&3)===0&&(l.count++,e=Cu.bind(l),t.addEventListener("load",e),t.addEventListener("error",e))}}var lf=0;function Km(l,t){return l.stylesheets&&l.count===0&&Ru(l,l.stylesheets),0lf?50:800)+t);return l.unsuspend=e,function(){l.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function Cu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ru(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var Uu=null;function Ru(l,t){l.stylesheets=null,l.unsuspend!==null&&(l.count++,Uu=new Map,t.forEach(Jm,l),Uu=null,Cu.call(l))}function Jm(l,t){if(!(t.state.loading&4)){var e=Uu.get(l);if(e)var a=e.get(null);else{e=new Map,Uu.set(l,e);for(var n=l.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(d)}catch(N){console.error(N)}}return d(),of.exports=fy(),of.exports}var oy=sy();const dy=Nr(oy),Dr="";async function Tt(d,N){const M=await fetch(`${Dr}${d}`,{...N,credentials:"same-origin",headers:{"Content-Type":"application/json",...N==null?void 0:N.headers}});if(M.status===401)throw window.location.hash="#login",new Error("Unauthorized");if(!M.ok){const h=await M.json().catch(()=>({}));throw new Error(h.error||`HTTP ${M.status}`)}return M.json()}async function ry(d){const N=await fetch(`${Dr}${d}`,{credentials:"same-origin"});if(N.status===401)throw window.location.hash="#login",new Error("Unauthorized");if(!N.ok)throw new Error(`HTTP ${N.status}`);return N.text()}const st={login:d=>Tt("/admin/login",{method:"POST",body:JSON.stringify({token:d})}),signOutEverywhere:()=>Tt("/admin/api/sign-out-everywhere",{method:"POST"}),stats:()=>Tt("/admin/api/stats"),health:()=>Tt("/admin/api/health-indicators"),agents:()=>Tt("/admin/api/agents"),requests:(d=1,N="")=>Tt(`/admin/api/requests?page=${d}${N}`),apiKeys:()=>Tt("/admin/api/api-keys"),createApiKey:d=>Tt("/admin/api/api-keys",{method:"POST",body:JSON.stringify({name:d})}),revokeApiKey:d=>Tt("/admin/api/api-keys/revoke",{method:"POST",body:JSON.stringify({name:d})}),updateClientTtl:(d,N)=>Tt("/admin/api/update-client-ttl",{method:"POST",body:JSON.stringify({clientId:d,tokenTtl:N})}),revokeClient:d=>Tt("/admin/api/revoke-client",{method:"POST",body:JSON.stringify({clientId:d})}),calibrationProfile:d=>Tt(`/admin/api/calibration/profile${d?`?holder=${encodeURIComponent(d)}`:""}`),calibrationChart:(d,N)=>ry(`/admin/api/calibration/charts/${encodeURIComponent(d)}${N?`?holder=${encodeURIComponent(N)}`:""}`)};function hy({onLogin:d}){const[N,M]=k.useState(""),[h,_]=k.useState(""),[Y,U]=k.useState(!1),Z=async O=>{O.preventDefault(),_(""),U(!0);try{await st.login(N),M(""),d()}catch{_("Invalid token.")}finally{U(!1)}};return f.jsx("div",{className:"login-page",children:f.jsxs("div",{className:"login-box",children:[f.jsx("div",{className:"login-logo",children:"GBrain"}),f.jsxs("div",{style:{background:"rgba(136, 170, 255, 0.08)",border:"1px solid rgba(136, 170, 255, 0.2)",borderRadius:8,padding:"14px 16px",marginBottom:20,fontSize:13,lineHeight:1.5,color:"var(--text-secondary)"},children:[f.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:6},children:"🔒 This is a protected dashboard"}),"Ask your AI agent for the admin login link:",f.jsx("div",{style:{background:"rgba(0,0,0,0.3)",borderRadius:6,padding:"8px 12px",marginTop:8,fontFamily:"var(--font-mono)",fontSize:12,color:"#88aaff",wordBreak:"break-all"},children:'"Give me the GBrain admin login link"'}),f.jsx("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)"},children:"Each link is single-use. Your agent generates a fresh one each time."})]}),f.jsxs("details",{style:{marginBottom:16},children:[f.jsx("summary",{style:{cursor:"pointer",fontSize:13,color:"var(--text-muted)"},children:"Or paste bootstrap token manually"}),f.jsxs("form",{onSubmit:Z,style:{marginTop:12},children:[f.jsx("div",{style:{marginBottom:12},children:f.jsx("input",{type:"password",placeholder:"Admin Token",value:N,onChange:O=>M(O.target.value)})}),f.jsx("button",{className:"btn btn-primary",style:{width:"100%"},disabled:Y,children:Y?"Authenticating...":"Submit"}),h&&f.jsx("div",{className:"login-error",children:h})]})]})]})})}function my(){const[d,N]=k.useState({connected_agents:0,requests_today:0,active_tokens:0}),[M,h]=k.useState({expiring_soon:0,error_rate:"0%"}),[_,Y]=k.useState([]),[U,Z]=k.useState("connecting"),O=k.useRef(null);k.useEffect(()=>{st.stats().then(N).catch(()=>{}),st.health().then(h).catch(()=>{});const H=new EventSource("/admin/events");O.current=H,H.onopen=()=>Z("connected"),H.onmessage=E=>{try{const I=JSON.parse(E.data);Y(L=>[I,...L].slice(0,50))}catch{}},H.onerror=()=>{Z("disconnected"),setTimeout(()=>{Z("connecting"),H.close()},3e3)};const j=setInterval(()=>{st.stats().then(N).catch(()=>{}),st.health().then(h).catch(()=>{})},3e4);return()=>{H.close(),clearInterval(j)}},[]);const p=H=>{const j=Date.now()-new Date(H).getTime();return j<6e4?`${Math.floor(j/1e3)}s ago`:j<36e5?`${Math.floor(j/6e4)} min ago`:`${Math.floor(j/36e5)}h ago`};return f.jsxs(f.Fragment,{children:[f.jsx("h1",{className:"page-title",children:"Dashboard"}),f.jsxs("div",{style:{display:"flex",gap:24},children:[f.jsxs("div",{style:{flex:1},children:[f.jsxs("div",{className:"metrics",children:[f.jsxs("div",{className:"metric",children:[f.jsx("div",{className:"metric-value",children:d.connected_agents}),f.jsx("div",{className:"metric-label",children:"Connected Agents"})]}),f.jsxs("div",{className:"metric",children:[f.jsx("div",{className:"metric-value",children:d.requests_today}),f.jsx("div",{className:"metric-label",children:"Requests Today"})]}),f.jsxs("div",{className:"metric",children:[f.jsx("div",{className:"metric-value",children:d.active_tokens}),f.jsx("div",{className:"metric-label",children:"Active Tokens"})]})]}),f.jsxs("h2",{className:"section-title",children:["Live Activity",f.jsx("span",{style:{marginLeft:8,fontSize:10,color:U==="connected"?"var(--success)":U==="connecting"?"var(--warning)":"var(--error)"},children:U==="connected"?"● connected":U==="connecting"?"● connecting...":"● disconnected"})]}),f.jsx("div",{className:"feed",children:_.length===0?f.jsx("div",{className:"feed-empty",children:U==="connected"?"No requests yet. Agents will appear when they connect.":"Connecting..."}):f.jsxs("table",{children:[f.jsx("thead",{children:f.jsxs("tr",{children:[f.jsx("th",{children:"Agent"}),f.jsx("th",{children:"Operation"}),f.jsx("th",{children:"Scopes"}),f.jsx("th",{children:"Latency"}),f.jsx("th",{children:"Status"}),f.jsx("th",{children:"Time"})]})}),f.jsx("tbody",{children:_.map((H,j)=>f.jsxs("tr",{children:[f.jsx("td",{className:"mono",children:H.agent}),f.jsx("td",{className:"mono",children:H.operation}),f.jsx("td",{children:H.scopes.split(",").map(E=>f.jsx("span",{className:`badge badge-${E.trim()}`,style:{marginRight:4},children:E.trim()},E))}),f.jsxs("td",{className:"mono",children:[H.latency_ms," ms"]}),f.jsx("td",{children:f.jsx("span",{className:`badge badge-${H.status}`,children:H.status})}),f.jsx("td",{style:{color:"var(--text-secondary)"},children:p(H.timestamp)})]},j))})]})})]}),f.jsxs("div",{style:{width:220},children:[f.jsx("h2",{className:"section-title",children:"Token Health"}),f.jsxs("div",{className:"health-panel",children:[f.jsxs("div",{className:"health-row",children:[f.jsx("span",{style:{color:"var(--warning)"},children:"Expiring Soon"}),f.jsx("span",{className:"mono",children:M.expiring_soon})]}),f.jsxs("div",{className:"health-row",children:[f.jsx("span",{style:{color:"var(--error)"},children:"Error Rate"}),f.jsx("span",{className:"mono",children:M.error_rate})]})]})]})]})]})}const jr=["admin","read","sources_admin","users_admin","write"];function yy(d){const N=Math.floor((Date.now()-d.getTime())/1e3);return N<60?"just now":N<3600?`${Math.floor(N/60)}m ago`:N<86400?`${Math.floor(N/3600)}h ago`:`${Math.floor(N/86400)}d ago`}function vy(){const[d,N]=k.useState([]),[M,h]=k.useState(!0),[_,Y]=k.useState(!1),[U,Z]=k.useState(null),[O,p]=k.useState(!1),[H,j]=k.useState(null),[E,I]=k.useState(null);k.useEffect(()=>{L()},[]);const L=()=>{st.agents().then(N).catch(()=>{})};return f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:24},children:[f.jsx("h1",{className:"page-title",style:{marginBottom:0},children:"Agents"}),f.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[f.jsxs("label",{style:{fontSize:13,color:"var(--text-secondary)",display:"flex",alignItems:"center",gap:6,cursor:"pointer"},children:[f.jsx("input",{type:"checkbox",checked:M,onChange:nl=>h(nl.target.checked)})," Hide revoked"]}),f.jsx("button",{className:"btn btn-secondary",onClick:()=>p(!0),children:"+ API Key"}),f.jsx("button",{className:"btn btn-primary",onClick:()=>Y(!0),children:"+ OAuth Client"})]})]}),(()=>{const nl=d.filter(tl=>!M||tl.status!=="revoked");return d.length===0?f.jsx("div",{style:{textAlign:"center",padding:48,color:"var(--text-muted)"},children:"No agents registered. Register your first agent to get started."}):nl.length===0?f.jsx("div",{style:{textAlign:"center",padding:48,color:"var(--text-muted)"},children:'All agents are revoked. Uncheck "Hide revoked" to view them.'}):f.jsxs(f.Fragment,{children:[f.jsxs("table",{children:[f.jsx("thead",{children:f.jsxs("tr",{children:[f.jsx("th",{children:"Name"}),f.jsx("th",{children:"Type"}),f.jsx("th",{children:"Scopes"}),f.jsx("th",{children:"Status"}),f.jsx("th",{children:"Requests"}),f.jsx("th",{children:"Last Used"})]})}),f.jsx("tbody",{children:nl.map(tl=>f.jsxs("tr",{onClick:()=>I(tl),style:{cursor:"pointer"},children:[f.jsx("td",{style:{fontWeight:500},children:tl.name||tl.client_name}),f.jsx("td",{children:f.jsx("span",{className:`badge ${tl.auth_type==="oauth"?"badge-read":"badge-write"}`,style:{fontSize:11},children:tl.auth_type==="oauth"?"OAuth":"API Key"})}),f.jsx("td",{children:(tl.scope||"").split(" ").filter(Boolean).map(pl=>f.jsx("span",{className:`badge badge-${pl}`,style:{marginRight:4},children:pl},pl))}),f.jsx("td",{children:f.jsx("span",{className:`badge ${tl.status==="active"?"badge-success":"badge-danger"}`,children:tl.status})}),f.jsxs("td",{children:[f.jsx("span",{style:{fontWeight:500},children:tl.requests_today||0}),f.jsxs("span",{style:{color:"var(--text-muted)",fontSize:12},children:[" / ",tl.total_requests||0]})]}),f.jsx("td",{style:{color:"var(--text-secondary)"},children:tl.last_used_at?yy(new Date(tl.last_used_at)):"Never"})]},tl.id))})]}),f.jsxs("div",{style:{color:"var(--text-muted)",fontSize:13,marginTop:12},children:[d.filter(tl=>tl.status==="active").length," active / ",d.length," total"]})]})})(),_&&f.jsx(by,{onClose:()=>Y(!1),onRegistered:nl=>{Y(!1),Z(nl),L()}}),U&&f.jsx(py,{credentials:U,onClose:()=>Z(null)}),E&&f.jsx(Ty,{agent:E,onClose:()=>I(null),onRevoked:L}),O&&f.jsx(gy,{onClose:()=>p(!1),onCreated:nl=>{p(!1),j(nl),L()}}),H&&f.jsx(Sy,{token:H,onClose:()=>j(null)})]})}function gy({onClose:d,onCreated:N}){const[M,h]=k.useState(""),[_,Y]=k.useState(!1),[U,Z]=k.useState(""),O=async p=>{if(p.preventDefault(),!M.trim()){Z("Name required");return}Y(!0);try{const H=await st.createApiKey(M.trim());N({name:H.name,token:H.token})}catch(H){Z(H instanceof Error?H.message:"Failed")}finally{Y(!1)}};return f.jsx("div",{className:"modal-overlay",onClick:d,children:f.jsxs("form",{className:"modal",onClick:p=>p.stopPropagation(),onSubmit:O,children:[f.jsx("div",{className:"modal-title",children:"Create API Key"}),f.jsx("p",{style:{color:"var(--text-secondary)",fontSize:13,marginBottom:16},children:"API keys use simple bearer token auth. They grant full read+write+admin access. For scoped access, use OAuth clients instead."}),f.jsxs("div",{style:{marginBottom:16},children:[f.jsx("label",{children:"Key Name"}),f.jsx("input",{placeholder:"e.g. claude-code-local",value:M,onChange:p=>h(p.target.value),autoFocus:!0})]}),U&&f.jsx("div",{style:{color:"var(--error)",fontSize:13,marginBottom:12},children:U}),f.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"flex-end"},children:[f.jsx("button",{type:"button",className:"btn btn-secondary",onClick:d,children:"Cancel"}),f.jsx("button",{type:"submit",className:"btn btn-primary",disabled:_,children:_?"Creating...":"Create Key"})]})]})})}function Sy({token:d,onClose:N}){const M=h=>navigator.clipboard.writeText(h);return f.jsx("div",{className:"modal-overlay",children:f.jsxs("div",{className:"modal",style:{maxWidth:560},children:[f.jsxs("div",{style:{textAlign:"center",marginBottom:16},children:[f.jsx("div",{style:{fontSize:36,color:"var(--success)",marginBottom:8},children:"✓"}),f.jsx("div",{style:{fontSize:20,fontWeight:600},children:"API Key Created"})]}),f.jsxs("div",{style:{marginBottom:12},children:[f.jsx("label",{style:{fontSize:12},children:"Name"}),f.jsx("div",{className:"code-block",children:f.jsx("span",{children:d.name})})]}),f.jsxs("div",{style:{marginBottom:12},children:[f.jsx("label",{style:{fontSize:12},children:"Bearer Token"}),f.jsxs("div",{className:"code-block",children:[f.jsx("span",{children:d.token}),f.jsx("button",{className:"copy-btn",onClick:()=>M(d.token),children:"Copy"})]})]}),f.jsxs("div",{style:{marginBottom:12},children:[f.jsx("label",{style:{fontSize:12},children:"Usage"}),f.jsxs("div",{className:"code-block",children:[f.jsx("pre",{style:{whiteSpace:"pre-wrap",margin:0,fontSize:12},children:`Authorization: Bearer ${d.token}`}),f.jsx("button",{className:"copy-btn",onClick:()=>M(`Authorization: Bearer ${d.token}`),children:"Copy"})]})]}),f.jsx("div",{className:"warning-bar",children:"Save this token now. It will not be shown again."}),f.jsx("div",{style:{display:"flex",gap:12,justifyContent:"flex-end",marginTop:20},children:f.jsx("button",{className:"btn btn-primary",onClick:N,children:"Done"})})]})})}function by({onClose:d,onRegistered:N}){const[M,h]=k.useState(""),[_,Y]=k.useState(()=>Object.fromEntries(jr.map(L=>[L,L==="read"]))),[U,Z]=k.useState("86400"),[O,p]=k.useState(!1),[H,j]=k.useState(""),E=[{label:"1 hour",value:"3600"},{label:"24 hours",value:"86400"},{label:"7 days",value:"604800"},{label:"30 days",value:"2592000"},{label:"1 year",value:"31536000"},{label:"No expiry",value:"0"}],I=async L=>{if(L.preventDefault(),!M.trim()){j("Name required");return}p(!0),j("");try{const nl=Object.entries(_).filter(([,Ml])=>Ml).map(([Ml])=>Ml).join(" "),tl=await fetch("/admin/api/register-client",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:M.trim(),scopes:nl,tokenTtl:U==="0"?31536e4:Number(U)})});if(!tl.ok)throw new Error("Registration failed");const pl=await tl.json();N({clientId:pl.clientId,clientSecret:pl.clientSecret,name:M.trim()})}catch(nl){j(nl instanceof Error?nl.message:"Registration failed")}finally{p(!1)}};return f.jsx("div",{className:"modal-overlay",onClick:d,children:f.jsxs("form",{className:"modal",onClick:L=>L.stopPropagation(),onSubmit:I,children:[f.jsx("div",{className:"modal-title",children:"Register Agent"}),f.jsxs("div",{style:{marginBottom:16},children:[f.jsx("label",{children:"Agent Name"}),f.jsx("input",{placeholder:"e.g. perplexity-production",value:M,onChange:L=>h(L.target.value),autoFocus:!0})]}),f.jsxs("div",{style:{marginBottom:16},children:[f.jsx("label",{children:"Scopes"}),f.jsx("div",{className:"checkbox-group",children:jr.map(L=>f.jsxs("label",{className:"checkbox-label",children:[f.jsx("input",{type:"checkbox",checked:_[L],onChange:nl=>Y(tl=>({...tl,[L]:nl.target.checked}))}),L]},L))})]}),f.jsxs("div",{style:{marginBottom:20},children:[f.jsx("label",{children:"Token Lifetime"}),f.jsx("select",{value:U,onChange:L=>Z(L.target.value),style:{width:"100%",background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border)",borderRadius:6,padding:"6px 10px",fontSize:14},children:E.map(L=>f.jsx("option",{value:L.value,children:L.label},L.value))})]}),H&&f.jsx("div",{style:{color:"var(--error)",fontSize:13,marginBottom:12},children:H}),f.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"flex-end"},children:[f.jsx("button",{type:"button",className:"btn btn-secondary",onClick:d,children:"Cancel"}),f.jsx("button",{type:"submit",className:"btn btn-primary",disabled:O,children:O?"Registering...":"Register"})]})]})})}function py({credentials:d,onClose:N}){const M=_=>navigator.clipboard.writeText(_),h=()=>{const _=new Blob([JSON.stringify(d,null,2)],{type:"application/json"}),Y=URL.createObjectURL(_),U=document.createElement("a");U.href=Y,U.download=`${d.name}-credentials.json`,U.click(),URL.revokeObjectURL(Y)};return f.jsx("div",{className:"modal-overlay",children:f.jsxs("div",{className:"modal",style:{maxWidth:560},children:[f.jsxs("div",{style:{textAlign:"center",marginBottom:16},children:[f.jsx("div",{style:{fontSize:36,color:"var(--success)",marginBottom:8},children:"✓"}),f.jsx("div",{style:{fontSize:20,fontWeight:600},children:"Agent Registered"})]}),f.jsxs("div",{style:{marginBottom:12},children:[f.jsx("label",{style:{fontSize:12},children:"Client ID"}),f.jsxs("div",{className:"code-block",children:[f.jsx("span",{children:d.clientId}),f.jsx("button",{className:"copy-btn",onClick:()=>M(d.clientId),children:"Copy"})]})]}),f.jsxs("div",{style:{marginBottom:12},children:[f.jsx("label",{style:{fontSize:12},children:"Client Secret"}),f.jsxs("div",{className:"code-block",children:[f.jsx("span",{children:d.clientSecret}),f.jsx("button",{className:"copy-btn",onClick:()=>M(d.clientSecret),children:"Copy"})]})]}),f.jsx("div",{className:"warning-bar",children:"Save this secret now. It will not be shown again."}),f.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"flex-end",marginTop:20},children:[f.jsx("button",{className:"btn btn-secondary",onClick:h,children:"Download as JSON"}),f.jsx("button",{className:"btn btn-primary",onClick:N,children:"Done"})]})]})})}function Ty({agent:d,onClose:N,onRevoked:M}){const[h,_]=k.useState("claude-code"),Y=j=>navigator.clipboard.writeText(j),U=window.location.origin,Z=d.id||d.client_id||"",O=d.auth_type==="oauth",p=d.name||d.client_name||"unknown",H={"claude-code":O?["The user wants to connect GBrain MCP to your context. Here's how.","","# Step 1 — read the client secret from the operator without putting it in shell history.","# read -s suppresses the echo; export keeps it scoped to this shell session.",'read -rs -p "Client Secret: " GBRAIN_CS && echo',"","# Step 2 — mint a token and register GBrain in one go.",`claude mcp add --transport http gbrain ${U}/mcp \\`,` --header "Authorization: Bearer $(curl -s -X POST ${U}/token \\`," -d 'grant_type=client_credentials' \\",` -d 'client_id=${Z}' \\`,' --data-urlencode "client_secret=$GBRAIN_CS" \\',` -d 'scope=${d.scope||"read write"}' | jq -r .access_token)"`,"","# Step 3 — clear the secret from this shell.","unset GBRAIN_CS","",`The token will last ${d.token_ttl?d.token_ttl>=86400?Math.floor(d.token_ttl/86400)+" days":Math.floor(d.token_ttl/3600)+" hours":"1 hour (default)"}.`,"","─── Fallback: 2-step curl + paste ───","","If your shell doesn't support read -s, mint the token first, then paste:","",`curl -s -X POST ${U}/token \\`," -d 'grant_type=client_credentials' \\",` -d 'client_id=${Z}' \\`," -d 'client_secret=PASTE_YOUR_CLIENT_SECRET_HERE' \\",` -d 'scope=${d.scope||"read write"}' | jq -r .access_token`,"",`claude mcp add --transport http gbrain ${U}/mcp \\`,' --header "Authorization: Bearer PASTE_TOKEN_FROM_ABOVE"',"","# Then run: history -d $((HISTCMD-1)) # zsh: print -s -- '' && fc -p"].join(` +`).replace(xm,"")}function Yd(l,t){return t=qd(t),qd(l)===t}function hl(l,t,e,a,n,u){switch(e){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||We(l,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&We(l,""+a);break;case"className":Dn(l,"class",a);break;case"tabIndex":Dn(l,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":Dn(l,e,a);break;case"style":qf(l,a,u);break;case"data":if(t!=="object"){Dn(l,"data",a);break}case"src":case"href":if(a===""&&(t!=="a"||e!=="href")){l.removeAttribute(e);break}if(a==null||typeof a=="function"||typeof a=="symbol"||typeof a=="boolean"){l.removeAttribute(e);break}a=Un(""+a),l.setAttribute(e,a);break;case"action":case"formAction":if(typeof a=="function"){l.setAttribute(e,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof u=="function"&&(e==="formAction"?(t!=="input"&&hl(l,t,"name",n.name,n,null),hl(l,t,"formEncType",n.formEncType,n,null),hl(l,t,"formMethod",n.formMethod,n,null),hl(l,t,"formTarget",n.formTarget,n,null)):(hl(l,t,"encType",n.encType,n,null),hl(l,t,"method",n.method,n,null),hl(l,t,"target",n.target,n,null)));if(a==null||typeof a=="symbol"||typeof a=="boolean"){l.removeAttribute(e);break}a=Un(""+a),l.setAttribute(e,a);break;case"onClick":a!=null&&(l.onclick=Ht);break;case"onScroll":a!=null&&F("scroll",l);break;case"onScrollEnd":a!=null&&F("scrollend",l);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(h(61));if(e=a.__html,e!=null){if(n.children!=null)throw Error(h(60));l.innerHTML=e}}break;case"multiple":l.multiple=a&&typeof a!="function"&&typeof a!="symbol";break;case"muted":l.muted=a&&typeof a!="function"&&typeof a!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(a==null||typeof a=="function"||typeof a=="boolean"||typeof a=="symbol"){l.removeAttribute("xlink:href");break}e=Un(""+a),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":a!=null&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(e,""+a):l.removeAttribute(e);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":a&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(e,""):l.removeAttribute(e);break;case"capture":case"download":a===!0?l.setAttribute(e,""):a!==!1&&a!=null&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(e,a):l.removeAttribute(e);break;case"cols":case"rows":case"size":case"span":a!=null&&typeof a!="function"&&typeof a!="symbol"&&!isNaN(a)&&1<=a?l.setAttribute(e,a):l.removeAttribute(e);break;case"rowSpan":case"start":a==null||typeof a=="function"||typeof a=="symbol"||isNaN(a)?l.removeAttribute(e):l.setAttribute(e,a);break;case"popover":F("beforetoggle",l),F("toggle",l),Mn(l,"popover",a);break;case"xlinkActuate":Rt(l,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":Rt(l,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":Rt(l,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":Rt(l,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":Rt(l,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":Rt(l,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":Rt(l,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":Rt(l,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":Rt(l,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":Mn(l,"is",a);break;case"innerText":case"textContent":break;default:(!(2c)break;var b=s.transferSize,x=s.initiatorType;b&&Gd(x)&&(s=s.responseEnd,i+=b*(s"u"?null:document;function Fd(l,t,e){var a=Aa;if(a&&typeof t=="string"&&t){var n=rt(t);n='link[rel="'+l+'"][href="'+n+'"]',typeof e=="string"&&(n+='[crossorigin="'+e+'"]'),Wd.has(n)||(Wd.add(n),l={rel:l,crossOrigin:e,href:t},a.querySelector(n)===null&&(t=a.createElement("link"),Yl(t,"link",l),Cl(t),a.head.appendChild(t)))}}function Hm(l){Ft.D(l),Fd("dns-prefetch",l,null)}function Bm(l,t){Ft.C(l,t),Fd("preconnect",l,t)}function qm(l,t,e){Ft.L(l,t,e);var a=Aa;if(a&&l&&t){var n='link[rel="preload"][as="'+rt(t)+'"]';t==="image"&&e&&e.imageSrcSet?(n+='[imagesrcset="'+rt(e.imageSrcSet)+'"]',typeof e.imageSizes=="string"&&(n+='[imagesizes="'+rt(e.imageSizes)+'"]')):n+='[href="'+rt(l)+'"]';var u=n;switch(t){case"style":u=Ea(l);break;case"script":u=_a(l)}pt.has(u)||(l=j({rel:"preload",href:t==="image"&&e&&e.imageSrcSet?void 0:l,as:t},e),pt.set(u,l),a.querySelector(n)!==null||t==="style"&&a.querySelector(vn(u))||t==="script"&&a.querySelector(gn(u))||(t=a.createElement("link"),Yl(t,"link",l),Cl(t),a.head.appendChild(t)))}}function Ym(l,t){Ft.m(l,t);var e=Aa;if(e&&l){var a=t&&typeof t.as=="string"?t.as:"script",n='link[rel="modulepreload"][as="'+rt(a)+'"][href="'+rt(l)+'"]',u=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=_a(l)}if(!pt.has(u)&&(l=j({rel:"modulepreload",href:l},t),pt.set(u,l),e.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(e.querySelector(gn(u)))return}a=e.createElement("link"),Yl(a,"link",l),Cl(a),e.head.appendChild(a)}}}function Gm(l,t,e){Ft.S(l,t,e);var a=Aa;if(a&&l){var n=we(a).hoistableStyles,u=Ea(l);t=t||"default";var i=n.get(u);if(!i){var c={loading:0,preload:null};if(i=a.querySelector(vn(u)))c.loading=5;else{l=j({rel:"stylesheet",href:l,"data-precedence":t},e),(e=pt.get(u))&&Ic(l,e);var s=i=a.createElement("link");Cl(s),Yl(s,"link",l),s._p=new Promise(function(v,b){s.onload=v,s.onerror=b}),s.addEventListener("load",function(){c.loading|=1}),s.addEventListener("error",function(){c.loading|=2}),c.loading|=4,Mu(i,t,a)}i={type:"stylesheet",instance:i,count:1,state:c},n.set(u,i)}}}function Xm(l,t){Ft.X(l,t);var e=Aa;if(e&&l){var a=we(e).hoistableScripts,n=_a(l),u=a.get(n);u||(u=e.querySelector(gn(n)),u||(l=j({src:l,async:!0},t),(t=pt.get(n))&&Pc(l,t),u=e.createElement("script"),Cl(u),Yl(u,"link",l),e.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function Qm(l,t){Ft.M(l,t);var e=Aa;if(e&&l){var a=we(e).hoistableScripts,n=_a(l),u=a.get(n);u||(u=e.querySelector(gn(n)),u||(l=j({src:l,async:!0,type:"module"},t),(t=pt.get(n))&&Pc(l,t),u=e.createElement("script"),Cl(u),Yl(u,"link",l),e.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function Id(l,t,e,a){var n=(n=$.current)?Nu(n):null;if(!n)throw Error(h(446));switch(l){case"meta":case"title":return null;case"style":return typeof e.precedence=="string"&&typeof e.href=="string"?(t=Ea(e.href),e=we(n).hoistableStyles,a=e.get(t),a||(a={type:"style",instance:null,count:0,state:null},e.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(e.rel==="stylesheet"&&typeof e.href=="string"&&typeof e.precedence=="string"){l=Ea(e.href);var u=we(n).hoistableStyles,i=u.get(l);if(i||(n=n.ownerDocument||n,i={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(l,i),(u=n.querySelector(vn(l)))&&!u._p&&(i.instance=u,i.state.loading=5),pt.has(l)||(e={rel:"preload",as:"style",href:e.href,crossOrigin:e.crossOrigin,integrity:e.integrity,media:e.media,hrefLang:e.hrefLang,referrerPolicy:e.referrerPolicy},pt.set(l,e),u||Zm(n,l,e,i.state))),t&&a===null)throw Error(h(528,""));return i}if(t&&a!==null)throw Error(h(529,""));return null;case"script":return t=e.async,e=e.src,typeof e=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=_a(e),e=we(n).hoistableScripts,a=e.get(t),a||(a={type:"script",instance:null,count:0,state:null},e.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(h(444,l))}}function Ea(l){return'href="'+rt(l)+'"'}function vn(l){return'link[rel="stylesheet"]['+l+"]"}function Pd(l){return j({},l,{"data-precedence":l.precedence,precedence:null})}function Zm(l,t,e,a){l.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=l.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),Yl(t,"link",e),Cl(t),l.head.appendChild(t))}function _a(l){return'[src="'+rt(l)+'"]'}function gn(l){return"script[async]"+l}function lr(l,t,e){if(t.count++,t.instance===null)switch(t.type){case"style":var a=l.querySelector('style[data-href~="'+rt(e.href)+'"]');if(a)return t.instance=a,Cl(a),a;var n=j({},e,{"data-href":e.href,"data-precedence":e.precedence,href:null,precedence:null});return a=(l.ownerDocument||l).createElement("style"),Cl(a),Yl(a,"style",n),Mu(a,e.precedence,l),t.instance=a;case"stylesheet":n=Ea(e.href);var u=l.querySelector(vn(n));if(u)return t.state.loading|=4,t.instance=u,Cl(u),u;a=Pd(e),(n=pt.get(n))&&Ic(a,n),u=(l.ownerDocument||l).createElement("link"),Cl(u);var i=u;return i._p=new Promise(function(c,s){i.onload=c,i.onerror=s}),Yl(u,"link",a),t.state.loading|=4,Mu(u,e.precedence,l),t.instance=u;case"script":return u=_a(e.src),(n=l.querySelector(gn(u)))?(t.instance=n,Cl(n),n):(a=e,(n=pt.get(u))&&(a=j({},e),Pc(a,n)),l=l.ownerDocument||l,n=l.createElement("script"),Cl(n),Yl(n,"link",a),l.head.appendChild(n),t.instance=n);case"void":return null;default:throw Error(h(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,Mu(a,e.precedence,l));return t.instance}function Mu(l,t,e){for(var a=e.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,u=n,i=0;i title"):null)}function Lm(l,t,e){if(e===1||t.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return l=t.disabled,typeof t.precedence=="string"&&l==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function ar(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function Vm(l,t,e,a){if(e.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(e.state.loading&4)===0){if(e.instance===null){var n=Ea(a.href),u=t.querySelector(vn(n));if(u){t=u._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(l.count++,l=Cu.bind(l),t.then(l,l)),e.state.loading|=4,e.instance=u,Cl(u);return}u=t.ownerDocument||t,a=Pd(a),(n=pt.get(n))&&Ic(a,n),u=u.createElement("link"),Cl(u);var i=u;i._p=new Promise(function(c,s){i.onload=c,i.onerror=s}),Yl(u,"link",a),e.instance=u}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(e,t),(t=e.state.preload)&&(e.state.loading&3)===0&&(l.count++,e=Cu.bind(l),t.addEventListener("load",e),t.addEventListener("error",e))}}var lf=0;function Km(l,t){return l.stylesheets&&l.count===0&&Ru(l,l.stylesheets),0lf?50:800)+t);return l.unsuspend=e,function(){l.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function Cu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ru(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var Uu=null;function Ru(l,t){l.stylesheets=null,l.unsuspend!==null&&(l.count++,Uu=new Map,t.forEach(Jm,l),Uu=null,Cu.call(l))}function Jm(l,t){if(!(t.state.loading&4)){var e=Uu.get(l);if(e)var a=e.get(null);else{e=new Map,Uu.set(l,e);for(var n=l.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(d)}catch(N){console.error(N)}}return d(),of.exports=fy(),of.exports}var oy=sy();const dy=Nr(oy),Dr="";async function Tt(d,N){const M=await fetch(`${Dr}${d}`,{...N,credentials:"same-origin",headers:{"Content-Type":"application/json",...N==null?void 0:N.headers}});if(M.status===401)throw window.location.hash="#login",new Error("Unauthorized");if(!M.ok){const h=await M.json().catch(()=>({}));throw new Error(h.error||`HTTP ${M.status}`)}return M.json()}async function ry(d){const N=await fetch(`${Dr}${d}`,{credentials:"same-origin"});if(N.status===401)throw window.location.hash="#login",new Error("Unauthorized");if(!N.ok)throw new Error(`HTTP ${N.status}`);return N.text()}const st={login:d=>Tt("/admin/login",{method:"POST",body:JSON.stringify({token:d})}),signOutEverywhere:()=>Tt("/admin/api/sign-out-everywhere",{method:"POST"}),stats:()=>Tt("/admin/api/stats"),health:()=>Tt("/admin/api/health-indicators"),agents:()=>Tt("/admin/api/agents"),requests:(d=1,N="")=>Tt(`/admin/api/requests?page=${d}${N}`),apiKeys:()=>Tt("/admin/api/api-keys"),createApiKey:d=>Tt("/admin/api/api-keys",{method:"POST",body:JSON.stringify({name:d})}),revokeApiKey:d=>Tt("/admin/api/api-keys/revoke",{method:"POST",body:JSON.stringify({name:d})}),updateClientTtl:(d,N)=>Tt("/admin/api/update-client-ttl",{method:"POST",body:JSON.stringify({clientId:d,tokenTtl:N})}),revokeClient:d=>Tt("/admin/api/revoke-client",{method:"POST",body:JSON.stringify({clientId:d})}),calibrationProfile:d=>Tt(`/admin/api/calibration/profile${d?`?holder=${encodeURIComponent(d)}`:""}`),calibrationChart:(d,N)=>ry(`/admin/api/calibration/charts/${encodeURIComponent(d)}${N?`?holder=${encodeURIComponent(N)}`:""}`)};function hy({onLogin:d}){const[N,M]=k.useState(""),[h,_]=k.useState(""),[Y,U]=k.useState(!1),Z=async O=>{O.preventDefault(),_(""),U(!0);try{await st.login(N),M(""),d()}catch{_("Invalid token.")}finally{U(!1)}};return f.jsx("div",{className:"login-page",children:f.jsxs("div",{className:"login-box",children:[f.jsx("div",{className:"login-logo",children:"GBrain"}),f.jsxs("div",{style:{background:"rgba(136, 170, 255, 0.08)",border:"1px solid rgba(136, 170, 255, 0.2)",borderRadius:8,padding:"14px 16px",marginBottom:20,fontSize:13,lineHeight:1.5,color:"var(--text-secondary)"},children:[f.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:6},children:"🔒 This is a protected dashboard"}),"Ask your AI agent for the admin login link:",f.jsx("div",{style:{background:"rgba(0,0,0,0.3)",borderRadius:6,padding:"8px 12px",marginTop:8,fontFamily:"var(--font-mono)",fontSize:12,color:"#88aaff",wordBreak:"break-all"},children:'"Give me the GBrain admin login link"'}),f.jsx("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)"},children:"Each link is single-use. Your agent generates a fresh one each time."})]}),f.jsxs("details",{style:{marginBottom:16},children:[f.jsx("summary",{style:{cursor:"pointer",fontSize:13,color:"var(--text-muted)"},children:"Or paste bootstrap token manually"}),f.jsxs("form",{onSubmit:Z,style:{marginTop:12},children:[f.jsx("div",{style:{marginBottom:12},children:f.jsx("input",{type:"password",placeholder:"Admin Token",value:N,onChange:O=>M(O.target.value)})}),f.jsx("button",{className:"btn btn-primary",style:{width:"100%"},disabled:Y,children:Y?"Authenticating...":"Submit"}),h&&f.jsx("div",{className:"login-error",children:h})]})]})]})})}function my(){const[d,N]=k.useState({connected_agents:0,requests_today:0,active_tokens:0}),[M,h]=k.useState({expiring_soon:0,error_rate:"0%"}),[_,Y]=k.useState([]),[U,Z]=k.useState("connecting"),O=k.useRef(null);k.useEffect(()=>{st.stats().then(N).catch(()=>{}),st.health().then(h).catch(()=>{});const H=new EventSource("/admin/events");O.current=H,H.onopen=()=>Z("connected"),H.onmessage=E=>{try{const I=JSON.parse(E.data);Y(L=>[I,...L].slice(0,50))}catch{}},H.onerror=()=>{Z("disconnected"),setTimeout(()=>{Z("connecting"),H.close()},3e3)};const j=setInterval(()=>{st.stats().then(N).catch(()=>{}),st.health().then(h).catch(()=>{})},3e4);return()=>{H.close(),clearInterval(j)}},[]);const p=H=>{const j=Date.now()-new Date(H).getTime();return j<6e4?`${Math.floor(j/1e3)}s ago`:j<36e5?`${Math.floor(j/6e4)} min ago`:`${Math.floor(j/36e5)}h ago`};return f.jsxs(f.Fragment,{children:[f.jsx("h1",{className:"page-title",children:"Dashboard"}),f.jsxs("div",{style:{display:"flex",gap:24},children:[f.jsxs("div",{style:{flex:1},children:[f.jsxs("div",{className:"metrics",children:[f.jsxs("div",{className:"metric",children:[f.jsx("div",{className:"metric-value",children:d.connected_agents}),f.jsx("div",{className:"metric-label",children:"Connected Agents"})]}),f.jsxs("div",{className:"metric",children:[f.jsx("div",{className:"metric-value",children:d.requests_today}),f.jsx("div",{className:"metric-label",children:"Requests Today"})]}),f.jsxs("div",{className:"metric",children:[f.jsx("div",{className:"metric-value",children:d.active_tokens}),f.jsx("div",{className:"metric-label",children:"Active Tokens"})]})]}),f.jsxs("h2",{className:"section-title",children:["Live Activity",f.jsx("span",{style:{marginLeft:8,fontSize:10,color:U==="connected"?"var(--success)":U==="connecting"?"var(--warning)":"var(--error)"},children:U==="connected"?"● connected":U==="connecting"?"● connecting...":"● disconnected"})]}),f.jsx("div",{className:"feed",children:_.length===0?f.jsx("div",{className:"feed-empty",children:U==="connected"?"No requests yet. Agents will appear when they connect.":"Connecting..."}):f.jsxs("table",{children:[f.jsx("thead",{children:f.jsxs("tr",{children:[f.jsx("th",{children:"Agent"}),f.jsx("th",{children:"Operation"}),f.jsx("th",{children:"Scopes"}),f.jsx("th",{children:"Latency"}),f.jsx("th",{children:"Status"}),f.jsx("th",{children:"Time"})]})}),f.jsx("tbody",{children:_.map((H,j)=>f.jsxs("tr",{children:[f.jsx("td",{className:"mono",children:H.agent}),f.jsx("td",{className:"mono",children:H.operation}),f.jsx("td",{children:H.scopes.split(",").map(E=>f.jsx("span",{className:`badge badge-${E.trim()}`,style:{marginRight:4},children:E.trim()},E))}),f.jsxs("td",{className:"mono",children:[H.latency_ms," ms"]}),f.jsx("td",{children:f.jsx("span",{className:`badge badge-${H.status}`,children:H.status})}),f.jsx("td",{style:{color:"var(--text-secondary)"},children:p(H.timestamp)})]},j))})]})})]}),f.jsxs("div",{style:{width:220},children:[f.jsx("h2",{className:"section-title",children:"Token Health"}),f.jsxs("div",{className:"health-panel",children:[f.jsxs("div",{className:"health-row",children:[f.jsx("span",{style:{color:"var(--warning)"},children:"Expiring Soon"}),f.jsx("span",{className:"mono",children:M.expiring_soon})]}),f.jsxs("div",{className:"health-row",children:[f.jsx("span",{style:{color:"var(--error)"},children:"Error Rate"}),f.jsx("span",{className:"mono",children:M.error_rate})]})]})]})]})]})}const jr=["admin","agent","read","sources_admin","users_admin","write"];function yy(d){const N=Math.floor((Date.now()-d.getTime())/1e3);return N<60?"just now":N<3600?`${Math.floor(N/60)}m ago`:N<86400?`${Math.floor(N/3600)}h ago`:`${Math.floor(N/86400)}d ago`}function vy(){const[d,N]=k.useState([]),[M,h]=k.useState(!0),[_,Y]=k.useState(!1),[U,Z]=k.useState(null),[O,p]=k.useState(!1),[H,j]=k.useState(null),[E,I]=k.useState(null);k.useEffect(()=>{L()},[]);const L=()=>{st.agents().then(N).catch(()=>{})};return f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:24},children:[f.jsx("h1",{className:"page-title",style:{marginBottom:0},children:"Agents"}),f.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[f.jsxs("label",{style:{fontSize:13,color:"var(--text-secondary)",display:"flex",alignItems:"center",gap:6,cursor:"pointer"},children:[f.jsx("input",{type:"checkbox",checked:M,onChange:nl=>h(nl.target.checked)})," Hide revoked"]}),f.jsx("button",{className:"btn btn-secondary",onClick:()=>p(!0),children:"+ API Key"}),f.jsx("button",{className:"btn btn-primary",onClick:()=>Y(!0),children:"+ OAuth Client"})]})]}),(()=>{const nl=d.filter(tl=>!M||tl.status!=="revoked");return d.length===0?f.jsx("div",{style:{textAlign:"center",padding:48,color:"var(--text-muted)"},children:"No agents registered. Register your first agent to get started."}):nl.length===0?f.jsx("div",{style:{textAlign:"center",padding:48,color:"var(--text-muted)"},children:'All agents are revoked. Uncheck "Hide revoked" to view them.'}):f.jsxs(f.Fragment,{children:[f.jsxs("table",{children:[f.jsx("thead",{children:f.jsxs("tr",{children:[f.jsx("th",{children:"Name"}),f.jsx("th",{children:"Type"}),f.jsx("th",{children:"Scopes"}),f.jsx("th",{children:"Status"}),f.jsx("th",{children:"Requests"}),f.jsx("th",{children:"Last Used"})]})}),f.jsx("tbody",{children:nl.map(tl=>f.jsxs("tr",{onClick:()=>I(tl),style:{cursor:"pointer"},children:[f.jsx("td",{style:{fontWeight:500},children:tl.name||tl.client_name}),f.jsx("td",{children:f.jsx("span",{className:`badge ${tl.auth_type==="oauth"?"badge-read":"badge-write"}`,style:{fontSize:11},children:tl.auth_type==="oauth"?"OAuth":"API Key"})}),f.jsx("td",{children:(tl.scope||"").split(" ").filter(Boolean).map(pl=>f.jsx("span",{className:`badge badge-${pl}`,style:{marginRight:4},children:pl},pl))}),f.jsx("td",{children:f.jsx("span",{className:`badge ${tl.status==="active"?"badge-success":"badge-danger"}`,children:tl.status})}),f.jsxs("td",{children:[f.jsx("span",{style:{fontWeight:500},children:tl.requests_today||0}),f.jsxs("span",{style:{color:"var(--text-muted)",fontSize:12},children:[" / ",tl.total_requests||0]})]}),f.jsx("td",{style:{color:"var(--text-secondary)"},children:tl.last_used_at?yy(new Date(tl.last_used_at)):"Never"})]},tl.id))})]}),f.jsxs("div",{style:{color:"var(--text-muted)",fontSize:13,marginTop:12},children:[d.filter(tl=>tl.status==="active").length," active / ",d.length," total"]})]})})(),_&&f.jsx(by,{onClose:()=>Y(!1),onRegistered:nl=>{Y(!1),Z(nl),L()}}),U&&f.jsx(py,{credentials:U,onClose:()=>Z(null)}),E&&f.jsx(Ty,{agent:E,onClose:()=>I(null),onRevoked:L}),O&&f.jsx(gy,{onClose:()=>p(!1),onCreated:nl=>{p(!1),j(nl),L()}}),H&&f.jsx(Sy,{token:H,onClose:()=>j(null)})]})}function gy({onClose:d,onCreated:N}){const[M,h]=k.useState(""),[_,Y]=k.useState(!1),[U,Z]=k.useState(""),O=async p=>{if(p.preventDefault(),!M.trim()){Z("Name required");return}Y(!0);try{const H=await st.createApiKey(M.trim());N({name:H.name,token:H.token})}catch(H){Z(H instanceof Error?H.message:"Failed")}finally{Y(!1)}};return f.jsx("div",{className:"modal-overlay",onClick:d,children:f.jsxs("form",{className:"modal",onClick:p=>p.stopPropagation(),onSubmit:O,children:[f.jsx("div",{className:"modal-title",children:"Create API Key"}),f.jsx("p",{style:{color:"var(--text-secondary)",fontSize:13,marginBottom:16},children:"API keys use simple bearer token auth. They grant full read+write+admin access. For scoped access, use OAuth clients instead."}),f.jsxs("div",{style:{marginBottom:16},children:[f.jsx("label",{children:"Key Name"}),f.jsx("input",{placeholder:"e.g. claude-code-local",value:M,onChange:p=>h(p.target.value),autoFocus:!0})]}),U&&f.jsx("div",{style:{color:"var(--error)",fontSize:13,marginBottom:12},children:U}),f.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"flex-end"},children:[f.jsx("button",{type:"button",className:"btn btn-secondary",onClick:d,children:"Cancel"}),f.jsx("button",{type:"submit",className:"btn btn-primary",disabled:_,children:_?"Creating...":"Create Key"})]})]})})}function Sy({token:d,onClose:N}){const M=h=>navigator.clipboard.writeText(h);return f.jsx("div",{className:"modal-overlay",children:f.jsxs("div",{className:"modal",style:{maxWidth:560},children:[f.jsxs("div",{style:{textAlign:"center",marginBottom:16},children:[f.jsx("div",{style:{fontSize:36,color:"var(--success)",marginBottom:8},children:"✓"}),f.jsx("div",{style:{fontSize:20,fontWeight:600},children:"API Key Created"})]}),f.jsxs("div",{style:{marginBottom:12},children:[f.jsx("label",{style:{fontSize:12},children:"Name"}),f.jsx("div",{className:"code-block",children:f.jsx("span",{children:d.name})})]}),f.jsxs("div",{style:{marginBottom:12},children:[f.jsx("label",{style:{fontSize:12},children:"Bearer Token"}),f.jsxs("div",{className:"code-block",children:[f.jsx("span",{children:d.token}),f.jsx("button",{className:"copy-btn",onClick:()=>M(d.token),children:"Copy"})]})]}),f.jsxs("div",{style:{marginBottom:12},children:[f.jsx("label",{style:{fontSize:12},children:"Usage"}),f.jsxs("div",{className:"code-block",children:[f.jsx("pre",{style:{whiteSpace:"pre-wrap",margin:0,fontSize:12},children:`Authorization: Bearer ${d.token}`}),f.jsx("button",{className:"copy-btn",onClick:()=>M(`Authorization: Bearer ${d.token}`),children:"Copy"})]})]}),f.jsx("div",{className:"warning-bar",children:"Save this token now. It will not be shown again."}),f.jsx("div",{style:{display:"flex",gap:12,justifyContent:"flex-end",marginTop:20},children:f.jsx("button",{className:"btn btn-primary",onClick:N,children:"Done"})})]})})}function by({onClose:d,onRegistered:N}){const[M,h]=k.useState(""),[_,Y]=k.useState(()=>Object.fromEntries(jr.map(L=>[L,L==="read"]))),[U,Z]=k.useState("86400"),[O,p]=k.useState(!1),[H,j]=k.useState(""),E=[{label:"1 hour",value:"3600"},{label:"24 hours",value:"86400"},{label:"7 days",value:"604800"},{label:"30 days",value:"2592000"},{label:"1 year",value:"31536000"},{label:"No expiry",value:"0"}],I=async L=>{if(L.preventDefault(),!M.trim()){j("Name required");return}p(!0),j("");try{const nl=Object.entries(_).filter(([,Ml])=>Ml).map(([Ml])=>Ml).join(" "),tl=await fetch("/admin/api/register-client",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:M.trim(),scopes:nl,tokenTtl:U==="0"?31536e4:Number(U)})});if(!tl.ok)throw new Error("Registration failed");const pl=await tl.json();N({clientId:pl.clientId,clientSecret:pl.clientSecret,name:M.trim()})}catch(nl){j(nl instanceof Error?nl.message:"Registration failed")}finally{p(!1)}};return f.jsx("div",{className:"modal-overlay",onClick:d,children:f.jsxs("form",{className:"modal",onClick:L=>L.stopPropagation(),onSubmit:I,children:[f.jsx("div",{className:"modal-title",children:"Register Agent"}),f.jsxs("div",{style:{marginBottom:16},children:[f.jsx("label",{children:"Agent Name"}),f.jsx("input",{placeholder:"e.g. perplexity-production",value:M,onChange:L=>h(L.target.value),autoFocus:!0})]}),f.jsxs("div",{style:{marginBottom:16},children:[f.jsx("label",{children:"Scopes"}),f.jsx("div",{className:"checkbox-group",children:jr.map(L=>f.jsxs("label",{className:"checkbox-label",children:[f.jsx("input",{type:"checkbox",checked:_[L],onChange:nl=>Y(tl=>({...tl,[L]:nl.target.checked}))}),L]},L))})]}),f.jsxs("div",{style:{marginBottom:20},children:[f.jsx("label",{children:"Token Lifetime"}),f.jsx("select",{value:U,onChange:L=>Z(L.target.value),style:{width:"100%",background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border)",borderRadius:6,padding:"6px 10px",fontSize:14},children:E.map(L=>f.jsx("option",{value:L.value,children:L.label},L.value))})]}),H&&f.jsx("div",{style:{color:"var(--error)",fontSize:13,marginBottom:12},children:H}),f.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"flex-end"},children:[f.jsx("button",{type:"button",className:"btn btn-secondary",onClick:d,children:"Cancel"}),f.jsx("button",{type:"submit",className:"btn btn-primary",disabled:O,children:O?"Registering...":"Register"})]})]})})}function py({credentials:d,onClose:N}){const M=_=>navigator.clipboard.writeText(_),h=()=>{const _=new Blob([JSON.stringify(d,null,2)],{type:"application/json"}),Y=URL.createObjectURL(_),U=document.createElement("a");U.href=Y,U.download=`${d.name}-credentials.json`,U.click(),URL.revokeObjectURL(Y)};return f.jsx("div",{className:"modal-overlay",children:f.jsxs("div",{className:"modal",style:{maxWidth:560},children:[f.jsxs("div",{style:{textAlign:"center",marginBottom:16},children:[f.jsx("div",{style:{fontSize:36,color:"var(--success)",marginBottom:8},children:"✓"}),f.jsx("div",{style:{fontSize:20,fontWeight:600},children:"Agent Registered"})]}),f.jsxs("div",{style:{marginBottom:12},children:[f.jsx("label",{style:{fontSize:12},children:"Client ID"}),f.jsxs("div",{className:"code-block",children:[f.jsx("span",{children:d.clientId}),f.jsx("button",{className:"copy-btn",onClick:()=>M(d.clientId),children:"Copy"})]})]}),f.jsxs("div",{style:{marginBottom:12},children:[f.jsx("label",{style:{fontSize:12},children:"Client Secret"}),f.jsxs("div",{className:"code-block",children:[f.jsx("span",{children:d.clientSecret}),f.jsx("button",{className:"copy-btn",onClick:()=>M(d.clientSecret),children:"Copy"})]})]}),f.jsx("div",{className:"warning-bar",children:"Save this secret now. It will not be shown again."}),f.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"flex-end",marginTop:20},children:[f.jsx("button",{className:"btn btn-secondary",onClick:h,children:"Download as JSON"}),f.jsx("button",{className:"btn btn-primary",onClick:N,children:"Done"})]})]})})}function Ty({agent:d,onClose:N,onRevoked:M}){const[h,_]=k.useState("claude-code"),Y=j=>navigator.clipboard.writeText(j),U=window.location.origin,Z=d.id||d.client_id||"",O=d.auth_type==="oauth",p=d.name||d.client_name||"unknown",H={"claude-code":O?["The user wants to connect GBrain MCP to your context. Here's how.","","# Step 1 — read the client secret from the operator without putting it in shell history.","# read -s suppresses the echo; export keeps it scoped to this shell session.",'read -rs -p "Client Secret: " GBRAIN_CS && echo',"","# Step 2 — mint a token and register GBrain in one go.",`claude mcp add --transport http gbrain ${U}/mcp \\`,` --header "Authorization: Bearer $(curl -s -X POST ${U}/token \\`," -d 'grant_type=client_credentials' \\",` -d 'client_id=${Z}' \\`,' --data-urlencode "client_secret=$GBRAIN_CS" \\',` -d 'scope=${d.scope||"read write"}' | jq -r .access_token)"`,"","# Step 3 — clear the secret from this shell.","unset GBRAIN_CS","",`The token will last ${d.token_ttl?d.token_ttl>=86400?Math.floor(d.token_ttl/86400)+" days":Math.floor(d.token_ttl/3600)+" hours":"1 hour (default)"}.`,"","─── Fallback: 2-step curl + paste ───","","If your shell doesn't support read -s, mint the token first, then paste:","",`curl -s -X POST ${U}/token \\`," -d 'grant_type=client_credentials' \\",` -d 'client_id=${Z}' \\`," -d 'client_secret=PASTE_YOUR_CLIENT_SECRET_HERE' \\",` -d 'scope=${d.scope||"read write"}' | jq -r .access_token`,"",`claude mcp add --transport http gbrain ${U}/mcp \\`,' --header "Authorization: Bearer PASTE_TOKEN_FROM_ABOVE"',"","# Then run: history -d $((HISTCMD-1)) # zsh: print -s -- '' && fc -p"].join(` `):["The user wants to connect GBrain MCP to your context. Here's how.","","Run this command in terminal to register GBrain:","",`claude mcp add --transport http gbrain ${U}/mcp \\`,' --header "Authorization: Bearer PASTE_YOUR_API_KEY_HERE"',"",`Replace PASTE_YOUR_API_KEY_HERE with the API key shown when "${p}" was created.`,"API keys never expire."].join(` `),chatgpt:["The user wants to connect GBrain MCP to ChatGPT.","","1. Open ChatGPT > Settings > Tools & Integrations > Add MCP Server","2. Enter this URL — ChatGPT will auto-discover the OAuth configuration:","",` ${U}/.well-known/oauth-authorization-server`,"","3. When prompted for credentials:",` Client ID: ${Z}`," Client Secret: (the secret from agent registration)"," Grant Type: client_credentials",` Scope: ${d.scope||"read write"}`].join(` `),"claude-cowork":["The user wants to connect GBrain MCP to Claude.ai.","","1. Open claude.ai > Settings > Connected Apps > Add MCP Server",`2. Server URL: ${U}/mcp`,"3. When prompted for auth:",` Token endpoint: ${U}/token`,` Client ID: ${Z}`," Client Secret: (the secret from agent registration)",` Scope: ${d.scope||"read write"}`,"",`Discovery URL: ${U}/.well-known/oauth-authorization-server`].join(` diff --git a/admin/dist/index.html b/admin/dist/index.html index 7e8440a2d..e6eadff6f 100644 --- a/admin/dist/index.html +++ b/admin/dist/index.html @@ -7,7 +7,7 @@ - + diff --git a/admin/src/lib/scope-constants.ts b/admin/src/lib/scope-constants.ts index 3399bfb56..f4db5df34 100644 --- a/admin/src/lib/scope-constants.ts +++ b/admin/src/lib/scope-constants.ts @@ -10,11 +10,14 @@ * or `bun run verify` will reject the change. */ -export type Scope = 'read' | 'write' | 'admin' | 'sources_admin' | 'users_admin'; +export type Scope = 'read' | 'write' | 'admin' | 'sources_admin' | 'users_admin' | 'agent'; // MIRROR OF src/core/scope.ts ALLOWED_SCOPES_LIST — keep alphabetically sorted. +// v0.38: 'agent' added for the submit_agent remote-MCP op (sibling to admin, +// NOT implied — existing admin clients must re-register to opt in). export const ALLOWED_SCOPES_LIST: ReadonlyArray = [ 'admin', + 'agent', 'read', 'sources_admin', 'users_admin',