@suveren/gateway 0.27.2 → 0.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,120 +0,0 @@
1
- var ag=Object.defineProperty;var ig=(n,s,i)=>s in n?ag(n,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[s]=i;var zs=(n,s,i)=>ig(n,typeof s!="symbol"?s+"":s,i);(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const h of d.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&o(h)}).observe(document,{childList:!0,subtree:!0});function i(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function o(c){if(c.ep)return;c.ep=!0;const d=i(c);fetch(c.href,d)}})();var ul={exports:{}},Fs={},dl={exports:{}},Be={};/**
2
- * @license React
3
- * react.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var Vd;function og(){if(Vd)return Be;Vd=1;var n=Symbol.for("react.element"),s=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),d=Symbol.for("react.provider"),h=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),j=Symbol.iterator;function w(S){return S===null||typeof S!="object"?null:(S=j&&S[j]||S["@@iterator"],typeof S=="function"?S:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,k={};function C(S,A,G){this.props=S,this.context=A,this.refs=k,this.updater=G||N}C.prototype.isReactComponent={},C.prototype.setState=function(S,A){if(typeof S!="object"&&typeof S!="function"&&S!=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,S,A,"setState")},C.prototype.forceUpdate=function(S){this.updater.enqueueForceUpdate(this,S,"forceUpdate")};function T(){}T.prototype=C.prototype;function I(S,A,G){this.props=S,this.context=A,this.refs=k,this.updater=G||N}var $=I.prototype=new T;$.constructor=I,E($,C.prototype),$.isPureReactComponent=!0;var P=Array.isArray,D=Object.prototype.hasOwnProperty,K={current:null},V={key:!0,ref:!0,__self:!0,__source:!0};function ce(S,A,G){var te,ue={},ve=null,Ce=null;if(A!=null)for(te in A.ref!==void 0&&(Ce=A.ref),A.key!==void 0&&(ve=""+A.key),A)D.call(A,te)&&!V.hasOwnProperty(te)&&(ue[te]=A[te]);var ke=arguments.length-2;if(ke===1)ue.children=G;else if(1<ke){for(var se=Array(ke),$e=0;$e<ke;$e++)se[$e]=arguments[$e+2];ue.children=se}if(S&&S.defaultProps)for(te in ke=S.defaultProps,ke)ue[te]===void 0&&(ue[te]=ke[te]);return{$$typeof:n,type:S,key:ve,ref:Ce,props:ue,_owner:K.current}}function Y(S,A){return{$$typeof:n,type:S.type,key:A,ref:S.ref,props:S.props,_owner:S._owner}}function re(S){return typeof S=="object"&&S!==null&&S.$$typeof===n}function J(S){var A={"=":"=0",":":"=2"};return"$"+S.replace(/[=:]/g,function(G){return A[G]})}var O=/\/+/g;function fe(S,A){return typeof S=="object"&&S!==null&&S.key!=null?J(""+S.key):A.toString(36)}function ie(S,A,G,te,ue){var ve=typeof S;(ve==="undefined"||ve==="boolean")&&(S=null);var Ce=!1;if(S===null)Ce=!0;else switch(ve){case"string":case"number":Ce=!0;break;case"object":switch(S.$$typeof){case n:case s:Ce=!0}}if(Ce)return Ce=S,ue=ue(Ce),S=te===""?"."+fe(Ce,0):te,P(ue)?(G="",S!=null&&(G=S.replace(O,"$&/")+"/"),ie(ue,A,G,"",function($e){return $e})):ue!=null&&(re(ue)&&(ue=Y(ue,G+(!ue.key||Ce&&Ce.key===ue.key?"":(""+ue.key).replace(O,"$&/")+"/")+S)),A.push(ue)),1;if(Ce=0,te=te===""?".":te+":",P(S))for(var ke=0;ke<S.length;ke++){ve=S[ke];var se=te+fe(ve,ke);Ce+=ie(ve,A,G,se,ue)}else if(se=w(S),typeof se=="function")for(S=se.call(S),ke=0;!(ve=S.next()).done;)ve=ve.value,se=te+fe(ve,ke++),Ce+=ie(ve,A,G,se,ue);else if(ve==="object")throw A=String(S),Error("Objects are not valid as a React child (found: "+(A==="[object Object]"?"object with keys {"+Object.keys(S).join(", ")+"}":A)+"). If you meant to render a collection of children, use an array instead.");return Ce}function Z(S,A,G){if(S==null)return S;var te=[],ue=0;return ie(S,te,"","",function(ve){return A.call(G,ve,ue++)}),te}function pe(S){if(S._status===-1){var A=S._result;A=A(),A.then(function(G){(S._status===0||S._status===-1)&&(S._status=1,S._result=G)},function(G){(S._status===0||S._status===-1)&&(S._status=2,S._result=G)}),S._status===-1&&(S._status=0,S._result=A)}if(S._status===1)return S._result.default;throw S._result}var ee={current:null},W={transition:null},M={ReactCurrentDispatcher:ee,ReactCurrentBatchConfig:W,ReactCurrentOwner:K};function H(){throw Error("act(...) is not supported in production builds of React.")}return Be.Children={map:Z,forEach:function(S,A,G){Z(S,function(){A.apply(this,arguments)},G)},count:function(S){var A=0;return Z(S,function(){A++}),A},toArray:function(S){return Z(S,function(A){return A})||[]},only:function(S){if(!re(S))throw Error("React.Children.only expected to receive a single React element child.");return S}},Be.Component=C,Be.Fragment=i,Be.Profiler=c,Be.PureComponent=I,Be.StrictMode=o,Be.Suspense=p,Be.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=M,Be.act=H,Be.cloneElement=function(S,A,G){if(S==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+S+".");var te=E({},S.props),ue=S.key,ve=S.ref,Ce=S._owner;if(A!=null){if(A.ref!==void 0&&(ve=A.ref,Ce=K.current),A.key!==void 0&&(ue=""+A.key),S.type&&S.type.defaultProps)var ke=S.type.defaultProps;for(se in A)D.call(A,se)&&!V.hasOwnProperty(se)&&(te[se]=A[se]===void 0&&ke!==void 0?ke[se]:A[se])}var se=arguments.length-2;if(se===1)te.children=G;else if(1<se){ke=Array(se);for(var $e=0;$e<se;$e++)ke[$e]=arguments[$e+2];te.children=ke}return{$$typeof:n,type:S.type,key:ue,ref:ve,props:te,_owner:Ce}},Be.createContext=function(S){return S={$$typeof:h,_currentValue:S,_currentValue2:S,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},S.Provider={$$typeof:d,_context:S},S.Consumer=S},Be.createElement=ce,Be.createFactory=function(S){var A=ce.bind(null,S);return A.type=S,A},Be.createRef=function(){return{current:null}},Be.forwardRef=function(S){return{$$typeof:g,render:S}},Be.isValidElement=re,Be.lazy=function(S){return{$$typeof:v,_payload:{_status:-1,_result:S},_init:pe}},Be.memo=function(S,A){return{$$typeof:y,type:S,compare:A===void 0?null:A}},Be.startTransition=function(S){var A=W.transition;W.transition={};try{S()}finally{W.transition=A}},Be.unstable_act=H,Be.useCallback=function(S,A){return ee.current.useCallback(S,A)},Be.useContext=function(S){return ee.current.useContext(S)},Be.useDebugValue=function(){},Be.useDeferredValue=function(S){return ee.current.useDeferredValue(S)},Be.useEffect=function(S,A){return ee.current.useEffect(S,A)},Be.useId=function(){return ee.current.useId()},Be.useImperativeHandle=function(S,A,G){return ee.current.useImperativeHandle(S,A,G)},Be.useInsertionEffect=function(S,A){return ee.current.useInsertionEffect(S,A)},Be.useLayoutEffect=function(S,A){return ee.current.useLayoutEffect(S,A)},Be.useMemo=function(S,A){return ee.current.useMemo(S,A)},Be.useReducer=function(S,A,G){return ee.current.useReducer(S,A,G)},Be.useRef=function(S){return ee.current.useRef(S)},Be.useState=function(S){return ee.current.useState(S)},Be.useSyncExternalStore=function(S,A,G){return ee.current.useSyncExternalStore(S,A,G)},Be.useTransition=function(){return ee.current.useTransition()},Be.version="18.3.1",Be}var Gd;function Bl(){return Gd||(Gd=1,dl.exports=og()),dl.exports}/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var Kd;function lg(){if(Kd)return Fs;Kd=1;var n=Bl(),s=Symbol.for("react.element"),i=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,c=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function h(g,p,y){var v,j={},w=null,N=null;y!==void 0&&(w=""+y),p.key!==void 0&&(w=""+p.key),p.ref!==void 0&&(N=p.ref);for(v in p)o.call(p,v)&&!d.hasOwnProperty(v)&&(j[v]=p[v]);if(g&&g.defaultProps)for(v in p=g.defaultProps,p)j[v]===void 0&&(j[v]=p[v]);return{$$typeof:s,type:g,key:w,ref:N,props:j,_owner:c.current}}return Fs.Fragment=i,Fs.jsx=h,Fs.jsxs=h,Fs}var Yd;function cg(){return Yd||(Yd=1,ul.exports=lg()),ul.exports}var r=cg(),f=Bl(),ai={},fl={exports:{}},Mt={},ml={exports:{}},hl={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */var Jd;function ug(){return Jd||(Jd=1,(function(n){function s(W,M){var H=W.length;W.push(M);e:for(;0<H;){var S=H-1>>>1,A=W[S];if(0<c(A,M))W[S]=M,W[H]=A,H=S;else break e}}function i(W){return W.length===0?null:W[0]}function o(W){if(W.length===0)return null;var M=W[0],H=W.pop();if(H!==M){W[0]=H;e:for(var S=0,A=W.length,G=A>>>1;S<G;){var te=2*(S+1)-1,ue=W[te],ve=te+1,Ce=W[ve];if(0>c(ue,H))ve<A&&0>c(Ce,ue)?(W[S]=Ce,W[ve]=H,S=ve):(W[S]=ue,W[te]=H,S=te);else if(ve<A&&0>c(Ce,H))W[S]=Ce,W[ve]=H,S=ve;else break e}}return M}function c(W,M){var H=W.sortIndex-M.sortIndex;return H!==0?H:W.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var d=performance;n.unstable_now=function(){return d.now()}}else{var h=Date,g=h.now();n.unstable_now=function(){return h.now()-g}}var p=[],y=[],v=1,j=null,w=3,N=!1,E=!1,k=!1,C=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function $(W){for(var M=i(y);M!==null;){if(M.callback===null)o(y);else if(M.startTime<=W)o(y),M.sortIndex=M.expirationTime,s(p,M);else break;M=i(y)}}function P(W){if(k=!1,$(W),!E)if(i(p)!==null)E=!0,pe(D);else{var M=i(y);M!==null&&ee(P,M.startTime-W)}}function D(W,M){E=!1,k&&(k=!1,T(ce),ce=-1),N=!0;var H=w;try{for($(M),j=i(p);j!==null&&(!(j.expirationTime>M)||W&&!J());){var S=j.callback;if(typeof S=="function"){j.callback=null,w=j.priorityLevel;var A=S(j.expirationTime<=M);M=n.unstable_now(),typeof A=="function"?j.callback=A:j===i(p)&&o(p),$(M)}else o(p);j=i(p)}if(j!==null)var G=!0;else{var te=i(y);te!==null&&ee(P,te.startTime-M),G=!1}return G}finally{j=null,w=H,N=!1}}var K=!1,V=null,ce=-1,Y=5,re=-1;function J(){return!(n.unstable_now()-re<Y)}function O(){if(V!==null){var W=n.unstable_now();re=W;var M=!0;try{M=V(!0,W)}finally{M?fe():(K=!1,V=null)}}else K=!1}var fe;if(typeof I=="function")fe=function(){I(O)};else if(typeof MessageChannel<"u"){var ie=new MessageChannel,Z=ie.port2;ie.port1.onmessage=O,fe=function(){Z.postMessage(null)}}else fe=function(){C(O,0)};function pe(W){V=W,K||(K=!0,fe())}function ee(W,M){ce=C(function(){W(n.unstable_now())},M)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(W){W.callback=null},n.unstable_continueExecution=function(){E||N||(E=!0,pe(D))},n.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Y=0<W?Math.floor(1e3/W):5},n.unstable_getCurrentPriorityLevel=function(){return w},n.unstable_getFirstCallbackNode=function(){return i(p)},n.unstable_next=function(W){switch(w){case 1:case 2:case 3:var M=3;break;default:M=w}var H=w;w=M;try{return W()}finally{w=H}},n.unstable_pauseExecution=function(){},n.unstable_requestPaint=function(){},n.unstable_runWithPriority=function(W,M){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var H=w;w=W;try{return M()}finally{w=H}},n.unstable_scheduleCallback=function(W,M,H){var S=n.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?S+H:S):H=S,W){case 1:var A=-1;break;case 2:A=250;break;case 5:A=1073741823;break;case 4:A=1e4;break;default:A=5e3}return A=H+A,W={id:v++,callback:M,priorityLevel:W,startTime:H,expirationTime:A,sortIndex:-1},H>S?(W.sortIndex=H,s(y,W),i(p)===null&&W===i(y)&&(k?(T(ce),ce=-1):k=!0,ee(P,H-S))):(W.sortIndex=A,s(p,W),E||N||(E=!0,pe(D))),W},n.unstable_shouldYield=J,n.unstable_wrapCallback=function(W){var M=w;return function(){var H=w;w=M;try{return W.apply(this,arguments)}finally{w=H}}}})(hl)),hl}var qd;function dg(){return qd||(qd=1,ml.exports=ug()),ml.exports}/**
26
- * @license React
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */var Qd;function fg(){if(Qd)return Mt;Qd=1;var n=Bl(),s=dg();function i(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,a=1;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,c={};function d(e,t){h(e,t),h(e+"Capture",t)}function h(e,t){for(c[e]=t,e=0;e<t.length;e++)o.add(t[e])}var g=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,y=/^[: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]*$/,v={},j={};function w(e){return p.call(j,e)?!0:p.call(v,e)?!1:y.test(e)?j[e]=!0:(v[e]=!0,!1)}function N(e,t,a,l){if(a!==null&&a.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return l?!1:a!==null?!a.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function E(e,t,a,l){if(t===null||typeof t>"u"||N(e,t,a,l))return!0;if(l)return!1;if(a!==null)switch(a.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 k(e,t,a,l,u,m,x){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=l,this.attributeNamespace=u,this.mustUseProperty=a,this.propertyName=e,this.type=t,this.sanitizeURL=m,this.removeEmptyString=x}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){C[e]=new k(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];C[t]=new k(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){C[e]=new k(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){C[e]=new k(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){C[e]=new k(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){C[e]=new k(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){C[e]=new k(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){C[e]=new k(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){C[e]=new k(e,5,!1,e.toLowerCase(),null,!1,!1)});var T=/[\-:]([a-z])/g;function I(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(T,I);C[t]=new k(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(T,I);C[t]=new k(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(T,I);C[t]=new k(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){C[e]=new k(e,1,!1,e.toLowerCase(),null,!1,!1)}),C.xlinkHref=new k("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){C[e]=new k(e,1,!1,e.toLowerCase(),null,!0,!0)});function $(e,t,a,l){var u=C.hasOwnProperty(t)?C[t]:null;(u!==null?u.type!==0:l||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(E(t,a,u,l)&&(a=null),l||u===null?w(t)&&(a===null?e.removeAttribute(t):e.setAttribute(t,""+a)):u.mustUseProperty?e[u.propertyName]=a===null?u.type===3?!1:"":a:(t=u.attributeName,l=u.attributeNamespace,a===null?e.removeAttribute(t):(u=u.type,a=u===3||u===4&&a===!0?"":""+a,l?e.setAttributeNS(l,t,a):e.setAttribute(t,a))))}var P=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,D=Symbol.for("react.element"),K=Symbol.for("react.portal"),V=Symbol.for("react.fragment"),ce=Symbol.for("react.strict_mode"),Y=Symbol.for("react.profiler"),re=Symbol.for("react.provider"),J=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),fe=Symbol.for("react.suspense"),ie=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),pe=Symbol.for("react.lazy"),ee=Symbol.for("react.offscreen"),W=Symbol.iterator;function M(e){return e===null||typeof e!="object"?null:(e=W&&e[W]||e["@@iterator"],typeof e=="function"?e:null)}var H=Object.assign,S;function A(e){if(S===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);S=t&&t[1]||""}return`
34
- `+S+e}var G=!1;function te(e,t){if(!e||G)return"";G=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(U){var l=U}Reflect.construct(e,[],t)}else{try{t.call()}catch(U){l=U}e.call(t.prototype)}else{try{throw Error()}catch(U){l=U}e()}}catch(U){if(U&&l&&typeof U.stack=="string"){for(var u=U.stack.split(`
35
- `),m=l.stack.split(`
36
- `),x=u.length-1,b=m.length-1;1<=x&&0<=b&&u[x]!==m[b];)b--;for(;1<=x&&0<=b;x--,b--)if(u[x]!==m[b]){if(x!==1||b!==1)do if(x--,b--,0>b||u[x]!==m[b]){var R=`
37
- `+u[x].replace(" at new "," at ");return e.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",e.displayName)),R}while(1<=x&&0<=b);break}}}finally{G=!1,Error.prepareStackTrace=a}return(e=e?e.displayName||e.name:"")?A(e):""}function ue(e){switch(e.tag){case 5:return A(e.type);case 16:return A("Lazy");case 13:return A("Suspense");case 19:return A("SuspenseList");case 0:case 2:case 15:return e=te(e.type,!1),e;case 11:return e=te(e.type.render,!1),e;case 1:return e=te(e.type,!0),e;default:return""}}function ve(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 V:return"Fragment";case K:return"Portal";case Y:return"Profiler";case ce:return"StrictMode";case fe:return"Suspense";case ie:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case J:return(e.displayName||"Context")+".Consumer";case re:return(e._context.displayName||"Context")+".Provider";case O:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Z:return t=e.displayName||null,t!==null?t:ve(e.type)||"Memo";case pe:t=e._payload,e=e._init;try{return ve(e(t))}catch{}}return null}function Ce(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 ve(t);case 8:return t===ce?"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 ke(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function $e(e){var t=se(e)?"checked":"value",a=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),l=""+e[t];if(!e.hasOwnProperty(t)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var u=a.get,m=a.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return u.call(this)},set:function(x){l=""+x,m.call(this,x)}}),Object.defineProperty(e,t,{enumerable:a.enumerable}),{getValue:function(){return l},setValue:function(x){l=""+x},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ee(e){e._valueTracker||(e._valueTracker=$e(e))}function _e(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==a?(t.setValue(e),!0):!1}function me(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 X(e,t){var a=t.checked;return H({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??e._wrapperState.initialChecked})}function we(e,t){var a=t.defaultValue==null?"":t.defaultValue,l=t.checked!=null?t.checked:t.defaultChecked;a=ke(t.value!=null?t.value:a),e._wrapperState={initialChecked:l,initialValue:a,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Te(e,t){t=t.checked,t!=null&&$(e,"checked",t,!1)}function Le(e,t){Te(e,t);var a=ke(t.value),l=t.type;if(a!=null)l==="number"?(a===0&&e.value===""||e.value!=a)&&(e.value=""+a):e.value!==""+a&&(e.value=""+a);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?xt(e,t.type,a):t.hasOwnProperty("defaultValue")&&xt(e,t.type,ke(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function lt(e,t,a){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var l=t.type;if(!(l!=="submit"&&l!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,a||t===e.value||(e.value=t),e.defaultValue=t}a=e.name,a!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,a!==""&&(e.name=a)}function xt(e,t,a){(t!=="number"||me(e.ownerDocument)!==e)&&(a==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+a&&(e.defaultValue=""+a))}var Ke=Array.isArray;function et(e,t,a,l){if(e=e.options,t){t={};for(var u=0;u<a.length;u++)t["$"+a[u]]=!0;for(a=0;a<e.length;a++)u=t.hasOwnProperty("$"+e[a].value),e[a].selected!==u&&(e[a].selected=u),u&&l&&(e[a].defaultSelected=!0)}else{for(a=""+ke(a),t=null,u=0;u<e.length;u++){if(e[u].value===a){e[u].selected=!0,l&&(e[u].defaultSelected=!0);return}t!==null||e[u].disabled||(t=e[u])}t!==null&&(t.selected=!0)}}function st(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(i(91));return H({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function ht(e,t){var a=t.value;if(a==null){if(a=t.children,t=t.defaultValue,a!=null){if(t!=null)throw Error(i(92));if(Ke(a)){if(1<a.length)throw Error(i(93));a=a[0]}t=a}t==null&&(t=""),a=t}e._wrapperState={initialValue:ke(a)}}function Fe(e,t){var a=ke(t.value),l=ke(t.defaultValue);a!=null&&(a=""+a,a!==e.value&&(e.value=a),t.defaultValue==null&&e.defaultValue!==a&&(e.defaultValue=a)),l!=null&&(e.defaultValue=""+l)}function L(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function oe(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function he(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?oe(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Re,de=(function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,a,l,u){MSApp.execUnsafeLocalFunction(function(){return e(t,a,l,u)})}:e})(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Re=Re||document.createElement("div"),Re.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Re.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Oe(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}var Ge={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},Ye=["Webkit","ms","Moz","O"];Object.keys(Ge).forEach(function(e){Ye.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ge[t]=Ge[e]})});function ft(e,t,a){return t==null||typeof t=="boolean"||t===""?"":a||typeof t!="number"||t===0||Ge.hasOwnProperty(e)&&Ge[e]?(""+t).trim():t+"px"}function fn(e,t){e=e.style;for(var a in t)if(t.hasOwnProperty(a)){var l=a.indexOf("--")===0,u=ft(a,t[a],l);a==="float"&&(a="cssFloat"),l?e.setProperty(a,u):e[a]=u}}var vn=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 tt(e,t){if(t){if(vn[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(i(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(i(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(i(61))}if(t.style!=null&&typeof t.style!="object")throw Error(i(62))}}function bt(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 Et=null;function wt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ae=null,je=null,ge=null;function Me(e){if(e=js(e)){if(typeof ae!="function")throw Error(i(280));var t=e.stateNode;t&&(t=wa(t),ae(e.stateNode,e.type,t))}}function ze(e){je?ge?ge.push(e):ge=[e]:je=e}function Je(){if(je){var e=je,t=ge;if(ge=je=null,Me(e),t)for(e=0;e<t.length;e++)Me(t[e])}}function Dt(e,t){return e(t)}function Xn(){}var ts=!1;function Xs(e,t,a){if(ts)return e(t,a);ts=!0;try{return Dt(e,t,a)}finally{ts=!1,(je!==null||ge!==null)&&(Xn(),Je())}}function xn(e,t){var a=e.stateNode;if(a===null)return null;var l=wa(a);if(l===null)return null;a=l[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(i(231,t,typeof a));return a}var Zn=!1;if(g)try{var er={};Object.defineProperty(er,"passive",{get:function(){Zn=!0}}),window.addEventListener("test",er,er),window.removeEventListener("test",er,er)}catch{Zn=!1}function Zs(e,t,a,l,u,m,x,b,R){var U=Array.prototype.slice.call(arguments,3);try{t.apply(a,U)}catch(Q){this.onError(Q)}}var Pn=!1,tr=null,nr=!1,ns=null,kr={onError:function(e){Pn=!0,tr=e}};function wn(e,t,a,l,u,m,x,b,R){Pn=!1,tr=null,Zs.apply(kr,arguments)}function hh(e,t,a,l,u,m,x,b,R){if(wn.apply(this,arguments),Pn){if(Pn){var U=tr;Pn=!1,tr=null}else throw Error(i(198));nr||(nr=!0,ns=U)}}function rr(e){var t=e,a=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(a=t.return),e=t.return;while(e)}return t.tag===3?a:null}function hc(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function pc(e){if(rr(e)!==e)throw Error(i(188))}function ph(e){var t=e.alternate;if(!t){if(t=rr(e),t===null)throw Error(i(188));return t!==e?null:e}for(var a=e,l=t;;){var u=a.return;if(u===null)break;var m=u.alternate;if(m===null){if(l=u.return,l!==null){a=l;continue}break}if(u.child===m.child){for(m=u.child;m;){if(m===a)return pc(u),e;if(m===l)return pc(u),t;m=m.sibling}throw Error(i(188))}if(a.return!==l.return)a=u,l=m;else{for(var x=!1,b=u.child;b;){if(b===a){x=!0,a=u,l=m;break}if(b===l){x=!0,l=u,a=m;break}b=b.sibling}if(!x){for(b=m.child;b;){if(b===a){x=!0,a=m,l=u;break}if(b===l){x=!0,l=m,a=u;break}b=b.sibling}if(!x)throw Error(i(189))}}if(a.alternate!==l)throw Error(i(190))}if(a.tag!==3)throw Error(i(188));return a.stateNode.current===a?e:t}function gc(e){return e=ph(e),e!==null?yc(e):null}function yc(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=yc(e);if(t!==null)return t;e=e.sibling}return null}var vc=s.unstable_scheduleCallback,xc=s.unstable_cancelCallback,gh=s.unstable_shouldYield,yh=s.unstable_requestPaint,ct=s.unstable_now,vh=s.unstable_getCurrentPriorityLevel,Ri=s.unstable_ImmediatePriority,wc=s.unstable_UserBlockingPriority,ea=s.unstable_NormalPriority,xh=s.unstable_LowPriority,jc=s.unstable_IdlePriority,ta=null,mn=null;function wh(e){if(mn&&typeof mn.onCommitFiberRoot=="function")try{mn.onCommitFiberRoot(ta,e,void 0,(e.current.flags&128)===128)}catch{}}var tn=Math.clz32?Math.clz32:kh,jh=Math.log,Sh=Math.LN2;function kh(e){return e>>>=0,e===0?32:31-(jh(e)/Sh|0)|0}var na=64,ra=4194304;function rs(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 sa(e,t){var a=e.pendingLanes;if(a===0)return 0;var l=0,u=e.suspendedLanes,m=e.pingedLanes,x=a&268435455;if(x!==0){var b=x&~u;b!==0?l=rs(b):(m&=x,m!==0&&(l=rs(m)))}else x=a&~u,x!==0?l=rs(x):m!==0&&(l=rs(m));if(l===0)return 0;if(t!==0&&t!==l&&(t&u)===0&&(u=l&-l,m=t&-t,u>=m||u===16&&(m&4194240)!==0))return t;if((l&4)!==0&&(l|=a&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=l;0<t;)a=31-tn(t),u=1<<a,l|=e[a],t&=~u;return l}function bh(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 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 t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Nh(e,t){for(var a=e.suspendedLanes,l=e.pingedLanes,u=e.expirationTimes,m=e.pendingLanes;0<m;){var x=31-tn(m),b=1<<x,R=u[x];R===-1?((b&a)===0||(b&l)!==0)&&(u[x]=bh(b,t)):R<=t&&(e.expiredLanes|=b),m&=~b}}function Ii(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Sc(){var e=na;return na<<=1,(na&4194240)===0&&(na=64),e}function Ai(e){for(var t=[],a=0;31>a;a++)t.push(e);return t}function ss(e,t,a){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-tn(t),e[t]=a}function Ch(e,t){var a=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 l=e.eventTimes;for(e=e.expirationTimes;0<a;){var u=31-tn(a),m=1<<u;t[u]=0,l[u]=-1,e[u]=-1,a&=~m}}function Pi(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var l=31-tn(a),u=1<<l;u&t|e[l]&t&&(e[l]|=t),a&=~u}}var Ve=0;function kc(e){return e&=-e,1<e?4<e?(e&268435455)!==0?16:536870912:4:1}var bc,_i,Nc,Cc,Ec,Li=!1,aa=[],_n=null,Ln=null,$n=null,as=new Map,is=new Map,zn=[],Eh="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Tc(e,t){switch(e){case"focusin":case"focusout":_n=null;break;case"dragenter":case"dragleave":Ln=null;break;case"mouseover":case"mouseout":$n=null;break;case"pointerover":case"pointerout":as.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":is.delete(t.pointerId)}}function os(e,t,a,l,u,m){return e===null||e.nativeEvent!==m?(e={blockedOn:t,domEventName:a,eventSystemFlags:l,nativeEvent:m,targetContainers:[u]},t!==null&&(t=js(t),t!==null&&_i(t)),e):(e.eventSystemFlags|=l,t=e.targetContainers,u!==null&&t.indexOf(u)===-1&&t.push(u),e)}function Th(e,t,a,l,u){switch(t){case"focusin":return _n=os(_n,e,t,a,l,u),!0;case"dragenter":return Ln=os(Ln,e,t,a,l,u),!0;case"mouseover":return $n=os($n,e,t,a,l,u),!0;case"pointerover":var m=u.pointerId;return as.set(m,os(as.get(m)||null,e,t,a,l,u)),!0;case"gotpointercapture":return m=u.pointerId,is.set(m,os(is.get(m)||null,e,t,a,l,u)),!0}return!1}function Rc(e){var t=sr(e.target);if(t!==null){var a=rr(t);if(a!==null){if(t=a.tag,t===13){if(t=hc(a),t!==null){e.blockedOn=t,Ec(e.priority,function(){Nc(a)});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ia(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=zi(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(a===null){a=e.nativeEvent;var l=new a.constructor(a.type,a);Et=l,a.target.dispatchEvent(l),Et=null}else return t=js(a),t!==null&&_i(t),e.blockedOn=a,!1;t.shift()}return!0}function Ic(e,t,a){ia(e)&&a.delete(t)}function Rh(){Li=!1,_n!==null&&ia(_n)&&(_n=null),Ln!==null&&ia(Ln)&&(Ln=null),$n!==null&&ia($n)&&($n=null),as.forEach(Ic),is.forEach(Ic)}function ls(e,t){e.blockedOn===t&&(e.blockedOn=null,Li||(Li=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Rh)))}function cs(e){function t(u){return ls(u,e)}if(0<aa.length){ls(aa[0],e);for(var a=1;a<aa.length;a++){var l=aa[a];l.blockedOn===e&&(l.blockedOn=null)}}for(_n!==null&&ls(_n,e),Ln!==null&&ls(Ln,e),$n!==null&&ls($n,e),as.forEach(t),is.forEach(t),a=0;a<zn.length;a++)l=zn[a],l.blockedOn===e&&(l.blockedOn=null);for(;0<zn.length&&(a=zn[0],a.blockedOn===null);)Rc(a),a.blockedOn===null&&zn.shift()}var br=P.ReactCurrentBatchConfig,oa=!0;function Ih(e,t,a,l){var u=Ve,m=br.transition;br.transition=null;try{Ve=1,$i(e,t,a,l)}finally{Ve=u,br.transition=m}}function Ah(e,t,a,l){var u=Ve,m=br.transition;br.transition=null;try{Ve=4,$i(e,t,a,l)}finally{Ve=u,br.transition=m}}function $i(e,t,a,l){if(oa){var u=zi(e,t,a,l);if(u===null)Zi(e,t,l,la,a),Tc(e,l);else if(Th(u,e,t,a,l))l.stopPropagation();else if(Tc(e,l),t&4&&-1<Eh.indexOf(e)){for(;u!==null;){var m=js(u);if(m!==null&&bc(m),m=zi(e,t,a,l),m===null&&Zi(e,t,l,la,a),m===u)break;u=m}u!==null&&l.stopPropagation()}else Zi(e,t,l,null,a)}}var la=null;function zi(e,t,a,l){if(la=null,e=wt(l),e=sr(e),e!==null)if(t=rr(e),t===null)e=null;else if(a=t.tag,a===13){if(e=hc(t),e!==null)return e;e=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return la=e,null}function Ac(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(vh()){case Ri:return 1;case wc:return 4;case ea:case xh:return 16;case jc:return 536870912;default:return 16}default:return 16}}var Fn=null,Fi=null,ca=null;function Pc(){if(ca)return ca;var e,t=Fi,a=t.length,l,u="value"in Fn?Fn.value:Fn.textContent,m=u.length;for(e=0;e<a&&t[e]===u[e];e++);var x=a-e;for(l=1;l<=x&&t[a-l]===u[m-l];l++);return ca=u.slice(e,1<l?1-l:void 0)}function ua(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function da(){return!0}function _c(){return!1}function Ut(e){function t(a,l,u,m,x){this._reactName=a,this._targetInst=u,this.type=l,this.nativeEvent=m,this.target=x,this.currentTarget=null;for(var b in e)e.hasOwnProperty(b)&&(a=e[b],this[b]=a?a(m):m[b]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?da:_c,this.isPropagationStopped=_c,this}return H(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=da)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=da)},persist:function(){},isPersistent:da}),t}var Nr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Oi=Ut(Nr),us=H({},Nr,{view:0,detail:0}),Ph=Ut(us),Mi,Bi,ds,fa=H({},us,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ui,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ds&&(ds&&e.type==="mousemove"?(Mi=e.screenX-ds.screenX,Bi=e.screenY-ds.screenY):Bi=Mi=0,ds=e),Mi)},movementY:function(e){return"movementY"in e?e.movementY:Bi}}),Lc=Ut(fa),_h=H({},fa,{dataTransfer:0}),Lh=Ut(_h),$h=H({},us,{relatedTarget:0}),Di=Ut($h),zh=H({},Nr,{animationName:0,elapsedTime:0,pseudoElement:0}),Fh=Ut(zh),Oh=H({},Nr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Mh=Ut(Oh),Bh=H({},Nr,{data:0}),$c=Ut(Bh),Dh={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Uh={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Wh={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Hh(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Wh[e])?!!t[e]:!1}function Ui(){return Hh}var Vh=H({},us,{key:function(e){if(e.key){var t=Dh[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ua(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Uh[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ui,charCode:function(e){return e.type==="keypress"?ua(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ua(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Gh=Ut(Vh),Kh=H({},fa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),zc=Ut(Kh),Yh=H({},us,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ui}),Jh=Ut(Yh),qh=H({},Nr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Qh=Ut(qh),Xh=H({},fa,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Zh=Ut(Xh),ep=[9,13,27,32],Wi=g&&"CompositionEvent"in window,fs=null;g&&"documentMode"in document&&(fs=document.documentMode);var tp=g&&"TextEvent"in window&&!fs,Fc=g&&(!Wi||fs&&8<fs&&11>=fs),Oc=" ",Mc=!1;function Bc(e,t){switch(e){case"keyup":return ep.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Dc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Cr=!1;function np(e,t){switch(e){case"compositionend":return Dc(t);case"keypress":return t.which!==32?null:(Mc=!0,Oc);case"textInput":return e=t.data,e===Oc&&Mc?null:e;default:return null}}function rp(e,t){if(Cr)return e==="compositionend"||!Wi&&Bc(e,t)?(e=Pc(),ca=Fi=Fn=null,Cr=!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.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Fc&&t.locale!=="ko"?null:t.data;default:return null}}var sp={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Uc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!sp[e.type]:t==="textarea"}function Wc(e,t,a,l){ze(l),t=ya(t,"onChange"),0<t.length&&(a=new Oi("onChange","change",null,a,l),e.push({event:a,listeners:t}))}var ms=null,hs=null;function ap(e){ou(e,0)}function ma(e){var t=Ar(e);if(_e(t))return e}function ip(e,t){if(e==="change")return t}var Hc=!1;if(g){var Hi;if(g){var Vi="oninput"in document;if(!Vi){var Vc=document.createElement("div");Vc.setAttribute("oninput","return;"),Vi=typeof Vc.oninput=="function"}Hi=Vi}else Hi=!1;Hc=Hi&&(!document.documentMode||9<document.documentMode)}function Gc(){ms&&(ms.detachEvent("onpropertychange",Kc),hs=ms=null)}function Kc(e){if(e.propertyName==="value"&&ma(hs)){var t=[];Wc(t,hs,e,wt(e)),Xs(ap,t)}}function op(e,t,a){e==="focusin"?(Gc(),ms=t,hs=a,ms.attachEvent("onpropertychange",Kc)):e==="focusout"&&Gc()}function lp(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ma(hs)}function cp(e,t){if(e==="click")return ma(t)}function up(e,t){if(e==="input"||e==="change")return ma(t)}function dp(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var nn=typeof Object.is=="function"?Object.is:dp;function ps(e,t){if(nn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),l=Object.keys(t);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var u=a[l];if(!p.call(t,u)||!nn(e[u],t[u]))return!1}return!0}function Yc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Jc(e,t){var a=Yc(e);e=0;for(var l;a;){if(a.nodeType===3){if(l=e+a.textContent.length,e<=t&&l>=t)return{node:a,offset:t-e};e=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Yc(a)}}function qc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?qc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Qc(){for(var e=window,t=me();t instanceof e.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)e=t.contentWindow;else break;t=me(e.document)}return t}function Gi(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 fp(e){var t=Qc(),a=e.focusedElem,l=e.selectionRange;if(t!==a&&a&&a.ownerDocument&&qc(a.ownerDocument.documentElement,a)){if(l!==null&&Gi(a)){if(t=l.start,e=l.end,e===void 0&&(e=t),"selectionStart"in a)a.selectionStart=t,a.selectionEnd=Math.min(e,a.value.length);else if(e=(t=a.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var u=a.textContent.length,m=Math.min(l.start,u);l=l.end===void 0?m:Math.min(l.end,u),!e.extend&&m>l&&(u=l,l=m,m=u),u=Jc(a,m);var x=Jc(a,l);u&&x&&(e.rangeCount!==1||e.anchorNode!==u.node||e.anchorOffset!==u.offset||e.focusNode!==x.node||e.focusOffset!==x.offset)&&(t=t.createRange(),t.setStart(u.node,u.offset),e.removeAllRanges(),m>l?(e.addRange(t),e.extend(x.node,x.offset)):(t.setEnd(x.node,x.offset),e.addRange(t)))}}for(t=[],e=a;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<t.length;a++)e=t[a],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var mp=g&&"documentMode"in document&&11>=document.documentMode,Er=null,Ki=null,gs=null,Yi=!1;function Xc(e,t,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Yi||Er==null||Er!==me(l)||(l=Er,"selectionStart"in l&&Gi(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),gs&&ps(gs,l)||(gs=l,l=ya(Ki,"onSelect"),0<l.length&&(t=new Oi("onSelect","select",null,t,a),e.push({event:t,listeners:l}),t.target=Er)))}function ha(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var Tr={animationend:ha("Animation","AnimationEnd"),animationiteration:ha("Animation","AnimationIteration"),animationstart:ha("Animation","AnimationStart"),transitionend:ha("Transition","TransitionEnd")},Ji={},Zc={};g&&(Zc=document.createElement("div").style,"AnimationEvent"in window||(delete Tr.animationend.animation,delete Tr.animationiteration.animation,delete Tr.animationstart.animation),"TransitionEvent"in window||delete Tr.transitionend.transition);function pa(e){if(Ji[e])return Ji[e];if(!Tr[e])return e;var t=Tr[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in Zc)return Ji[e]=t[a];return e}var eu=pa("animationend"),tu=pa("animationiteration"),nu=pa("animationstart"),ru=pa("transitionend"),su=new Map,au="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function On(e,t){su.set(e,t),d(t,[e])}for(var qi=0;qi<au.length;qi++){var Qi=au[qi],hp=Qi.toLowerCase(),pp=Qi[0].toUpperCase()+Qi.slice(1);On(hp,"on"+pp)}On(eu,"onAnimationEnd"),On(tu,"onAnimationIteration"),On(nu,"onAnimationStart"),On("dblclick","onDoubleClick"),On("focusin","onFocus"),On("focusout","onBlur"),On(ru,"onTransitionEnd"),h("onMouseEnter",["mouseout","mouseover"]),h("onMouseLeave",["mouseout","mouseover"]),h("onPointerEnter",["pointerout","pointerover"]),h("onPointerLeave",["pointerout","pointerover"]),d("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),d("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),d("onBeforeInput",["compositionend","keypress","textInput","paste"]),d("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),d("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),d("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ys="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),gp=new Set("cancel close invalid load scroll toggle".split(" ").concat(ys));function iu(e,t,a){var l=e.type||"unknown-event";e.currentTarget=a,hh(l,t,void 0,e),e.currentTarget=null}function ou(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var l=e[a],u=l.event;l=l.listeners;e:{var m=void 0;if(t)for(var x=l.length-1;0<=x;x--){var b=l[x],R=b.instance,U=b.currentTarget;if(b=b.listener,R!==m&&u.isPropagationStopped())break e;iu(u,b,U),m=R}else for(x=0;x<l.length;x++){if(b=l[x],R=b.instance,U=b.currentTarget,b=b.listener,R!==m&&u.isPropagationStopped())break e;iu(u,b,U),m=R}}}if(nr)throw e=ns,nr=!1,ns=null,e}function Xe(e,t){var a=t[ao];a===void 0&&(a=t[ao]=new Set);var l=e+"__bubble";a.has(l)||(lu(t,e,2,!1),a.add(l))}function Xi(e,t,a){var l=0;t&&(l|=4),lu(a,e,l,t)}var ga="_reactListening"+Math.random().toString(36).slice(2);function vs(e){if(!e[ga]){e[ga]=!0,o.forEach(function(a){a!=="selectionchange"&&(gp.has(a)||Xi(a,!1,e),Xi(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[ga]||(t[ga]=!0,Xi("selectionchange",!1,t))}}function lu(e,t,a,l){switch(Ac(t)){case 1:var u=Ih;break;case 4:u=Ah;break;default:u=$i}a=u.bind(null,t,a,e),u=void 0,!Zn||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(u=!0),l?u!==void 0?e.addEventListener(t,a,{capture:!0,passive:u}):e.addEventListener(t,a,!0):u!==void 0?e.addEventListener(t,a,{passive:u}):e.addEventListener(t,a,!1)}function Zi(e,t,a,l,u){var m=l;if((t&1)===0&&(t&2)===0&&l!==null)e:for(;;){if(l===null)return;var x=l.tag;if(x===3||x===4){var b=l.stateNode.containerInfo;if(b===u||b.nodeType===8&&b.parentNode===u)break;if(x===4)for(x=l.return;x!==null;){var R=x.tag;if((R===3||R===4)&&(R=x.stateNode.containerInfo,R===u||R.nodeType===8&&R.parentNode===u))return;x=x.return}for(;b!==null;){if(x=sr(b),x===null)return;if(R=x.tag,R===5||R===6){l=m=x;continue e}b=b.parentNode}}l=l.return}Xs(function(){var U=m,Q=wt(a),ne=[];e:{var q=su.get(e);if(q!==void 0){var ye=Oi,Se=e;switch(e){case"keypress":if(ua(a)===0)break e;case"keydown":case"keyup":ye=Gh;break;case"focusin":Se="focus",ye=Di;break;case"focusout":Se="blur",ye=Di;break;case"beforeblur":case"afterblur":ye=Di;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ye=Lc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ye=Lh;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ye=Jh;break;case eu:case tu:case nu:ye=Fh;break;case ru:ye=Qh;break;case"scroll":ye=Ph;break;case"wheel":ye=Zh;break;case"copy":case"cut":case"paste":ye=Mh;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ye=zc}var be=(t&4)!==0,ut=!be&&e==="scroll",z=be?q!==null?q+"Capture":null:q;be=[];for(var _=U,F;_!==null;){F=_;var le=F.stateNode;if(F.tag===5&&le!==null&&(F=le,z!==null&&(le=xn(_,z),le!=null&&be.push(xs(_,le,F)))),ut)break;_=_.return}0<be.length&&(q=new ye(q,Se,null,a,Q),ne.push({event:q,listeners:be}))}}if((t&7)===0){e:{if(q=e==="mouseover"||e==="pointerover",ye=e==="mouseout"||e==="pointerout",q&&a!==Et&&(Se=a.relatedTarget||a.fromElement)&&(sr(Se)||Se[jn]))break e;if((ye||q)&&(q=Q.window===Q?Q:(q=Q.ownerDocument)?q.defaultView||q.parentWindow:window,ye?(Se=a.relatedTarget||a.toElement,ye=U,Se=Se?sr(Se):null,Se!==null&&(ut=rr(Se),Se!==ut||Se.tag!==5&&Se.tag!==6)&&(Se=null)):(ye=null,Se=U),ye!==Se)){if(be=Lc,le="onMouseLeave",z="onMouseEnter",_="mouse",(e==="pointerout"||e==="pointerover")&&(be=zc,le="onPointerLeave",z="onPointerEnter",_="pointer"),ut=ye==null?q:Ar(ye),F=Se==null?q:Ar(Se),q=new be(le,_+"leave",ye,a,Q),q.target=ut,q.relatedTarget=F,le=null,sr(Q)===U&&(be=new be(z,_+"enter",Se,a,Q),be.target=F,be.relatedTarget=ut,le=be),ut=le,ye&&Se)t:{for(be=ye,z=Se,_=0,F=be;F;F=Rr(F))_++;for(F=0,le=z;le;le=Rr(le))F++;for(;0<_-F;)be=Rr(be),_--;for(;0<F-_;)z=Rr(z),F--;for(;_--;){if(be===z||z!==null&&be===z.alternate)break t;be=Rr(be),z=Rr(z)}be=null}else be=null;ye!==null&&cu(ne,q,ye,be,!1),Se!==null&&ut!==null&&cu(ne,ut,Se,be,!0)}}e:{if(q=U?Ar(U):window,ye=q.nodeName&&q.nodeName.toLowerCase(),ye==="select"||ye==="input"&&q.type==="file")var Ne=ip;else if(Uc(q))if(Hc)Ne=up;else{Ne=lp;var Ie=op}else(ye=q.nodeName)&&ye.toLowerCase()==="input"&&(q.type==="checkbox"||q.type==="radio")&&(Ne=cp);if(Ne&&(Ne=Ne(e,U))){Wc(ne,Ne,a,Q);break e}Ie&&Ie(e,q,U),e==="focusout"&&(Ie=q._wrapperState)&&Ie.controlled&&q.type==="number"&&xt(q,"number",q.value)}switch(Ie=U?Ar(U):window,e){case"focusin":(Uc(Ie)||Ie.contentEditable==="true")&&(Er=Ie,Ki=U,gs=null);break;case"focusout":gs=Ki=Er=null;break;case"mousedown":Yi=!0;break;case"contextmenu":case"mouseup":case"dragend":Yi=!1,Xc(ne,a,Q);break;case"selectionchange":if(mp)break;case"keydown":case"keyup":Xc(ne,a,Q)}var Ae;if(Wi)e:{switch(e){case"compositionstart":var Pe="onCompositionStart";break e;case"compositionend":Pe="onCompositionEnd";break e;case"compositionupdate":Pe="onCompositionUpdate";break e}Pe=void 0}else Cr?Bc(e,a)&&(Pe="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(Pe="onCompositionStart");Pe&&(Fc&&a.locale!=="ko"&&(Cr||Pe!=="onCompositionStart"?Pe==="onCompositionEnd"&&Cr&&(Ae=Pc()):(Fn=Q,Fi="value"in Fn?Fn.value:Fn.textContent,Cr=!0)),Ie=ya(U,Pe),0<Ie.length&&(Pe=new $c(Pe,e,null,a,Q),ne.push({event:Pe,listeners:Ie}),Ae?Pe.data=Ae:(Ae=Dc(a),Ae!==null&&(Pe.data=Ae)))),(Ae=tp?np(e,a):rp(e,a))&&(U=ya(U,"onBeforeInput"),0<U.length&&(Q=new $c("onBeforeInput","beforeinput",null,a,Q),ne.push({event:Q,listeners:U}),Q.data=Ae))}ou(ne,t)})}function xs(e,t,a){return{instance:e,listener:t,currentTarget:a}}function ya(e,t){for(var a=t+"Capture",l=[];e!==null;){var u=e,m=u.stateNode;u.tag===5&&m!==null&&(u=m,m=xn(e,a),m!=null&&l.unshift(xs(e,m,u)),m=xn(e,t),m!=null&&l.push(xs(e,m,u))),e=e.return}return l}function Rr(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function cu(e,t,a,l,u){for(var m=t._reactName,x=[];a!==null&&a!==l;){var b=a,R=b.alternate,U=b.stateNode;if(R!==null&&R===l)break;b.tag===5&&U!==null&&(b=U,u?(R=xn(a,m),R!=null&&x.unshift(xs(a,R,b))):u||(R=xn(a,m),R!=null&&x.push(xs(a,R,b)))),a=a.return}x.length!==0&&e.push({event:t,listeners:x})}var yp=/\r\n?/g,vp=/\u0000|\uFFFD/g;function uu(e){return(typeof e=="string"?e:""+e).replace(yp,`
38
- `).replace(vp,"")}function va(e,t,a){if(t=uu(t),uu(e)!==t&&a)throw Error(i(425))}function xa(){}var eo=null,to=null;function no(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var ro=typeof setTimeout=="function"?setTimeout:void 0,xp=typeof clearTimeout=="function"?clearTimeout:void 0,du=typeof Promise=="function"?Promise:void 0,wp=typeof queueMicrotask=="function"?queueMicrotask:typeof du<"u"?function(e){return du.resolve(null).then(e).catch(jp)}:ro;function jp(e){setTimeout(function(){throw e})}function so(e,t){var a=t,l=0;do{var u=a.nextSibling;if(e.removeChild(a),u&&u.nodeType===8)if(a=u.data,a==="/$"){if(l===0){e.removeChild(u),cs(t);return}l--}else a!=="$"&&a!=="$?"&&a!=="$!"||l++;a=u}while(a);cs(t)}function Mn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function fu(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="$"||a==="$!"||a==="$?"){if(t===0)return e;t--}else a==="/$"&&t++}e=e.previousSibling}return null}var Ir=Math.random().toString(36).slice(2),hn="__reactFiber$"+Ir,ws="__reactProps$"+Ir,jn="__reactContainer$"+Ir,ao="__reactEvents$"+Ir,Sp="__reactListeners$"+Ir,kp="__reactHandles$"+Ir;function sr(e){var t=e[hn];if(t)return t;for(var a=e.parentNode;a;){if(t=a[jn]||a[hn]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=fu(e);e!==null;){if(a=e[hn])return a;e=fu(e)}return t}e=a,a=e.parentNode}return null}function js(e){return e=e[hn]||e[jn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Ar(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(i(33))}function wa(e){return e[ws]||null}var io=[],Pr=-1;function Bn(e){return{current:e}}function Ze(e){0>Pr||(e.current=io[Pr],io[Pr]=null,Pr--)}function qe(e,t){Pr++,io[Pr]=e.current,e.current=t}var Dn={},Tt=Bn(Dn),Lt=Bn(!1),ar=Dn;function _r(e,t){var a=e.type.contextTypes;if(!a)return Dn;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===t)return l.__reactInternalMemoizedMaskedChildContext;var u={},m;for(m in a)u[m]=t[m];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=u),u}function $t(e){return e=e.childContextTypes,e!=null}function ja(){Ze(Lt),Ze(Tt)}function mu(e,t,a){if(Tt.current!==Dn)throw Error(i(168));qe(Tt,t),qe(Lt,a)}function hu(e,t,a){var l=e.stateNode;if(t=t.childContextTypes,typeof l.getChildContext!="function")return a;l=l.getChildContext();for(var u in l)if(!(u in t))throw Error(i(108,Ce(e)||"Unknown",u));return H({},a,l)}function Sa(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Dn,ar=Tt.current,qe(Tt,e),qe(Lt,Lt.current),!0}function pu(e,t,a){var l=e.stateNode;if(!l)throw Error(i(169));a?(e=hu(e,t,ar),l.__reactInternalMemoizedMergedChildContext=e,Ze(Lt),Ze(Tt),qe(Tt,e)):Ze(Lt),qe(Lt,a)}var Sn=null,ka=!1,oo=!1;function gu(e){Sn===null?Sn=[e]:Sn.push(e)}function bp(e){ka=!0,gu(e)}function Un(){if(!oo&&Sn!==null){oo=!0;var e=0,t=Ve;try{var a=Sn;for(Ve=1;e<a.length;e++){var l=a[e];do l=l(!0);while(l!==null)}Sn=null,ka=!1}catch(u){throw Sn!==null&&(Sn=Sn.slice(e+1)),vc(Ri,Un),u}finally{Ve=t,oo=!1}}return null}var Lr=[],$r=0,ba=null,Na=0,Kt=[],Yt=0,ir=null,kn=1,bn="";function or(e,t){Lr[$r++]=Na,Lr[$r++]=ba,ba=e,Na=t}function yu(e,t,a){Kt[Yt++]=kn,Kt[Yt++]=bn,Kt[Yt++]=ir,ir=e;var l=kn;e=bn;var u=32-tn(l)-1;l&=~(1<<u),a+=1;var m=32-tn(t)+u;if(30<m){var x=u-u%5;m=(l&(1<<x)-1).toString(32),l>>=x,u-=x,kn=1<<32-tn(t)+u|a<<u|l,bn=m+e}else kn=1<<m|a<<u|l,bn=e}function lo(e){e.return!==null&&(or(e,1),yu(e,1,0))}function co(e){for(;e===ba;)ba=Lr[--$r],Lr[$r]=null,Na=Lr[--$r],Lr[$r]=null;for(;e===ir;)ir=Kt[--Yt],Kt[Yt]=null,bn=Kt[--Yt],Kt[Yt]=null,kn=Kt[--Yt],Kt[Yt]=null}var Wt=null,Ht=null,nt=!1,rn=null;function vu(e,t){var a=Xt(5,null,null,0);a.elementType="DELETED",a.stateNode=t,a.return=e,t=e.deletions,t===null?(e.deletions=[a],e.flags|=16):t.push(a)}function xu(e,t){switch(e.tag){case 5:var a=e.type;return t=t.nodeType!==1||a.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,Wt=e,Ht=Mn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Wt=e,Ht=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(a=ir!==null?{id:kn,overflow:bn}:null,e.memoizedState={dehydrated:t,treeContext:a,retryLane:1073741824},a=Xt(18,null,null,0),a.stateNode=t,a.return=e,e.child=a,Wt=e,Ht=null,!0):!1;default:return!1}}function uo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function fo(e){if(nt){var t=Ht;if(t){var a=t;if(!xu(e,t)){if(uo(e))throw Error(i(418));t=Mn(a.nextSibling);var l=Wt;t&&xu(e,t)?vu(l,a):(e.flags=e.flags&-4097|2,nt=!1,Wt=e)}}else{if(uo(e))throw Error(i(418));e.flags=e.flags&-4097|2,nt=!1,Wt=e}}}function wu(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Wt=e}function Ca(e){if(e!==Wt)return!1;if(!nt)return wu(e),nt=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!no(e.type,e.memoizedProps)),t&&(t=Ht)){if(uo(e))throw ju(),Error(i(418));for(;t;)vu(e,t),t=Mn(t.nextSibling)}if(wu(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"){if(t===0){Ht=Mn(e.nextSibling);break e}t--}else a!=="$"&&a!=="$!"&&a!=="$?"||t++}e=e.nextSibling}Ht=null}}else Ht=Wt?Mn(e.stateNode.nextSibling):null;return!0}function ju(){for(var e=Ht;e;)e=Mn(e.nextSibling)}function zr(){Ht=Wt=null,nt=!1}function mo(e){rn===null?rn=[e]:rn.push(e)}var Np=P.ReactCurrentBatchConfig;function Ss(e,t,a){if(e=a.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(i(309));var l=a.stateNode}if(!l)throw Error(i(147,e));var u=l,m=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===m?t.ref:(t=function(x){var b=u.refs;x===null?delete b[m]:b[m]=x},t._stringRef=m,t)}if(typeof e!="string")throw Error(i(284));if(!a._owner)throw Error(i(290,e))}return e}function Ea(e,t){throw e=Object.prototype.toString.call(t),Error(i(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Su(e){var t=e._init;return t(e._payload)}function ku(e){function t(z,_){if(e){var F=z.deletions;F===null?(z.deletions=[_],z.flags|=16):F.push(_)}}function a(z,_){if(!e)return null;for(;_!==null;)t(z,_),_=_.sibling;return null}function l(z,_){for(z=new Map;_!==null;)_.key!==null?z.set(_.key,_):z.set(_.index,_),_=_.sibling;return z}function u(z,_){return z=qn(z,_),z.index=0,z.sibling=null,z}function m(z,_,F){return z.index=F,e?(F=z.alternate,F!==null?(F=F.index,F<_?(z.flags|=2,_):F):(z.flags|=2,_)):(z.flags|=1048576,_)}function x(z){return e&&z.alternate===null&&(z.flags|=2),z}function b(z,_,F,le){return _===null||_.tag!==6?(_=sl(F,z.mode,le),_.return=z,_):(_=u(_,F),_.return=z,_)}function R(z,_,F,le){var Ne=F.type;return Ne===V?Q(z,_,F.props.children,le,F.key):_!==null&&(_.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===pe&&Su(Ne)===_.type)?(le=u(_,F.props),le.ref=Ss(z,_,F),le.return=z,le):(le=Qa(F.type,F.key,F.props,null,z.mode,le),le.ref=Ss(z,_,F),le.return=z,le)}function U(z,_,F,le){return _===null||_.tag!==4||_.stateNode.containerInfo!==F.containerInfo||_.stateNode.implementation!==F.implementation?(_=al(F,z.mode,le),_.return=z,_):(_=u(_,F.children||[]),_.return=z,_)}function Q(z,_,F,le,Ne){return _===null||_.tag!==7?(_=pr(F,z.mode,le,Ne),_.return=z,_):(_=u(_,F),_.return=z,_)}function ne(z,_,F){if(typeof _=="string"&&_!==""||typeof _=="number")return _=sl(""+_,z.mode,F),_.return=z,_;if(typeof _=="object"&&_!==null){switch(_.$$typeof){case D:return F=Qa(_.type,_.key,_.props,null,z.mode,F),F.ref=Ss(z,null,_),F.return=z,F;case K:return _=al(_,z.mode,F),_.return=z,_;case pe:var le=_._init;return ne(z,le(_._payload),F)}if(Ke(_)||M(_))return _=pr(_,z.mode,F,null),_.return=z,_;Ea(z,_)}return null}function q(z,_,F,le){var Ne=_!==null?_.key:null;if(typeof F=="string"&&F!==""||typeof F=="number")return Ne!==null?null:b(z,_,""+F,le);if(typeof F=="object"&&F!==null){switch(F.$$typeof){case D:return F.key===Ne?R(z,_,F,le):null;case K:return F.key===Ne?U(z,_,F,le):null;case pe:return Ne=F._init,q(z,_,Ne(F._payload),le)}if(Ke(F)||M(F))return Ne!==null?null:Q(z,_,F,le,null);Ea(z,F)}return null}function ye(z,_,F,le,Ne){if(typeof le=="string"&&le!==""||typeof le=="number")return z=z.get(F)||null,b(_,z,""+le,Ne);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case D:return z=z.get(le.key===null?F:le.key)||null,R(_,z,le,Ne);case K:return z=z.get(le.key===null?F:le.key)||null,U(_,z,le,Ne);case pe:var Ie=le._init;return ye(z,_,F,Ie(le._payload),Ne)}if(Ke(le)||M(le))return z=z.get(F)||null,Q(_,z,le,Ne,null);Ea(_,le)}return null}function Se(z,_,F,le){for(var Ne=null,Ie=null,Ae=_,Pe=_=0,kt=null;Ae!==null&&Pe<F.length;Pe++){Ae.index>Pe?(kt=Ae,Ae=null):kt=Ae.sibling;var We=q(z,Ae,F[Pe],le);if(We===null){Ae===null&&(Ae=kt);break}e&&Ae&&We.alternate===null&&t(z,Ae),_=m(We,_,Pe),Ie===null?Ne=We:Ie.sibling=We,Ie=We,Ae=kt}if(Pe===F.length)return a(z,Ae),nt&&or(z,Pe),Ne;if(Ae===null){for(;Pe<F.length;Pe++)Ae=ne(z,F[Pe],le),Ae!==null&&(_=m(Ae,_,Pe),Ie===null?Ne=Ae:Ie.sibling=Ae,Ie=Ae);return nt&&or(z,Pe),Ne}for(Ae=l(z,Ae);Pe<F.length;Pe++)kt=ye(Ae,z,Pe,F[Pe],le),kt!==null&&(e&&kt.alternate!==null&&Ae.delete(kt.key===null?Pe:kt.key),_=m(kt,_,Pe),Ie===null?Ne=kt:Ie.sibling=kt,Ie=kt);return e&&Ae.forEach(function(Qn){return t(z,Qn)}),nt&&or(z,Pe),Ne}function be(z,_,F,le){var Ne=M(F);if(typeof Ne!="function")throw Error(i(150));if(F=Ne.call(F),F==null)throw Error(i(151));for(var Ie=Ne=null,Ae=_,Pe=_=0,kt=null,We=F.next();Ae!==null&&!We.done;Pe++,We=F.next()){Ae.index>Pe?(kt=Ae,Ae=null):kt=Ae.sibling;var Qn=q(z,Ae,We.value,le);if(Qn===null){Ae===null&&(Ae=kt);break}e&&Ae&&Qn.alternate===null&&t(z,Ae),_=m(Qn,_,Pe),Ie===null?Ne=Qn:Ie.sibling=Qn,Ie=Qn,Ae=kt}if(We.done)return a(z,Ae),nt&&or(z,Pe),Ne;if(Ae===null){for(;!We.done;Pe++,We=F.next())We=ne(z,We.value,le),We!==null&&(_=m(We,_,Pe),Ie===null?Ne=We:Ie.sibling=We,Ie=We);return nt&&or(z,Pe),Ne}for(Ae=l(z,Ae);!We.done;Pe++,We=F.next())We=ye(Ae,z,Pe,We.value,le),We!==null&&(e&&We.alternate!==null&&Ae.delete(We.key===null?Pe:We.key),_=m(We,_,Pe),Ie===null?Ne=We:Ie.sibling=We,Ie=We);return e&&Ae.forEach(function(sg){return t(z,sg)}),nt&&or(z,Pe),Ne}function ut(z,_,F,le){if(typeof F=="object"&&F!==null&&F.type===V&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case D:e:{for(var Ne=F.key,Ie=_;Ie!==null;){if(Ie.key===Ne){if(Ne=F.type,Ne===V){if(Ie.tag===7){a(z,Ie.sibling),_=u(Ie,F.props.children),_.return=z,z=_;break e}}else if(Ie.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===pe&&Su(Ne)===Ie.type){a(z,Ie.sibling),_=u(Ie,F.props),_.ref=Ss(z,Ie,F),_.return=z,z=_;break e}a(z,Ie);break}else t(z,Ie);Ie=Ie.sibling}F.type===V?(_=pr(F.props.children,z.mode,le,F.key),_.return=z,z=_):(le=Qa(F.type,F.key,F.props,null,z.mode,le),le.ref=Ss(z,_,F),le.return=z,z=le)}return x(z);case K:e:{for(Ie=F.key;_!==null;){if(_.key===Ie)if(_.tag===4&&_.stateNode.containerInfo===F.containerInfo&&_.stateNode.implementation===F.implementation){a(z,_.sibling),_=u(_,F.children||[]),_.return=z,z=_;break e}else{a(z,_);break}else t(z,_);_=_.sibling}_=al(F,z.mode,le),_.return=z,z=_}return x(z);case pe:return Ie=F._init,ut(z,_,Ie(F._payload),le)}if(Ke(F))return Se(z,_,F,le);if(M(F))return be(z,_,F,le);Ea(z,F)}return typeof F=="string"&&F!==""||typeof F=="number"?(F=""+F,_!==null&&_.tag===6?(a(z,_.sibling),_=u(_,F),_.return=z,z=_):(a(z,_),_=sl(F,z.mode,le),_.return=z,z=_),x(z)):a(z,_)}return ut}var Fr=ku(!0),bu=ku(!1),Ta=Bn(null),Ra=null,Or=null,ho=null;function po(){ho=Or=Ra=null}function go(e){var t=Ta.current;Ze(Ta),e._currentValue=t}function yo(e,t,a){for(;e!==null;){var l=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,l!==null&&(l.childLanes|=t)):l!==null&&(l.childLanes&t)!==t&&(l.childLanes|=t),e===a)break;e=e.return}}function Mr(e,t){Ra=e,ho=Or=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(zt=!0),e.firstContext=null)}function Jt(e){var t=e._currentValue;if(ho!==e)if(e={context:e,memoizedValue:t,next:null},Or===null){if(Ra===null)throw Error(i(308));Or=e,Ra.dependencies={lanes:0,firstContext:e}}else Or=Or.next=e;return t}var lr=null;function vo(e){lr===null?lr=[e]:lr.push(e)}function Nu(e,t,a,l){var u=t.interleaved;return u===null?(a.next=a,vo(t)):(a.next=u.next,u.next=a),t.interleaved=a,Nn(e,l)}function Nn(e,t){e.lanes|=t;var a=e.alternate;for(a!==null&&(a.lanes|=t),a=e,e=e.return;e!==null;)e.childLanes|=t,a=e.alternate,a!==null&&(a.childLanes|=t),a=e,e=e.return;return a.tag===3?a.stateNode:null}var Wn=!1;function xo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Cu(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 Cn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Hn(e,t,a){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(Ue&2)!==0){var u=l.pending;return u===null?t.next=t:(t.next=u.next,u.next=t),l.pending=t,Nn(e,a)}return u=l.interleaved,u===null?(t.next=t,vo(l)):(t.next=u.next,u.next=t),l.interleaved=t,Nn(e,a)}function Ia(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194240)!==0)){var l=t.lanes;l&=e.pendingLanes,a|=l,t.lanes=a,Pi(e,a)}}function Eu(e,t){var a=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var u=null,m=null;if(a=a.firstBaseUpdate,a!==null){do{var x={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};m===null?u=m=x:m=m.next=x,a=a.next}while(a!==null);m===null?u=m=t:m=m.next=t}else u=m=t;a={baseState:l.baseState,firstBaseUpdate:u,lastBaseUpdate:m,shared:l.shared,effects:l.effects},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}function Aa(e,t,a,l){var u=e.updateQueue;Wn=!1;var m=u.firstBaseUpdate,x=u.lastBaseUpdate,b=u.shared.pending;if(b!==null){u.shared.pending=null;var R=b,U=R.next;R.next=null,x===null?m=U:x.next=U,x=R;var Q=e.alternate;Q!==null&&(Q=Q.updateQueue,b=Q.lastBaseUpdate,b!==x&&(b===null?Q.firstBaseUpdate=U:b.next=U,Q.lastBaseUpdate=R))}if(m!==null){var ne=u.baseState;x=0,Q=U=R=null,b=m;do{var q=b.lane,ye=b.eventTime;if((l&q)===q){Q!==null&&(Q=Q.next={eventTime:ye,lane:0,tag:b.tag,payload:b.payload,callback:b.callback,next:null});e:{var Se=e,be=b;switch(q=t,ye=a,be.tag){case 1:if(Se=be.payload,typeof Se=="function"){ne=Se.call(ye,ne,q);break e}ne=Se;break e;case 3:Se.flags=Se.flags&-65537|128;case 0:if(Se=be.payload,q=typeof Se=="function"?Se.call(ye,ne,q):Se,q==null)break e;ne=H({},ne,q);break e;case 2:Wn=!0}}b.callback!==null&&b.lane!==0&&(e.flags|=64,q=u.effects,q===null?u.effects=[b]:q.push(b))}else ye={eventTime:ye,lane:q,tag:b.tag,payload:b.payload,callback:b.callback,next:null},Q===null?(U=Q=ye,R=ne):Q=Q.next=ye,x|=q;if(b=b.next,b===null){if(b=u.shared.pending,b===null)break;q=b,b=q.next,q.next=null,u.lastBaseUpdate=q,u.shared.pending=null}}while(!0);if(Q===null&&(R=ne),u.baseState=R,u.firstBaseUpdate=U,u.lastBaseUpdate=Q,t=u.shared.interleaved,t!==null){u=t;do x|=u.lane,u=u.next;while(u!==t)}else m===null&&(u.shared.lanes=0);dr|=x,e.lanes=x,e.memoizedState=ne}}function Tu(e,t,a){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var l=e[t],u=l.callback;if(u!==null){if(l.callback=null,l=a,typeof u!="function")throw Error(i(191,u));u.call(l)}}}var ks={},pn=Bn(ks),bs=Bn(ks),Ns=Bn(ks);function cr(e){if(e===ks)throw Error(i(174));return e}function wo(e,t){switch(qe(Ns,t),qe(bs,e),qe(pn,ks),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:he(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=he(t,e)}Ze(pn),qe(pn,t)}function Br(){Ze(pn),Ze(bs),Ze(Ns)}function Ru(e){cr(Ns.current);var t=cr(pn.current),a=he(t,e.type);t!==a&&(qe(bs,e),qe(pn,a))}function jo(e){bs.current===e&&(Ze(pn),Ze(bs))}var at=Bn(0);function Pa(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||a.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var So=[];function ko(){for(var e=0;e<So.length;e++)So[e]._workInProgressVersionPrimary=null;So.length=0}var _a=P.ReactCurrentDispatcher,bo=P.ReactCurrentBatchConfig,ur=0,it=null,pt=null,jt=null,La=!1,Cs=!1,Es=0,Cp=0;function Rt(){throw Error(i(321))}function No(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!nn(e[a],t[a]))return!1;return!0}function Co(e,t,a,l,u,m){if(ur=m,it=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,_a.current=e===null||e.memoizedState===null?Ip:Ap,e=a(l,u),Cs){m=0;do{if(Cs=!1,Es=0,25<=m)throw Error(i(301));m+=1,jt=pt=null,t.updateQueue=null,_a.current=Pp,e=a(l,u)}while(Cs)}if(_a.current=Fa,t=pt!==null&&pt.next!==null,ur=0,jt=pt=it=null,La=!1,t)throw Error(i(300));return e}function Eo(){var e=Es!==0;return Es=0,e}function gn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jt===null?it.memoizedState=jt=e:jt=jt.next=e,jt}function qt(){if(pt===null){var e=it.alternate;e=e!==null?e.memoizedState:null}else e=pt.next;var t=jt===null?it.memoizedState:jt.next;if(t!==null)jt=t,pt=e;else{if(e===null)throw Error(i(310));pt=e,e={memoizedState:pt.memoizedState,baseState:pt.baseState,baseQueue:pt.baseQueue,queue:pt.queue,next:null},jt===null?it.memoizedState=jt=e:jt=jt.next=e}return jt}function Ts(e,t){return typeof t=="function"?t(e):t}function To(e){var t=qt(),a=t.queue;if(a===null)throw Error(i(311));a.lastRenderedReducer=e;var l=pt,u=l.baseQueue,m=a.pending;if(m!==null){if(u!==null){var x=u.next;u.next=m.next,m.next=x}l.baseQueue=u=m,a.pending=null}if(u!==null){m=u.next,l=l.baseState;var b=x=null,R=null,U=m;do{var Q=U.lane;if((ur&Q)===Q)R!==null&&(R=R.next={lane:0,action:U.action,hasEagerState:U.hasEagerState,eagerState:U.eagerState,next:null}),l=U.hasEagerState?U.eagerState:e(l,U.action);else{var ne={lane:Q,action:U.action,hasEagerState:U.hasEagerState,eagerState:U.eagerState,next:null};R===null?(b=R=ne,x=l):R=R.next=ne,it.lanes|=Q,dr|=Q}U=U.next}while(U!==null&&U!==m);R===null?x=l:R.next=b,nn(l,t.memoizedState)||(zt=!0),t.memoizedState=l,t.baseState=x,t.baseQueue=R,a.lastRenderedState=l}if(e=a.interleaved,e!==null){u=e;do m=u.lane,it.lanes|=m,dr|=m,u=u.next;while(u!==e)}else u===null&&(a.lanes=0);return[t.memoizedState,a.dispatch]}function Ro(e){var t=qt(),a=t.queue;if(a===null)throw Error(i(311));a.lastRenderedReducer=e;var l=a.dispatch,u=a.pending,m=t.memoizedState;if(u!==null){a.pending=null;var x=u=u.next;do m=e(m,x.action),x=x.next;while(x!==u);nn(m,t.memoizedState)||(zt=!0),t.memoizedState=m,t.baseQueue===null&&(t.baseState=m),a.lastRenderedState=m}return[m,l]}function Iu(){}function Au(e,t){var a=it,l=qt(),u=t(),m=!nn(l.memoizedState,u);if(m&&(l.memoizedState=u,zt=!0),l=l.queue,Io(Lu.bind(null,a,l,e),[e]),l.getSnapshot!==t||m||jt!==null&&jt.memoizedState.tag&1){if(a.flags|=2048,Rs(9,_u.bind(null,a,l,u,t),void 0,null),St===null)throw Error(i(349));(ur&30)!==0||Pu(a,t,u)}return u}function Pu(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=it.updateQueue,t===null?(t={lastEffect:null,stores:null},it.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function _u(e,t,a,l){t.value=a,t.getSnapshot=l,$u(t)&&zu(e)}function Lu(e,t,a){return a(function(){$u(t)&&zu(e)})}function $u(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!nn(e,a)}catch{return!0}}function zu(e){var t=Nn(e,1);t!==null&&ln(t,e,1,-1)}function Fu(e){var t=gn();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ts,lastRenderedState:e},t.queue=e,e=e.dispatch=Rp.bind(null,it,e),[t.memoizedState,e]}function Rs(e,t,a,l){return e={tag:e,create:t,destroy:a,deps:l,next:null},t=it.updateQueue,t===null?(t={lastEffect:null,stores:null},it.updateQueue=t,t.lastEffect=e.next=e):(a=t.lastEffect,a===null?t.lastEffect=e.next=e:(l=a.next,a.next=e,e.next=l,t.lastEffect=e)),e}function Ou(){return qt().memoizedState}function $a(e,t,a,l){var u=gn();it.flags|=e,u.memoizedState=Rs(1|t,a,void 0,l===void 0?null:l)}function za(e,t,a,l){var u=qt();l=l===void 0?null:l;var m=void 0;if(pt!==null){var x=pt.memoizedState;if(m=x.destroy,l!==null&&No(l,x.deps)){u.memoizedState=Rs(t,a,m,l);return}}it.flags|=e,u.memoizedState=Rs(1|t,a,m,l)}function Mu(e,t){return $a(8390656,8,e,t)}function Io(e,t){return za(2048,8,e,t)}function Bu(e,t){return za(4,2,e,t)}function Du(e,t){return za(4,4,e,t)}function Uu(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Wu(e,t,a){return a=a!=null?a.concat([e]):null,za(4,4,Uu.bind(null,t,e),a)}function Ao(){}function Hu(e,t){var a=qt();t=t===void 0?null:t;var l=a.memoizedState;return l!==null&&t!==null&&No(t,l[1])?l[0]:(a.memoizedState=[e,t],e)}function Vu(e,t){var a=qt();t=t===void 0?null:t;var l=a.memoizedState;return l!==null&&t!==null&&No(t,l[1])?l[0]:(e=e(),a.memoizedState=[e,t],e)}function Gu(e,t,a){return(ur&21)===0?(e.baseState&&(e.baseState=!1,zt=!0),e.memoizedState=a):(nn(a,t)||(a=Sc(),it.lanes|=a,dr|=a,e.baseState=!0),t)}function Ep(e,t){var a=Ve;Ve=a!==0&&4>a?a:4,e(!0);var l=bo.transition;bo.transition={};try{e(!1),t()}finally{Ve=a,bo.transition=l}}function Ku(){return qt().memoizedState}function Tp(e,t,a){var l=Yn(e);if(a={lane:l,action:a,hasEagerState:!1,eagerState:null,next:null},Yu(e))Ju(t,a);else if(a=Nu(e,t,a,l),a!==null){var u=_t();ln(a,e,l,u),qu(a,t,l)}}function Rp(e,t,a){var l=Yn(e),u={lane:l,action:a,hasEagerState:!1,eagerState:null,next:null};if(Yu(e))Ju(t,u);else{var m=e.alternate;if(e.lanes===0&&(m===null||m.lanes===0)&&(m=t.lastRenderedReducer,m!==null))try{var x=t.lastRenderedState,b=m(x,a);if(u.hasEagerState=!0,u.eagerState=b,nn(b,x)){var R=t.interleaved;R===null?(u.next=u,vo(t)):(u.next=R.next,R.next=u),t.interleaved=u;return}}catch{}finally{}a=Nu(e,t,u,l),a!==null&&(u=_t(),ln(a,e,l,u),qu(a,t,l))}}function Yu(e){var t=e.alternate;return e===it||t!==null&&t===it}function Ju(e,t){Cs=La=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function qu(e,t,a){if((a&4194240)!==0){var l=t.lanes;l&=e.pendingLanes,a|=l,t.lanes=a,Pi(e,a)}}var Fa={readContext:Jt,useCallback:Rt,useContext:Rt,useEffect:Rt,useImperativeHandle:Rt,useInsertionEffect:Rt,useLayoutEffect:Rt,useMemo:Rt,useReducer:Rt,useRef:Rt,useState:Rt,useDebugValue:Rt,useDeferredValue:Rt,useTransition:Rt,useMutableSource:Rt,useSyncExternalStore:Rt,useId:Rt,unstable_isNewReconciler:!1},Ip={readContext:Jt,useCallback:function(e,t){return gn().memoizedState=[e,t===void 0?null:t],e},useContext:Jt,useEffect:Mu,useImperativeHandle:function(e,t,a){return a=a!=null?a.concat([e]):null,$a(4194308,4,Uu.bind(null,t,e),a)},useLayoutEffect:function(e,t){return $a(4194308,4,e,t)},useInsertionEffect:function(e,t){return $a(4,2,e,t)},useMemo:function(e,t){var a=gn();return t=t===void 0?null:t,e=e(),a.memoizedState=[e,t],e},useReducer:function(e,t,a){var l=gn();return t=a!==void 0?a(t):t,l.memoizedState=l.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},l.queue=e,e=e.dispatch=Tp.bind(null,it,e),[l.memoizedState,e]},useRef:function(e){var t=gn();return e={current:e},t.memoizedState=e},useState:Fu,useDebugValue:Ao,useDeferredValue:function(e){return gn().memoizedState=e},useTransition:function(){var e=Fu(!1),t=e[0];return e=Ep.bind(null,e[1]),gn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,a){var l=it,u=gn();if(nt){if(a===void 0)throw Error(i(407));a=a()}else{if(a=t(),St===null)throw Error(i(349));(ur&30)!==0||Pu(l,t,a)}u.memoizedState=a;var m={value:a,getSnapshot:t};return u.queue=m,Mu(Lu.bind(null,l,m,e),[e]),l.flags|=2048,Rs(9,_u.bind(null,l,m,a,t),void 0,null),a},useId:function(){var e=gn(),t=St.identifierPrefix;if(nt){var a=bn,l=kn;a=(l&~(1<<32-tn(l)-1)).toString(32)+a,t=":"+t+"R"+a,a=Es++,0<a&&(t+="H"+a.toString(32)),t+=":"}else a=Cp++,t=":"+t+"r"+a.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Ap={readContext:Jt,useCallback:Hu,useContext:Jt,useEffect:Io,useImperativeHandle:Wu,useInsertionEffect:Bu,useLayoutEffect:Du,useMemo:Vu,useReducer:To,useRef:Ou,useState:function(){return To(Ts)},useDebugValue:Ao,useDeferredValue:function(e){var t=qt();return Gu(t,pt.memoizedState,e)},useTransition:function(){var e=To(Ts)[0],t=qt().memoizedState;return[e,t]},useMutableSource:Iu,useSyncExternalStore:Au,useId:Ku,unstable_isNewReconciler:!1},Pp={readContext:Jt,useCallback:Hu,useContext:Jt,useEffect:Io,useImperativeHandle:Wu,useInsertionEffect:Bu,useLayoutEffect:Du,useMemo:Vu,useReducer:Ro,useRef:Ou,useState:function(){return Ro(Ts)},useDebugValue:Ao,useDeferredValue:function(e){var t=qt();return pt===null?t.memoizedState=e:Gu(t,pt.memoizedState,e)},useTransition:function(){var e=Ro(Ts)[0],t=qt().memoizedState;return[e,t]},useMutableSource:Iu,useSyncExternalStore:Au,useId:Ku,unstable_isNewReconciler:!1};function sn(e,t){if(e&&e.defaultProps){t=H({},t),e=e.defaultProps;for(var a in e)t[a]===void 0&&(t[a]=e[a]);return t}return t}function Po(e,t,a,l){t=e.memoizedState,a=a(l,t),a=a==null?t:H({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Oa={isMounted:function(e){return(e=e._reactInternals)?rr(e)===e:!1},enqueueSetState:function(e,t,a){e=e._reactInternals;var l=_t(),u=Yn(e),m=Cn(l,u);m.payload=t,a!=null&&(m.callback=a),t=Hn(e,m,u),t!==null&&(ln(t,e,u,l),Ia(t,e,u))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var l=_t(),u=Yn(e),m=Cn(l,u);m.tag=1,m.payload=t,a!=null&&(m.callback=a),t=Hn(e,m,u),t!==null&&(ln(t,e,u,l),Ia(t,e,u))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=_t(),l=Yn(e),u=Cn(a,l);u.tag=2,t!=null&&(u.callback=t),t=Hn(e,u,l),t!==null&&(ln(t,e,l,a),Ia(t,e,l))}};function Qu(e,t,a,l,u,m,x){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,m,x):t.prototype&&t.prototype.isPureReactComponent?!ps(a,l)||!ps(u,m):!0}function Xu(e,t,a){var l=!1,u=Dn,m=t.contextType;return typeof m=="object"&&m!==null?m=Jt(m):(u=$t(t)?ar:Tt.current,l=t.contextTypes,m=(l=l!=null)?_r(e,u):Dn),t=new t(a,m),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Oa,e.stateNode=t,t._reactInternals=e,l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=u,e.__reactInternalMemoizedMaskedChildContext=m),t}function Zu(e,t,a,l){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,l),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,l),t.state!==e&&Oa.enqueueReplaceState(t,t.state,null)}function _o(e,t,a,l){var u=e.stateNode;u.props=a,u.state=e.memoizedState,u.refs={},xo(e);var m=t.contextType;typeof m=="object"&&m!==null?u.context=Jt(m):(m=$t(t)?ar:Tt.current,u.context=_r(e,m)),u.state=e.memoizedState,m=t.getDerivedStateFromProps,typeof m=="function"&&(Po(e,t,m,a),u.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof u.getSnapshotBeforeUpdate=="function"||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(t=u.state,typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount(),t!==u.state&&Oa.enqueueReplaceState(u,u.state,null),Aa(e,a,u,l),u.state=e.memoizedState),typeof u.componentDidMount=="function"&&(e.flags|=4194308)}function Dr(e,t){try{var a="",l=t;do a+=ue(l),l=l.return;while(l);var u=a}catch(m){u=`
39
- Error generating stack: `+m.message+`
40
- `+m.stack}return{value:e,source:t,stack:u,digest:null}}function Lo(e,t,a){return{value:e,source:null,stack:a??null,digest:t??null}}function $o(e,t){try{console.error(t.value)}catch(a){setTimeout(function(){throw a})}}var _p=typeof WeakMap=="function"?WeakMap:Map;function ed(e,t,a){a=Cn(-1,a),a.tag=3,a.payload={element:null};var l=t.value;return a.callback=function(){Va||(Va=!0,qo=l),$o(e,t)},a}function td(e,t,a){a=Cn(-1,a),a.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var u=t.value;a.payload=function(){return l(u)},a.callback=function(){$o(e,t)}}var m=e.stateNode;return m!==null&&typeof m.componentDidCatch=="function"&&(a.callback=function(){$o(e,t),typeof l!="function"&&(Gn===null?Gn=new Set([this]):Gn.add(this));var x=t.stack;this.componentDidCatch(t.value,{componentStack:x!==null?x:""})}),a}function nd(e,t,a){var l=e.pingCache;if(l===null){l=e.pingCache=new _p;var u=new Set;l.set(t,u)}else u=l.get(t),u===void 0&&(u=new Set,l.set(t,u));u.has(a)||(u.add(a),e=Kp.bind(null,e,t,a),t.then(e,e))}function rd(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function sd(e,t,a,l,u){return(e.mode&1)===0?(e===t?e.flags|=65536:(e.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(t=Cn(-1,1),t.tag=2,Hn(a,t,1))),a.lanes|=1),e):(e.flags|=65536,e.lanes=u,e)}var Lp=P.ReactCurrentOwner,zt=!1;function Pt(e,t,a,l){t.child=e===null?bu(t,null,a,l):Fr(t,e.child,a,l)}function ad(e,t,a,l,u){a=a.render;var m=t.ref;return Mr(t,u),l=Co(e,t,a,l,m,u),a=Eo(),e!==null&&!zt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~u,En(e,t,u)):(nt&&a&&lo(t),t.flags|=1,Pt(e,t,l,u),t.child)}function id(e,t,a,l,u){if(e===null){var m=a.type;return typeof m=="function"&&!rl(m)&&m.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(t.tag=15,t.type=m,od(e,t,m,l,u)):(e=Qa(a.type,null,l,t,t.mode,u),e.ref=t.ref,e.return=t,t.child=e)}if(m=e.child,(e.lanes&u)===0){var x=m.memoizedProps;if(a=a.compare,a=a!==null?a:ps,a(x,l)&&e.ref===t.ref)return En(e,t,u)}return t.flags|=1,e=qn(m,l),e.ref=t.ref,e.return=t,t.child=e}function od(e,t,a,l,u){if(e!==null){var m=e.memoizedProps;if(ps(m,l)&&e.ref===t.ref)if(zt=!1,t.pendingProps=l=m,(e.lanes&u)!==0)(e.flags&131072)!==0&&(zt=!0);else return t.lanes=e.lanes,En(e,t,u)}return zo(e,t,a,l,u)}function ld(e,t,a){var l=t.pendingProps,u=l.children,m=e!==null?e.memoizedState:null;if(l.mode==="hidden")if((t.mode&1)===0)t.memoizedState={baseLanes:0,cachePool:null,transitions:null},qe(Wr,Vt),Vt|=a;else{if((a&1073741824)===0)return e=m!==null?m.baseLanes|a:a,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,qe(Wr,Vt),Vt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=m!==null?m.baseLanes:a,qe(Wr,Vt),Vt|=l}else m!==null?(l=m.baseLanes|a,t.memoizedState=null):l=a,qe(Wr,Vt),Vt|=l;return Pt(e,t,u,a),t.child}function cd(e,t){var a=t.ref;(e===null&&a!==null||e!==null&&e.ref!==a)&&(t.flags|=512,t.flags|=2097152)}function zo(e,t,a,l,u){var m=$t(a)?ar:Tt.current;return m=_r(t,m),Mr(t,u),a=Co(e,t,a,l,m,u),l=Eo(),e!==null&&!zt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~u,En(e,t,u)):(nt&&l&&lo(t),t.flags|=1,Pt(e,t,a,u),t.child)}function ud(e,t,a,l,u){if($t(a)){var m=!0;Sa(t)}else m=!1;if(Mr(t,u),t.stateNode===null)Ba(e,t),Xu(t,a,l),_o(t,a,l,u),l=!0;else if(e===null){var x=t.stateNode,b=t.memoizedProps;x.props=b;var R=x.context,U=a.contextType;typeof U=="object"&&U!==null?U=Jt(U):(U=$t(a)?ar:Tt.current,U=_r(t,U));var Q=a.getDerivedStateFromProps,ne=typeof Q=="function"||typeof x.getSnapshotBeforeUpdate=="function";ne||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(b!==l||R!==U)&&Zu(t,x,l,U),Wn=!1;var q=t.memoizedState;x.state=q,Aa(t,l,x,u),R=t.memoizedState,b!==l||q!==R||Lt.current||Wn?(typeof Q=="function"&&(Po(t,a,Q,l),R=t.memoizedState),(b=Wn||Qu(t,a,b,l,q,R,U))?(ne||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(t.flags|=4194308)):(typeof x.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=l,t.memoizedState=R),x.props=l,x.state=R,x.context=U,l=b):(typeof x.componentDidMount=="function"&&(t.flags|=4194308),l=!1)}else{x=t.stateNode,Cu(e,t),b=t.memoizedProps,U=t.type===t.elementType?b:sn(t.type,b),x.props=U,ne=t.pendingProps,q=x.context,R=a.contextType,typeof R=="object"&&R!==null?R=Jt(R):(R=$t(a)?ar:Tt.current,R=_r(t,R));var ye=a.getDerivedStateFromProps;(Q=typeof ye=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(b!==ne||q!==R)&&Zu(t,x,l,R),Wn=!1,q=t.memoizedState,x.state=q,Aa(t,l,x,u);var Se=t.memoizedState;b!==ne||q!==Se||Lt.current||Wn?(typeof ye=="function"&&(Po(t,a,ye,l),Se=t.memoizedState),(U=Wn||Qu(t,a,U,l,q,Se,R)||!1)?(Q||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(l,Se,R),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(l,Se,R)),typeof x.componentDidUpdate=="function"&&(t.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof x.componentDidUpdate!="function"||b===e.memoizedProps&&q===e.memoizedState||(t.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&q===e.memoizedState||(t.flags|=1024),t.memoizedProps=l,t.memoizedState=Se),x.props=l,x.state=Se,x.context=R,l=U):(typeof x.componentDidUpdate!="function"||b===e.memoizedProps&&q===e.memoizedState||(t.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&q===e.memoizedState||(t.flags|=1024),l=!1)}return Fo(e,t,a,l,m,u)}function Fo(e,t,a,l,u,m){cd(e,t);var x=(t.flags&128)!==0;if(!l&&!x)return u&&pu(t,a,!1),En(e,t,m);l=t.stateNode,Lp.current=t;var b=x&&typeof a.getDerivedStateFromError!="function"?null:l.render();return t.flags|=1,e!==null&&x?(t.child=Fr(t,e.child,null,m),t.child=Fr(t,null,b,m)):Pt(e,t,b,m),t.memoizedState=l.state,u&&pu(t,a,!0),t.child}function dd(e){var t=e.stateNode;t.pendingContext?mu(e,t.pendingContext,t.pendingContext!==t.context):t.context&&mu(e,t.context,!1),wo(e,t.containerInfo)}function fd(e,t,a,l,u){return zr(),mo(u),t.flags|=256,Pt(e,t,a,l),t.child}var Oo={dehydrated:null,treeContext:null,retryLane:0};function Mo(e){return{baseLanes:e,cachePool:null,transitions:null}}function md(e,t,a){var l=t.pendingProps,u=at.current,m=!1,x=(t.flags&128)!==0,b;if((b=x)||(b=e!==null&&e.memoizedState===null?!1:(u&2)!==0),b?(m=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(u|=1),qe(at,u&1),e===null)return fo(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((t.mode&1)===0?t.lanes=1:e.data==="$!"?t.lanes=8:t.lanes=1073741824,null):(x=l.children,e=l.fallback,m?(l=t.mode,m=t.child,x={mode:"hidden",children:x},(l&1)===0&&m!==null?(m.childLanes=0,m.pendingProps=x):m=Xa(x,l,0,null),e=pr(e,l,a,null),m.return=t,e.return=t,m.sibling=e,t.child=m,t.child.memoizedState=Mo(a),t.memoizedState=Oo,e):Bo(t,x));if(u=e.memoizedState,u!==null&&(b=u.dehydrated,b!==null))return $p(e,t,x,l,b,u,a);if(m){m=l.fallback,x=t.mode,u=e.child,b=u.sibling;var R={mode:"hidden",children:l.children};return(x&1)===0&&t.child!==u?(l=t.child,l.childLanes=0,l.pendingProps=R,t.deletions=null):(l=qn(u,R),l.subtreeFlags=u.subtreeFlags&14680064),b!==null?m=qn(b,m):(m=pr(m,x,a,null),m.flags|=2),m.return=t,l.return=t,l.sibling=m,t.child=l,l=m,m=t.child,x=e.child.memoizedState,x=x===null?Mo(a):{baseLanes:x.baseLanes|a,cachePool:null,transitions:x.transitions},m.memoizedState=x,m.childLanes=e.childLanes&~a,t.memoizedState=Oo,l}return m=e.child,e=m.sibling,l=qn(m,{mode:"visible",children:l.children}),(t.mode&1)===0&&(l.lanes=a),l.return=t,l.sibling=null,e!==null&&(a=t.deletions,a===null?(t.deletions=[e],t.flags|=16):a.push(e)),t.child=l,t.memoizedState=null,l}function Bo(e,t){return t=Xa({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ma(e,t,a,l){return l!==null&&mo(l),Fr(t,e.child,null,a),e=Bo(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function $p(e,t,a,l,u,m,x){if(a)return t.flags&256?(t.flags&=-257,l=Lo(Error(i(422))),Ma(e,t,x,l)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(m=l.fallback,u=t.mode,l=Xa({mode:"visible",children:l.children},u,0,null),m=pr(m,u,x,null),m.flags|=2,l.return=t,m.return=t,l.sibling=m,t.child=l,(t.mode&1)!==0&&Fr(t,e.child,null,x),t.child.memoizedState=Mo(x),t.memoizedState=Oo,m);if((t.mode&1)===0)return Ma(e,t,x,null);if(u.data==="$!"){if(l=u.nextSibling&&u.nextSibling.dataset,l)var b=l.dgst;return l=b,m=Error(i(419)),l=Lo(m,l,void 0),Ma(e,t,x,l)}if(b=(x&e.childLanes)!==0,zt||b){if(l=St,l!==null){switch(x&-x){case 4:u=2;break;case 16:u=8;break;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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:u=32;break;case 536870912:u=268435456;break;default:u=0}u=(u&(l.suspendedLanes|x))!==0?0:u,u!==0&&u!==m.retryLane&&(m.retryLane=u,Nn(e,u),ln(l,e,u,-1))}return nl(),l=Lo(Error(i(421))),Ma(e,t,x,l)}return u.data==="$?"?(t.flags|=128,t.child=e.child,t=Yp.bind(null,e),u._reactRetry=t,null):(e=m.treeContext,Ht=Mn(u.nextSibling),Wt=t,nt=!0,rn=null,e!==null&&(Kt[Yt++]=kn,Kt[Yt++]=bn,Kt[Yt++]=ir,kn=e.id,bn=e.overflow,ir=t),t=Bo(t,l.children),t.flags|=4096,t)}function hd(e,t,a){e.lanes|=t;var l=e.alternate;l!==null&&(l.lanes|=t),yo(e.return,t,a)}function Do(e,t,a,l,u){var m=e.memoizedState;m===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:u}:(m.isBackwards=t,m.rendering=null,m.renderingStartTime=0,m.last=l,m.tail=a,m.tailMode=u)}function pd(e,t,a){var l=t.pendingProps,u=l.revealOrder,m=l.tail;if(Pt(e,t,l.children,a),l=at.current,(l&2)!==0)l=l&1|2,t.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&hd(e,a,t);else if(e.tag===19)hd(e,a,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}l&=1}if(qe(at,l),(t.mode&1)===0)t.memoizedState=null;else switch(u){case"forwards":for(a=t.child,u=null;a!==null;)e=a.alternate,e!==null&&Pa(e)===null&&(u=a),a=a.sibling;a=u,a===null?(u=t.child,t.child=null):(u=a.sibling,a.sibling=null),Do(t,!1,u,a,m);break;case"backwards":for(a=null,u=t.child,t.child=null;u!==null;){if(e=u.alternate,e!==null&&Pa(e)===null){t.child=u;break}e=u.sibling,u.sibling=a,a=u,u=e}Do(t,!0,a,null,m);break;case"together":Do(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Ba(e,t){(t.mode&1)===0&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function En(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),dr|=t.lanes,(a&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,a=qn(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=qn(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function zp(e,t,a){switch(t.tag){case 3:dd(t),zr();break;case 5:Ru(t);break;case 1:$t(t.type)&&Sa(t);break;case 4:wo(t,t.stateNode.containerInfo);break;case 10:var l=t.type._context,u=t.memoizedProps.value;qe(Ta,l._currentValue),l._currentValue=u;break;case 13:if(l=t.memoizedState,l!==null)return l.dehydrated!==null?(qe(at,at.current&1),t.flags|=128,null):(a&t.child.childLanes)!==0?md(e,t,a):(qe(at,at.current&1),e=En(e,t,a),e!==null?e.sibling:null);qe(at,at.current&1);break;case 19:if(l=(a&t.childLanes)!==0,(e.flags&128)!==0){if(l)return pd(e,t,a);t.flags|=128}if(u=t.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),qe(at,at.current),l)break;return null;case 22:case 23:return t.lanes=0,ld(e,t,a)}return En(e,t,a)}var gd,Uo,yd,vd;gd=function(e,t){for(var a=t.child;a!==null;){if(a.tag===5||a.tag===6)e.appendChild(a.stateNode);else if(a.tag!==4&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return;a=a.return}a.sibling.return=a.return,a=a.sibling}},Uo=function(){},yd=function(e,t,a,l){var u=e.memoizedProps;if(u!==l){e=t.stateNode,cr(pn.current);var m=null;switch(a){case"input":u=X(e,u),l=X(e,l),m=[];break;case"select":u=H({},u,{value:void 0}),l=H({},l,{value:void 0}),m=[];break;case"textarea":u=st(e,u),l=st(e,l),m=[];break;default:typeof u.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=xa)}tt(a,l);var x;a=null;for(U in u)if(!l.hasOwnProperty(U)&&u.hasOwnProperty(U)&&u[U]!=null)if(U==="style"){var b=u[U];for(x in b)b.hasOwnProperty(x)&&(a||(a={}),a[x]="")}else U!=="dangerouslySetInnerHTML"&&U!=="children"&&U!=="suppressContentEditableWarning"&&U!=="suppressHydrationWarning"&&U!=="autoFocus"&&(c.hasOwnProperty(U)?m||(m=[]):(m=m||[]).push(U,null));for(U in l){var R=l[U];if(b=u!=null?u[U]:void 0,l.hasOwnProperty(U)&&R!==b&&(R!=null||b!=null))if(U==="style")if(b){for(x in b)!b.hasOwnProperty(x)||R&&R.hasOwnProperty(x)||(a||(a={}),a[x]="");for(x in R)R.hasOwnProperty(x)&&b[x]!==R[x]&&(a||(a={}),a[x]=R[x])}else a||(m||(m=[]),m.push(U,a)),a=R;else U==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,b=b?b.__html:void 0,R!=null&&b!==R&&(m=m||[]).push(U,R)):U==="children"?typeof R!="string"&&typeof R!="number"||(m=m||[]).push(U,""+R):U!=="suppressContentEditableWarning"&&U!=="suppressHydrationWarning"&&(c.hasOwnProperty(U)?(R!=null&&U==="onScroll"&&Xe("scroll",e),m||b===R||(m=[])):(m=m||[]).push(U,R))}a&&(m=m||[]).push("style",a);var U=m;(t.updateQueue=U)&&(t.flags|=4)}},vd=function(e,t,a,l){a!==l&&(t.flags|=4)};function Is(e,t){if(!nt)switch(e.tailMode){case"hidden":t=e.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function It(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,l=0;if(t)for(var u=e.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags&14680064,l|=u.flags&14680064,u.return=e,u=u.sibling;else for(u=e.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags,l|=u.flags,u.return=e,u=u.sibling;return e.subtreeFlags|=l,e.childLanes=a,t}function Fp(e,t,a){var l=t.pendingProps;switch(co(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return It(t),null;case 1:return $t(t.type)&&ja(),It(t),null;case 3:return l=t.stateNode,Br(),Ze(Lt),Ze(Tt),ko(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(Ca(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,rn!==null&&(Zo(rn),rn=null))),Uo(e,t),It(t),null;case 5:jo(t);var u=cr(Ns.current);if(a=t.type,e!==null&&t.stateNode!=null)yd(e,t,a,l,u),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!l){if(t.stateNode===null)throw Error(i(166));return It(t),null}if(e=cr(pn.current),Ca(t)){l=t.stateNode,a=t.type;var m=t.memoizedProps;switch(l[hn]=t,l[ws]=m,e=(t.mode&1)!==0,a){case"dialog":Xe("cancel",l),Xe("close",l);break;case"iframe":case"object":case"embed":Xe("load",l);break;case"video":case"audio":for(u=0;u<ys.length;u++)Xe(ys[u],l);break;case"source":Xe("error",l);break;case"img":case"image":case"link":Xe("error",l),Xe("load",l);break;case"details":Xe("toggle",l);break;case"input":we(l,m),Xe("invalid",l);break;case"select":l._wrapperState={wasMultiple:!!m.multiple},Xe("invalid",l);break;case"textarea":ht(l,m),Xe("invalid",l)}tt(a,m),u=null;for(var x in m)if(m.hasOwnProperty(x)){var b=m[x];x==="children"?typeof b=="string"?l.textContent!==b&&(m.suppressHydrationWarning!==!0&&va(l.textContent,b,e),u=["children",b]):typeof b=="number"&&l.textContent!==""+b&&(m.suppressHydrationWarning!==!0&&va(l.textContent,b,e),u=["children",""+b]):c.hasOwnProperty(x)&&b!=null&&x==="onScroll"&&Xe("scroll",l)}switch(a){case"input":Ee(l),lt(l,m,!0);break;case"textarea":Ee(l),L(l);break;case"select":case"option":break;default:typeof m.onClick=="function"&&(l.onclick=xa)}l=u,t.updateQueue=l,l!==null&&(t.flags|=4)}else{x=u.nodeType===9?u:u.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=oe(a)),e==="http://www.w3.org/1999/xhtml"?a==="script"?(e=x.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=x.createElement(a,{is:l.is}):(e=x.createElement(a),a==="select"&&(x=e,l.multiple?x.multiple=!0:l.size&&(x.size=l.size))):e=x.createElementNS(e,a),e[hn]=t,e[ws]=l,gd(e,t,!1,!1),t.stateNode=e;e:{switch(x=bt(a,l),a){case"dialog":Xe("cancel",e),Xe("close",e),u=l;break;case"iframe":case"object":case"embed":Xe("load",e),u=l;break;case"video":case"audio":for(u=0;u<ys.length;u++)Xe(ys[u],e);u=l;break;case"source":Xe("error",e),u=l;break;case"img":case"image":case"link":Xe("error",e),Xe("load",e),u=l;break;case"details":Xe("toggle",e),u=l;break;case"input":we(e,l),u=X(e,l),Xe("invalid",e);break;case"option":u=l;break;case"select":e._wrapperState={wasMultiple:!!l.multiple},u=H({},l,{value:void 0}),Xe("invalid",e);break;case"textarea":ht(e,l),u=st(e,l),Xe("invalid",e);break;default:u=l}tt(a,u),b=u;for(m in b)if(b.hasOwnProperty(m)){var R=b[m];m==="style"?fn(e,R):m==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,R!=null&&de(e,R)):m==="children"?typeof R=="string"?(a!=="textarea"||R!=="")&&Oe(e,R):typeof R=="number"&&Oe(e,""+R):m!=="suppressContentEditableWarning"&&m!=="suppressHydrationWarning"&&m!=="autoFocus"&&(c.hasOwnProperty(m)?R!=null&&m==="onScroll"&&Xe("scroll",e):R!=null&&$(e,m,R,x))}switch(a){case"input":Ee(e),lt(e,l,!1);break;case"textarea":Ee(e),L(e);break;case"option":l.value!=null&&e.setAttribute("value",""+ke(l.value));break;case"select":e.multiple=!!l.multiple,m=l.value,m!=null?et(e,!!l.multiple,m,!1):l.defaultValue!=null&&et(e,!!l.multiple,l.defaultValue,!0);break;default:typeof u.onClick=="function"&&(e.onclick=xa)}switch(a){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}}l&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return It(t),null;case 6:if(e&&t.stateNode!=null)vd(e,t,e.memoizedProps,l);else{if(typeof l!="string"&&t.stateNode===null)throw Error(i(166));if(a=cr(Ns.current),cr(pn.current),Ca(t)){if(l=t.stateNode,a=t.memoizedProps,l[hn]=t,(m=l.nodeValue!==a)&&(e=Wt,e!==null))switch(e.tag){case 3:va(l.nodeValue,a,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&va(l.nodeValue,a,(e.mode&1)!==0)}m&&(t.flags|=4)}else l=(a.nodeType===9?a:a.ownerDocument).createTextNode(l),l[hn]=t,t.stateNode=l}return It(t),null;case 13:if(Ze(at),l=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(nt&&Ht!==null&&(t.mode&1)!==0&&(t.flags&128)===0)ju(),zr(),t.flags|=98560,m=!1;else if(m=Ca(t),l!==null&&l.dehydrated!==null){if(e===null){if(!m)throw Error(i(318));if(m=t.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(i(317));m[hn]=t}else zr(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;It(t),m=!1}else rn!==null&&(Zo(rn),rn=null),m=!0;if(!m)return t.flags&65536?t:null}return(t.flags&128)!==0?(t.lanes=a,t):(l=l!==null,l!==(e!==null&&e.memoizedState!==null)&&l&&(t.child.flags|=8192,(t.mode&1)!==0&&(e===null||(at.current&1)!==0?gt===0&&(gt=3):nl())),t.updateQueue!==null&&(t.flags|=4),It(t),null);case 4:return Br(),Uo(e,t),e===null&&vs(t.stateNode.containerInfo),It(t),null;case 10:return go(t.type._context),It(t),null;case 17:return $t(t.type)&&ja(),It(t),null;case 19:if(Ze(at),m=t.memoizedState,m===null)return It(t),null;if(l=(t.flags&128)!==0,x=m.rendering,x===null)if(l)Is(m,!1);else{if(gt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(x=Pa(e),x!==null){for(t.flags|=128,Is(m,!1),l=x.updateQueue,l!==null&&(t.updateQueue=l,t.flags|=4),t.subtreeFlags=0,l=a,a=t.child;a!==null;)m=a,e=l,m.flags&=14680066,x=m.alternate,x===null?(m.childLanes=0,m.lanes=e,m.child=null,m.subtreeFlags=0,m.memoizedProps=null,m.memoizedState=null,m.updateQueue=null,m.dependencies=null,m.stateNode=null):(m.childLanes=x.childLanes,m.lanes=x.lanes,m.child=x.child,m.subtreeFlags=0,m.deletions=null,m.memoizedProps=x.memoizedProps,m.memoizedState=x.memoizedState,m.updateQueue=x.updateQueue,m.type=x.type,e=x.dependencies,m.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),a=a.sibling;return qe(at,at.current&1|2),t.child}e=e.sibling}m.tail!==null&&ct()>Hr&&(t.flags|=128,l=!0,Is(m,!1),t.lanes=4194304)}else{if(!l)if(e=Pa(x),e!==null){if(t.flags|=128,l=!0,a=e.updateQueue,a!==null&&(t.updateQueue=a,t.flags|=4),Is(m,!0),m.tail===null&&m.tailMode==="hidden"&&!x.alternate&&!nt)return It(t),null}else 2*ct()-m.renderingStartTime>Hr&&a!==1073741824&&(t.flags|=128,l=!0,Is(m,!1),t.lanes=4194304);m.isBackwards?(x.sibling=t.child,t.child=x):(a=m.last,a!==null?a.sibling=x:t.child=x,m.last=x)}return m.tail!==null?(t=m.tail,m.rendering=t,m.tail=t.sibling,m.renderingStartTime=ct(),t.sibling=null,a=at.current,qe(at,l?a&1|2:a&1),t):(It(t),null);case 22:case 23:return tl(),l=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(t.flags|=8192),l&&(t.mode&1)!==0?(Vt&1073741824)!==0&&(It(t),t.subtreeFlags&6&&(t.flags|=8192)):It(t),null;case 24:return null;case 25:return null}throw Error(i(156,t.tag))}function Op(e,t){switch(co(t),t.tag){case 1:return $t(t.type)&&ja(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Br(),Ze(Lt),Ze(Tt),ko(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return jo(t),null;case 13:if(Ze(at),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));zr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ze(at),null;case 4:return Br(),null;case 10:return go(t.type._context),null;case 22:case 23:return tl(),null;case 24:return null;default:return null}}var Da=!1,At=!1,Mp=typeof WeakSet=="function"?WeakSet:Set,xe=null;function Ur(e,t){var a=e.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(l){ot(e,t,l)}else a.current=null}function Wo(e,t,a){try{a()}catch(l){ot(e,t,l)}}var xd=!1;function Bp(e,t){if(eo=oa,e=Qc(),Gi(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var u=l.anchorOffset,m=l.focusNode;l=l.focusOffset;try{a.nodeType,m.nodeType}catch{a=null;break e}var x=0,b=-1,R=-1,U=0,Q=0,ne=e,q=null;t:for(;;){for(var ye;ne!==a||u!==0&&ne.nodeType!==3||(b=x+u),ne!==m||l!==0&&ne.nodeType!==3||(R=x+l),ne.nodeType===3&&(x+=ne.nodeValue.length),(ye=ne.firstChild)!==null;)q=ne,ne=ye;for(;;){if(ne===e)break t;if(q===a&&++U===u&&(b=x),q===m&&++Q===l&&(R=x),(ye=ne.nextSibling)!==null)break;ne=q,q=ne.parentNode}ne=ye}a=b===-1||R===-1?null:{start:b,end:R}}else a=null}a=a||{start:0,end:0}}else a=null;for(to={focusedElem:e,selectionRange:a},oa=!1,xe=t;xe!==null;)if(t=xe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,xe=e;else for(;xe!==null;){t=xe;try{var Se=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(Se!==null){var be=Se.memoizedProps,ut=Se.memoizedState,z=t.stateNode,_=z.getSnapshotBeforeUpdate(t.elementType===t.type?be:sn(t.type,be),ut);z.__reactInternalSnapshotBeforeUpdate=_}break;case 3:var F=t.stateNode.containerInfo;F.nodeType===1?F.textContent="":F.nodeType===9&&F.documentElement&&F.removeChild(F.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(le){ot(t,t.return,le)}if(e=t.sibling,e!==null){e.return=t.return,xe=e;break}xe=t.return}return Se=xd,xd=!1,Se}function As(e,t,a){var l=t.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var u=l=l.next;do{if((u.tag&e)===e){var m=u.destroy;u.destroy=void 0,m!==void 0&&Wo(t,a,m)}u=u.next}while(u!==l)}}function Ua(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var a=t=t.next;do{if((a.tag&e)===e){var l=a.create;a.destroy=l()}a=a.next}while(a!==t)}}function Ho(e){var t=e.ref;if(t!==null){var a=e.stateNode;switch(e.tag){case 5:e=a;break;default:e=a}typeof t=="function"?t(e):t.current=e}}function wd(e){var t=e.alternate;t!==null&&(e.alternate=null,wd(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[hn],delete t[ws],delete t[ao],delete t[Sp],delete t[kp])),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 jd(e){return e.tag===5||e.tag===3||e.tag===4}function Sd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||jd(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 Vo(e,t,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?a.nodeType===8?a.parentNode.insertBefore(e,t):a.insertBefore(e,t):(a.nodeType===8?(t=a.parentNode,t.insertBefore(e,a)):(t=a,t.appendChild(e)),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=xa));else if(l!==4&&(e=e.child,e!==null))for(Vo(e,t,a),e=e.sibling;e!==null;)Vo(e,t,a),e=e.sibling}function Go(e,t,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(Go(e,t,a),e=e.sibling;e!==null;)Go(e,t,a),e=e.sibling}var Nt=null,an=!1;function Vn(e,t,a){for(a=a.child;a!==null;)kd(e,t,a),a=a.sibling}function kd(e,t,a){if(mn&&typeof mn.onCommitFiberUnmount=="function")try{mn.onCommitFiberUnmount(ta,a)}catch{}switch(a.tag){case 5:At||Ur(a,t);case 6:var l=Nt,u=an;Nt=null,Vn(e,t,a),Nt=l,an=u,Nt!==null&&(an?(e=Nt,a=a.stateNode,e.nodeType===8?e.parentNode.removeChild(a):e.removeChild(a)):Nt.removeChild(a.stateNode));break;case 18:Nt!==null&&(an?(e=Nt,a=a.stateNode,e.nodeType===8?so(e.parentNode,a):e.nodeType===1&&so(e,a),cs(e)):so(Nt,a.stateNode));break;case 4:l=Nt,u=an,Nt=a.stateNode.containerInfo,an=!0,Vn(e,t,a),Nt=l,an=u;break;case 0:case 11:case 14:case 15:if(!At&&(l=a.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){u=l=l.next;do{var m=u,x=m.destroy;m=m.tag,x!==void 0&&((m&2)!==0||(m&4)!==0)&&Wo(a,t,x),u=u.next}while(u!==l)}Vn(e,t,a);break;case 1:if(!At&&(Ur(a,t),l=a.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=a.memoizedProps,l.state=a.memoizedState,l.componentWillUnmount()}catch(b){ot(a,t,b)}Vn(e,t,a);break;case 21:Vn(e,t,a);break;case 22:a.mode&1?(At=(l=At)||a.memoizedState!==null,Vn(e,t,a),At=l):Vn(e,t,a);break;default:Vn(e,t,a)}}function bd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var a=e.stateNode;a===null&&(a=e.stateNode=new Mp),t.forEach(function(l){var u=Jp.bind(null,e,l);a.has(l)||(a.add(l),l.then(u,u))})}}function on(e,t){var a=t.deletions;if(a!==null)for(var l=0;l<a.length;l++){var u=a[l];try{var m=e,x=t,b=x;e:for(;b!==null;){switch(b.tag){case 5:Nt=b.stateNode,an=!1;break e;case 3:Nt=b.stateNode.containerInfo,an=!0;break e;case 4:Nt=b.stateNode.containerInfo,an=!0;break e}b=b.return}if(Nt===null)throw Error(i(160));kd(m,x,u),Nt=null,an=!1;var R=u.alternate;R!==null&&(R.return=null),u.return=null}catch(U){ot(u,t,U)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Nd(t,e),t=t.sibling}function Nd(e,t){var a=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(on(t,e),yn(e),l&4){try{As(3,e,e.return),Ua(3,e)}catch(be){ot(e,e.return,be)}try{As(5,e,e.return)}catch(be){ot(e,e.return,be)}}break;case 1:on(t,e),yn(e),l&512&&a!==null&&Ur(a,a.return);break;case 5:if(on(t,e),yn(e),l&512&&a!==null&&Ur(a,a.return),e.flags&32){var u=e.stateNode;try{Oe(u,"")}catch(be){ot(e,e.return,be)}}if(l&4&&(u=e.stateNode,u!=null)){var m=e.memoizedProps,x=a!==null?a.memoizedProps:m,b=e.type,R=e.updateQueue;if(e.updateQueue=null,R!==null)try{b==="input"&&m.type==="radio"&&m.name!=null&&Te(u,m),bt(b,x);var U=bt(b,m);for(x=0;x<R.length;x+=2){var Q=R[x],ne=R[x+1];Q==="style"?fn(u,ne):Q==="dangerouslySetInnerHTML"?de(u,ne):Q==="children"?Oe(u,ne):$(u,Q,ne,U)}switch(b){case"input":Le(u,m);break;case"textarea":Fe(u,m);break;case"select":var q=u._wrapperState.wasMultiple;u._wrapperState.wasMultiple=!!m.multiple;var ye=m.value;ye!=null?et(u,!!m.multiple,ye,!1):q!==!!m.multiple&&(m.defaultValue!=null?et(u,!!m.multiple,m.defaultValue,!0):et(u,!!m.multiple,m.multiple?[]:"",!1))}u[ws]=m}catch(be){ot(e,e.return,be)}}break;case 6:if(on(t,e),yn(e),l&4){if(e.stateNode===null)throw Error(i(162));u=e.stateNode,m=e.memoizedProps;try{u.nodeValue=m}catch(be){ot(e,e.return,be)}}break;case 3:if(on(t,e),yn(e),l&4&&a!==null&&a.memoizedState.isDehydrated)try{cs(t.containerInfo)}catch(be){ot(e,e.return,be)}break;case 4:on(t,e),yn(e);break;case 13:on(t,e),yn(e),u=e.child,u.flags&8192&&(m=u.memoizedState!==null,u.stateNode.isHidden=m,!m||u.alternate!==null&&u.alternate.memoizedState!==null||(Jo=ct())),l&4&&bd(e);break;case 22:if(Q=a!==null&&a.memoizedState!==null,e.mode&1?(At=(U=At)||Q,on(t,e),At=U):on(t,e),yn(e),l&8192){if(U=e.memoizedState!==null,(e.stateNode.isHidden=U)&&!Q&&(e.mode&1)!==0)for(xe=e,Q=e.child;Q!==null;){for(ne=xe=Q;xe!==null;){switch(q=xe,ye=q.child,q.tag){case 0:case 11:case 14:case 15:As(4,q,q.return);break;case 1:Ur(q,q.return);var Se=q.stateNode;if(typeof Se.componentWillUnmount=="function"){l=q,a=q.return;try{t=l,Se.props=t.memoizedProps,Se.state=t.memoizedState,Se.componentWillUnmount()}catch(be){ot(l,a,be)}}break;case 5:Ur(q,q.return);break;case 22:if(q.memoizedState!==null){Td(ne);continue}}ye!==null?(ye.return=q,xe=ye):Td(ne)}Q=Q.sibling}e:for(Q=null,ne=e;;){if(ne.tag===5){if(Q===null){Q=ne;try{u=ne.stateNode,U?(m=u.style,typeof m.setProperty=="function"?m.setProperty("display","none","important"):m.display="none"):(b=ne.stateNode,R=ne.memoizedProps.style,x=R!=null&&R.hasOwnProperty("display")?R.display:null,b.style.display=ft("display",x))}catch(be){ot(e,e.return,be)}}}else if(ne.tag===6){if(Q===null)try{ne.stateNode.nodeValue=U?"":ne.memoizedProps}catch(be){ot(e,e.return,be)}}else if((ne.tag!==22&&ne.tag!==23||ne.memoizedState===null||ne===e)&&ne.child!==null){ne.child.return=ne,ne=ne.child;continue}if(ne===e)break e;for(;ne.sibling===null;){if(ne.return===null||ne.return===e)break e;Q===ne&&(Q=null),ne=ne.return}Q===ne&&(Q=null),ne.sibling.return=ne.return,ne=ne.sibling}}break;case 19:on(t,e),yn(e),l&4&&bd(e);break;case 21:break;default:on(t,e),yn(e)}}function yn(e){var t=e.flags;if(t&2){try{e:{for(var a=e.return;a!==null;){if(jd(a)){var l=a;break e}a=a.return}throw Error(i(160))}switch(l.tag){case 5:var u=l.stateNode;l.flags&32&&(Oe(u,""),l.flags&=-33);var m=Sd(e);Go(e,m,u);break;case 3:case 4:var x=l.stateNode.containerInfo,b=Sd(e);Vo(e,b,x);break;default:throw Error(i(161))}}catch(R){ot(e,e.return,R)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Dp(e,t,a){xe=e,Cd(e)}function Cd(e,t,a){for(var l=(e.mode&1)!==0;xe!==null;){var u=xe,m=u.child;if(u.tag===22&&l){var x=u.memoizedState!==null||Da;if(!x){var b=u.alternate,R=b!==null&&b.memoizedState!==null||At;b=Da;var U=At;if(Da=x,(At=R)&&!U)for(xe=u;xe!==null;)x=xe,R=x.child,x.tag===22&&x.memoizedState!==null?Rd(u):R!==null?(R.return=x,xe=R):Rd(u);for(;m!==null;)xe=m,Cd(m),m=m.sibling;xe=u,Da=b,At=U}Ed(e)}else(u.subtreeFlags&8772)!==0&&m!==null?(m.return=u,xe=m):Ed(e)}}function Ed(e){for(;xe!==null;){var t=xe;if((t.flags&8772)!==0){var a=t.alternate;try{if((t.flags&8772)!==0)switch(t.tag){case 0:case 11:case 15:At||Ua(5,t);break;case 1:var l=t.stateNode;if(t.flags&4&&!At)if(a===null)l.componentDidMount();else{var u=t.elementType===t.type?a.memoizedProps:sn(t.type,a.memoizedProps);l.componentDidUpdate(u,a.memoizedState,l.__reactInternalSnapshotBeforeUpdate)}var m=t.updateQueue;m!==null&&Tu(t,m,l);break;case 3:var x=t.updateQueue;if(x!==null){if(a=null,t.child!==null)switch(t.child.tag){case 5:a=t.child.stateNode;break;case 1:a=t.child.stateNode}Tu(t,x,a)}break;case 5:var b=t.stateNode;if(a===null&&t.flags&4){a=b;var R=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":R.autoFocus&&a.focus();break;case"img":R.src&&(a.src=R.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var U=t.alternate;if(U!==null){var Q=U.memoizedState;if(Q!==null){var ne=Q.dehydrated;ne!==null&&cs(ne)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(i(163))}At||t.flags&512&&Ho(t)}catch(q){ot(t,t.return,q)}}if(t===e){xe=null;break}if(a=t.sibling,a!==null){a.return=t.return,xe=a;break}xe=t.return}}function Td(e){for(;xe!==null;){var t=xe;if(t===e){xe=null;break}var a=t.sibling;if(a!==null){a.return=t.return,xe=a;break}xe=t.return}}function Rd(e){for(;xe!==null;){var t=xe;try{switch(t.tag){case 0:case 11:case 15:var a=t.return;try{Ua(4,t)}catch(R){ot(t,a,R)}break;case 1:var l=t.stateNode;if(typeof l.componentDidMount=="function"){var u=t.return;try{l.componentDidMount()}catch(R){ot(t,u,R)}}var m=t.return;try{Ho(t)}catch(R){ot(t,m,R)}break;case 5:var x=t.return;try{Ho(t)}catch(R){ot(t,x,R)}}}catch(R){ot(t,t.return,R)}if(t===e){xe=null;break}var b=t.sibling;if(b!==null){b.return=t.return,xe=b;break}xe=t.return}}var Up=Math.ceil,Wa=P.ReactCurrentDispatcher,Ko=P.ReactCurrentOwner,Qt=P.ReactCurrentBatchConfig,Ue=0,St=null,mt=null,Ct=0,Vt=0,Wr=Bn(0),gt=0,Ps=null,dr=0,Ha=0,Yo=0,_s=null,Ft=null,Jo=0,Hr=1/0,Tn=null,Va=!1,qo=null,Gn=null,Ga=!1,Kn=null,Ka=0,Ls=0,Qo=null,Ya=-1,Ja=0;function _t(){return(Ue&6)!==0?ct():Ya!==-1?Ya:Ya=ct()}function Yn(e){return(e.mode&1)===0?1:(Ue&2)!==0&&Ct!==0?Ct&-Ct:Np.transition!==null?(Ja===0&&(Ja=Sc()),Ja):(e=Ve,e!==0||(e=window.event,e=e===void 0?16:Ac(e.type)),e)}function ln(e,t,a,l){if(50<Ls)throw Ls=0,Qo=null,Error(i(185));ss(e,a,l),((Ue&2)===0||e!==St)&&(e===St&&((Ue&2)===0&&(Ha|=a),gt===4&&Jn(e,Ct)),Ot(e,l),a===1&&Ue===0&&(t.mode&1)===0&&(Hr=ct()+500,ka&&Un()))}function Ot(e,t){var a=e.callbackNode;Nh(e,t);var l=sa(e,e===St?Ct:0);if(l===0)a!==null&&xc(a),e.callbackNode=null,e.callbackPriority=0;else if(t=l&-l,e.callbackPriority!==t){if(a!=null&&xc(a),t===1)e.tag===0?bp(Ad.bind(null,e)):gu(Ad.bind(null,e)),wp(function(){(Ue&6)===0&&Un()}),a=null;else{switch(kc(l)){case 1:a=Ri;break;case 4:a=wc;break;case 16:a=ea;break;case 536870912:a=jc;break;default:a=ea}a=Md(a,Id.bind(null,e))}e.callbackPriority=t,e.callbackNode=a}}function Id(e,t){if(Ya=-1,Ja=0,(Ue&6)!==0)throw Error(i(327));var a=e.callbackNode;if(Vr()&&e.callbackNode!==a)return null;var l=sa(e,e===St?Ct:0);if(l===0)return null;if((l&30)!==0||(l&e.expiredLanes)!==0||t)t=qa(e,l);else{t=l;var u=Ue;Ue|=2;var m=_d();(St!==e||Ct!==t)&&(Tn=null,Hr=ct()+500,mr(e,t));do try{Vp();break}catch(b){Pd(e,b)}while(!0);po(),Wa.current=m,Ue=u,mt!==null?t=0:(St=null,Ct=0,t=gt)}if(t!==0){if(t===2&&(u=Ii(e),u!==0&&(l=u,t=Xo(e,u))),t===1)throw a=Ps,mr(e,0),Jn(e,l),Ot(e,ct()),a;if(t===6)Jn(e,l);else{if(u=e.current.alternate,(l&30)===0&&!Wp(u)&&(t=qa(e,l),t===2&&(m=Ii(e),m!==0&&(l=m,t=Xo(e,m))),t===1))throw a=Ps,mr(e,0),Jn(e,l),Ot(e,ct()),a;switch(e.finishedWork=u,e.finishedLanes=l,t){case 0:case 1:throw Error(i(345));case 2:hr(e,Ft,Tn);break;case 3:if(Jn(e,l),(l&130023424)===l&&(t=Jo+500-ct(),10<t)){if(sa(e,0)!==0)break;if(u=e.suspendedLanes,(u&l)!==l){_t(),e.pingedLanes|=e.suspendedLanes&u;break}e.timeoutHandle=ro(hr.bind(null,e,Ft,Tn),t);break}hr(e,Ft,Tn);break;case 4:if(Jn(e,l),(l&4194240)===l)break;for(t=e.eventTimes,u=-1;0<l;){var x=31-tn(l);m=1<<x,x=t[x],x>u&&(u=x),l&=~m}if(l=u,l=ct()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Up(l/1960))-l,10<l){e.timeoutHandle=ro(hr.bind(null,e,Ft,Tn),l);break}hr(e,Ft,Tn);break;case 5:hr(e,Ft,Tn);break;default:throw Error(i(329))}}}return Ot(e,ct()),e.callbackNode===a?Id.bind(null,e):null}function Xo(e,t){var a=_s;return e.current.memoizedState.isDehydrated&&(mr(e,t).flags|=256),e=qa(e,t),e!==2&&(t=Ft,Ft=a,t!==null&&Zo(t)),e}function Zo(e){Ft===null?Ft=e:Ft.push.apply(Ft,e)}function Wp(e){for(var t=e;;){if(t.flags&16384){var a=t.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var l=0;l<a.length;l++){var u=a[l],m=u.getSnapshot;u=u.value;try{if(!nn(m(),u))return!1}catch{return!1}}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Jn(e,t){for(t&=~Yo,t&=~Ha,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var a=31-tn(t),l=1<<a;e[a]=-1,t&=~l}}function Ad(e){if((Ue&6)!==0)throw Error(i(327));Vr();var t=sa(e,0);if((t&1)===0)return Ot(e,ct()),null;var a=qa(e,t);if(e.tag!==0&&a===2){var l=Ii(e);l!==0&&(t=l,a=Xo(e,l))}if(a===1)throw a=Ps,mr(e,0),Jn(e,t),Ot(e,ct()),a;if(a===6)throw Error(i(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,hr(e,Ft,Tn),Ot(e,ct()),null}function el(e,t){var a=Ue;Ue|=1;try{return e(t)}finally{Ue=a,Ue===0&&(Hr=ct()+500,ka&&Un())}}function fr(e){Kn!==null&&Kn.tag===0&&(Ue&6)===0&&Vr();var t=Ue;Ue|=1;var a=Qt.transition,l=Ve;try{if(Qt.transition=null,Ve=1,e)return e()}finally{Ve=l,Qt.transition=a,Ue=t,(Ue&6)===0&&Un()}}function tl(){Vt=Wr.current,Ze(Wr)}function mr(e,t){e.finishedWork=null,e.finishedLanes=0;var a=e.timeoutHandle;if(a!==-1&&(e.timeoutHandle=-1,xp(a)),mt!==null)for(a=mt.return;a!==null;){var l=a;switch(co(l),l.tag){case 1:l=l.type.childContextTypes,l!=null&&ja();break;case 3:Br(),Ze(Lt),Ze(Tt),ko();break;case 5:jo(l);break;case 4:Br();break;case 13:Ze(at);break;case 19:Ze(at);break;case 10:go(l.type._context);break;case 22:case 23:tl()}a=a.return}if(St=e,mt=e=qn(e.current,null),Ct=Vt=t,gt=0,Ps=null,Yo=Ha=dr=0,Ft=_s=null,lr!==null){for(t=0;t<lr.length;t++)if(a=lr[t],l=a.interleaved,l!==null){a.interleaved=null;var u=l.next,m=a.pending;if(m!==null){var x=m.next;m.next=u,l.next=x}a.pending=l}lr=null}return e}function Pd(e,t){do{var a=mt;try{if(po(),_a.current=Fa,La){for(var l=it.memoizedState;l!==null;){var u=l.queue;u!==null&&(u.pending=null),l=l.next}La=!1}if(ur=0,jt=pt=it=null,Cs=!1,Es=0,Ko.current=null,a===null||a.return===null){gt=1,Ps=t,mt=null;break}e:{var m=e,x=a.return,b=a,R=t;if(t=Ct,b.flags|=32768,R!==null&&typeof R=="object"&&typeof R.then=="function"){var U=R,Q=b,ne=Q.tag;if((Q.mode&1)===0&&(ne===0||ne===11||ne===15)){var q=Q.alternate;q?(Q.updateQueue=q.updateQueue,Q.memoizedState=q.memoizedState,Q.lanes=q.lanes):(Q.updateQueue=null,Q.memoizedState=null)}var ye=rd(x);if(ye!==null){ye.flags&=-257,sd(ye,x,b,m,t),ye.mode&1&&nd(m,U,t),t=ye,R=U;var Se=t.updateQueue;if(Se===null){var be=new Set;be.add(R),t.updateQueue=be}else Se.add(R);break e}else{if((t&1)===0){nd(m,U,t),nl();break e}R=Error(i(426))}}else if(nt&&b.mode&1){var ut=rd(x);if(ut!==null){(ut.flags&65536)===0&&(ut.flags|=256),sd(ut,x,b,m,t),mo(Dr(R,b));break e}}m=R=Dr(R,b),gt!==4&&(gt=2),_s===null?_s=[m]:_s.push(m),m=x;do{switch(m.tag){case 3:m.flags|=65536,t&=-t,m.lanes|=t;var z=ed(m,R,t);Eu(m,z);break e;case 1:b=R;var _=m.type,F=m.stateNode;if((m.flags&128)===0&&(typeof _.getDerivedStateFromError=="function"||F!==null&&typeof F.componentDidCatch=="function"&&(Gn===null||!Gn.has(F)))){m.flags|=65536,t&=-t,m.lanes|=t;var le=td(m,b,t);Eu(m,le);break e}}m=m.return}while(m!==null)}$d(a)}catch(Ne){t=Ne,mt===a&&a!==null&&(mt=a=a.return);continue}break}while(!0)}function _d(){var e=Wa.current;return Wa.current=Fa,e===null?Fa:e}function nl(){(gt===0||gt===3||gt===2)&&(gt=4),St===null||(dr&268435455)===0&&(Ha&268435455)===0||Jn(St,Ct)}function qa(e,t){var a=Ue;Ue|=2;var l=_d();(St!==e||Ct!==t)&&(Tn=null,mr(e,t));do try{Hp();break}catch(u){Pd(e,u)}while(!0);if(po(),Ue=a,Wa.current=l,mt!==null)throw Error(i(261));return St=null,Ct=0,gt}function Hp(){for(;mt!==null;)Ld(mt)}function Vp(){for(;mt!==null&&!gh();)Ld(mt)}function Ld(e){var t=Od(e.alternate,e,Vt);e.memoizedProps=e.pendingProps,t===null?$d(e):mt=t,Ko.current=null}function $d(e){var t=e;do{var a=t.alternate;if(e=t.return,(t.flags&32768)===0){if(a=Fp(a,t,Vt),a!==null){mt=a;return}}else{if(a=Op(a,t),a!==null){a.flags&=32767,mt=a;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{gt=6,mt=null;return}}if(t=t.sibling,t!==null){mt=t;return}mt=t=e}while(t!==null);gt===0&&(gt=5)}function hr(e,t,a){var l=Ve,u=Qt.transition;try{Qt.transition=null,Ve=1,Gp(e,t,a,l)}finally{Qt.transition=u,Ve=l}return null}function Gp(e,t,a,l){do Vr();while(Kn!==null);if((Ue&6)!==0)throw Error(i(327));a=e.finishedWork;var u=e.finishedLanes;if(a===null)return null;if(e.finishedWork=null,e.finishedLanes=0,a===e.current)throw Error(i(177));e.callbackNode=null,e.callbackPriority=0;var m=a.lanes|a.childLanes;if(Ch(e,m),e===St&&(mt=St=null,Ct=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||Ga||(Ga=!0,Md(ea,function(){return Vr(),null})),m=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||m){m=Qt.transition,Qt.transition=null;var x=Ve;Ve=1;var b=Ue;Ue|=4,Ko.current=null,Bp(e,a),Nd(a,e),fp(to),oa=!!eo,to=eo=null,e.current=a,Dp(a),yh(),Ue=b,Ve=x,Qt.transition=m}else e.current=a;if(Ga&&(Ga=!1,Kn=e,Ka=u),m=e.pendingLanes,m===0&&(Gn=null),wh(a.stateNode),Ot(e,ct()),t!==null)for(l=e.onRecoverableError,a=0;a<t.length;a++)u=t[a],l(u.value,{componentStack:u.stack,digest:u.digest});if(Va)throw Va=!1,e=qo,qo=null,e;return(Ka&1)!==0&&e.tag!==0&&Vr(),m=e.pendingLanes,(m&1)!==0?e===Qo?Ls++:(Ls=0,Qo=e):Ls=0,Un(),null}function Vr(){if(Kn!==null){var e=kc(Ka),t=Qt.transition,a=Ve;try{if(Qt.transition=null,Ve=16>e?16:e,Kn===null)var l=!1;else{if(e=Kn,Kn=null,Ka=0,(Ue&6)!==0)throw Error(i(331));var u=Ue;for(Ue|=4,xe=e.current;xe!==null;){var m=xe,x=m.child;if((xe.flags&16)!==0){var b=m.deletions;if(b!==null){for(var R=0;R<b.length;R++){var U=b[R];for(xe=U;xe!==null;){var Q=xe;switch(Q.tag){case 0:case 11:case 15:As(8,Q,m)}var ne=Q.child;if(ne!==null)ne.return=Q,xe=ne;else for(;xe!==null;){Q=xe;var q=Q.sibling,ye=Q.return;if(wd(Q),Q===U){xe=null;break}if(q!==null){q.return=ye,xe=q;break}xe=ye}}}var Se=m.alternate;if(Se!==null){var be=Se.child;if(be!==null){Se.child=null;do{var ut=be.sibling;be.sibling=null,be=ut}while(be!==null)}}xe=m}}if((m.subtreeFlags&2064)!==0&&x!==null)x.return=m,xe=x;else e:for(;xe!==null;){if(m=xe,(m.flags&2048)!==0)switch(m.tag){case 0:case 11:case 15:As(9,m,m.return)}var z=m.sibling;if(z!==null){z.return=m.return,xe=z;break e}xe=m.return}}var _=e.current;for(xe=_;xe!==null;){x=xe;var F=x.child;if((x.subtreeFlags&2064)!==0&&F!==null)F.return=x,xe=F;else e:for(x=_;xe!==null;){if(b=xe,(b.flags&2048)!==0)try{switch(b.tag){case 0:case 11:case 15:Ua(9,b)}}catch(Ne){ot(b,b.return,Ne)}if(b===x){xe=null;break e}var le=b.sibling;if(le!==null){le.return=b.return,xe=le;break e}xe=b.return}}if(Ue=u,Un(),mn&&typeof mn.onPostCommitFiberRoot=="function")try{mn.onPostCommitFiberRoot(ta,e)}catch{}l=!0}return l}finally{Ve=a,Qt.transition=t}}return!1}function zd(e,t,a){t=Dr(a,t),t=ed(e,t,1),e=Hn(e,t,1),t=_t(),e!==null&&(ss(e,1,t),Ot(e,t))}function ot(e,t,a){if(e.tag===3)zd(e,e,a);else for(;t!==null;){if(t.tag===3){zd(t,e,a);break}else if(t.tag===1){var l=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(Gn===null||!Gn.has(l))){e=Dr(a,e),e=td(t,e,1),t=Hn(t,e,1),e=_t(),t!==null&&(ss(t,1,e),Ot(t,e));break}}t=t.return}}function Kp(e,t,a){var l=e.pingCache;l!==null&&l.delete(t),t=_t(),e.pingedLanes|=e.suspendedLanes&a,St===e&&(Ct&a)===a&&(gt===4||gt===3&&(Ct&130023424)===Ct&&500>ct()-Jo?mr(e,0):Yo|=a),Ot(e,t)}function Fd(e,t){t===0&&((e.mode&1)===0?t=1:(t=ra,ra<<=1,(ra&130023424)===0&&(ra=4194304)));var a=_t();e=Nn(e,t),e!==null&&(ss(e,t,a),Ot(e,a))}function Yp(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),Fd(e,a)}function Jp(e,t){var a=0;switch(e.tag){case 13:var l=e.stateNode,u=e.memoizedState;u!==null&&(a=u.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(i(314))}l!==null&&l.delete(t),Fd(e,a)}var Od;Od=function(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps||Lt.current)zt=!0;else{if((e.lanes&a)===0&&(t.flags&128)===0)return zt=!1,zp(e,t,a);zt=(e.flags&131072)!==0}else zt=!1,nt&&(t.flags&1048576)!==0&&yu(t,Na,t.index);switch(t.lanes=0,t.tag){case 2:var l=t.type;Ba(e,t),e=t.pendingProps;var u=_r(t,Tt.current);Mr(t,a),u=Co(null,t,l,e,u,a);var m=Eo();return t.flags|=1,typeof u=="object"&&u!==null&&typeof u.render=="function"&&u.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,$t(l)?(m=!0,Sa(t)):m=!1,t.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,xo(t),u.updater=Oa,t.stateNode=u,u._reactInternals=t,_o(t,l,e,a),t=Fo(null,t,l,!0,m,a)):(t.tag=0,nt&&m&&lo(t),Pt(null,t,u,a),t=t.child),t;case 16:l=t.elementType;e:{switch(Ba(e,t),e=t.pendingProps,u=l._init,l=u(l._payload),t.type=l,u=t.tag=Qp(l),e=sn(l,e),u){case 0:t=zo(null,t,l,e,a);break e;case 1:t=ud(null,t,l,e,a);break e;case 11:t=ad(null,t,l,e,a);break e;case 14:t=id(null,t,l,sn(l.type,e),a);break e}throw Error(i(306,l,""))}return t;case 0:return l=t.type,u=t.pendingProps,u=t.elementType===l?u:sn(l,u),zo(e,t,l,u,a);case 1:return l=t.type,u=t.pendingProps,u=t.elementType===l?u:sn(l,u),ud(e,t,l,u,a);case 3:e:{if(dd(t),e===null)throw Error(i(387));l=t.pendingProps,m=t.memoizedState,u=m.element,Cu(e,t),Aa(t,l,null,a);var x=t.memoizedState;if(l=x.element,m.isDehydrated)if(m={element:l,isDehydrated:!1,cache:x.cache,pendingSuspenseBoundaries:x.pendingSuspenseBoundaries,transitions:x.transitions},t.updateQueue.baseState=m,t.memoizedState=m,t.flags&256){u=Dr(Error(i(423)),t),t=fd(e,t,l,a,u);break e}else if(l!==u){u=Dr(Error(i(424)),t),t=fd(e,t,l,a,u);break e}else for(Ht=Mn(t.stateNode.containerInfo.firstChild),Wt=t,nt=!0,rn=null,a=bu(t,null,l,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(zr(),l===u){t=En(e,t,a);break e}Pt(e,t,l,a)}t=t.child}return t;case 5:return Ru(t),e===null&&fo(t),l=t.type,u=t.pendingProps,m=e!==null?e.memoizedProps:null,x=u.children,no(l,u)?x=null:m!==null&&no(l,m)&&(t.flags|=32),cd(e,t),Pt(e,t,x,a),t.child;case 6:return e===null&&fo(t),null;case 13:return md(e,t,a);case 4:return wo(t,t.stateNode.containerInfo),l=t.pendingProps,e===null?t.child=Fr(t,null,l,a):Pt(e,t,l,a),t.child;case 11:return l=t.type,u=t.pendingProps,u=t.elementType===l?u:sn(l,u),ad(e,t,l,u,a);case 7:return Pt(e,t,t.pendingProps,a),t.child;case 8:return Pt(e,t,t.pendingProps.children,a),t.child;case 12:return Pt(e,t,t.pendingProps.children,a),t.child;case 10:e:{if(l=t.type._context,u=t.pendingProps,m=t.memoizedProps,x=u.value,qe(Ta,l._currentValue),l._currentValue=x,m!==null)if(nn(m.value,x)){if(m.children===u.children&&!Lt.current){t=En(e,t,a);break e}}else for(m=t.child,m!==null&&(m.return=t);m!==null;){var b=m.dependencies;if(b!==null){x=m.child;for(var R=b.firstContext;R!==null;){if(R.context===l){if(m.tag===1){R=Cn(-1,a&-a),R.tag=2;var U=m.updateQueue;if(U!==null){U=U.shared;var Q=U.pending;Q===null?R.next=R:(R.next=Q.next,Q.next=R),U.pending=R}}m.lanes|=a,R=m.alternate,R!==null&&(R.lanes|=a),yo(m.return,a,t),b.lanes|=a;break}R=R.next}}else if(m.tag===10)x=m.type===t.type?null:m.child;else if(m.tag===18){if(x=m.return,x===null)throw Error(i(341));x.lanes|=a,b=x.alternate,b!==null&&(b.lanes|=a),yo(x,a,t),x=m.sibling}else x=m.child;if(x!==null)x.return=m;else for(x=m;x!==null;){if(x===t){x=null;break}if(m=x.sibling,m!==null){m.return=x.return,x=m;break}x=x.return}m=x}Pt(e,t,u.children,a),t=t.child}return t;case 9:return u=t.type,l=t.pendingProps.children,Mr(t,a),u=Jt(u),l=l(u),t.flags|=1,Pt(e,t,l,a),t.child;case 14:return l=t.type,u=sn(l,t.pendingProps),u=sn(l.type,u),id(e,t,l,u,a);case 15:return od(e,t,t.type,t.pendingProps,a);case 17:return l=t.type,u=t.pendingProps,u=t.elementType===l?u:sn(l,u),Ba(e,t),t.tag=1,$t(l)?(e=!0,Sa(t)):e=!1,Mr(t,a),Xu(t,l,u),_o(t,l,u,a),Fo(null,t,l,!0,e,a);case 19:return pd(e,t,a);case 22:return ld(e,t,a)}throw Error(i(156,t.tag))};function Md(e,t){return vc(e,t)}function qp(e,t,a,l){this.tag=e,this.key=a,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=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xt(e,t,a,l){return new qp(e,t,a,l)}function rl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Qp(e){if(typeof e=="function")return rl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===O)return 11;if(e===Z)return 14}return 2}function qn(e,t){var a=e.alternate;return a===null?(a=Xt(e.tag,t,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=t,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&14680064,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,t=e.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a}function Qa(e,t,a,l,u,m){var x=2;if(l=e,typeof e=="function")rl(e)&&(x=1);else if(typeof e=="string")x=5;else e:switch(e){case V:return pr(a.children,u,m,t);case ce:x=8,u|=8;break;case Y:return e=Xt(12,a,t,u|2),e.elementType=Y,e.lanes=m,e;case fe:return e=Xt(13,a,t,u),e.elementType=fe,e.lanes=m,e;case ie:return e=Xt(19,a,t,u),e.elementType=ie,e.lanes=m,e;case ee:return Xa(a,u,m,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case re:x=10;break e;case J:x=9;break e;case O:x=11;break e;case Z:x=14;break e;case pe:x=16,l=null;break e}throw Error(i(130,e==null?e:typeof e,""))}return t=Xt(x,a,t,u),t.elementType=e,t.type=l,t.lanes=m,t}function pr(e,t,a,l){return e=Xt(7,e,l,t),e.lanes=a,e}function Xa(e,t,a,l){return e=Xt(22,e,l,t),e.elementType=ee,e.lanes=a,e.stateNode={isHidden:!1},e}function sl(e,t,a){return e=Xt(6,e,null,t),e.lanes=a,e}function al(e,t,a){return t=Xt(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Xp(e,t,a,l,u){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=Ai(0),this.expirationTimes=Ai(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ai(0),this.identifierPrefix=l,this.onRecoverableError=u,this.mutableSourceEagerHydrationData=null}function il(e,t,a,l,u,m,x,b,R){return e=new Xp(e,t,a,b,R),t===1?(t=1,m===!0&&(t|=8)):t=0,m=Xt(3,null,null,t),e.current=m,m.stateNode=e,m.memoizedState={element:l,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},xo(m),e}function Zp(e,t,a){var l=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:K,key:l==null?null:""+l,children:e,containerInfo:t,implementation:a}}function Bd(e){if(!e)return Dn;e=e._reactInternals;e:{if(rr(e)!==e||e.tag!==1)throw Error(i(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if($t(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(i(171))}if(e.tag===1){var a=e.type;if($t(a))return hu(e,a,t)}return t}function Dd(e,t,a,l,u,m,x,b,R){return e=il(a,l,!0,e,u,m,x,b,R),e.context=Bd(null),a=e.current,l=_t(),u=Yn(a),m=Cn(l,u),m.callback=t??null,Hn(a,m,u),e.current.lanes=u,ss(e,u,l),Ot(e,l),e}function Za(e,t,a,l){var u=t.current,m=_t(),x=Yn(u);return a=Bd(a),t.context===null?t.context=a:t.pendingContext=a,t=Cn(m,x),t.payload={element:e},l=l===void 0?null:l,l!==null&&(t.callback=l),e=Hn(u,t,x),e!==null&&(ln(e,u,x,m),Ia(e,u,x)),x}function ei(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Ud(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function ol(e,t){Ud(e,t),(e=e.alternate)&&Ud(e,t)}function eg(){return null}var Wd=typeof reportError=="function"?reportError:function(e){console.error(e)};function ll(e){this._internalRoot=e}ti.prototype.render=ll.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));Za(e,t,null,null)},ti.prototype.unmount=ll.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;fr(function(){Za(null,e,null,null)}),t[jn]=null}};function ti(e){this._internalRoot=e}ti.prototype.unstable_scheduleHydration=function(e){if(e){var t=Cc();e={blockedOn:null,target:e,priority:t};for(var a=0;a<zn.length&&t!==0&&t<zn[a].priority;a++);zn.splice(a,0,e),a===0&&Rc(e)}};function cl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ni(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Hd(){}function tg(e,t,a,l,u){if(u){if(typeof l=="function"){var m=l;l=function(){var U=ei(x);m.call(U)}}var x=Dd(t,l,e,0,null,!1,!1,"",Hd);return e._reactRootContainer=x,e[jn]=x.current,vs(e.nodeType===8?e.parentNode:e),fr(),x}for(;u=e.lastChild;)e.removeChild(u);if(typeof l=="function"){var b=l;l=function(){var U=ei(R);b.call(U)}}var R=il(e,0,!1,null,null,!1,!1,"",Hd);return e._reactRootContainer=R,e[jn]=R.current,vs(e.nodeType===8?e.parentNode:e),fr(function(){Za(t,R,a,l)}),R}function ri(e,t,a,l,u){var m=a._reactRootContainer;if(m){var x=m;if(typeof u=="function"){var b=u;u=function(){var R=ei(x);b.call(R)}}Za(t,x,e,u)}else x=tg(a,t,e,u,l);return ei(x)}bc=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var a=rs(t.pendingLanes);a!==0&&(Pi(t,a|1),Ot(t,ct()),(Ue&6)===0&&(Hr=ct()+500,Un()))}break;case 13:fr(function(){var l=Nn(e,1);if(l!==null){var u=_t();ln(l,e,1,u)}}),ol(e,1)}},_i=function(e){if(e.tag===13){var t=Nn(e,134217728);if(t!==null){var a=_t();ln(t,e,134217728,a)}ol(e,134217728)}},Nc=function(e){if(e.tag===13){var t=Yn(e),a=Nn(e,t);if(a!==null){var l=_t();ln(a,e,t,l)}ol(e,t)}},Cc=function(){return Ve},Ec=function(e,t){var a=Ve;try{return Ve=e,t()}finally{Ve=a}},ae=function(e,t,a){switch(t){case"input":if(Le(e,a),t=a.name,a.type==="radio"&&t!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<a.length;t++){var l=a[t];if(l!==e&&l.form===e.form){var u=wa(l);if(!u)throw Error(i(90));_e(l),Le(l,u)}}}break;case"textarea":Fe(e,a);break;case"select":t=a.value,t!=null&&et(e,!!a.multiple,t,!1)}},Dt=el,Xn=fr;var ng={usingClientEntryPoint:!1,Events:[js,Ar,wa,ze,Je,el]},$s={findFiberByHostInstance:sr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},rg={bundleType:$s.bundleType,version:$s.version,rendererPackageName:$s.rendererPackageName,rendererConfig:$s.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:P.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=gc(e),e===null?null:e.stateNode},findFiberByHostInstance:$s.findFiberByHostInstance||eg,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var si=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!si.isDisabled&&si.supportsFiber)try{ta=si.inject(rg),mn=si}catch{}}return Mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ng,Mt.createPortal=function(e,t){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!cl(t))throw Error(i(200));return Zp(e,t,null,a)},Mt.createRoot=function(e,t){if(!cl(e))throw Error(i(299));var a=!1,l="",u=Wd;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(l=t.identifierPrefix),t.onRecoverableError!==void 0&&(u=t.onRecoverableError)),t=il(e,1,!1,null,null,a,!1,l,u),e[jn]=t.current,vs(e.nodeType===8?e.parentNode:e),new ll(t)},Mt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(i(188)):(e=Object.keys(e).join(","),Error(i(268,e)));return e=gc(t),e=e===null?null:e.stateNode,e},Mt.flushSync=function(e){return fr(e)},Mt.hydrate=function(e,t,a){if(!ni(t))throw Error(i(200));return ri(null,e,t,!0,a)},Mt.hydrateRoot=function(e,t,a){if(!cl(e))throw Error(i(405));var l=a!=null&&a.hydratedSources||null,u=!1,m="",x=Wd;if(a!=null&&(a.unstable_strictMode===!0&&(u=!0),a.identifierPrefix!==void 0&&(m=a.identifierPrefix),a.onRecoverableError!==void 0&&(x=a.onRecoverableError)),t=Dd(t,null,e,1,a??null,u,!1,m,x),e[jn]=t.current,vs(e),l)for(e=0;e<l.length;e++)a=l[e],u=a._getVersion,u=u(a._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[a,u]:t.mutableSourceEagerHydrationData.push(a,u);return new ti(t)},Mt.render=function(e,t,a){if(!ni(t))throw Error(i(200));return ri(null,e,t,!1,a)},Mt.unmountComponentAtNode=function(e){if(!ni(e))throw Error(i(40));return e._reactRootContainer?(fr(function(){ri(null,null,e,!1,function(){e._reactRootContainer=null,e[jn]=null})}),!0):!1},Mt.unstable_batchedUpdates=el,Mt.unstable_renderSubtreeIntoContainer=function(e,t,a,l){if(!ni(a))throw Error(i(200));if(e==null||e._reactInternals===void 0)throw Error(i(38));return ri(e,t,a,!1,l)},Mt.version="18.3.1-next-f1338f8080-20240426",Mt}var Xd;function qf(){if(Xd)return fl.exports;Xd=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(s){console.error(s)}}return n(),fl.exports=fg(),fl.exports}var Zd;function mg(){if(Zd)return ai;Zd=1;var n=qf();return ai.createRoot=n.createRoot,ai.hydrateRoot=n.hydrateRoot,ai}var hg=mg();/**
41
- * react-router v7.18.4
42
- *
43
- * Copyright (c) Remix Software Inc.
44
- *
45
- * This source code is licensed under the MIT license found in the
46
- * LICENSE.md file in the root directory of this source tree.
47
- *
48
- * @license MIT
49
- */var Dl=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Qf=/^[\\/]{2}/;function pg(n,s){return s+n.replace(/\\/g,"/")}var ef="popstate";function tf(n){return typeof n=="object"&&n!=null&&"pathname"in n&&"search"in n&&"hash"in n&&"state"in n&&"key"in n}function gg(n={}){function s(o,c){var y;let d=(y=c.state)==null?void 0:y.masked,{pathname:h,search:g,hash:p}=d||o.location;return Cl("",{pathname:h,search:g,hash:p},c.state&&c.state.usr||null,c.state&&c.state.key||"default",d?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function i(o,c){return typeof c=="string"?c:jr(c)}return vg(s,i,null,n)}function rt(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function en(n,s){if(!n){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function yg(){return Math.random().toString(36).substring(2,10)}function nf(n,s){return{usr:n.state,key:n.key,idx:s,masked:n.mask?{pathname:n.pathname,search:n.search,hash:n.hash}:void 0}}function Cl(n,s,i=null,o,c){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof s=="string"?Qr(s):s,state:i,key:s&&s.key||o||yg(),mask:c}}function jr({pathname:n="/",search:s="",hash:i=""}){return s&&s!=="?"&&(n+=s.charAt(0)==="?"?s:"?"+s),i&&i!=="#"&&(n+=i.charAt(0)==="#"?i:"#"+i),n}function Qr(n){let s={};if(n){let i=n.indexOf("#");i>=0&&(s.hash=n.substring(i),n=n.substring(0,i));let o=n.indexOf("?");o>=0&&(s.search=n.substring(o),n=n.substring(0,o)),n&&(s.pathname=n)}return s}function vg(n,s,i,o={}){let{window:c=document.defaultView,v5Compat:d=!1}=o,h=c.history,g="POP",p=null,y=v();y==null&&(y=0,h.replaceState({...h.state,idx:y},""));function v(){return(h.state||{idx:null}).idx}function j(){g="POP";let C=v(),T=C==null?null:C-y;y=C,p&&p({action:g,location:k.location,delta:T})}function w(C,T){g="PUSH";let I=tf(C)?C:Cl(k.location,C,T);y=v()+1;let $=nf(I,y),P=k.createHref(I.mask||I);try{h.pushState($,"",P)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;c.location.assign(P)}d&&p&&p({action:g,location:k.location,delta:1})}function N(C,T){g="REPLACE";let I=tf(C)?C:Cl(k.location,C,T);y=v();let $=nf(I,y),P=k.createHref(I.mask||I);h.replaceState($,"",P),d&&p&&p({action:g,location:k.location,delta:0})}function E(C){return xg(c,C)}let k={get action(){return g},get location(){return n(c,h)},listen(C){if(p)throw new Error("A history only accepts one active listener");return c.addEventListener(ef,j),p=C,()=>{c.removeEventListener(ef,j),p=null}},createHref(C){return s(c,C)},createURL:E,encodeLocation(C){let T=E(C);return{pathname:T.pathname,search:T.search,hash:T.hash}},push:w,replace:N,go(C){return h.go(C)}};return k}function xg(n,s,i=!1){let o="http://localhost";n&&(o=n.location.origin!=="null"?n.location.origin:n.location.href),rt(o,"No window.location.(origin|href) available to create URL");let c=typeof s=="string"?s:jr(s);return c=c.replace(/ $/,"%20"),!i&&Qf.test(c)&&(c=o+c),new URL(c,o)}function Xf(n,s,i="/"){return wg(n,s,i,!1)}function wg(n,s,i,o,c){let d=typeof s=="string"?Qr(s):s,h=An(d.pathname||"/",i);if(h==null)return null;let g=jg(n),p=null,y=Pg(h);for(let v=0;p==null&&v<g.length;++v)p=Ag(g[v],y,o);return p}function jg(n){let s=Zf(n);return Sg(s),s}function Zf(n,s=[],i=[],o="",c=!1){let d=(h,g,p=c,y)=>{let v={relativePath:y===void 0?h.path||"":y,caseSensitive:h.caseSensitive===!0,childrenIndex:g,route:h};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(o)&&p)return;rt(v.relativePath.startsWith(o),`Absolute route path "${v.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(o.length)}let j=cn([o,v.relativePath]),w=i.concat(v);h.children&&h.children.length>0&&(rt(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${j}".`),Zf(h.children,s,w,j,p)),!(h.path==null&&!h.index)&&s.push({path:j,score:Rg(j,h.index),routesMeta:w.map((N,E)=>{let[k,C]=nm(N.relativePath,N.caseSensitive,E===w.length-1);return{...N,matcher:k,compiledParams:C}})})};return n.forEach((h,g)=>{var p;if(h.path===""||!((p=h.path)!=null&&p.includes("?")))d(h,g);else for(let y of em(h.path))d(h,g,!0,y)}),s}function em(n){let s=n.split("/");if(s.length===0)return[];let[i,...o]=s,c=i.endsWith("?"),d=i.replace(/\?$/,"");if(o.length===0)return c?[d,""]:[d];let h=em(o.join("/")),g=[];return g.push(...h.map(p=>p===""?d:[d,p].join("/"))),c&&g.push(...h),g.map(p=>n.startsWith("/")&&p===""?"/":p)}function Sg(n){n.sort((s,i)=>s.score!==i.score?i.score-s.score:Ig(s.routesMeta.map(o=>o.childrenIndex),i.routesMeta.map(o=>o.childrenIndex)))}var kg=/^:[\w-]+$/,bg=3,Ng=2,Cg=1,Eg=10,Tg=-2,rf=n=>n==="*";function Rg(n,s){let i=n.split("/"),o=i.length;return i.some(rf)&&(o+=Tg),s&&(o+=Ng),i.filter(c=>!rf(c)).reduce((c,d)=>c+(kg.test(d)?bg:d===""?Cg:Eg),o)}function Ig(n,s){return n.length===s.length&&n.slice(0,-1).every((o,c)=>o===s[c])?n[n.length-1]-s[s.length-1]:0}function Ag(n,s,i=!1){let{routesMeta:o}=n,c={},d="/",h=[];for(let g=0;g<o.length;++g){let p=o[g],y=g===o.length-1,v=d==="/"?s:s.slice(d.length)||"/",j={path:p.relativePath,caseSensitive:p.caseSensitive,end:y},w=p.matcher&&p.compiledParams?tm(j,v,p.matcher,p.compiledParams):vi(j,v),N=p.route;if(!w&&y&&i&&!o[o.length-1].route.index&&(w=vi({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},v)),!w)return null;Object.assign(c,w.params),h.push({params:c,pathname:cn([d,w.pathname]),pathnameBase:$g(cn([d,w.pathnameBase])),route:N}),w.pathnameBase!=="/"&&(d=cn([d,w.pathnameBase]))}return h}function vi(n,s){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[i,o]=nm(n.path,n.caseSensitive,n.end);return tm(n,s,i,o)}function tm(n,s,i,o){let c=s.match(i);if(!c)return null;let d=c[0],h=Jr(d,1),g=c.slice(1);return{params:o.reduce((y,{paramName:v,isOptional:j},w)=>{if(v==="*"){let E=g[w]||"";h=Jr(d.slice(0,d.length-E.length),1)}const N=g[w];return j&&!N?y[v]=void 0:y[v]=(N||"").replace(/%2F/g,"/"),y},{}),pathname:d,pathnameBase:h,pattern:n}}function nm(n,s=!1,i=!0){en(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let o=[],c="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(h,g,p,y,v)=>{if(o.push({paramName:g,isOptional:p!=null}),p){let j=v.charAt(y+h.length);return j&&j!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(o.push({paramName:"*"}),c+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?c+="\\/*$":n!==""&&n!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,s?void 0:"i"),o]}function Pg(n){try{return n.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return en(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),n}}function An(n,s){if(s==="/")return n;if(!n.toLowerCase().startsWith(s.toLowerCase()))return null;let i=s.endsWith("/")?s.length-1:s.length,o=n.charAt(i);return o&&o!=="/"?null:n.slice(i)||"/"}function _g(n,s="/"){let{pathname:i,search:o="",hash:c=""}=typeof n=="string"?Qr(n):n,d;return i?(i=rm(i),i.startsWith("/")||i.startsWith("\\")?d=sf(i.substring(1),"/"):d=sf(i,s)):d=s,{pathname:d,search:zg(o),hash:Fg(c)}}function sf(n,s){let i=Jr(s).split("/");return n.split("/").forEach(c=>{c===".."?i.length>1&&i.pop():c!=="."&&i.push(c)}),i.length>1?i.join("/"):"/"}function pl(n,s,i,o){return`Cannot include a '${n}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${i}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Lg(n){return n.filter((s,i)=>i===0||s.route.path&&s.route.path.length>0)}function Ul(n){let s=Lg(n);return s.map((i,o)=>o===s.length-1?i.pathname:i.pathnameBase)}function bi(n,s,i,o=!1){let c;typeof n=="string"?c=Qr(n):(c={...n},rt(!c.pathname||!c.pathname.includes("?"),pl("?","pathname","search",c)),rt(!c.pathname||!c.pathname.includes("#"),pl("#","pathname","hash",c)),rt(!c.search||!c.search.includes("#"),pl("#","search","hash",c)));let d=n===""||c.pathname==="",h=d?"/":c.pathname,g;if(h==null)g=i;else{let j=s.length-1;if(!o&&h.startsWith("..")){let w=h.split("/");for(;w[0]==="..";)w.shift(),j-=1;c.pathname=w.join("/")}g=j>=0?s[j]:"/"}let p=_g(c,g),y=h&&h!=="/"&&h.endsWith("/"),v=(d||h===".")&&i.endsWith("/");return!p.pathname.endsWith("/")&&(y||v)&&(p.pathname+="/"),p}var rm=n=>n.replace(/[\\/]{2,}/g,"/"),cn=n=>rm(n.join("/"));function Jr(n,s=0){let i=n.length;for(;i>s&&n.charCodeAt(i-1)===47;)i--;return i===n.length?n:n.slice(0,i)}var $g=n=>Jr(n).replace(/^\/*/,"/"),zg=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,Fg=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n,Og=class{constructor(n,s,i,o=!1){this.status=n,this.statusText=s||"",this.internal=o,i instanceof Error?(this.data=i.toString(),this.error=i):this.data=i}};function Mg(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}function Bg(n){let s=n.map(i=>i.route.path).filter(Boolean);return cn(s)||"/"}var sm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function am(n,s){let i=n;if(typeof i!="string"||!Dl.test(i))return{absoluteURL:void 0,isExternal:!1,to:i};let o=i,c=!1;if(sm)try{let d=new URL(window.location.href),h=Qf.test(i)?new URL(pg(i,d.protocol)):new URL(i),g=An(h.pathname,s);h.origin===d.origin&&g!=null?i=g+h.search+h.hash:c=!0}catch{en(!1,`<Link to="${i}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:c,to:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var af=new URL("http://localhost");function Wl(n){if(n.createURL)return n.createURL("/");try{return new URL(n.createHref("/"),af)}catch{return af}}function gl(n,s){return n.origin===s.origin&&(n.origin!=="null"||n.protocol===s.protocol&&n.host===s.host)}function Dg(n,s){if(n.startsWith("//"))return!0;let i=s.protocol.toLowerCase();return n.toLowerCase().startsWith(i)?s.host===""||n.slice(i.length).startsWith("//"):!1}function Hl(n,s,i,o){let c=null;try{c=n==null?null:new URL(n,i)}catch{}let d=new URL(s,i),h=c!=null&&!gl(c,i),g=!gl(d,i);if(o==="reject"){if(h||g)throw new Error("External navigation is not allowed")}else if(g&&(c==null||!Dg(n,c)||!gl(c,d)))throw new Error("External navigation is not allowed")}var im=["POST","PUT","PATCH","DELETE"];new Set(im);var Ug=["GET",...im];new Set(Ug);var Wg=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Hg(n){try{return Wg.includes(new URL(n).protocol)}catch{return!1}}var Xr=f.createContext(null);Xr.displayName="DataRouter";var Ni=f.createContext(null);Ni.displayName="DataRouterState";var om=f.createContext(!1);function Vg(){return f.useContext(om)}var lm=f.createContext({isTransitioning:!1});lm.displayName="ViewTransition";var Gg=f.createContext(new Map);Gg.displayName="Fetchers";var Kg=f.createContext(null);Kg.displayName="Await";var Gt=f.createContext(null);Gt.displayName="Navigation";var Ys=f.createContext(null);Ys.displayName="Location";var un=f.createContext({outlet:null,matches:[],isDataRoute:!1});un.displayName="Route";var Vl=f.createContext(null);Vl.displayName="RouteError";var cm="REACT_ROUTER_ERROR",Yg="REDIRECT",Jg="ROUTE_ERROR_RESPONSE";function qg(n){if(n.startsWith(`${cm}:${Yg}:{`))try{let s=JSON.parse(n.slice(28));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string"&&typeof s.location=="string"&&typeof s.reloadDocument=="boolean"&&typeof s.replace=="boolean")return s}catch{}}function Qg(n){if(n.startsWith(`${cm}:${Jg}:{`))try{let s=JSON.parse(n.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new Og(s.status,s.statusText,s.data)}catch{}}function Xg(n,{relative:s}={}){rt(Zr(),"useHref() may be used only in the context of a <Router> component.");let{basename:i,navigator:o}=f.useContext(Gt),{hash:c,pathname:d,search:h}=Js(n,{relative:s}),g=d;return i!=="/"&&(g=d==="/"?i:cn([i,d])),o.createHref({pathname:g,search:h,hash:c})}function Zr(){return f.useContext(Ys)!=null}function Bt(){return rt(Zr(),"useLocation() may be used only in the context of a <Router> component."),f.useContext(Ys).location}var um="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function dm(n){f.useContext(Gt).static||f.useLayoutEffect(n)}function dn(){let{isDataRoute:n}=f.useContext(un);return n?my():Zg()}function Zg(){rt(Zr(),"useNavigate() may be used only in the context of a <Router> component.");let n=f.useContext(Xr),{basename:s,navigator:i}=f.useContext(Gt),{matches:o}=f.useContext(un),{pathname:c}=Bt(),d=JSON.stringify(Ul(o)),h=f.useRef(!1);return dm(()=>{h.current=!0}),f.useCallback((p,y={})=>{if(en(h.current,um),!h.current)return;if(typeof p=="number"){i.go(p);return}let v=bi(p,JSON.parse(d),c,y.relative==="path");n==null&&s!=="/"&&(v.pathname=v.pathname==="/"?s:cn([s,v.pathname])),Hl(typeof p=="string"?p:jr(p),i.createHref(v),Wl(i),"reject"),(y.replace?i.replace:i.push)(v,y.state,y)},[s,i,d,c,n])}var ey=f.createContext(null);function ty(n){let s=f.useContext(un).outlet;return f.useMemo(()=>s&&f.createElement(ey.Provider,{value:n},s),[s,n])}function Js(n,{relative:s}={}){let{matches:i}=f.useContext(un),{pathname:o}=Bt(),c=JSON.stringify(Ul(i));return f.useMemo(()=>bi(n,JSON.parse(c),o,s==="path"),[n,c,o,s])}function ny(n,s){return fm(n,s)}function fm(n,s,i){var C;rt(Zr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=f.useContext(Gt),{matches:c}=f.useContext(un),d=c[c.length-1],h=d?d.params:{},g=d?d.pathname:"/",p=d?d.pathnameBase:"/",y=d&&d.route;{let T=y&&y.path||"";hm(g,!y||T.endsWith("*")||T.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${T}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
50
-
51
- Please change the parent <Route path="${T}"> to <Route path="${T==="/"?"*":`${T}/*`}">.`)}let v=Bt(),j;if(s){let T=typeof s=="string"?Qr(s):s;rt(p==="/"||((C=T.pathname)==null?void 0:C.startsWith(p)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${p}" but pathname "${T.pathname}" was given in the \`location\` prop.`),j=T}else j=v;let w=j.pathname||"/",N=w;if(p!=="/"){let T=p.replace(/^\//,"").split("/");N="/"+w.replace(/^\//,"").split("/").slice(T.length).join("/")}let E=i&&i.state.matches.length?i.state.matches.map(T=>Object.assign(T,{route:i.manifest[T.route.id]||T.route})):Xf(n,{pathname:N});en(y||E!=null,`No routes matched location "${j.pathname}${j.search}${j.hash}" `),en(E==null||E[E.length-1].route.element!==void 0||E[E.length-1].route.Component!==void 0||E[E.length-1].route.lazy!==void 0,`Matched leaf route at location "${j.pathname}${j.search}${j.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let k=oy(E&&E.map(T=>Object.assign({},T,{params:Object.assign({},h,T.params),pathname:cn([p,o.encodeLocation?o.encodeLocation(T.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathname]),pathnameBase:T.pathnameBase==="/"?p:cn([p,o.encodeLocation?o.encodeLocation(T.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathnameBase])})),c,i);return s&&k?f.createElement(Ys.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...j},navigationType:"POP"}},k):k}function ry(){let n=fy(),s=Mg(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),i=n instanceof Error?n.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},d={padding:"2px 4px",backgroundColor:o},h=null;return console.error("Error handled by React Router default ErrorBoundary:",n),h=f.createElement(f.Fragment,null,f.createElement("p",null,"💿 Hey developer 👋"),f.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",f.createElement("code",{style:d},"ErrorBoundary")," or"," ",f.createElement("code",{style:d},"errorElement")," prop on your route.")),f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},s),i?f.createElement("pre",{style:c},i):null,h)}var sy=f.createElement(ry,null),mm=class extends f.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,s){return s.location!==n.location||s.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:s.error,location:s.location,revalidation:n.revalidation||s.revalidation}}componentDidCatch(n,s){this.props.onError?this.props.onError(n,s):console.error("React Router caught the following error during render",n)}render(){let n=this.state.error;if(this.context&&typeof n=="object"&&n&&"digest"in n&&typeof n.digest=="string"){const i=Qg(n.digest);i&&(n=i)}let s=n!==void 0?f.createElement(un.Provider,{value:this.props.routeContext},f.createElement(Vl.Provider,{value:n,children:this.props.component})):this.props.children;return this.context?f.createElement(ay,{error:n},s):s}};mm.contextType=om;var yl=new WeakMap;function ay({children:n,error:s}){let{basename:i,navigator:o}=f.useContext(Gt);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let c=qg(s.digest);if(c){let d=yl.get(s);if(d)throw d;let h=am(c.location,i),g=h.absoluteURL||h.to;if(Hl(c.location,g,Wl(o),"allow-explicit"),Hg(g))throw new Error("Invalid redirect location");if(sm&&!yl.get(s))if(h.isExternal||c.reloadDocument)window.location.href=g;else{const p=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(h.to,{replace:c.replace}));throw yl.set(s,p),p}return f.createElement("meta",{httpEquiv:"refresh",content:`0;url=${g}`})}}return n}function iy({routeContext:n,match:s,children:i}){let o=f.useContext(Xr);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),f.createElement(un.Provider,{value:n},i)}function oy(n,s=[],i){let o=i==null?void 0:i.state;if(n==null){if(!o)return null;if(o.errors)n=o.matches;else if(s.length===0&&!o.initialized&&o.matches.length>0)n=o.matches;else return null}let c=n,d=o==null?void 0:o.errors;if(d!=null){let v=c.findIndex(j=>j.route.id&&(d==null?void 0:d[j.route.id])!==void 0);rt(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(d).join(",")}`),c=c.slice(0,Math.min(c.length,v+1))}let h=!1,g=-1;if(i&&o){h=o.renderFallback;for(let v=0;v<c.length;v++){let j=c[v];if((j.route.HydrateFallback||j.route.hydrateFallbackElement)&&(g=v),j.route.id){let{loaderData:w,errors:N}=o,E=j.route.loader&&!w.hasOwnProperty(j.route.id)&&(!N||N[j.route.id]===void 0);if(j.route.lazy||E){i.isStatic&&(h=!0),g>=0?c=c.slice(0,g+1):c=[c[0]];break}}}}let p=i==null?void 0:i.onError,y=o&&p?(v,j)=>{var w,N;p(v,{location:o.location,params:((N=(w=o.matches)==null?void 0:w[0])==null?void 0:N.params)??{},pattern:Bg(o.matches),errorInfo:j})}:void 0;return c.reduceRight((v,j,w)=>{let N,E=!1,k=null,C=null;o&&(N=d&&j.route.id?d[j.route.id]:void 0,k=j.route.errorElement||sy,h&&(g<0&&w===0?(hm("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),E=!0,C=null):g===w&&(E=!0,C=j.route.hydrateFallbackElement||null)));let T=s.concat(c.slice(0,w+1)),I=()=>{let $;return N?$=k:E?$=C:j.route.Component?$=f.createElement(j.route.Component,null):j.route.element?$=j.route.element:$=v,f.createElement(iy,{match:j,routeContext:{outlet:v,matches:T,isDataRoute:o!=null},children:$})};return o&&(j.route.ErrorBoundary||j.route.errorElement||w===0)?f.createElement(mm,{location:o.location,revalidation:o.revalidation,component:k,error:N,children:I(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:y}):I()},null)}function Gl(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ly(n){let s=f.useContext(Xr);return rt(s,Gl(n)),s}function cy(n){let s=f.useContext(Ni);return rt(s,Gl(n)),s}function uy(n){let s=f.useContext(un);return rt(s,Gl(n)),s}function Kl(n){let s=uy(n),i=s.matches[s.matches.length-1];return rt(i.route.id,`${n} can only be used on routes that contain a unique "id"`),i.route.id}function dy(){return Kl("useRouteId")}function fy(){var o;let n=f.useContext(Vl),s=cy("useRouteError"),i=Kl("useRouteError");return n!==void 0?n:(o=s.errors)==null?void 0:o[i]}function my(){let{router:n}=ly("useNavigate"),s=Kl("useNavigate"),i=f.useRef(!1);return dm(()=>{i.current=!0}),f.useCallback(async(c,d={})=>{en(i.current,um),i.current&&(typeof c=="number"?await n.navigate(c):await n.navigate(c,{fromRouteId:s,...d}))},[n,s])}var of={};function hm(n,s,i){!s&&!of[n]&&(of[n]=!0,en(!1,i))}f.memo(hy);function hy({routes:n,manifest:s,future:i,state:o,isStatic:c,onError:d}){return fm(n,void 0,{manifest:s,state:o,isStatic:c,onError:d})}function In({to:n,replace:s,state:i,relative:o}){rt(Zr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:c,navigator:d}=f.useContext(Gt);en(!c,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:h}=f.useContext(un),{pathname:g}=Bt(),p=dn(),y=bi(n,Ul(h),g,o==="path");Hl(typeof n=="string"?n:jr(n),d.createHref(y),Wl(d),"reject");let v=JSON.stringify(y);return f.useEffect(()=>{p(JSON.parse(v),{replace:s,state:i,relative:o})},[p,v,o,s,i]),null}function py(n){return ty(n.context)}function Qe(n){rt(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function gy({basename:n="/",children:s=null,location:i,navigationType:o="POP",navigator:c,static:d=!1,useTransitions:h}){rt(!Zr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let g=n.replace(/^\/*/,"/"),p=f.useMemo(()=>({basename:g,navigator:c,static:d,useTransitions:h,future:{}}),[g,c,d,h]);typeof i=="string"&&(i=Qr(i));let{pathname:y="/",search:v="",hash:j="",state:w=null,key:N="default",mask:E}=i,k=f.useMemo(()=>{let C=An(y,g);return C==null?null:{location:{pathname:C,search:v,hash:j,state:w,key:N,mask:E},navigationType:o}},[g,y,v,j,w,N,o,E]);return en(k!=null,`<Router basename="${g}"> is not able to match the URL "${y}${v}${j}" because it does not start with the basename, so the <Router> won't render anything.`),k==null?null:f.createElement(Gt.Provider,{value:p},f.createElement(Ys.Provider,{children:s,value:k}))}function yy({children:n,location:s}){return ny(El(n),s)}function El(n,s=[]){let i=[];return f.Children.forEach(n,(o,c)=>{if(!f.isValidElement(o))return;let d=[...s,c];if(o.type===f.Fragment){i.push.apply(i,El(o.props.children,d));return}rt(o.type===Qe,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),rt(!o.props.index||!o.props.children,"An index route cannot have child routes.");let h={id:o.props.id||d.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(h.children=El(o.props.children,d)),i.push(h)}),i}var fi="get",mi="application/x-www-form-urlencoded";function Ci(n){return typeof HTMLElement<"u"&&n instanceof HTMLElement}function vy(n){return Ci(n)&&n.tagName.toLowerCase()==="button"}function xy(n){return Ci(n)&&n.tagName.toLowerCase()==="form"}function wy(n){return Ci(n)&&n.tagName.toLowerCase()==="input"}function jy(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function Sy(n,s){return n.button===0&&(!s||s==="_self")&&!jy(n)}function Tl(n=""){return new URLSearchParams(typeof n=="string"||Array.isArray(n)||n instanceof URLSearchParams?n:Object.keys(n).reduce((s,i)=>{let o=n[i];return s.concat(Array.isArray(o)?o.map(c=>[i,c]):[[i,o]])},[]))}function ky(n,s){let i=Tl(n);return s&&s.forEach((o,c)=>{i.has(c)||s.getAll(c).forEach(d=>{i.append(c,d)})}),i}var ii=null;function by(){if(ii===null)try{new FormData(document.createElement("form"),0),ii=!1}catch{ii=!0}return ii}var Ny=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function vl(n){return n!=null&&!Ny.has(n)?(en(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${mi}"`),null):n}function Cy(n,s){let i,o,c,d,h;if(xy(n)){let g=n.getAttribute("action");o=g?An(g,s):null,i=n.getAttribute("method")||fi,c=vl(n.getAttribute("enctype"))||mi,d=new FormData(n)}else if(vy(n)||wy(n)&&(n.type==="submit"||n.type==="image")){let g=n.form;if(g==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=n.getAttribute("formaction")||g.getAttribute("action");if(o=p?An(p,s):null,i=n.getAttribute("formmethod")||g.getAttribute("method")||fi,c=vl(n.getAttribute("formenctype"))||vl(g.getAttribute("enctype"))||mi,d=new FormData(g,n),!by()){let{name:y,type:v,value:j}=n;if(v==="image"){let w=y?`${y}.`:"";d.append(`${w}x`,"0"),d.append(`${w}y`,"0")}else y&&d.append(y,j)}}else{if(Ci(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=fi,o=null,c=mi,h=n}return d&&c==="text/plain"&&(h=d,d=void 0),{action:o,method:i.toLowerCase(),encType:c,formData:d,body:h}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Yl(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function pm(n,s,i,o){let c=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return i?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${o}`:c.pathname=`${c.pathname}.${o}`:c.pathname==="/"?c.pathname=`_root.${o}`:s&&An(c.pathname,s)==="/"?c.pathname=`${Jr(s)}/_root.${o}`:c.pathname=`${Jr(c.pathname)}.${o}`,c}async function Ey(n,s){if(n.id in s)return s[n.id];try{let i=await import(n.module);return s[n.id]=i,i}catch(i){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(i),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Ty(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function Ry(n,s,i){let o=await Promise.all(n.map(async c=>{let d=s.routes[c.route.id];if(d){let h=await Ey(d,i);return h.links?h.links():[]}return[]}));return _y(o.flat(1).filter(Ty).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function lf(n,s,i,o,c,d){let h=(p,y)=>i[y]?p.route.id!==i[y].route.id:!0,g=(p,y)=>{var v;return i[y].pathname!==p.pathname||((v=i[y].route.path)==null?void 0:v.endsWith("*"))&&i[y].params["*"]!==p.params["*"]};return d==="assets"?s.filter((p,y)=>h(p,y)||g(p,y)):d==="data"?s.filter((p,y)=>{var j;let v=o.routes[p.route.id];if(!v||!v.hasLoader)return!1;if(h(p,y)||g(p,y))return!0;if(p.route.shouldRevalidate){let w=p.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((j=i[0])==null?void 0:j.params)||{},nextUrl:new URL(n,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof w=="boolean")return w}return!0}):[]}function Iy(n,s,{includeHydrateFallback:i}={}){return Ay(n.map(o=>{let c=s.routes[o.route.id];if(!c)return[];let d=[c.module];return c.clientActionModule&&(d=d.concat(c.clientActionModule)),c.clientLoaderModule&&(d=d.concat(c.clientLoaderModule)),i&&c.hydrateFallbackModule&&(d=d.concat(c.hydrateFallbackModule)),c.imports&&(d=d.concat(c.imports)),d}).flat(1))}function Ay(n){return[...new Set(n)]}function Py(n){let s={},i=Object.keys(n).sort();for(let o of i)s[o]=n[o];return s}function _y(n,s){let i=new Set;return new Set(s),n.reduce((o,c)=>{let d=JSON.stringify(Py(c));return i.has(d)||(i.add(d),o.push({key:d,link:c})),o},[])}function Jl(){let n=f.useContext(Xr);return Yl(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function Ly(){let n=f.useContext(Ni);return Yl(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var ql=f.createContext(void 0);ql.displayName="FrameworkContext";function Ei(){let n=f.useContext(ql);return Yl(n,"You must render this element inside a <HydratedRouter> element"),n}function $y(n,s){let i=f.useContext(ql),[o,c]=f.useState(!1),[d,h]=f.useState(!1),{onFocus:g,onBlur:p,onMouseEnter:y,onMouseLeave:v,onTouchStart:j}=s,w=f.useRef(null);f.useEffect(()=>{if(n==="render"&&h(!0),n==="viewport"){let k=T=>{T.forEach(I=>{h(I.isIntersecting)})},C=new IntersectionObserver(k,{threshold:.5});return w.current&&C.observe(w.current),()=>{C.disconnect()}}},[n]),f.useEffect(()=>{if(o){let k=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(k)}}},[o]);let N=()=>{c(!0)},E=()=>{c(!1),h(!1)};return i?n!=="intent"?[d,w,{}]:[d,w,{onFocus:Os(g,N),onBlur:Os(p,E),onMouseEnter:Os(y,N),onMouseLeave:Os(v,E),onTouchStart:Os(j,N)}]:[!1,w,{}]}function Os(n,s){return i=>{n&&n(i),i.defaultPrevented||s(i)}}function zy({page:n,...s}){let i=Vg(),{nonce:o}=Ei(),{router:c}=Jl(),d=f.useMemo(()=>Xf(c.routes,n,c.basename),[c.routes,n,c.basename]);return d?(s.nonce==null&&o&&(s={...s,nonce:o}),i?f.createElement(Oy,{page:n,matches:d,...s}):f.createElement(My,{page:n,matches:d,...s})):null}function Fy(n){let{manifest:s,routeModules:i}=Ei(),[o,c]=f.useState([]);return f.useEffect(()=>{let d=!1;return Ry(n,s,i).then(h=>{d||c(h)}),()=>{d=!0}},[n,s,i]),o}function Oy({page:n,matches:s,...i}){let o=Bt(),{future:c}=Ei(),{basename:d}=Jl(),h=f.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let g=pm(n,d,c.v8_trailingSlashAwareDataRequests,"rsc"),p=!1,y=[];for(let v of s)typeof v.route.shouldRevalidate=="function"?p=!0:y.push(v.route.id);return p&&y.length>0&&g.searchParams.set("_routes",y.join(",")),[g.pathname+g.search]},[d,c.v8_trailingSlashAwareDataRequests,n,o,s]);return f.createElement(f.Fragment,null,h.map(g=>f.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...i})))}function My({page:n,matches:s,...i}){let o=Bt(),{future:c,manifest:d,routeModules:h}=Ei(),{basename:g}=Jl(),{loaderData:p,matches:y}=Ly(),v=f.useMemo(()=>lf(n,s,y,d,o,"data"),[n,s,y,d,o]),j=f.useMemo(()=>lf(n,s,y,d,o,"assets"),[n,s,y,d,o]),w=f.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let k=new Set,C=!1;if(s.forEach(I=>{var P;let $=d.routes[I.route.id];!$||!$.hasLoader||(!v.some(D=>D.route.id===I.route.id)&&I.route.id in p&&((P=h[I.route.id])!=null&&P.shouldRevalidate)||$.hasClientLoader?C=!0:k.add(I.route.id))}),k.size===0)return[];let T=pm(n,g,c.v8_trailingSlashAwareDataRequests,"data");return C&&k.size>0&&T.searchParams.set("_routes",s.filter(I=>k.has(I.route.id)).map(I=>I.route.id).join(",")),[T.pathname+T.search]},[g,c.v8_trailingSlashAwareDataRequests,p,o,d,v,s,n,h]),N=f.useMemo(()=>Iy(j,d),[j,d]),E=Fy(j);return f.createElement(f.Fragment,null,w.map(k=>f.createElement("link",{key:k,rel:"prefetch",as:"fetch",href:k,...i})),N.map(k=>f.createElement("link",{key:k,rel:"modulepreload",href:k,...i})),E.map(({key:k,link:C})=>f.createElement("link",{key:k,nonce:i.nonce,...C,crossOrigin:C.crossOrigin??i.crossOrigin})))}function By(...n){return s=>{n.forEach(i=>{typeof i=="function"?i(s):i!=null&&(i.current=s)})}}var Dy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Dy&&(window.__reactRouterVersion="7.18.4")}catch{}function Uy({basename:n,children:s,useTransitions:i,window:o}){let c=f.useRef();c.current==null&&(c.current=gg({window:o,v5Compat:!0}));let d=c.current,[h,g]=f.useState({action:d.action,location:d.location}),p=f.useCallback(y=>{i===!1?g(y):f.startTransition(()=>g(y))},[i]);return f.useLayoutEffect(()=>d.listen(p),[d,p]),f.createElement(gy,{basename:n,children:s,location:h.location,navigationType:h.action,navigator:d,useTransitions:i})}var yt=f.forwardRef(function({onClick:s,discover:i="render",prefetch:o="none",relative:c,reloadDocument:d,replace:h,mask:g,state:p,target:y,to:v,preventScrollReset:j,viewTransition:w,defaultShouldRevalidate:N,...E},k){let{basename:C,navigator:T,useTransitions:I}=f.useContext(Gt),$=typeof v=="string"&&Dl.test(v),P=am(v,C);v=P.to;let D=Xg(v,{relative:c}),K=Bt(),V=null;if(g){let Z=bi(g,[],K.mask?K.mask.pathname:"/",!0);C!=="/"&&(Z.pathname=Z.pathname==="/"?C:cn([C,Z.pathname])),V=T.createHref(Z)}let[ce,Y,re]=$y(o,E),J=Vy(v,{replace:h,mask:g,state:p,target:y,preventScrollReset:j,relative:c,viewTransition:w,defaultShouldRevalidate:N,useTransitions:I});function O(Z){s&&s(Z),Z.defaultPrevented||J(Z)}let fe=!(P.isExternal||d),ie=f.createElement("a",{...E,...re,href:(fe?V:void 0)||P.absoluteURL||D,onClick:fe?O:s,ref:By(k,Y),target:y,"data-discover":!$&&i==="render"?"true":void 0});return ce&&!$?f.createElement(f.Fragment,null,ie,f.createElement(zy,{page:D})):ie});yt.displayName="Link";var Ql=f.forwardRef(function({"aria-current":s="page",caseSensitive:i=!1,className:o="",end:c=!1,style:d,to:h,viewTransition:g,children:p,...y},v){let j=Js(h,{relative:y.relative}),w=Bt(),N=f.useContext(Ni),{navigator:E,basename:k}=f.useContext(Gt),C=N!=null&&qy(j)&&g===!0,T=E.encodeLocation?E.encodeLocation(j).pathname:j.pathname,I=w.pathname,$=N&&N.navigation&&N.navigation.location?N.navigation.location.pathname:null;i||(I=I.toLowerCase(),$=$?$.toLowerCase():null,T=T.toLowerCase()),$&&k&&($=An($,k)||$);const P=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let D=I===T||!c&&I.startsWith(T)&&I.charAt(P)==="/",K=$!=null&&($===T||!c&&$.startsWith(T)&&$.charAt(T.length)==="/"),V={isActive:D,isPending:K,isTransitioning:C},ce=D?s:void 0,Y;typeof o=="function"?Y=o(V):Y=[o,D?"active":null,K?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let re=typeof d=="function"?d(V):d;return f.createElement(yt,{...y,"aria-current":ce,className:Y,ref:v,style:re,to:h,viewTransition:g},typeof p=="function"?p(V):p)});Ql.displayName="NavLink";var Wy=f.forwardRef(({discover:n="render",fetcherKey:s,navigate:i,reloadDocument:o,replace:c,state:d,method:h=fi,action:g,onSubmit:p,relative:y,preventScrollReset:v,viewTransition:j,defaultShouldRevalidate:w,...N},E)=>{let{useTransitions:k}=f.useContext(Gt),C=Yy(),T=Jy(g,{relative:y}),I=h.toLowerCase()==="get"?"get":"post",$=typeof g=="string"&&Dl.test(g),P=D=>{if(p&&p(D),D.defaultPrevented)return;D.preventDefault();let K=D.nativeEvent.submitter,V=(K==null?void 0:K.getAttribute("formmethod"))||h,ce=()=>C(K||D.currentTarget,{fetcherKey:s,method:V,navigate:i,replace:c,state:d,relative:y,preventScrollReset:v,viewTransition:j,defaultShouldRevalidate:w});k&&i!==!1?f.startTransition(()=>ce()):ce()};return f.createElement("form",{ref:E,method:I,action:T,onSubmit:o?p:P,...N,"data-discover":!$&&n==="render"?"true":void 0})});Wy.displayName="Form";function Hy(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function gm(n){let s=f.useContext(Xr);return rt(s,Hy(n)),s}function Vy(n,{target:s,replace:i,mask:o,state:c,preventScrollReset:d,relative:h,viewTransition:g,defaultShouldRevalidate:p,useTransitions:y}={}){let v=dn(),j=Bt(),w=Js(n,{relative:h});return f.useCallback(N=>{if(Sy(N,s)){N.preventDefault();let E=i!==void 0?i:jr(j)===jr(w),k=()=>v(n,{replace:E,mask:o,state:c,preventScrollReset:d,relative:h,viewTransition:g,defaultShouldRevalidate:p});y?f.startTransition(()=>k()):k()}},[j,v,w,i,o,c,s,n,d,h,g,p,y])}function Xl(n){en(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let s=f.useRef(Tl(n)),i=f.useRef(!1),o=Bt(),c=f.useMemo(()=>ky(o.search,i.current?null:s.current),[o.search]),d=dn(),h=f.useCallback((g,p)=>{const y=Tl(typeof g=="function"?g(new URLSearchParams(c)):g);i.current=!0,d("?"+y,p)},[d,c]);return[c,h]}var Gy=0,Ky=()=>`__${String(++Gy)}__`;function Yy(){let{router:n}=gm("useSubmit"),{basename:s}=f.useContext(Gt),i=dy(),o=n.fetch,c=n.navigate;return f.useCallback(async(d,h={})=>{let{action:g,method:p,encType:y,formData:v,body:j}=Cy(d,s);if(h.navigate===!1){let w=h.fetcherKey||Ky();await o(w,i,h.action||g,{defaultShouldRevalidate:h.defaultShouldRevalidate,preventScrollReset:h.preventScrollReset,formData:v,body:j,formMethod:h.method||p,formEncType:h.encType||y,flushSync:h.flushSync})}else await c(h.action||g,{defaultShouldRevalidate:h.defaultShouldRevalidate,preventScrollReset:h.preventScrollReset,formData:v,body:j,formMethod:h.method||p,formEncType:h.encType||y,replace:h.replace,state:h.state,fromRouteId:i,flushSync:h.flushSync,viewTransition:h.viewTransition})},[o,c,s,i])}function Jy(n,{relative:s}={}){let{basename:i}=f.useContext(Gt),o=f.useContext(un);rt(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),d={...Js(n||".",{relative:s})},h=Bt();if(n==null){d.search=h.search;let g=new URLSearchParams(d.search),p=g.getAll("index");if(p.some(v=>v==="")){g.delete("index"),p.filter(j=>j).forEach(j=>g.append("index",j));let v=g.toString();d.search=v?`?${v}`:""}}return(!n||n===".")&&c.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(d.pathname=d.pathname==="/"?i:cn([i,d.pathname])),jr(d)}function qy(n,{relative:s}={}){let i=f.useContext(lm);rt(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=gm("useViewTransitionState"),c=Js(n,{relative:s});if(!i.isTransitioning)return!1;let d=An(i.currentLocation.pathname,o)||i.currentLocation.pathname,h=An(i.nextLocation.pathname,o)||i.nextLocation.pathname;return vi(c.pathname,h)!=null||vi(c.pathname,d)!=null}var Qy=qf();const xr="owner";function Xy(n){const s=n||xr;return s===xr?[xr]:[s,xr]}function Zy(n){const s=new Map;for(const i of n)for(const o of i)s.has(o.id)||s.set(o.id,o);return[...s.values()].sort((i,o)=>o.createdAt-i.createdAt)}function ev(n,s){const i=s||xr,o=(n==null?void 0:n.pendingDomains)??[];return o.includes(i)?i:o.includes(xr)?xr:i}class ym extends Error{constructor(i){super("different_account");zs(this,"summary");this.name="DifferentAccountError",this.summary=i}}function De(n,s){const i=n??{},o=Array.isArray(i.errors)?i.errors[0]:void 0;return o!=null&&o.message?o.code?`${o.message} (${o.code})`:o.message:o!=null&&o.code?o.code:i.error||i.detail||s}function tv(n){const s=n==null?void 0:n.pubkeys;return!s||typeof s!="object"||Array.isArray(s)?[]:Object.entries(s).filter(i=>typeof i[1]=="string"&&i[1].length>0).map(([i,o])=>({userId:i,publicKey:o}))}class nv{constructor(){zs(this,"apiKey",null)}setApiKey(s){this.apiKey=s}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(s,i){return globalThis.fetch(s,{...i,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...i==null?void 0:i.headers}})}async login(s,i={}){const o=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":s,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:i.confirmWipe===!0})});if(o.status===409){const d=await o.json().catch(()=>({}));if(d!=null&&d.wouldWipe)throw new ym(d.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!o.ok){const d=await o.json().catch(()=>({error:"Invalid API key"}));throw new Error(De(d,`Login failed: ${o.status}`))}return(await o.json()).user}async logout(){await this.fetch("/auth/logout",{method:"POST"})}async getGroups(){const s=await this.fetch("/api/groups");if(!s.ok)throw new Error(`Failed to fetch groups: ${s.status}`);const i=await s.json();return i.groups??i}async listProfiles(){const s=await this.fetch("/api/profiles");if(!s.ok)throw new Error(`Failed to fetch profiles: ${s.status}`);return(await s.json()).profiles}async getProfile(s){const i=await this.fetch(`/api/profiles/${encodeURIComponent(s)}`);if(!i.ok)throw new Error(`Failed to fetch profile: ${i.status}`);return i.json()}async attest(s){const i=await this.fetch("/api/as/mandate",{method:"POST",body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({error:"Unknown error"}));throw new Error(De(o,`Signing failed: ${i.status}`))}return i.json()}async getPending(s){const i=await this.fetch(`/api/mandates/pending?domain=${encodeURIComponent(s)}`);if(!i.ok)throw new Error(`Failed to fetch pending: ${i.status}`);const o=await i.json();return o.pending??o}async getMyAttestations(s){const i=s?`?status=${encodeURIComponent(s)}`:"",o=await this.fetch(`/api/mandates/mine${i}`);if(!o.ok)throw new Error(`Failed to fetch attestations: ${o.status}`);return((await o.json()).mandates??[]).map(d=>{var h,g;return{authorization_id:d.authorization_id,profile_id:d.profileId,path:d.path,title:d.title??null,sp_status:d.status??null,frame:d.bounds??d.frame??{},required_domains:d.requiredDomains??[],attested_domains:d.attestedDomains??[],missing_domains:(d.requiredDomains??[]).filter(p=>!(d.attestedDomains??[]).includes(p)),deferred_commitment_domains:d.deferredCommitmentDomains??[],approvers_frozen:d.approversFrozen??[],above_cap:d.aboveCap??!1,created_at:d.createdAt?new Date(d.createdAt*1e3).toISOString():"",earliest_expiry:(h=d.attestations)!=null&&h.length?new Date(Math.min(...d.attestations.map(p=>p.expiresAt))*1e3).toISOString():null,remaining_seconds:(g=d.attestations)!=null&&g.length?Math.max(0,Math.min(...d.attestations.map(p=>p.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getDenials(s){const i=new URLSearchParams;s!=null&&s.since&&i.set("since",String(s.since)),s!=null&&s.limit&&i.set("limit",String(s.limit));const o=i.toString()?`?${i.toString()}`:"",c=await this.fetch(`/denials${o}`);if(!c.ok)throw new Error(`Failed to fetch denials: ${c.status}`);return c.json()}async getMyReceipts(s){const i=new URLSearchParams;s!=null&&s.date&&i.set("date",s.date),s!=null&&s.profile&&i.set("profile",s.profile),s!=null&&s.limit&&i.set("limit",String(s.limit));const o=i.toString(),c=await this.fetch(`/api/tickets/mine${o?"?"+o:""}`);if(!c.ok)throw new Error(`Failed to fetch receipts: ${c.status}`);return(await c.json()).tickets??[]}async fetchEvidenceBundle(){var c;const s=await this.fetch("/api/evidence-export"),i=await s.json();if(!s.ok)throw new Error(De(i,`Export failed (${s.status})`));const o=((c=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:c[1])??"suveren-evidence.json";return{bundle:i,filename:o}}async getLocalAuthorizations(){const s=await this.fetch("/api/evidence/authorizations");if(!s.ok)throw new Error(`Local evidence unavailable (${s.status})`);const i=await s.json();return{authorizations:i.authorizations??{},signatures:i.signatures??{}}}async getArchivedReceipt(s){const i=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(s)}`);if(i.status===404)return null;if(!i.ok)throw new Error(`Local evidence unavailable (${i.status})`);return await i.json()}async getReport(){const s=await this.fetch("/api/report");if(!s.ok){const i=await s.json().catch(()=>({error:`Report unavailable (${s.status})`}));throw new Error(De(i,`Report unavailable (${s.status})`))}return s.json()}async saveReport(s){const i=await this.fetch("/api/report",{method:"POST",body:JSON.stringify({html:s})});if(!i.ok){const o=await i.json().catch(()=>({error:`Save failed (${i.status})`}));throw new Error(De(o,`Save failed (${i.status})`))}return i.json()}async recheckReport(){const s=await this.fetch("/api/report/recheck",{method:"POST"});if(!s.ok){const i=await s.json().catch(()=>({error:`Recheck failed (${s.status})`}));throw new Error(De(i,`Recheck failed (${s.status})`))}return s.json()}async exportReportWithProof(){var c;const s=await this.fetch("/api/report/export");if(!s.ok){const d=await s.json().catch(()=>({error:`Export failed (${s.status})`}));throw new Error(De(d,`Export failed (${s.status})`))}const i=await s.text(),o=((c=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:c[1])??"suveren-report.html";return{html:i,filename:o}}async revokeAttestation(s,i){const o=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/revoke`,{method:"POST",body:JSON.stringify({reason:i??"Revoked by user"})});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed to revoke"}));throw new Error(De(c,`Revoke failed: ${o.status}`))}}async getAttestations(s){const i=await this.fetch(`/api/mandates?authorization_id=${encodeURIComponent(s)}`);if(!i.ok)throw new Error(`Failed to fetch attestations: ${i.status}`);const o=await i.json();return{...o,attestations:o.mandates??o.attestations??[]}}async getGroupById(s){const i=await this.fetch(`/api/groups/${encodeURIComponent(s)}`);if(!i.ok)throw new Error(`Failed to fetch group: ${i.status}`);return i.json()}async createGroup(s){const i=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:s})});if(!i.ok){const d=await i.json().catch(()=>({error:"Unknown error"}));throw new Error(De(d,`Create group failed: ${i.status}`))}const o=await i.json(),c=o.group||o;return{id:c.id,name:c.name,myDomains:c.myDomains||[],isAdmin:!0,ended:o.ended??{mandates:0,proposals:0}}}async getCreatePreview(){const s=await this.fetch("/api/groups/create/preview");if(!s.ok){const i=await s.json().catch(()=>({error:"Unknown error"}));throw new Error(De(i,`Failed to preview team creation: ${s.status}`))}return s.json()}async getJoinPreview(s){const i=await this.fetch(`/api/groups/join/preview?inviteCode=${encodeURIComponent(s)}`);if(!i.ok){const o=await i.json().catch(()=>({error:"Invalid or expired invite code"}));throw new Error(De(o,`Invalid invite code: ${i.status}`))}return i.json()}async requestToJoinGroup(s){const i=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:s})});if(i.status!==202){const c=await i.json().catch(()=>({error:"Unknown error"}));throw new Error(De(c,`Request to join failed: ${i.status}`))}return(await i.json()).request}async withdrawJoinRequest(){const s=await this.fetch("/api/groups/join",{method:"DELETE"});if(s.status===404)return!1;if(!s.ok){const o=await s.json().catch(()=>({error:"Unknown error"}));throw new Error(De(o,`Withdraw failed: ${s.status}`))}return(await s.json()).withdrawn===!0}async inviteToGroup(s){const i=await this.fetch(`/api/groups/${encodeURIComponent(s)}/invite`,{method:"POST"});if(!i.ok){const o=await i.json().catch(()=>({error:"Unknown error"}));throw new Error(De(o,`Invite failed: ${i.status}`))}return i.json()}async getMyTeam(){const s=await this.fetch("/api/groups/me");if(!s.ok)return{group:null,membership:null,pendingRequest:null};const i=await s.json();return{group:i.group??null,membership:i.membership??null,pendingRequest:i.pendingRequest??null}}async listUsers(){const s=await this.fetch("/api/users");return s.ok?(await s.json()).users??[]:[]}async setPubkey(s){const i=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:s})});if(!i.ok){const o=await i.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(De(o,`setPubkey failed: ${i.status}`))}}async getPubkey(s){const i=await this.fetch(`/api/users/${encodeURIComponent(s)}/pubkey`);return i.status===404||!i.ok?null:(await i.json()).pubkey??null}async leaveTeam(s){const i=await this.fetch(`/api/groups/${encodeURIComponent(s)}/leave`,{method:"POST"});if(!i.ok){const o=await i.json().catch(()=>({error:"Failed to leave team"}));throw new Error(De(o,`Leave failed: ${i.status}`))}}async getVaultStatus(){const s=await this.fetch("/vault/status");if(!s.ok)throw new Error(`Failed to fetch vault status: ${s.status}`);return s.json()}async getGatewaySettings(){const s=await this.fetch("/api/gateway-settings");if(!s.ok)throw new Error(`Failed to load settings: ${s.status}`);return s.json()}async setGatewaySettings(s){const i=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!i.ok)throw new Error(`Failed to save settings: ${i.status}`);return i.json()}async getArchivedMandates(){const s=await this.fetch("/api/archived-mandates");if(!s.ok)throw new Error(`Failed to load archived mandates: ${s.status}`);return(await s.json()).archived}async setMandateArchived(s,i){const o=await this.fetch(`/api/archived-mandates/${encodeURIComponent(s)}`,{method:i?"PUT":"DELETE"});if(!o.ok)throw new Error(`Failed to ${i?"archive":"unarchive"} mandate: ${o.status}`);return(await o.json()).archived}async getCredential(s){const i=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`);if(!i.ok)throw new Error(`Failed to check credential: ${i.status}`);return i.json()}async setCredential(s,i){const o=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`,{method:"PUT",body:JSON.stringify(i)});if(!o.ok)throw new Error(`Failed to save credential: ${o.status}`)}async testCredential(s){const i=await this.fetch(`/vault/test/${encodeURIComponent(s)}`,{method:"POST"});if(!i.ok)throw new Error(`Test failed: ${i.status}`);return i.json()}async aiAssist(s){const i=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:De(o,"AI request failed"),disclaimer:"AI surfaces reality. You supply intent."}}return i.json()}async aiIntentReview(s){const i=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:De(o,"AI request failed")}}return i.json()}async aiTest(s){const i=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(s??{})});if(!i.ok)throw new Error(`AI test failed: ${i.status}`);return i.json()}async aiModels(s){const i=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(s??{})});if(!i.ok)throw new Error(`Model list failed: ${i.status}`);return i.json()}async getMcpHealth(){const s=await this.fetch("/mcp/health");if(!s.ok)throw new Error(`MCP server unreachable: ${s.status}`);return s.json()}async getAgentContact(){const s=await this.fetch("/mcp/agent-contact");if(!s.ok)throw new Error(`Failed to fetch agent contact: ${s.status}`);return s.json()}async getMcpIntegrations(){const s=await this.fetch("/mcp/integrations");if(!s.ok)throw new Error(`Failed to fetch integrations: ${s.status}`);return s.json()}async getOAuthHealth(s){try{const i=await this.fetch(`/auth/oauth/${encodeURIComponent(s)}/health`);return i.ok?await i.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const s=await this.fetch("/mcp/integrations/manifests");if(!s.ok)throw new Error(`Failed to fetch manifests: ${s.status}`);return s.json()}async discoverScopeField(s,i){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/discover/${encodeURIComponent(i)}`);if(!o.ok){const c=await o.json().catch(()=>({error:`Discovery failed: ${o.status}`}));throw new Error(De(c,`Discovery failed: ${o.status}`))}return o.json()}async activateIntegration(s){const i=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}/activate`,{method:"POST"});if(!i.ok){const o=await i.json().catch(()=>({error:"Failed"}));throw new Error(De(o,`Failed: ${i.status}`))}return i.json()}async removeMcpIntegration(s){const i=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}`,{method:"DELETE"});if(!i.ok)throw new Error(`Failed to remove integration: ${i.status}`)}async setReadPolicy(s,i){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/read-policy`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAgeDays:i})});if(!o.ok){const c=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(De(c,`HTTP ${o.status}`))}}async getTeamProfileConfig(s,i){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(i)}`);if(o.status===404||!o.ok)return null;const c=await o.json();return(c==null?void 0:c.config)??null}async setTeamProfileConfig(s,i,o){const c=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(i)}`,{method:"PUT",body:JSON.stringify(o)});if(!c.ok){const d=await c.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(De(d,`setTeamProfileConfig failed: ${c.status}`))}}async encryptIntent(s,i){const o=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:s,recipients:i})});if(!o.ok){const c=await o.json().catch(()=>({error:"Encryption failed"}));throw new Error(De(c,`encryptIntent failed: ${o.status}`))}return o.json()}async getToolDisplay(){const s=await this.fetch("/tool-display");if(!s.ok)return{};const i=await s.json();return(i==null?void 0:i.tools)??{}}async getApproversPubkeys(s,i){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(i)}/approvers/pubkeys`);return o.ok?tv(await o.json()):[]}async deleteTeamProfileConfig(s,i){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(i)}`,{method:"DELETE"});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(De(c,`deleteTeamProfileConfig failed: ${o.status}`))}}async getIdentityDisclosure(){const s=await this.fetch("/api/users/me/identity-disclosure");if(!s.ok)throw new Error(`Failed to read identity setting: ${s.status}`);return s.json()}async setIdentityDisclosure(s){const i=await this.fetch("/api/users/me/identity-disclosure",{method:"PUT",body:JSON.stringify({always:s})});if(!i.ok)throw new Error(`Failed to save identity setting: ${i.status}`);return i.json()}async getProposals(s,i="pending"){const o=i==="all"?"&status=all":"",c=await this.fetch(`/api/proposals?domain=${encodeURIComponent(s)}${o}`);if(!c.ok)throw new Error(`Failed to fetch proposals: ${c.status}`);return(await c.json()).proposals??[]}async getMyProposals(s,i="pending"){const o=await Promise.all(Xy(s).map(c=>this.getProposals(c,i)));return Zy(o)}async resolveProposal(s,i,o,c){const{noteEncrypted:d,contentHash:h,note:g,...p}=c??{},y=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/resolve`,{method:"POST",body:JSON.stringify({action:i,domain:o,...p,...d?{note_encrypted:d}:g?{note:g}:{},...h?{content_hash:h}:{}})});if(!y.ok){const v=await y.json().catch(()=>({error:"Failed"}));throw new Error(De(v,`Failed: ${y.status}`))}return y.json()}async getProposal(s){const i=await this.fetch(`/api/proposals/${encodeURIComponent(s)}`);if(!i.ok){const c=await i.json().catch(()=>({error:"Failed"}));throw new Error(De(c,`getProposal failed: ${i.status}`))}const o=await i.json();return o.proposal??o}async getProposalsForApprover(){const s=await this.fetch("/api/proposals?approver=me");if(!s.ok)throw new Error(`Failed to fetch approver proposals: ${s.status}`);return(await s.json()).proposals??[]}async approveProposal(s,i){const o=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/approve`,{method:"POST",body:i?JSON.stringify({content_hash:i}):void 0});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed"}));throw new Error(De(c,`approveProposal failed: ${o.status}`))}return o.json()}async rejectProposal(s,i,o){let c;if(typeof i=="string")c={reason:i};else{const{noteEncrypted:h,note:g,...p}=i??{};c={...p,...h?{note_encrypted:h}:g?{note:g}:{}}}o&&(c.content_hash=o);const d=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/reject`,{method:"POST",body:JSON.stringify(c)});if(!d.ok){const h=await d.json().catch(()=>({error:"Failed"}));throw new Error(De(h,`rejectProposal failed: ${d.status}`))}return d.json()}async getProposalPreview(s){const i=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/preview`);if(!i.ok)throw new Error(`Failed to fetch preview: ${i.status}`);return i.json()}async getProposalOutcome(s){const i=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/outcome`);if(!i.ok)throw new Error(`Failed to fetch outcome: ${i.status}`);return i.json()}async getAttestationIntent(s){const i=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/intent`);return i.status===404||i.status===403||!i.ok?null:i.json()}async decryptIntent(s){const i=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(s)});if(!i.ok){const c=await i.json().catch(()=>({error:"Decryption failed"}));throw new Error(De(c,`decryptIntent failed: ${i.status}`))}return(await i.json()).intent}async decryptProposalContent(s){const i=await this.fetch("/api/decrypt-proposal-content",{method:"POST",body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({error:"Decryption failed"}));throw new Error(De(o,`decryptProposalContent failed: ${i.status}`))}return i.json()}async encryptProposalNote(s,i){const o=await this.fetch("/api/encrypt-proposal-note",{method:"POST",body:JSON.stringify({note:s,recipientUserIds:i})});if(!o.ok){const c=await o.json().catch(()=>({error:"Encryption failed"}));throw new Error(De(c,`encryptProposalNote failed: ${o.status}`))}return o.json()}async storeApprovedIntent(s,i){const o=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:s,intent:i})});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed"}));throw new Error(De(c,`storeApprovedIntent failed: ${o.status}`))}}async listTeamAuthorizations(s){const i=await this.fetch(`/api/groups/${encodeURIComponent(s)}/mandates`);if(!i.ok)throw new Error(`Failed to fetch team authorizations: ${i.status}`);return((await i.json()).mandates??[]).map(c=>{var g,p;const d=c.owner??{userId:""};return{authorization_id:c.authorization_id??c.authorizationId,profile_id:c.profileId??c.profile_id,path:c.path??"",title:c.title??null,sp_status:c.status??c.sp_status??null,frame:c.bounds??c.frame??{},required_domains:c.requiredDomains??c.required_domains??[],attested_domains:c.attestedDomains??c.attested_domains??[],missing_domains:(c.requiredDomains??c.required_domains??[]).filter(y=>!(c.attestedDomains??c.attested_domains??[]).includes(y)),deferred_commitment_domains:c.deferredCommitmentDomains??c.deferred_commitment_domains??[],approvers_frozen:c.approversFrozen??c.approvers_frozen??[],above_cap:c.aboveCap??c.above_cap??!1,created_at:c.createdAt?new Date(c.createdAt*1e3).toISOString():c.created_at??"",earliest_expiry:(g=c.mandates)!=null&&g.length?new Date(Math.min(...c.mandates.map(y=>y.expiresAt))*1e3).toISOString():null,remaining_seconds:(p=c.mandates)!=null&&p.length?Math.max(0,Math.min(...c.mandates.map(y=>y.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:d}})}async listTeamReceipts(s){const i=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets`);if(!i.ok)throw new Error(`Failed to fetch team receipts: ${i.status}`);return(await i.json()).tickets??[]}async getMyReceiptsPage(s){const i=new URLSearchParams;s!=null&&s.before&&i.set("before",s.before),s!=null&&s.profile&&i.set("profile",s.profile),s!=null&&s.limit&&i.set("limit",String(s.limit));const o=i.toString(),c=await this.fetch(`/api/tickets/mine${o?"?"+o:""}`);if(!c.ok)throw new Error(`Failed to fetch receipts: ${c.status}`);const d=await c.json();return{receipts:d.tickets??[],nextBefore:d.nextBefore??null}}async listTeamReceiptsPage(s,i){const o=new URLSearchParams;i!=null&&i.before&&o.set("before",i.before),i!=null&&i.profile&&o.set("profile",i.profile),i!=null&&i.limit&&o.set("limit",String(i.limit));const c=o.toString(),d=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets${c?"?"+c:""}`);if(!d.ok)throw new Error(`Failed to fetch team receipts: ${d.status}`);const h=await d.json();return{receipts:h.tickets??[],nextBefore:h.nextBefore??null}}async getThread(s){const i=s.sinceDays??7,o=s.status??"pending",c=await this.getMyProposals(s.domain,o);let d=[];if(o==="all"){const h=[],g=new Date;for(let y=0;y<i;y++){const v=new Date(g);v.setUTCDate(g.getUTCDate()-y),h.push(v.toISOString().slice(0,10))}d=(await Promise.all(h.map(y=>this.getMyReceipts({date:y,profile:s.profile})))).flat()}return{proposals:c,receipts:d}}async getAutostart(){const s=await this.fetch("/autostart");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async setAutostart(s){const i=await this.fetch("/autostart",{method:s?"POST":"DELETE"});if(!i.ok){const o=await i.json().catch(()=>({}));throw new Error(o.message||`HTTP ${i.status}`)}}async getAsPairing(){const s=await this.fetch("/as-pairing");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async getSkippedCommitments(){const s=await this.fetch("/skipped-commitments");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async getGateContent(s){const i=await this.fetch(`/gate-content?path=${encodeURIComponent(s)}`);if(!i.ok)throw new Error(`Failed to fetch gate content: ${i.status}`);return(await i.json()).entry??null}async resyncGates(){const s=await this.fetch("/resync-gates",{method:"POST"});if(!s.ok)throw new Error(`Failed to resync gates: ${s.status}`)}async getEnrichedAuthorizations(){const s=await this.fetch("/active-authorizations");if(!s.ok)throw new Error(`Failed to fetch authorizations: ${s.status}`);return(await s.json()).authorizations??[]}async pushGateContent(s){const i=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(De(o,`Push gate content failed: ${i.status}`))}}async getAgentContext(){const s=await this.fetch("/agent-brief/context");if(!s.ok)throw new Error(`Failed to fetch agent context: ${s.status}`);return(await s.json()).content}async saveAgentContext(s){const i=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:s})});if(!i.ok){const o=await i.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(De(o,`Save failed: ${i.status}`))}}async aiChat(s){const i=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({error:"AI chat failed"}));return{success:!1,error:De(o,`Chat failed: ${i.status}`)}}return i.json()}async getAIPrompts(){const s=await this.fetch("/ai-prompts");if(!s.ok)throw new Error(`Failed to load AI prompts: ${s.status}`);return s.json()}async setAIPrompt(s,i){const o=await this.fetch(`/ai-prompts/${s}`,{method:"PUT",body:JSON.stringify({value:i})});if(!o.ok){const c=await o.json().catch(()=>({error:"Save failed"}));throw new Error(De(c,`Save failed: ${o.status}`))}}}const B=new nv,vm=f.createContext(null);function rv({children:n}){const[s,i]=f.useState(null),[o,c]=f.useState("personal"),[d,h]=f.useState(null),[g,p]=f.useState(""),[y,v]=f.useState(null),[j,w]=f.useState(null),[N,E]=f.useState(null),[k,C]=f.useState(!1),[T,I]=f.useState(""),$=f.useRef(!1),P=f.useRef(null),D=f.useCallback(async()=>{if($.current)try{const J=await B.getMyTeam();if(E(J.pendingRequest),J.group&&J.membership){const{group:O,membership:fe}=J;v(O),w(fe),c("team"),h(O);const ie=P.current??fe.domains[0]??"owner";p(ie)}else v(null),w(null),c("personal")}catch{}},[]);f.useEffect(()=>{const J=()=>{document.visibilityState==="visible"&&D()};return document.addEventListener("visibilitychange",J),()=>document.removeEventListener("visibilitychange",J)},[D]),f.useEffect(()=>{fetch("/health").then(J=>J.json()).then(J=>{var O;((O=J.session)==null?void 0:O.lockedReason)==="as-url-changed"&&I(`Authority Server changed to ${J.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const K=f.useCallback(async(J,O={})=>{C(!0),I("");try{B.setApiKey(J),$.current=!0;const fe=await B.login(J,O);i(fe),P.current=fe.id;const ie=await B.getGroups(),Z=ie.find(pe=>pe.isPersonal)??ie[0]??null;h(Z),p("owner"),await D()}catch(fe){throw B.clearApiKey(),$.current=!1,I(fe instanceof Error?fe.message:"Login failed"),fe}finally{C(!1)}},[D]),V=f.useCallback(async()=>{await B.logout(),B.clearApiKey(),$.current=!1,P.current=null,i(null),h(null),p(""),v(null),w(null),E(null),c("personal"),I("")},[]),ce=f.useCallback(J=>{B.clearApiKey(),$.current=!1,P.current=null,i(null),h(null),p(""),v(null),w(null),E(null),c("personal"),I(J??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),Y=f.useCallback(()=>I(""),[]),re=f.useCallback((J,O)=>{h(J),p(O)},[]);return r.jsx(vm.Provider,{value:{user:s,mode:o,group:d,domain:g,groupId:(d==null?void 0:d.id)??null,activeTeam:y,activeMembership:j,pendingRequest:N,isLoading:k,error:T,login:K,logout:V,clearError:Y,handleSessionLocked:ce,activeGroup:d,activeDomain:g,groups:d?[d]:[],setActiveContext:re,refreshGroups:D},children:n})}function vt(){const n=f.useContext(vm);if(!n)throw new Error("useAuth must be used within AuthProvider");return n}const xm=f.createContext(null);function sv({children:n}){const{user:s}=vt(),i=f.useRef(null),[o,c]=f.useState(!1),d=f.useRef(new Map),h=f.useCallback((g,p)=>{const y=d.current;return y.has(g)||y.set(g,new Set),y.get(g).add(p),()=>{var v;(v=y.get(g))==null||v.delete(p)}},[]);return f.useEffect(()=>{if(!s){i.current&&(i.current.close(),i.current=null,c(!1));return}if(i.current)return;const g=B.getApiKey();if(!g)return;const p=new EventSource(`/events?key=${encodeURIComponent(g)}`);i.current=p,p.onopen=()=>c(!0),p.onerror=()=>c(!1);const y=["integration-changed","attestation-changed","proposal-added","proposal-resolved","team-membership-changed","action-approval-needed","action-resolved","proposal-approved","proposal-rejected","session-locked"];for(const v of y)p.addEventListener(v,j=>{let w;try{w=JSON.parse(j.data)}catch{w=null}const N=d.current.get(v);if(N)for(const E of N)try{E(w)}catch(k){console.error(`[EventSource] handler for "${v}" threw:`,k)}});return()=>{p.close(),i.current=null,c(!1)}},[s]),r.jsx(xm.Provider,{value:{connected:o,addListener:h},children:n})}function He(n,s){const i=f.useContext(xm);if(!i)return;const{addListener:o}=i;f.useEffect(()=>o(n,s),[n,s,o])}const Hs="suveren-theme",cf="hap-theme";function oi(n){return n!=="system"?n:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const s=localStorage.getItem(cf);s!==null&&localStorage.getItem(Hs)===null&&localStorage.setItem(Hs,s),s!==null&&localStorage.removeItem(cf)})();function wm(){const[n,s]=f.useState(()=>{const d=localStorage.getItem(Hs);return d==="light"||d==="dark"?d:"system"}),[i,o]=f.useState(()=>oi(n));f.useEffect(()=>{const d=document.documentElement,h=oi(n);d.setAttribute("data-theme",h),n==="system"?localStorage.removeItem(Hs):localStorage.setItem(Hs,n),o(oi(n))},[n]),f.useEffect(()=>{if(n!=="system")return;const d=window.matchMedia("(prefers-color-scheme: dark)"),h=()=>o(oi("system"));return d.addEventListener("change",h),()=>d.removeEventListener("change",h)},[n]);const c=f.useCallback(()=>{s(d=>d==="system"?"light":d==="light"?"dark":"system")},[]);return{theme:n,effectiveTheme:i,toggle:c}}const av=300*1e3,iv=2e3;function Zl(){const[n,s]=f.useState(!1),[i,o]=f.useState("docker"),[c,d]=f.useState(""),[h,g]=f.useState(null),[p,y]=f.useState(!1),[v,j]=f.useState(!1),[w,N]=f.useState(!1),E=f.useRef(null);return f.useEffect(()=>{let k=!1;const C=($=!1)=>{fetch($?"/health?refresh=1":"/health").then(P=>P.json()).then(P=>{k||(P.installMethod&&o(P.installMethod),typeof P.latestVersion<"u"&&g(P.latestVersion),P.updateAvailable&&s(!0),P.version&&(d(P.version),E.current===null?E.current=P.version:P.version!==E.current&&P.version!=="dev"&&y(!0)))}).catch(()=>{})};C(!0);const T=setInterval(()=>C(!1),w?iv:av),I=()=>{document.visibilityState==="visible"&&C(!1)};return document.addEventListener("visibilitychange",I),window.addEventListener("focus",I),()=>{k=!0,clearInterval(T),document.removeEventListener("visibilitychange",I),window.removeEventListener("focus",I)}},[w]),{updateAvailable:n&&!v,installMethod:i,version:c,latestVersion:h,serverRestarted:p,startFastPolling:()=>N(!0),dismiss:()=>j(!0)}}function ov(n){return!n||typeof n!="object"?{managed:!1}:{managed:Array.isArray(n.policyLocked)&&n.policyLocked.includes("team")}}function lv(){const[n,s]=f.useState({managed:!1});return f.useEffect(()=>{let i=!1;return fetch("/health").then(o=>o.json()).then(o=>{i||s(ov(o))}).catch(()=>{}),()=>{i=!0}},[]),n}function cv({size:n=20}){return r.jsxs("svg",{width:n,height:n,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[r.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),r.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function uv(n){return n?n==="dev"?"dev":/^[0-9a-f]{40}$/i.test(n)?n.slice(0,7):n:""}const uf={system:"◑",light:"☀",dark:"☾"};function ec({onMenuToggle:n}){const{user:s,logout:i,mode:o,activeTeam:c}=vt(),{theme:d,toggle:h}=wm(),{version:g,updateAvailable:p,latestVersion:y}=Zl(),{managed:v}=lv(),j=uv(g),w=o==="team"&&c?`Team ${c.name}`:"Personal";return r.jsx("nav",{className:"top-nav",children:r.jsxs("div",{className:"top-nav-inner",children:[r.jsxs("div",{className:"logo-group",children:[r.jsx(cv,{size:20}),r.jsx("span",{className:"logo",children:"Suveren"}),r.jsx("span",{className:"version-badge",children:"Local Gateway"}),j&&r.jsxs("span",{className:"gw-version",title:p&&y?`Running v${j} — v${y} is available`:"Running gateway version","data-stale":p?"true":void 0,children:["v",j,p&&y?` → ${y}`:""]})]}),r.jsx("div",{className:"nav-spacer"}),r.jsx("div",{className:"nav-actions nav-actions-desktop",children:s?r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"workspace-pill","data-managed":v?"true":void 0,title:v?`${w} — set by your IT`:w,children:[w,v&&r.jsx("span",{className:"workspace-pill-it",children:" · set by your IT"})]}),r.jsx("span",{className:"user-chip",children:r.jsx("strong",{children:s.name})}),r.jsx("button",{className:"theme-toggle",onClick:h,title:`Theme: ${d}`,children:uf[d]}),r.jsx("button",{className:"nav-logout",onClick:i,children:"Logout"})]}):r.jsx("button",{className:"theme-toggle",onClick:h,title:`Theme: ${d}`,children:uf[d]})}),s&&n&&r.jsx("button",{className:"mobile-menu-btn",onClick:n,"aria-label":"Menu",children:"☰"})]})})}function tc(n,s){var i;if((i=s==null?void 0:s.revokedSet)!=null&&i.has(n.authorization_id))return"revoked";switch(n.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return n.remaining_seconds===null||n.remaining_seconds<=0?"expired":n.missing_domains.length>0?"pending":"active"}function jm(n){return n==="expired"||n==="revoked"}function Sm(n,s){var i;return!!((i=s==null?void 0:s.archivedSet)!=null&&i.has(n.authorization_id))&&jm(tc(n,s))}function xi(n,s){return Sm(n,s)?"archived":tc(n,s)}function km(n,s){const i={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const o of n)i[xi(o,s)].push(o);return i}function dv(n,s){return s==="expired"?n.earliest_expiry?{iso:n.earliest_expiry,meaning:"expired"}:null:n.created_at?{iso:n.created_at,meaning:"created"}:null}function Zt(n,s,i){const o=f.useRef(n);o.current=n,f.useEffect(()=>{let c=null;const d=()=>typeof document>"u"?!0:document.visibilityState==="visible",h=()=>{d()&&o.current()},g=()=>{c===null&&(c=setInterval(h,s))},p=()=>{c!==null&&(clearInterval(c),c=null)},y=()=>{d()?(o.current(),g()):p()};return d()&&(o.current(),g()),document.addEventListener("visibilitychange",y),()=>{p(),document.removeEventListener("visibilitychange",y)}},[s,i])}function nc(){const[n,s]=f.useState(!1);return f.useEffect(()=>{let i=!1;const o=()=>{fetch("/health").then(h=>h.json()).then(h=>{i||s(h.simulation===!0)}).catch(()=>{})};o();const c=setInterval(o,3e4),d=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",d),()=>{i=!0,clearInterval(c),document.removeEventListener("visibilitychange",d)}},[]),n}function fv(n,s){const i=n.simulation;return i?(((s==null?void 0:s[i.field])??"").trim().toLowerCase()||i.default.trim().toLowerCase())==="simulation":!1}function Vs(n){return!!(n!=null&&n.simulation)}const bm=f.createContext(null),mv=3e4,hv=5e3,pv=3e5;function gv(n,s,i){return s===0?"loading":n!=null&&n.running?"running":n!=null&&n.paused?"paused":n!=null&&n.error?"error":n&&i?"starting":"not-running"}function yv({children:n}){const[s,i]=f.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),o=f.useRef(null),c=f.useCallback(async()=>{let v=!1;const[j,w]=await Promise.all([B.getIntegrationManifests().catch(()=>(v=!0,{manifests:[]})),B.getMcpHealth().catch(()=>null)]);i(E=>({...E,manifests:j.manifests,integrations:(w==null?void 0:w.integrations)??E.integrations,activeSessions:(w==null?void 0:w.activeSessions)??E.activeSessions,mcpServerUp:!!w,manifestsError:v,fetchCount:E.fetchCount+1}));const N=j.manifests.filter(E=>E.oauth);if(N.length>0){const E=await Promise.all(N.map(async k=>[k.id,await B.getOAuthHealth(k.id)]));i(k=>({...k,authHealth:Object.fromEntries(E)}))}},[]),d=s.fetchCount>0&&s.manifests.some(v=>{const j=s.integrations.find(w=>w.id===v.id);return j&&!j.running&&!j.paused});He("integration-changed",c),Zt(c,d?hv:pv);const h=f.useMemo(()=>{const v=new Map(s.integrations.map(N=>[N.id,N])),j=Date.now();d&&o.current===null?o.current=j:d||(o.current=null);const w=o.current!==null&&j-o.current<mv;return s.manifests.map(N=>{const E=v.get(N.id),k=gv(E,s.fetchCount,w),C=s.authHealth[N.id];return{id:N.id,manifest:N,integration:E,state:k,authStatus:C==null?void 0:C.status,authAccount:C==null?void 0:C.account,authError:C==null?void 0:C.error}})},[s,d]),g=nc(),p=f.useMemo(()=>h.filter(v=>!(g&&!Vs(v.manifest))&&(v.state==="not-running"||v.state==="error"||v.authStatus==="failed")).length,[h,g]),y={loading:s.fetchCount===0,mcpServerUp:s.mcpServerUp,manifestsError:s.manifestsError,entries:h,attentionCount:p,activeSessions:s.activeSessions,refresh:c};return r.jsx(bm.Provider,{value:y,children:n})}function rc(){const n=f.useContext(bm);if(!n)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return n}const vv={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},sc=n=>vv[n]??n,xv={resource:{chip:"Restricted",sev:"warn"},spam:{chip:"Spam / Trash",sev:"info"},age:{chip:"Too old",sev:"warn"},unset_age:{chip:"Needs setup",sev:"act",fixTo:"/integrations"},read_gate:{chip:"Not granted",sev:"act",fixTo:"/mandates"},ungoverned:{chip:"Unconfigured",sev:"act"},query_unsafe:{chip:"Unsafe search",sev:"info"}};function wv(n){return(n&&xv[n])??{chip:"Blocked",sev:"info"}}function jv(n){const s=sc(n.integrationId);switch(n.reason){case"resource":return n.integrationId==="calendar"?r.jsxs(r.Fragment,{children:["Tried to read your ",r.jsx("b",{children:n.target??"restricted"})," calendar"]}):r.jsxs(r.Fragment,{children:["Tried to read a restricted location in ",s]});case"spam":return r.jsxs(r.Fragment,{children:["Tried to open a message in ",r.jsx("b",{children:"spam or trash"})]});case"age":return r.jsxs(r.Fragment,{children:["Tried to read ",s," older than your read window"]});case"unset_age":return r.jsxs(r.Fragment,{children:["Your ",s," has ",r.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return r.jsxs(r.Fragment,{children:["Read access isn't granted on your ",s," mandate"]});case"ungoverned":return r.jsxs(r.Fragment,{children:["A ",s," tool isn't configured for safe reading"]});case"query_unsafe":return r.jsx(r.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return r.jsx(r.Fragment,{children:n.detail})}}function Nm(n,s){const i=Math.max(0,(s-n)/1e3);if(i<60)return"Just now";if(i<3600)return`${Math.floor(i/60)} min ago`;if(i<86400)return`${Math.floor(i/3600)} hr ago`;const o=Math.floor(i/86400);return o===1?"Yesterday":`${o} days ago`}const df=5,Sv=1440*60*1e3,hi=7;function kv(n,s){const i=s-hi*Sv;return{recent:n.filter(o=>o.ts>=i),all:n}}function bv(){const[n,s]=f.useState(null),[i,o]=f.useState(!1),[c,d]=f.useState(!1),h=f.useCallback(()=>{B.getDenials({limit:200}).then(({records:w})=>{s(w),d(!1)}).catch(()=>d(!0))},[]);if(f.useEffect(()=>{h()},[h]),Zt(h,12e4),c||n===null)return null;const{recent:g,all:p}=kv(n,Date.now()),y=i?p:g.slice(0,df),v=p.length-g.length,j=(w,N)=>{const E=wv(w.reason);return r.jsxs("div",{className:"rb-row",children:[r.jsx("span",{className:`rb-dot ${E.sev==="act"?"act":E.sev==="info"?"info":""}`,"aria-hidden":"true"}),r.jsxs("div",{className:"rb-body",children:[r.jsx("div",{className:"rb-line",children:jv(w)}),r.jsxs("div",{className:"rb-meta",children:[r.jsx("span",{className:`rb-chip ${E.sev==="act"?"act":E.sev==="warn"?"warn":""}`,children:E.chip}),r.jsx("span",{className:"rb-via",children:sc(w.integrationId)})]}),E.fixTo&&r.jsx(yt,{className:"rb-fix",to:E.fixTo,children:"Set a read window →"})]}),r.jsx("div",{className:"rb-when",children:Nm(w.ts,Date.now())})]},`${w.ts}-${N}`)};return r.jsxs("section",{className:"card recent-blocks","aria-label":"Recent blocks",style:{marginTop:"1.5rem"},children:[r.jsxs("div",{className:"card-header",children:[r.jsx("h2",{className:"card-title",children:"Recent blocks"}),(i?p.length:g.length)>0&&r.jsx("span",{className:"rb-count",children:i?p.length:g.length})]}),y.length===0?r.jsxs("div",{className:"rb-empty",children:[r.jsx("span",{className:"rb-mark","aria-hidden":"true",children:r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M20 6 9 17l-5-5"})})}),r.jsxs("h3",{children:["Nothing blocked in the last ",hi," days"]}),r.jsx("p",{children:"Your agent has stayed within every limit you set."}),v>0&&r.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!0),children:["Show the last 30 days (",v,")"]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"rb-sub",children:[i?"Last 30 days. ":`Last ${hi} days. `,"Limits you set that stopped your agent. Seeing them here means the gateway is doing its job."]}),r.jsx("div",{className:"rb-rows",children:y.map(j)}),!i&&p.length>y.length&&r.jsx("div",{className:"rb-foot",children:r.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!0),children:["View all ",p.length," blocks from the last 30 days"]})}),i&&p.length>Math.min(g.length,df)&&r.jsx("div",{className:"rb-foot",children:r.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!1),children:["Show only the last ",hi," days"]})})]})]})}function Gs(n){return n.kind??"read"}function Nv(n,s){var d,h,g,p;if(!s)return"";if(!n)return s;const i=(h=(d=n.scopeSchema)==null?void 0:d.fields)==null?void 0:h[s];if(i!=null&&i.displayName)return i.displayName;const o=((g=n.boundsSchema)==null?void 0:g.fields)??{};if((p=o[s])!=null&&p.displayName)return o[s].displayName;const c=Object.values(o).find(y=>y.boundType&&"of"in y.boundType&&y.boundType.of===s);return c!=null&&c.displayName?c.displayName:s}const Cv={bound:"Blocked — above your limit",scope:"Blocked — outside your mandate's scope",cumulative:"Blocked — limit reached",simulation:"Blocked — simulation mode",not_authorized:"Blocked — not authorized",read:"Read blocked"},Ev={bound:"Nothing ran. To allow this, raise the limit on the mandate (needs your signature) — or ask the AI to stay within it.",scope:"Nothing ran. To allow this, widen the mandate's scope (needs your signature) — or ask the AI to stay within it.",cumulative:"Nothing ran. Possible again once the window resets — or raise the limit in the mandate.",simulation:"Nothing ran. Turn off simulation mode in Settings to use real systems.",not_authorized:"Nothing ran. Grant a mandate for this, or ask the decision owner.",read:"Nothing was read."};function ff(n){return n===void 0?"":typeof n=="number"?n.toLocaleString():n}function Tv(n,s){const i=Gs(n),o=ff(n.value),c=ff(n.limit);switch(i){case"bound":return o&&c?`${s||"Value"} ${o} is above the limit ${c}.`:n.detail;case"scope":return o?`${s||"Value"} "${o}" is not within your mandate's allowed ${s||"scope"}.`:n.detail;case"cumulative":return o&&c?`${o} of ${c} used — the limit is reached.`:n.detail;case"simulation":return"Real systems are switched off while the gateway runs in simulation mode.";case"not_authorized":return"No mandate currently covers this action.";case"read":default:return n.detail}}function Rv(n){const s=Gs(n),i=sc(n.integrationId),o=n.mandateTitle?` · mandate "${n.mandateTitle}"`:n.mandateId?` · mandate ${n.mandateId.slice(0,14)}…`:"",c=n.who==="authority-server"?"refused by the Authority Server":s==="read"?"refused by this gateway":"refused by this gateway, before anything ran",d=n.code?` (${n.code})`:"";return`${i} · ${n.tool}${o} · ${c}${d}`}function Iv(n,s){const i=Gs(n),o=Nv(s,n.field);return{title:Cv[i],sentence:Tv(n,o),sourceLine:Rv(n),whatYouCanDo:Ev[i]}}function Cm(n,s){const i=new Date(s);return i.setHours(0,0,0,0),n.filter(o=>o.ts>=i.getTime()).length}const Av=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Pending Approvals",statusKey:"proposals"},{to:"/mandates",icon:"☰",label:"Mandates",statusKey:"authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/blocked",icon:"⛔",label:"Blocked",statusKey:"blocked"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/team",icon:"◉",label:"Team",teamOnly:!0},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations"},{to:"/settings",icon:"⚙",label:"Settings",statusKey:"assistant"}];function Pv(){const{activeDomain:n}=vt(),[s,i]=f.useState({}),o=f.useCallback(async()=>{try{const[c,d,h,g,p,y,v]=await Promise.all([B.getCredential("ai-config").catch(()=>null),B.getMyAttestations().catch(()=>null),B.getMyProposals(n).catch(()=>null),B.getProposalsForApprover().catch(()=>null),B.getAgentContext().catch(()=>""),B.getArchivedMandates().catch(()=>[]),B.getDenials({limit:200}).catch(()=>null)]),j={};if(c&&!c.configured&&(j.assistant=1),d){const k=km(d,{archivedSet:new Set(y)}).expired.length;k>0&&(j.authorizations=k)}const w=(h==null?void 0:h.length)??0,N=(g==null?void 0:g.length)??0,E=w+N;if(E>0&&(j.proposals=E),(!p||!p.trim())&&(j.brief=1),v){const k=Cm(v.records,Date.now());k>0&&(j.blocked=k)}i(j)}catch{}},[n]);return He("attestation-changed",o),He("proposal-added",o),He("proposal-resolved",o),He("proposal-approved",o),He("proposal-rejected",o),He("team-membership-changed",o),f.useEffect(()=>(window.addEventListener("suveren:archived-changed",o),()=>window.removeEventListener("suveren:archived-changed",o)),[o]),Zt(o,3e5,n),s}const _v={marginLeft:"auto",minWidth:"1.25rem",height:"1.25rem",padding:"0 0.375rem",borderRadius:"0.625rem",background:"var(--warning)",color:"var(--bg-elevated)",fontSize:"0.7rem",fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},Lv={position:"fixed",bottom:"1.5rem",left:"50%",transform:"translateX(-50%)",background:"var(--bg-elevated, #1e1e2e)",color:"var(--text-primary, #e2e8f0)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.625rem 1rem",fontSize:"0.85rem",boxShadow:"0 4px 16px rgba(0,0,0,0.3)",zIndex:9999,whiteSpace:"nowrap",pointerEvents:"none"};function $v(){const{mode:n,group:s,domain:i,activeTeam:o}=vt(),c=Pv(),{attentionCount:d}=rc(),h={...c};d>0&&(h.integrations=d);const g=Av.filter(w=>!w.teamOnly||n==="team"),p=f.useRef(null),[y,v]=f.useState(null),j=Bt();return f.useEffect(()=>{if(p.current===null){p.current=n;return}p.current!==n&&(n==="team"&&o?v(`You are now acting in team context — ${o.name}`):n==="personal"&&v("You have left the team — back to personal context"),p.current=n)},[n,o]),f.useEffect(()=>{v(null)},[j.pathname]),r.jsxs("div",{className:"sidebar",children:[r.jsx("ul",{className:"sidebar-nav",children:g.map(w=>{const N=w.statusKey?h[w.statusKey]:0;return r.jsx("li",{children:r.jsxs(Ql,{to:w.to,end:w.to==="/",className:({isActive:E})=>`sidebar-item${E?" active":""}`,children:[r.jsx("span",{className:"icon",children:w.icon}),w.label,N?r.jsx("span",{style:_v,children:N}):null]})},w.to)})}),r.jsxs("div",{className:"sidebar-context",children:[r.jsx("div",{className:"ctx-label",children:"Active context"}),r.jsx("div",{className:"ctx-value",children:n==="personal"?"personal":s?`${s.name} / ${i}`:i})]}),y&&r.jsx("div",{style:Lv,role:"status","aria-live":"polite",children:y})]})}const xl="suveren:updatedTo";function zv(n){return n==="managed"||n==="msi"?null:n==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":n==="dev"?"git pull && pnpm install":"docker rm -f suveren-gateway 2>/dev/null; docker ps -q --filter publish=7400 --filter publish=7430 | xargs -r docker rm -f; docker pull ghcr.io/suverenai/suveren-gateway:latest && docker run -d --name suveren-gateway -p 7400:3000 -p 7430:3030 -v $HOME/.suveren:/app/data ghcr.io/suverenai/suveren-gateway"}const Fv="Updates for this gateway come from your company's IT — no action needed here.";function Ov(n){return n==="managed"?"update-banner is-managed":"update-banner"}const Mv="Download the new installer and run it. Your settings and mandates stay.";function Bv(n){const s="https://github.com/suverenai/suveren-gateway/releases";return n?`${s}/tag/v${n}`:`${s}/latest`}function Dv(){const n=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const i of n)if(!i.closest(".update-overlay"))return!0;const s=document.activeElement;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)){const i=s.value;if(i&&i.trim())return!0}return!1}function Em(){const{updateAvailable:n,installMethod:s,version:i,latestVersion:o,serverRestarted:c,startFastPolling:d,dismiss:h}=Zl(),[g,p]=f.useState(!1),[y,v]=f.useState(!1),[j,w]=f.useState(()=>{try{const $=sessionStorage.getItem(xl);if($)return sessionStorage.removeItem(xl),$}catch{}return null}),N=zv(s),E=f.useRef(null),k=$=>{try{sessionStorage.setItem(xl,$||o||"✓")}catch{}window.location.reload()};f.useEffect(()=>{if(!j)return;const $=setTimeout(()=>w(null),6e3);return()=>clearTimeout($)},[j]),f.useEffect(()=>{if(!g||!c)return;const $=()=>Dv()?!1:(k(i),!0);if($())return;const P=setInterval($,1500);return()=>clearInterval(P)},[g,c,i]),f.useEffect(()=>(document.body.classList.toggle("is-updating",g),()=>document.body.classList.remove("is-updating")),[g]);const C=n&&!g&&!j||!!j&&!g;f.useEffect(()=>{if(!C){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const $=()=>{var K;const D=((K=E.current)==null?void 0:K.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${D}px`)};$();const P=new ResizeObserver($);return E.current&&P.observe(E.current),()=>{P.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[C]);const T=()=>{p(!0),d()},I=async()=>{if(N)try{await navigator.clipboard.writeText(N),v(!0),setTimeout(()=>v(!1),1800)}catch{}};return r.jsxs(r.Fragment,{children:[j&&!g&&r.jsx("div",{ref:E,className:"update-banner is-live",role:"status","aria-live":"polite",children:r.jsxs("div",{className:"update-banner-row",children:[r.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",j&&j!=="✓"?` — ${j} is live`:" — now live","."]}),r.jsx("button",{className:"update-banner-x",onClick:()=>w(null),"aria-label":"Dismiss",children:"×"})]})}),n&&!g&&!j&&r.jsxs("div",{ref:E,className:Ov(s),role:"status","aria-live":"polite",children:[r.jsxs("div",{className:"update-banner-row",children:[r.jsx("span",{className:"update-banner-text",children:s==="msi"&&o?`Update available — version ${o}.`:"Update available."}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[s==="msi"&&r.jsx("a",{className:"btn btn-sm btn-secondary",href:Bv(o),target:"_blank",rel:"noopener noreferrer",children:"Download installer"}),s!=="managed"&&s!=="msi"&&r.jsx("button",{className:"btn btn-sm btn-secondary",onClick:T,children:"Update"}),r.jsx("button",{className:"update-banner-x",onClick:h,"aria-label":"Dismiss",children:"×"})]})]}),s==="managed"&&r.jsx("p",{className:"update-banner-hint",children:Fv}),s==="msi"&&r.jsx("p",{className:"update-banner-hint",children:Mv})]}),g&&r.jsx("div",{className:"update-overlay",children:r.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[r.jsx("div",{className:"update-spinner"}),r.jsxs("h2",{children:["Finishing the update","…"]}),r.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",r.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),r.jsxs("div",{className:"update-cmd-row",children:[r.jsx("code",{className:"update-cmd",children:N}),r.jsx("button",{className:"btn btn-sm btn-primary",onClick:I,children:y?"Copied":"Copy"})]}),r.jsxs("div",{className:"update-status",children:[r.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),r.jsxs("div",{className:"update-overlay-actions",children:[r.jsx("button",{className:"btn btn-primary",onClick:()=>k(i),children:"Reload now"}),r.jsx("button",{className:"btn btn-secondary",onClick:()=>p(!1),children:"Cancel"})]})]})})]})}function Tm(){const n=nc(),s=f.useRef(null);return f.useEffect(()=>{if(!n){document.documentElement.style.removeProperty("--sim-banner-h");return}const i=()=>{var d;const c=((d=s.current)==null?void 0:d.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${c}px`)};i();const o=new ResizeObserver(i);return s.current&&o.observe(s.current),()=>{o.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[n]),n?r.jsx("div",{ref:s,className:"simulation-banner",role:"status","aria-live":"polite",children:r.jsx("span",{className:"simulation-banner-text",children:"Simulation mode — real systems are blocked."})}):null}const Uv={system:"◑",light:"☀",dark:"☾"},Wv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Pending Approvals"},{to:"/mandates",icon:"☰",label:"Mandates"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/team",icon:"◉",label:"Team"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"Settings"}];function Hv({open:n,onClose:s}){const{user:i,activeGroup:o,activeDomain:c,logout:d}=vt(),{theme:h,toggle:g}=wm(),p=Bt();return f.useEffect(()=>{s()},[p.pathname]),n?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"mobile-menu-backdrop",onClick:s}),r.jsxs("div",{className:"mobile-menu-panel",children:[i&&r.jsxs("div",{className:"mobile-menu-header",children:[r.jsx("strong",{children:i.name}),r.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:o?`${o.name} / ${c}`:c||"personal"})]}),r.jsx("nav",{className:"mobile-menu-nav",children:Wv.map(y=>r.jsxs(Ql,{to:y.to,end:y.to==="/",className:({isActive:v})=>`mobile-menu-item${v?" active":""}`,onClick:s,children:[r.jsx("span",{className:"icon",children:y.icon}),y.label]},y.to))}),r.jsxs("div",{className:"mobile-menu-footer",children:[r.jsxs("button",{className:"mobile-menu-action",onClick:()=>{g()},children:[r.jsx("span",{className:"icon",children:Uv[h]}),"Theme: ",h]}),r.jsx("button",{className:"mobile-menu-action",onClick:()=>{d(),s()},children:"Logout"})]})]})]}):null}function Rm(n){return n.status==="pending"}function Vv(n,s){return n.filter(Rm).length+s.length}const gr=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],Gv=500;function Im(){const{user:n,domain:s}=vt(),[i,o]=f.useState(0),c=f.useRef(null),d=f.useCallback(async()=>{if(!n){o(0);return}try{const[g,p]=await Promise.all([B.getMyProposals(s).catch(()=>[]),B.getProposalsForApprover().catch(()=>[])]);o(Vv(g,p))}catch{o(0)}},[n,s]),h=f.useCallback(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d()},Gv)},[d]);return f.useEffect(()=>(d(),()=>{c.current&&clearTimeout(c.current)}),[d]),He(gr[0],h),He(gr[1],h),He(gr[2],h),He(gr[3],h),He(gr[4],h),He(gr[5],h),He(gr[6],h),i}const mf="Suveren",Kv="/favicon.svg",Yv="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",li={x1:74.54,y1:22.74,x2:94.46,y2:34.24},Jv=14,qv="#f59e0b";function Qv(n){const s=ac(n);return s>0?`(${s}) ${mf}`:mf}function ac(n){return Number.isFinite(n)&&n>0?Math.floor(n):0}function Xv(){const n=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
52
- <path class="m" d="${Yv}"/>
53
- <line class="m" x1="${li.x1}" y1="${li.y1}" x2="${li.x2}" y2="${li.y2}"/>
54
- <circle cx="103" cy="103" r="25" fill="${qv}"/>
55
- <style>.m{stroke:#111111;stroke-width:${Jv};fill:none;stroke-linecap:round}@media (prefers-color-scheme:dark){.m{stroke:#ffffff;stroke-width:13.3}}</style>
56
- </svg>`;return`data:image/svg+xml,${encodeURIComponent(n)}`}function Zv(){return document.querySelector('link[rel="icon"]')}function Am(n){const s=ac(n);document.title=Qv(s),Pm(s);const i=Zv();if(!i)return;const o=s>0?Xv():Kv;i.getAttribute("href")!==o&&i.setAttribute("href",o)}function ex(){Am(0)}function Pm(n,s=globalThis.navigator){var c;if(!s||typeof s.setAppBadge!="function")return;const i=ac(n),o=i>0?s.setAppBadge(i):s.clearAppBadge?s.clearAppBadge():s.setAppBadge(0);(c=o==null?void 0:o.catch)==null||c.call(o,()=>{})}function tx(){const n=Im();return f.useEffect(()=>{Am(n)},[n]),f.useEffect(()=>ex,[]),null}const _m="suveren:dockBadgePrompt";function nx(){var o;if(typeof window>"u"||!("Notification"in window)||!("setAppBadge"in navigator)||!(((o=window.matchMedia)==null?void 0:o.call(window,"(display-mode: standalone)").matches)||navigator.standalone===!0))return!1;const s=navigator.userAgent;if(!(/Safari\//.test(s)&&!/Chrome\/|Chromium\/|Edg\//.test(s))||Notification.permission!=="default")return!1;try{if(localStorage.getItem(_m))return!1}catch{}return!0}function rx(){const[n,s]=f.useState(!1),i=Im();if(f.useEffect(()=>{s(nx())},[]),!n)return null;const o=()=>{try{localStorage.setItem(_m,"1")}catch{}s(!1)},c=async()=>{try{await Notification.requestPermission()==="granted"&&Pm(i)}catch{}o()};return r.jsxs("div",{className:"hint-box",style:{marginBottom:"1rem",alignItems:"center"},children:[r.jsxs("div",{className:"hint-body",children:[r.jsx("div",{className:"hint-head",children:"Show waiting approvals on the Dock icon"}),"Safari needs your permission once. The icon then shows how many approvals are waiting, and nothing else."]}),r.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:c,children:"Allow"}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:o,"aria-label":"Not now",children:"Not now"})]})}function sx(){const[n,s]=f.useState(!1);return r.jsxs(yv,{children:[r.jsx(tx,{}),r.jsx(ec,{onMenuToggle:()=>s(!n)}),r.jsx(Em,{}),r.jsx(Tm,{}),r.jsx($v,{}),r.jsx(Hv,{open:n,onClose:()=>s(!1)}),r.jsx("div",{className:"main-content",children:r.jsxs("div",{className:"page-inner",children:[r.jsx(rx,{}),r.jsx(py,{})]})})]})}function Lm({what:n}){return r.jsxs("div",{className:"human-only-note",role:"note",children:[r.jsx("strong",{children:"Only you."})," ",n==="sign-in"?"Never let an AI or a browser it controls sign in here or see this key.":"Approve only yourself. Never let an AI or a browser it controls open this page or approve for you."]})}function ic(){return typeof navigator<"u"&&navigator.webdriver===!0}const oc="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function ax(){const[n,s]=f.useState(""),{login:i,isLoading:o,error:c,clearError:d}=vt(),[h,g]=f.useState(null),p=ic(),y=async()=>{if(!(!n.trim()||p)){d();try{await i(n)}catch(w){if(w instanceof ym){g(w.summary);return}}}},v=async()=>{g(null),d();try{await i(n,{confirmWipe:!0})}catch{}},j=()=>{g(null)};return r.jsxs(r.Fragment,{children:[r.jsx(ec,{}),r.jsx(Em,{}),r.jsx(Tm,{}),r.jsxs("div",{className:"login-split",children:[r.jsx("div",{className:"login-split-left",children:r.jsxs("div",{style:{maxWidth:"28rem"},children:[r.jsx("h1",{style:{fontSize:"clamp(2.25rem, 4vw, 3.25rem)",letterSpacing:"-0.03em",lineHeight:1.1,marginBottom:"1.25rem"},children:"Your agents, your intent, your rules."}),r.jsx("p",{style:{fontSize:"1.125rem",color:"var(--text-secondary)",lineHeight:1.6,marginBottom:"3rem"},children:"The gateway runs on your machine, between your agents and the tools they use. Your signature. Your bounds. Your tickets."})]})}),r.jsx("div",{className:"login-split-right",children:r.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[r.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[r.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),r.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage mandates."})]}),r.jsx(Lm,{what:"sign-in"}),p&&r.jsx("div",{className:"error-message",children:oc}),c&&r.jsx("div",{className:"error-message",children:c}),r.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[r.jsx("label",{className:"form-label",children:"API Key"}),r.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:n,onChange:w=>s(w.target.value),onKeyDown:w=>w.key==="Enter"&&y(),disabled:o,style:{padding:"0.75rem"}}),r.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),r.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:y,disabled:o||p,style:{marginBottom:"2rem"},children:o?"Signing in...":"Sign In"}),r.jsx("div",{className:"login-divider",children:"New here?"}),r.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[r.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",r.jsx("br",{}),"then come back to sign in."]}),r.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-full",style:{textDecoration:"none"},children:"Create Account"})]}),r.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),r.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[r.jsxs(r.Fragment,{children:["Create an account at ",r.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)"},children:"Suveren"})]}),"Join or create a team to get domain authority","Sign in here with your API key to start giving mandates"].map((w,N)=>r.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:N<2?"0.5rem":0},children:[r.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[N+1,"."]}),w]},N))})]})]})})]}),h&&r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wipe-warning-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:j,children:r.jsxs("div",{className:"card",onClick:w=>w.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[r.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),r.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["This gateway already holds data for another account. Signing in with this API key will ",r.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),r.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[r.jsxs("li",{children:[h.credentialCount," stored service credential",h.credentialCount===1?"":"s",h.credentialIds.length>0&&r.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",h.credentialIds.slice(0,5).join(", "),h.credentialIds.length>5?`, +${h.credentialIds.length-5} more`:"",")"]})]}),r.jsxs("li",{children:[h.serviceCount," configured integration",h.serviceCount===1?"":"s"]}),r.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),r.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),r.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Mandates and tickets on the Authority Server are NOT affected — only this gateway's local state is wiped."}),r.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:"If this isn't what you wanted, cancel and sign back in with the original API key, or use a different gateway instance for this account."}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:j,disabled:o,children:"Cancel"}),r.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:v,disabled:o,children:o?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function ix(n,s){return!s&&n!=null}function ox(n,s){return n==="join-waiting"&&s==="team"}function lx(n,s,i,o){return i!=null||n!=="join-waiting"||s==="team"?null:o}function cx(n){return`${n} personal mandate${n===1?"":"s"}`}function ux({mandates:n,pendingProposals:s}){return n.length===0&&s===0?r.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)"},children:"You have no personal mandates to end."}):r.jsxs("div",{style:{background:"var(--bg-elevated)",borderRadius:"0.5rem",padding:"0.75rem 1rem",margin:"0.75rem 0"},children:[r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Your personal mandates end"}),r.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,fontSize:"0.825rem"},children:n.map(i=>r.jsxs("li",{style:{display:"flex",justifyContent:"space-between",gap:"0.5rem",padding:"0.25rem 0",borderBottom:"1px solid var(--border)"},children:[r.jsx("span",{children:i.title||i.profileId}),r.jsx("span",{style:{color:"var(--text-tertiary)"},children:i.commitmentMode??""})]},i.id))}),r.jsxs("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem",marginBottom:0},children:["They stay in your history; their tickets stay verifiable.",s>0&&` ${s} personal proposal${s===1?"":"s"} waiting for approval end${s===1?"s":""} too.`]})]})}function dx(){const{mode:n,pendingRequest:s,refreshGroups:i}=vt(),o=dn(),[c,d]=f.useState("choose"),[h,g]=f.useState(""),[p,y]=f.useState(""),[v,j]=f.useState(null),[w,N]=f.useState(null),[E,k]=f.useState(""),[C,T]=f.useState(""),[I,$]=f.useState(!1),P=f.useRef(!1);f.useEffect(()=>{ix(s,P.current)&&(P.current=!0,d("join-waiting"))},[s]),f.useEffect(()=>{ox(c,n)&&o("/")},[c,n,o]);const D=f.useRef(null);f.useEffect(()=>{if(s){D.current=s.groupName;return}const O=lx(c,n,s,D.current);O&&(k(O),d("join-declined"),D.current=null)},[s,c,n]),f.useEffect(()=>{if(c!=="join-waiting")return;const O=setInterval(()=>{i()},5e3);return()=>clearInterval(O)},[c,i]);const K=f.useCallback(()=>{d("choose"),T(""),j(null),N(null),g(""),y("")},[]),V=async()=>{if(h.trim()){$(!0),T("");try{const O=await B.getJoinPreview(h.trim());j(O),d("join-preview")}catch(O){T(O instanceof Error?O.message:"Invalid or expired invite code")}finally{$(!1)}}},ce=async()=>{$(!0),T("");try{await B.requestToJoinGroup(h.trim()),await i(),d("join-waiting")}catch(O){T(O instanceof Error?O.message:"Failed to join group")}finally{$(!1)}},Y=async()=>{$(!0),T("");try{await B.withdrawJoinRequest(),await i(),K()}catch(O){T(O instanceof Error?O.message:"Failed to withdraw request")}finally{$(!1)}},re=async()=>{d("create"),T(""),$(!0);try{const O=await B.getCreatePreview();N(O)}catch(O){T(O instanceof Error?O.message:"Failed to load preview")}finally{$(!1)}},J=async()=>{if(p.trim()){$(!0),T("");try{await B.createGroup(p.trim()),await i(),o("/")}catch(O){T(O instanceof Error?O.message:"Failed to create group")}finally{$(!1)}}};return r.jsxs(r.Fragment,{children:[r.jsx(ec,{}),r.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:r.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[C&&r.jsx("div",{className:"error-message",children:C}),c==="choose"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[r.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join or create a team"}),r.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6},children:"An account is Personal or in one team — never both. Joining or creating a team moves your account: your personal mandates end (kept in your history)."})]}),r.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[r.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing team"}),r.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),r.jsxs("div",{className:"invite-input-row",children:[r.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:h,onChange:O=>g(O.target.value),onKeyDown:O=>O.key==="Enter"&&V(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:I}),r.jsx("button",{className:"btn btn-primary",onClick:V,disabled:I||!h.trim(),children:I?"Checking…":"Continue"})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new team"}),r.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members."}),r.jsx("button",{className:"btn btn-secondary",onClick:re,disabled:I,children:"Create a team"})]})]}),c==="join-preview"&&v&&r.jsxs("div",{className:"card",children:[r.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Join team ",v.groupName,"?"]}),r.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Your account ",r.jsx("strong",{children:"moves to the team"}),". From then on you work under the team's rules — its approvers and limits."]}),r.jsx(ux,{mandates:v.personalMandates,pendingProposals:v.pendingPersonalProposals}),r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:["The team admin (",v.admin.name,") confirms your request. Nothing changes until then."]}),r.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:ce,disabled:I,children:I?"Asking…":"Ask to join"}),r.jsx("button",{className:"btn btn-ghost",onClick:K,disabled:I,children:"Cancel"})]})]}),c==="join-waiting"&&r.jsxs("div",{className:"card",children:[r.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request sent to team ",(s==null?void 0:s.groupName)??""]}),r.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Waiting for the team admin to confirm. Until then your account stays Personal and your mandates keep working."}),r.jsx("button",{className:"btn btn-secondary",onClick:Y,disabled:I,children:I?"Withdrawing…":"Withdraw request"})]}),c==="join-declined"&&r.jsxs("div",{className:"card",children:[r.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request to ",E," ended"]}),r.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"The team admin declined your request, or it was withdrawn. Your account stays Personal."}),r.jsx("button",{className:"btn btn-primary",onClick:K,disabled:I,children:"Back"})]}),c==="create"&&r.jsxs("div",{className:"card",children:[r.jsx("h3",{style:{marginBottom:"0.75rem"},children:"Create a team"}),r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsx("label",{style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:"Team name"}),r.jsx("input",{className:"form-input",placeholder:"e.g., Acme Corp",value:p,onChange:O=>y(O.target.value),onKeyDown:O=>O.key==="Enter"&&J(),disabled:I,autoFocus:!0})]}),w&&r.jsxs("div",{className:"alert alert-info",style:{color:"white"},children:["Your account moves to the new team. Your ",cx(w.personalMandates.length)," end (kept in your history)."]}),r.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginTop:"1rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:J,disabled:I||!p.trim(),children:I?"Creating…":"Create team and move my account"}),r.jsx("button",{className:"btn btn-ghost",onClick:K,disabled:I,children:"Cancel"})]})]})]})})]})}const hf={"claude-code":{label:"Claude Code",snippet:n=>`claude mcp add --transport http suveren ${n}/mcp`},"claude-desktop":{label:"Claude Desktop",snippet:n=>`Add to ~/Library/Application Support/Claude/claude_desktop_config.json, then restart Claude Desktop:
57
-
58
- ${JSON.stringify({mcpServers:{suveren:{command:"npx",args:["mcp-remote@latest",`${n}/mcp`,"--allow-http"]}}},null,2)}`},"chatgpt-codex":{label:"ChatGPT / Codex",snippet:n=>`Add to ~/.codex/config.toml:
59
-
60
- [mcp_servers.suveren]
61
- url = "${n}/mcp"
62
-
63
- Or: codex mcp add suveren --url ${n}/mcp`},other:{label:"Other",snippet:n=>`Streamable HTTP: POST ${n}/mcp
64
- SSE transport: GET ${n}/sse
65
- Health check: GET ${n}/health`}},pf=["claude-code","claude-desktop","chatgpt-codex","other"];function Rl({mcpEndpoint:n}){const[s,i]=f.useState(pf[0]),[o,c]=f.useState(!1),d=f.useCallback(async g=>{try{await navigator.clipboard.writeText(g),c(!0),setTimeout(()=>c(!1),2e3)}catch{}},[]),h=hf[s].snippet(n);return r.jsxs("div",{children:[r.jsx("div",{className:"gate-content-label",children:"MCP Endpoint"}),r.jsx("div",{className:"mcp-endpoint",children:n}),r.jsx("div",{className:"mcp-tabs",children:pf.map(g=>r.jsx("button",{className:`mcp-tab${s===g?" active":""}`,onClick:()=>i(g),children:hf[g].label},g))}),r.jsx("pre",{className:"mcp-snippet",children:h}),r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>d(h),children:o?"Copied":"Copy"})]})}const Il="suveren-setup-ai-skipped",Al="suveren-setup-agent-done",Pl="suveren-setup-dismissed",fx={"hap-setup-ai-skipped":Il,"hap-setup-agent-done":Al,"hap-setup-dismissed":Pl};function mx(){for(const[n,s]of Object.entries(fx)){const i=localStorage.getItem(n);i!==null&&localStorage.getItem(s)===null&&localStorage.setItem(s,i),i!==null&&localStorage.removeItem(n)}}mx();function hx({aiConfigured:n,hasRunningIntegration:s,hasActiveAuth:i,hasAgentConnected:o,mcpEndpoint:c}){const[d,h]=f.useState(()=>localStorage.getItem(Il)==="true"),[g,p]=f.useState(()=>localStorage.getItem(Al)==="true"),[y,v]=f.useState(()=>localStorage.getItem(Pl)==="true"),[j,w]=f.useState(null),N=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status:n?"done":d?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:s?"done":"pending"},{label:"Give your agent a mandate",to:"/mandates?new=1",status:i?"done":"pending"},{label:"Connect your agent",status:o||g?"done":"pending"}],E=N.filter(P=>P.status==="done"||P.status==="skipped").length,k=E===N.length,C=f.useCallback(()=>{localStorage.setItem(Il,"true"),h(!0)},[]),T=f.useCallback(()=>{localStorage.setItem(Al,"true"),p(!0),w(null)},[]),I=f.useCallback(()=>{localStorage.setItem(Pl,"true"),v(!0)},[]);if(y||k)return null;const $=N.findIndex(P=>P.status==="pending");return r.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[r.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),r.jsx("button",{onClick:I,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:N.map((P,D)=>{const K=D===$,V=P.status==="done"||P.status==="skipped"?"●":"○",ce=P.status==="done"?"var(--success)":P.status==="skipped"?"var(--text-tertiary)":K?"var(--accent)":"var(--text-tertiary)";return r.jsxs("div",{children:[r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:K?"0.75rem":"0.25rem 0",borderRadius:K?"0.5rem":void 0,background:K?"var(--accent-subtle)":void 0},children:[r.jsx("span",{style:{color:ce,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:V}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[P.to&&P.status==="pending"?r.jsx(yt,{to:P.to,style:{fontSize:"0.9rem",fontWeight:K?600:500,color:K?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:P.label}):P.status==="pending"&&D===3?r.jsx("button",{onClick:()=>w(j===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:K?600:500,color:K?"var(--accent)":"var(--text-primary)"},children:P.label}):r.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:P.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:P.label}),P.optional&&P.status==="pending"&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),P.status==="skipped"&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),P.detail&&P.status==="pending"&&K&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:P.detail})]}),P.optional&&P.status==="pending"&&r.jsx("button",{onClick:C,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),P.to&&P.status==="pending"&&r.jsx(yt,{to:P.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),D===3&&j===3&&r.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[r.jsx(Rl,{mcpEndpoint:c}),r.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:T,children:"Done"})]})]},D)})}),r.jsxs("div",{style:{marginTop:"1.25rem"},children:[r.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:r.jsx("div",{style:{height:"100%",width:`${E/N.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),r.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[E," of ",N.length," complete"]})]})]})}function $m(n,s=null){const i=[n.hasContact,n.hasDelegationMandate,n.delegationProposalCount>0],o=i.every(Boolean),c=n.otherMandateCount===0&&!o,d=i.findIndex(y=>!y),h=s!==null&&i[s]===!1?s:d,g=n.managed?"managed":"self",p=y=>i[y]?{status:"done"}:y!==h?{status:"todo"}:y===1?{status:"open",variant:g,simulationOn:n.simulationOn}:y===0?{status:"open",variant:g}:{status:"open"};return{visible:c,step1:p(0),step2:p(1),step3:p(2)}}const px="/mandates?new=1&profile=delegation";function gf({text:n}){const[s,i]=f.useState(!1),o=f.useCallback(async()=>{try{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),2e3)}catch{}},[n]);return r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:o,children:s?"Copied":"Copy"})}function wl({todo:n,onOpen:s,children:i}){return n?r.jsx("button",{type:"button",className:"flow-step-title flow-todo-title flow-step-open-btn",onClick:s,children:i}):r.jsx("span",{className:"flow-step-title",children:i})}function gx({contact:n,hasDelegationMandate:s,otherMandateCount:i,delegationProposalCount:o,managed:c,simulationOn:d,mcpEndpoint:h}){const g={hasContact:n!==null,hasDelegationMandate:s,otherMandateCount:i,delegationProposalCount:o,managed:c,simulationOn:d},[p,y]=f.useState(null),v=$m(g,p);if(!v.visible)return null;const j=`Please connect to the Suveren gateway: MCP server at ${h}/mcp`;return r.jsxs("div",{className:"card setup-card",children:[r.jsx("h2",{className:"card-title",children:"Get started"}),r.jsx("p",{className:"setup-intro",children:"You decide what your AI can do — it acts only within that. Every action that changes something gets a signed ticket."}),r.jsxs("div",{className:"flow-step",children:[r.jsxs("div",{className:"flow-step-head",children:[r.jsx("span",{className:`flow-step-marker flow-${v.step1.status==="open"?"open":v.step1.status==="done"?"done":"todo"}`,children:v.step1.status==="done"?"✓":"1"}),v.step1.status==="done"&&n?r.jsxs("span",{className:"flow-step-title flow-done-title",children:[n.clientName," connected · last contact ",Nm(Date.parse(n.lastSeenAt),Date.now()).toLowerCase()]}):r.jsx(wl,{todo:v.step1.status==="todo",onOpen:()=>y(0),children:"Connect your AI"})]}),v.step1.status==="open"&&r.jsx("div",{className:"flow-step-body",children:v.step1.variant==="managed"?r.jsxs(r.Fragment,{children:[r.jsx("p",{children:"Your IT sets up the connection. Open your AI — if Suveren isn't there, contact your IT."}),r.jsxs("details",{className:"int-details",children:[r.jsx("summary",{children:"For your IT"}),r.jsx("div",{style:{marginTop:"0.75rem"},children:r.jsx(Rl,{mcpEndpoint:h})})]})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{children:"Ask your AI to connect to Suveren. Copy this into it:"}),r.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.75rem"},children:r.jsxs("div",{className:"quote-box",children:[r.jsx("span",{className:"quote-text",children:j}),r.jsx(gf,{text:j})]})}),r.jsx("p",{className:"cta-helper",style:{marginTop:0,marginBottom:"0.75rem"},children:"If your AI can't add it itself, it will tell you how. In ChatGPT, use a local session."}),r.jsxs("details",{className:"int-details",children:[r.jsx("summary",{children:"Set it up by hand"}),r.jsx("div",{style:{marginTop:"0.75rem"},children:r.jsx(Rl,{mcpEndpoint:h})})]})]})})]}),r.jsxs("div",{className:"flow-step",children:[r.jsxs("div",{className:"flow-step-head",children:[r.jsx("span",{className:`flow-step-marker flow-${v.step2.status==="open"?"open":v.step2.status==="done"?"done":"todo"}`,children:v.step2.status==="done"?"✓":"2"}),v.step2.status==="done"?r.jsxs("span",{className:"flow-step-title flow-done-title",children:["Delegation mandate given · ",r.jsx(yt,{to:"/mandates",children:"review or revoke under Mandates"})]}):r.jsx(wl,{todo:v.step2.status==="todo",onOpen:()=>y(1),children:"Give the Delegation mandate"})]}),v.step2.status==="open"&&r.jsxs("div",{className:"flow-step-body",children:[r.jsx("p",{children:"Delegation lets your AI propose the rest of its own setup — new mandates and its working instructions. It can only propose; nothing changes until you approve it."}),r.jsxs("ul",{className:"bound-list",children:[r.jsx("li",{children:"Read the setup guides"}),r.jsx("li",{children:"Propose new mandates — each waits for your approval"}),r.jsx("li",{children:"Propose an updated agent brief — also waits for your approval"})]}),v.step2.simulationOn?r.jsxs(r.Fragment,{children:[r.jsx(yt,{to:px,className:"btn btn-primary",children:"Give the Delegation mandate →"}),r.jsx("p",{className:"cta-helper",children:"You set the daily limit in the next step."}),v.step2.variant==="managed"&&r.jsx("p",{className:"managed-note",children:"In a company team you may need approver rights — ask your IT if the button is refused."})]}):r.jsx("p",{className:"managed-note",style:{marginTop:0},children:v.step2.variant==="managed"?"Delegation works in simulation mode only. Ask your IT to turn on simulation mode.":r.jsxs(r.Fragment,{children:["Delegation works in simulation mode only. Turn it on with ",r.jsx("code",{children:"suveren-gateway simulation on"})," and restart."]})})]})]}),r.jsxs("div",{className:"flow-step",children:[r.jsxs("div",{className:"flow-step-head",children:[r.jsx("span",{className:`flow-step-marker flow-${v.step3.status==="open"?"open":"todo"}`,children:"3"}),r.jsx(wl,{todo:v.step3.status==="todo",onOpen:()=>y(2),children:"Ask your AI: “How do I start with Suveren?”"})]}),v.step3.status==="open"&&r.jsxs("div",{className:"flow-step-body",children:[r.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.875rem"},children:r.jsxs("div",{className:"quote-box",children:[r.jsx("span",{className:"quote-text",children:"“How do I start with Suveren?”"}),r.jsx(gf,{text:"How do I start with Suveren?"})]})}),r.jsxs("p",{children:["It will interview you, suggest test data, and propose mandates and a brief. Approve its proposals under ",r.jsx(yt,{to:"/approvals",children:"Approvals"}),"."]})]})]})]})}function yx(){const[n,s]=f.useState(null);return f.useEffect(()=>{let i=!1;return fetch("/health").then(o=>o.json()).then(o=>{!i&&typeof o.mcpPort=="number"&&s(`http://localhost:${o.mcpPort}`)}).catch(()=>{}),()=>{i=!0}},[]),n}function vx(n){if(!n||typeof n!="object")return{simulation:null,locked:!1};const s=Array.isArray(n.policyLocked)&&n.policyLocked.includes("simulation");return{simulation:typeof n.simulation=="boolean"?n.simulation:null,locked:s}}function zm(){const[n,s]=f.useState({simulation:null,locked:!1});return f.useEffect(()=>{let i=!1;return fetch("/health").then(o=>o.json()).then(o=>{i||s(vx(o))}).catch(()=>{}),()=>{i=!0}},[]),n}function xx(n){return!n||typeof n!="object"?!1:Array.isArray(n.policyLocked)&&n.policyLocked.length>0}function wx(){const[n,s]=f.useState(!1);return f.useEffect(()=>{let i=!1;const o=()=>{fetch("/health").then(h=>h.json()).then(h=>{i||s(xx(h))}).catch(()=>{})};o();const c=setInterval(o,3e4),d=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",d),()=>{i=!0,clearInterval(c),document.removeEventListener("visibilitychange",d)}},[]),n}function wr({variant:n="base",style:s,className:i,...o}){const c=n==="title"?"skeleton skeleton-title":n==="line"?"skeleton skeleton-line":n==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return r.jsx("span",{className:`${c}${i?` ${i}`:""}`,style:s,role:"status","aria-busy":"true","aria-label":o["aria-label"]??"Loading"})}function jl(){return r.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[r.jsx(wr,{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",flexShrink:0}}),r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.35rem"},children:[r.jsx(wr,{variant:"line",style:{width:"35%"}}),r.jsx(wr,{variant:"line-sm",style:{width:"65%"}})]})]})}function jx(){const[n,s]=f.useState([]);return Zt(async()=>{try{const{skipped:o}=await B.getSkippedCommitments();s(o)}catch{}},3e4),n.length===0?null:r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1.5rem",borderLeft:"3px solid var(--warn, #b58900)"},children:[r.jsxs("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:["Approved, but not run here (",n.length,")"]}),r.jsx("p",{style:{margin:"0.5rem 0 1rem",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"These were approved, but this gateway has no local record of asking for them — usually because a different device/installation of yours submitted them, or its local record is gone. Re-run the same request on this gateway to execute it here."}),r.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",fontSize:"0.9rem"},children:n.map(o=>r.jsxs("li",{style:{marginBottom:"0.35rem"},children:[r.jsx("code",{children:o.tool})," ",r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",o.id,")"]})]},o.id))})]})}function Sx(n,s){return s&&!Vs(n.manifest)}function kx(n,s=!1){var o;const i=[];for(const c of n)Sx(c,s)||(c.state==="error"?i.push({label:"Integration error",detail:(o=c.integration)!=null&&o.error?`${c.manifest.name}: ${c.integration.error}`:`${c.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"}):c.state==="not-running"&&(Vs(c.manifest)?i.push({label:`${c.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--danger)"}):i.push({label:"Integration stopped",detail:`${c.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"})));return i}function bx(n){const s=n.filter(i=>i.state==="paused");return s.length===0?null:{count:s.length,namesText:s.map(i=>i.manifest.name).join(", ")}}const Nx=1800;function Gr(n){return n.replace(/@.*$/,"").split("/").pop()??n}function Cx(){const{domain:n}=vt(),[s,i]=f.useState([]),[o,c]=f.useState([]),[d,h]=f.useState([]),[g,p]=f.useState(!0),[y,v]=f.useState(!1),[j,w]=f.useState([]),[N,E]=f.useState(!1),[k,C]=f.useState(!1),[T,I]=f.useState(null),[$,P]=f.useState(!1),{entries:D,activeSessions:K,loading:V}=rc(),ce=yx(),Y=!V,{simulation:re}=zm(),J=re===!0,O=wx(),fe=f.useCallback(()=>{B.getMyAttestations().then(se=>{i(se),v(!0)}).catch(()=>v(!0)),B.getArchivedMandates().then(w).catch(()=>w([])),B.getMyProposals(n).then(se=>{c(se),E(!0)}).catch(()=>E(!0)),B.getProposalsForApprover().then(se=>h(se)).catch(()=>h([])),B.getCredential("ai-config").then(se=>{p(se.configured),C(!0)}).catch(()=>C(!0)),B.getAgentContact().then(se=>{I(se.contact),P(!0)}).catch(()=>P(!0))},[n]);He("attestation-changed",fe),He("proposal-added",fe),He("proposal-resolved",fe),He("proposal-approved",fe),He("proposal-rejected",fe),Zt(fe,3e5,n);const ie=y&&N&&k&&Y&&$&&re!==null,Z=km(s,{archivedSet:new Set(j)}),pe=Z.active,ee=Z.expired,W=pe.some(se=>Gr(se.profile_id)==="delegation"),M=pe.filter(se=>Gr(se.profile_id)!=="delegation").length,H=o.filter(se=>Gr(se.profileId)==="delegation").length,S=$m({hasContact:T!==null,hasDelegationMandate:W,otherMandateCount:M,delegationProposalCount:H,managed:O,simulationOn:J}),A=J&&S.visible,G=pe.filter(se=>se.remaining_seconds!==null&&se.remaining_seconds<=Nx),te=o.filter(Rm),ue=D.filter(se=>se.state==="running"),ve=D.filter(se=>se.state==="starting"),Ce=bx(D),ke=[];for(const se of d)ke.push({label:"Approval needed",detail:`${se.tool} — above-cap action under ${Gr(se.profileId)}`,to:"/approvals",color:"var(--warning)"});for(const se of te)ke.push({label:"Approval pending",detail:`${se.tool} awaiting your approval`,to:"/approvals",color:"var(--warning)"});for(const se of G){const $e=Math.ceil((se.remaining_seconds??0)/60);ke.push({label:"Expiring soon",detail:`${se.title??Gr(se.profile_id)} — ${$e} min remaining`,to:"/mandates",color:"var(--warning)"})}for(const se of ee)ke.push({label:"Expired",detail:se.title??Gr(se.profile_id),to:"/mandates",color:"var(--danger)"});ke.push(...kx(D,J));for(const se of ve)ke.push({label:"Integration starting",detail:`${se.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const se of D)se.authStatus==="failed"&&se.state!=="not-running"&&se.state!=="error"&&se.state!=="paused"&&ke.push({label:"Reconnect needed",detail:`${se.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return g||ke.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Dashboard"})}),ie&&ce&&(A?r.jsx(gx,{contact:T,hasDelegationMandate:W,otherMandateCount:M,delegationProposalCount:H,managed:O,simulationOn:J,mcpEndpoint:ce}):!J&&r.jsx(hx,{aiConfigured:g,hasRunningIntegration:ue.length>0,hasActiveAuth:pe.length>0,hasAgentConnected:K>0,mcpEndpoint:ce})),!A&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(8rem, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[r.jsx(yt,{to:"/mandates",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[y?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:pe.length>0?"var(--success)":"var(--text-tertiary)"},children:pe.length}):r.jsx(wr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),r.jsx(yt,{to:"/approvals",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[N?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:te.length>0?"var(--warning)":"var(--text-tertiary)"},children:te.length}):r.jsx(wr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),r.jsx(yt,{to:"/mandates",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[y?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:ee.length>0?"var(--danger)":"var(--text-tertiary)"},children:ee.length}):r.jsx(wr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),r.jsx(yt,{to:"/integrations",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[Y?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:ue.length>0?"var(--success)":"var(--text-tertiary)"},children:ue.length}):r.jsx(wr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),r.jsxs("section",{className:"card attention","aria-label":"Needs your attention",children:[r.jsxs("div",{className:"card-header",children:[r.jsx("h2",{className:"card-title",children:"Needs your attention"}),ke.length>0&&r.jsx("span",{className:"rb-count",children:ke.length})]}),ke.length>0?r.jsx("div",{className:"attention-rows",children:ke.map((se,$e)=>r.jsxs(yt,{to:se.to,className:"attention-row",children:[r.jsx("span",{className:"attention-dot",style:{background:se.color},"aria-hidden":"true"}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:se.label}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:se.detail})]}),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},$e))}):ie?r.jsxs("div",{className:"all-clear",children:[r.jsx("span",{className:"rb-mark","aria-hidden":"true",children:r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M20 6 9 17l-5-5"})})}),r.jsx("h3",{children:"All clear"}),r.jsx("p",{children:"Nothing needs your attention."})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[r.jsx(jl,{}),r.jsx(jl,{}),r.jsx(jl,{})]})]})]}),Ce&&r.jsxs("div",{className:"sim-paused-summary",role:"status",children:[r.jsx("span",{className:"sim-paused-summary-icon","aria-hidden":"true",children:"⏸"}),r.jsxs("span",{children:[r.jsxs("b",{children:[Ce.count," real system",Ce.count===1?"":"s"," ",Ce.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",Ce.namesText,"."]})]}),r.jsx(jx,{}),r.jsx(bv,{})]})}const Ex=["Scope & Limits","Intent","Sign"];function Fm({currentStep:n,onStepClick:s}){const i=dn();return r.jsxs("div",{className:"wizard-progress",children:[r.jsx("ol",{className:"wizard-steps",children:Ex.map((o,c)=>{const d=c+2,h=d<n,g=d===n,p=d-1<n,y=h&&!!s;return r.jsxs("li",{className:`wizard-step${p?" reached":""}`,"aria-current":g?"step":void 0,children:[r.jsx("button",{type:"button",className:`step-circle${h?" completed":""}${g?" current":""}`,onClick:y?()=>s(d):void 0,disabled:!y,"aria-label":`${o}${h?" (done)":g?" (current)":""}`,children:h?"✓":c+1}),r.jsx("span",{className:`step-label-text${g?" current":h?" completed":""}`,children:o})]},d)})}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>i("/mandates?new=1"),children:"Cancel"})]})}const yf=40,Tx={delegation:"Delegation"};function dt(n,s){const i=n.lastIndexOf("/"),o=i>=0?n.slice(i+1):n,c=o.indexOf("@"),d=c>=0?o.slice(0,c):o,h=Tx[d.toLowerCase()];return h||(s?s.slice(0,yf):(d.charAt(0).toUpperCase()+d.slice(1)).slice(0,yf))}function Rx({profileId:n,bounds:s,groupName:i,domain:o,onSwitch:c}){return r.jsxs("div",{className:"context-strip",children:[i&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"context-strip-label",children:"Team:"}),r.jsxs("span",{children:[r.jsx("strong",{children:i}),o?` / ${o}`:""]})]}),n&&r.jsxs("span",{children:[r.jsx("strong",{children:"Profile:"})," ",dt(n)]}),s&&r.jsxs("span",{children:[r.jsx("strong",{children:"Bounds:"})," ",s]}),c&&r.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:c,children:"Switch"})]})}function Ix({integrationId:n,field:s,value:i,onChange:o,disabled:c,onLabels:d}){const[h,g]=f.useState(null),[p,y]=f.useState(null),[v,j]=f.useState(!0);f.useEffect(()=>{let E=!1;return B.discoverScopeField(n,s).then(k=>{var C;E||(g(k.options),j(!1),(C=k.options)!=null&&C.length&&(d==null||d(Object.fromEntries(k.options.map(T=>[T.value,T.label])))))}).catch(k=>{E||(y(k instanceof Error?k.message:String(k)),j(!1))}),()=>{E=!0}},[n,s]);const w=new Set(i.split(",").map(E=>E.trim()).filter(Boolean)),N=E=>{const k=new Set(w);k.has(E)?k.delete(E):k.add(E),o(Array.from(k).join(","))};return v?r.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",n,"…"]}):p||!h?r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--warning)",marginBottom:"0.5rem"},children:["Couldn't fetch options (",p??"no response","). Enter values manually, separated by commas."]}),r.jsx("input",{className:"form-input",type:"text",value:i,onChange:E=>o(E.target.value),disabled:c})]}):h.length===0?r.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",n," for this field."]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:h.map(E=>{const k=E.extras??{},C=typeof k.access=="string"?k.access:void 0,T=C==="reader",I=k.primary===!0;return r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:T?"var(--text-tertiary)":"var(--text-primary)",cursor:c||T?"not-allowed":"pointer"},title:T?"Read-only — you can authorize list/read but not writes":void 0,children:[r.jsx("input",{type:"checkbox",checked:w.has(String(E.value)),onChange:()=>N(String(E.value)),disabled:c||T}),r.jsx("span",{children:E.label||E.value}),I&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),C&&r.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",C]})]},E.value)})})}function lc(n){if(n.type!=="number")return 0;const s=n.boundType,i=n.unit;return(s==null?void 0:s.kind)==="per_transaction"&&i==="count"?1:0}function Ax(n,s){if(s!==void 0)return String(s);const i=n.default;return typeof i=="string"||typeof i=="number"&&Number.isFinite(i)?String(i):lc(n)===1?"1":""}function Om(n){const s=n.maximum;return typeof s=="number"&&Number.isFinite(s)?s:void 0}function vf(n,s){const i=lc(n),o=Om(n),c=s===""?i:Math.max(i,Number(s));return o!==void 0?Math.min(o,c):c}function cc(n){return!n||n==="count"?"":n==="minutes"?"min":n==="hours"?"hr":n==="days"?"days":n==="percent"?"%":n.startsWith("currency:")?n.slice(9):n}function Px(n){return n.replace(/@.*$/,"").split("/").pop()??n}function _x(n,s){return s.displayName?s.displayName:n.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function Lx(n){return n.type==="string"&&(n.format==="email"||n.format==="domain")}function $x(n){var i;const s=n;return!!(s.enum&&((i=s.constraint)!=null&&i.enforceable.includes("subset")))}function xf(n,s){const i=n.trim();return i?s==="email"?i.includes("@")&&i.indexOf(".",i.indexOf("@"))>-1:s==="domain"?i.includes(".")&&!i.includes("@"):!0:!1}function zx(n){return n?n==="minutes"?15:n==="percent"?5:n.startsWith("currency:")?10:1:1}function Fx(n){return n?n==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:n==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:n==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:n==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:n.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function Ox(n,s){if(!n||!s)return"";const i=Number(n);if(!Number.isFinite(i)||i<=0)return"";if(s==="minutes"&&i>=60){const o=Math.floor(i/60),c=i%60;return c===0?`${o} hour${o!==1?"s":""}`:`${o}h ${c}m`}if(s==="hours"&&i>=24&&i%24===0){const o=i/24;return`${o} day${o!==1?"s":""}`}if(s==="days"){if(i>=30&&i%30===0)return`${i/30} month${i/30!==1?"s":""}`;if(i>=7&&i%7===0)return`${i/7} week${i/7!==1?"s":""}`}return""}function Mx({id:n,value:s,onChange:i,disabled:o,placeholder:c,unit:d,min:h=0,max:g}){const p=zx(d),y=Fx(d).filter(k=>g===void 0||k.value<=g),v=cc(d),j=Ox(s,d),w=s===""?null:Number(s),N=()=>{const k=s===""?0:Number(s),C=k%p,T=C===0?k+p:k+(p-C);i(String(g!==void 0?Math.min(g,T):T))},E=()=>{const k=s===""?0:Number(s);if(k<=h)return;const C=k%p,T=C===0?k-p:k-C;i(String(Math.max(h,T)))};return r.jsxs("div",{className:"bounded-input",children:[r.jsxs("div",{className:"bounded-input-field",children:[r.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:E,disabled:o||s===""||Number(s)<=h,"aria-label":"Decrease",children:"−"}),r.jsx("input",{id:n,className:"stepper-input",type:"number",min:h,max:g,step:p,value:s,placeholder:c??String(h),onChange:k=>{const C=k.target.value;i(g!==void 0&&C!==""&&Number(C)>g?String(g):C)},onFocus:k=>k.target.select(),disabled:o}),r.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:N,disabled:o||g!==void 0&&s!==""&&Number(s)>=g,"aria-label":"Increase",children:"+"}),v&&r.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:v})]}),y.length>0&&!o&&r.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:y.map(k=>r.jsx("button",{type:"button",className:`preset-chip${w===k.value?" preset-chip-selected":""}`,onClick:()=>i(String(k.value)),children:k.label},k.value))}),j&&r.jsxs("div",{className:"bounded-input-echo",children:["≈ ",j]})]})}function wf({htmlFor:n,label:s,description:i}){const[o,c]=f.useState(!1);return r.jsxs("div",{className:"field-label-with-tip",children:[r.jsx("label",{className:"form-label",htmlFor:n,children:s}),i&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${s}" mean?`,"aria-expanded":o,onClick:()=>c(d=>!d),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onBlur:()=>c(!1),children:"i"}),o&&r.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:i})]})]})}function Bx({id:n,value:s,onChange:i,disabled:o,format:c,placeholder:d}){const[h,g]=f.useState(""),[p,y]=f.useState(!1),v=f.useRef(null),j=s?s.split(",").map(T=>T.trim()).filter(Boolean):[],w=T=>{const I=T.trim();if(!I)return;if(!xf(I,c)){y(!0);return}y(!1);const $=j.includes(I)?j:[...j,I];i($.join(",")),g("")},N=T=>{const I=j.filter(($,P)=>P!==T);i(I.join(","))},E=T=>{T.key==="Enter"||T.key===","||T.key==="Tab"?h.trim()&&(T.preventDefault(),w(h)):T.key==="Backspace"&&!h&&j.length>0&&N(j.length-1)},k=T=>{const I=T.clipboardData.getData("text");if(I.includes(",")){T.preventDefault();const P=I.split(",").map(K=>K.trim()).filter(Boolean).filter(K=>xf(K,c)),D=[...new Set([...j,...P])];i(D.join(",")),g(""),y(!1)}},C=c==="email"?"Type email and press Enter...":"Type domain and press Enter...";return r.jsxs("div",{className:`tag-input${p?" tag-input-invalid":""}`,onClick:()=>{var T;return(T=v.current)==null?void 0:T.focus()},children:[j.map((T,I)=>r.jsxs("span",{className:"tag-pill",children:[T,!o&&r.jsx("button",{type:"button",className:"tag-remove",onClick:$=>{$.stopPropagation(),N(I)},"aria-label":`Remove ${T}`,children:"×"})]},T)),!o&&r.jsx("input",{ref:v,id:n,className:"tag-input-field",type:"text",value:h,onChange:T=>{g(T.target.value),y(!1)},onKeyDown:E,onPaste:k,onBlur:()=>{h.trim()&&w(h)},placeholder:j.length===0?d??C:""})]})}function Dx({id:n,options:s,value:i,onChange:o,disabled:c}){const d=i?i.split(",").map(g=>g.trim()).filter(Boolean):[],h=g=>{const p=d.includes(g)?d.filter(y=>y!==g):[...d,g];o(p.join(","))};return r.jsx("div",{className:"checkbox-group",id:n,children:s.map(g=>r.jsxs("label",{className:`checkbox-pill${d.includes(g)?" checkbox-pill-selected":""}`,children:[r.jsx("input",{type:"checkbox",checked:d.includes(g),onChange:()=>h(g),disabled:c}),r.jsx("span",{children:g})]},g))})}function jf({fieldKey:n,fieldDef:s,value:i,onChange:o,prefix:c,readOnly:d,twoColumn:h,discoveryIntegrationId:g,onLabels:p}){const y=_x(n,s),v=`${c}-field-${n}`,j=r.jsx(r.Fragment,{children:$x(s)?r.jsx(Dx,{id:v,options:s.enum,value:i,onChange:w=>o(n,w),disabled:d}):(()=>{const w=s.boundType;return(w==null?void 0:w.kind)==="enum"&&Array.isArray(w.values)})()?r.jsxs("select",{id:v,className:"form-select",value:i,onChange:w=>o(n,w.target.value),disabled:d,children:[r.jsx("option",{value:"",children:"Select..."}),s.boundType.values.map(w=>r.jsx("option",{value:w,children:w},w))]}):s.enum?r.jsxs("select",{id:v,className:"form-select",value:i,onChange:w=>o(n,w.target.value),disabled:d,children:[r.jsx("option",{value:"",children:"Select..."}),s.enum.map(w=>r.jsx("option",{value:w,children:w},w))]}):s.type==="number"?r.jsx(Mx,{id:v,value:i,onChange:w=>o(n,w),disabled:d,unit:s.unit,min:lc(s),max:Om(s)}):Lx(s)?r.jsx(Bx,{id:v,value:i,onChange:w=>o(n,w),disabled:d,format:s.format}):g?r.jsx(Ix,{integrationId:g,field:n,value:i,onChange:w=>o(n,w),disabled:d,onLabels:w=>p==null?void 0:p(n,w)}):r.jsx("input",{id:v,className:"form-input",type:"text",value:i,onChange:w=>o(n,w.target.value),disabled:d})});return h?r.jsxs("div",{className:"bounds-field-row",children:[r.jsx("div",{className:"bounds-field-label",children:r.jsx(wf,{htmlFor:v,label:y,description:s.description})}),r.jsx("div",{className:"bounds-field-input",children:j})]},`${c}-${n}`):r.jsxs("div",{className:"form-group",children:[r.jsx(wf,{htmlFor:v,label:y,description:s.description}),j]},`${c}-${n}`)}function Ux(n,s){if(!s)return"no-config";const i=s.caps,o=Array.isArray(s.approvers)&&s.approvers.length>0;if(!(i&&Object.keys(i).length>0))return o?"approvers-dormant":"no-config";let d=!1;for(const[h,g]of Object.entries(i)){const p=n[h];if(p===""||p===void 0)continue;const y=Number(p);if(!isNaN(y)&&y>g){d=!0;break}}return d?o?"above-approvers":"hard-ceiling":"within-cap"}function Wx(n,s){const i=new Set;if(!s)return i;for(const[o,c]of Object.entries(s)){const d=n[o];if(d===""||d===void 0)continue;const h=Number(d);!isNaN(h)&&h>c&&i.add(o)}return i}function Hx({profile:n,onConfirm:s,onCancel:i,readOnly:o,initialBounds:c,initialContext:d,initialFrame:h,profileConfig:g,approverNames:p,adminName:y}){const v=n.boundsSchema,j=n.scopeSchema,w=v?Object.entries(v.fields).filter(([S,A])=>!(S==="profile"||S==="path"||A.enforced===!1||A.enforcedBy==="gatekeeper")):[],N=v?Object.entries(v.fields).filter(([,S])=>S.enforcedBy==="gatekeeper").filter(([,S])=>S.enforced!==!1).map(([S,A])=>A.displayName??S):[],E=j&&j.keyOrder.length>0?Object.entries(j.fields):[],k=c??h??{},C=d??{},T={};for(const[S,A]of w)T[S]=Ax(A,k[S]);const I={};for(const[S]of E)I[S]=C[S]!==void 0?String(C[S]):"";const[$,P]=f.useState(T),[D,K]=f.useState(I),[V,ce]=f.useState({}),[Y,re]=f.useState(null);f.useEffect(()=>{const S=Px(n.id);B.getIntegrationManifests().then(({manifests:A})=>{const G=A.find(te=>te.profile===S&&te.contextDiscovery&&Object.keys(te.contextDiscovery).length>0);re(G??null)}).catch(()=>re(null))},[n.id]);const J=Ux($,g),O=Wx($,g==null?void 0:g.caps),fe=(S,A)=>{P(G=>({...G,[S]:A}))},ie=(S,A)=>{K(G=>({...G,[S]:A}))},Z=()=>{const S={profile:n.id};for(const[G,te]of w)te.type==="number"?S[G]=vf(te,$[G]):S[G]=$[G];const A={};for(const[G,te]of E)te.type==="number"?A[G]=D[G]===""?0:Number(D[G]):A[G]=D[G];return[S,A]},pe=()=>{const[S,A]=Z();s(S,A,V)},ee=()=>{const S=(g==null?void 0:g.caps)??{},A={...$};for(const ue of O)S[ue]!==void 0&&(A[ue]=String(S[ue]));P(A);const G={profile:n.id};for(const[ue,ve]of w)ve.type==="number"?G[ue]=vf(ve,A[ue]??""):G[ue]=A[ue]??"";const te={};for(const[ue,ve]of E)ve.type==="number"?te[ue]=D[ue]===""?0:Number(D[ue]):te[ue]=D[ue];s(G,te,V)},W=S=>{const A=g==null?void 0:g.caps;if(!A||A[S]===void 0)return null;const G=A[S],te=O.has(S);return J==="hard-ceiling"&&te?r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",G," — exceeds team ceiling"]}):J==="above-approvers"&&te?r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",G," — above cap"]}):r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",G," ok"]})},M=()=>{var S;if(J==="no-config")return null;if(J==="approvers-dormant"){const A=p&&p.length>0?p.join(", "):"the configured approvers";return r.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--accent)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[r.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",A]}),r.jsxs("div",{children:["No caps are set on this profile, so ",A," won't gate any action under this mandate. Your intent will still be encrypted and shared with them as an accountability record — they can read what you authorised, even though they aren't reviewing individual actions."]})]})}if(J==="within-cap")return r.jsx("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--border)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:r.jsx("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:"Within all team caps — your responsibility."})});if(J==="above-approvers"){const A=p&&p.length>0?p.join(", "):"the required approvers";return r.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--warning)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[r.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.25rem"},children:"Above team cap."}),r.jsxs("div",{children:[r.jsx("strong",{children:"Over-cap actions"})," will require approval from you and ",A,". Within-cap actions run per the mode you choose."]})]})}if(J==="hard-ceiling"){const A=Array.from(O)[0],G=A?(S=g==null?void 0:g.caps)==null?void 0:S[A]:void 0,te=y??"the team admin";return r.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--danger)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[r.jsx("div",{style:{fontWeight:600,color:"var(--danger)",marginBottom:"0.25rem"},children:"Hard team ceiling."}),r.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Team policy caps this at ",G??"the configured limit",". Lower your bound or ask ",te," to add an approver path above the cap."]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ee,children:"Save below cap"}),i&&r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:i,children:"Cancel"})]})]})}return null},H=J==="hard-ceiling";return r.jsxs("div",{children:[E.length>0&&r.jsxs("div",{className:"context-section",children:[r.jsxs("div",{className:"bounds-section-header",children:[r.jsx("span",{className:"bounds-section-icon",children:"🛡"}),r.jsxs("div",{children:[r.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),r.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the Authority Server"})]})]}),E.map(([S,A])=>{var te;const G=!!((te=Y==null?void 0:Y.contextDiscovery)!=null&&te[S]);return r.jsx(jf,{fieldKey:S,fieldDef:A,value:D[S],onChange:ie,prefix:"context",readOnly:o,discoveryIntegrationId:G?Y.id:void 0,onLabels:(ue,ve)=>ce(Ce=>({...Ce,[ue]:ve}))},`context-${S}`)})]}),w.length>0&&r.jsxs("div",{className:"bounds-section",children:[r.jsxs("div",{className:"bounds-section-header",children:[r.jsx("span",{className:"bounds-section-icon",children:"🔒"}),r.jsxs("div",{children:[r.jsx("div",{className:"bounds-section-title",children:"Limits"}),r.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Authority Server"})]})]}),r.jsx("div",{className:"bounds-fields-grid",children:w.map(([S,A])=>{var G;return r.jsxs("div",{style:{display:"contents"},children:[r.jsx(jf,{fieldKey:S,fieldDef:A,value:$[S],onChange:fe,prefix:"bounds",readOnly:o,twoColumn:!0}),J!=="no-config"&&((G=g==null?void 0:g.caps)==null?void 0:G[S])!==void 0&&r.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:W(S)})]},`bounds-${S}`)})}),M(),N.length>0&&r.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[N.join(", ")," ",N.length===1?"is":"are"," set on the integration, not here — reads are checked on this device, so the limit applies immediately and can be changed any time under"," ",r.jsx(yt,{to:"/integrations",children:"Integrations"}),"."]})]}),r.jsx("button",{className:"btn btn-primary",onClick:pe,disabled:H,style:{marginTop:"0.5rem"},children:o?"Next: Gates":"Next: Problem Statement"})]})}function Vx(n){var i;const s=n.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((i=s==null?void 0:s[1])==null?void 0:i.trim())??null}function Gx(n){return n.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const Kx="Tell me what your agent should do — I'll help shape it. Or ask me to draft a full intent and we'll iterate.";function wi({target:n,currentText:s,onApply:i,greeting:o,placeholder:c,title:d}){const[h,g]=f.useState([{role:"assistant",content:o??Kx}]),[p,y]=f.useState(""),[v,j]=f.useState(!1),[w,N]=f.useState(null),E=f.useRef(null),k=f.useRef(null);f.useEffect(()=>{const I=E.current;if(!I)return;const $=h[h.length-1],P=k.current;!v&&($==null?void 0:$.role)==="assistant"&&h.length>1&&P?I.scrollTop=P.offsetTop:I.scrollTop=I.scrollHeight},[h,v]);const C=async()=>{const I=p.trim();if(!I||v)return;const $=[...h,{role:"user",content:I}];g($),y(""),N(null),j(!0);try{const P=await B.aiChat({target:n,currentText:s,messages:$.filter((D,K)=>!(K===0&&D.role==="assistant"))});P.success&&P.reply?g(D=>[...D,{role:"assistant",content:P.reply}]):N(P.error??"AI returned no reply")}catch(P){N(P instanceof Error?P.message:"Chat failed")}finally{j(!1)}},T=I=>{I.key==="Enter"&&!I.shiftKey&&!I.nativeEvent.isComposing&&(I.preventDefault(),C())};return r.jsxs("div",{className:"intent-chat",children:[r.jsx("h3",{className:"card-title",children:d??"AI Assistant"}),r.jsxs("div",{ref:E,className:"chat-messages",children:[h.map((I,$)=>{const P=I.role==="assistant"?Vx(I.content):null,D=P?Gx(I.content):I.content;return r.jsx("div",{className:`chat-msg ${I.role}`,ref:$===h.length-1?k:void 0,children:r.jsxs("div",{className:"chat-msg-body",children:[D&&r.jsx("div",{className:"chat-msg-prose",children:D}),P!==null&&r.jsxs(r.Fragment,{children:[r.jsx("pre",{className:"chat-fenced-block",children:P}),r.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>i(P),children:"Apply this draft"})]})]})},$)}),v&&r.jsx("div",{className:"chat-msg assistant",children:r.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),w&&r.jsx("div",{className:"error-message",children:w}),r.jsxs("div",{className:"chat-composer",children:[r.jsxs("div",{className:"chat-composer-pill",children:[r.jsx("textarea",{className:"chat-input",value:p,onChange:I=>y(I.target.value),onKeyDown:T,placeholder:c??"Ask for help articulating the intent…",rows:1,disabled:v}),r.jsx("button",{type:"button",className:"chat-send-btn",onClick:C,disabled:v||!p.trim(),"aria-label":"Send",children:"↑"})]}),r.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Mm({open:n,onClose:s,children:i,ariaLabel:o}){const c=f.useRef(null),d=f.useRef(null);return f.useEffect(()=>{var g;if(!n)return;d.current=document.activeElement,document.body.style.overflow="hidden";const h=p=>{p.key==="Escape"&&s()};return document.addEventListener("keydown",h),(g=c.current)==null||g.focus(),()=>{document.removeEventListener("keydown",h),document.body.style.overflow="",d.current instanceof HTMLElement&&d.current.focus()}},[n,s]),Qy.createPortal(r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`bottom-sheet-backdrop${n?" is-open":""}`,onClick:s,"aria-hidden":"true"}),r.jsxs("aside",{ref:c,className:`bottom-sheet${n?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":o,tabIndex:-1,children:[r.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),r.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:s,"aria-label":"Close",children:"×"}),i]})]}),document.body)}function Yx(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Jx(n,s,i){if(s.length===0)return[{text:n,label:n,matched:null}];const o=[],c=new Set;for(const p of s)if(!(!p.scope||p.scope==="all (unscoped)"))for(const y of[p.scope,...p.scope.split(",").map(v=>v.trim())]){const v=y.toLowerCase();y&&!c.has(v)&&(c.add(v),o.push(y))}o.sort((p,y)=>y.length-p.length);const d=p=>{const y=p.toLowerCase();return s.filter(v=>{var j,w;return((j=v.scope)==null?void 0:j.toLowerCase())===y||((w=v.scope)==null?void 0:w.split(",").map(N=>N.trim().toLowerCase()).includes(y))})},h=["\\[\\d+\\]",...o.map(Yx)],g=new RegExp(`(${h.join("|")})`,"gi");return n.split(g).filter(p=>p!=="").map(p=>{const y=/^\[(\d+)\]$/.exec(p);if(y){const v=s[Number(y[1])-1];if(v){const j=v.scope&&v.scope!=="all (unscoped)"?v.scope:"all recipients",w=i?`${i}: ${j}`:j;return{text:p,label:w,matched:[v]}}}else if(o.some(v=>v.toLowerCase()===p.toLowerCase())){const v=d(p);if(v.length>0)return{text:p,label:p,matched:v}}return{text:p,label:p,matched:null}})}const Sf=`Why — What's the situation? Why does this need to happen?
66
-
67
- Goal — What should the agent try to achieve?
68
-
69
- Watch out — What should the agent avoid or be careful about?`;function qx(n,s,i,o){return Jx(n,s,o).map((c,d)=>{if(!c.matched)return r.jsx("span",{children:c.text},d);const h=c.matched;return r.jsx("button",{type:"button",onClick:()=>i(h),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:c.label},d)})}function Qx(){var _e;const n=dn(),[s]=Xl(),i=Number(s.get("step"))||2,[o,c]=f.useState(null),[d,h]=f.useState(null),[g,p]=f.useState(i),[y,v]=f.useState(null),[j,w]=f.useState(null),[N,E]=f.useState({}),[k,C]=f.useState(Sf),[T,I]=f.useState(!1),[$,P]=f.useState(null),[D,K]=f.useState(!0),[V,ce]=f.useState(null),[Y,re]=f.useState([]),[J,O]=f.useState(void 0),[fe,ie]=f.useState(!1),[Z,pe]=f.useState(null),[ee,W]=f.useState(null),[M,H]=f.useState(null),[S,A]=f.useState([]),[G,te]=f.useState(null);f.useEffect(()=>{var Te;const me=sessionStorage.getItem("agentAuth");if(!me){n("/mandates?new=1");return}const X=JSON.parse(me);c(X),X.intentHint&&C(X.intentHint),B.getCredential("ai-config").then(Le=>P(Le.configured)).catch(()=>P(!1));const we=sessionStorage.getItem("agentGate");if(we){const Le=JSON.parse(we);Le.bounds&&v(Le.bounds),Le.context&&w(Le.context),(Te=Le.gateContent)!=null&&Te.intent&&C(Le.gateContent.intent)}B.getProfile(X.profileId).then(Le=>h(Le)).catch(()=>n("/mandates?new=1")).finally(()=>K(!1)),X.groupId&&Promise.all([B.getTeamProfileConfig(X.groupId,X.profileId).catch(()=>null),B.getGroupById(X.groupId).catch(()=>null),B.listUsers().catch(()=>[])]).then(([Le,lt,xt])=>{if(ce(Le),Le){const Ke=new Map;for(const Fe of xt){const L=Fe.name&&Fe.email?`${Fe.name} (${Fe.email})`:Fe.name||Fe.email||Fe.id;Ke.set(Fe.id,L)}const et=(lt==null?void 0:lt.members)??[];for(const Fe of et){const L=Fe.userId??Fe.id;L&&(Fe.name&&Fe.email?Ke.set(L,`${Fe.name} (${Fe.email})`):Fe.name&&Ke.set(L,Fe.name))}const st=(Le.approvers??[]).map(Fe=>Ke.get(Fe)??Fe);re(st);const ht=et.find(Fe=>Fe.role==="admin");if(ht){const Fe=ht.userId??ht.id;Fe&&O(Ke.get(Fe)??ht.name)}}})},[n]);const ue=y?Object.entries(y).filter(([me])=>me!=="profile"&&me!=="path").map(([me,X])=>`${me} = ${X}`).join(", "):"",ve=(me,X,we)=>{v(me),w(X),we&&E(we),p(3)},Ce=k.trim()!==Sf.trim()&&k.trim()!=="",ke=me=>{Ce&&!confirm("Replace your current intent with the AI draft?")||C(me)},se=()=>{const me=d==null?void 0:d.ttl,X={intent:k},we=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...we,bounds:y,context:j,contextLabels:N,gateContent:X,ttlConfig:me})),n("/mandates/new/sign")},$e=async()=>{if(o){ie(!0),pe(null),W(null),H(null),A([]),te(null);try{const me=await B.aiIntentReview({profileId:o.profileId,newIntent:k,context:j??void 0});A(me.grants??[]),me.success?me.review?pe(me.review):W(me.note??"No other mandates on this profile to compare against."):H(me.error??"Check failed.")}catch(me){H(me instanceof Error?me.message:"Check failed.")}finally{ie(!1)}}},Ee=me=>{C(me),(Z||ee||M)&&(pe(null),W(null),H(null),A([]),te(null))};return D||!o||!d?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):r.jsxs(r.Fragment,{children:[r.jsx(Fm,{currentStep:g,onStepClick:me=>{me>=2&&p(me)}}),r.jsx(Rx,{profileId:o.profileId,bounds:ue||void 0,groupName:o.groupName,domain:o.domain}),g===2&&r.jsx("div",{className:"card",children:r.jsx(Hx,{profile:d,onConfirm:ve,onCancel:()=>n("/mandates?new=1"),initialBounds:y||void 0,initialContext:j||void 0,profileConfig:V,approverNames:Y,adminName:J})}),g===3&&r.jsxs("div",{className:`intent-layout${$?"":" no-chat"}`,children:[$&&r.jsx("div",{className:"card intent-pane chat tool",children:r.jsx(wi,{target:{kind:"intent",profileId:o.profileId,bounds:ue||void 0},currentText:k,onApply:ke})}),r.jsxs("div",{className:"card intent-pane document",children:[r.jsx("h3",{className:"card-title",children:"What should your agent know?"}),r.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),r.jsx("textarea",{className:"intent-textarea",value:k,onChange:me=>Ee(me.target.value)}),r.jsxs("div",{className:"char-counter",children:[k.length," / 2000"]})]}),$===!1&&r.jsxs("p",{className:"intent-ai-hint",children:[r.jsx(yt,{to:"/settings",children:"Set up an AI assistant in Settings"})," to get help writing this."]}),$&&r.jsxs("div",{style:{marginTop:"0.5rem"},children:[r.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:$e,disabled:fe||!Ce,children:fe?"Checking…":"Check against my other grants"}),M&&r.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeftColor:"var(--danger)"},children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),r.jsx("div",{className:"hint-body",children:M})]}),ee&&r.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),r.jsx("div",{className:"hint-body",children:ee})]}),Z&&r.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),r.jsxs("div",{className:"hint-body",children:[r.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),r.jsx("div",{style:{whiteSpace:"pre-wrap"},children:qx(Z,S,te,dt(o.profileId))}),r.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),r.jsxs("div",{className:"intent-footer",children:[r.jsx("button",{className:"btn btn-ghost",onClick:()=>p(2),children:"Back"}),r.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:se,disabled:!Ce,children:"Continue to Review"})]}),(((_e=V==null?void 0:V.approvers)==null?void 0:_e.length)??0)>0&&r.jsxs("div",{className:"hint-box",role:"note",children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),r.jsxs("div",{className:"hint-body",children:[r.jsxs("div",{className:"hint-head",children:["Visible to ",Y.length>0?Y.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",Y.length>0?Y.join(", "):"this profile's required approvers",". Only they can decrypt it — your Authority Server cannot. Each approver stores a copy as their accountability record."]})]})]}),$&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"floating-help",onClick:()=>I(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),r.jsx(Mm,{open:T,onClose:()=>I(!1),ariaLabel:"Intent assistant",children:r.jsx(wi,{target:{kind:"intent",profileId:o.profileId,bounds:ue||void 0},currentText:k,onApply:me=>{ke(me),I(!1)}})})]}),G&&r.jsx("div",{className:"modal-backdrop",onClick:me=>me.target===me.currentTarget&&te(null),children:r.jsxs("div",{className:"modal",children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h3",{className:"modal-title",children:G.length>1?`Existing mandates (${G.length})`:"Existing mandate"}),r.jsx("button",{className:"modal-close",onClick:()=>te(null),children:"×"})]}),r.jsx("div",{className:"modal-body",children:G.map((me,X)=>{var we;return r.jsxs("div",{style:{marginBottom:X<G.length-1?"1rem":0,paddingBottom:X<G.length-1?"1rem":0,borderBottom:X<G.length-1?"1px solid var(--border)":"none"},children:[r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),r.jsx("div",{style:{marginBottom:"0.75rem"},children:me.scope}),r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),r.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((we=me.intent)==null?void 0:we.trim())||"(no intent recorded)"}),Object.entries(me.bounds).filter(([Te])=>Te!=="profile"&&Te!=="path").length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),r.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(me.bounds).filter(([Te])=>Te!=="profile"&&Te!=="path").map(([Te,Le])=>`${Te}: ${Le}`).join(" · ")})]})]},X)})})]})})]})]})}function Xx(n){return n.normalize("NFC").replace(/\r\n?/g,`
70
- `).split(`
71
- `).map(c=>c.replace(/[ \t]+$/,"")).join(`
72
- `).replace(/\n+$/,"")}async function uc(n){const i=new TextEncoder().encode(n),o=await crypto.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(o)).map(d=>d.toString(16).padStart(2,"0")).join("")}class Zx extends Error{constructor(i,o,c){super(c);zs(this,"code");zs(this,"field");this.name="CanonicalValueError",this.code=i,this.field=o}}function e0(n){const s=new TextEncoder().encode(n);let i="";for(const o of s)o===61||o===37||o<32||o>126?i+="%"+o.toString(16).toUpperCase().padStart(2,"0"):i+=String.fromCharCode(o);return i}function Bm(n,s,i){const o=[];for(const c of s){const d=n[c];if(d==null)continue;const h=String(d);if(h.includes(`
73
- `)||h.includes("\r"))throw new Zx(i,c,`Value for "${c}" contains a raw newline or carriage return. Refusing: a hash over stripped or normalized input would not represent what was authorized.`);o.push(`${c}=${e0(h)}`)}return o.join(`
74
- `)}async function pi(n,s){const i=s.boundsSchema;if(!i)throw new Error("Profile has no boundsSchema");const o=Bm(n,i.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await uc(o)}`}async function Dm(n,s){const i=s.scopeSchema?Bm(n,s.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await uc(i)}`}function _l(n){if(n===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof n=="number"&&!Number.isFinite(n))throw new Error(`canonicalize: ${n} is not a valid JSON number`);if(n===null||typeof n!="object")return JSON.stringify(n);if(Array.isArray(n))return"["+n.map(c=>c===void 0?"null":_l(c)).join(",")+"]";const s=n,i=[];for(const o of Object.keys(s).sort()){const c=s[o];c!==void 0&&i.push(JSON.stringify(o)+":"+_l(c))}return"{"+i.join(",")+"}"}async function Um(n){return`sha256:${await uc(_l(n))}`}async function ji(n){const s=new TextEncoder().encode(Xx(n)),i=await crypto.subtle.digest("SHA-256",s);return`sha256:${Array.from(new Uint8Array(i)).map(d=>d.toString(16).padStart(2,"0")).join("")}`}function Wm(n,s){if(!n.authorization_id)throw new Error("Signing result lacks authorization_id — the Authority Server predates per-ceremony identity. Update the Authority Server (lockstep deploy).");return{authorizationId:n.authorization_id,boundsHash:n.bounds_hash??s.boundsHash,contextHash:s.contextHash,context:s.context,...s.contextLabels&&Object.keys(s.contextLabels).length>0?{contextLabels:s.contextLabels}:{},gateContent:s.gateContent,...s.path?{path:s.path}:{}}}function t0(n){const s=n.commitment_modes;return s===void 0?["review","automatic"]:Array.isArray(s)?["review","automatic"].filter(i=>s.includes(i)):[]}function n0(n){return n==="per-action"?"review":"automatic"}function kf(n){return n?t0(n).map(s=>s==="review"?"per-action":"immediate"):["per-action","immediate"]}function r0(n,s){return s.includes(n)?n:s[0]??null}function bf(n){return n==null?new Set:new Set(String(n).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean))}function s0(n,s){for(const i of n)if(s.has(i))return!0;return!1}function a0(n,s,i){for(const o of n){const c=bf(s[o]),d=bf(i[o]);if(!(c.size===0||d.size===0)&&!s0(c,d))return!1}return!0}function i0(n){return n.length>24?`${n.slice(0,10)}…`:n}function Hm(n,s,i){const o=i==null?void 0:i[n];return String(s).split(",").map(d=>d.trim()).filter(Boolean).map(d=>{const h=o==null?void 0:o[d];return h?`${h} (${i0(d)})`:d}).join(", ")}function Vm(n){var i;if(n.isPersonal)return{can:!0};if(!n.configLoaded)return{can:!0};const s=n.teamName?`"${n.teamName}"`:"this team";return(((i=n.approvers)==null?void 0:i.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${s}.`,fix:`Ask an admin of ${s} to enable ${n.profileName} and name who may give its mandates.`}:!n.userId||!n.approvers.includes(n.userId)?{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${n.profileName}'s approvers in ${s} can give this — you are not one of them.`,fix:"Ask one of them, or a team admin to add you."}:{can:!0}}const Si=500,o0=["Lower the discount","Other recipient","Shorter","Different wording"];function dc(n){const s=n.trim();return s.length===0?{valid:!1,error:"Describe what should change."}:s.length>Si?{valid:!1,error:`At most ${Si} characters (currently ${s.length}).`}:{valid:!0,trimmed:s}}function l0(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gm(n,s){return n.toLowerCase().includes(s.toLowerCase())}function c0(n,s){const i=n.trim();if(i.length===0)return s;if(!Gm(i,s))return`${i}. ${s}`;const o=new RegExp(`\\.?\\s*${l0(s)}\\.?`,"i");return i.replace(o,"").replace(/\s{2,}/g," ").replace(/^\.\s*/,"").trim()}function Ll(){return{outcome:"rejected"}}function u0(n){const s=dc(n);if(!s.valid)throw new Error(s.error);return{outcome:"change_needed",note:s.trimmed}}function Nf(){return{outcome:"replaced"}}function d0(n,s){if((n.pendingApprovers??[]).includes(s))return{route:"approver"};const i=n.pendingDomains??[];return i.includes(s)?{route:"resolve",domain:s}:i.includes("owner")?{route:"resolve",domain:"owner"}:null}const f0={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function m0(n,s){const i=n.rejectedBy??n.approverRejectedBy;if(!i)return null;const o=i.outcome??"rejected",c=i.note??("reason"in i?i.reason:void 0);return{kind:f0[o],who:i.userId===s?"You":i.userId,at:i.at,note:c}}function h0(n){return n.refusal?{kind:"REFUSED",at:n.refusal.at,message:n.refusal.message}:null}function p0(){var he,Re;const n=dn(),{user:s,mode:i,domain:o}=vt(),[c,d]=f.useState(null),[h,g]=f.useState(null),[p,y]=f.useState(null),[v,j]=f.useState("per-action"),[w,N]=f.useState(1800),[E,k]=f.useState(86400),[C,T]=f.useState(""),[I,$]=f.useState("hours"),[P,D]=f.useState(""),[K,V]=f.useState(!0),[ce,Y]=f.useState(!1);f.useEffect(()=>{B.getIdentityDisclosure().then(de=>Y(de.always)).catch(()=>{})},[]);const[re,J]=f.useState(!1),[O,fe]=f.useState(""),[ie,Z]=f.useState(null),[pe,ee]=f.useState([]),[W,M]=f.useState(!1),[H,S]=f.useState([]),[A,G]=f.useState(0);f.useEffect(()=>{var vn;const de=sessionStorage.getItem("agentAuth"),Oe=sessionStorage.getItem("agentGate");if(!de||!Oe){n("/mandates?new=1");return}const Ge=JSON.parse(de),Ye=JSON.parse(Oe),ft={bounds:Ye.bounds??{},context:Ye.context??{},contextLabels:Ye.contextLabels??void 0,gateContent:Ye.gateContent};d(Ge),g(ft),Ye.ttlConfig&&(N(Ye.ttlConfig.default??1800),k(Ye.ttlConfig.max??86400)),Ye.templateMode==="automatic"?j("immediate"):Ye.templateMode==="review"&&j("per-action");const fn=((vn=Ye.ttlConfig)==null?void 0:vn.max)??86400;if(typeof Ye.templateTtl=="number"&&Ye.templateTtl>0){const tt=Math.min(Ye.templateTtl,fn);N(tt),[3600,86400,604800,2592e3,31536e3].includes(tt)||(tt%86400===0?(T(String(tt/86400)),$("days")):(T(String(Math.max(1,Math.round(tt/3600)))),$("hours")))}B.getProfile(Ge.profileId).then(tt=>{var bt;if(y(tt),!P){const Et=tt.name??((bt=Ge.profileId.split("/").pop())==null?void 0:bt.replace(/@.*$/,""))??"",wt=[];if(ft.context&&tt.scopeSchema)for(const je of tt.scopeSchema.keyOrder){const ge=ft.context[je];if(ge!==void 0&&ge!==""){const Me=String(ge).split(",").map(ze=>ze.trim()).filter(Boolean);wt.push(Me.join(", "))}}const ae=wt.length>0?`${Et}: ${wt.join(" · ")}`:Et;D(ae)}}).catch(()=>{}),Ge.isPersonal?M(!0):Promise.all([B.getTeamProfileConfig(Ge.groupId,Ge.profileId).catch(()=>null),B.getGroupById(Ge.groupId).catch(()=>null),B.listUsers().catch(()=>[])]).then(([tt,bt,Et])=>{if(Z(tt),tt){const wt=new Map;for(const ge of Et){const Me=ge.name&&ge.email?`${ge.name} (${ge.email})`:ge.name||ge.email||ge.id;wt.set(ge.id,Me)}const ae=(bt==null?void 0:bt.members)??[];for(const ge of ae){const Me=ge.userId??ge.id;Me&&(ge.name&&ge.email?wt.set(Me,`${ge.name} (${ge.email})`):ge.name&&wt.set(Me,ge.name))}const je=(tt.approvers??[]).map(ge=>wt.get(ge)??ge);ee(je)}}).finally(()=>{M(!0)})},[n]),f.useEffect(()=>{if(!(c!=null&&c.profileId))return;const de=c.profileId,Oe=sessionStorage.getItem("agentEditReplaces");B.getEnrichedAuthorizations().then(Ge=>{const Ye=Ge.filter(ft=>ft.profileId===de&&ft.authorizationId!==Oe).map(ft=>({authorizationId:ft.authorizationId,bounds:ft.bounds,context:ft.context??{},intent:ft.intent}));S(Ye)}).catch(()=>S([]))},[c==null?void 0:c.profileId]),f.useEffect(()=>{if(!p)return;const de=r0(v,kf(p));de&&de!==v&&j(de)},[p,v]),f.useEffect(()=>{if(!h||!p||H.length===0){G(0);return}let de=!1;return(async()=>{const Oe=await pi(h.bounds,p),Ge=await Promise.all(H.map(Ye=>pi(Ye.bounds,p).catch(()=>null)));de||G(Ge.filter(Ye=>Ye===Oe).length)})().catch(()=>{de||G(0)}),()=>{de=!0}},[h,p,H]);const te=async()=>{if(!(!c||!h||!p||!s)){if(!c.groupId){fe("No active group; cannot create mandate.");return}J(!0),fe("");try{const de=o||c.domain||"owner",Oe=await pi(h.bounds,p),Ge=await Dm(h.context,p),[Ye,ft]=await Promise.all([ji(h.gateContent.intent),ji(JSON.stringify({profile:c.profileId,domain:de,group:c.groupId}))]);let fn,vn,tt,bt;if(c.isTeam){const ze=await B.getApproversPubkeys(c.groupId,c.profileId);if(ze.length>0){const Je=await B.encryptIntent(h.gateContent.intent,ze);fn=Je.intentCiphertext,vn=Je.encryptedKeys,tt=Je.approversFrozen,bt=Je.intentDisclosureHash}}const Et=`authz_${crypto.randomUUID()}`,wt=sessionStorage.getItem("agentEditReplaces")||void 0,ae=sessionStorage.getItem("agentReplacesProposal")||void 0,je=await Um(p),ge=await B.attest({authorization_id:Et,replaces:wt,profile_id:c.profileId,profile_hash:je,supported_versions:["0.7"],bounds:h.bounds,bounds_hash:Oe,scope_hash:Ge,domain:de,did:s.did,mandate_owners:[{did:s.did}],gate_content_hashes:{intent:Ye},execution_context_hash:ft,group_id:c.groupId,ttl:w,commitment_mode:n0(v),title:P.trim(),intent_ciphertext:fn,encrypted_keys:vn,approvers_frozen:tt,intent_disclosure_hash:bt,disclose_identity:K});try{await B.pushGateContent(Wm(ge,{boundsHash:Oe,contextHash:Ge,context:h.context,contextLabels:h.contextLabels,gateContent:h.gateContent}))}catch(ze){try{await B.revokeAttestation(Et,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${ze instanceof Error?ze.message:"Unknown error"})`)}if(wt)try{await B.revokeAttestation(wt,`Replaced by ${Et} (edit)`),B.resyncGates().catch(()=>{})}catch{}let Me="";if(ae)try{const ze=await B.getProposal(ae);if(ze.status==="pending"){const Je=d0(ze,(s==null?void 0:s.id)??"");Je?Je.route==="approver"?await B.rejectProposal(ae,Nf()):await B.resolveProposal(ae,"reject",Je.domain,Nf()):Me="you are not one of the people who may decide it"}}catch(ze){Me=ze instanceof Error?ze.message:"unknown error"}if(sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),sessionStorage.removeItem("agentReplacesProposal"),Me){fe(`Your mandate is signed and active. The AI's proposal could not be withdrawn (${Me}) — reject it under Approvals.`);return}n(`/mandates?highlight=${encodeURIComponent(Et)}`)}catch(de){fe(de instanceof Error?de.message:"Signing the mandate failed")}finally{J(!1)}}};if(!c||!h)return r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const ue=Object.entries(h.bounds).filter(([de])=>de!=="profile"&&de!=="path"),ve=Object.entries(h.context),ke=((ie==null?void 0:ie.caps)!=null?Object.keys(ie.caps):[]).length!==0,se=pe.length>0?pe.join(", "):((ie==null?void 0:ie.approvers)??[]).join(", "),$e=ke?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${se}, regardless of your mode.`:"No caps set — they won't gate any action, but your intent is encrypted and shared with them as an accountability record.",Ee=ke?`Over-cap actions will be reviewed by you and ${se}. Within-cap actions run per the mode you chose above.`:`Approvers ${se} can read your intent but won't gate any action — no caps configured on this profile.`,_e=!!((he=ie==null?void 0:ie.approvers)!=null&&he.length),me=Vm({isPersonal:c.isPersonal,configLoaded:W,approvers:ie==null?void 0:ie.approvers,userId:s==null?void 0:s.id,profileName:dt(c.profileId),teamName:c.groupName}),X=!me.can,we=kf(p),Te=we.length===0,Le=w>E,lt={flex:1,padding:"0.75rem",border:v==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:v==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},xt={flex:1,padding:"0.75rem",border:v==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:v==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Ke=((Re=p==null?void 0:p.scopeSchema)==null?void 0:Re.keyOrder)??[],et=H.filter(de=>a0(Ke,h.context,de.context)),st=et.length>0,ht=dt(c.profileId),Fe=de=>{const Oe=Object.values(de).map(Ge=>String(Ge).trim()).filter(Boolean);return Oe.length>0?Oe.join(", "):"all (unscoped)"},L=et.map(de=>Fe(de.context)).join("; "),oe=`This grant's scope overlaps an existing grant on ${ht} (scoped to: ${L}). The agent may act under either. Per-action limits take the more permissive value, and daily limits add together — two grants of 10/day allow 20/day. Approval is not weakened: if either grant requires review, review still applies. Confirm this is intended before authorizing.`;return r.jsxs(r.Fragment,{children:[r.jsx(Fm,{currentStep:4,onStepClick:de=>{de<=3&&n(`/mandates/new/intent?step=${de}`)}}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),r.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),c.upgradedFromProfileId&&p&&r.jsxs("div",{className:"hint-box",role:"note",style:{marginBottom:"1rem"},children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),r.jsxs("div",{className:"hint-body",children:["Updated to ",dt(c.profileId)," ",p.version," — the current version of this profile."]})]}),O&&r.jsx("div",{className:"error-message",children:O}),r.jsxs("div",{className:"field-editable",children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Title"]}),r.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${dt(c.profileId)}: daily operations`,value:P,onChange:de=>D(de.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),r.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this mandate on your dashboard."})]}),r.jsxs("div",{className:"field-editable",children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),r.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[we.includes("per-action")&&r.jsxs("button",{onClick:()=>j("per-action"),style:xt,children:[r.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),we.includes("immediate")&&r.jsxs("button",{onClick:()=>j("immediate"),style:lt,children:[r.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]}),we.length===1&&r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:we[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),Te&&r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--danger)",marginTop:"0.25rem"},children:"This profile allows no commitment mode, so no mandate can be signed under it. Its publisher must fix the profile."})]}),r.jsxs("div",{className:"field-editable",children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Duration"]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center"},children:[[{label:"1 hour",seconds:3600},{label:"24 hours",seconds:86400},{label:"7 days",seconds:604800},{label:"30 days",seconds:2592e3},{label:"1 year",seconds:31536e3}].filter(de=>de.seconds<=E).map(de=>r.jsx("button",{onClick:()=>{N(de.seconds),T("")},style:{padding:"0.5rem 0.85rem",border:w===de.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:w===de.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:de.label},de.seconds)),r.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[r.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:C,onChange:de=>{T(de.target.value);const Oe=parseInt(de.target.value,10);if(Oe>0){const Ge=I==="days"?Oe*86400:Oe*3600;N(Math.min(Ge,E))}}}),r.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:I,onChange:de=>{$(de.target.value);const Oe=parseInt(C,10);if(Oe>0){const Ge=de.target.value==="days"?Oe*86400:Oe*3600;N(Math.min(Ge,E))}},children:[r.jsx("option",{value:"hours",children:"hours"}),r.jsx("option",{value:"days",children:"days"})]})]}),Le&&r.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",E>=86400?`${Math.floor(E/86400)} days`:`${Math.floor(E/3600)} hours`]})]})]}),r.jsx("div",{className:"field-editable",children:r.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[r.jsx("input",{type:"checkbox",checked:ce||K,disabled:ce,onChange:de=>V(de.target.checked),style:{marginTop:"0.15rem"}}),r.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this mandate",r.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.15rem"},children:['Adds "verified by Suveren" with your name to outgoing content. Takes effect only if your identity is verified; otherwise actions stay pseudonymous.',ce&&" Always on — you chose this in Settings."]})]})]})}),r.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),r.jsxs("div",{className:"info-block",children:[r.jsxs("div",{className:"info-head",children:[r.jsx("span",{className:"info-title",children:"Intent"}),r.jsx("button",{className:"info-edit",onClick:()=>n("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),r.jsx("div",{style:{whiteSpace:"pre-wrap"},children:h.gateContent.intent})]}),(!!ue.length||!!ve.length)&&r.jsxs("div",{className:"info-block",children:[r.jsxs("div",{className:"info-head",children:[r.jsx("span",{className:"info-title",children:"Scope & Limits"}),r.jsx("button",{className:"info-edit",onClick:()=>n("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),r.jsxs("dl",{className:"info-kv",children:[ve.map(([de,Oe])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:de}),r.jsx("dd",{children:Hm(de,Oe,h.contextLabels)})]},de)),ue.map(([de,Oe])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:de}),r.jsx("dd",{children:String(Oe)})]},de))]})]}),r.jsxs("div",{className:"info-block",children:[r.jsx("div",{className:"info-head",children:r.jsx("span",{className:"info-title",children:"Authority"})}),r.jsxs("dl",{className:"info-kv",children:[r.jsx("dt",{children:"Profile"}),r.jsxs("dd",{children:[dt(c.profileId),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:c.profileId})]}),!c.isPersonal&&c.groupName&&r.jsxs(r.Fragment,{children:[r.jsx("dt",{children:"Team"}),r.jsx("dd",{children:c.groupName})]}),!c.isPersonal&&r.jsxs(r.Fragment,{children:[r.jsx("dt",{children:"Approvers"}),r.jsx("dd",{children:W?me.can?r.jsxs(r.Fragment,{children:[se,r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:$e})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{color:"var(--danger)",fontWeight:600},children:me.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${c.groupName??"this team"}`:"You cannot give this mandate"}),me.code==="OWNER_NOT_APPROVER"&&r.jsx("div",{children:se}),r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[me.reason," ",me.fix]})]}):r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),A>0?r.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[r.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),r.jsxs("div",{children:[A===1?`An active grant on ${ht} already has exactly these limits.`:`${A} active grants on ${ht} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",r.jsx("strong",{children:"Extend"})," on the Mandates page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,st?r.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[r.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Overlapping scope"}),r.jsx("div",{children:oe})]})]}):null,r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:()=>n("/mandates/new/intent"),children:"Back"}),r.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:te,disabled:re||!P.trim()||X||Te,children:re?"Signing...":v==="immediate"?"Sign mandate":"Sign mandate (asks first)"})]}),r.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:_e?"block":"none"},children:Ee})]})]})}const g0={card:"💳",mail:"✉️"};function Km(n){return g0[n]??"🔧"}function y0(n){const s=n==null?void 0:n.overrides;return!s||typeof s!="object"?!1:Object.values(s).some(i=>{var o;return typeof((o=i==null?void 0:i.read)==null?void 0:o.ageField)=="string"})}const v0=[0,7,30,90,365,3650];function ci(n){return n===null?"From your mandate":n===0?"Read nothing":n===1?"1 day back":n===365?"1 year back":n%365===0?`${n/365} years back`:`${n} days back`}function x0(n){return(n==null?void 0:n.paused)==="simulation"?{chip:{c:"int-chip-paused",t:"Paused"},showStart:!1}:n&&!n.running&&n.error?{chip:{c:"int-chip-bad",t:"Crashed"},showStart:!0}:{chip:{c:"int-chip-idle",t:"Stopped"},showStart:!0}}function Sl({manifest:n,integration:s,state:i,onStatusChange:o,onSuccess:c}){var Fe;const[d,h]=f.useState({}),[g,p]=f.useState(!1),[y,v]=f.useState(!1),[j,w]=f.useState({}),[N,E]=f.useState({}),[k,C]=f.useState(void 0),[T,I]=f.useState(!1),[$,P]=f.useState(null),[D,K]=f.useState(!1),[V,ce]=f.useState(!1),[Y,re]=f.useState(!1),[J,O]=f.useState(!1),[fe,ie]=f.useState({}),[Z,pe]=f.useState(null),[ee,W]=f.useState(!1),[M,H]=f.useState(null),[S,A]=f.useState(!1);f.useEffect(()=>{let L=!1;return B.getCredential(n.id).then(oe=>{var he;if(!(L||!oe.configured)){if(p(!0),v(!0),oe.fields){const Re={};for(const de of n.credentials.fields)oe.fields[de.key]!=null&&(Re[de.key]=oe.fields[de.key]);w(Re)}if(E(oe.secrets??{}),C(oe.updatedAt),n.oauth){const Re=((he=oe.fieldNames)==null?void 0:he.includes(n.oauth.tokenStorage))??!1;I(Re),Re&&B.getOAuthHealth(n.id).then(de=>{L||P(de)})}}}).catch(()=>{}),()=>{L=!0}},[n.id,n.oauth]);const G=y0(n.toolGating),te=s?s.readAgeDays??null:void 0,ue=ee&&Z?Z.value:te,ve=async L=>{pe({value:L}),W(!0),H(null);try{await B.setReadPolicy(n.id,L),c(L===null?`${n.name} read window now follows your mandate`:`${n.name} read window set to ${ci(L).toLowerCase()}`),o()}catch(oe){H(oe instanceof Error?oe.message:"Could not save")}finally{W(!1),pe(null)}},Ce=!!n.oauth||n.credentials.fields.some(L=>!L.optional),ke=n.oauth?T:g,se=!Ce||ke,$e=i==="starting"?"starting":se?s!=null&&s.running?"running":!g&&n.credentials.fields.length>0?"unconfigured":"ready":n.oauth&&g&&!T?"needs-oauth":"unconfigured",Ee=async()=>{if(n.credentials.fields.some(oe=>{var he;return(he=d[oe.key])==null?void 0:he.trim()})){K(!0);try{await B.setCredential(n.id,d),p(!0),h({}),n.oauth?c(`${n.name} credentials saved!`):(c(`${n.name} credentials saved — starting integration...`),await Te())}catch{c(`Failed to save ${n.name} credentials`)}finally{K(!1)}}},_e=()=>{const L={};for(const oe of n.credentials.fields){const he=d[oe.key];oe.type==="password"?he!=null&&he.trim()&&(L[oe.key]=he):he!=null&&he!==(j[oe.key]??"")&&(L[oe.key]=he)}return L},me=Object.keys(_e()).length>0,X=async()=>{const L=_e();if(Object.keys(L).length!==0){K(!0);try{await B.setCredential(n.id,L),h({}),p(!0),n.oauth?c(`${n.name} credentials saved — now click Connect.`):(O(!1),c(`${n.name} credentials updated — restarting...`),await Te())}catch{c(`Failed to update ${n.name} credentials`)}finally{K(!1)}}},we=()=>{window.open(`/auth/oauth/${n.id}/start`,"_blank","width=600,height=700");const L=setInterval(async()=>{var oe;try{const he=await B.getCredential(n.id);he.configured&&n.oauth&&((oe=he.fieldNames)!=null&&oe.includes(n.oauth.tokenStorage))&&(I(!0),O(!1),P(null),clearInterval(L),c(`${n.name} connected — starting integration...`),B.getOAuthHealth(n.id).then(P).catch(()=>{}),await Te())}catch{}},2e3);setTimeout(()=>clearInterval(L),12e4)},Te=async()=>{re(!0);try{const L=await B.activateIntegration(n.id);L.warning?c(L.warning):c(`${n.name} integration started with ${L.tools.length} tools`),o()}catch(L){c(`Failed to start ${n.name}: ${L instanceof Error?L.message:"Unknown error"}`)}finally{re(!1)}},Le=async()=>{try{await B.removeMcpIntegration(n.id),c(`${n.name} integration removed`),o()}catch{c(`Failed to remove ${n.name}`)}},lt=Km(n.icon),xt=x0(s),Ke=$e==="running"?{c:"int-chip-ok",t:"Running"}:$e==="starting"?{c:"int-chip-idle",t:"Starting"}:xt.chip,et=n.oauth&&T&&($==null?void 0:$.status)==="failed",st=Ce?et?{c:"int-chip-bad",t:"Auth failed"}:ke?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},ht=L=>L.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${n.id}/callback`);return r.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[r.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:lt}),r.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:n.name}),r.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[$e!=="unconfigured"&&$e!=="needs-oauth"&&r.jsxs("span",{className:`int-chip ${Ke.c}`,children:[r.jsx("span",{className:"int-dot"}),Ke.t]}),r.jsxs("span",{className:`int-chip ${st.c}`,children:[r.jsx("span",{className:"int-dot"}),st.t]}),fv(n,j)&&r.jsxs("span",{className:"int-chip int-chip-sim",title:"This connector answers from a simulated system with test data. Nothing reaches your real systems.",children:[r.jsx("span",{className:"int-dot"}),"Simulation"]})]})]}),n.oauth&&T&&r.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:$!=null&&$.account?r.jsxs(r.Fragment,{children:["Connected as ",r.jsx("b",{children:$.account})]}):r.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),et&&!J&&r.jsxs("div",{style:{marginTop:"0.7rem",border:"1px solid var(--danger)",borderRadius:"10px",padding:"0.8rem 0.95rem",background:"color-mix(in srgb, var(--danger) 5%, var(--bg-elevated))"},children:[r.jsxs("div",{style:{fontSize:"0.86rem",fontWeight:700},children:[n.name," stopped accepting the stored credentials"]}),r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0.3rem 0 0",lineHeight:1.55},children:[($==null?void 0:$.error)==="invalid_grant"?r.jsxs(r.Fragment,{children:["The refresh token was revoked (",r.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):$!=null&&$.error?r.jsxs(r.Fragment,{children:["The provider reported ",r.jsx("code",{children:$.error}),"."]}):r.jsx(r.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",n.name," actions are ",r.jsx("b",{children:"blocked"}),", not failing silently."]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.6rem"},children:[r.jsxs("button",{className:"btn btn-primary btn-sm",onClick:we,children:["Reconnect ",n.name]}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{h({...j}),O(!0)},children:"Edit credentials"})]})]}),r.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[r.jsx("summary",{children:"Details"}),r.jsxs("div",{className:"int-meta",children:[r.jsx("span",{className:"int-k",children:"What"}),r.jsx("span",{children:n.description}),n.profile&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"int-k",children:"Profile"}),r.jsx("span",{children:n.profile})]}),n.oauth&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"int-k",children:"Scopes"}),r.jsx("span",{children:((Fe=n.oauth.scopes)==null?void 0:Fe.join(", "))||"—"})]}),s&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"int-k",children:"Tools"}),r.jsxs("span",{children:[s.toolCount," gated"]})]})]})]}),n.setupGuide&&n.setupGuide.length>0&&($e!=="running"||et)&&r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[r.jsxs("button",{onClick:()=>ce(!V),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[r.jsx("span",{style:{transition:"transform 0.2s",transform:V?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",n.name]}),V&&r.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:n.setupGuide.map((L,oe)=>r.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[r.jsx("div",{style:{width:"1.5rem",height:"1.5rem",borderRadius:"50%",background:"var(--border)",color:"var(--text-secondary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.7rem",fontWeight:700,flexShrink:0,marginTop:"0.1rem"},children:oe+1}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:L.title}),r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[ht(L.description),L.link&&r.jsxs(r.Fragment,{children:[" ",r.jsxs("a",{href:L.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},oe))})]}),$e==="starting"&&r.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[r.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),J&&r.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[r.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),y&&r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.6rem"},children:["Leaving a secret blank keeps the stored one — editing other fields can never silently wipe it.",n.oauth?" Save, then Connect to re-link the account.":""]}),n.credentials.fields.map(L=>{var oe;return r.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[r.jsx("label",{className:"form-label",children:L.label}),L.type==="password"?r.jsxs("div",{className:"cred-field",children:[r.jsx("input",{className:"form-input",type:fe[L.key]?"text":"password",name:`${n.id}-${L.key}-credential`,autoComplete:"new-password",placeholder:(oe=N[L.key])!=null&&oe.preview?`Unchanged — ends in ${N[L.key].preview}`:y?"Unchanged — paste a new value to replace":L.placeholder,value:d[L.key]||"",onChange:he=>h(Re=>({...Re,[L.key]:he.target.value}))}),r.jsx("button",{className:"cred-toggle",onClick:()=>ie(he=>({...he,[L.key]:!he[L.key]})),children:fe[L.key]?"hide":"show"})]}):r.jsx("input",{className:"form-input",type:"text",name:`${n.id}-${L.key}-credential`,autoComplete:"off",placeholder:L.placeholder,value:d[L.key]||"",onChange:he=>h(Re=>({...Re,[L.key]:he.target.value}))})]},L.key)}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[r.jsx("button",{className:"btn btn-primary btn-sm",onClick:X,disabled:D||!me,children:D?"Saving…":"Save"}),!me&&!D&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),n.oauth&&r.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:we,children:["Connect ",n.name]}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{O(!1),h({})},children:"Cancel"})]})]}),!J&&$e==="running"&&s&&r.jsxs(r.Fragment,{children:[(Object.keys(j).length>0||Object.keys(N).length>0)&&r.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:n.credentials.fields.map(L=>{const oe=L.type==="password",he=N[L.key];return!oe&&j[L.key]==null||oe&&he==null?null:r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[r.jsx("span",{style:{color:"var(--text-muted)"},children:L.label}),r.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[oe?he.preview??"set":j[L.key],oe&&k&&r.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(k).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},L.key)})}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[r.jsx(yt,{to:"/mandates?new=1",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Give a mandate"}),(n.credentials.fields.length>0||n.oauth)&&r.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{h({...j}),O(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),r.jsx("span",{style:{flex:1}}),r.jsx("button",{className:"btn btn-sm btn-ghost",style:{color:"var(--danger)"},onClick:Le,title:"Stops the subprocess and removes the integration from the registry. It will NOT auto-start on next gateway restart. Re-enable with Install.",children:"Disable"})]}),G&&ue!==void 0&&!S&&r.jsx("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"0.5rem",minWidth:0},children:[r.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"Reads"}),r.jsx("span",{style:{fontSize:"0.82rem",color:"var(--text-muted)"},children:ue===null?"window from your mandate":ci(ue).toLowerCase()}),ee&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),M&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:M})]}),r.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>A(!0),children:"Edit"})]})}),G&&ue!==void 0&&S&&r.jsxs("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem",marginBottom:"0.35rem"},children:[r.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"How far back may your agent read?"}),r.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>A(!1),children:"Done"})]}),r.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-tertiary)",margin:"0 0 0.55rem"},children:"Applies immediately — no Save, no new mandate."}),r.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[v0.map(L=>{const oe=ue===L;return r.jsx("button",{className:`btn btn-sm ${oe?"btn-primary":"btn-secondary"}`,"aria-pressed":oe,disabled:ee,onClick:()=>ve(L),children:ci(L)},L)}),r.jsx("button",{className:`btn btn-sm ${ue===null?"btn-primary":"btn-ghost"}`,"aria-pressed":ue===null,disabled:ee,onClick:()=>ve(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:ci(null)})]}),r.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:M?r.jsx("span",{style:{color:"var(--danger)"},children:M}):ee?r.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):ue===null?r.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):ue===0?r.jsx("span",{style:{color:"var(--text-muted)"},children:"Your agent cannot read any mail."}):r.jsxs("span",{style:{color:"var(--text-muted)"},children:["Anything older than ",ue," days is blocked, whoever it is from."]})})]}),r.jsx("div",{style:{display:"none"},children:r.jsx(yt,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),$e==="unconfigured"&&(()=>{const L=n.credentials.fields.every(Re=>Re.optional),oe=n.credentials.fields.some(Re=>!Re.optional),he=n.credentials.fields.some(Re=>{var de;return(de=d[Re.key])==null?void 0:de.trim()});return r.jsxs(r.Fragment,{children:[y&&r.jsxs("div",{className:"alert",style:{fontSize:"0.8rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.75rem",marginBottom:"0.75rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{style:{color:"var(--text-primary)"},children:"Credentials on file."})," ","Existing values are encrypted in the vault and not shown. Enter new values below to replace them, or"," ",r.jsx("button",{onClick:()=>{p(!0),n.oauth&&I(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),n.oauth&&!y&&r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Step 1 of 2 — enter credentials, then connect your account."}),n.setupHint&&!y&&r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:n.setupHint}),n.credentials.fields.map(Re=>r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsx("label",{className:"form-label",children:Re.label}),Re.type==="password"?r.jsxs("div",{className:"cred-field",children:[r.jsx("input",{className:"form-input",type:fe[Re.key]?"text":"password",name:`${n.id}-${Re.key}-credential`,autoComplete:"new-password",placeholder:Re.placeholder,value:d[Re.key]||"",onChange:de=>h(Oe=>({...Oe,[Re.key]:de.target.value}))}),r.jsx("button",{className:"cred-toggle",onClick:()=>ie(de=>({...de,[Re.key]:!de[Re.key]})),children:fe[Re.key]?"hide":"show"})]}):r.jsx("input",{className:"form-input",type:"text",name:`${n.id}-${Re.key}-credential`,autoComplete:"off",placeholder:Re.placeholder,value:d[Re.key]||"",onChange:de=>h(Oe=>({...Oe,[Re.key]:de.target.value}))})]},Re.key)),r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[he&&r.jsx("button",{className:"btn btn-primary",onClick:Ee,disabled:D||oe&&!n.credentials.fields.filter(Re=>!Re.optional).every(Re=>{var de;return(de=d[Re.key])==null?void 0:de.trim()}),children:D?"Saving...":"Save & Encrypt"}),L&&!he&&r.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:Y,children:Y?"Starting...":`Activate ${n.name}`})]})]})})(),$e==="needs-oauth"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",n.name," account to authorize access."]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[r.jsxs("button",{className:"btn btn-primary",onClick:we,children:["Connect ",n.name," Account"]}),r.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Change Credentials"})]})]}),$e==="ready"&&!s&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.75rem"},children:["✓"," ",n.oauth?`${n.name} account connected`:"Credentials configured"]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[r.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:Y,children:Y?"Starting...":`Start ${n.name} Integration`}),!n.oauth&&r.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Update Credentials"}),n.oauth&&r.jsx("button",{className:"btn btn-ghost",onClick:()=>{p(!1),I(!1)},children:"Change Credentials"})]})]}),$e==="ready"&&s&&!s.running&&(xt.showStart?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[r.jsx("span",{className:"service-status-dot"}),"Not running"]}),s.error&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--danger)",marginBottom:"0.75rem"},children:s.error}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:Y,children:Y?"Starting...":"Start"}),r.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:Le,children:"Disable"})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"service-status",style:{marginBottom:"0.5rem",color:"var(--text-muted)"},children:[r.jsx("span",{className:"service-status-dot",style:{background:"var(--text-muted)"}}),"Paused"]}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.75rem"},children:"Real systems are off while simulation mode is on."}),r.jsx("div",{style:{display:"flex",gap:"0.5rem"},children:r.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:Le,children:"Disable"})})]}))]})}function w0(n,s){if(!s)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:n};const i=n.filter(h=>Vs(h.manifest)),o=n.filter(h=>!Vs(h.manifest)),c=o.filter(h=>h.state==="error"),d=o.filter(h=>h.state!=="error");return{grouped:!0,testSystems:i,realErrors:c,pausedReal:d,ungrouped:[]}}function j0({entry:n}){return r.jsxs("div",{className:"int-paused-row",children:[r.jsx("span",{"aria-hidden":"true",children:Km(n.manifest.icon)}),r.jsx("span",{className:"int-paused-name",children:n.manifest.name}),r.jsxs("span",{className:"int-chip int-chip-paused",children:[r.jsx("span",{className:"int-dot"}),"Paused"]})]})}function S0(){const{loading:n,mcpServerUp:s,manifestsError:i,entries:o,refresh:c}=rc(),d=nc(),[h,g]=f.useState(""),p=f.useCallback(v=>{g(v),setTimeout(()=>g(""),5e3)},[]),y=w0(o,d);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Integrations"}),r.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),h&&r.jsx("div",{className:"alert alert-success",children:h}),n?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):s===!1?r.jsxs("div",{className:"status-banner status-banner-error",children:[r.jsx("span",{className:"status-banner-icon",children:"!"}),r.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):y.grouped?r.jsxs(r.Fragment,{children:[y.testSystems.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"int-group-label",children:"Test systems"}),y.testSystems.map(v=>r.jsx(Sl,{manifest:v.manifest,integration:v.integration,state:v.state,onStatusChange:c,onSuccess:p},v.id))]}),(y.realErrors.length>0||y.pausedReal.length>0)&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"int-group-label",children:"Real systems"}),y.realErrors.map(v=>r.jsx(Sl,{manifest:v.manifest,integration:v.integration,state:v.state,onStatusChange:c,onSuccess:p},v.id)),y.pausedReal.length>0&&r.jsxs("details",{className:"int-paused-group",open:!0,children:[r.jsxs("summary",{children:["Paused while simulation mode is on (",y.pausedReal.length,")"]}),r.jsxs("p",{className:"int-paused-group-note",children:["Nothing is lost — mandates, credentials and data stay. They start again when simulation mode is switched off (",r.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),y.pausedReal.map(v=>r.jsx(j0,{entry:v},v.id))]})]}),o.length===0&&r.jsx(Cf,{manifestsError:i})]}):r.jsxs(r.Fragment,{children:[o.map(v=>r.jsx(Sl,{manifest:v.manifest,integration:v.integration,state:v.state,onStatusChange:c,onSuccess:p},v.id)),o.length===0&&r.jsx(Cf,{manifestsError:i})]})]})}function Cf({manifestsError:n}){return n?r.jsxs("div",{className:"status-banner status-banner-error",children:[r.jsx("span",{className:"status-banner-icon",children:"!"}),r.jsxs("span",{className:"status-banner-text",children:["Couldn't load integrations — the gateway can't reach its MCP server (or you're signed out). Check the control-plane's"," ",r.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):r.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."})}function k0(){var O,fe,ie;const{activeTeam:n,activeMembership:s,refreshGroups:i,user:o}=vt(),c=dn(),[d,h]=f.useState(null),[g,p]=f.useState(!1),[y,v]=f.useState(""),[j,w]=f.useState(""),[N,E]=f.useState(!1),[k,C]=f.useState(""),[T,I]=f.useState("");f.useEffect(()=>{fetch("/health").then(Z=>Z.json()).then(Z=>{typeof Z.spUrl=="string"&&I(Z.spUrl)}).catch(()=>{})},[]),f.useEffect(()=>{if(!n){h(null);return}B.getGroupById(n.id).then(Z=>{const pe=Z.group??Z,ee=Z.members??[],W=Z.isAdmin??!1,M=ee.map(H=>{const S=H.userId||H.id||"",A=H.role||(W&&S===pe.createdBy?"admin":"member");return{id:S,name:H.name||S.slice(0,8)||"Member",email:H.email||"",domains:H.domains||[],role:A,isAdmin:A==="admin"||W&&S===pe.createdBy}});h({id:pe.id,name:pe.name,members:M})}).catch(()=>h(null))},[n==null?void 0:n.id]);const $=(d==null?void 0:d.members.filter(Z=>Z.isAdmin))??[],P=(n==null?void 0:n.isAdmin)===!0&&$.length<=1&&$.some(Z=>Z.id===(o==null?void 0:o.id)),D=(n==null?void 0:n.name)??"",K=k.trim()===D&&!g,V=()=>{C(""),E(!0)},ce=()=>{E(!1),C("")},Y=async()=>{if(!(!n||!K)){p(!0),v("");try{await B.leaveTeam(n.id),await i(),w("You have left the team."),h(null),ce()}catch(Z){v(Z instanceof Error?Z.message:"Failed to leave team")}finally{p(!1)}}},re=n&&T?`${T}/dashboard/groups/${n.id}`:void 0,J=T?`${T}/dashboard/groups`:void 0;return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"page-header",children:r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:"Team"}),r.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Authority Server dashboard."})]})}),y&&r.jsx("div",{className:"error-message",children:y}),j&&r.jsx("div",{className:"alert alert-success",children:j}),n?r.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[r.jsxs("div",{className:"card-header",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"card-title",children:n.name}),r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((O=d==null?void 0:d.members)==null?void 0:O.length)??0," ",(((fe=d==null?void 0:d.members)==null?void 0:fe.length)??0)===1?"member":"members",n.isAdmin&&" · You are admin"]})]}),r.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(ie=d==null?void 0:d.members)==null?void 0:ie.map(Z=>r.jsxs("div",{className:"member-row",children:[r.jsx("div",{className:"member-avatar",children:Z.name.split(" ").map(pe=>pe[0]).join("").slice(0,2).toUpperCase()}),r.jsxs("div",{className:"member-info",children:[r.jsx("div",{className:"member-name",children:Z.name}),r.jsx("div",{className:"member-email",children:Z.email})]}),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Z.role})]},Z.id)),r.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[re&&r.jsx("a",{className:"btn btn-secondary btn-sm",href:re,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server →"}),r.jsx("span",{title:P?"You are the only admin. Transfer admin to another member in your Authority Server dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:r.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:V,disabled:g||P,children:"Leave team"})})]})]}):r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[r.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),r.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",maxWidth:480,marginLeft:"auto",marginRight:"auto"},children:"Every mandate you create here is in your personal context. An account is Personal or in one team — joining or creating a team moves it."}),r.jsxs("div",{style:{display:"flex",gap:"0.75rem",justifyContent:"center",flexWrap:"wrap"},children:[r.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>c("/onboarding"),children:"Join or create a team"}),J&&r.jsx("a",{className:"btn btn-ghost btn-sm",href:J,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server →"})]})]}),N&&n&&r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"leave-team-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:ce,children:r.jsxs("div",{className:"card",onClick:Z=>Z.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[r.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",D,"?"]}),r.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),r.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[r.jsx("li",{children:"Revoke all mandates you created in this team's context"}),r.jsx("li",{children:"Reject any pending action proposals you authored"}),r.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),r.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",r.jsx("strong",{children:"personal"})," mandates are not affected."]}),r.jsxs("div",{className:"form-group",children:[r.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",r.jsx("code",{children:D})," to confirm:"]}),r.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:k,onChange:Z=>C(Z.target.value),placeholder:D,disabled:g,autoFocus:!0})]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:ce,disabled:g,children:"Cancel"}),r.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:Y,disabled:!K,children:g?"Leaving...":"Leave team"})]})]})})]})}const b0=new Set(["mail","users","receipt","credit-card","calendar","megaphone","archive","rocket","flask","shopping-cart","bar-chart","help-circle"]),N0={email:"mail",customers:"users",sales:"receipt",charge:"credit-card",calendar:"calendar",publish:"megaphone",records:"archive",deploy:"rocket",delegation:"flask",purchase:"shopping-cart",reporting:"bar-chart"};function C0(n){const s=n.lastIndexOf("/"),i=s>=0?n.slice(s+1):n,o=i.indexOf("@");return(o>=0?i.slice(0,o):i).toLowerCase()}function Sr(n,s){const i=C0(n),o=s!=null&&s.icon&&b0.has(s.icon)?s.icon:N0[i]??"help-circle",c=dt(n,s==null?void 0:s.name);return{icon:o,name:c,testSetup:i==="delegation"}}function Ti(n){return n.startsWith("setup__")}const E0={mail:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),r.jsx("path",{d:"m3 7 9 6 9-6"})]}),users:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),r.jsx("path",{d:"M3.5 20c0-3.6 2.5-6.3 5.5-6.3s5.5 2.7 5.5 6.3"}),r.jsx("circle",{cx:"17.2",cy:"9.2",r:"2.3"}),r.jsx("path",{d:"M16.8 13.9c2.4.5 4.2 2.6 4.2 5.4"})]}),receipt:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M6 3h12v18l-2.2-1.4L14 21l-2-1.4L10 21l-2-1.4L6 21V3Z"}),r.jsx("line",{x1:"9",y1:"7.5",x2:"15",y2:"7.5"}),r.jsx("line",{x1:"9",y1:"11.5",x2:"15",y2:"11.5"}),r.jsx("line",{x1:"9",y1:"15.5",x2:"13",y2:"15.5"})]}),"credit-card":r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2.2"}),r.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"}),r.jsx("line",{x1:"5.5",y1:"15",x2:"9.5",y2:"15"})]}),calendar:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"4.5",width:"18",height:"16.5",rx:"2"}),r.jsx("line",{x1:"3",y1:"9.5",x2:"21",y2:"9.5"}),r.jsx("line",{x1:"8",y1:"2.5",x2:"8",y2:"6.5"}),r.jsx("line",{x1:"16",y1:"2.5",x2:"16",y2:"6.5"})]}),megaphone:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M3 10.2v3.6c0 .7.6 1.2 1.2 1.2h2.6l6.4 4V5l-6.4 4H4.2C3.6 9 3 9.5 3 10.2Z"}),r.jsx("path",{d:"M14.5 8.3a4.3 4.3 0 0 1 0 7.4"}),r.jsx("path",{d:"M17.6 6a7.6 7.6 0 0 1 0 12"})]}),archive:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"3.5",width:"18",height:"5",rx:"1.2"}),r.jsx("path",{d:"M5 8.5V18a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8.5"}),r.jsx("line",{x1:"10",y1:"13",x2:"14",y2:"13"})]}),rocket:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M12 2.2c2.4 2 3.8 5.3 3.8 8.6 0 1.9-.9 3.9-.9 3.9H9.1s-.9-2-.9-3.9c0-3.3 1.4-6.6 3.8-8.6Z"}),r.jsx("path",{d:"M9 14.7 6.3 19.4l3.8-1.7"}),r.jsx("path",{d:"M15 14.7l2.7 4.7-3.8-1.7"}),r.jsx("circle",{cx:"12",cy:"9.3",r:"1.3"})]}),flask:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M9 3h6"}),r.jsx("path",{d:"M10 3v6.3l-5 9.1A2 2 0 0 0 6.7 21.5h10.6a2 2 0 0 0 1.7-3.1l-5-9.1V3"}),r.jsx("line",{x1:"8.3",y1:"14.5",x2:"15.7",y2:"14.5"})]}),"shopping-cart":r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9",cy:"20",r:"1.4"}),r.jsx("circle",{cx:"18",cy:"20",r:"1.4"}),r.jsx("path",{d:"M2.5 3h2.4l2.1 11.2a2 2 0 0 0 2 1.6h8.6a2 2 0 0 0 2-1.6l1.4-7.6H6"})]}),"bar-chart":r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"4",y1:"20.5",x2:"20",y2:"20.5"}),r.jsx("rect",{x:"6",y:"13",width:"3.2",height:"7.5"}),r.jsx("rect",{x:"11.4",y:"8.5",width:"3.2",height:"12"}),r.jsx("rect",{x:"16.8",y:"4",width:"3.2",height:"16.5"})]}),"help-circle":r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"12",cy:"12",r:"9.2"}),r.jsx("path",{d:"M9.6 9.6a2.5 2.5 0 1 1 3.6 2.3c-.9.5-1.4 1.1-1.4 2.2"}),r.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"17.05"})]})};function Ym({icon:n,className:s}){return r.jsx("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:E0[n]})}function qs({profileId:n,declared:s}){const{icon:i,name:o}=Sr(n,s);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"id-rail",children:[r.jsx(Ym,{icon:i,className:"id-rail-icon"}),r.jsx("span",{className:"id-rail-name",children:o})]}),r.jsx("div",{className:"id-sep"})]})}const Ks=n=>n.replace(/@.*$/,"").split("/").pop()??n,Ef=n=>n.split("@")[1]??"";function T0(n,s){const i=new Map;for(const o of n){const c=Ks(o.id);if(!s.has(c))continue;const d=i.get(c);(!d||Ef(o.id).localeCompare(Ef(d.id),void 0,{numeric:!0})>0)&&i.set(c,o)}return i}function R0(n,s,i,o){var g;const c=new Set([...s.filter(p=>p.profile).map(p=>p.profile),...o.map(p=>Ks(p.profile))]),d=T0(n,c),h=[];for(const p of s){const y=p.profile?d.get(p.profile):void 0;y&&h.push({key:`connector:${p.id}`,name:p.name,description:p.description||y.description,profile:y,kind:"connector",ready:((g=i.find(v=>v.id===p.id))==null?void 0:g.running)===!0,setupId:p.id,...p.intentHint?{intentHint:p.intentHint}:{}})}for(const p of o){const y=d.get(Ks(p.profile));y&&h.push({key:`builtin:${p.id}`,name:p.name,description:p.description||y.description,profile:y,kind:"builtin",ready:p.available,unavailableReason:p.available?void 0:"Available only while simulation mode is on.",...p.intentHint?{intentHint:p.intentHint}:{}})}return h}function I0(n,s,i){if(s)return n.find(o=>Ks(o.profile.id)===Ks(s)&&o.ready&&i(o))}function A0({onDismiss:n,preselectProfileId:s}){const i=dn(),{group:o,groupId:c,domain:d,user:h}=vt(),[g,p]=f.useState([]),[y,v]=f.useState([]),[j,w]=f.useState([]),[N,E]=f.useState([]),[k,C]=f.useState(!0),[T,I]=f.useState({});f.useEffect(()=>{Promise.all([B.listProfiles().catch(()=>[]),B.getIntegrationManifests().then(Y=>Y.manifests??[]).catch(()=>[]),B.getMcpHealth().catch(()=>null)]).then(async([Y,re,J])=>{if(p(Y),v(re),w((J==null?void 0:J.integrations)??[]),E((J==null?void 0:J.builtins)??[]),c){const O=await Promise.all(Y.map(ie=>B.getTeamProfileConfig(c,ie.id).catch(()=>null))),fe={};Y.forEach((ie,Z)=>{const pe=O[Z];pe&&(fe[ie.id]=pe)}),I(fe)}}).finally(()=>C(!1))},[c]);const $=R0(g,y,j,N),P=Y=>{var re;return Vm({isPersonal:!!(o!=null&&o.isPersonal),configLoaded:!k,approvers:(re=T[Y.id])==null?void 0:re.approvers,userId:h==null?void 0:h.id,profileName:dt(Y.id),teamName:o==null?void 0:o.name})},D=Y=>Y in T,K=(Y,re)=>{if(!c){console.error("No active group when creating authorization");return}const J=D(Y);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Y,groupId:c,groupName:(o==null?void 0:o.name)??null,domain:d,isTeam:J,isPersonal:!!(o!=null&&o.isPersonal),...re?{intentHint:re}:{}})),sessionStorage.removeItem("agentGate"),n==null||n(),i("/mandates/new/intent")},V=(Y,re)=>{c&&K(Y,re)},ce=f.useRef(!1);return f.useEffect(()=>{if(k||!s||ce.current)return;const Y=I0($,s,re=>P(re.profile).can);Y&&(ce.current=!0,V(Y.profile.id,Y.intentHint))},[k,s]),r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
75
- .profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
76
- .profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
77
- @media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
78
- @media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
79
- `}),k?r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):$.length===0?r.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[r.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),r.jsx(yt,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>n==null?void 0:n(),children:"Go to Integrations"})]}):r.jsx("div",{className:"profile-grid",children:$.map(Y=>{const re=Y.profile,J=D(re.id),O=P(re),fe=!Y.ready||!O.can,{icon:ie}=Sr(re.id,{name:re.name,icon:re.icon});return r.jsxs("div",{className:"card",style:fe?{opacity:.7}:void 0,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[r.jsxs("h3",{className:"card-title profile-chip",style:{margin:0},children:[r.jsx(Ym,{icon:ie,className:"profile-chip-icon"}),Y.name]}),J?r.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Team"}):o!=null&&o.isPersonal?r.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--bg-main)",color:"var(--text-tertiary)",fontWeight:600,border:"1px solid var(--border)"},children:"Personal"}):null]}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:Y.description}),O.can?Y.ready?r.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>V(re.id,Y.intentHint),children:"Give a mandate"}):Y.kind==="builtin"?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem"},children:Y.unavailableReason})]}):r.jsxs(yt,{to:`/integrations?setup=${Y.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>n==null?void 0:n(),children:["Set up ",Y.name]}):r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:[O.reason," ",r.jsx("span",{style:{color:"var(--text-tertiary)"},children:O.fix})]})]})]},Y.key)})})]})}const P0={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function _0({status:n,label:s}){return r.jsx("span",{className:`status-badge status-${n}`,children:s||P0[n]})}function L0({domain:n,attested:s}){const i=s===!0?"domain-attested":s===!1?"domain-missing":"";return r.jsx("span",{className:`domain-badge ${i}`,style:{fontSize:"0.75rem"},children:n})}const yr=86400,Us=3600,ui=60,$0=30*yr;function z0(n){if(n<=0)return"Expired";if(n>90*yr){const s=Math.floor(n/$0);return`${s} ${s===1?"month":"months"} remaining`}if(n>7*yr){const s=Math.floor(n/yr);return`${s} ${s===1?"day":"days"} remaining`}if(n>=2*yr){const s=Math.floor(n/yr),i=Math.floor(n%yr/Us);return`${s} ${s===1?"day":"days"} ${i}h remaining`}if(n>=2*Us){const s=Math.floor(n/Us),i=Math.floor(n%Us/ui);return`${s}h ${String(i).padStart(2,"0")}m remaining`}if(n>=ui){const s=Math.floor(n/ui),i=Math.floor(n%ui);return`${s}m ${String(i).padStart(2,"0")}s remaining`}return`${Math.floor(n)}s remaining`}function F0({expiresAt:n}){const[s,i]=f.useState(()=>n-Date.now()/1e3),o=s<2*Us;f.useEffect(()=>{const d=setInterval(()=>i(n-Date.now()/1e3),o?1e3:6e4);return()=>clearInterval(d)},[n,o]);const c=s<300;return r.jsx("span",{className:`ttl-badge ${c?"ttl-warn":"ttl-ok"}`,children:z0(s)})}function qr({icon:n,title:s,text:i,children:o}){return r.jsxs("div",{className:"empty-state",children:[n&&r.jsx("div",{className:"empty-state-icon",children:n}),r.jsx("div",{className:"empty-state-title",children:s}),i&&r.jsx("div",{className:"empty-state-text",children:i}),o]})}function O0(n){const s=Math.floor(n/86400);if(s>=1)return`${s} day${s===1?"":"s"}`;const i=Math.floor(n/3600);if(i>=1)return`${i} hour${i===1?"":"s"}`;const o=Math.ceil(n/60);return`${o} minute${o===1?"":"s"}`}const M0=[{label:"30m",seconds:1800},{label:"1h",seconds:3600},{label:"2h",seconds:7200},{label:"4h",seconds:14400},{label:"8h",seconds:28800},{label:"24h",seconds:86400},{label:"7d",seconds:604800},{label:"30d",seconds:2592e3},{label:"1y",seconds:31536e3}];function B0({item:n,onClose:s,onSuccess:i}){var $;const{user:o,activeDomain:c,groupId:d}=vt(),[h,g]=f.useState(null);f.useEffect(()=>{let P=!1;return B.getProfile(n.profile_id).then(D=>{var K;P||g(((K=D==null?void 0:D.ttl)==null?void 0:K.max)??null)}).catch(()=>{}),()=>{P=!0}},[n.profile_id]);const p=n.remaining_seconds??0,y=M0.filter(P=>P.seconds>p&&(h===null||P.seconds<=h)),v=(($=y[0])==null?void 0:$.seconds)??2592e3,[j,w]=f.useState(v);f.useEffect(()=>{var P;if(h!==null&&j>h){const D=(P=y[y.length-1])==null?void 0:P.seconds;D&&w(D)}},[h]);const[N,E]=f.useState(!1),[k,C]=f.useState(""),T=Object.entries(n.frame).filter(([P])=>P!=="profile"&&P!=="path"),I=async()=>{var P;if(o){E(!0),C("");try{const D=n.authorization_id,K=await B.getGateContent(D);if(!K)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const V=await B.getProfile(n.profile_id),ce=n.frame,Y=K.context??{},re=n.attested_domains[0]||c||"owner",J=await pi(ce,V),O=await Dm(Y,V),[fe,ie]=await Promise.all([ji(K.gateContent.intent),ji(JSON.stringify({profile:n.profile_id,path:n.path,domain:re}))]);if(!d)throw new Error("No active group; cannot extend mandate.");const Z=(((P=n.deferred_commitment_domains)==null?void 0:P.length)??0)>0?"review":"automatic",pe=await Um(V),ee=await B.attest({authorization_id:n.authorization_id,renew:!0,profile_id:n.profile_id,profile_hash:pe,supported_versions:["0.7"],bounds:ce,bounds_hash:J,scope_hash:O,domain:re,did:o.did,mandate_owners:[{did:o.did}],gate_content_hashes:{intent:fe},execution_context_hash:ie,group_id:d,commitment_mode:Z,ttl:j});await B.pushGateContent(Wm(ee,{boundsHash:J,contextHash:O,context:Y,path:n.path,gateContent:K.gateContent})),i()}catch(D){C(D instanceof Error?D.message:"Extension failed")}finally{E(!1)}}};return r.jsx("div",{className:"modal-backdrop",onClick:P=>P.target===P.currentTarget&&s(),children:r.jsxs("div",{className:"modal",children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h3",{className:"modal-title",children:"Extend mandate"}),r.jsx("button",{className:"modal-close",onClick:s,children:"×"})]}),r.jsxs("div",{className:"modal-body",children:[r.jsxs("div",{style:{marginBottom:"1rem"},children:[r.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[dt(n.profile_id)," / ",n.path]}),T.length>0&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:T.map(([P,D])=>`${P}=${D}`).join(" · ")})]}),r.jsxs("div",{style:{marginBottom:"1rem"},children:[r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),p>0&&r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",O0(p),". Only longer durations are shown."]}),r.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:y.length===0?r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This mandate is already on the longest available duration. Nothing to extend."}):y.map(P=>r.jsx("button",{className:`btn ${j===P.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>w(P.seconds),style:{minWidth:"3.5rem"},children:P.label},P.seconds))})]}),r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, scope, and gate content will be re-signed with a new TTL (measured from now)."}),k&&r.jsx("div",{className:"error-message",children:k})]}),r.jsxs("div",{className:"modal-footer",children:[r.jsx("button",{className:"btn btn-secondary",onClick:s,disabled:N,children:"Cancel"}),r.jsx("button",{className:"btn btn-primary",onClick:I,disabled:N,children:N?"Extending...":"Extend"})]})]})})}function Tf(n){return n.replace(/@.*$/,"").split("/").pop()??n}function Rf(n){return n.split("@")[1]??""}function D0(n,s){return Rf(n).localeCompare(Rf(s),void 0,{numeric:!0})>0}function Jm(n,s){const i=Tf(n);let o;for(const c of s)Tf(c.id)===i&&(!o||D0(c.id,o.id))&&(o=c);return o}function qm(n,s){var o;if(!s)return{};const i={};for(const c of s.keyOrder){if(c==="profile"||c==="path")continue;if(n[c]!==void 0){i[c]=n[c];continue}const d=(o=s.fields[c])==null?void 0:o.default;(typeof d=="string"||typeof d=="number"&&Number.isFinite(d))&&(i[c]=d)}return i}function Qm(n,s){return qm(n,s.boundsSchema)}function Xm(n,s){return qm(n,s.scopeSchema)}function U0(n,s,i){return[...n].sort((o,c)=>{if(i){if(o.authorization_id===i&&c.authorization_id!==i)return-1;if(c.authorization_id===i&&o.authorization_id!==i)return 1}const d=xi(o,s),h=xi(c,s),g={active:0,pending:1,expired:2,revoked:3,archived:4};return g[d]!==g[h]?g[d]-g[h]:new Date(c.created_at).getTime()-new Date(o.created_at).getTime()})}function W0({item:n,newerProfile:s,revokedSet:i,expandedHash:o,gateCache:c,gateLoading:d,copiedHash:h,revokingHash:g,copyingHash:p,profileConfigCache:y,mode:v,ownerLabel:j,isAdmin:w,onExpand:N,onCopyHash:E,onCopy:k,onRevoke:C,onExtend:T,archivedSet:I,archivingHash:$,onArchive:P,highlightHash:D,needsReapprovalSet:K}){var $e;const V=tc(n,{revokedSet:i}),ce=V==="active"&&((K==null?void 0:K.has(n.authorization_id))??!1),Y=Sm(n,{revokedSet:i,archivedSet:I}),re=!j&&!!P&&jm(V),J=o===n.authorization_id,O=c[n.authorization_id],fe=V==="active"||V==="pending"||V==="expired",ie=Object.entries(n.frame).filter(([Ee])=>Ee!=="profile"&&Ee!=="path"),Z=y.get(n.profile_id)??null,pe=((($e=Z==null?void 0:Z.approvers)==null?void 0:$e.length)??0)>0,ee=new Map;if(Z!=null&&Z.caps&&v==="team")for(const[Ee,_e]of ie){const me=Z.caps[Ee];me!==void 0&&Number(_e)>me&&ee.set(Ee,{authorized:Number(_e),cap:me})}const W=ee.size>0,M=n.approvers_frozen??[],H=(Z==null?void 0:Z.approvers)??[],S=v==="team"&&M.length>0&&H.length>0&&(M.length!==H.length||M.some(Ee=>!H.includes(Ee))||H.some(Ee=>!M.includes(Ee))),A=Array.from(ee.entries()).map(([Ee,_e])=>`${Ee}: ${_e.authorized} (cap ${_e.cap})`).join(", "),G=Array.from(ee.entries()).map(([Ee,_e])=>`${Ee}: ${_e.authorized} → ${_e.cap}`).join(", "),te=W?pe?ee.size===1?`Above team cap: ${A} — actions require approval`:`Above team cap (${ee.size}): ${A} — actions require approval`:ee.size===1?`Reduced by hard cap: ${G}`:`Reduced by hard cap (${ee.size}): ${G}`:"",ue=W?pe?"Above-cap actions under this mandate require per-action approval from the profile's approvers. Bounds remain authorized at their original values.":"No approvers are configured for this profile, so the team cap is a hard ceiling. Bounds above the cap are effectively reduced to the cap. Ask the admin to raise the cap or add approvers, or copy this mandate to reissue within the cap.":void 0,ve=Sr(n.profile_id),Ce=ve.name,ke=s?r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem",padding:"0.4rem 0.6rem",border:"1px solid var(--border)",borderRadius:6},children:[r.jsxs("strong",{style:{color:"var(--text-secondary)"},children:[Ce,"@",s.version," available"]}),s.whatsNew?r.jsxs(r.Fragment,{children:[" — ",s.whatsNew]}):null,r.jsx("br",{}),r.jsxs("span",{children:["This mandate stays on ",n.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,se=D!=null&&n.authorization_id===D;return r.jsxs("div",{className:`card id-card${se?" card-highlight":""}`,style:{marginBottom:0},children:[r.jsx(qs,{profileId:n.profile_id}),r.jsxs("div",{className:"id-body",children:[ke,j&&r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",r.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:j})]}),r.jsxs("div",{className:"auth-card-header",children:[r.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:n.title||Ce}),r.jsx(_0,{status:V}),ce&&r.jsx("span",{title:"The Authority Server no longer verifies this mandate's protocol version. Re-approve it to keep using this authority.",style:{fontSize:"0.75rem",fontWeight:700,color:"var(--text-on-warning, #7a4a00)",background:"var(--warning-bg, #fff3cd)",borderRadius:"4px",padding:"2px 6px"},children:"Needs re-approval"}),ve.testSetup&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),V==="active"&&n.earliest_expiry&&r.jsx(F0,{expiresAt:new Date(n.earliest_expiry).getTime()/1e3}),V==="expired"&&(()=>{const Ee=dv(n,V);return Ee?r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(Ee.iso).toLocaleString()}`,children:new Date(Ee.iso).toLocaleDateString(void 0,{month:"short",day:"numeric"})}):null})()]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[n.required_domains.map(Ee=>r.jsx(L0,{domain:Ee,attested:n.attested_domains.includes(Ee)},Ee)),n.deferred_commitment_domains.length>0&&r.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Review Mode"}),W&&r.jsx("span",{title:ue,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:pe?"var(--accent-subtle)":"var(--danger-subtle)",color:pe?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:te}),S&&r.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.65rem",padding:"0.15rem 0.5rem",borderRadius:"0.25rem",background:"var(--warning-subtle, rgba(234,179,8,0.12))",color:"var(--warning, #ca8a04)",fontWeight:600,border:"1px solid var(--warning-border, rgba(234,179,8,0.3))",cursor:"pointer",lineHeight:1.4},onClick:()=>k(n),disabled:p===n.authorization_id,title:"The approver list for this profile has changed since this mandate was created. Copy to reissue with the current approvers.",children:p===n.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),ie.length>0&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:ie.map(([Ee,_e],me)=>{const X=ee.get(Ee);return r.jsxs("span",{children:[me>0&&" · ",X?pe?r.jsxs("span",{title:`Team cap on ${Ee} is ${X.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${X.authorized}.`,children:[r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[Ee,"=",String(_e)]}),r.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",X.cap]})]}):r.jsxs("span",{title:`Team cap on ${Ee} is ${X.cap} with no approvers configured (hard cap). Authorized for ${X.authorized}; effective ${X.cap}.`,children:[r.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[Ee,"=",String(_e)]}),r.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",X.cap]})]}):r.jsxs("span",{children:[Ee,"=",String(_e)]})]},Ee)})}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[re&&r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>P(n.authorization_id,!Y),disabled:$===n.authorization_id,title:Y?"Move back to the Expired or Revoked list":"Hide from the list and the nav badge. Nothing is deleted: the mandate and its tickets stay stored and verifiable.",children:$===n.authorization_id?Y?"Unarchiving…":"Archiving…":Y?"↩ Unarchive":"⊟ Archive"}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>N(n),children:J?"▲ Hide Details":"▼ Details"})]}),J&&r.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[ie.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Bounds"}),r.jsx("dl",{className:"review-grid",children:ie.map(([Ee,_e])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:Ee}),r.jsx("dd",{children:String(_e)})]},Ee))})]}),(O==null?void 0:O.context)&&Object.keys(O.context).length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Scope"}),r.jsx("dl",{className:"review-grid",children:Object.entries(O.context).map(([Ee,_e])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:Ee}),r.jsx("dd",{title:String(_e),children:Hm(Ee,_e,O.contextLabels)})]},Ee))})]}),r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Intent"}),d===n.authorization_id?r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):O?r.jsx("div",{className:"gate-content-block",children:r.jsx("div",{className:"gate-content-item",children:r.jsx("div",{className:"gate-content-text",children:O.gateContent.intent})})}):r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"1rem"},children:["Created: ",new Date(n.created_at).toLocaleString(),n.earliest_expiry&&` · Expires: ${new Date(n.earliest_expiry).toLocaleString()}`]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:n.authorization_id}),r.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>E(n.authorization_id),children:h===n.authorization_id?"copied":"copy"})]}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!j&&r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>k(n),disabled:p===n.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:p===n.authorization_id?"Copying…":"⧉ Copy"}),!j&&(V==="active"||V==="pending")&&r.jsx("button",{className:ce?"btn btn-primary btn-sm":"btn btn-secondary btn-sm",onClick:()=>k(n,{asEdit:!0}),disabled:p===n.authorization_id,title:ce?"The Authority Server no longer verifies this mandate's protocol version. Re-approving opens the ceremony pre-filled with the same bounds, scope, and intent; signing it revokes this one.":"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new mandate revokes this one",children:ce?"⚠ Re-approve":"✎ Edit"}),!j&&fe&&r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>T(n),children:"↻ Extend"}),j&&w&&V!=="revoked"?r.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>C(n.authorization_id,j,Ce),disabled:g===n.authorization_id,children:g===n.authorization_id?"Revoking…":"Revoke"}):!j&&(V==="active"||V==="pending")?r.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>C(n.authorization_id),disabled:g===n.authorization_id,children:g===n.authorization_id?"Revoking…":"Revoke"}):null]})]})]})]},n.authorization_id)}function H0(){const[n,s]=f.useState([]),[i,o]=f.useState(!0),[c,d]=f.useState([]),[h,g]=f.useState(!1),[p,y]=f.useState(new Map),[v,j]=f.useState("mine"),[w,N]=f.useState("active"),[E,k]=f.useState(null),[C,T]=f.useState(null),[I,$]=Xl(),[P,D]=f.useState(()=>I.get("new")==="1"),[K]=f.useState(()=>I.get("profile")),[V,ce]=f.useState(()=>I.get("highlight")),[Y,re]=f.useState(null),[J,O]=f.useState({}),[fe,ie]=f.useState(null),[Z,pe]=f.useState(null),[ee,W]=f.useState(null),[M,H]=f.useState(new Set),[S,A]=f.useState(null),[G,te]=f.useState(new Set),[ue,ve]=f.useState(null),[Ce,ke]=f.useState(null),[se,$e]=f.useState(new Set),Ee=dn(),{group:_e,groupId:me,domain:X,mode:we,activeTeam:Te}=vt(),Le=(Te==null?void 0:Te.isAdmin)===!0,[lt,xt]=f.useState(()=>new Map),Ke=f.useCallback(()=>{o(!0),B.getMyAttestations().then(s).catch(()=>{}).finally(()=>o(!1))},[]),et=f.useCallback(()=>{B.getArchivedMandates().then(ae=>te(new Set(ae))).catch(()=>{})},[]);f.useEffect(()=>{et()},[et]);const st=f.useCallback(()=>{B.getEnrichedAuthorizations().then(ae=>$e(new Set(ae.filter(je=>je.needsReapproval).map(je=>je.authorizationId)))).catch(()=>{})},[]);f.useEffect(()=>{st()},[st]);const ht=async(ae,je)=>{ve(ae);try{const ge=await B.setMandateArchived(ae,je);te(new Set(ge)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(ge){alert(ge instanceof Error?ge.message:"Failed to update archive")}finally{ve(null)}},Fe=f.useCallback(()=>{me&&(g(!0),B.listTeamAuthorizations(me).then(d).catch(()=>{}).finally(()=>g(!1)))},[me]);He("attestation-changed",()=>{Ke(),Le&&me&&Fe(),st()}),f.useEffect(()=>{if(!V)return;I.get("highlight")&&(I.delete("highlight"),$(I,{replace:!0}));const ae=window.setTimeout(()=>ce(null),3e3);return()=>window.clearTimeout(ae)},[]),Zt(Ke,3e5),f.useEffect(()=>{v==="team"&&Le&&me&&c.length===0&&!h&&Fe()},[v,Le,me,c.length,h,Fe]),f.useEffect(()=>{let ae=!1;return B.listProfiles().then(je=>{if(ae)return;const ge=Je=>Je.replace(/@.*$/,"").split("/").pop()??Je,Me=Je=>Je.split("@")[1]??"",ze=new Map;for(const Je of je){const Dt=ge(Je.id),Xn=ze.get(Dt);(!Xn||Me(Je.id).localeCompare(Me(Xn.id),void 0,{numeric:!0})>0)&&ze.set(Dt,Je)}y(ze)}).catch(()=>{}),()=>{ae=!0}},[]);const L=f.useCallback(ae=>{const je=Dt=>Dt.replace(/@.*$/,"").split("/").pop()??Dt,ge=Dt=>Dt.split("@")[1]??"",Me=p.get(je(ae));if(!Me)return;const ze=ge(ae),Je=ge(Me.id);if(!(!ze||!Je))return Je.localeCompare(ze,void 0,{numeric:!0})>0?Me:void 0},[p]);f.useEffect(()=>{if(we!=="team"||!me)return;const ae=v==="mine"?n:c;if(ae.length===0)return;const je=[...new Set(ae.map(ge=>ge.profile_id))].filter(ge=>!lt.has(ge));if(je.length!==0){xt(ge=>{const Me=new Map(ge);for(const ze of je)Me.set(ze,null);return Me});for(const ge of je)B.getTeamProfileConfig(me,ge).then(Me=>{xt(ze=>new Map(ze).set(ge,Me))}).catch(()=>{})}},[n,c,v,me,we,lt]);const oe=async ae=>{if(Y===ae.authorization_id){re(null);return}re(ae.authorization_id);const je=ae.authorization_id;if(!(je in J)){ie(ae.authorization_id);try{const ge=await B.getGateContent(je);O(Me=>({...Me,[je]:ge}))}catch{O(ge=>({...ge,[je]:null}))}finally{ie(null)}}},he=ae=>{navigator.clipboard.writeText(ae).then(()=>{W(ae),setTimeout(()=>W(null),2e3)})},Re=async(ae,je)=>{var ge;if(!me){alert("No active group; cannot copy mandate.");return}ke(ae.authorization_id);try{const Me=ae.authorization_id;let ze=J[Me]??null;Me in J||(ze=await B.getGateContent(Me),O(wn=>({...wn,[Me]:ze})));const Je=Object.fromEntries(Object.entries(ae.frame).filter(([wn])=>wn!=="profile"&&wn!=="path")),Dt=(ze==null?void 0:ze.context)??{},Xn=((ge=ze==null?void 0:ze.gateContent)==null?void 0:ge.intent)??"",ts=ae.deferred_commitment_domains.length>0?"review":"automatic",Xs=ae.attested_domains[0]||X||"owner",xn=Date.parse(ae.created_at),Zn=ae.earliest_expiry?Date.parse(ae.earliest_expiry):NaN,er=Number.isFinite(xn)&&Number.isFinite(Zn)&&Zn>xn?Math.round((Zn-xn)/1e3):void 0;let Zs=ae.profile_id,Pn=Je,tr=Dt,nr;const ns=await B.listProfiles(),kr=Jm(ae.profile_id,ns);if(kr&&kr.id!==ae.profile_id){const wn=await B.getProfile(kr.id);Zs=kr.id,Pn=Qm(Je,wn),tr=Xm(Dt,wn),nr=ae.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Zs,groupId:me,groupName:(_e==null?void 0:_e.name)??null,domain:Xs,isPersonal:!!(_e!=null&&_e.isPersonal),upgradedFromProfileId:nr})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:Pn,context:tr,gateContent:{intent:Xn},templateMode:ts,templateTtl:er})),je!=null&&je.asEdit?sessionStorage.setItem("agentEditReplaces",ae.authorization_id):sessionStorage.removeItem("agentEditReplaces"),Ee("/mandates/new/intent")}catch(Me){alert(Me instanceof Error?Me.message:"Failed to copy mandate")}finally{ke(null)}},de=async(ae,je,ge)=>{const Me=je&&ge?`Revoke ${je}'s ${ge} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(Me)){A(ae);try{await B.revokeAttestation(ae),H(ze=>new Set(ze).add(ae)),B.resyncGates().catch(()=>{}),je&&me&&Fe()}catch(ze){alert(ze instanceof Error?ze.message:"Failed to revoke mandate")}finally{A(null)}}},Oe=v==="mine"?n:c,Ge=v==="mine"?i:h,Ye=v==="mine"?{revokedSet:M,archivedSet:G}:{revokedSet:M},ft=ae=>xi(ae,Ye),fn={active:0,pending:0,expired:0,revoked:0,archived:0};for(const ae of Oe)fn[ft(ae)]+=1;const vn=v==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],tt=(()=>{const ae=new Map;for(const je of Oe){if(ft(je)!==w)continue;const ge=ae.get(je.profile_id)??{count:0,review:!1};ge.count+=1,je.deferred_commitment_domains.length>0&&(ge.review=!0),ae.set(je.profile_id,ge)}return Array.from(ae.entries()).map(([je,ge])=>({profileId:je,...ge})).sort((je,ge)=>dt(je.profileId).localeCompare(dt(ge.profileId)))})(),bt=U0(Oe.filter(ae=>{if(ft(ae)!==w||E!==null&&ae.profile_id!==E)return!1;if(C!==null){const je=ae.deferred_commitment_domains.length>0;if(C==="review"&&!je||C==="auto"&&je)return!1}return!0}),Ye,V),Et={revokedSet:M,expandedHash:Y,gateCache:J,gateLoading:fe,copiedHash:ee,revokingHash:S,copyingHash:Ce,profileConfigCache:lt,mode:we,activeDomain:X,group:_e,groupId:me,onExpand:oe,onCopyHash:he,onCopy:Re,onRevoke:de,onExtend:pe,highlightHash:V},wt={...Et,archivedSet:G,archivingHash:ue,onArchive:ht,needsReapprovalSet:se};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:"Mandates"}),r.jsx("p",{className:"page-subtitle",children:"Active, pending, expired, and archived agent mandates."})]}),r.jsx("button",{className:"btn btn-primary",onClick:()=>D(!0),children:"+ New mandate"})]}),P&&r.jsx("div",{className:"modal-backdrop",onClick:()=>{D(!1),(I.get("new")||I.get("profile"))&&(I.delete("new"),I.delete("profile"),$(I,{replace:!0}))},children:r.jsxs("div",{className:"modal",onClick:ae=>ae.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h2",{className:"modal-title",children:"New mandate"}),r.jsx("button",{className:"modal-close",onClick:()=>{D(!1),(I.get("new")||I.get("profile"))&&(I.delete("new"),I.delete("profile"),$(I,{replace:!0}))},children:"×"})]}),r.jsxs("div",{className:"modal-body",children:[r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem",marginTop:0,marginBottom:"1rem"},children:"What should your agent be able to do? Pick a profile, set limits, then authorize."}),r.jsx(A0,{onDismiss:()=>D(!1),preselectProfileId:K})]})]})}),Le&&r.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[r.jsx("button",{className:`nav-tab${v==="mine"?" active":""}`,onClick:()=>{j("mine"),N("active"),k(null),T(null),re(null)},children:"Mine"}),r.jsx("button",{className:`nav-tab${v==="team"?" active":""}`,onClick:()=>{j("team"),N("active"),k(null),T(null),re(null)},children:"Team"})]}),r.jsx("div",{className:"nav-tabs",children:vn.map(ae=>r.jsxs("button",{className:`nav-tab${w===ae?" active":""}`,onClick:()=>{N(ae),k(null),T(null)},children:[ae.charAt(0).toUpperCase()+ae.slice(1)," (",fn[ae],")"]},ae))}),tt.length>0&&r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[tt.map(ae=>{const je=E===ae.profileId;return r.jsx("button",{className:`btn btn-sm ${je?"btn-primary":"btn-secondary"}`,onClick:()=>k(je?null:ae.profileId),children:dt(ae.profileId)},ae.profileId)}),r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(ae=>{const je=C===ae;return r.jsx("button",{className:`btn btn-sm ${je?"btn-primary":"btn-secondary"}`,onClick:()=>T(je?null:ae),children:ae==="auto"?"Auto":"Review"},ae)})]}),Ge&&Oe.length===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):bt.length===0?r.jsx(qr,{icon:"☰",title:"No mandates",text:w==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${w} mandates found.`}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:bt.map(ae=>{const je=v==="team"?ae:null,ge=je!=null&&je.owner?je.owner.name??je.owner.email??je.owner.userId:void 0;return r.jsx(W0,{item:ae,newerProfile:L(ae.profile_id),ownerLabel:ge,isAdmin:Le,...v==="mine"?wt:Et},ae.authorization_id)})}),Z&&r.jsx(B0,{item:Z,onClose:()=>pe(null),onSuccess:()=>{pe(null),Ke()}})]})}const V0=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function es(n){const s=n.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)}function fc(n){const s=n.indexOf("__");return s<0?{integrationId:"",toolName:n}:{integrationId:n.slice(0,s),toolName:n.slice(s+2)}}function G0(n){const{integrationId:s,toolName:i}=fc(n);return s?`${s} · ${i}`:i}function Zm(n,s){const i=s==null?void 0:s.find(o=>o.id===n);return i!=null&&i.name?i.name:n?n.toUpperCase():"the system"}function K0(n){return Array.isArray(n)?"list":n&&typeof n=="object"?"object":typeof n=="string"&&(n.includes(`
80
- `)||n.length>120)?"markdown":"text"}function Y0(n,s){var h,g;const i=(s==null?void 0:s.approvalView)??{},o=((h=s==null?void 0:s.inputSchema)==null?void 0:h.properties)??{},c=[...new Set([...Object.keys(i),...Object.keys(o),...Object.keys(n)])],d=[];for(const p of c){if(!(p in n)||V0.has(p))continue;const y=n[p],v=i[p]??{},j=v.kind??K0(y),w={key:p,label:v.label??es(p),kind:j,value:y,hint:(g=o[p])==null?void 0:g.description};j==="money"&&v.currencyArg&&typeof n[v.currencyArg]=="string"&&(w.currency=n[v.currencyArg]),j==="profile"&&typeof y=="string"&&(w.profileRef=y),(j==="profile-limits"||j==="profile-scope")&&v.profileArg&&typeof n[v.profileArg]=="string"&&(w.profileRef=n[v.profileArg]),d.push(w)}return d}function eh(n,s){var o,c;const i=(c=(o=s==null?void 0:s.scopeSchema)==null?void 0:o.fields)==null?void 0:c[n];return i?{label:i.displayName??n,hint:i.description}:{label:n}}function J0(n,s,i){if(!n||typeof n!="object"||Array.isArray(n))return[];const o=i==="limits"?s==null?void 0:s.boundsSchema:s==null?void 0:s.scopeSchema,c=(o==null?void 0:o.fields)??{},d=[...new Set([...(o==null?void 0:o.keyOrder)??[],...Object.keys(n)])],h=[];for(const g of d){if(g==="profile"||!(g in n))continue;const p=n[g],y=c[g],v=cc(y==null?void 0:y.unit),j=Array.isArray(p)?p.join(", "):String(p);h.push({key:g,label:(y==null?void 0:y.displayName)??es(g),value:v?`${j} ${v}`:j,hint:y==null?void 0:y.description,unknown:s?!y:void 0})}return h}function q0(n){const s=n.indexOf("__");return s<0?{integrationId:"",toolName:n}:{integrationId:n.slice(0,s),toolName:n.slice(s+2)}}function Q0(n,s){var p,y,v;const{integrationId:i,toolName:o}=q0(n.action),c=s.find(j=>j.id===i),d=(y=(p=c==null?void 0:c.toolGating)==null?void 0:p.overrides)==null?void 0:y[o];if(d!=null&&d.actionLabel)return d.actionLabel;const h=dt(n.profileId),g=(v=n.executionContext)==null?void 0:v.action_type;return typeof g=="string"&&g?`${h} · ${g}`:`${h} · ${o}`}function X0(n,s){var c;const i=(c=s==null?void 0:s.scopeSchema)==null?void 0:c.fields;if(!i)return"";const o=[];for(const[d,h]of Object.entries(n.executionContext??{})){if(!(d in i))continue;const g=String(h??"").trim();g&&o.push(g.split(",").map(p=>p.trim()).filter(Boolean).join(", "))}return o.join(" · ")}function Z0(n,s){var c,d;if(!n)return"";const i=((c=s==null?void 0:s.scopeSchema)==null?void 0:c.fields)??{},o=[];for(const[h,g]of Object.entries(n)){if(h==="action_type")continue;const p=String(g??"").trim();if(!p)continue;const y=((d=i[h])==null?void 0:d.displayName)??h;o.push(`${y} ${p.split(",").map(v=>v.trim()).filter(Boolean).join(", ")}`)}return o.join(" · ")}function If(n){return n.appliesTo}function ew(n,s,i){var g,p,y,v;const o=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],c=n.actionType??(typeof((g=n.executionContext)==null?void 0:g.action_type)=="string"?n.executionContext.action_type:void 0),d=(p=i==null?void 0:i.boundsSchema)==null?void 0:p.fields,h=[];for(const{window:j,label:w}of o){const N=(y=n.cumulativeState)==null?void 0:y[j];if(!N)continue;let E;if(d&&s){const T=Object.entries(d).filter(([P,D])=>{if(!(P in s))return!1;const K=D.boundType;if(!K||K.kind!=="cumulative_sum"&&K.kind!=="cumulative_count"||K.window!==j)return!1;const V=If(D);return!V||!c||V.includes(c)}),$=(c?T.find(([,P])=>{var D;return(D=If(P))==null?void 0:D.includes(c)}):void 0)??(T.length===1?T[0]:void 0);$&&(E={key:$[0],isAmount:((v=$[1].boundType)==null?void 0:v.kind)==="cumulative_sum"})}const k=E?E.isAmount?N.amount:N.count:void 0,C=E?Number(s==null?void 0:s[E.key]):NaN;E&&Number.isFinite(C)?h.push(`${k} of ${C} ${w}`):h.push(`${N.count} ${N.count===1?"call":"calls"} ${w}`)}return h.join(" · ")}function tw(n,s,i){var d;const o=(d=i==null?void 0:i.boundsSchema)==null?void 0:d.fields;if(!n||!s||!o)return[];const c=[];for(const[h,g]of Object.entries(o)){const p=g.boundType;if(!p||p.kind!=="per_transaction")continue;const y=p.of;if(!(y in n)||!(h in s))continue;const v=Number(n[y]),j=Number(s[h]);if(!Number.isFinite(v)||!Number.isFinite(j))continue;const w=cc(g.unit),N=g.displayName??es(y),E=k=>w?`${k.toLocaleString()} ${w}`:k.toLocaleString();c.push({key:h,label:N,ok:v<=j,valueText:E(v),limitText:E(j)})}return c}function nw(n){return typeof n.proposalId=="string"&&n.proposalId.length>0}function rw(n){const s=dt(n),i=n.split("@")[1];return i?`${s}@${i}`:s}const Af=new Map;function sw(n){let s=Af.get(n);return s||(s=(async()=>{try{let i=n;if(!n.includes("@")){const o=await B.listProfiles(),c=h=>h.replace(/@.*$/,"").split("/").pop(),d=o.filter(h=>c(h.id)===n).sort((h,g)=>(g.id.split("@")[1]??"").localeCompare(h.id.split("@")[1]??"",void 0,{numeric:!0}));if(!d[0])return null;i=d[0].id}return await B.getProfile(i)}catch{return null}})(),Af.set(n,s)),s}function Qs(n){const[s,i]=f.useState(null);return f.useEffect(()=>{let o=!0;return n&&sw(n).then(c=>{o&&i(c)}),()=>{o=!1}},[n]),s}async function Pf(n){const s=new TextEncoder().encode(n),i=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(i)).map(o=>o.toString(16).padStart(2,"0")).join("")}function aw(n){return n.normalize("NFC").replace(/\r\n?/g,`
81
- `).split(`
82
- `).map(c=>c.replace(/[ \t]+$/,"")).join(`
83
- `).replace(/\n+$/,"")}function $l(n){if(n===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof n=="number"&&!Number.isFinite(n))throw new Error(`canonicalize: ${n} is not a valid JSON number`);if(n===null||typeof n!="object")return JSON.stringify(n);if(Array.isArray(n))return"["+n.map(c=>c===void 0?"null":$l(c)).join(",")+"]";const s=n,i=[];for(const o of Object.keys(s).sort()){const c=s[o];c!==void 0&&i.push(JSON.stringify(o)+":"+$l(c))}return"{"+i.join(",")+"}"}async function th(n,s){if(n==="jcs"){if(typeof s=="string")throw new Error('content_binding kind="jcs" expects a record payload (object), got a string');return`sha256:${await Pf($l(s))}`}if(typeof s!="string")throw new Error('content_binding kind="text" expects a string, got an object');return`sha256:${await Pf(aw(s))}`}function vr(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Rn(n,s=!1){return n==null?"—":typeof n=="string"?n:typeof n=="boolean"?String(n):typeof n=="number"?s||Number.isInteger(n)?String(n):String(Math.round(n*100)/100):"—"}function iw(n){return n==null?!1:typeof n=="string"||Array.isArray(n)?n.length>0:!0}function Ws(n,s,i){const o=s?Object.keys(s).filter(c=>c in n):Object.keys(n);return o.length===0?"—":o.map(c=>{var p,y;const d=n[c],h=((p=s==null?void 0:s[c])==null?void 0:p.title)??es(c),g=vr(d)?Ws(d,(y=s==null?void 0:s[c])==null?void 0:y.properties,i):Rn(d,i);return`${h}: ${g}`}).join(" · ")}function ow(n){return n.split(`
84
- `).map(s=>s.startsWith("+")&&!s.startsWith("+++")?{text:s,kind:"add"}:s.startsWith("-")&&!s.startsWith("---")?{text:s,kind:"remove"}:{text:s,kind:"context"})}function lw(n,s){var c;if(Array.isArray(n)){if(n.length===0)return{value:"—"};if(n.every(y=>!vr(y)&&!Array.isArray(y))){if(n.every(j=>typeof j=="string"))return{lines:n};const y=n.map(j=>Rn(j)).join(", "),v=n.map(j=>Rn(j,!0)).join(", ");return v===y?{value:y}:{value:y,valueTitle:v}}const d=(c=s==null?void 0:s.items)==null?void 0:c.properties,h=n.map(y=>vr(y)?Ws(y,d,!1):Rn(y)),g=n.map(y=>vr(y)?Ws(y,d,!0):Rn(y,!0)),p=h.map((y,v)=>y===g[v]?void 0:g[v]);return p.some(y=>y!==void 0)?{lines:h,lineTitles:p}:{lines:h}}if(vr(n)){const d=s==null?void 0:s.properties,h=d?Object.keys(d).filter(y=>y in n):Object.keys(n);if(h.length>0&&h.every(y=>!vr(n[y])&&!Array.isArray(n[y])))return{sublist:h.map(v=>{var k;const j=n[v],w=((k=d==null?void 0:d[v])==null?void 0:k.title)??es(v),N=Rn(j),E=Rn(j,!0);return E===N?{key:v,label:w,value:N}:{key:v,label:w,value:N,valueTitle:E}})};const g=Ws(n,d,!1),p=Ws(n,d,!0);return p===g?{value:g}:{value:g,valueTitle:p}}if(typeof n=="string"&&(s==null?void 0:s.contentMediaType)==="text/x-diff")return{diffLines:ow(n)};const i=Rn(n),o=Rn(n,!0);return o===i?{value:i}:{value:i,valueTitle:o}}function cw(n){let s;try{s=JSON.parse(n)}catch{return null}return vr(s)?s:null}function ki(n){const s=n!=null&&n.structured&&Object.keys(n.structured).length>0?n.structured:void 0;if(s)return{obj:s,schema:n==null?void 0:n.outputSchema};const i=n!=null&&n.text?cw(n.text):null;return i?{obj:i}:null}function zl(n){const s=ki(n);if(!s)return[];const{obj:i,schema:o}=s,c=(o==null?void 0:o.properties)??{},d=[...new Set([...Object.keys(c),...Object.keys(i)])],h=[];for(const g of d){if(!(g in i))continue;const p=c[g],y=(p==null?void 0:p.title)??es(g),v={key:g,label:y,...lw(i[g],p)};p!=null&&p.description&&(v.description=p.description),h.push(v)}return h}function Fl(n,s){const i=ki(n);if(i){const c=zl(n),d=s==null?void 0:s.fields;let h;if(d&&d.length>0){const y=new Map(c.map(v=>[v.key,v]));h=d.map(v=>y.get(v)).filter(v=>v!==void 0)}else h=c.filter(y=>iw(i.obj[y.key]));const g=new Set(h.map(y=>y.key)),p=c.filter(y=>!g.has(y.key));return{kind:"structured",fields:h,moreFields:p,totalFields:c.length}}const o=n==null?void 0:n.text;return o&&o.trim().length>0?{kind:"text",fields:[],moreFields:[],totalFields:0,text:o}:{kind:"empty",fields:[],moreFields:[],totalFields:0}}function _f(n){return n?n.lines?`lines:${JSON.stringify(n.lines)}`:n.sublist?`sublist:${JSON.stringify(n.sublist.map(s=>[s.key,s.value]))}`:n.diffLines?`diffLines:${JSON.stringify(n.diffLines)}`:`value:${n.value??""}`:""}function di(n){return{kind:n.length>0?"structured":"empty",fields:n,moreFields:[],totalFields:n.length}}function uw(n,s,i){const o=ki(n),c=ki(s);if(!o&&!c){const w=(n==null?void 0:n.text)??"",N=(s==null?void 0:s.text)??"";return w===N?{approved:di([]),current:di([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:w},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:N},unchanged:!1}}const d=new Map(zl(n).map(w=>[w.key,w])),h=new Map(zl(s).map(w=>[w.key,w])),p=[...new Set([...d.keys(),...h.keys()])].filter(w=>w===(i==null?void 0:i.excludeKey)?!1:_f(d.get(w))!==_f(h.get(w))),y=i!=null&&i.fields&&i.fields.length>0?[...i.fields.filter(w=>p.includes(w)),...p.filter(w=>!i.fields.includes(w))]:p,v=y.map(w=>d.get(w)).filter(w=>w!==void 0),j=y.map(w=>h.get(w)).filter(w=>w!==void 0);return{approved:di(v),current:di(j),unchanged:p.length===0}}function dw(n){return n.offDevice?"off-device":n.boundContent===void 0?"none":n.hasHashToCheck?n.hashVerified===!0?"verified":"mismatch":"unchecked"}function fw(n,s){return n===void 0?{kind:"empty",fields:[],moreFields:[],totalFields:0}:typeof n=="string"?Fl({text:n}):Fl({structured:n},{fields:s})}function mw(n,s){return n?Object.entries(n).filter(([,i])=>i!=null&&i!=="").map(([i,o])=>({key:i,label:eh(i,s).label,value:String(o)})):[]}function hw({row:n}){return r.jsxs("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:[n.label,n.description&&r.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.72rem",fontWeight:400,whiteSpace:"normal",marginTop:"0.1rem"},children:n.description})]})}function pw({row:n}){return n.sublist?r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.6rem",margin:0},children:n.sublist.map(s=>r.jsxs(f.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:s.label}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},title:s.valueTitle,children:s.value})]},s.key))}):n.diffLines?r.jsx("div",{style:{fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.8rem"},children:n.diffLines.map((s,i)=>r.jsx("div",{style:s.kind==="remove"?{color:"var(--danger)",textDecoration:"line-through"}:s.kind==="add"?{color:"var(--success)"}:void 0,children:s.text||" "},i))}):n.lines?r.jsx("div",{children:n.lines.map((s,i)=>{var o;return r.jsx("div",{title:(o=n.lineTitles)==null?void 0:o[i],children:s},i)})}):r.jsx("span",{title:n.valueTitle,children:n.value})}function Lf({rows:n}){return r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:n.map(s=>r.jsxs(f.Fragment,{children:[r.jsx(hw,{row:s}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:r.jsx(pw,{row:s})})]},s.key))})}function gi({rendered:n}){return n.kind==="empty"?r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",margin:"0.4rem 0"},children:"No fields returned."}):n.kind==="text"?r.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.85rem",margin:"0.4rem 0"},children:n.text}):r.jsxs(r.Fragment,{children:[r.jsx(Lf,{rows:n.fields}),n.moreFields.length>0&&r.jsxs("details",{style:{fontSize:"0.8rem"},children:[r.jsxs("summary",{style:{cursor:"pointer",color:"var(--text-tertiary)"},children:["All fields (",n.totalFields,")"]}),r.jsx(Lf,{rows:n.moreFields})]})]})}function nh({receipt:n,profile:s}){var w;const[i,o]=f.useState(void 0),[c,d]=f.useState(null),h=!!(n.contentHash&&n.contentBinding);if(f.useEffect(()=>{let N=!0;return o(void 0),d(null),(async()=>{let E;try{E=await B.getArchivedReceipt(n.id)}catch{N&&o(null);return}let k=null;const C=E==null?void 0:E.entry.boundContent;if(C!==void 0&&h)try{k=await th(n.contentBinding.kind,C)===n.contentHash}catch{k=!1}N&&(d(k),o(E))})(),()=>{N=!1}},[n.id,n.contentHash,n.contentBinding,h]),i===void 0)return r.jsx("div",{className:"ticket-done-box ticket-done-loading","data-testid":"ticket-what-was-done","data-bound":"loading","aria-busy":"true",children:"Loading…"});const g=i===null,p=i==null?void 0:i.entry.boundContent,y=dw({offDevice:g,boundContent:p,hasHashToCheck:h,hashVerified:c});if(y==="off-device")return r.jsx("div",{className:"ticket-done-box ticket-done-off-device","data-testid":"ticket-what-was-done","data-bound":"off-device",children:r.jsx("p",{className:"ticket-done-note",children:"Content not on this device — only the signed values are shown."})});if(y==="none"){const N=mw(n.executionContext,s);return r.jsxs("div",{className:"ticket-done-box","data-testid":"ticket-what-was-done","data-bound":"none",children:[r.jsx("h4",{children:"What was done"}),N.length>0?r.jsx("dl",{className:"ticket-done-fields",children:N.map(E=>r.jsxs("div",{className:"ticket-done-field-row",children:[r.jsx("dt",{children:E.label}),r.jsx("dd",{children:E.value})]},E.key))}):r.jsx("p",{className:"ticket-done-note",children:"No checked values recorded for this action."})]})}const v=fw(p,(w=n.contentBinding)==null?void 0:w.fields),j=y==="verified"?"ticket-done-verified":y==="mismatch"?"ticket-done-mismatch":"ticket-done-unchecked";return r.jsxs("div",{className:`ticket-done-box ${j}`,"data-testid":"ticket-what-was-done","data-bound":y,children:[r.jsxs("h4",{children:["What was done",y!=="unchecked"&&r.jsxs(r.Fragment,{children:[" ",r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]})]}),r.jsx(gi,{rendered:v}),y==="verified"&&r.jsx("p",{className:"ticket-done-note ticket-done-note-ok",children:"✓ This exact content is bound by hash — any change after the fact would break the ticket."}),y==="mismatch"&&r.jsx("p",{className:"ticket-done-note ticket-done-note-bad",children:"⚠ This content does NOT match the ticket's signed hash — it may have been altered since archiving."}),y==="unchecked"&&r.jsx("p",{className:"ticket-done-note ticket-done-note-neutral",children:"This content is kept on this device, but the ticket carries no content hash — it cannot be checked against the ticket."})]})}function Ms({label:n,children:s}){return r.jsxs(r.Fragment,{children:[r.jsx("dt",{className:"receipt-row-label",children:n}),r.jsx("dd",{className:"receipt-row-value",children:s})]})}function gw({receipt:n,manifests:s,localAuth:i,localUnavailable:o,signature:c,grantTitle:d,ownerLabel:h,spUrl:g,formatDate:p,onOpenComplete:y}){var I;const v=Qs(n.profileId),j=X0(n,v),w=Z0(i==null?void 0:i.context,v),N=ew(n,(i==null?void 0:i.bounds)??n.limits,v),E=i==null?void 0:i.intent,k=Sr(n.profileId).testSetup||Ti(n.action),[C,T]=f.useState(!1);return r.jsxs("div",{className:"card id-card",style:{marginBottom:0},children:[r.jsx(qs,{profileId:n.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{className:"receipt-head",children:[r.jsx("span",{className:"receipt-what",children:Q0(n,s)}),r.jsx("span",{className:"receipt-tag",children:nw(n)?"review":"automatic"}),n.contentHash&&r.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(I=n.contentBinding)!=null&&I.fields?`The ticket binds: ${n.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),k&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),r.jsx("span",{className:"auth-card-time",children:p(n.timestamp)})]}),j&&r.jsx("div",{className:"receipt-scope",children:j}),r.jsx(nh,{receipt:n,profile:v}),r.jsxs("dl",{className:"receipt-rows",children:[r.jsxs(Ms,{label:"mandate",children:[r.jsx("strong",{children:d||rw(n.profileId)})," ",r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),h&&r.jsx(Ms,{label:"owner",children:h}),w&&r.jsxs(Ms,{label:"allowed",children:[w," ",r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),N&&r.jsxs(Ms,{label:"used",children:[r.jsx("span",{className:"receipt-num",children:N})," ",r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),r.jsx(Ms,{label:"intent",children:E?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`intent-text${C?"":" intent-clamped"}`,children:E}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>T(!C),children:C?"Show less":"Show full intent"})," ",r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}):r.jsx("span",{className:"receipt-absent",children:o?"local store unreachable — sign in to the gateway to read it":"not on this device — the Authority Server stores only its hash"})})]}),r.jsxs("div",{className:"receipt-foot",children:[c==="valid"&&r.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued — no Authority Server involved.",children:"✓ Verified on this device"}),c==="valid-legacy"&&r.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued. This ticket was issued before protocol 0.7 and is checked with that version's format.",children:"✓ Verified on this device · issued before protocol 0.7"}),c==="invalid"&&r.jsx("span",{className:"receipt-tamper",title:"The stored ticket does not match what was signed.",children:"⚠ Signature check FAILED"}),r.jsx("button",{type:"button",className:"receipt-evidence-link",onClick:y,children:"Complete ticket"}),g&&r.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",r.jsx("a",{className:"receipt-link",href:`${g}/r/${n.id}`,target:"_blank",rel:"noreferrer",children:"public link ↗"})]})]}),r.jsxs("details",{className:"receipt-more",children:[r.jsx("summary",{children:"Raw"}),r.jsxs("div",{className:"receipt-kv",children:[r.jsxs("div",{children:["ticket · ",n.id]}),r.jsxs("div",{children:["action · ",n.action]}),r.jsxs("div",{children:["profile · ",n.profileId]}),n.authorizationId&&r.jsxs("div",{children:["mandate · ",n.authorizationId]}),Object.keys(n.executionContext??{}).length>0&&r.jsxs("div",{children:["scope ·"," ",Object.entries(n.executionContext).map(([$,P])=>`${$}=${P}`).join(" · ")]}),(i==null?void 0:i.boundsHash)&&r.jsxs("div",{children:["bounds hash · ",i.boundsHash]}),(i==null?void 0:i.contextHash)&&r.jsxs("div",{children:["scope hash · ",i.contextHash]}),n.contentHash&&r.jsxs("div",{children:["content · ",n.contentHash]}),n.proposalId&&r.jsxs("div",{children:["proposal · ",n.proposalId]}),r.jsxs("div",{children:["signature · ",n.signature]})]})]})]})]})}function yw({receipt:n,onClose:s}){const[i,o]=f.useState(null),[c,d]=f.useState(null),[h,g]=f.useState(null),[p,y]=f.useState(!0),[v,j]=f.useState(!1);f.useEffect(()=>{let C=!1;return y(!0),B.getArchivedReceipt(n.id).then(T=>{C||(o(T),d(T?"local":"authority-server"),g((T==null?void 0:T.signature)??null))}).catch(()=>{C||d("authority-server")}).finally(()=>{C||y(!1)}),()=>{C=!0}},[n.id]);const w=i?i.entry:{receipt:n},N=JSON.stringify(w,null,2);function E(){const C=URL.createObjectURL(new Blob([N],{type:"application/json"})),T=document.createElement("a");T.href=C,T.download=`suveren-ticket-${n.id.slice(0,8)}.json`,T.click(),URL.revokeObjectURL(C)}async function k(){try{await navigator.clipboard.writeText(N),j(!0),setTimeout(()=>j(!1),2e3)}catch{j(!1)}}return r.jsx("div",{className:"modal-backdrop",onClick:C=>C.target===C.currentTarget&&s(),children:r.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h3",{className:"modal-title",children:"Complete ticket"}),r.jsx("button",{className:"modal-close",onClick:s,"aria-label":"Close",children:"×"})]}),r.jsxs("div",{className:"modal-body",children:[h==="valid"&&r.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued."}),h==="valid-legacy"&&r.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued. Issued before protocol 0.7 — checked with that version's format."}),h==="invalid"&&r.jsx("p",{className:"receipt-tamper",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"⚠ Signature check FAILED — the stored ticket does not match what was signed."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children:p?"Loading…":c==="local"?"Held on this device — the signed ticket, the mandate it ran under, and the issuer key. Anyone with this file and that key can verify it offline, without Suveren.":"No local copy of this ticket (it predates local archiving, or ran on another device). Shown from the Authority Server — complete and signed, but it needs the server to retrieve."}),r.jsx("pre",{style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.68rem",lineHeight:1.65,margin:0,background:"var(--accent-subtle)",border:"1px solid var(--border)",borderRadius:"6px",padding:"0.75rem 0.85rem",overflowX:"auto",maxHeight:"22rem",overflowY:"auto"},children:N})]}),r.jsxs("div",{className:"modal-footer",children:[r.jsx("button",{className:"btn btn-primary btn-sm",onClick:E,children:"Download"}),r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:k,children:v?"Copied":"Copy"})]})]})})}function vw(n){return new Date(n*1e3).toLocaleString()}function xw(n,s){if(s==="all")return!0;const i=s==="1d"?1:s==="7d"?7:30,o=Math.floor(Date.now()/1e3)-i*86400;return n.timestamp>=o}function ww(n,s){if(!s)return!0;const i=s.toLowerCase();return n.profileId.toLowerCase().includes(i)||dt(n.profileId).toLowerCase().includes(i)||n.path.toLowerCase().includes(i)||n.action.toLowerCase().includes(i)||n.attestationHash.toLowerCase().includes(i)||n.id.toLowerCase().includes(i)||JSON.stringify(n.executionContext).toLowerCase().includes(i)}function $f(n,s){const i=new Map(n.map(o=>[o.id,o]));for(const o of s)i.set(o.id,o);return[...i.values()].sort((o,c)=>c.timestamp-o.timestamp)}function jw(){const{activeTeam:n,groupId:s}=vt(),i=(n==null?void 0:n.isAdmin)===!0,[o,c]=f.useState("mine"),[d,h]=f.useState([]),[g,p]=f.useState([]),[y,v]=f.useState(""),[j,w]=f.useState(!0),[N,E]=f.useState({}),[k,C]=f.useState(new Set),[T,I]=f.useState(""),[$,P]=f.useState(new Set),[D,K]=f.useState(new Set),[V,ce]=f.useState("all"),[Y,re]=f.useState(!1),[J,O]=f.useState(!1),[fe,ie]=f.useState(null),[Z,pe]=f.useState({}),[ee,W]=f.useState(!1),[M,H]=f.useState({}),[S,A]=f.useState({}),[G,te]=f.useState(null),[ue,ve]=f.useState(null),[Ce,ke]=f.useState(!1),[se,$e]=f.useState(!1),Ee=f.useRef(""),_e=f.useCallback(L=>o==="team"&&i&&s?B.listTeamReceiptsPage(s,{before:L,limit:200}):B.getMyReceiptsPage({before:L,limit:200}),[o,i,s]),me=f.useCallback(()=>{const L=o==="team"?`team:${s}`:"mine",oe=Ee.current!==L;Ee.current=L,w(!0),$e(!1),_e().then(he=>{h(Re=>oe?he.receipts:$f(Re,he.receipts)),ve(Re=>oe?he.nextBefore:Re??he.nextBefore)}).catch(()=>{oe&&h([]),$e(!0)}).finally(()=>w(!1))},[_e,o,s]),X=f.useCallback(()=>{!ue||Ce||(ke(!0),$e(!1),_e(ue).then(L=>{h(oe=>$f(oe,L.receipts)),ve(L.nextBefore)}).catch(()=>$e(!0)).finally(()=>ke(!1)))},[ue,Ce,_e]);Zt(me,12e4),f.useEffect(()=>{B.getIntegrationManifests().then(({manifests:L})=>p(L)).catch(()=>{}),fetch("/health").then(L=>L.json()).then(L=>{typeof L.spUrl=="string"&&v(L.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),f.useEffect(()=>{B.getLocalAuthorizations().then(({authorizations:L,signatures:oe})=>{pe(L),H(oe),W(!1)}).catch(()=>{pe({}),H({}),W(!0)}),B.getMyAttestations().then(L=>{const oe={};for(const he of L)he.authorization_id&&he.title&&(oe[he.authorization_id]=he.title);A(oe)}).catch(()=>{})},[]),f.useEffect(()=>{o!=="team"||Object.keys(N).length>0||B.listUsers().then(L=>{const oe={};for(const he of L)oe[he.id]={name:he.name,email:he.email};E(oe)}).catch(()=>{})},[o,N]);const we=f.useMemo(()=>{const L=new Set;for(const oe of d)L.add(dt(oe.profileId));return[...L].sort()},[d]),Te=f.useMemo(()=>{const L=new Set;for(const oe of d)L.add(oe.action);return[...L].sort()},[d]),Le=f.useMemo(()=>{if(o!=="team")return[];const L=new Set;for(const oe of d)oe.userId&&L.add(oe.userId);return[...L].map(oe=>{var he;return{id:oe,label:(he=N[oe])!=null&&he.name?`${N[oe].name} (${N[oe].email})`:oe}}).sort((oe,he)=>oe.label.localeCompare(he.label))},[o,d,N]),lt=f.useMemo(()=>d.filter(L=>!(!ww(L,T)||$.size>0&&!$.has(dt(L.profileId))||D.size>0&&!D.has(L.action)||k.size>0&&L.userId&&!k.has(L.userId)||!xw(L,V))),[d,T,$,D,k,V]),xt=$.size>0||D.size>0||k.size>0||V!=="all";function Ke(L){P(oe=>{const he=new Set(oe);return he.has(L)?he.delete(L):he.add(L),he})}function et(L){K(oe=>{const he=new Set(oe);return he.has(L)?he.delete(L):he.add(L),he})}function st(L){C(oe=>{const he=new Set(oe);return he.has(L)?he.delete(L):he.add(L),he})}function ht(){P(new Set),K(new Set),C(new Set),ce("all"),I("")}async function Fe(){O(!0),ie(null);try{const{bundle:L,filename:oe}=await B.fetchEvidenceBundle(),he=URL.createObjectURL(new Blob([JSON.stringify(L,null,2)],{type:"application/json"})),Re=document.createElement("a");Re.href=he,Re.download=oe,Re.click(),URL.revokeObjectURL(he);const de=L.sources??{};de.authorityServer?de.local||ie(`Downloaded Authority Server history only — ${de.localError??"local archive unavailable."}`):ie(`Downloaded local evidence only — ${de.asError??"Authority Server export unavailable."}`)}catch(L){ie(`Export failed: ${L instanceof Error?L.message:String(L)}`)}finally{O(!1)}}return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:"Tickets"}),r.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),r.jsx("button",{className:"btn btn-secondary",onClick:Fe,disabled:J,children:J?"Preparing…":"Download evidence"})]}),fe&&r.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:fe}),i&&r.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(L=>r.jsx("button",{onClick:()=>c(L),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:o===L?"2px solid var(--accent)":"2px solid transparent",color:o===L?"var(--text-primary)":"var(--text-tertiary)",fontWeight:o===L?600:500},children:L==="mine"?"Mine":"Team"},L))}),r.jsxs("div",{className:"search-filter-bar",children:[r.jsxs("div",{className:"search-input-wrap",children:[r.jsx("span",{className:"search-icon",children:"⌕"}),r.jsx("input",{type:"text",className:"form-input search-input",placeholder:"Search by profile, action, path, or hash\\u2026",value:T,onChange:L=>I(L.target.value)}),T&&r.jsx("button",{className:"search-clear",onClick:()=>I(""),children:"×"})]}),r.jsxs("button",{className:`btn btn-sm btn-secondary${Y?" active":""}`,onClick:()=>re(!Y),children:["Filters",xt?` (${$.size+D.size+(V!=="all"?1:0)})`:""]})]}),Y&&r.jsxs("div",{className:"filter-panel",children:[we.length>1&&r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Profile"}),r.jsx("div",{className:"filter-chips",children:we.map(L=>r.jsx("button",{className:`filter-chip${$.has(L)?" selected":""}`,onClick:()=>Ke(L),children:L},L))})]}),Te.length>1&&r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Action"}),r.jsx("div",{className:"filter-chips",children:Te.map(L=>r.jsx("button",{className:`filter-chip${D.has(L)?" selected":""}`,onClick:()=>et(L),children:L},L))})]}),o==="team"&&Le.length>1&&r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Owner"}),r.jsx("div",{className:"filter-chips",children:Le.map(L=>r.jsx("button",{className:`filter-chip${k.has(L.id)?" selected":""}`,onClick:()=>st(L.id),children:L.label},L.id))})]}),r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Time range"}),r.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([L,oe])=>r.jsx("button",{className:`filter-chip${V===L?" selected":""}`,onClick:()=>ce(L),children:oe},L))})]})]}),xt&&r.jsxs("div",{className:"active-filters",children:[[...$].map(L=>r.jsxs("span",{className:"active-chip",onClick:()=>Ke(L),children:[L," ",r.jsx("span",{className:"chip-remove",children:"×"})]},L)),[...D].map(L=>r.jsxs("span",{className:"active-chip",onClick:()=>et(L),children:[L," ",r.jsx("span",{className:"chip-remove",children:"×"})]},L)),[...k].map(L=>{const oe=N[L],he=oe?oe.name:L;return r.jsxs("span",{className:"active-chip",onClick:()=>st(L),children:[he," ",r.jsx("span",{className:"chip-remove",children:"×"})]},L)}),V!=="all"&&r.jsxs("span",{className:"active-chip",onClick:()=>ce("all"),children:[V==="1d"?"Today":V==="7d"?"7 days":"30 days"," ",r.jsx("span",{className:"chip-remove",children:"×"})]}),r.jsx("button",{className:"clear-filters",onClick:ht,children:"Clear all"})]}),se&&r.jsx("div",{className:"card",style:{borderColor:"var(--danger, #c0392b)",marginBottom:"0.75rem"},children:r.jsx("span",{style:{color:"var(--danger, #c0392b)",fontSize:"0.85rem"},children:"Couldn’t load tickets — your session may have expired. Try signing out and back in."})}),j&&d.length===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):lt.length===0?r.jsx(qr,{icon:"⌕",title:d.length===0?"No tickets in the last 30 days":"No matching tickets",text:d.length===0?"Tickets appear here after an agent uses an authorized tool. Older tickets can be loaded below.":"Try adjusting your search or filters."}):r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:lt.length===d.length?`${d.length} ticket${d.length!==1?"s":""}`:`${lt.length} of ${d.length} tickets`}),r.jsx("div",{className:"timeline",children:lt.map(L=>{const oe=L.userId?N[L.userId]:void 0;return r.jsx("div",{className:"timeline-event",children:r.jsx(gw,{receipt:L,manifests:g,localAuth:L.authorizationId?Z[L.authorizationId]:void 0,localUnavailable:ee,signature:M[L.id],grantTitle:L.authorizationId?S[L.authorizationId]:null,ownerLabel:o==="team"&&L.userId?oe?`${oe.name} (${oe.email})`:L.userId:null,spUrl:y,formatDate:vw,onOpenComplete:()=>te(L)})},L.id)})})]}),G&&r.jsx(yw,{receipt:G,onClose:()=>te(null)}),ue&&r.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:X,disabled:Ce,children:Ce?"Loading…":"Load older"})})]})}function Sw(){const[n,s]=f.useState(null),[i,o]=f.useState({}),[c,d]=f.useState(!1),h=f.useCallback(()=>{B.getDenials({limit:200}).then(({records:p})=>{s(p),d(!1)}).catch(()=>d(!0))},[]);if(f.useEffect(()=>{h()},[h]),Zt(h,6e4),f.useEffect(()=>{if(!n)return;const p=[...new Set(n.map(y=>y.profile).filter(y=>!!y))].filter(y=>!(y in i));p.length!==0&&Promise.all(p.map(y=>B.getProfile(y).catch(()=>null))).then(y=>{o(v=>{const j={...v};return p.forEach((w,N)=>{y[N]&&(j[w]=y[N])}),j})})},[n,i]),c)return r.jsx(qr,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(n===null)return null;const g=Cm(n,Date.now());return r.jsxs("div",{className:"blocked-page",children:[r.jsxs("div",{className:"page-header blocked-header",children:[r.jsx("h1",{className:"page-title",children:"Blocked actions"}),r.jsxs("span",{className:"blocked-today",children:[g," today · nothing ran"]})]}),n.length===0?r.jsx(qr,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):r.jsx("div",{className:"blocked-list",children:n.map((p,y)=>{const v=Iv(p,p.profile?i[p.profile]:void 0);return r.jsxs("div",{className:"blocked-row","data-kind":Gs(p),children:[r.jsx("span",{className:`blocked-dot blocked-dot-${Gs(p)}`,"aria-hidden":"true"}),r.jsxs("div",{className:"blocked-row-main",children:[r.jsx("div",{className:"blocked-title",children:v.title}),r.jsx("div",{className:"blocked-sentence",children:v.sentence}),r.jsx("div",{className:"blocked-source",children:v.sourceLine}),r.jsxs("details",{children:[r.jsx("summary",{children:"What you can do"}),r.jsx("div",{className:"blocked-advice",children:v.whatYouCanDo})]})]}),r.jsx("div",{className:"blocked-when",children:new Date(p.ts).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]},`${p.ts}-${y}`)})})]})}const kw={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function bw(){const[n,s]=f.useState(null),[i,o]=f.useState(!1),[c,d]=f.useState(null),h=f.useCallback(async()=>{try{s(await B.getAutostart())}catch(y){d(y instanceof Error?y.message:"Could not read autostart state")}},[]);f.useEffect(()=>{h()},[h]);const g=f.useCallback(async()=>{if(!(!(n!=null&&n.supported)||i)){o(!0),d(null);try{await B.setAutostart(!n.installed)}catch(y){d(y instanceof Error?y.message:"Failed")}finally{try{s(await B.getAutostart()),d(null)}catch(y){d(y instanceof Error?y.message:"Could not re-read state")}o(!1)}}},[n,i,h]);if(!n)return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),r.jsx("p",{role:c?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:c?`Could not read autostart state: ${c}`:"Checking…"})]});const p=kw[n.platform]??"a login service";return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),r.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:n.supported?r.jsxs(r.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",p," — no admin rights needed."]}):n.reason})]}),n.supported&&r.jsx("button",{type:"button",onClick:()=>void g(),disabled:i,"aria-pressed":n.installed,className:n.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:i?"Working…":n.installed?"Turn off":"Turn on"})]}),n.supported&&r.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",r.jsx("strong",{children:n.installed?"On — starts from your next login":"Off"})]}),n.supported&&r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Turning this on doesn't interrupt the gateway you're using — it takes effect at your next login. After any restart Suveren comes back ",r.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]}),c&&r.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger, #c00)"},children:c})]})}function Nw(){const[n,s]=f.useState(null),[i,o]=f.useState(!1),[c,d]=f.useState(null),h=f.useCallback(async()=>{try{const p=await B.getGatewaySettings();s(p.desktopNotifications),d(null)}catch(p){d(p instanceof Error?p.message:"Could not read notification setting")}},[]);f.useEffect(()=>{h()},[h]);const g=f.useCallback(async()=>{if(!(n===null||i)){o(!0),d(null);try{const p=await B.setGatewaySettings({desktopNotifications:!n});s(p.desktopNotifications)}catch(p){d(p instanceof Error?p.message:"Failed to save"),await h()}finally{o(!1)}}},[n,i,h]);return n===null?r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),r.jsx("p",{role:c?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:c?`Could not read the setting: ${c}`:"Checking…"})]}):r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),r.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:"Tells you something is waiting for review — never what it is, and never with an approve button. Open Suveren to see and decide. At most one notification a minute; the browser tab always shows the count."})]}),r.jsx("button",{type:"button",onClick:()=>void g(),disabled:i,"aria-pressed":n,className:n?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:i?"Saving…":n?"Turn off":"Turn on"})]}),c&&r.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:c})]})}const zf={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function Cw(){const[n,s]=f.useState(null),[i,o]=f.useState(!1),[c,d]=f.useState(null),h=f.useCallback(async()=>{try{s(await B.getIdentityDisclosure()),d(null)}catch(v){d(v instanceof Error?v.message:"Could not read the setting")}},[]);f.useEffect(()=>{h()},[h]);const g=f.useCallback(async()=>{if(!(!n||i)){o(!0),d(null);try{s(await B.setIdentityDisclosure(!n.always))}catch(v){d(v instanceof Error?v.message:"Failed to save"),await h()}finally{o(!1)}}},[n,i,h]),p=r.jsx("h3",{className:"card-title",style:{margin:0},children:"Your name on mandates and tickets"});if(!n)return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[p,r.jsx("p",{role:c?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:c?`Could not read the setting: ${c}`:"Checking…"})]});const y=n.verified&&n.name?`${n.name} — ${n.method==="as_vouched"?`${zf.as_vouched} ${n.verifier}`:zf[n.method??""]??n.method}`:null;return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[p,r.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:[n.always?"On: your verified name is attached to every mandate you give — including ones the setup AI proposes and you approve — and to the tickets under them.":"Off: each mandate asks whether to show your name. Mandates the setup AI proposes carry no name."," ","Mandates already given stay as they are."]}),r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:y?`Your identity: ${y}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),r.jsx("button",{type:"button",onClick:()=>void g(),disabled:i,"aria-pressed":n.always,className:n.always?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:i?"Saving…":n.always?"Turn off":"Always show my name"})]}),c&&r.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:c})]})}const Ew={npm:"Checking npm for new releases",docker:"Checking the container registry for new images",dev:"Git checkout — comparing against origin/main, not npm releases",managed:"Checking npm for new releases — managed by your IT",msi:"Checking for new releases — update with the Windows installer"};function Tw(){const{version:n,latestVersion:s,updateAvailable:i,installMethod:o}=Zl();return n?r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Version"}),r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:["Running ",r.jsx("strong",{children:n}),i&&s?r.jsxs(r.Fragment,{children:[" — ",r.jsx("strong",{children:s})," is available"]}):null]}),r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:[Ew[o]??"Update checking is unavailable",o==="dev"&&r.jsx(r.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function Ol({title:n}){return r.jsxs("span",{className:"it-locked-badge",title:n,children:[r.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function Ff(n){return n===!0}function Rw(){const[n,s]=f.useState(null),[i,o]=f.useState(null);f.useEffect(()=>{let h=!1;return B.getAsPairing().then(g=>{h||s(g)}).catch(g=>{h||o(g instanceof Error?g.message:"Could not read Authority Server info")}),()=>{h=!0}},[]);const c=Ff(n==null?void 0:n.asUrlLockedByPolicy),d=Ff(n==null?void 0:n.pinTlsLockedByPolicy);return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Authority Server"}),c&&r.jsx(Ol,{})]}),!n&&!i&&r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Checking…"}),i&&r.jsx("p",{role:"alert",style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--danger, #c00)"},children:i}),n&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{children:"URL:"})," ",r.jsx("code",{children:n.asUrl})]}),n.paired&&n.fingerprint?r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{children:"Key fingerprint:"})," ",r.jsx("code",{children:n.fingerprint}),r.jsx("br",{}),r.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Compare this with the fingerprint on the Authority Server's own admin page over a second channel (phone, video call) to confirm this gateway is talking to the right server."})]}):r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:"Not yet paired — sign in once to pin this server's key."}),(n.tlsPinFingerprint||n.pinTlsEnabled)&&r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{children:"TLS certificate pin:"})," ",d&&r.jsx(Ol,{title:"TLS pinning is set by your IT policy"})," ",n.tlsPinFingerprint?r.jsx("code",{children:n.tlsPinFingerprint}):r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["not yet captured — this URL has no recorded pairing over TLS",n.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]}),r.jsx("br",{}),r.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[n.pinTlsEnabled?r.jsxs(r.Fragment,{children:["TLS pinning is ON",d?r.jsx(r.Fragment,{children:", set by your organization's IT policy"}):r.jsxs(r.Fragment,{children:[" (",r.jsx("code",{children:"config set pin-tls on"}),")"]}),". Every connection to the Authority Server must present this certificate's public key, or the gateway refuses it and locks."]}):r.jsxs(r.Fragment,{children:["Captured at sign-in; not currently enforced",d?r.jsx(r.Fragment,{children:" — controlled by your organization's IT policy on this computer"}):r.jsxs(r.Fragment,{children:[" (",r.jsx("code",{children:"config set pin-tls on"})," to require it on every connection)"]}),"."]})," ","A certificate renewal with the SAME key keeps this pin; a NEW key needs re-pairing."]})]}),c?r.jsx("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This Authority Server URL is set by your organization's IT policy and cannot be changed from this computer. Contact your IT administrator if it needs to change."}):r.jsxs("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:["To point this gateway at a different Authority Server:"," ",r.jsx("code",{children:"suveren-gateway config set as-url <url>"}),", then restart. Changing it ends the current sign-in and clears cached mandates — you sign in again against the new server."]})]})]})}function Iw(){const{simulation:n,locked:s}=zm();return s?r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Simulation mode"}),r.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:['Blocks every real connector without a manifest "simulation" marker.',n!==null&&r.jsxs(r.Fragment,{children:[" ","Currently ",r.jsx("strong",{children:n?"ON":"OFF"}),n?" — real systems are not reachable from this gateway.":"."]})]})]}),r.jsx(Ol,{})]}),r.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.78rem",color:"var(--text-tertiary)"},children:["Simulation mode is set by your organization's IT policy",n!==null?` (currently ${n?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const Aw={ollama:{provider:"ollama",endpoint:"http://localhost:11434",models:["gemma4:e4b","gemma4:e2b","gemma4:26b","gemma4:31b","llama3.2","llama3.1","mistral","qwen2.5"]},openrouter:{provider:"openai-compatible",endpoint:"https://openrouter.ai/api/v1",models:["google/gemma-4-31b-it","qwen/qwen3.6-plus:free","stepfun/step-3.5-flash:free","google/gemini-2.5-flash","openai/gpt-4o-mini","anthropic/claude-haiku-4"]},openai:{provider:"openai-compatible",endpoint:"https://api.openai.com/v1",models:["gpt-4o-mini","gpt-4o","o3-mini"]},groq:{provider:"openai-compatible",endpoint:"https://api.groq.com/openai/v1",models:["llama-3.1-8b-instant","llama-3.3-70b-versatile","gemma2-9b-it"]},together:{provider:"openai-compatible",endpoint:"https://api.together.xyz/v1",models:["meta-llama/Llama-3-8b-chat-hf","meta-llama/Llama-3-70b-chat-hf"]}},Bs=["AI Assistant","Authority Server","This computer","Security","Version"],Ds={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function Pw(){const[n,s]=f.useState(""),[i,o]=f.useState("openrouter"),[c,d]=f.useState("openai-compatible"),[h,g]=f.useState("https://openrouter.ai/api/v1"),[p,y]=f.useState("google/gemma-4-31b-it"),[v,j]=f.useState(""),[w,N]=f.useState(!1),[E,k]=f.useState(!1),[C,T]=f.useState(!1),[I,$]=f.useState(null),[P,D]=f.useState([]),[K,V]=f.useState(!1),[ce,Y]=f.useState(null),[re,J]=f.useState(""),O=f.useCallback(M=>{s(M),setTimeout(()=>s(""),3e3)},[]),fe=f.useCallback(async(M,H,S)=>{V(!0),Y(null);try{const A=await B.aiModels({provider:M,endpoint:H,...S?{apiKey:S}:{}});A.ok&&A.models.length>0?(D(A.models),Y(`${A.models.length} models available`)):(D([]),Y(A.message||"No models returned — using defaults"))}catch(A){D([]),Y(A instanceof Error?A.message:"Failed to load models")}finally{V(!1)}},[]),ie=f.useCallback(async()=>{try{const M=await B.getCredential("ai-config");if(N(M.configured),M.configured&&M.fields){const H=M.fields.provider||"openai-compatible",S=M.fields.endpoint||"";M.fields.provider&&d(H),M.fields.endpoint&&g(S),M.fields.model&&y(M.fields.model),S.includes("openai.com")?o("openai"):S.includes("groq.com")?o("groq"):S.includes("together.xyz")?o("together"):S.includes("openrouter.ai")?o("openrouter"):o("ollama"),S&&fe(H,S)}}catch{}},[fe]);f.useEffect(()=>{ie()},[ie]);const Z=M=>{o(M),D([]),Y(null),J("");const H=Aw[M];H&&(d(H.provider),g(H.endpoint),y(""),fe(H.provider,H.endpoint,v||void 0))},pe=()=>fe(c,h,v||void 0),ee=async()=>{k(!0);try{await B.setCredential("ai-config",{provider:c,endpoint:h,model:p,...v?{apiKey:v}:{}}),N(!0),O("AI configuration saved!")}catch{O("Failed to save AI config")}finally{k(!1)}},W=async()=>{T(!0),$(null);try{const M=await B.aiTest({provider:c,endpoint:h,model:p,...v?{apiKey:v}:{}});$(M.ok?`OK: ${M.message}`:`Failed: ${M.message}`)}catch(M){$(`Error: ${M instanceof Error?M.message:"Unknown"}`)}finally{T(!1)}};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Settings"}),r.jsx("p",{className:"page-subtitle",children:"Your AI assistant, the connection to your Authority Server, security and version."})]}),n&&r.jsx("div",{className:"alert alert-success",children:n}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Ds,children:Bs[0]}),r.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Advisory AI to help you think through intent when giving mandates."}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"card-title",children:"Configuration"}),r.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Connect a trusted AI model that has access to your intent — problem, objective, and tradeoffs — to help you think through mandates. Keys are encrypted in your vault."}),w&&r.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[r.jsx("span",{className:"status-banner-icon",children:"✓"}),r.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsx("label",{className:"form-label",children:"Provider Preset"}),r.jsxs("select",{className:"form-input",value:i,onChange:M=>Z(M.target.value),children:[r.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),r.jsx("option",{value:"ollama",children:"Ollama (local)"}),r.jsx("option",{value:"openai",children:"OpenAI"}),r.jsx("option",{value:"groq",children:"Groq"}),r.jsx("option",{value:"together",children:"Together"})]})]}),r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsxs("label",{className:"form-label",children:["API Key ",c==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),r.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:v,onChange:M=>j(M.target.value),onBlur:()=>{v.trim()&&fe(c,h,v.trim())},placeholder:w?"••••••••••••••••":"sk-... (not needed for Ollama)"}),r.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:"Each provider uses its own key — paste it and the model list loads automatically."})]}),r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[r.jsx("label",{className:"form-label",children:"Model"}),r.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.75rem",padding:"0.125rem 0.5rem"},onClick:pe,disabled:K,title:"Re-fetch the model list from the provider",children:K?"Loading…":"↻ Refresh"})]}),P.length===0?r.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:K?"Loading models…":c==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const M=P,H=M.includes(p),S=M.length>12,A=re.trim().toLowerCase();let G=A?M.filter(te=>te.toLowerCase().includes(A)):M;return H&&!G.includes(p)&&(G=[p,...G]),r.jsxs(r.Fragment,{children:[S&&r.jsx("input",{className:"form-input",value:re,onChange:te=>J(te.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),r.jsxs("select",{className:"form-input",value:H?p:"__unset__",onChange:te=>y(te.target.value==="__unset__"?"":te.target.value),children:[r.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),G.map(te=>r.jsx("option",{value:te,children:te},te)),A&&G.length===0&&r.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",re,"”"]})]})]})})(),ce&&r.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:ce})]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[r.jsx("button",{className:"btn btn-primary",onClick:ee,disabled:E||!p.trim(),title:p.trim()?void 0:"Select a model first",children:E?"Saving...":"Save & Encrypt"}),w&&r.jsx("button",{className:"btn btn-ghost",onClick:W,disabled:C,children:C?"Testing...":"Test Connection"})]}),I&&r.jsx("div",{className:`alert ${I.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:I})]}),r.jsx(_w,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Ds,children:Bs[1]}),r.jsx(Rw,{}),r.jsx(Cw,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Ds,children:Bs[2]}),r.jsx(bw,{}),r.jsx(Nw,{}),r.jsx(Iw,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Ds,children:Bs[3]}),r.jsx("div",{className:"card",style:{padding:"1.5rem"},children:r.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[r.jsxs("div",{style:{marginBottom:"1rem"},children:[r.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),r.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[r.jsx("li",{children:"Every tool call verified against your mandate bounds"}),r.jsx("li",{children:"Credentials never exposed to agents through MCP"}),r.jsx("li",{children:"Every action produces a signed ticket"})]})]}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),r.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[r.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),r.jsx("li",{children:"For best security, run agents in sandboxed environments"}),r.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})})]}),r.jsxs("section",{children:[r.jsx("h2",{style:Ds,children:Bs[4]}),r.jsx(Tw,{})]})]})}function _w(){const[n,s]=f.useState(null),[i,o]=f.useState({intent:"",context:""}),[c,d]=f.useState(null),[h,g]=f.useState(null),[p,y]=f.useState(null),[v,j]=f.useState(!1),w=f.useCallback(async()=>{if(!v)try{const k=await B.getAIPrompts();s(k),o({intent:k.intent.current,context:k.context.current}),j(!0)}catch(k){g(k instanceof Error?k.message:"Failed to load prompts")}},[v]),N=async k=>{if(n){d(k),g(null);try{const C=i[k],T=C.trim()===n[k].default.trim()?"":C;await B.setAIPrompt(k,T);const I=await B.getAIPrompts();s(I),o({intent:I.intent.current,context:I.context.current}),y(k),setTimeout(()=>y(null),2e3)}catch(C){g(C instanceof Error?C.message:"Save failed")}finally{d(null)}}},E=async k=>{if(confirm(`Revert ${k} prompt to the built-in default?`)){d(k),g(null);try{await B.setAIPrompt(k,"");const C=await B.getAIPrompts();s(C),o({intent:C.intent.current,context:C.context.current})}catch(C){g(C instanceof Error?C.message:"Revert failed")}finally{d(null)}}};return r.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:k=>{k.currentTarget.open&&w()},children:[r.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),r.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",margin:"0.75rem 0 1rem 0",lineHeight:1.55},children:"These are the system prompts the AI assistant sees when helping you write Intent (per-mandate) or Context (your standing-orders brief). Edit with care — changes apply on the next chat turn."}),h&&r.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:h}),!v&&!h&&r.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),n&&r.jsxs(r.Fragment,{children:[r.jsx(Of,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:n.intent,draft:i.intent,onChange:k=>o(C=>({...C,intent:k})),onSave:()=>N("intent"),onRevert:()=>E("intent"),saving:c==="intent",justSaved:p==="intent"}),r.jsx(Of,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:n.context,draft:i.context,onChange:k=>o(C=>({...C,context:k})),onSave:()=>N("context"),onRevert:()=>E("context"),saving:c==="context",justSaved:p==="context"})]})]})}function Of({kind:n,label:s,description:i,state:o,draft:c,onChange:d,onSave:h,onRevert:g,saving:p,justSaved:y}){const v=c!==o.current;return r.jsxs("section",{style:{marginBottom:"1.5rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:s}),r.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:i})]}),o.overridden&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),r.jsx("textarea",{className:"form-textarea",value:c,onChange:j=>d(j.target.value),rows:12,spellCheck:!1,style:{width:"100%",fontFamily:"'SF Mono', Monaco, 'Cascadia Code', monospace",fontSize:"0.82rem",lineHeight:1.55,resize:"vertical",minHeight:"14rem",marginTop:"0.5rem"},"aria-label":`${s} system prompt`}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[r.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:h,disabled:p||!v,children:p?"Saving…":"Save"}),o.overridden&&r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:g,disabled:p,title:"Discard the override and use the built-in default",children:"Revert to default"}),y&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--success)"},children:"Saved"}),v&&!p&&!y&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),r.jsxs("details",{style:{marginTop:"0.5rem"},children:[r.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),r.jsx("pre",{style:{marginTop:"0.5rem",padding:"0.75rem 1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem",fontSize:"0.78rem",lineHeight:1.55,whiteSpace:"pre-wrap",maxHeight:"20rem",overflowY:"auto"},children:o.default})]}),r.jsx("span",{style:{display:"none"},children:n})]})}function Lw(n){return n.proposalId?"review":"automatic"}function Mf(n,s,i={}){const o=i.status??"pending",c=i.includeAutonomous??!1,d=[];for(const h of n)o==="pending"&&h.status!=="pending"||i.profile&&h.profileId!==i.profile||d.push({kind:"proposal",id:h.id,sortTimestamp:h.createdAt,commitmentMode:"review",profileId:h.profileId,proposal:h});if(o==="all")for(const h of s){const g=Lw(h);!c&&g==="automatic"||i.profile&&h.profileId!==i.profile||d.push({kind:"receipt",id:h.id,sortTimestamp:h.timestamp,commitmentMode:g,profileId:h.profileId,receipt:h})}return d.sort((h,g)=>g.sortTimestamp-h.sortTimestamp),typeof i.limit=="number"&&i.limit>0?d.slice(0,i.limit):d}const $w=["https://","http://"];function rh(n,s){return n!=null&&n.length?n.flatMap(i=>{const o=i.template.replace(/\{(\w+)\}/g,(c,d)=>{const h=s[d];return typeof h=="string"||typeof h=="number"?String(h):"\0"});return o.includes("\0")||/\{|\}/.test(o)?[]:$w.some(c=>o.toLowerCase().startsWith(c))?[{label:i.label,href:o,description:i.description}]:[]}):[]}function sh(n,s){const i=n-Math.floor(s/1e3);if(i<=0)return{label:"expired",urgent:!1,expired:!0};const o=Math.floor(i/86400),c=Math.floor(i%86400/3600),d=Math.floor(i%3600/60);let h;return o>0?h=`expires in ${o}d ${c}h`:c>0?h=`expires in ${c}h ${d}m`:h=`expires in ${Math.max(1,d)}m`,{label:h,urgent:i<2*3600,expired:!1}}const zw=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function Fw(n,s){return typeof s!="string"?!1:/^data:image\//i.test(s)?!0:zw.test(n)?/^https?:\/\//.test(s):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(s)}function Kr(n){if(n==null)return"—";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);try{return JSON.stringify(n,null,2)}catch{return String(n)}}function Bf({row:n,which:s}){const i=Qs(n.profileRef),o=J0(n.value,i,s);return o.length===0?r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"none"}):r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.75rem",margin:0},children:o.map(c=>r.jsxs(f.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-secondary)"},title:c.hint,children:c.label}),r.jsxs("dd",{style:{margin:0,fontWeight:600},children:[c.value,c.unknown&&r.jsx("span",{style:{color:"var(--danger)",fontWeight:400,marginLeft:"0.5rem"},children:"not defined by this profile"})]})]},c.key))})}function Ow({row:n}){const s=Qs(n.profileRef),i=(s==null?void 0:s.id)??n.profileRef??"";return r.jsxs(r.Fragment,{children:[(s==null?void 0:s.name)??dt(i),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:i})]})}function Mw({row:n,altText:s}){switch(n.kind){case"profile":return r.jsx(Ow,{row:n});case"profile-limits":return r.jsx(Bf,{row:n,which:"limits"});case"profile-scope":return r.jsx(Bf,{row:n,which:"scope"});case"markdown":return r.jsx("div",{style:{whiteSpace:"pre-wrap",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.625rem"},children:Kr(n.value)});case"list":return Array.isArray(n.value)?r.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:n.value.map((i,o)=>r.jsx("li",{children:Kr(i)},o))}):r.jsx(r.Fragment,{children:Kr(n.value)});case"money":return r.jsxs(r.Fragment,{children:[Kr(n.value),n.currency?` ${n.currency}`:""]});case"object":return r.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Kr(n.value)});default:return Fw(n.key,n.value)?r.jsx("img",{src:n.value,alt:s??n.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):r.jsx(r.Fragment,{children:Kr(n.value)})}}function ah({args:n,display:s,heading:i="Details"}){const o=Y0(n,s);if(o.length===0)return null;const c=typeof n.altText=="string"?n.altText:void 0;return r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[i&&r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:i}),r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:o.map(d=>r.jsxs(f.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:d.hint,children:d.label}),r.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:r.jsx(Mw,{row:d,altText:c})})]},d.key))})]})}const Df=500;function Ml(n){return n.length>Df?`${n.slice(0,Df)}…`:n}function Uf(n){return n.length?n[0].toUpperCase()+n.slice(1):n}function Wf(n,s){switch(n.status){case"none":return n.reason==="no_target"?{heading:"Nothing to read beforehand",note:`This action does not refer to an existing record — nothing to read beforehand. Showing exactly what will be sent to ${s}.`}:{heading:"No preview declared",note:`No preview declared for this tool — showing exactly what will be sent to ${s}.`};case"unavailable":return n.reason==="no_connector"?{heading:"Preview not available",note:"Preview not available on this gateway."}:{heading:"Preview not available",note:n.message?`Preview not available — ${Ml(n.message)}`:"Preview not available."};case"not_found":return{heading:"Not found in your system",note:n.message?`Not found in your system — ${Ml(n.message)}`:"Not found in your system."};case"ok":{const i=Fl(n.body,{fields:n.fields}),o={heading:`From ${s}, before it runs`,note:`Read by the gateway with ${n.tool} when you opened this card — the AI is not involved.`,rendered:i},c=n.version;if(c&&(o.versionNote=`You approve ${c.field} ${c.approved}; if it changes, ${s} refuses it.`,c.stale)){const d=uw(n.body,c.currentBody,{fields:n.fields,excludeKey:c.field});o.stale={heading:`A newer ${c.field} exists (${c.current})`,approvedLabel:`${Uf(c.field)} ${c.approved}`,currentLabel:`${Uf(c.field)} ${c.current}`,...d.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:d.approved,currentRendered:d.current}}}return o}}}function Bw(n,s){if(n.state!=="failed")return null;const i=n.detail?Ml(n.detail):void 0;return n.outcome==="changed"?{heading:"Changed since your approval",note:`The record changed in ${s} since you approved it — nothing was done. Ask the AI to request it again.`}:{heading:`Refused by ${s}`,note:`${s} refused it${i?`: ${i}`:""} — nothing was done. Ask the AI to request it again.`}}function Dw(n){return n!==null&&n!=="loading"&&n!=="ok"&&n!=="stale"}function Uw({proposalId:n,systemName:s}){const[i,o]=f.useState(null);if(f.useEffect(()=>{let d=!0;return o(null),B.getProposalOutcome(n).then(h=>{d&&o(h)}).catch(()=>{}),()=>{d=!1}},[n]),!i)return null;const c=Bw(i,s);return c?r.jsxs("div",{className:"outcome-box",children:[r.jsx("h4",{children:c.heading}),r.jsx("p",{className:"outcome-note",children:c.note})]}):null}function Ww({proposalId:n,systemName:s,onTone:i}){const[o,c]=f.useState(null),[d,h]=f.useState(!1);if(f.useEffect(()=>{let y=!0;return c(null),h(!1),B.getProposalPreview(n).then(v=>{y&&c(v)}).catch(()=>{y&&h(!0)}),()=>{y=!1}},[n]),f.useEffect(()=>{if(d){i==null||i("unavailable");return}if(!o)return;const y=Wf(o,s);i==null||i(o.status==="ok"?y.stale?"stale":"ok":o.status)},[o,d,s,i]),d)return r.jsxs("div",{className:"preview-box preview-box-unavailable","data-testid":"approval-preview","data-preview-status":"unavailable",children:[r.jsx("h4",{children:"Preview not available"}),r.jsx("p",{className:"preview-note",children:"Preview not available on this gateway."})]});if(!o)return r.jsxs("div",{className:"preview-box preview-box-loading","data-testid":"approval-preview","data-preview-status":"loading","aria-busy":"true",children:["Reading from ",s,"…"]});const g=Wf(o,s),p=o.status==="ok"?g.stale?"stale":"ok":o.status;return p==="none"?r.jsx("p",{className:"preview-note","data-testid":"approval-preview","data-preview-status":"none",children:g.note}):r.jsxs("div",{className:`preview-box preview-box-${p}`,"data-testid":"approval-preview","data-preview-status":p,children:[r.jsx("h4",{children:g.heading}),g.rendered&&r.jsx(gi,{rendered:g.rendered}),r.jsx("p",{className:"preview-note",children:g.note}),g.versionNote&&!g.stale&&r.jsx("p",{className:"preview-note",children:g.versionNote}),g.stale&&r.jsxs("div",{className:"preview-stale",children:[r.jsx("h5",{children:g.stale.heading}),g.stale.unchangedNote?r.jsx("p",{className:"preview-note",children:g.stale.unchangedNote}):r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.5rem 0 0"},children:[r.jsx("dt",{children:g.stale.approvedLabel}),r.jsx("dd",{children:r.jsx(gi,{rendered:g.stale.approvedRendered})}),r.jsx("dt",{children:g.stale.currentLabel}),r.jsx("dd",{children:r.jsx(gi,{rendered:g.stale.currentRendered})})]})]})]})}let kl=null;function Hw(){return kl||(kl=B.getEnrichedAuthorizations().then(n=>new Map(n.map(s=>[s.authorizationId,s.bounds]))).catch(()=>new Map)),kl}function Vw(n){const[s,i]=f.useState(void 0);return f.useEffect(()=>{let o=!0;if(n)return Hw().then(c=>{o&&i(c.get(n))}),()=>{o=!1}},[n]),s}function Gw(n,s){const[i,o]=f.useState(null),[c,d]=f.useState(!1),[h,g]=f.useState(null);return f.useEffect(()=>{let p=!0;return o(null),g(null),d(!0),(async()=>{var y;try{try{const w=await B.getGateContent(n);if((y=w==null?void 0:w.gateContent)!=null&&y.intent){p&&o(w.gateContent.intent);return}}catch{}const v=await B.getAttestationIntent(n);if(!v){p&&g("Intent not available or you are not an authorized approver.");return}const j=await B.decryptIntent({intentCiphertext:v.intentCiphertext,encryptedKey:v.encryptedKey,approverId:s});p&&o(j)}catch(v){p&&g(v instanceof Error?v.message:"Failed to decrypt intent")}finally{p&&d(!1)}})(),()=>{p=!1}},[n,s]),{intent:i,loading:c,error:h}}async function ih(n){if(n.toolArgs)return n.toolArgs;if(!n.content)return null;try{const{plaintext:s}=await B.decryptProposalContent(n.content),i=JSON.parse(s);return typeof i!="object"||i===null||Array.isArray(i)?null:i}catch{return null}}function Kw(n){if(!n.content)return[];const s=new Set([...n.createdBy?[n.createdBy]:[],...n.pendingApprovers??[]]),i=new Set(Object.keys(n.content.keys));return Array.from(s).filter(o=>!i.has(o))}function oh(n){return!n.loading&&n.readable}function lh(n,s){const i=new Set;if(n.content)for(const o of Object.keys(n.content.keys))i.add(o);else{n.createdBy&&i.add(n.createdBy);for(const o of n.pendingApprovers??[])i.add(o)}return s&&i.add(s),Array.from(i)}async function yi(n){const s=await ih(n);if(s)return th("jcs",s)}function Yw(n){var o;const[s,i]=f.useState((n==null?void 0:n.note)??null);return f.useEffect(()=>{let c=!0;if(n!=null&&n.note){i(n.note);return}if(!(n!=null&&n.noteEncrypted)){i(null);return}return i(null),B.decryptProposalContent(n.noteEncrypted).then(({plaintext:d})=>{c&&i(d)}).catch(()=>{c&&i(null)}),()=>{c=!1}},[n==null?void 0:n.note,(o=n==null?void 0:n.noteEncrypted)==null?void 0:o.ciphertext]),s}const Jw={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function ch(n){var o;const[s,i]=f.useState(Jw);return f.useEffect(()=>{let c=!0;if(n.toolArgs){i({toolArgs:n.toolArgs,loading:!1,sealed:!1,undecryptable:!1});return}if(!n.content){i({toolArgs:null,loading:!1,sealed:!1,undecryptable:!1});return}return i({toolArgs:null,loading:!0,sealed:!0,undecryptable:!1}),(async()=>{const d=await ih(n);c&&i({toolArgs:d,loading:!1,sealed:!0,undecryptable:d===null})})(),()=>{c=!1}},[(o=n.content)==null?void 0:o.ciphertext,n.toolArgs]),s}function Hf(n){if(!n||typeof n!="object"||Array.isArray(n))return{};const s={};for(const[i,o]of Object.entries(n))(typeof o=="string"||typeof o=="number")&&(s[i]=o);return s}function qw(n){const s=Hf(n.limits),i=Hf(n.scope),o=typeof n.intent=="string"?n.intent:"",c={bounds:s,context:i,gateContent:{intent:o}};return(n.mode==="automatic"||n.mode==="review")&&(c.templateMode=n.mode),typeof n.duration_hours=="number"&&n.duration_hours>0&&(c.templateTtl=Math.round(n.duration_hours*3600)),c}function uh(n){if(n==null)return"—";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);if(Array.isArray(n))return n.map(s=>uh(s)).join(", ");try{return JSON.stringify(n,null,2)}catch{return String(n)}}const Qw="setup__create_mandate";function dh({proposal:n,currentUserId:s,proposalLinks:i,toolDisplay:o,manifests:c,onContentState:d}){const[h,g]=f.useState(!1),[p,y]=f.useState(!1),[v,j]=f.useState(null),w=dn(),{group:N,groupId:E,domain:k}=vt(),C=Object.entries(n.executionContext),T=Qs(n.profileId),I=Vw(n.authorizationId),$=tw(n.executionContext,I,T),P=G0(n.tool),{integrationId:D}=fc(n.tool),K=Zm(D,c),{intent:V,loading:ce,error:Y}=Gw(n.authorizationId,s),re=ch(n),J=re.toolArgs!==null;f.useEffect(()=>{d==null||d({loading:re.loading,readable:J})},[re.loading,J]);const O=Kw(n),fe=re.toolArgs?rh(i,re.toolArgs):[],ie=async()=>{if(!E){j("No active workspace; cannot open the mandate screen.");return}y(!0),j(null);try{if(!re.toolArgs){j("This content is not readable on this device yet.");return}const M=re.toolArgs,H=typeof M.profile=="string"?M.profile:"",S=await B.listProfiles(),A=Jm(H,S);if(!A){j(`Unknown profile "${H}".`);return}const G=await B.getProfile(A.id),te=qw(M),ue=Qm(te.bounds,G),ve=Xm(te.context,G);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:A.id,groupId:E,groupName:(N==null?void 0:N.name)??null,domain:k,isPersonal:!!(N!=null&&N.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...te,bounds:ue,context:ve})),sessionStorage.setItem("agentReplacesProposal",n.id),w("/mandates/new/intent")}catch(M){j(M instanceof Error?M.message:"Could not open the mandate screen.")}finally{y(!1)}},[Z,pe]=f.useState(null),ee=Dw(Z),W=re.toolArgs?r.jsxs(r.Fragment,{children:[r.jsx(ah,{args:re.toolArgs,display:o,heading:""}),C.length>0&&r.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:C.map(([M,H],S)=>{const{label:A,hint:G}=eh(M,T);return r.jsxs("span",{children:[S>0&&" · ",r.jsxs("span",{title:G,children:[A,"=",uh(H)]})]},M)})})]}):null;return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"approval-headline",children:P}),re.sealed&&re.undecryptable&&r.jsxs("div",{className:"preview-box","data-testid":"proposal-undecryptable",style:{marginBottom:"0.5rem"},children:[r.jsx("strong",{children:"Encrypted for another device."}),r.jsx("p",{style:{margin:"0.35rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"This device was added after the proposal was made, and no device of yours has shared it yet. It is shared automatically once a device that can read it comes online — or open it there."})]}),re.sealed&&re.loading&&r.jsx("div",{className:"preview-box","data-testid":"proposal-decrypting",style:{marginBottom:"0.5rem"},children:"Decrypting…"}),ee&&J&&r.jsxs("div",{className:"preview-box preview-box-ok","data-testid":"bound-values-open",style:{marginBottom:"0.5rem"},children:[r.jsxs("h4",{children:["What will be sent",re.sealed?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})," ",r.jsx("span",{className:"lock-tag",children:"end-to-end encrypted"})]}):r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),W,re.sealed&&r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Decrypted on this device. suveren.ai stores only an unreadable copy and its fingerprint."})]}),O.length>0&&r.jsxs("p",{"data-testid":"proposal-cannot-read",style:{margin:"0 0 0.5rem",fontSize:"0.78rem",color:"var(--text-tertiary)"},children:["Cannot read this proposal yet: ",O.join(", ")," — shared automatically once they sign in on a device."]}),J&&r.jsx(Ww,{proposalId:n.id,systemName:K,onTone:pe}),$.length>0&&r.jsxs("div",{className:"limit-checks",children:[r.jsx("h4",{children:"Within your limits"}),r.jsx("ul",{className:"limit-check-list",children:$.map(M=>r.jsxs("li",{className:M.ok?"ok":"bad",children:[r.jsx("span",{className:"limit-check-icon",children:M.ok?"✓":"✗"}),r.jsxs("span",{children:[M.label," ",M.valueText," — your limit ",M.limitText]})]},M.key))})]}),r.jsxs("div",{className:"mandate-intent",children:[r.jsxs("dl",{children:[r.jsx("dt",{children:"Mandate"}),r.jsxs("dd",{children:[r.jsx("strong",{children:(T==null?void 0:T.name)??dt(n.profileId)}),r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]})]}),r.jsxs("dl",{children:[r.jsx("dt",{children:"Intent"}),r.jsx("dd",{children:Y?r.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:Y}):V!==null?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:`intent-text${h?"":" intent-clamped"}`,children:V}),r.jsx("button",{className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>g(!h),children:h?"Show less":"Show full intent"})]}):ce?r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"Loading intent…"}):r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this mandate."})})]})]}),J&&fe.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:fe.map(M=>r.jsxs("a",{href:M.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:M.description??M.href,children:[M.label," ↗"]},M.label))}),!ee&&J&&r.jsxs("details",{className:"proposal-args-fold",style:{marginBottom:"0.75rem"},children:[r.jsx("summary",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",cursor:"pointer"},children:"Details (exactly what is bound)"}),r.jsx("div",{style:{marginTop:"0.5rem"},children:W})]}),J&&n.tool===Qw&&r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",margin:"0 0 0.4rem"},children:["The intent above is written by the AI, but it becomes ",r.jsx("strong",{children:"your words"})," once you approve. Edit it first — nothing is created until you sign on the mandate screen."]}),r.jsx("button",{type:"button",className:"btn btn-secondary btn-sm","data-testid":"edit-before-signing",onClick:ie,disabled:p,children:p?"Opening…":"Edit before signing"}),v&&r.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:"0.4rem 0 0"},children:v})]})]})}function fh({note:n,onNoteChange:s,onSend:i,onCancel:o,sending:c,error:d}){return r.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"var(--bg-main)",padding:"0.75rem 0.875rem",marginTop:"0.5rem"},children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:[r.jsx("strong",{style:{color:"var(--text-primary)"},children:"What should change?"})," (the AI will read this)"]}),r.jsx("div",{style:{display:"flex",gap:"0.375rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:o0.map(h=>r.jsx("button",{type:"button",className:`filter-chip${Gm(n,h)?" selected":""}`,onClick:()=>s(c0(n,h)),disabled:c,children:h},h))}),r.jsx("textarea",{"data-testid":"change-note",className:"form-input",value:n,maxLength:Si,onChange:h=>s(h.target.value),rows:3,placeholder:"What should the AI do differently?",disabled:c,style:{width:"100%",resize:"vertical",fontFamily:"inherit"}}),r.jsxs("div",{style:{textAlign:"right",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[n.length," / ",Si]}),d&&r.jsx("div",{className:"error-message",style:{marginTop:"0.4rem"},children:d}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.5rem"},children:[r.jsx("button",{"data-testid":"btn-send-back",className:"btn btn-primary",style:{background:"var(--warning)",borderColor:"var(--warning)"},onClick:i,disabled:c,children:c?"Sending…":"Send back for change"}),r.jsx("button",{className:"btn btn-ghost",onClick:o,disabled:c,children:"Cancel"})]}),r.jsx("p",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",marginTop:"0.5rem",marginBottom:0},children:"The AI is told: adjust and propose again — a new proposal you approve again. Nothing runs from this one."})]})}const Xw={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired",refused:"Refused"},Zw={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired",refused:"status-revoked"},Vf={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced",REFUSED:"status-revoked"};function bl(n){const s=Date.now()-n*1e3,i=s/36e5;return i<48?i<1?`${Math.max(1,Math.round(s/6e4))}m ago`:`${Math.round(i)}h ago`:new Date(n*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ej(n){return n.split("__").pop()??n}function tj(n){const s=n.toLowerCase();return s.includes("delete")||s.includes("refund")||s.includes("cancel")||s.includes("revoke")}function mh(n){if(n==null)return"—";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);if(Array.isArray(n))return n.map(s=>mh(s)).join(", ");try{return JSON.stringify(n,null,2)}catch{return String(n)}}function Gf({item:n,onApprove:s,onReject:i,onChangeNeeded:o,resolving:c,proposalLinks:d,toolDisplay:h,manifests:g,currentUserId:p}){const y=n.kind==="proposal",v=y?n.proposal.status:"executed",j=y?n.proposal.tool:n.receipt.action,w=ej(j),N=tj(j),{integrationId:E}=fc(j),k=Zm(E,g),[C,T]=f.useState(!1),[I,$]=f.useState(""),[P,D]=f.useState(""),K=()=>{const A=dc(I);if(!A.valid){D(A.error);return}D(""),o==null||o(n.id,A.trimmed)},V=y&&v==="rejected"?m0(n.proposal,p??""):null,ce=y&&v==="refused"?h0(n.proposal):null,Y=Yw(y?n.proposal.rejectedBy??n.proposal.approverRejectedBy??null:null),re=Qs(n.profileId),J=ch(y?n.proposal:{toolArgs:void 0,content:void 0}),O=y?J.toolArgs:null,fe=y?n.proposal.executionContext:n.receipt.executionContext,ie=y?null:n.receipt.cumulativeState,[Z,pe]=f.useState(!0),[ee,W]=f.useState(!1),M=y&&J.toolArgs?rh(d,J.toolArgs):[],H=Object.entries(fe??{}),S=Sr(n.profileId).testSetup||Ti(j);return r.jsxs("div",{className:"card id-card",children:[r.jsx(qs,{profileId:n.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[r.jsx("code",{style:{fontSize:"0.85rem"},children:w}),S&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),n.commitmentMode==="automatic"&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),r.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[y&&v==="pending"&&(()=>{const A=sh(n.proposal.expiresAt,Date.now());return r.jsx("span",{style:{fontSize:"0.72rem",color:A.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:A.urgent?600:400,whiteSpace:"nowrap"},children:A.label})})(),r.jsx("span",{"data-testid":V||ce?"outcome-kind":void 0,className:`status-badge ${V?Vf[V.kind]:ce?Vf.REFUSED:Zw[v]}`,children:V?V.kind:ce?ce.kind:Xw[v]}),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:bl(n.sortTimestamp)})]})]}),y&&n.proposal.status==="executed"&&r.jsx(Uw,{proposalId:n.proposal.id,systemName:k}),V&&r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[r.jsxs("div",{children:["By ",V.who,", ",bl(V.at)]}),(Y??V.note)&&r.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[V.kind==="CHANGE NEEDED"?"Change: ":"Note: ",Y??V.note]})]}),ce&&r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[r.jsxs("div",{children:["By the Authority Server, ",bl(ce.at)]}),r.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:["Reason: ",ce.message]})]}),N&&r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.4rem",fontSize:"0.8rem",color:"var(--warning)",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.4rem 0.6rem",marginBottom:"0.75rem"},children:[r.jsx("span",{children:"⚠"}),r.jsx("span",{children:"Irreversible action"})]}),y&&typeof(O==null?void 0:O._imagePreview)=="string"&&r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),r.jsx("img",{src:O._imagePreview,alt:typeof(O==null?void 0:O.altText)=="string"?O.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),y&&v==="pending"?r.jsx(dh,{proposal:n.proposal,currentUserId:p??"",proposalLinks:d,toolDisplay:h,manifests:g,onContentState:({loading:A,readable:G})=>{W(A),pe(G)}}):r.jsxs(r.Fragment,{children:[M.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:M.map(A=>r.jsxs("a",{href:A.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:A.description??A.href,children:[A.label," ↗"]},A.label))}),y?r.jsxs(r.Fragment,{children:[O&&r.jsx(ah,{args:O,display:h}),H.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:H.map(([A,G])=>`${A}=${mh(G)}`).join(" · ")})]}):r.jsx(nh,{receipt:n.receipt,profile:re})]}),ie&&r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",ie.daily.count," action",ie.daily.count===1?"":"s",ie.daily.amount>0?`, ${ie.daily.amount}`:""," · ","this month: ",ie.monthly.count,ie.monthly.amount>0?`, ${ie.monthly.amount}`:""]}),y&&v==="pending"&&oh({loading:ee,readable:Z})&&(C?r.jsx(fh,{note:I,onNoteChange:$,onSend:K,onCancel:()=>{T(!1),$(""),D("")},sending:!!c,error:P}):r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:()=>s==null?void 0:s(n.id),disabled:c,children:c?"Approving…":"Approve"}),r.jsx("button",{"data-testid":"btn-change-needed",className:"btn",style:{background:"#fff",color:"var(--warning)",border:"1px solid var(--warning)"},onClick:()=>T(!0),disabled:c,children:"Change needed"}),r.jsx("button",{"data-testid":"btn-reject",className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:()=>i==null?void 0:i(n.id),disabled:c,children:"Reject"})]})),r.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[y?"Proposal":"Ticket",": ",n.id]})]})]})}function nj(n){const s=Date.now()-n*1e3,i=Math.floor(s/6e4);if(i<60)return`${Math.max(1,i)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function rj({proposal:n,currentUserId:s,onAction:i,onMessage:o,proposalLinks:c,toolDisplay:d,manifests:h}){const[g,p]=f.useState(!1),[y,v]=f.useState(!1),[j,w]=f.useState(!1),[N,E]=f.useState(""),[k,C]=f.useState(""),[T,I]=f.useState(!1),[$,P]=f.useState(!1),[D,K]=f.useState(!0),V=Sr(n.profileId).testSetup||Ti(n.tool),ce=n.pendingApprovers??[],Y=n.approvedBy??{},re=Object.keys(Y).length,J=ce.filter(ee=>!(ee in Y)).length,O=s in Y,fe=async()=>{if(ic()){o(oc);return}p(!0),o("");try{const ee=await yi(n);await B.approveProposal(n.id,ee);try{const W=await B.getAttestationIntent(n.authorizationId);if(W){const M=await B.decryptIntent({intentCiphertext:W.intentCiphertext,encryptedKey:W.encryptedKey,approverId:s});await B.storeApprovedIntent(n.authorizationId,M)}}catch{}o(`Approved. ${J-1>0?`${J-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),i()}catch(ee){o(ee instanceof Error?ee.message:"Approval failed")}finally{p(!1)}},ie=async()=>{v(!0),o("");try{const ee=await yi(n);await B.rejectProposal(n.id,Ll(),ee),o("Action rejected."),i()}catch(ee){o(ee instanceof Error?ee.message:"Rejection failed")}finally{v(!1)}},Z=async()=>{const ee=dc(N);if(!ee.valid){C(ee.error);return}C(""),I(!0),o("");try{const{noteEncrypted:W}=await B.encryptProposalNote(ee.trimmed,lh(n,s)),M=await yi(n);await B.rejectProposal(n.id,{outcome:"change_needed",noteEncrypted:W},M),o("Sent back for a change."),i()}catch(W){o(W instanceof Error?W.message:"Failed to send back")}finally{I(!1)}},pe=g||y||T;return r.jsxs("div",{className:"card id-card",children:[r.jsx(qs,{profileId:n.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[r.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),V&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),r.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const ee=sh(n.expiresAt,Date.now());return r.jsx("span",{style:{fontSize:"0.72rem",color:ee.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:ee.urgent?600:400,whiteSpace:"nowrap"},children:ee.label})})(),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:nj(n.createdAt)})]})]}),r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[re," of ",ce.length," approver",ce.length===1?"":"s"," signed off",ce.map(ee=>{const W=ee in Y;return r.jsxs("span",{style:{marginLeft:"0.5rem",color:W?"var(--success, green)":"var(--text-tertiary)"},children:[W?"✓":"○"," ",ee===s?"You":ee]},ee)})]}),r.jsx(dh,{proposal:n,currentUserId:s,proposalLinks:c,toolDisplay:d,manifests:h,onContentState:({loading:ee,readable:W})=>{P(ee),K(W)}}),!O&&oh({loading:$,readable:D})&&(j?r.jsx(fh,{note:N,onNoteChange:E,onSend:Z,onCancel:()=>{w(!1),E(""),C("")},sending:T,error:k}):r.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:fe,disabled:pe,children:g?"Approving...":"Approve"}),r.jsx("button",{"data-testid":"btn-change-needed",className:"btn",style:{background:"#fff",color:"var(--warning)",border:"1px solid var(--warning)"},onClick:()=>w(!0),disabled:pe,children:"Change needed"}),r.jsx("button",{"data-testid":"btn-reject",className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:ie,disabled:pe,children:y?"Rejecting...":"Reject"})]})),O&&r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"You approved this action. Waiting on other approvers."}),r.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",n.id]})]})]})}function sj(){const{domain:n,user:s}=vt(),i=(s==null?void 0:s.id)??"",[o,c]=f.useState("awaiting-me"),[d,h]=f.useState([]),[g,p]=f.useState([]),[y,v]=f.useState({}),[j,w]=f.useState(!0),[N,E]=f.useState(""),k=f.useCallback(async()=>{try{const X=await B.getProposalsForApprover();h(X)}catch{}finally{w(!1)}},[]);He("proposal-added",k),He("proposal-approved",k),He("proposal-rejected",k),He("proposal-resolved",k),Zt(k,3e4);const[C,T]=f.useState([]),I=f.useCallback(async()=>{try{const X=await B.getMyProposals(n);T(X)}catch{}},[n]);He("proposal-added",I),He("proposal-approved",I),He("proposal-rejected",I),He("proposal-resolved",I),Zt(I,3e4,n);const $=f.useMemo(()=>C.filter(X=>{var we;return X.status==="pending"&&(((we=X.pendingApprovers)==null?void 0:we.length)??0)===0}),[C]),P=f.useMemo(()=>Mf($,[],{status:"pending"}),[$]),[D,K]=f.useState([]),V=f.useCallback(async()=>{if(i)try{const we=(await B.getMyProposals(n)).filter(Te=>Te.status==="pending"&&Te.pendingApprovers&&Te.pendingApprovers.includes(i)&&Te.approvedBy&&i in Te.approvedBy);K(we)}catch{}},[i,n]);He("proposal-approved",V),He("proposal-rejected",V),Zt(V,3e4,`${i}:${n}`),f.useEffect(()=>{B.getIntegrationManifests().then(X=>p(X.manifests??[])).catch(()=>{}),B.getToolDisplay().then(v).catch(()=>{})},[]);const ce=X=>{var we;return(we=g.find(Te=>Te.id===X.split("__")[0]))==null?void 0:we.proposalLinks};f.useEffect(()=>{k(),I(),V()},[]);const[Y,re]=f.useState([]),[J,O]=f.useState([]),[fe,ie]=f.useState(!0),[Z,pe]=f.useState(null),[ee,W]=f.useState(""),[M,H]=f.useState("pending"),[S,A]=f.useState(null),[G,te]=f.useState(!1),ue=f.useCallback(async()=>{try{const{proposals:X,receipts:we}=await B.getThread({domain:n,status:M,sinceDays:7});re(X),O(we)}catch{}finally{ie(!1)}},[n,M]);Zt(ue,3e4,`${n}:${M}`);const ve=async(X,we,Te)=>{if(we==="commit"&&ic()){W(oc);return}pe(X),W("");try{const Le=Y.find(st=>st.id===X)??C.find(st=>st.id===X),lt=ev(Le,n),xt=Le?await yi(Le):void 0;let Ke=Te??{};if((Te==null?void 0:Te.outcome)==="change_needed"&&Te.note){const st=Le?lh(Le,i):[i],{noteEncrypted:ht}=await B.encryptProposalNote(Te.note,st);Ke={outcome:"change_needed",noteEncrypted:ht}}const et=await B.resolveProposal(X,we,lt,{...Ke,contentHash:xt});W(we==="commit"?`Action approved. Status: ${et.status}`:(Te==null?void 0:Te.outcome)==="change_needed"?"Sent back for a change.":"Action rejected."),await Promise.all([ue(),I()])}catch(Le){W(Le instanceof Error?Le.message:"Failed")}finally{pe(null)}},Ce=(X,we)=>ve(X,"reject",u0(we)),ke=f.useMemo(()=>{const X=new Set;for(const we of Y)X.add(we.profileId);for(const we of J)X.add(we.profileId);return Array.from(X).sort()},[Y,J]),se=f.useMemo(()=>Mf(Y,J,{status:M,profile:S??void 0,includeAutonomous:G}),[Y,J,M,S,G]),$e=f.useCallback(()=>{k(),V()},[k,V]),Ee=f.useMemo(()=>{const X=new Set,we=[];for(const Te of D)X.has(Te.id)||(X.add(Te.id),we.push(Te));return we.sort((Te,Le)=>Le.createdAt-Te.createdAt)},[D]),_e=d.length+P.length,me=Ee.length;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Pending Approvals"}),r.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."}),r.jsx(Lm,{what:"approve"})]}),r.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[r.jsxs("button",{className:`nav-tab${o==="awaiting-me"?" active":""}`,onClick:()=>c("awaiting-me"),children:["Awaiting me ",_e>0&&r.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--warning)",color:"var(--bg-elevated)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:_e})]}),r.jsxs("button",{className:`nav-tab${o==="awaiting-others"?" active":""}`,onClick:()=>c("awaiting-others"),children:["Awaiting others ",me>0&&r.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--border)",color:"var(--text-secondary)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:me})]}),r.jsx("button",{className:`nav-tab${o==="all"?" active":""}`,onClick:()=>{c("all"),ue()},children:"All"})]}),o==="awaiting-me"&&r.jsx(r.Fragment,{children:j&&_e===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):_e===0?r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[r.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(N||ee)&&r.jsx("div",{className:"alert alert-success",children:N||ee}),P.map(X=>r.jsx(Gf,{proposalLinks:X.kind==="proposal"?ce(X.proposal.tool):void 0,toolDisplay:X.kind==="proposal"?y[X.proposal.tool]:void 0,manifests:g,currentUserId:i,item:X,onApprove:we=>ve(we,"commit"),onReject:we=>ve(we,"reject",Ll()),onChangeNeeded:Ce,resolving:Z===X.id},X.id)),d.map(X=>r.jsx(rj,{proposal:X,currentUserId:i,onAction:$e,onMessage:E,proposalLinks:ce(X.tool),toolDisplay:y[X.tool],manifests:g},X.id))]})}),o==="awaiting-others"&&r.jsx(r.Fragment,{children:Ee.length===0?r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[r.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:Ee.map(X=>r.jsx(ij,{proposal:X,currentUserId:i,onCancel:async()=>{try{await B.rejectProposal(X.id,{reason:"cancelled by creator"}),V(),I()}catch(we){alert(we instanceof Error?we.message:"Cancel failed")}}},X.id))})}),o==="all"&&r.jsxs(r.Fragment,{children:[ee&&r.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:ee}),r.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[r.jsx("button",{className:`filter-chip ${M==="pending"?"selected":""}`,onClick:()=>H("pending"),children:"Pending"}),r.jsx("button",{className:`filter-chip ${M==="all"?"selected":""}`,onClick:()=>H("all"),children:"All"}),ke.length>0&&r.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),ke.map(X=>r.jsx("button",{className:`filter-chip ${S===X?"selected":""}`,onClick:()=>A(S===X?null:X),children:dt(X)},X)),M==="all"&&r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),r.jsxs("button",{className:`filter-chip ${G?"selected":""}`,onClick:()=>te(!G),title:"Include actions executed without human review (automatic commitment mode)",children:[G?"✓ ":"","Autonomous actions"]})]})]}),fe&&se.length===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):se.length===0?r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[r.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:M==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:M==="pending"?"Your agents are operating within their mandates. Switch to All to see recent activity.":"When an agent calls a gated tool, activity will appear here."})]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:se.map(X=>r.jsx(Gf,{proposalLinks:X.kind==="proposal"?ce(X.proposal.tool):void 0,toolDisplay:X.kind==="proposal"?y[X.proposal.tool]:void 0,manifests:g,currentUserId:i,item:X,onApprove:we=>ve(we,"commit"),onReject:we=>ve(we,"reject",Ll()),onChangeNeeded:Ce,resolving:Z===X.id},X.id))})]})]})}function aj(n){const s=Date.now()-n*1e3,i=Math.floor(s/6e4);if(i<60)return`${Math.max(1,i)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function ij({proposal:n,currentUserId:s,onCancel:i}){var v;const[o,c]=f.useState(!1),d=Object.keys(n.approvedBy??{}),h=(n.pendingApprovers??[]).filter(j=>!(j in(n.approvedBy??{}))),g=(((v=n.pendingApprovers)==null?void 0:v.length)??0)>0,p=async()=>{if(confirm("Cancel this action? All approvers will be notified.")){c(!0);try{await i()}finally{c(!1)}}},y=Sr(n.profileId).testSetup||Ti(n.tool);return r.jsxs("div",{className:"card id-card",children:[r.jsx(qs,{profileId:n.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[r.jsx("code",{style:{fontSize:"0.85rem"},children:n.tool.split("__").pop()??n.tool}),y&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),g&&r.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),r.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:aj(n.createdAt)})]}),g&&r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[d.map(j=>r.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:j===s?"You approved":`${j} approved`},j)),h.map(j=>r.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",j===s?"you":j]},j))]}),r.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:r.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--danger)"},onClick:p,disabled:o,children:o?"Cancelling...":"Cancel"})})]})]})}const oj=`# Agent Brief
85
-
86
- You act on my behalf through Suveren — the gateway that gates every
87
- privileged tool call you make. Suveren implements the bounded-authority
88
- model from the open Human Agency Protocol (HAP): each mandate
89
- describes an area of authority, a set of numeric limits, and a scope.
90
- Operate inside those bounds or the Gatekeeper will reject your action.
91
-
92
- ## Before you act in a domain
93
-
94
- 1. Call \`list-authorizations(domain: "<domain>")\` to load the full
95
- intent, scope, and usage for that area. The session brief shows only
96
- a one-line summary per mandate — the Intent paragraph lives behind
97
- that call, and often contains soft rules you MUST honor (e.g. "never
98
- publish on weekends", "only reply in English").
99
- 2. If the action would exceed a bound or fall outside the scope, stop
100
- and explain what would be blocked instead of trying.
101
- 3. If you're not sure whether an action is covered, ask me first.
102
-
103
- ## How to handle reviews
104
-
105
- Mandates in review mode require my approval before the action
106
- executes. When you propose an action:
107
- - Include everything I need to judge it (title, recipients, amounts,
108
- dates, attendees) in the tool arguments.
109
- - Don't batch unrelated proposals — one proposal per decision.
110
-
111
- ## Standing orders
112
-
113
- (Add your own here. Examples:)
114
-
115
- - Every morning, summarize today's calendar and flag conflicts.
116
- - On Fridays, give me a weekly review: what's done, what slipped, what's
117
- next.
118
- - Never email anyone outside the company without asking first.
119
- - When drafting posts, prefer plain language over marketing copy.
120
- `;function lj(){const[n,s]=f.useState(""),[i,o]=f.useState(""),[c,d]=f.useState(!0),[h,g]=f.useState(!1),[p,y]=f.useState(null),[v,j]=f.useState(!1),w=n!==i,N=new Blob([n]).size,E=16*1024;f.useEffect(()=>{if(!w)return;const I=P=>{P.preventDefault(),P.returnValue=""},$=P=>{var V,ce;if(P.defaultPrevented||P.button!==0||P.metaKey||P.ctrlKey||P.shiftKey||P.altKey)return;const D=(ce=(V=P.target)==null?void 0:V.closest)==null?void 0:ce.call(V,"a");if(!D||!D.href)return;let K;try{K=new URL(D.href)}catch{return}K.origin===window.location.origin&&K.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(P.preventDefault(),P.stopPropagation()))};return window.addEventListener("beforeunload",I),document.addEventListener("click",$,!0),()=>{window.removeEventListener("beforeunload",I),document.removeEventListener("click",$,!0)}},[w]),f.useEffect(()=>{let I=!1;return B.getAgentContext().then($=>{I||(s($),o($))}).catch($=>{I||y({kind:"error",text:$ instanceof Error?$.message:"Failed to load context"})}).finally(()=>{I||d(!1)}),()=>{I=!0}},[]);const k=async()=>{g(!0),y(null);try{await B.saveAgentContext(n),o(n),y({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(I){y({kind:"error",text:I instanceof Error?I.message:"Save failed"})}finally{g(!1)}},C=()=>{s(i),y(null)},T=()=>{n.trim()&&!confirm("Replace current context with the starter template?")||s(oj)};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Agent Brief"}),r.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!n.trim()&&!c&&r.jsx("button",{className:"btn btn-primary btn-sm",onClick:T,disabled:h,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),p&&r.jsx("div",{className:p.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:p.text}),r.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[r.jsx("div",{className:"card intent-pane chat",children:r.jsx(wi,{target:{kind:"context"},currentText:n,onApply:I=>{n.trim()&&!confirm("Replace the current context with the applied draft?")||s(I)},greeting:"Tell me what your agent should know — I'll help shape your standing orders. Or ask me to draft a full brief and we'll iterate.",placeholder:"Ask for help with your brief…"})}),r.jsxs("div",{className:"card intent-pane document",children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[r.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),r.jsxs("span",{style:{fontSize:"0.75rem",color:N>E?"var(--danger)":"var(--text-muted)"},children:[N.toLocaleString()," / ",E.toLocaleString()," bytes"]})]}),r.jsx("textarea",{className:"form-textarea",value:n,onChange:I=>s(I.target.value),placeholder:c?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:c,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),r.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:C,disabled:h||!w,children:"Revert"}),r.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:k,disabled:h||!w||N>E||c,children:h?"Saving…":"Save"})]})]}),r.jsx("button",{type:"button",className:"floating-help",onClick:()=>j(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),r.jsx(Mm,{open:v,onClose:()=>j(!1),ariaLabel:"Brief assistant",children:r.jsx(wi,{target:{kind:"context"},currentText:n,onApply:I=>{n.trim()&&!confirm("Replace the current context with the applied draft?")||(s(I),j(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function cj(n){const s=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(n);return s&&s[1].replace(/<[^>]+>/g,"").trim()||"Report"}function uj(n){const s=n.find(c=>{var d;return c.kind==="sv-mandate"&&c.status!=="unverifiable"&&typeof((d=c.data)==null?void 0:d.profile)=="string"});if(!s)return null;const i=s.data;if(typeof i.profileLabel=="string"&&i.profileLabel)return i.profileLabel;const o=i.profile.split("@")[0].split("/").pop();return o?o.charAt(0).toUpperCase()+o.slice(1):null}function dj(n){return new Date(n*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function fj(n,s){const i=s.emailExportError?"cases unknown":`${s.coveredCases.length}/${s.loadedCases.length} cases`;return`${n.signaturesValid>0?`${n.signaturesValid} ✓ tickets`:`${n.signaturesValid} tickets`} · ${i} · ${s.ticketsReferenced.length}/${s.ticketsInPeriod.length} tickets covered`}function mj(n){return n.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:n.emailExportError}:{kind:"ok",text:`${n.coveredCases.length} of ${n.loadedCases.length}`}}function hj(n){return n.periodStart!==null?null:n.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:n.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function Kf(n,s="none in this report"){return n>0?{kind:"ok",text:`${n} ✓`}:{kind:"neutral",text:s}}function pj(n){return/Labels?$/.test(n)||n==="limits"||n==="fields"}function gj(n,s){const i=s[n];return i==null||i===""||pj(n)?null:typeof i=="object"?JSON.stringify(i):String(i)}function yj(n){const s=[];return n.missingCases.length>0&&s.push(`cases ${n.missingCases.join(", ")}`),n.ticketsNotReferenced.length>0&&s.push(`${n.ticketsNotReferenced.length} ticket${n.ticketsNotReferenced.length===1?"":"s"}`),s.length>0?`Not in the report: ${s.join(" · ")}`:null}function vj(n,s){var i;if(s)return s;if(!n)return null;if(n.kind==="sv-ticket")return n.attrs.ref||null;if(n.kind==="sv-approval"||n.kind==="sv-mandate")return n.attrs.ticket||null;if(n.kind==="sv-case"){const o=(i=n.data)==null?void 0:i.goal;return(o==null?void 0:o.ticketId)??null}return null}const xj="allow-popups allow-popups-to-escape-sandbox",wj="AI analysis — not verified",jj="Green = verified by the gateway — raw signed fields only",Sj="Grey dashed = the AI's own analysis, not verified",kj="= translation by the AI, not verified",bj="Übersetzung anzeigen / show translation";function Yf(n){var i;const s=((i=n.formatNotice)==null?void 0:i.blocksNotShown)??0;return s<=0?null:`This report was written in an older format — ${s} ${s===1?"block was":"blocks were"} not shown. Ask the AI to write it again.`}function Nj(n,s){return s&&n.renderedHtmlGloss?n.renderedHtmlGloss:n.renderedHtml}function Cj(n,s,i){const o=new URLSearchParams(n);return o.set("element",s),i?o.set("ticket",i):o.delete("ticket"),o}const Ej={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function Tj(n){return n.filter(s=>s.status==="unverifiable").map(s=>({elementId:s.id,text:`${Ej[s.kind]??"Element"}: ${s.reason??"could not be checked"}`}))}function Rj(n){if(!n||n.kind!=="sv-case"||!n.data)return[];const s=Array.isArray(n.data.steps)?n.data.steps:[],i=n.data.goal,o=[...s.map(c=>({n:c,isGoal:!1})),...i?[{n:i,isGoal:!0}]:[]].filter(c=>typeof c.n.ticketId=="string"&&c.n.ticketId);return o.sort((c,d)=>(c.n.time??0)-(d.n.time??0)),o.map(({n:c,isGoal:d})=>({ticketId:c.ticketId,label:String(c.action??c.ticketId),isGoal:d}))}function Ij(n){return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:;"><style>body{margin:12px;background:#fff}</style></head><body>${n}</body></html>`}const mc={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},Aj={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function Pj(n,s){return Array.isArray(s.fields)?s.fields.map(o=>({label:o.key,value:o.value})):{Ticket:["action","profile","time"],Mandate:["profile","mode","owners","intent"],Approval:["createdAt","decidedAt","whoLabel","status","waitSeconds"]}[n].filter(o=>s[o]!==void 0&&s[o]!==null).map(o=>({label:o,value:typeof s[o]=="object"?JSON.stringify(s[o]):String(s[o])}))}function _j(n,s){const i=Aj[n].filter(o=>s[o]!==void 0);return i.length===0?null:r.jsxs("details",{style:{marginTop:"0.5rem"},children:[r.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical details"}),r.jsx("dl",{style:{...mc,marginTop:"0.5rem"},children:i.map(o=>r.jsxs("div",{style:{display:"contents"},children:[r.jsx("dt",{style:{color:"var(--text-muted)"},children:o}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:typeof s[o]=="object"?JSON.stringify(s[o]):String(s[o])})]},o))})]})}function Nl(n,s){return s?r.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[r.jsx("div",{className:"card-title",children:n}),s.status==="unverifiable"?r.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",s.reason??"no further detail."]}):r.jsxs(r.Fragment,{children:[r.jsx("dl",{style:mc,children:Pj(n,s.data??{}).map(({label:i,value:o})=>r.jsxs("div",{style:{display:"contents"},children:[r.jsx("dt",{style:{color:"var(--text-muted)"},children:i}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:o})]},i))}),_j(n,s.data??{})]})]}):null}function Lj({report:n,elementId:s,ticketParam:i,onClose:o,onSelectTicket:c}){var j;const d=n.elements.find(w=>w.id===s),h=vj(d,i),g=h?n.ticketDetails[h]:void 0,p=Rj(d),y=(j=n.proof.verifiedValues.find(w=>w.elementId===s))==null?void 0:j.summary,v=f.useRef(null);return f.useEffect(()=>{const w=v.current;if(!w||typeof w.getBoundingClientRect!="function")return;const N=w.getBoundingClientRect().top;(N<0||N>window.innerHeight-80)&&w.scrollIntoView({block:"start",behavior:"smooth"})},[s,i]),r.jsxs("div",{className:"card reports-detail",ref:v,children:[r.jsxs("div",{className:"card-header",children:[r.jsx("div",{className:"card-title",children:"Details"}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:o,children:"Close"})]}),y&&r.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:y}),p.length>0&&r.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:p.map(w=>r.jsxs("button",{type:"button",className:`btn btn-sm ${w.ticketId===h?"btn-secondary":"btn-ghost"}`,"aria-pressed":w.ticketId===h,onClick:()=>c(w.ticketId),children:[w.isGoal?"Goal: ":"",w.label]},w.ticketId))}),!d&&r.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),d&&!h&&(d.status==="unverifiable"?r.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",d.reason??"no further detail."]}):r.jsx("dl",{style:mc,children:Object.keys(d.data??{}).map(w=>{const N=gj(w,d.data??{});return N===null?null:r.jsxs("div",{style:{display:"contents"},children:[r.jsx("dt",{style:{color:"var(--text-muted)"},children:w}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:N})]},w)})})),g&&r.jsxs(r.Fragment,{children:[Nl("Ticket",g.ticket),Nl("Mandate",g.mandate),Nl("Approval",g.approval)]}),h&&!g&&r.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",h,"."]})]})}async function $j(n){const{html:s,filename:i}=await n.exportReport();n.download(s,i),await n.refresh()}function Jf({detail:n}){return n?r.jsxs("details",{style:{marginTop:"0.25rem"},children:[r.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical detail"}),r.jsx("p",{className:"page-subtitle",style:{marginTop:"0.25rem",wordBreak:"break-word"},children:n})]}):null}function zj({report:n,open:s,selectedId:i,onOpenElement:o,detail:c}){const{proof:d,coverage:h}=n,g=Tj(n.elements),p=yj(h),y=mj(h),v=hj(h),j=Kf(d.signaturesValid),w=Kf(d.recordsChecked);return r.jsxs("div",{className:`reports-side${s?" reports-side-open":""}`,children:[c,r.jsxs("div",{className:"card",children:[r.jsx("div",{className:"card-title",children:"Proof"}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Tickets referenced"}),r.jsx("b",{children:d.ticketsReferenced.length})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Signatures valid"}),r.jsx("b",{style:j.kind==="ok"?{color:"var(--success)"}:void 0,children:j.text})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Records checked"}),r.jsx("b",{style:w.kind==="ok"?{color:"var(--success)"}:void 0,children:w.text})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Not verifiable"}),r.jsx("b",{children:d.unverifiableCount})]}),g.map(N=>r.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${i===N.elementId?" reports-row-selected":""}`,onClick:()=>o(N.elementId),children:[r.jsx("span",{children:N.text}),r.jsx("span",{"aria-hidden":"true",children:"›"})]},N.elementId))]}),r.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[r.jsx("div",{className:"card-title",children:"Coverage"}),y.kind==="error"?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"reports-error",role:"alert",children:y.text}),r.jsx(Jf,{detail:y.detail})]}):r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Cases"}),r.jsx("b",{children:y.text})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Tickets in test period"}),r.jsxs("b",{children:[h.ticketsReferenced.length," of ",h.ticketsInPeriod.length]})]}),v&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:v.detail?"reports-error":"reports-note",role:v.detail?"alert":void 0,children:v.text}),r.jsx(Jf,{detail:v.detail})]}),p&&r.jsx("p",{className:"reports-missing",children:p})]}),d.verifiedValues.length>0&&r.jsxs("div",{className:"card reports-checked-values",style:{marginTop:"0.75rem"},children:[r.jsx("div",{className:"card-title",children:"Checked values"}),d.verifiedValues.map(N=>r.jsxs("button",{type:"button",className:`reports-row reports-row-button${i===N.elementId?" reports-row-selected":""}`,onClick:()=>o(N.elementId),title:"Show details",children:[r.jsx("span",{children:N.summary}),r.jsx("span",{"aria-hidden":"true",children:"›"})]},N.elementId))]})]})}function Fj(){const[n,s]=f.useState(null),[i,o]=f.useState(!0),[c,d]=f.useState(null),[h,g]=f.useState(!1),[p,y]=f.useState(!1),[v,j]=f.useState(null),[w,N]=f.useState(!1),[E,k]=f.useState(!1),[C,T]=Xl(),I=f.useCallback(()=>B.getReport().then(({report:O})=>s(O)).catch(O=>d(O instanceof Error?O.message:String(O))),[]),$=f.useCallback(()=>{o(!0),d(null),I().finally(()=>o(!1))},[I]);f.useEffect(()=>{$()},[$]);const P=f.useCallback(()=>{g(!0),B.recheckReport().then(({report:O})=>s(O)).catch(O=>d(O instanceof Error?O.message:String(O))).finally(()=>g(!1))},[]),D=f.useCallback(async()=>{y(!0),j(null);try{await $j({exportReport:()=>B.exportReportWithProof(),download:(O,fe)=>{const ie=URL.createObjectURL(new Blob([O],{type:"text/html"})),Z=document.createElement("a");Z.href=ie,Z.download=fe,Z.click(),URL.revokeObjectURL(ie)},refresh:I})}catch(O){j(O instanceof Error?O.message:String(O))}finally{y(!1)}},[I]),K=C.get("element"),V=C.get("ticket"),ce=f.useCallback((O,fe)=>{T(Cj(C,O,fe))},[C,T]),Y=f.useCallback(()=>{const O=new URLSearchParams(C);O.delete("element"),O.delete("ticket"),T(O,{replace:!0})},[C,T]);if(i)return r.jsxs("div",{className:"page-inner",children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Reports"})}),r.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(c)return r.jsxs("div",{className:"page-inner",children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Reports"})}),r.jsx(qr,{icon:"⚠",title:"Report unavailable",text:c})]});if(!n)return r.jsxs("div",{className:"page-inner",children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Reports"})}),r.jsx(qr,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const re=cj(n.renderedHtml),J=uj(n.elements);return r.jsx("div",{className:"page-inner reports-page",children:r.jsxs("div",{className:"reports-layout",children:[r.jsxs("div",{className:"reports-bar",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:re}),r.jsxs("p",{className:"page-subtitle",children:[J?`written by the AI under mandate ${J} · `:"","checked ",dj(n.checkedAt)]})]}),r.jsxs("div",{className:"reports-bar-actions",children:[r.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:P,disabled:h,children:h?"Checking…":"Check again"}),r.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:D,disabled:p,children:p?"Exporting…":"Export with proof"})]})]}),v&&r.jsxs("p",{className:"reports-error",role:"alert",style:{margin:"0.5rem 0 0 0"},children:["Export failed: ",v]}),r.jsxs("div",{className:"reports-summary-chip",children:[r.jsx("span",{children:fj(n.proof,n.coverage)}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>N(O=>!O),children:w?"hide":"details"})]}),r.jsxs("div",{className:"reports-grid",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"reports-legend",role:"note",children:[r.jsxs("span",{className:"reports-legend-chip",children:[r.jsx("span",{className:"reports-sw reports-sw-v"}),jj]}),r.jsxs("span",{className:"reports-legend-chip",children:[r.jsx("span",{className:"reports-sw reports-sw-a"}),Sj," (“",wj,"”)"]}),n.renderedHtmlGloss&&r.jsxs("span",{className:"reports-legend-chip",children:[r.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",kj]})]}),Yf(n)&&r.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:Yf(n)}),n.renderedHtmlGloss&&r.jsxs("label",{className:"reports-gloss-switch",children:[r.jsx("input",{type:"checkbox",role:"switch",checked:E,onChange:O=>k(O.target.checked)}),r.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:r.jsx("span",{className:"reports-gloss-thumb"})}),r.jsx("span",{children:bj})]}),r.jsx("p",{className:"form-hint",style:{marginBottom:"0.5rem"},children:"Written by the AI, rendered without scripts or network access. Scroll inside the report — the gateway does not auto-resize the frame. Click a checked value to see its details."}),r.jsx("iframe",{title:"Report",sandbox:xj,srcDoc:Ij(Nj(n,E)),className:"reports-iframe"})]}),r.jsx(zj,{report:n,open:w||!!K,selectedId:K,onOpenElement:O=>ce(O),detail:K?r.jsx(Lj,{report:n,elementId:K,ticketParam:V,onClose:Y,onSelectTicket:O=>ce(K,O)}):void 0})]})]})})}function Yr({to:n}){const{search:s,hash:i}=Bt();return r.jsx(In,{to:`${n}${s}${i}`,replace:!0})}function Oj({children:n}){const{user:s,mode:i,domain:o}=vt();return s?i==="team"&&!o?r.jsx(In,{to:"/onboarding",replace:!0}):r.jsx(r.Fragment,{children:n}):r.jsx(In,{to:"/login",replace:!0})}function Mj(){const{user:n,handleSessionLocked:s,refreshGroups:i}=vt();return He("session-locked",o=>{const c=o==null?void 0:o.message;s(c)}),He("team-membership-changed",()=>{i()}),r.jsxs(yy,{children:[r.jsx(Qe,{path:"/login",element:n?r.jsx(In,{to:"/",replace:!0}):r.jsx(ax,{})}),r.jsx(Qe,{path:"/onboarding",element:n?r.jsx(dx,{}):r.jsx(In,{to:"/login",replace:!0})}),r.jsxs(Qe,{element:r.jsx(Oj,{children:r.jsx(sx,{})}),children:[r.jsx(Qe,{path:"/",element:r.jsx(Cx,{})}),r.jsx(Qe,{path:"/mandates",element:r.jsx(H0,{})}),r.jsx(Qe,{path:"/mandates/new/intent",element:r.jsx(Qx,{})}),r.jsx(Qe,{path:"/mandates/new/sign",element:r.jsx(p0,{})}),r.jsx(Qe,{path:"/integrations",element:r.jsx(S0,{})}),r.jsx(Qe,{path:"/team",element:r.jsx(k0,{})}),r.jsx(Qe,{path:"/tickets",element:r.jsx(jw,{})}),r.jsx(Qe,{path:"/blocked",element:r.jsx(Sw,{})}),r.jsx(Qe,{path:"/approvals",element:r.jsx(sj,{})}),r.jsx(Qe,{path:"/reports",element:r.jsx(Fj,{})}),r.jsx(Qe,{path:"/agent/new",element:r.jsx(In,{to:"/mandates?new=1",replace:!0})}),r.jsx(Qe,{path:"/agent/gate",element:r.jsx(Yr,{to:"/mandates/new/intent"})}),r.jsx(Qe,{path:"/agent/review",element:r.jsx(Yr,{to:"/mandates/new/sign"})}),r.jsx(Qe,{path:"/authorizations",element:r.jsx(Yr,{to:"/mandates"})}),r.jsx(Qe,{path:"/groups",element:r.jsx(Yr,{to:"/team"})}),r.jsx(Qe,{path:"/audit",element:r.jsx(Yr,{to:"/tickets"})}),r.jsx(Qe,{path:"/proposals",element:r.jsx(Yr,{to:"/approvals"})}),r.jsx(Qe,{path:"/agent-brief",element:r.jsx(lj,{})}),r.jsx(Qe,{path:"/settings",element:r.jsx(Pw,{})}),r.jsx(Qe,{path:"/settings/services",element:r.jsx(In,{to:"/settings",replace:!0})}),r.jsx(Qe,{path:"/deploy",element:r.jsx(In,{to:"/integrations",replace:!0})})]}),r.jsx(Qe,{path:"*",element:r.jsx(In,{to:"/",replace:!0})})]})}function Bj(){return r.jsx(Uy,{children:r.jsx(rv,{children:r.jsx(sv,{children:r.jsx(Mj,{})})})})}hg.createRoot(document.getElementById("root")).render(r.jsx(f.StrictMode,{children:r.jsx(Bj,{})}));