@suveren/gateway 0.32.0 → 0.33.0
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.
- package/dist/control-plane/index.mjs +37 -1
- package/dist/mcp-server/http.mjs +129 -6
- package/dist/ui/assets/index-Bev2H2zu.js +123 -0
- package/dist/ui/assets/{index-BWCRFqkv.css → index-BiGnI2Tk.css} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +1 -1
- package/dist/ui/assets/index-BCAc8h7B.js +0 -123
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
var $y=Object.defineProperty;var _y=(e,s,a)=>s in e?$y(e,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[s]=a;var Js=(e,s,a)=>_y(e,typeof s!="symbol"?s+"":s,a);(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))o(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const f of u.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&o(f)}).observe(document,{childList:!0,subtree:!0});function a(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(l){if(l.ep)return;l.ep=!0;const u=a(l);fetch(l.href,u)}})();var Ul={exports:{}},Qs={},Wl={exports:{}},De={};/**
|
|
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 Tf;function Ly(){if(Tf)return De;Tf=1;var e=Symbol.for("react.element"),s=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),f=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),x=Symbol.iterator;function j(A){return A===null||typeof A!="object"?null:(A=x&&A[x]||A["@@iterator"],typeof A=="function"?A:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,S={};function N(A,$,ie){this.props=A,this.context=$,this.refs=S,this.updater=ie||k}N.prototype.isReactComponent={},N.prototype.setState=function(A,$){if(typeof A!="object"&&typeof A!="function"&&A!=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,A,$,"setState")},N.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function E(){}E.prototype=N.prototype;function T(A,$,ie){this.props=A,this.context=$,this.refs=S,this.updater=ie||k}var P=T.prototype=new E;P.constructor=T,b(P,N.prototype),P.isPureReactComponent=!0;var I=Array.isArray,B=Object.prototype.hasOwnProperty,O={current:null},K={key:!0,ref:!0,__self:!0,__source:!0};function z(A,$,ie){var re,H={},oe=null,ue=null;if($!=null)for(re in $.ref!==void 0&&(ue=$.ref),$.key!==void 0&&(oe=""+$.key),$)B.call($,re)&&!K.hasOwnProperty(re)&&(H[re]=$[re]);var pe=arguments.length-2;if(pe===1)H.children=ie;else if(1<pe){for(var ve=Array(pe),le=0;le<pe;le++)ve[le]=arguments[le+2];H.children=ve}if(A&&A.defaultProps)for(re in pe=A.defaultProps,pe)H[re]===void 0&&(H[re]=pe[re]);return{$$typeof:e,type:A,key:oe,ref:ue,props:H,_owner:O.current}}function U(A,$){return{$$typeof:e,type:A.type,key:$,ref:A.ref,props:A.props,_owner:A._owner}}function ee(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function X(A){var $={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(ie){return $[ie]})}var F=/\/+/g;function ne(A,$){return typeof A=="object"&&A!==null&&A.key!=null?X(""+A.key):$.toString(36)}function fe(A,$,ie,re,H){var oe=typeof A;(oe==="undefined"||oe==="boolean")&&(A=null);var ue=!1;if(A===null)ue=!0;else switch(oe){case"string":case"number":ue=!0;break;case"object":switch(A.$$typeof){case e:case s:ue=!0}}if(ue)return ue=A,H=H(ue),A=re===""?"."+ne(ue,0):re,I(H)?(ie="",A!=null&&(ie=A.replace(F,"$&/")+"/"),fe(H,$,ie,"",function(le){return le})):H!=null&&(ee(H)&&(H=U(H,ie+(!H.key||ue&&ue.key===H.key?"":(""+H.key).replace(F,"$&/")+"/")+A)),$.push(H)),1;if(ue=0,re=re===""?".":re+":",I(A))for(var pe=0;pe<A.length;pe++){oe=A[pe];var ve=re+ne(oe,pe);ue+=fe(oe,$,ie,ve,H)}else if(ve=j(A),typeof ve=="function")for(A=ve.call(A),pe=0;!(oe=A.next()).done;)oe=oe.value,ve=re+ne(oe,pe++),ue+=fe(oe,$,ie,ve,H);else if(oe==="object")throw $=String(A),Error("Objects are not valid as a React child (found: "+($==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":$)+"). If you meant to render a collection of children, use an array instead.");return ue}function te(A,$,ie){if(A==null)return A;var re=[],H=0;return fe(A,re,"","",function(oe){return $.call(ie,oe,H++)}),re}function ge(A){if(A._status===-1){var $=A._result;$=$(),$.then(function(ie){(A._status===0||A._status===-1)&&(A._status=1,A._result=ie)},function(ie){(A._status===0||A._status===-1)&&(A._status=2,A._result=ie)}),A._status===-1&&(A._status=0,A._result=$)}if(A._status===1)return A._result.default;throw A._result}var ke={current:null},Z={transition:null},Q={ReactCurrentDispatcher:ke,ReactCurrentBatchConfig:Z,ReactCurrentOwner:O};function q(){throw Error("act(...) is not supported in production builds of React.")}return De.Children={map:te,forEach:function(A,$,ie){te(A,function(){$.apply(this,arguments)},ie)},count:function(A){var $=0;return te(A,function(){$++}),$},toArray:function(A){return te(A,function($){return $})||[]},only:function(A){if(!ee(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},De.Component=N,De.Fragment=a,De.Profiler=l,De.PureComponent=T,De.StrictMode=o,De.Suspense=g,De.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Q,De.act=q,De.cloneElement=function(A,$,ie){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var re=b({},A.props),H=A.key,oe=A.ref,ue=A._owner;if($!=null){if($.ref!==void 0&&(oe=$.ref,ue=O.current),$.key!==void 0&&(H=""+$.key),A.type&&A.type.defaultProps)var pe=A.type.defaultProps;for(ve in $)B.call($,ve)&&!K.hasOwnProperty(ve)&&(re[ve]=$[ve]===void 0&&pe!==void 0?pe[ve]:$[ve])}var ve=arguments.length-2;if(ve===1)re.children=ie;else if(1<ve){pe=Array(ve);for(var le=0;le<ve;le++)pe[le]=arguments[le+2];re.children=pe}return{$$typeof:e,type:A.type,key:H,ref:oe,props:re,_owner:ue}},De.createContext=function(A){return A={$$typeof:f,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},A.Provider={$$typeof:u,_context:A},A.Consumer=A},De.createElement=z,De.createFactory=function(A){var $=z.bind(null,A);return $.type=A,$},De.createRef=function(){return{current:null}},De.forwardRef=function(A){return{$$typeof:p,render:A}},De.isValidElement=ee,De.lazy=function(A){return{$$typeof:y,_payload:{_status:-1,_result:A},_init:ge}},De.memo=function(A,$){return{$$typeof:v,type:A,compare:$===void 0?null:$}},De.startTransition=function(A){var $=Z.transition;Z.transition={};try{A()}finally{Z.transition=$}},De.unstable_act=q,De.useCallback=function(A,$){return ke.current.useCallback(A,$)},De.useContext=function(A){return ke.current.useContext(A)},De.useDebugValue=function(){},De.useDeferredValue=function(A){return ke.current.useDeferredValue(A)},De.useEffect=function(A,$){return ke.current.useEffect(A,$)},De.useId=function(){return ke.current.useId()},De.useImperativeHandle=function(A,$,ie){return ke.current.useImperativeHandle(A,$,ie)},De.useInsertionEffect=function(A,$){return ke.current.useInsertionEffect(A,$)},De.useLayoutEffect=function(A,$){return ke.current.useLayoutEffect(A,$)},De.useMemo=function(A,$){return ke.current.useMemo(A,$)},De.useReducer=function(A,$,ie){return ke.current.useReducer(A,$,ie)},De.useRef=function(A){return ke.current.useRef(A)},De.useState=function(A){return ke.current.useState(A)},De.useSyncExternalStore=function(A,$,ie){return ke.current.useSyncExternalStore(A,$,ie)},De.useTransition=function(){return ke.current.useTransition()},De.version="18.3.1",De}var Af;function bc(){return Af||(Af=1,Wl.exports=Ly()),Wl.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 If;function zy(){if(If)return Qs;If=1;var e=bc(),s=Symbol.for("react.element"),a=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function f(p,g,v){var y,x={},j=null,k=null;v!==void 0&&(j=""+v),g.key!==void 0&&(j=""+g.key),g.ref!==void 0&&(k=g.ref);for(y in g)o.call(g,y)&&!u.hasOwnProperty(y)&&(x[y]=g[y]);if(p&&p.defaultProps)for(y in g=p.defaultProps,g)x[y]===void 0&&(x[y]=g[y]);return{$$typeof:s,type:p,key:j,ref:k,props:x,_owner:l.current}}return Qs.Fragment=a,Qs.jsx=f,Qs.jsxs=f,Qs}var Rf;function Fy(){return Rf||(Rf=1,Ul.exports=zy()),Ul.exports}var n=Fy(),h=bc(),Ni={},Hl={exports:{}},Jt={},Vl={exports:{}},Gl={};/**
|
|
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 Pf;function My(){return Pf||(Pf=1,(function(e){function s(Z,Q){var q=Z.length;Z.push(Q);e:for(;0<q;){var A=q-1>>>1,$=Z[A];if(0<l($,Q))Z[A]=Q,Z[q]=$,q=A;else break e}}function a(Z){return Z.length===0?null:Z[0]}function o(Z){if(Z.length===0)return null;var Q=Z[0],q=Z.pop();if(q!==Q){Z[0]=q;e:for(var A=0,$=Z.length,ie=$>>>1;A<ie;){var re=2*(A+1)-1,H=Z[re],oe=re+1,ue=Z[oe];if(0>l(H,q))oe<$&&0>l(ue,H)?(Z[A]=ue,Z[oe]=q,A=oe):(Z[A]=H,Z[re]=q,A=re);else if(oe<$&&0>l(ue,q))Z[A]=ue,Z[oe]=q,A=oe;else break e}}return Q}function l(Z,Q){var q=Z.sortIndex-Q.sortIndex;return q!==0?q:Z.id-Q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var f=Date,p=f.now();e.unstable_now=function(){return f.now()-p}}var g=[],v=[],y=1,x=null,j=3,k=!1,b=!1,S=!1,N=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function P(Z){for(var Q=a(v);Q!==null;){if(Q.callback===null)o(v);else if(Q.startTime<=Z)o(v),Q.sortIndex=Q.expirationTime,s(g,Q);else break;Q=a(v)}}function I(Z){if(S=!1,P(Z),!b)if(a(g)!==null)b=!0,ge(B);else{var Q=a(v);Q!==null&&ke(I,Q.startTime-Z)}}function B(Z,Q){b=!1,S&&(S=!1,E(z),z=-1),k=!0;var q=j;try{for(P(Q),x=a(g);x!==null&&(!(x.expirationTime>Q)||Z&&!X());){var A=x.callback;if(typeof A=="function"){x.callback=null,j=x.priorityLevel;var $=A(x.expirationTime<=Q);Q=e.unstable_now(),typeof $=="function"?x.callback=$:x===a(g)&&o(g),P(Q)}else o(g);x=a(g)}if(x!==null)var ie=!0;else{var re=a(v);re!==null&&ke(I,re.startTime-Q),ie=!1}return ie}finally{x=null,j=q,k=!1}}var O=!1,K=null,z=-1,U=5,ee=-1;function X(){return!(e.unstable_now()-ee<U)}function F(){if(K!==null){var Z=e.unstable_now();ee=Z;var Q=!0;try{Q=K(!0,Z)}finally{Q?ne():(O=!1,K=null)}}else O=!1}var ne;if(typeof T=="function")ne=function(){T(F)};else if(typeof MessageChannel<"u"){var fe=new MessageChannel,te=fe.port2;fe.port1.onmessage=F,ne=function(){te.postMessage(null)}}else ne=function(){N(F,0)};function ge(Z){K=Z,O||(O=!0,ne())}function ke(Z,Q){z=N(function(){Z(e.unstable_now())},Q)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(Z){Z.callback=null},e.unstable_continueExecution=function(){b||k||(b=!0,ge(B))},e.unstable_forceFrameRate=function(Z){0>Z||125<Z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<Z?Math.floor(1e3/Z):5},e.unstable_getCurrentPriorityLevel=function(){return j},e.unstable_getFirstCallbackNode=function(){return a(g)},e.unstable_next=function(Z){switch(j){case 1:case 2:case 3:var Q=3;break;default:Q=j}var q=j;j=Q;try{return Z()}finally{j=q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Z,Q){switch(Z){case 1:case 2:case 3:case 4:case 5:break;default:Z=3}var q=j;j=Z;try{return Q()}finally{j=q}},e.unstable_scheduleCallback=function(Z,Q,q){var A=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?A+q:A):q=A,Z){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=q+$,Z={id:y++,callback:Q,priorityLevel:Z,startTime:q,expirationTime:$,sortIndex:-1},q>A?(Z.sortIndex=q,s(v,Z),a(g)===null&&Z===a(v)&&(S?(E(z),z=-1):S=!0,ke(I,q-A))):(Z.sortIndex=$,s(g,Z),b||k||(b=!0,ge(B))),Z},e.unstable_shouldYield=X,e.unstable_wrapCallback=function(Z){var Q=j;return function(){var q=j;j=Q;try{return Z.apply(this,arguments)}finally{j=q}}}})(Gl)),Gl}var $f;function Oy(){return $f||($f=1,Vl.exports=My()),Vl.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 _f;function By(){if(_f)return Jt;_f=1;var e=bc(),s=Oy();function a(t){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+t,i=1;i<arguments.length;i++)r+="&args[]="+encodeURIComponent(arguments[i]);return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,l={};function u(t,r){f(t,r),f(t+"Capture",r)}function f(t,r){for(l[t]=r,t=0;t<r.length;t++)o.add(r[t])}var p=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),g=Object.prototype.hasOwnProperty,v=/^[: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]*$/,y={},x={};function j(t){return g.call(x,t)?!0:g.call(y,t)?!1:v.test(t)?x[t]=!0:(y[t]=!0,!1)}function k(t,r,i,c){if(i!==null&&i.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return c?!1:i!==null?!i.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function b(t,r,i,c){if(r===null||typeof r>"u"||k(t,r,i,c))return!0;if(c)return!1;if(i!==null)switch(i.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function S(t,r,i,c,d,m,w){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=c,this.attributeNamespace=d,this.mustUseProperty=i,this.propertyName=t,this.type=r,this.sanitizeURL=m,this.removeEmptyString=w}var N={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){N[t]=new S(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var r=t[0];N[r]=new S(r,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){N[t]=new S(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){N[t]=new S(t,2,!1,t,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(t){N[t]=new S(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){N[t]=new S(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){N[t]=new S(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){N[t]=new S(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){N[t]=new S(t,5,!1,t.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function T(t){return t[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(t){var r=t.replace(E,T);N[r]=new S(r,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var r=t.replace(E,T);N[r]=new S(r,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var r=t.replace(E,T);N[r]=new S(r,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){N[t]=new S(t,1,!1,t.toLowerCase(),null,!1,!1)}),N.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){N[t]=new S(t,1,!1,t.toLowerCase(),null,!0,!0)});function P(t,r,i,c){var d=N.hasOwnProperty(r)?N[r]:null;(d!==null?d.type!==0:c||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(b(r,i,d,c)&&(i=null),c||d===null?j(r)&&(i===null?t.removeAttribute(r):t.setAttribute(r,""+i)):d.mustUseProperty?t[d.propertyName]=i===null?d.type===3?!1:"":i:(r=d.attributeName,c=d.attributeNamespace,i===null?t.removeAttribute(r):(d=d.type,i=d===3||d===4&&i===!0?"":""+i,c?t.setAttributeNS(c,r,i):t.setAttribute(r,i))))}var I=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,B=Symbol.for("react.element"),O=Symbol.for("react.portal"),K=Symbol.for("react.fragment"),z=Symbol.for("react.strict_mode"),U=Symbol.for("react.profiler"),ee=Symbol.for("react.provider"),X=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),ne=Symbol.for("react.suspense"),fe=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),ge=Symbol.for("react.lazy"),ke=Symbol.for("react.offscreen"),Z=Symbol.iterator;function Q(t){return t===null||typeof t!="object"?null:(t=Z&&t[Z]||t["@@iterator"],typeof t=="function"?t:null)}var q=Object.assign,A;function $(t){if(A===void 0)try{throw Error()}catch(i){var r=i.stack.trim().match(/\n( *(at )?)/);A=r&&r[1]||""}return`
|
|
34
|
+
`+A+t}var ie=!1;function re(t,r){if(!t||ie)return"";ie=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(V){var c=V}Reflect.construct(t,[],r)}else{try{r.call()}catch(V){c=V}t.call(r.prototype)}else{try{throw Error()}catch(V){c=V}t()}}catch(V){if(V&&c&&typeof V.stack=="string"){for(var d=V.stack.split(`
|
|
35
|
+
`),m=c.stack.split(`
|
|
36
|
+
`),w=d.length-1,C=m.length-1;1<=w&&0<=C&&d[w]!==m[C];)C--;for(;1<=w&&0<=C;w--,C--)if(d[w]!==m[C]){if(w!==1||C!==1)do if(w--,C--,0>C||d[w]!==m[C]){var R=`
|
|
37
|
+
`+d[w].replace(" at new "," at ");return t.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",t.displayName)),R}while(1<=w&&0<=C);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(t=t?t.displayName||t.name:"")?$(t):""}function H(t){switch(t.tag){case 5:return $(t.type);case 16:return $("Lazy");case 13:return $("Suspense");case 19:return $("SuspenseList");case 0:case 2:case 15:return t=re(t.type,!1),t;case 11:return t=re(t.type.render,!1),t;case 1:return t=re(t.type,!0),t;default:return""}}function oe(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case K:return"Fragment";case O:return"Portal";case U:return"Profiler";case z:return"StrictMode";case ne:return"Suspense";case fe:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case X:return(t.displayName||"Context")+".Consumer";case ee:return(t._context.displayName||"Context")+".Provider";case F:var r=t.render;return t=t.displayName,t||(t=r.displayName||r.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case te:return r=t.displayName||null,r!==null?r:oe(t.type)||"Memo";case ge:r=t._payload,t=t._init;try{return oe(t(r))}catch{}}return null}function ue(t){var r=t.type;switch(t.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=r.render,t=t.displayName||t.name||"",r.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return oe(r);case 8:return r===z?"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 r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function pe(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function ve(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function le(t){var r=ve(t)?"checked":"value",i=Object.getOwnPropertyDescriptor(t.constructor.prototype,r),c=""+t[r];if(!t.hasOwnProperty(r)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var d=i.get,m=i.set;return Object.defineProperty(t,r,{configurable:!0,get:function(){return d.call(this)},set:function(w){c=""+w,m.call(this,w)}}),Object.defineProperty(t,r,{enumerable:i.enumerable}),{getValue:function(){return c},setValue:function(w){c=""+w},stopTracking:function(){t._valueTracker=null,delete t[r]}}}}function Ge(t){t._valueTracker||(t._valueTracker=le(t))}function Se(t){if(!t)return!1;var r=t._valueTracker;if(!r)return!0;var i=r.getValue(),c="";return t&&(c=ve(t)?t.checked?"true":"false":t.value),t=c,t!==i?(r.setValue(t),!0):!1}function Y(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function $e(t,r){var i=r.checked;return q({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??t._wrapperState.initialChecked})}function _e(t,r){var i=r.defaultValue==null?"":r.defaultValue,c=r.checked!=null?r.checked:r.defaultChecked;i=pe(r.value!=null?r.value:i),t._wrapperState={initialChecked:c,initialValue:i,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Be(t,r){r=r.checked,r!=null&&P(t,"checked",r,!1)}function ze(t,r){Be(t,r);var i=pe(r.value),c=r.type;if(i!=null)c==="number"?(i===0&&t.value===""||t.value!=i)&&(t.value=""+i):t.value!==""+i&&(t.value=""+i);else if(c==="submit"||c==="reset"){t.removeAttribute("value");return}r.hasOwnProperty("value")?tt(t,r.type,i):r.hasOwnProperty("defaultValue")&&tt(t,r.type,pe(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(t.defaultChecked=!!r.defaultChecked)}function it(t,r,i){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var c=r.type;if(!(c!=="submit"&&c!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+t._wrapperState.initialValue,i||r===t.value||(t.value=r),t.defaultValue=r}i=t.name,i!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,i!==""&&(t.name=i)}function tt(t,r,i){(r!=="number"||Y(t.ownerDocument)!==t)&&(i==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+i&&(t.defaultValue=""+i))}var Qe=Array.isArray;function Ye(t,r,i,c){if(t=t.options,r){r={};for(var d=0;d<i.length;d++)r["$"+i[d]]=!0;for(i=0;i<t.length;i++)d=r.hasOwnProperty("$"+t[i].value),t[i].selected!==d&&(t[i].selected=d),d&&c&&(t[i].defaultSelected=!0)}else{for(i=""+pe(i),r=null,d=0;d<t.length;d++){if(t[d].value===i){t[d].selected=!0,c&&(t[d].defaultSelected=!0);return}r!==null||t[d].disabled||(r=t[d])}r!==null&&(r.selected=!0)}}function jt(t,r){if(r.dangerouslySetInnerHTML!=null)throw Error(a(91));return q({},r,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function pt(t,r){var i=r.value;if(i==null){if(i=r.children,r=r.defaultValue,i!=null){if(r!=null)throw Error(a(92));if(Qe(i)){if(1<i.length)throw Error(a(93));i=i[0]}r=i}r==null&&(r=""),i=r}t._wrapperState={initialValue:pe(i)}}function Me(t,r){var i=pe(r.value),c=pe(r.defaultValue);i!=null&&(i=""+i,i!==t.value&&(t.value=i),r.defaultValue==null&&t.defaultValue!==i&&(t.defaultValue=i)),c!=null&&(t.defaultValue=""+c)}function me(t){var r=t.textContent;r===t._wrapperState.initialValue&&r!==""&&r!==null&&(t.value=r)}function Ae(t){switch(t){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 Oe(t,r){return t==null||t==="http://www.w3.org/1999/xhtml"?Ae(r):t==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var G,J=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,i,c,d){MSApp.execUnsafeLocalFunction(function(){return t(r,i,c,d)})}:t})(function(t,r){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=r;else{for(G=G||document.createElement("div"),G.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=G.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;r.firstChild;)t.appendChild(r.firstChild)}});function ye(t,r){if(r){var i=t.firstChild;if(i&&i===t.lastChild&&i.nodeType===3){i.nodeValue=r;return}}t.textContent=r}var Ue={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},We=["Webkit","ms","Moz","O"];Object.keys(Ue).forEach(function(t){We.forEach(function(r){r=r+t.charAt(0).toUpperCase()+t.substring(1),Ue[r]=Ue[t]})});function nt(t,r,i){return r==null||typeof r=="boolean"||r===""?"":i||typeof r!="number"||r===0||Ue.hasOwnProperty(t)&&Ue[t]?(""+r).trim():r+"px"}function Ht(t,r){t=t.style;for(var i in r)if(r.hasOwnProperty(i)){var c=i.indexOf("--")===0,d=nt(i,r[i],c);i==="float"&&(i="cssFloat"),c?t.setProperty(i,d):t[i]=d}}var Ot=q({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 Ze(t,r){if(r){if(Ot[t]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(a(137,t));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(a(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(a(61))}if(r.style!=null&&typeof r.style!="object")throw Error(a(62))}}function W(t,r){if(t.indexOf("-")===-1)return typeof r.is=="string";switch(t){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 xe=null;function Te(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var rt=null,gt=null,Ke=null;function Nt(t){if(t=Ls(t)){if(typeof rt!="function")throw Error(a(280));var r=t.stateNode;r&&(r=Ba(r),rt(t.stateNode,t.type,r))}}function St(t){gt?Ke?Ke.push(t):Ke=[t]:gt=t}function Xt(){if(gt){var t=gt,r=Ke;if(Ke=gt=null,Nt(t),r)for(t=0;t<r.length;t++)Nt(r[t])}}function de(t,r){return t(r)}function Ce(){}var Ie=!1;function Ve(t,r,i){if(Ie)return t(r,i);Ie=!0;try{return de(t,r,i)}finally{Ie=!1,(gt!==null||Ke!==null)&&(Ce(),Xt())}}function Xe(t,r){var i=t.stateNode;if(i===null)return null;var c=Ba(i);if(c===null)return null;i=c[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(i&&typeof i!="function")throw Error(a(231,r,typeof i));return i}var Ct=!1;if(p)try{var Pt={};Object.defineProperty(Pt,"passive",{get:function(){Ct=!0}}),window.addEventListener("test",Pt,Pt),window.removeEventListener("test",Pt,Pt)}catch{Ct=!1}function Lr(t,r,i,c,d,m,w,C,R){var V=Array.prototype.slice.call(arguments,3);try{r.apply(i,V)}catch(ae){this.onError(ae)}}var cr=!1,zr=null,Wn=!1,ur=null,io={onError:function(t){cr=!0,zr=t}};function ya(t,r,i,c,d,m,w,C,R){cr=!1,zr=null,Lr.apply(io,arguments)}function va(t,r,i,c,d,m,w,C,R){if(ya.apply(this,arguments),cr){if(cr){var V=zr;cr=!1,zr=null}else throw Error(a(198));Wn||(Wn=!0,ur=V)}}function bn(t){var r=t,i=t;if(t.alternate)for(;r.return;)r=r.return;else{t=r;do r=t,(r.flags&4098)!==0&&(i=r.return),t=r.return;while(t)}return r.tag===3?i:null}function gs(t){if(t.tag===13){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function xa(t){if(bn(t)!==t)throw Error(a(188))}function Fr(t){var r=t.alternate;if(!r){if(r=bn(t),r===null)throw Error(a(188));return r!==t?null:t}for(var i=t,c=r;;){var d=i.return;if(d===null)break;var m=d.alternate;if(m===null){if(c=d.return,c!==null){i=c;continue}break}if(d.child===m.child){for(m=d.child;m;){if(m===i)return xa(d),t;if(m===c)return xa(d),r;m=m.sibling}throw Error(a(188))}if(i.return!==c.return)i=d,c=m;else{for(var w=!1,C=d.child;C;){if(C===i){w=!0,i=d,c=m;break}if(C===c){w=!0,c=d,i=m;break}C=C.sibling}if(!w){for(C=m.child;C;){if(C===i){w=!0,i=m,c=d;break}if(C===c){w=!0,c=m,i=d;break}C=C.sibling}if(!w)throw Error(a(189))}}if(i.alternate!==c)throw Error(a(190))}if(i.tag!==3)throw Error(a(188));return i.stateNode.current===i?t:r}function kn(t){return t=Fr(t),t!==null?Zc(t):null}function Zc(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var r=Zc(t);if(r!==null)return r;t=t.sibling}return null}var eu=s.unstable_scheduleCallback,tu=s.unstable_cancelCallback,Hp=s.unstable_shouldYield,Vp=s.unstable_requestPaint,yt=s.unstable_now,Gp=s.unstable_getCurrentPriorityLevel,oo=s.unstable_ImmediatePriority,nu=s.unstable_UserBlockingPriority,wa=s.unstable_NormalPriority,Kp=s.unstable_LowPriority,ru=s.unstable_IdlePriority,ja=null,Nn=null;function qp(t){if(Nn&&typeof Nn.onCommitFiberRoot=="function")try{Nn.onCommitFiberRoot(ja,t,void 0,(t.current.flags&128)===128)}catch{}}var hn=Math.clz32?Math.clz32:Qp,Yp=Math.log,Jp=Math.LN2;function Qp(t){return t>>>=0,t===0?32:31-(Yp(t)/Jp|0)|0}var Sa=64,ba=4194304;function ys(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64: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&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function ka(t,r){var i=t.pendingLanes;if(i===0)return 0;var c=0,d=t.suspendedLanes,m=t.pingedLanes,w=i&268435455;if(w!==0){var C=w&~d;C!==0?c=ys(C):(m&=w,m!==0&&(c=ys(m)))}else w=i&~d,w!==0?c=ys(w):m!==0&&(c=ys(m));if(c===0)return 0;if(r!==0&&r!==c&&(r&d)===0&&(d=c&-c,m=r&-r,d>=m||d===16&&(m&4194240)!==0))return r;if((c&4)!==0&&(c|=i&16),r=t.entangledLanes,r!==0)for(t=t.entanglements,r&=c;0<r;)i=31-hn(r),d=1<<i,c|=t[i],r&=~d;return c}function Xp(t,r){switch(t){case 1:case 2:case 4:return r+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 r+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 Zp(t,r){for(var i=t.suspendedLanes,c=t.pingedLanes,d=t.expirationTimes,m=t.pendingLanes;0<m;){var w=31-hn(m),C=1<<w,R=d[w];R===-1?((C&i)===0||(C&c)!==0)&&(d[w]=Xp(C,r)):R<=r&&(t.expiredLanes|=C),m&=~C}}function lo(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function su(){var t=Sa;return Sa<<=1,(Sa&4194240)===0&&(Sa=64),t}function co(t){for(var r=[],i=0;31>i;i++)r.push(t);return r}function vs(t,r,i){t.pendingLanes|=r,r!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,r=31-hn(r),t[r]=i}function eg(t,r){var i=t.pendingLanes&~r;t.pendingLanes=r,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=r,t.mutableReadLanes&=r,t.entangledLanes&=r,r=t.entanglements;var c=t.eventTimes;for(t=t.expirationTimes;0<i;){var d=31-hn(i),m=1<<d;r[d]=0,c[d]=-1,t[d]=-1,i&=~m}}function uo(t,r){var i=t.entangledLanes|=r;for(t=t.entanglements;i;){var c=31-hn(i),d=1<<c;d&r|t[c]&r&&(t[c]|=r),i&=~d}}var et=0;function au(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var iu,fo,ou,lu,cu,ho=!1,Na=[],Hn=null,Vn=null,Gn=null,xs=new Map,ws=new Map,Kn=[],tg="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 uu(t,r){switch(t){case"focusin":case"focusout":Hn=null;break;case"dragenter":case"dragleave":Vn=null;break;case"mouseover":case"mouseout":Gn=null;break;case"pointerover":case"pointerout":xs.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":ws.delete(r.pointerId)}}function js(t,r,i,c,d,m){return t===null||t.nativeEvent!==m?(t={blockedOn:r,domEventName:i,eventSystemFlags:c,nativeEvent:m,targetContainers:[d]},r!==null&&(r=Ls(r),r!==null&&fo(r)),t):(t.eventSystemFlags|=c,r=t.targetContainers,d!==null&&r.indexOf(d)===-1&&r.push(d),t)}function ng(t,r,i,c,d){switch(r){case"focusin":return Hn=js(Hn,t,r,i,c,d),!0;case"dragenter":return Vn=js(Vn,t,r,i,c,d),!0;case"mouseover":return Gn=js(Gn,t,r,i,c,d),!0;case"pointerover":var m=d.pointerId;return xs.set(m,js(xs.get(m)||null,t,r,i,c,d)),!0;case"gotpointercapture":return m=d.pointerId,ws.set(m,js(ws.get(m)||null,t,r,i,c,d)),!0}return!1}function du(t){var r=dr(t.target);if(r!==null){var i=bn(r);if(i!==null){if(r=i.tag,r===13){if(r=gs(i),r!==null){t.blockedOn=r,cu(t.priority,function(){ou(i)});return}}else if(r===3&&i.stateNode.current.memoizedState.isDehydrated){t.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Ca(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var i=po(t.domEventName,t.eventSystemFlags,r[0],t.nativeEvent);if(i===null){i=t.nativeEvent;var c=new i.constructor(i.type,i);xe=c,i.target.dispatchEvent(c),xe=null}else return r=Ls(i),r!==null&&fo(r),t.blockedOn=i,!1;r.shift()}return!0}function fu(t,r,i){Ca(t)&&i.delete(r)}function rg(){ho=!1,Hn!==null&&Ca(Hn)&&(Hn=null),Vn!==null&&Ca(Vn)&&(Vn=null),Gn!==null&&Ca(Gn)&&(Gn=null),xs.forEach(fu),ws.forEach(fu)}function Ss(t,r){t.blockedOn===r&&(t.blockedOn=null,ho||(ho=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,rg)))}function bs(t){function r(d){return Ss(d,t)}if(0<Na.length){Ss(Na[0],t);for(var i=1;i<Na.length;i++){var c=Na[i];c.blockedOn===t&&(c.blockedOn=null)}}for(Hn!==null&&Ss(Hn,t),Vn!==null&&Ss(Vn,t),Gn!==null&&Ss(Gn,t),xs.forEach(r),ws.forEach(r),i=0;i<Kn.length;i++)c=Kn[i],c.blockedOn===t&&(c.blockedOn=null);for(;0<Kn.length&&(i=Kn[0],i.blockedOn===null);)du(i),i.blockedOn===null&&Kn.shift()}var Mr=I.ReactCurrentBatchConfig,Ea=!0;function sg(t,r,i,c){var d=et,m=Mr.transition;Mr.transition=null;try{et=1,mo(t,r,i,c)}finally{et=d,Mr.transition=m}}function ag(t,r,i,c){var d=et,m=Mr.transition;Mr.transition=null;try{et=4,mo(t,r,i,c)}finally{et=d,Mr.transition=m}}function mo(t,r,i,c){if(Ea){var d=po(t,r,i,c);if(d===null)Po(t,r,c,Ta,i),uu(t,c);else if(ng(d,t,r,i,c))c.stopPropagation();else if(uu(t,c),r&4&&-1<tg.indexOf(t)){for(;d!==null;){var m=Ls(d);if(m!==null&&iu(m),m=po(t,r,i,c),m===null&&Po(t,r,c,Ta,i),m===d)break;d=m}d!==null&&c.stopPropagation()}else Po(t,r,c,null,i)}}var Ta=null;function po(t,r,i,c){if(Ta=null,t=Te(c),t=dr(t),t!==null)if(r=bn(t),r===null)t=null;else if(i=r.tag,i===13){if(t=gs(r),t!==null)return t;t=null}else if(i===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;t=null}else r!==t&&(t=null);return Ta=t,null}function hu(t){switch(t){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(Gp()){case oo:return 1;case nu:return 4;case wa:case Kp:return 16;case ru:return 536870912;default:return 16}default:return 16}}var qn=null,go=null,Aa=null;function mu(){if(Aa)return Aa;var t,r=go,i=r.length,c,d="value"in qn?qn.value:qn.textContent,m=d.length;for(t=0;t<i&&r[t]===d[t];t++);var w=i-t;for(c=1;c<=w&&r[i-c]===d[m-c];c++);return Aa=d.slice(t,1<c?1-c:void 0)}function Ia(t){var r=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&r===13&&(t=13)):t=r,t===10&&(t=13),32<=t||t===13?t:0}function Ra(){return!0}function pu(){return!1}function Zt(t){function r(i,c,d,m,w){this._reactName=i,this._targetInst=d,this.type=c,this.nativeEvent=m,this.target=w,this.currentTarget=null;for(var C in t)t.hasOwnProperty(C)&&(i=t[C],this[C]=i?i(m):m[C]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?Ra:pu,this.isPropagationStopped=pu,this}return q(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=Ra)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=Ra)},persist:function(){},isPersistent:Ra}),r}var Or={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},yo=Zt(Or),ks=q({},Or,{view:0,detail:0}),ig=Zt(ks),vo,xo,Ns,Pa=q({},ks,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:jo,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Ns&&(Ns&&t.type==="mousemove"?(vo=t.screenX-Ns.screenX,xo=t.screenY-Ns.screenY):xo=vo=0,Ns=t),vo)},movementY:function(t){return"movementY"in t?t.movementY:xo}}),gu=Zt(Pa),og=q({},Pa,{dataTransfer:0}),lg=Zt(og),cg=q({},ks,{relatedTarget:0}),wo=Zt(cg),ug=q({},Or,{animationName:0,elapsedTime:0,pseudoElement:0}),dg=Zt(ug),fg=q({},Or,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),hg=Zt(fg),mg=q({},Or,{data:0}),yu=Zt(mg),pg={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},gg={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"},yg={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vg(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=yg[t])?!!r[t]:!1}function jo(){return vg}var xg=q({},ks,{key:function(t){if(t.key){var r=pg[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=Ia(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?gg[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:jo,charCode:function(t){return t.type==="keypress"?Ia(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Ia(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),wg=Zt(xg),jg=q({},Pa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),vu=Zt(jg),Sg=q({},ks,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:jo}),bg=Zt(Sg),kg=q({},Or,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ng=Zt(kg),Cg=q({},Pa,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Eg=Zt(Cg),Tg=[9,13,27,32],So=p&&"CompositionEvent"in window,Cs=null;p&&"documentMode"in document&&(Cs=document.documentMode);var Ag=p&&"TextEvent"in window&&!Cs,xu=p&&(!So||Cs&&8<Cs&&11>=Cs),wu=" ",ju=!1;function Su(t,r){switch(t){case"keyup":return Tg.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function bu(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Br=!1;function Ig(t,r){switch(t){case"compositionend":return bu(r);case"keypress":return r.which!==32?null:(ju=!0,wu);case"textInput":return t=r.data,t===wu&&ju?null:t;default:return null}}function Rg(t,r){if(Br)return t==="compositionend"||!So&&Su(t,r)?(t=mu(),Aa=go=qn=null,Br=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return xu&&r.locale!=="ko"?null:r.data;default:return null}}var Pg={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 ku(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!Pg[t.type]:r==="textarea"}function Nu(t,r,i,c){St(c),r=Fa(r,"onChange"),0<r.length&&(i=new yo("onChange","change",null,i,c),t.push({event:i,listeners:r}))}var Es=null,Ts=null;function $g(t){Wu(t,0)}function $a(t){var r=Vr(t);if(Se(r))return t}function _g(t,r){if(t==="change")return r}var Cu=!1;if(p){var bo;if(p){var ko="oninput"in document;if(!ko){var Eu=document.createElement("div");Eu.setAttribute("oninput","return;"),ko=typeof Eu.oninput=="function"}bo=ko}else bo=!1;Cu=bo&&(!document.documentMode||9<document.documentMode)}function Tu(){Es&&(Es.detachEvent("onpropertychange",Au),Ts=Es=null)}function Au(t){if(t.propertyName==="value"&&$a(Ts)){var r=[];Nu(r,Ts,t,Te(t)),Ve($g,r)}}function Lg(t,r,i){t==="focusin"?(Tu(),Es=r,Ts=i,Es.attachEvent("onpropertychange",Au)):t==="focusout"&&Tu()}function zg(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return $a(Ts)}function Fg(t,r){if(t==="click")return $a(r)}function Mg(t,r){if(t==="input"||t==="change")return $a(r)}function Og(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var mn=typeof Object.is=="function"?Object.is:Og;function As(t,r){if(mn(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;var i=Object.keys(t),c=Object.keys(r);if(i.length!==c.length)return!1;for(c=0;c<i.length;c++){var d=i[c];if(!g.call(r,d)||!mn(t[d],r[d]))return!1}return!0}function Iu(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Ru(t,r){var i=Iu(t);t=0;for(var c;i;){if(i.nodeType===3){if(c=t+i.textContent.length,t<=r&&c>=r)return{node:i,offset:r-t};t=c}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Iu(i)}}function Pu(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?Pu(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function $u(){for(var t=window,r=Y();r instanceof t.HTMLIFrameElement;){try{var i=typeof r.contentWindow.location.href=="string"}catch{i=!1}if(i)t=r.contentWindow;else break;r=Y(t.document)}return r}function No(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r&&(r==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||r==="textarea"||t.contentEditable==="true")}function Bg(t){var r=$u(),i=t.focusedElem,c=t.selectionRange;if(r!==i&&i&&i.ownerDocument&&Pu(i.ownerDocument.documentElement,i)){if(c!==null&&No(i)){if(r=c.start,t=c.end,t===void 0&&(t=r),"selectionStart"in i)i.selectionStart=r,i.selectionEnd=Math.min(t,i.value.length);else if(t=(r=i.ownerDocument||document)&&r.defaultView||window,t.getSelection){t=t.getSelection();var d=i.textContent.length,m=Math.min(c.start,d);c=c.end===void 0?m:Math.min(c.end,d),!t.extend&&m>c&&(d=c,c=m,m=d),d=Ru(i,m);var w=Ru(i,c);d&&w&&(t.rangeCount!==1||t.anchorNode!==d.node||t.anchorOffset!==d.offset||t.focusNode!==w.node||t.focusOffset!==w.offset)&&(r=r.createRange(),r.setStart(d.node,d.offset),t.removeAllRanges(),m>c?(t.addRange(r),t.extend(w.node,w.offset)):(r.setEnd(w.node,w.offset),t.addRange(r)))}}for(r=[],t=i;t=t.parentNode;)t.nodeType===1&&r.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<r.length;i++)t=r[i],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var Dg=p&&"documentMode"in document&&11>=document.documentMode,Dr=null,Co=null,Is=null,Eo=!1;function _u(t,r,i){var c=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Eo||Dr==null||Dr!==Y(c)||(c=Dr,"selectionStart"in c&&No(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Is&&As(Is,c)||(Is=c,c=Fa(Co,"onSelect"),0<c.length&&(r=new yo("onSelect","select",null,r,i),t.push({event:r,listeners:c}),r.target=Dr)))}function _a(t,r){var i={};return i[t.toLowerCase()]=r.toLowerCase(),i["Webkit"+t]="webkit"+r,i["Moz"+t]="moz"+r,i}var Ur={animationend:_a("Animation","AnimationEnd"),animationiteration:_a("Animation","AnimationIteration"),animationstart:_a("Animation","AnimationStart"),transitionend:_a("Transition","TransitionEnd")},To={},Lu={};p&&(Lu=document.createElement("div").style,"AnimationEvent"in window||(delete Ur.animationend.animation,delete Ur.animationiteration.animation,delete Ur.animationstart.animation),"TransitionEvent"in window||delete Ur.transitionend.transition);function La(t){if(To[t])return To[t];if(!Ur[t])return t;var r=Ur[t],i;for(i in r)if(r.hasOwnProperty(i)&&i in Lu)return To[t]=r[i];return t}var zu=La("animationend"),Fu=La("animationiteration"),Mu=La("animationstart"),Ou=La("transitionend"),Bu=new Map,Du="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 Yn(t,r){Bu.set(t,r),u(r,[t])}for(var Ao=0;Ao<Du.length;Ao++){var Io=Du[Ao],Ug=Io.toLowerCase(),Wg=Io[0].toUpperCase()+Io.slice(1);Yn(Ug,"on"+Wg)}Yn(zu,"onAnimationEnd"),Yn(Fu,"onAnimationIteration"),Yn(Mu,"onAnimationStart"),Yn("dblclick","onDoubleClick"),Yn("focusin","onFocus"),Yn("focusout","onBlur"),Yn(Ou,"onTransitionEnd"),f("onMouseEnter",["mouseout","mouseover"]),f("onMouseLeave",["mouseout","mouseover"]),f("onPointerEnter",["pointerout","pointerover"]),f("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Rs="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(" "),Hg=new Set("cancel close invalid load scroll toggle".split(" ").concat(Rs));function Uu(t,r,i){var c=t.type||"unknown-event";t.currentTarget=i,va(c,r,void 0,t),t.currentTarget=null}function Wu(t,r){r=(r&4)!==0;for(var i=0;i<t.length;i++){var c=t[i],d=c.event;c=c.listeners;e:{var m=void 0;if(r)for(var w=c.length-1;0<=w;w--){var C=c[w],R=C.instance,V=C.currentTarget;if(C=C.listener,R!==m&&d.isPropagationStopped())break e;Uu(d,C,V),m=R}else for(w=0;w<c.length;w++){if(C=c[w],R=C.instance,V=C.currentTarget,C=C.listener,R!==m&&d.isPropagationStopped())break e;Uu(d,C,V),m=R}}}if(Wn)throw t=ur,Wn=!1,ur=null,t}function ot(t,r){var i=r[Mo];i===void 0&&(i=r[Mo]=new Set);var c=t+"__bubble";i.has(c)||(Hu(r,t,2,!1),i.add(c))}function Ro(t,r,i){var c=0;r&&(c|=4),Hu(i,t,c,r)}var za="_reactListening"+Math.random().toString(36).slice(2);function Ps(t){if(!t[za]){t[za]=!0,o.forEach(function(i){i!=="selectionchange"&&(Hg.has(i)||Ro(i,!1,t),Ro(i,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[za]||(r[za]=!0,Ro("selectionchange",!1,r))}}function Hu(t,r,i,c){switch(hu(r)){case 1:var d=sg;break;case 4:d=ag;break;default:d=mo}i=d.bind(null,r,i,t),d=void 0,!Ct||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(d=!0),c?d!==void 0?t.addEventListener(r,i,{capture:!0,passive:d}):t.addEventListener(r,i,!0):d!==void 0?t.addEventListener(r,i,{passive:d}):t.addEventListener(r,i,!1)}function Po(t,r,i,c,d){var m=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var w=c.tag;if(w===3||w===4){var C=c.stateNode.containerInfo;if(C===d||C.nodeType===8&&C.parentNode===d)break;if(w===4)for(w=c.return;w!==null;){var R=w.tag;if((R===3||R===4)&&(R=w.stateNode.containerInfo,R===d||R.nodeType===8&&R.parentNode===d))return;w=w.return}for(;C!==null;){if(w=dr(C),w===null)return;if(R=w.tag,R===5||R===6){c=m=w;continue e}C=C.parentNode}}c=c.return}Ve(function(){var V=m,ae=Te(i),ce=[];e:{var se=Bu.get(t);if(se!==void 0){var we=yo,be=t;switch(t){case"keypress":if(Ia(i)===0)break e;case"keydown":case"keyup":we=wg;break;case"focusin":be="focus",we=wo;break;case"focusout":be="blur",we=wo;break;case"beforeblur":case"afterblur":we=wo;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":we=gu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":we=lg;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":we=bg;break;case zu:case Fu:case Mu:we=dg;break;case Ou:we=Ng;break;case"scroll":we=ig;break;case"wheel":we=Eg;break;case"copy":case"cut":case"paste":we=hg;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":we=vu}var Ne=(r&4)!==0,vt=!Ne&&t==="scroll",M=Ne?se!==null?se+"Capture":null:se;Ne=[];for(var _=V,D;_!==null;){D=_;var he=D.stateNode;if(D.tag===5&&he!==null&&(D=he,M!==null&&(he=Xe(_,M),he!=null&&Ne.push($s(_,he,D)))),vt)break;_=_.return}0<Ne.length&&(se=new we(se,be,null,i,ae),ce.push({event:se,listeners:Ne}))}}if((r&7)===0){e:{if(se=t==="mouseover"||t==="pointerover",we=t==="mouseout"||t==="pointerout",se&&i!==xe&&(be=i.relatedTarget||i.fromElement)&&(dr(be)||be[Rn]))break e;if((we||se)&&(se=ae.window===ae?ae:(se=ae.ownerDocument)?se.defaultView||se.parentWindow:window,we?(be=i.relatedTarget||i.toElement,we=V,be=be?dr(be):null,be!==null&&(vt=bn(be),be!==vt||be.tag!==5&&be.tag!==6)&&(be=null)):(we=null,be=V),we!==be)){if(Ne=gu,he="onMouseLeave",M="onMouseEnter",_="mouse",(t==="pointerout"||t==="pointerover")&&(Ne=vu,he="onPointerLeave",M="onPointerEnter",_="pointer"),vt=we==null?se:Vr(we),D=be==null?se:Vr(be),se=new Ne(he,_+"leave",we,i,ae),se.target=vt,se.relatedTarget=D,he=null,dr(ae)===V&&(Ne=new Ne(M,_+"enter",be,i,ae),Ne.target=D,Ne.relatedTarget=vt,he=Ne),vt=he,we&&be)t:{for(Ne=we,M=be,_=0,D=Ne;D;D=Wr(D))_++;for(D=0,he=M;he;he=Wr(he))D++;for(;0<_-D;)Ne=Wr(Ne),_--;for(;0<D-_;)M=Wr(M),D--;for(;_--;){if(Ne===M||M!==null&&Ne===M.alternate)break t;Ne=Wr(Ne),M=Wr(M)}Ne=null}else Ne=null;we!==null&&Vu(ce,se,we,Ne,!1),be!==null&&vt!==null&&Vu(ce,vt,be,Ne,!0)}}e:{if(se=V?Vr(V):window,we=se.nodeName&&se.nodeName.toLowerCase(),we==="select"||we==="input"&&se.type==="file")var Ee=_g;else if(ku(se))if(Cu)Ee=Mg;else{Ee=zg;var Re=Lg}else(we=se.nodeName)&&we.toLowerCase()==="input"&&(se.type==="checkbox"||se.type==="radio")&&(Ee=Fg);if(Ee&&(Ee=Ee(t,V))){Nu(ce,Ee,i,ae);break e}Re&&Re(t,se,V),t==="focusout"&&(Re=se._wrapperState)&&Re.controlled&&se.type==="number"&&tt(se,"number",se.value)}switch(Re=V?Vr(V):window,t){case"focusin":(ku(Re)||Re.contentEditable==="true")&&(Dr=Re,Co=V,Is=null);break;case"focusout":Is=Co=Dr=null;break;case"mousedown":Eo=!0;break;case"contextmenu":case"mouseup":case"dragend":Eo=!1,_u(ce,i,ae);break;case"selectionchange":if(Dg)break;case"keydown":case"keyup":_u(ce,i,ae)}var Pe;if(So)e:{switch(t){case"compositionstart":var Le="onCompositionStart";break e;case"compositionend":Le="onCompositionEnd";break e;case"compositionupdate":Le="onCompositionUpdate";break e}Le=void 0}else Br?Su(t,i)&&(Le="onCompositionEnd"):t==="keydown"&&i.keyCode===229&&(Le="onCompositionStart");Le&&(xu&&i.locale!=="ko"&&(Br||Le!=="onCompositionStart"?Le==="onCompositionEnd"&&Br&&(Pe=mu()):(qn=ae,go="value"in qn?qn.value:qn.textContent,Br=!0)),Re=Fa(V,Le),0<Re.length&&(Le=new yu(Le,t,null,i,ae),ce.push({event:Le,listeners:Re}),Pe?Le.data=Pe:(Pe=bu(i),Pe!==null&&(Le.data=Pe)))),(Pe=Ag?Ig(t,i):Rg(t,i))&&(V=Fa(V,"onBeforeInput"),0<V.length&&(ae=new yu("onBeforeInput","beforeinput",null,i,ae),ce.push({event:ae,listeners:V}),ae.data=Pe))}Wu(ce,r)})}function $s(t,r,i){return{instance:t,listener:r,currentTarget:i}}function Fa(t,r){for(var i=r+"Capture",c=[];t!==null;){var d=t,m=d.stateNode;d.tag===5&&m!==null&&(d=m,m=Xe(t,i),m!=null&&c.unshift($s(t,m,d)),m=Xe(t,r),m!=null&&c.push($s(t,m,d))),t=t.return}return c}function Wr(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function Vu(t,r,i,c,d){for(var m=r._reactName,w=[];i!==null&&i!==c;){var C=i,R=C.alternate,V=C.stateNode;if(R!==null&&R===c)break;C.tag===5&&V!==null&&(C=V,d?(R=Xe(i,m),R!=null&&w.unshift($s(i,R,C))):d||(R=Xe(i,m),R!=null&&w.push($s(i,R,C)))),i=i.return}w.length!==0&&t.push({event:r,listeners:w})}var Vg=/\r\n?/g,Gg=/\u0000|\uFFFD/g;function Gu(t){return(typeof t=="string"?t:""+t).replace(Vg,`
|
|
38
|
+
`).replace(Gg,"")}function Ma(t,r,i){if(r=Gu(r),Gu(t)!==r&&i)throw Error(a(425))}function Oa(){}var $o=null,_o=null;function Lo(t,r){return t==="textarea"||t==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var zo=typeof setTimeout=="function"?setTimeout:void 0,Kg=typeof clearTimeout=="function"?clearTimeout:void 0,Ku=typeof Promise=="function"?Promise:void 0,qg=typeof queueMicrotask=="function"?queueMicrotask:typeof Ku<"u"?function(t){return Ku.resolve(null).then(t).catch(Yg)}:zo;function Yg(t){setTimeout(function(){throw t})}function Fo(t,r){var i=r,c=0;do{var d=i.nextSibling;if(t.removeChild(i),d&&d.nodeType===8)if(i=d.data,i==="/$"){if(c===0){t.removeChild(d),bs(r);return}c--}else i!=="$"&&i!=="$?"&&i!=="$!"||c++;i=d}while(i);bs(r)}function Jn(t){for(;t!=null;t=t.nextSibling){var r=t.nodeType;if(r===1||r===3)break;if(r===8){if(r=t.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return t}function qu(t){t=t.previousSibling;for(var r=0;t;){if(t.nodeType===8){var i=t.data;if(i==="$"||i==="$!"||i==="$?"){if(r===0)return t;r--}else i==="/$"&&r++}t=t.previousSibling}return null}var Hr=Math.random().toString(36).slice(2),Cn="__reactFiber$"+Hr,_s="__reactProps$"+Hr,Rn="__reactContainer$"+Hr,Mo="__reactEvents$"+Hr,Jg="__reactListeners$"+Hr,Qg="__reactHandles$"+Hr;function dr(t){var r=t[Cn];if(r)return r;for(var i=t.parentNode;i;){if(r=i[Rn]||i[Cn]){if(i=r.alternate,r.child!==null||i!==null&&i.child!==null)for(t=qu(t);t!==null;){if(i=t[Cn])return i;t=qu(t)}return r}t=i,i=t.parentNode}return null}function Ls(t){return t=t[Cn]||t[Rn],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Vr(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(a(33))}function Ba(t){return t[_s]||null}var Oo=[],Gr=-1;function Qn(t){return{current:t}}function lt(t){0>Gr||(t.current=Oo[Gr],Oo[Gr]=null,Gr--)}function st(t,r){Gr++,Oo[Gr]=t.current,t.current=r}var Xn={},$t=Qn(Xn),Vt=Qn(!1),fr=Xn;function Kr(t,r){var i=t.type.contextTypes;if(!i)return Xn;var c=t.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===r)return c.__reactInternalMemoizedMaskedChildContext;var d={},m;for(m in i)d[m]=r[m];return c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=r,t.__reactInternalMemoizedMaskedChildContext=d),d}function Gt(t){return t=t.childContextTypes,t!=null}function Da(){lt(Vt),lt($t)}function Yu(t,r,i){if($t.current!==Xn)throw Error(a(168));st($t,r),st(Vt,i)}function Ju(t,r,i){var c=t.stateNode;if(r=r.childContextTypes,typeof c.getChildContext!="function")return i;c=c.getChildContext();for(var d in c)if(!(d in r))throw Error(a(108,ue(t)||"Unknown",d));return q({},i,c)}function Ua(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Xn,fr=$t.current,st($t,t),st(Vt,Vt.current),!0}function Qu(t,r,i){var c=t.stateNode;if(!c)throw Error(a(169));i?(t=Ju(t,r,fr),c.__reactInternalMemoizedMergedChildContext=t,lt(Vt),lt($t),st($t,t)):lt(Vt),st(Vt,i)}var Pn=null,Wa=!1,Bo=!1;function Xu(t){Pn===null?Pn=[t]:Pn.push(t)}function Xg(t){Wa=!0,Xu(t)}function Zn(){if(!Bo&&Pn!==null){Bo=!0;var t=0,r=et;try{var i=Pn;for(et=1;t<i.length;t++){var c=i[t];do c=c(!0);while(c!==null)}Pn=null,Wa=!1}catch(d){throw Pn!==null&&(Pn=Pn.slice(t+1)),eu(oo,Zn),d}finally{et=r,Bo=!1}}return null}var qr=[],Yr=0,Ha=null,Va=0,sn=[],an=0,hr=null,$n=1,_n="";function mr(t,r){qr[Yr++]=Va,qr[Yr++]=Ha,Ha=t,Va=r}function Zu(t,r,i){sn[an++]=$n,sn[an++]=_n,sn[an++]=hr,hr=t;var c=$n;t=_n;var d=32-hn(c)-1;c&=~(1<<d),i+=1;var m=32-hn(r)+d;if(30<m){var w=d-d%5;m=(c&(1<<w)-1).toString(32),c>>=w,d-=w,$n=1<<32-hn(r)+d|i<<d|c,_n=m+t}else $n=1<<m|i<<d|c,_n=t}function Do(t){t.return!==null&&(mr(t,1),Zu(t,1,0))}function Uo(t){for(;t===Ha;)Ha=qr[--Yr],qr[Yr]=null,Va=qr[--Yr],qr[Yr]=null;for(;t===hr;)hr=sn[--an],sn[an]=null,_n=sn[--an],sn[an]=null,$n=sn[--an],sn[an]=null}var en=null,tn=null,ct=!1,pn=null;function ed(t,r){var i=un(5,null,null,0);i.elementType="DELETED",i.stateNode=r,i.return=t,r=t.deletions,r===null?(t.deletions=[i],t.flags|=16):r.push(i)}function td(t,r){switch(t.tag){case 5:var i=t.type;return r=r.nodeType!==1||i.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(t.stateNode=r,en=t,tn=Jn(r.firstChild),!0):!1;case 6:return r=t.pendingProps===""||r.nodeType!==3?null:r,r!==null?(t.stateNode=r,en=t,tn=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(i=hr!==null?{id:$n,overflow:_n}:null,t.memoizedState={dehydrated:r,treeContext:i,retryLane:1073741824},i=un(18,null,null,0),i.stateNode=r,i.return=t,t.child=i,en=t,tn=null,!0):!1;default:return!1}}function Wo(t){return(t.mode&1)!==0&&(t.flags&128)===0}function Ho(t){if(ct){var r=tn;if(r){var i=r;if(!td(t,r)){if(Wo(t))throw Error(a(418));r=Jn(i.nextSibling);var c=en;r&&td(t,r)?ed(c,i):(t.flags=t.flags&-4097|2,ct=!1,en=t)}}else{if(Wo(t))throw Error(a(418));t.flags=t.flags&-4097|2,ct=!1,en=t}}}function nd(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;en=t}function Ga(t){if(t!==en)return!1;if(!ct)return nd(t),ct=!0,!1;var r;if((r=t.tag!==3)&&!(r=t.tag!==5)&&(r=t.type,r=r!=="head"&&r!=="body"&&!Lo(t.type,t.memoizedProps)),r&&(r=tn)){if(Wo(t))throw rd(),Error(a(418));for(;r;)ed(t,r),r=Jn(r.nextSibling)}if(nd(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(a(317));e:{for(t=t.nextSibling,r=0;t;){if(t.nodeType===8){var i=t.data;if(i==="/$"){if(r===0){tn=Jn(t.nextSibling);break e}r--}else i!=="$"&&i!=="$!"&&i!=="$?"||r++}t=t.nextSibling}tn=null}}else tn=en?Jn(t.stateNode.nextSibling):null;return!0}function rd(){for(var t=tn;t;)t=Jn(t.nextSibling)}function Jr(){tn=en=null,ct=!1}function Vo(t){pn===null?pn=[t]:pn.push(t)}var Zg=I.ReactCurrentBatchConfig;function zs(t,r,i){if(t=i.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(i._owner){if(i=i._owner,i){if(i.tag!==1)throw Error(a(309));var c=i.stateNode}if(!c)throw Error(a(147,t));var d=c,m=""+t;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===m?r.ref:(r=function(w){var C=d.refs;w===null?delete C[m]:C[m]=w},r._stringRef=m,r)}if(typeof t!="string")throw Error(a(284));if(!i._owner)throw Error(a(290,t))}return t}function Ka(t,r){throw t=Object.prototype.toString.call(r),Error(a(31,t==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":t))}function sd(t){var r=t._init;return r(t._payload)}function ad(t){function r(M,_){if(t){var D=M.deletions;D===null?(M.deletions=[_],M.flags|=16):D.push(_)}}function i(M,_){if(!t)return null;for(;_!==null;)r(M,_),_=_.sibling;return null}function c(M,_){for(M=new Map;_!==null;)_.key!==null?M.set(_.key,_):M.set(_.index,_),_=_.sibling;return M}function d(M,_){return M=or(M,_),M.index=0,M.sibling=null,M}function m(M,_,D){return M.index=D,t?(D=M.alternate,D!==null?(D=D.index,D<_?(M.flags|=2,_):D):(M.flags|=2,_)):(M.flags|=1048576,_)}function w(M){return t&&M.alternate===null&&(M.flags|=2),M}function C(M,_,D,he){return _===null||_.tag!==6?(_=zl(D,M.mode,he),_.return=M,_):(_=d(_,D),_.return=M,_)}function R(M,_,D,he){var Ee=D.type;return Ee===K?ae(M,_,D.props.children,he,D.key):_!==null&&(_.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===ge&&sd(Ee)===_.type)?(he=d(_,D.props),he.ref=zs(M,_,D),he.return=M,he):(he=yi(D.type,D.key,D.props,null,M.mode,he),he.ref=zs(M,_,D),he.return=M,he)}function V(M,_,D,he){return _===null||_.tag!==4||_.stateNode.containerInfo!==D.containerInfo||_.stateNode.implementation!==D.implementation?(_=Fl(D,M.mode,he),_.return=M,_):(_=d(_,D.children||[]),_.return=M,_)}function ae(M,_,D,he,Ee){return _===null||_.tag!==7?(_=Sr(D,M.mode,he,Ee),_.return=M,_):(_=d(_,D),_.return=M,_)}function ce(M,_,D){if(typeof _=="string"&&_!==""||typeof _=="number")return _=zl(""+_,M.mode,D),_.return=M,_;if(typeof _=="object"&&_!==null){switch(_.$$typeof){case B:return D=yi(_.type,_.key,_.props,null,M.mode,D),D.ref=zs(M,null,_),D.return=M,D;case O:return _=Fl(_,M.mode,D),_.return=M,_;case ge:var he=_._init;return ce(M,he(_._payload),D)}if(Qe(_)||Q(_))return _=Sr(_,M.mode,D,null),_.return=M,_;Ka(M,_)}return null}function se(M,_,D,he){var Ee=_!==null?_.key:null;if(typeof D=="string"&&D!==""||typeof D=="number")return Ee!==null?null:C(M,_,""+D,he);if(typeof D=="object"&&D!==null){switch(D.$$typeof){case B:return D.key===Ee?R(M,_,D,he):null;case O:return D.key===Ee?V(M,_,D,he):null;case ge:return Ee=D._init,se(M,_,Ee(D._payload),he)}if(Qe(D)||Q(D))return Ee!==null?null:ae(M,_,D,he,null);Ka(M,D)}return null}function we(M,_,D,he,Ee){if(typeof he=="string"&&he!==""||typeof he=="number")return M=M.get(D)||null,C(_,M,""+he,Ee);if(typeof he=="object"&&he!==null){switch(he.$$typeof){case B:return M=M.get(he.key===null?D:he.key)||null,R(_,M,he,Ee);case O:return M=M.get(he.key===null?D:he.key)||null,V(_,M,he,Ee);case ge:var Re=he._init;return we(M,_,D,Re(he._payload),Ee)}if(Qe(he)||Q(he))return M=M.get(D)||null,ae(_,M,he,Ee,null);Ka(_,he)}return null}function be(M,_,D,he){for(var Ee=null,Re=null,Pe=_,Le=_=0,At=null;Pe!==null&&Le<D.length;Le++){Pe.index>Le?(At=Pe,Pe=null):At=Pe.sibling;var Je=se(M,Pe,D[Le],he);if(Je===null){Pe===null&&(Pe=At);break}t&&Pe&&Je.alternate===null&&r(M,Pe),_=m(Je,_,Le),Re===null?Ee=Je:Re.sibling=Je,Re=Je,Pe=At}if(Le===D.length)return i(M,Pe),ct&&mr(M,Le),Ee;if(Pe===null){for(;Le<D.length;Le++)Pe=ce(M,D[Le],he),Pe!==null&&(_=m(Pe,_,Le),Re===null?Ee=Pe:Re.sibling=Pe,Re=Pe);return ct&&mr(M,Le),Ee}for(Pe=c(M,Pe);Le<D.length;Le++)At=we(Pe,M,Le,D[Le],he),At!==null&&(t&&At.alternate!==null&&Pe.delete(At.key===null?Le:At.key),_=m(At,_,Le),Re===null?Ee=At:Re.sibling=At,Re=At);return t&&Pe.forEach(function(lr){return r(M,lr)}),ct&&mr(M,Le),Ee}function Ne(M,_,D,he){var Ee=Q(D);if(typeof Ee!="function")throw Error(a(150));if(D=Ee.call(D),D==null)throw Error(a(151));for(var Re=Ee=null,Pe=_,Le=_=0,At=null,Je=D.next();Pe!==null&&!Je.done;Le++,Je=D.next()){Pe.index>Le?(At=Pe,Pe=null):At=Pe.sibling;var lr=se(M,Pe,Je.value,he);if(lr===null){Pe===null&&(Pe=At);break}t&&Pe&&lr.alternate===null&&r(M,Pe),_=m(lr,_,Le),Re===null?Ee=lr:Re.sibling=lr,Re=lr,Pe=At}if(Je.done)return i(M,Pe),ct&&mr(M,Le),Ee;if(Pe===null){for(;!Je.done;Le++,Je=D.next())Je=ce(M,Je.value,he),Je!==null&&(_=m(Je,_,Le),Re===null?Ee=Je:Re.sibling=Je,Re=Je);return ct&&mr(M,Le),Ee}for(Pe=c(M,Pe);!Je.done;Le++,Je=D.next())Je=we(Pe,M,Le,Je.value,he),Je!==null&&(t&&Je.alternate!==null&&Pe.delete(Je.key===null?Le:Je.key),_=m(Je,_,Le),Re===null?Ee=Je:Re.sibling=Je,Re=Je);return t&&Pe.forEach(function(Py){return r(M,Py)}),ct&&mr(M,Le),Ee}function vt(M,_,D,he){if(typeof D=="object"&&D!==null&&D.type===K&&D.key===null&&(D=D.props.children),typeof D=="object"&&D!==null){switch(D.$$typeof){case B:e:{for(var Ee=D.key,Re=_;Re!==null;){if(Re.key===Ee){if(Ee=D.type,Ee===K){if(Re.tag===7){i(M,Re.sibling),_=d(Re,D.props.children),_.return=M,M=_;break e}}else if(Re.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===ge&&sd(Ee)===Re.type){i(M,Re.sibling),_=d(Re,D.props),_.ref=zs(M,Re,D),_.return=M,M=_;break e}i(M,Re);break}else r(M,Re);Re=Re.sibling}D.type===K?(_=Sr(D.props.children,M.mode,he,D.key),_.return=M,M=_):(he=yi(D.type,D.key,D.props,null,M.mode,he),he.ref=zs(M,_,D),he.return=M,M=he)}return w(M);case O:e:{for(Re=D.key;_!==null;){if(_.key===Re)if(_.tag===4&&_.stateNode.containerInfo===D.containerInfo&&_.stateNode.implementation===D.implementation){i(M,_.sibling),_=d(_,D.children||[]),_.return=M,M=_;break e}else{i(M,_);break}else r(M,_);_=_.sibling}_=Fl(D,M.mode,he),_.return=M,M=_}return w(M);case ge:return Re=D._init,vt(M,_,Re(D._payload),he)}if(Qe(D))return be(M,_,D,he);if(Q(D))return Ne(M,_,D,he);Ka(M,D)}return typeof D=="string"&&D!==""||typeof D=="number"?(D=""+D,_!==null&&_.tag===6?(i(M,_.sibling),_=d(_,D),_.return=M,M=_):(i(M,_),_=zl(D,M.mode,he),_.return=M,M=_),w(M)):i(M,_)}return vt}var Qr=ad(!0),id=ad(!1),qa=Qn(null),Ya=null,Xr=null,Go=null;function Ko(){Go=Xr=Ya=null}function qo(t){var r=qa.current;lt(qa),t._currentValue=r}function Yo(t,r,i){for(;t!==null;){var c=t.alternate;if((t.childLanes&r)!==r?(t.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),t===i)break;t=t.return}}function Zr(t,r){Ya=t,Go=Xr=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&r)!==0&&(Kt=!0),t.firstContext=null)}function on(t){var r=t._currentValue;if(Go!==t)if(t={context:t,memoizedValue:r,next:null},Xr===null){if(Ya===null)throw Error(a(308));Xr=t,Ya.dependencies={lanes:0,firstContext:t}}else Xr=Xr.next=t;return r}var pr=null;function Jo(t){pr===null?pr=[t]:pr.push(t)}function od(t,r,i,c){var d=r.interleaved;return d===null?(i.next=i,Jo(r)):(i.next=d.next,d.next=i),r.interleaved=i,Ln(t,c)}function Ln(t,r){t.lanes|=r;var i=t.alternate;for(i!==null&&(i.lanes|=r),i=t,t=t.return;t!==null;)t.childLanes|=r,i=t.alternate,i!==null&&(i.childLanes|=r),i=t,t=t.return;return i.tag===3?i.stateNode:null}var er=!1;function Qo(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ld(t,r){t=t.updateQueue,r.updateQueue===t&&(r.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function zn(t,r){return{eventTime:t,lane:r,tag:0,payload:null,callback:null,next:null}}function tr(t,r,i){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(qe&2)!==0){var d=c.pending;return d===null?r.next=r:(r.next=d.next,d.next=r),c.pending=r,Ln(t,i)}return d=c.interleaved,d===null?(r.next=r,Jo(c)):(r.next=d.next,d.next=r),c.interleaved=r,Ln(t,i)}function Ja(t,r,i){if(r=r.updateQueue,r!==null&&(r=r.shared,(i&4194240)!==0)){var c=r.lanes;c&=t.pendingLanes,i|=c,r.lanes=i,uo(t,i)}}function cd(t,r){var i=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,i===c)){var d=null,m=null;if(i=i.firstBaseUpdate,i!==null){do{var w={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};m===null?d=m=w:m=m.next=w,i=i.next}while(i!==null);m===null?d=m=r:m=m.next=r}else d=m=r;i={baseState:c.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:c.shared,effects:c.effects},t.updateQueue=i;return}t=i.lastBaseUpdate,t===null?i.firstBaseUpdate=r:t.next=r,i.lastBaseUpdate=r}function Qa(t,r,i,c){var d=t.updateQueue;er=!1;var m=d.firstBaseUpdate,w=d.lastBaseUpdate,C=d.shared.pending;if(C!==null){d.shared.pending=null;var R=C,V=R.next;R.next=null,w===null?m=V:w.next=V,w=R;var ae=t.alternate;ae!==null&&(ae=ae.updateQueue,C=ae.lastBaseUpdate,C!==w&&(C===null?ae.firstBaseUpdate=V:C.next=V,ae.lastBaseUpdate=R))}if(m!==null){var ce=d.baseState;w=0,ae=V=R=null,C=m;do{var se=C.lane,we=C.eventTime;if((c&se)===se){ae!==null&&(ae=ae.next={eventTime:we,lane:0,tag:C.tag,payload:C.payload,callback:C.callback,next:null});e:{var be=t,Ne=C;switch(se=r,we=i,Ne.tag){case 1:if(be=Ne.payload,typeof be=="function"){ce=be.call(we,ce,se);break e}ce=be;break e;case 3:be.flags=be.flags&-65537|128;case 0:if(be=Ne.payload,se=typeof be=="function"?be.call(we,ce,se):be,se==null)break e;ce=q({},ce,se);break e;case 2:er=!0}}C.callback!==null&&C.lane!==0&&(t.flags|=64,se=d.effects,se===null?d.effects=[C]:se.push(C))}else we={eventTime:we,lane:se,tag:C.tag,payload:C.payload,callback:C.callback,next:null},ae===null?(V=ae=we,R=ce):ae=ae.next=we,w|=se;if(C=C.next,C===null){if(C=d.shared.pending,C===null)break;se=C,C=se.next,se.next=null,d.lastBaseUpdate=se,d.shared.pending=null}}while(!0);if(ae===null&&(R=ce),d.baseState=R,d.firstBaseUpdate=V,d.lastBaseUpdate=ae,r=d.shared.interleaved,r!==null){d=r;do w|=d.lane,d=d.next;while(d!==r)}else m===null&&(d.shared.lanes=0);vr|=w,t.lanes=w,t.memoizedState=ce}}function ud(t,r,i){if(t=r.effects,r.effects=null,t!==null)for(r=0;r<t.length;r++){var c=t[r],d=c.callback;if(d!==null){if(c.callback=null,c=i,typeof d!="function")throw Error(a(191,d));d.call(c)}}}var Fs={},En=Qn(Fs),Ms=Qn(Fs),Os=Qn(Fs);function gr(t){if(t===Fs)throw Error(a(174));return t}function Xo(t,r){switch(st(Os,r),st(Ms,t),st(En,Fs),t=r.nodeType,t){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Oe(null,"");break;default:t=t===8?r.parentNode:r,r=t.namespaceURI||null,t=t.tagName,r=Oe(r,t)}lt(En),st(En,r)}function es(){lt(En),lt(Ms),lt(Os)}function dd(t){gr(Os.current);var r=gr(En.current),i=Oe(r,t.type);r!==i&&(st(Ms,t),st(En,i))}function Zo(t){Ms.current===t&&(lt(En),lt(Ms))}var dt=Qn(0);function Xa(t){for(var r=t;r!==null;){if(r.tag===13){var i=r.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data==="$?"||i.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var el=[];function tl(){for(var t=0;t<el.length;t++)el[t]._workInProgressVersionPrimary=null;el.length=0}var Za=I.ReactCurrentDispatcher,nl=I.ReactCurrentBatchConfig,yr=0,ft=null,bt=null,Et=null,ei=!1,Bs=!1,Ds=0,ey=0;function _t(){throw Error(a(321))}function rl(t,r){if(r===null)return!1;for(var i=0;i<r.length&&i<t.length;i++)if(!mn(t[i],r[i]))return!1;return!0}function sl(t,r,i,c,d,m){if(yr=m,ft=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Za.current=t===null||t.memoizedState===null?sy:ay,t=i(c,d),Bs){m=0;do{if(Bs=!1,Ds=0,25<=m)throw Error(a(301));m+=1,Et=bt=null,r.updateQueue=null,Za.current=iy,t=i(c,d)}while(Bs)}if(Za.current=ri,r=bt!==null&&bt.next!==null,yr=0,Et=bt=ft=null,ei=!1,r)throw Error(a(300));return t}function al(){var t=Ds!==0;return Ds=0,t}function Tn(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Et===null?ft.memoizedState=Et=t:Et=Et.next=t,Et}function ln(){if(bt===null){var t=ft.alternate;t=t!==null?t.memoizedState:null}else t=bt.next;var r=Et===null?ft.memoizedState:Et.next;if(r!==null)Et=r,bt=t;else{if(t===null)throw Error(a(310));bt=t,t={memoizedState:bt.memoizedState,baseState:bt.baseState,baseQueue:bt.baseQueue,queue:bt.queue,next:null},Et===null?ft.memoizedState=Et=t:Et=Et.next=t}return Et}function Us(t,r){return typeof r=="function"?r(t):r}function il(t){var r=ln(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=t;var c=bt,d=c.baseQueue,m=i.pending;if(m!==null){if(d!==null){var w=d.next;d.next=m.next,m.next=w}c.baseQueue=d=m,i.pending=null}if(d!==null){m=d.next,c=c.baseState;var C=w=null,R=null,V=m;do{var ae=V.lane;if((yr&ae)===ae)R!==null&&(R=R.next={lane:0,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),c=V.hasEagerState?V.eagerState:t(c,V.action);else{var ce={lane:ae,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null};R===null?(C=R=ce,w=c):R=R.next=ce,ft.lanes|=ae,vr|=ae}V=V.next}while(V!==null&&V!==m);R===null?w=c:R.next=C,mn(c,r.memoizedState)||(Kt=!0),r.memoizedState=c,r.baseState=w,r.baseQueue=R,i.lastRenderedState=c}if(t=i.interleaved,t!==null){d=t;do m=d.lane,ft.lanes|=m,vr|=m,d=d.next;while(d!==t)}else d===null&&(i.lanes=0);return[r.memoizedState,i.dispatch]}function ol(t){var r=ln(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=t;var c=i.dispatch,d=i.pending,m=r.memoizedState;if(d!==null){i.pending=null;var w=d=d.next;do m=t(m,w.action),w=w.next;while(w!==d);mn(m,r.memoizedState)||(Kt=!0),r.memoizedState=m,r.baseQueue===null&&(r.baseState=m),i.lastRenderedState=m}return[m,c]}function fd(){}function hd(t,r){var i=ft,c=ln(),d=r(),m=!mn(c.memoizedState,d);if(m&&(c.memoizedState=d,Kt=!0),c=c.queue,ll(gd.bind(null,i,c,t),[t]),c.getSnapshot!==r||m||Et!==null&&Et.memoizedState.tag&1){if(i.flags|=2048,Ws(9,pd.bind(null,i,c,d,r),void 0,null),Tt===null)throw Error(a(349));(yr&30)!==0||md(i,r,d)}return d}function md(t,r,i){t.flags|=16384,t={getSnapshot:r,value:i},r=ft.updateQueue,r===null?(r={lastEffect:null,stores:null},ft.updateQueue=r,r.stores=[t]):(i=r.stores,i===null?r.stores=[t]:i.push(t))}function pd(t,r,i,c){r.value=i,r.getSnapshot=c,yd(r)&&vd(t)}function gd(t,r,i){return i(function(){yd(r)&&vd(t)})}function yd(t){var r=t.getSnapshot;t=t.value;try{var i=r();return!mn(t,i)}catch{return!0}}function vd(t){var r=Ln(t,1);r!==null&&xn(r,t,1,-1)}function xd(t){var r=Tn();return typeof t=="function"&&(t=t()),r.memoizedState=r.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Us,lastRenderedState:t},r.queue=t,t=t.dispatch=ry.bind(null,ft,t),[r.memoizedState,t]}function Ws(t,r,i,c){return t={tag:t,create:r,destroy:i,deps:c,next:null},r=ft.updateQueue,r===null?(r={lastEffect:null,stores:null},ft.updateQueue=r,r.lastEffect=t.next=t):(i=r.lastEffect,i===null?r.lastEffect=t.next=t:(c=i.next,i.next=t,t.next=c,r.lastEffect=t)),t}function wd(){return ln().memoizedState}function ti(t,r,i,c){var d=Tn();ft.flags|=t,d.memoizedState=Ws(1|r,i,void 0,c===void 0?null:c)}function ni(t,r,i,c){var d=ln();c=c===void 0?null:c;var m=void 0;if(bt!==null){var w=bt.memoizedState;if(m=w.destroy,c!==null&&rl(c,w.deps)){d.memoizedState=Ws(r,i,m,c);return}}ft.flags|=t,d.memoizedState=Ws(1|r,i,m,c)}function jd(t,r){return ti(8390656,8,t,r)}function ll(t,r){return ni(2048,8,t,r)}function Sd(t,r){return ni(4,2,t,r)}function bd(t,r){return ni(4,4,t,r)}function kd(t,r){if(typeof r=="function")return t=t(),r(t),function(){r(null)};if(r!=null)return t=t(),r.current=t,function(){r.current=null}}function Nd(t,r,i){return i=i!=null?i.concat([t]):null,ni(4,4,kd.bind(null,r,t),i)}function cl(){}function Cd(t,r){var i=ln();r=r===void 0?null:r;var c=i.memoizedState;return c!==null&&r!==null&&rl(r,c[1])?c[0]:(i.memoizedState=[t,r],t)}function Ed(t,r){var i=ln();r=r===void 0?null:r;var c=i.memoizedState;return c!==null&&r!==null&&rl(r,c[1])?c[0]:(t=t(),i.memoizedState=[t,r],t)}function Td(t,r,i){return(yr&21)===0?(t.baseState&&(t.baseState=!1,Kt=!0),t.memoizedState=i):(mn(i,r)||(i=su(),ft.lanes|=i,vr|=i,t.baseState=!0),r)}function ty(t,r){var i=et;et=i!==0&&4>i?i:4,t(!0);var c=nl.transition;nl.transition={};try{t(!1),r()}finally{et=i,nl.transition=c}}function Ad(){return ln().memoizedState}function ny(t,r,i){var c=ar(t);if(i={lane:c,action:i,hasEagerState:!1,eagerState:null,next:null},Id(t))Rd(r,i);else if(i=od(t,r,i,c),i!==null){var d=Dt();xn(i,t,c,d),Pd(i,r,c)}}function ry(t,r,i){var c=ar(t),d={lane:c,action:i,hasEagerState:!1,eagerState:null,next:null};if(Id(t))Rd(r,d);else{var m=t.alternate;if(t.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var w=r.lastRenderedState,C=m(w,i);if(d.hasEagerState=!0,d.eagerState=C,mn(C,w)){var R=r.interleaved;R===null?(d.next=d,Jo(r)):(d.next=R.next,R.next=d),r.interleaved=d;return}}catch{}finally{}i=od(t,r,d,c),i!==null&&(d=Dt(),xn(i,t,c,d),Pd(i,r,c))}}function Id(t){var r=t.alternate;return t===ft||r!==null&&r===ft}function Rd(t,r){Bs=ei=!0;var i=t.pending;i===null?r.next=r:(r.next=i.next,i.next=r),t.pending=r}function Pd(t,r,i){if((i&4194240)!==0){var c=r.lanes;c&=t.pendingLanes,i|=c,r.lanes=i,uo(t,i)}}var ri={readContext:on,useCallback:_t,useContext:_t,useEffect:_t,useImperativeHandle:_t,useInsertionEffect:_t,useLayoutEffect:_t,useMemo:_t,useReducer:_t,useRef:_t,useState:_t,useDebugValue:_t,useDeferredValue:_t,useTransition:_t,useMutableSource:_t,useSyncExternalStore:_t,useId:_t,unstable_isNewReconciler:!1},sy={readContext:on,useCallback:function(t,r){return Tn().memoizedState=[t,r===void 0?null:r],t},useContext:on,useEffect:jd,useImperativeHandle:function(t,r,i){return i=i!=null?i.concat([t]):null,ti(4194308,4,kd.bind(null,r,t),i)},useLayoutEffect:function(t,r){return ti(4194308,4,t,r)},useInsertionEffect:function(t,r){return ti(4,2,t,r)},useMemo:function(t,r){var i=Tn();return r=r===void 0?null:r,t=t(),i.memoizedState=[t,r],t},useReducer:function(t,r,i){var c=Tn();return r=i!==void 0?i(r):r,c.memoizedState=c.baseState=r,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:r},c.queue=t,t=t.dispatch=ny.bind(null,ft,t),[c.memoizedState,t]},useRef:function(t){var r=Tn();return t={current:t},r.memoizedState=t},useState:xd,useDebugValue:cl,useDeferredValue:function(t){return Tn().memoizedState=t},useTransition:function(){var t=xd(!1),r=t[0];return t=ty.bind(null,t[1]),Tn().memoizedState=t,[r,t]},useMutableSource:function(){},useSyncExternalStore:function(t,r,i){var c=ft,d=Tn();if(ct){if(i===void 0)throw Error(a(407));i=i()}else{if(i=r(),Tt===null)throw Error(a(349));(yr&30)!==0||md(c,r,i)}d.memoizedState=i;var m={value:i,getSnapshot:r};return d.queue=m,jd(gd.bind(null,c,m,t),[t]),c.flags|=2048,Ws(9,pd.bind(null,c,m,i,r),void 0,null),i},useId:function(){var t=Tn(),r=Tt.identifierPrefix;if(ct){var i=_n,c=$n;i=(c&~(1<<32-hn(c)-1)).toString(32)+i,r=":"+r+"R"+i,i=Ds++,0<i&&(r+="H"+i.toString(32)),r+=":"}else i=ey++,r=":"+r+"r"+i.toString(32)+":";return t.memoizedState=r},unstable_isNewReconciler:!1},ay={readContext:on,useCallback:Cd,useContext:on,useEffect:ll,useImperativeHandle:Nd,useInsertionEffect:Sd,useLayoutEffect:bd,useMemo:Ed,useReducer:il,useRef:wd,useState:function(){return il(Us)},useDebugValue:cl,useDeferredValue:function(t){var r=ln();return Td(r,bt.memoizedState,t)},useTransition:function(){var t=il(Us)[0],r=ln().memoizedState;return[t,r]},useMutableSource:fd,useSyncExternalStore:hd,useId:Ad,unstable_isNewReconciler:!1},iy={readContext:on,useCallback:Cd,useContext:on,useEffect:ll,useImperativeHandle:Nd,useInsertionEffect:Sd,useLayoutEffect:bd,useMemo:Ed,useReducer:ol,useRef:wd,useState:function(){return ol(Us)},useDebugValue:cl,useDeferredValue:function(t){var r=ln();return bt===null?r.memoizedState=t:Td(r,bt.memoizedState,t)},useTransition:function(){var t=ol(Us)[0],r=ln().memoizedState;return[t,r]},useMutableSource:fd,useSyncExternalStore:hd,useId:Ad,unstable_isNewReconciler:!1};function gn(t,r){if(t&&t.defaultProps){r=q({},r),t=t.defaultProps;for(var i in t)r[i]===void 0&&(r[i]=t[i]);return r}return r}function ul(t,r,i,c){r=t.memoizedState,i=i(c,r),i=i==null?r:q({},r,i),t.memoizedState=i,t.lanes===0&&(t.updateQueue.baseState=i)}var si={isMounted:function(t){return(t=t._reactInternals)?bn(t)===t:!1},enqueueSetState:function(t,r,i){t=t._reactInternals;var c=Dt(),d=ar(t),m=zn(c,d);m.payload=r,i!=null&&(m.callback=i),r=tr(t,m,d),r!==null&&(xn(r,t,d,c),Ja(r,t,d))},enqueueReplaceState:function(t,r,i){t=t._reactInternals;var c=Dt(),d=ar(t),m=zn(c,d);m.tag=1,m.payload=r,i!=null&&(m.callback=i),r=tr(t,m,d),r!==null&&(xn(r,t,d,c),Ja(r,t,d))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var i=Dt(),c=ar(t),d=zn(i,c);d.tag=2,r!=null&&(d.callback=r),r=tr(t,d,c),r!==null&&(xn(r,t,c,i),Ja(r,t,c))}};function $d(t,r,i,c,d,m,w){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,m,w):r.prototype&&r.prototype.isPureReactComponent?!As(i,c)||!As(d,m):!0}function _d(t,r,i){var c=!1,d=Xn,m=r.contextType;return typeof m=="object"&&m!==null?m=on(m):(d=Gt(r)?fr:$t.current,c=r.contextTypes,m=(c=c!=null)?Kr(t,d):Xn),r=new r(i,m),t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=si,t.stateNode=r,r._reactInternals=t,c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=d,t.__reactInternalMemoizedMaskedChildContext=m),r}function Ld(t,r,i,c){t=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(i,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(i,c),r.state!==t&&si.enqueueReplaceState(r,r.state,null)}function dl(t,r,i,c){var d=t.stateNode;d.props=i,d.state=t.memoizedState,d.refs={},Qo(t);var m=r.contextType;typeof m=="object"&&m!==null?d.context=on(m):(m=Gt(r)?fr:$t.current,d.context=Kr(t,m)),d.state=t.memoizedState,m=r.getDerivedStateFromProps,typeof m=="function"&&(ul(t,r,m,i),d.state=t.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(r=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),r!==d.state&&si.enqueueReplaceState(d,d.state,null),Qa(t,i,d,c),d.state=t.memoizedState),typeof d.componentDidMount=="function"&&(t.flags|=4194308)}function ts(t,r){try{var i="",c=r;do i+=H(c),c=c.return;while(c);var d=i}catch(m){d=`
|
|
39
|
+
Error generating stack: `+m.message+`
|
|
40
|
+
`+m.stack}return{value:t,source:r,stack:d,digest:null}}function fl(t,r,i){return{value:t,source:null,stack:i??null,digest:r??null}}function hl(t,r){try{console.error(r.value)}catch(i){setTimeout(function(){throw i})}}var oy=typeof WeakMap=="function"?WeakMap:Map;function zd(t,r,i){i=zn(-1,i),i.tag=3,i.payload={element:null};var c=r.value;return i.callback=function(){di||(di=!0,Tl=c),hl(t,r)},i}function Fd(t,r,i){i=zn(-1,i),i.tag=3;var c=t.type.getDerivedStateFromError;if(typeof c=="function"){var d=r.value;i.payload=function(){return c(d)},i.callback=function(){hl(t,r)}}var m=t.stateNode;return m!==null&&typeof m.componentDidCatch=="function"&&(i.callback=function(){hl(t,r),typeof c!="function"&&(rr===null?rr=new Set([this]):rr.add(this));var w=r.stack;this.componentDidCatch(r.value,{componentStack:w!==null?w:""})}),i}function Md(t,r,i){var c=t.pingCache;if(c===null){c=t.pingCache=new oy;var d=new Set;c.set(r,d)}else d=c.get(r),d===void 0&&(d=new Set,c.set(r,d));d.has(i)||(d.add(i),t=jy.bind(null,t,r,i),r.then(t,t))}function Od(t){do{var r;if((r=t.tag===13)&&(r=t.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return t;t=t.return}while(t!==null);return null}function Bd(t,r,i,c,d){return(t.mode&1)===0?(t===r?t.flags|=65536:(t.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(r=zn(-1,1),r.tag=2,tr(i,r,1))),i.lanes|=1),t):(t.flags|=65536,t.lanes=d,t)}var ly=I.ReactCurrentOwner,Kt=!1;function Bt(t,r,i,c){r.child=t===null?id(r,null,i,c):Qr(r,t.child,i,c)}function Dd(t,r,i,c,d){i=i.render;var m=r.ref;return Zr(r,d),c=sl(t,r,i,c,m,d),i=al(),t!==null&&!Kt?(r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~d,Fn(t,r,d)):(ct&&i&&Do(r),r.flags|=1,Bt(t,r,c,d),r.child)}function Ud(t,r,i,c,d){if(t===null){var m=i.type;return typeof m=="function"&&!Ll(m)&&m.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(r.tag=15,r.type=m,Wd(t,r,m,c,d)):(t=yi(i.type,null,c,r,r.mode,d),t.ref=r.ref,t.return=r,r.child=t)}if(m=t.child,(t.lanes&d)===0){var w=m.memoizedProps;if(i=i.compare,i=i!==null?i:As,i(w,c)&&t.ref===r.ref)return Fn(t,r,d)}return r.flags|=1,t=or(m,c),t.ref=r.ref,t.return=r,r.child=t}function Wd(t,r,i,c,d){if(t!==null){var m=t.memoizedProps;if(As(m,c)&&t.ref===r.ref)if(Kt=!1,r.pendingProps=c=m,(t.lanes&d)!==0)(t.flags&131072)!==0&&(Kt=!0);else return r.lanes=t.lanes,Fn(t,r,d)}return ml(t,r,i,c,d)}function Hd(t,r,i){var c=r.pendingProps,d=c.children,m=t!==null?t.memoizedState:null;if(c.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},st(rs,nn),nn|=i;else{if((i&1073741824)===0)return t=m!==null?m.baseLanes|i:i,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:t,cachePool:null,transitions:null},r.updateQueue=null,st(rs,nn),nn|=t,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=m!==null?m.baseLanes:i,st(rs,nn),nn|=c}else m!==null?(c=m.baseLanes|i,r.memoizedState=null):c=i,st(rs,nn),nn|=c;return Bt(t,r,d,i),r.child}function Vd(t,r){var i=r.ref;(t===null&&i!==null||t!==null&&t.ref!==i)&&(r.flags|=512,r.flags|=2097152)}function ml(t,r,i,c,d){var m=Gt(i)?fr:$t.current;return m=Kr(r,m),Zr(r,d),i=sl(t,r,i,c,m,d),c=al(),t!==null&&!Kt?(r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~d,Fn(t,r,d)):(ct&&c&&Do(r),r.flags|=1,Bt(t,r,i,d),r.child)}function Gd(t,r,i,c,d){if(Gt(i)){var m=!0;Ua(r)}else m=!1;if(Zr(r,d),r.stateNode===null)ii(t,r),_d(r,i,c),dl(r,i,c,d),c=!0;else if(t===null){var w=r.stateNode,C=r.memoizedProps;w.props=C;var R=w.context,V=i.contextType;typeof V=="object"&&V!==null?V=on(V):(V=Gt(i)?fr:$t.current,V=Kr(r,V));var ae=i.getDerivedStateFromProps,ce=typeof ae=="function"||typeof w.getSnapshotBeforeUpdate=="function";ce||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(C!==c||R!==V)&&Ld(r,w,c,V),er=!1;var se=r.memoizedState;w.state=se,Qa(r,c,w,d),R=r.memoizedState,C!==c||se!==R||Vt.current||er?(typeof ae=="function"&&(ul(r,i,ae,c),R=r.memoizedState),(C=er||$d(r,i,C,c,se,R,V))?(ce||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount()),typeof w.componentDidMount=="function"&&(r.flags|=4194308)):(typeof w.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=R),w.props=c,w.state=R,w.context=V,c=C):(typeof w.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{w=r.stateNode,ld(t,r),C=r.memoizedProps,V=r.type===r.elementType?C:gn(r.type,C),w.props=V,ce=r.pendingProps,se=w.context,R=i.contextType,typeof R=="object"&&R!==null?R=on(R):(R=Gt(i)?fr:$t.current,R=Kr(r,R));var we=i.getDerivedStateFromProps;(ae=typeof we=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(C!==ce||se!==R)&&Ld(r,w,c,R),er=!1,se=r.memoizedState,w.state=se,Qa(r,c,w,d);var be=r.memoizedState;C!==ce||se!==be||Vt.current||er?(typeof we=="function"&&(ul(r,i,we,c),be=r.memoizedState),(V=er||$d(r,i,V,c,se,be,R)||!1)?(ae||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(c,be,R),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(c,be,R)),typeof w.componentDidUpdate=="function"&&(r.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof w.componentDidUpdate!="function"||C===t.memoizedProps&&se===t.memoizedState||(r.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||C===t.memoizedProps&&se===t.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=be),w.props=c,w.state=be,w.context=R,c=V):(typeof w.componentDidUpdate!="function"||C===t.memoizedProps&&se===t.memoizedState||(r.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||C===t.memoizedProps&&se===t.memoizedState||(r.flags|=1024),c=!1)}return pl(t,r,i,c,m,d)}function pl(t,r,i,c,d,m){Vd(t,r);var w=(r.flags&128)!==0;if(!c&&!w)return d&&Qu(r,i,!1),Fn(t,r,m);c=r.stateNode,ly.current=r;var C=w&&typeof i.getDerivedStateFromError!="function"?null:c.render();return r.flags|=1,t!==null&&w?(r.child=Qr(r,t.child,null,m),r.child=Qr(r,null,C,m)):Bt(t,r,C,m),r.memoizedState=c.state,d&&Qu(r,i,!0),r.child}function Kd(t){var r=t.stateNode;r.pendingContext?Yu(t,r.pendingContext,r.pendingContext!==r.context):r.context&&Yu(t,r.context,!1),Xo(t,r.containerInfo)}function qd(t,r,i,c,d){return Jr(),Vo(d),r.flags|=256,Bt(t,r,i,c),r.child}var gl={dehydrated:null,treeContext:null,retryLane:0};function yl(t){return{baseLanes:t,cachePool:null,transitions:null}}function Yd(t,r,i){var c=r.pendingProps,d=dt.current,m=!1,w=(r.flags&128)!==0,C;if((C=w)||(C=t!==null&&t.memoizedState===null?!1:(d&2)!==0),C?(m=!0,r.flags&=-129):(t===null||t.memoizedState!==null)&&(d|=1),st(dt,d&1),t===null)return Ho(r),t=r.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((r.mode&1)===0?r.lanes=1:t.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(w=c.children,t=c.fallback,m?(c=r.mode,m=r.child,w={mode:"hidden",children:w},(c&1)===0&&m!==null?(m.childLanes=0,m.pendingProps=w):m=vi(w,c,0,null),t=Sr(t,c,i,null),m.return=r,t.return=r,m.sibling=t,r.child=m,r.child.memoizedState=yl(i),r.memoizedState=gl,t):vl(r,w));if(d=t.memoizedState,d!==null&&(C=d.dehydrated,C!==null))return cy(t,r,w,c,C,d,i);if(m){m=c.fallback,w=r.mode,d=t.child,C=d.sibling;var R={mode:"hidden",children:c.children};return(w&1)===0&&r.child!==d?(c=r.child,c.childLanes=0,c.pendingProps=R,r.deletions=null):(c=or(d,R),c.subtreeFlags=d.subtreeFlags&14680064),C!==null?m=or(C,m):(m=Sr(m,w,i,null),m.flags|=2),m.return=r,c.return=r,c.sibling=m,r.child=c,c=m,m=r.child,w=t.child.memoizedState,w=w===null?yl(i):{baseLanes:w.baseLanes|i,cachePool:null,transitions:w.transitions},m.memoizedState=w,m.childLanes=t.childLanes&~i,r.memoizedState=gl,c}return m=t.child,t=m.sibling,c=or(m,{mode:"visible",children:c.children}),(r.mode&1)===0&&(c.lanes=i),c.return=r,c.sibling=null,t!==null&&(i=r.deletions,i===null?(r.deletions=[t],r.flags|=16):i.push(t)),r.child=c,r.memoizedState=null,c}function vl(t,r){return r=vi({mode:"visible",children:r},t.mode,0,null),r.return=t,t.child=r}function ai(t,r,i,c){return c!==null&&Vo(c),Qr(r,t.child,null,i),t=vl(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function cy(t,r,i,c,d,m,w){if(i)return r.flags&256?(r.flags&=-257,c=fl(Error(a(422))),ai(t,r,w,c)):r.memoizedState!==null?(r.child=t.child,r.flags|=128,null):(m=c.fallback,d=r.mode,c=vi({mode:"visible",children:c.children},d,0,null),m=Sr(m,d,w,null),m.flags|=2,c.return=r,m.return=r,c.sibling=m,r.child=c,(r.mode&1)!==0&&Qr(r,t.child,null,w),r.child.memoizedState=yl(w),r.memoizedState=gl,m);if((r.mode&1)===0)return ai(t,r,w,null);if(d.data==="$!"){if(c=d.nextSibling&&d.nextSibling.dataset,c)var C=c.dgst;return c=C,m=Error(a(419)),c=fl(m,c,void 0),ai(t,r,w,c)}if(C=(w&t.childLanes)!==0,Kt||C){if(c=Tt,c!==null){switch(w&-w){case 4:d=2;break;case 16:d=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:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(c.suspendedLanes|w))!==0?0:d,d!==0&&d!==m.retryLane&&(m.retryLane=d,Ln(t,d),xn(c,t,d,-1))}return _l(),c=fl(Error(a(421))),ai(t,r,w,c)}return d.data==="$?"?(r.flags|=128,r.child=t.child,r=Sy.bind(null,t),d._reactRetry=r,null):(t=m.treeContext,tn=Jn(d.nextSibling),en=r,ct=!0,pn=null,t!==null&&(sn[an++]=$n,sn[an++]=_n,sn[an++]=hr,$n=t.id,_n=t.overflow,hr=r),r=vl(r,c.children),r.flags|=4096,r)}function Jd(t,r,i){t.lanes|=r;var c=t.alternate;c!==null&&(c.lanes|=r),Yo(t.return,r,i)}function xl(t,r,i,c,d){var m=t.memoizedState;m===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:i,tailMode:d}:(m.isBackwards=r,m.rendering=null,m.renderingStartTime=0,m.last=c,m.tail=i,m.tailMode=d)}function Qd(t,r,i){var c=r.pendingProps,d=c.revealOrder,m=c.tail;if(Bt(t,r,c.children,i),c=dt.current,(c&2)!==0)c=c&1|2,r.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Jd(t,i,r);else if(t.tag===19)Jd(t,i,r);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===r)break e;for(;t.sibling===null;){if(t.return===null||t.return===r)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}c&=1}if(st(dt,c),(r.mode&1)===0)r.memoizedState=null;else switch(d){case"forwards":for(i=r.child,d=null;i!==null;)t=i.alternate,t!==null&&Xa(t)===null&&(d=i),i=i.sibling;i=d,i===null?(d=r.child,r.child=null):(d=i.sibling,i.sibling=null),xl(r,!1,d,i,m);break;case"backwards":for(i=null,d=r.child,r.child=null;d!==null;){if(t=d.alternate,t!==null&&Xa(t)===null){r.child=d;break}t=d.sibling,d.sibling=i,i=d,d=t}xl(r,!0,i,null,m);break;case"together":xl(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function ii(t,r){(r.mode&1)===0&&t!==null&&(t.alternate=null,r.alternate=null,r.flags|=2)}function Fn(t,r,i){if(t!==null&&(r.dependencies=t.dependencies),vr|=r.lanes,(i&r.childLanes)===0)return null;if(t!==null&&r.child!==t.child)throw Error(a(153));if(r.child!==null){for(t=r.child,i=or(t,t.pendingProps),r.child=i,i.return=r;t.sibling!==null;)t=t.sibling,i=i.sibling=or(t,t.pendingProps),i.return=r;i.sibling=null}return r.child}function uy(t,r,i){switch(r.tag){case 3:Kd(r),Jr();break;case 5:dd(r);break;case 1:Gt(r.type)&&Ua(r);break;case 4:Xo(r,r.stateNode.containerInfo);break;case 10:var c=r.type._context,d=r.memoizedProps.value;st(qa,c._currentValue),c._currentValue=d;break;case 13:if(c=r.memoizedState,c!==null)return c.dehydrated!==null?(st(dt,dt.current&1),r.flags|=128,null):(i&r.child.childLanes)!==0?Yd(t,r,i):(st(dt,dt.current&1),t=Fn(t,r,i),t!==null?t.sibling:null);st(dt,dt.current&1);break;case 19:if(c=(i&r.childLanes)!==0,(t.flags&128)!==0){if(c)return Qd(t,r,i);r.flags|=128}if(d=r.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),st(dt,dt.current),c)break;return null;case 22:case 23:return r.lanes=0,Hd(t,r,i)}return Fn(t,r,i)}var Xd,wl,Zd,ef;Xd=function(t,r){for(var i=r.child;i!==null;){if(i.tag===5||i.tag===6)t.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},wl=function(){},Zd=function(t,r,i,c){var d=t.memoizedProps;if(d!==c){t=r.stateNode,gr(En.current);var m=null;switch(i){case"input":d=$e(t,d),c=$e(t,c),m=[];break;case"select":d=q({},d,{value:void 0}),c=q({},c,{value:void 0}),m=[];break;case"textarea":d=jt(t,d),c=jt(t,c),m=[];break;default:typeof d.onClick!="function"&&typeof c.onClick=="function"&&(t.onclick=Oa)}Ze(i,c);var w;i=null;for(V in d)if(!c.hasOwnProperty(V)&&d.hasOwnProperty(V)&&d[V]!=null)if(V==="style"){var C=d[V];for(w in C)C.hasOwnProperty(w)&&(i||(i={}),i[w]="")}else V!=="dangerouslySetInnerHTML"&&V!=="children"&&V!=="suppressContentEditableWarning"&&V!=="suppressHydrationWarning"&&V!=="autoFocus"&&(l.hasOwnProperty(V)?m||(m=[]):(m=m||[]).push(V,null));for(V in c){var R=c[V];if(C=d!=null?d[V]:void 0,c.hasOwnProperty(V)&&R!==C&&(R!=null||C!=null))if(V==="style")if(C){for(w in C)!C.hasOwnProperty(w)||R&&R.hasOwnProperty(w)||(i||(i={}),i[w]="");for(w in R)R.hasOwnProperty(w)&&C[w]!==R[w]&&(i||(i={}),i[w]=R[w])}else i||(m||(m=[]),m.push(V,i)),i=R;else V==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,C=C?C.__html:void 0,R!=null&&C!==R&&(m=m||[]).push(V,R)):V==="children"?typeof R!="string"&&typeof R!="number"||(m=m||[]).push(V,""+R):V!=="suppressContentEditableWarning"&&V!=="suppressHydrationWarning"&&(l.hasOwnProperty(V)?(R!=null&&V==="onScroll"&&ot("scroll",t),m||C===R||(m=[])):(m=m||[]).push(V,R))}i&&(m=m||[]).push("style",i);var V=m;(r.updateQueue=V)&&(r.flags|=4)}},ef=function(t,r,i,c){i!==c&&(r.flags|=4)};function Hs(t,r){if(!ct)switch(t.tailMode){case"hidden":r=t.tail;for(var i=null;r!==null;)r.alternate!==null&&(i=r),r=r.sibling;i===null?t.tail=null:i.sibling=null;break;case"collapsed":i=t.tail;for(var c=null;i!==null;)i.alternate!==null&&(c=i),i=i.sibling;c===null?r||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function Lt(t){var r=t.alternate!==null&&t.alternate.child===t.child,i=0,c=0;if(r)for(var d=t.child;d!==null;)i|=d.lanes|d.childLanes,c|=d.subtreeFlags&14680064,c|=d.flags&14680064,d.return=t,d=d.sibling;else for(d=t.child;d!==null;)i|=d.lanes|d.childLanes,c|=d.subtreeFlags,c|=d.flags,d.return=t,d=d.sibling;return t.subtreeFlags|=c,t.childLanes=i,r}function dy(t,r,i){var c=r.pendingProps;switch(Uo(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Lt(r),null;case 1:return Gt(r.type)&&Da(),Lt(r),null;case 3:return c=r.stateNode,es(),lt(Vt),lt($t),tl(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(t===null||t.child===null)&&(Ga(r)?r.flags|=4:t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,pn!==null&&(Rl(pn),pn=null))),wl(t,r),Lt(r),null;case 5:Zo(r);var d=gr(Os.current);if(i=r.type,t!==null&&r.stateNode!=null)Zd(t,r,i,c,d),t.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!c){if(r.stateNode===null)throw Error(a(166));return Lt(r),null}if(t=gr(En.current),Ga(r)){c=r.stateNode,i=r.type;var m=r.memoizedProps;switch(c[Cn]=r,c[_s]=m,t=(r.mode&1)!==0,i){case"dialog":ot("cancel",c),ot("close",c);break;case"iframe":case"object":case"embed":ot("load",c);break;case"video":case"audio":for(d=0;d<Rs.length;d++)ot(Rs[d],c);break;case"source":ot("error",c);break;case"img":case"image":case"link":ot("error",c),ot("load",c);break;case"details":ot("toggle",c);break;case"input":_e(c,m),ot("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!m.multiple},ot("invalid",c);break;case"textarea":pt(c,m),ot("invalid",c)}Ze(i,m),d=null;for(var w in m)if(m.hasOwnProperty(w)){var C=m[w];w==="children"?typeof C=="string"?c.textContent!==C&&(m.suppressHydrationWarning!==!0&&Ma(c.textContent,C,t),d=["children",C]):typeof C=="number"&&c.textContent!==""+C&&(m.suppressHydrationWarning!==!0&&Ma(c.textContent,C,t),d=["children",""+C]):l.hasOwnProperty(w)&&C!=null&&w==="onScroll"&&ot("scroll",c)}switch(i){case"input":Ge(c),it(c,m,!0);break;case"textarea":Ge(c),me(c);break;case"select":case"option":break;default:typeof m.onClick=="function"&&(c.onclick=Oa)}c=d,r.updateQueue=c,c!==null&&(r.flags|=4)}else{w=d.nodeType===9?d:d.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=Ae(i)),t==="http://www.w3.org/1999/xhtml"?i==="script"?(t=w.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof c.is=="string"?t=w.createElement(i,{is:c.is}):(t=w.createElement(i),i==="select"&&(w=t,c.multiple?w.multiple=!0:c.size&&(w.size=c.size))):t=w.createElementNS(t,i),t[Cn]=r,t[_s]=c,Xd(t,r,!1,!1),r.stateNode=t;e:{switch(w=W(i,c),i){case"dialog":ot("cancel",t),ot("close",t),d=c;break;case"iframe":case"object":case"embed":ot("load",t),d=c;break;case"video":case"audio":for(d=0;d<Rs.length;d++)ot(Rs[d],t);d=c;break;case"source":ot("error",t),d=c;break;case"img":case"image":case"link":ot("error",t),ot("load",t),d=c;break;case"details":ot("toggle",t),d=c;break;case"input":_e(t,c),d=$e(t,c),ot("invalid",t);break;case"option":d=c;break;case"select":t._wrapperState={wasMultiple:!!c.multiple},d=q({},c,{value:void 0}),ot("invalid",t);break;case"textarea":pt(t,c),d=jt(t,c),ot("invalid",t);break;default:d=c}Ze(i,d),C=d;for(m in C)if(C.hasOwnProperty(m)){var R=C[m];m==="style"?Ht(t,R):m==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,R!=null&&J(t,R)):m==="children"?typeof R=="string"?(i!=="textarea"||R!=="")&&ye(t,R):typeof R=="number"&&ye(t,""+R):m!=="suppressContentEditableWarning"&&m!=="suppressHydrationWarning"&&m!=="autoFocus"&&(l.hasOwnProperty(m)?R!=null&&m==="onScroll"&&ot("scroll",t):R!=null&&P(t,m,R,w))}switch(i){case"input":Ge(t),it(t,c,!1);break;case"textarea":Ge(t),me(t);break;case"option":c.value!=null&&t.setAttribute("value",""+pe(c.value));break;case"select":t.multiple=!!c.multiple,m=c.value,m!=null?Ye(t,!!c.multiple,m,!1):c.defaultValue!=null&&Ye(t,!!c.multiple,c.defaultValue,!0);break;default:typeof d.onClick=="function"&&(t.onclick=Oa)}switch(i){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return Lt(r),null;case 6:if(t&&r.stateNode!=null)ef(t,r,t.memoizedProps,c);else{if(typeof c!="string"&&r.stateNode===null)throw Error(a(166));if(i=gr(Os.current),gr(En.current),Ga(r)){if(c=r.stateNode,i=r.memoizedProps,c[Cn]=r,(m=c.nodeValue!==i)&&(t=en,t!==null))switch(t.tag){case 3:Ma(c.nodeValue,i,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Ma(c.nodeValue,i,(t.mode&1)!==0)}m&&(r.flags|=4)}else c=(i.nodeType===9?i:i.ownerDocument).createTextNode(c),c[Cn]=r,r.stateNode=c}return Lt(r),null;case 13:if(lt(dt),c=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(ct&&tn!==null&&(r.mode&1)!==0&&(r.flags&128)===0)rd(),Jr(),r.flags|=98560,m=!1;else if(m=Ga(r),c!==null&&c.dehydrated!==null){if(t===null){if(!m)throw Error(a(318));if(m=r.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(a(317));m[Cn]=r}else Jr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Lt(r),m=!1}else pn!==null&&(Rl(pn),pn=null),m=!0;if(!m)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=i,r):(c=c!==null,c!==(t!==null&&t.memoizedState!==null)&&c&&(r.child.flags|=8192,(r.mode&1)!==0&&(t===null||(dt.current&1)!==0?kt===0&&(kt=3):_l())),r.updateQueue!==null&&(r.flags|=4),Lt(r),null);case 4:return es(),wl(t,r),t===null&&Ps(r.stateNode.containerInfo),Lt(r),null;case 10:return qo(r.type._context),Lt(r),null;case 17:return Gt(r.type)&&Da(),Lt(r),null;case 19:if(lt(dt),m=r.memoizedState,m===null)return Lt(r),null;if(c=(r.flags&128)!==0,w=m.rendering,w===null)if(c)Hs(m,!1);else{if(kt!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(w=Xa(t),w!==null){for(r.flags|=128,Hs(m,!1),c=w.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),r.subtreeFlags=0,c=i,i=r.child;i!==null;)m=i,t=c,m.flags&=14680066,w=m.alternate,w===null?(m.childLanes=0,m.lanes=t,m.child=null,m.subtreeFlags=0,m.memoizedProps=null,m.memoizedState=null,m.updateQueue=null,m.dependencies=null,m.stateNode=null):(m.childLanes=w.childLanes,m.lanes=w.lanes,m.child=w.child,m.subtreeFlags=0,m.deletions=null,m.memoizedProps=w.memoizedProps,m.memoizedState=w.memoizedState,m.updateQueue=w.updateQueue,m.type=w.type,t=w.dependencies,m.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),i=i.sibling;return st(dt,dt.current&1|2),r.child}t=t.sibling}m.tail!==null&&yt()>ss&&(r.flags|=128,c=!0,Hs(m,!1),r.lanes=4194304)}else{if(!c)if(t=Xa(w),t!==null){if(r.flags|=128,c=!0,i=t.updateQueue,i!==null&&(r.updateQueue=i,r.flags|=4),Hs(m,!0),m.tail===null&&m.tailMode==="hidden"&&!w.alternate&&!ct)return Lt(r),null}else 2*yt()-m.renderingStartTime>ss&&i!==1073741824&&(r.flags|=128,c=!0,Hs(m,!1),r.lanes=4194304);m.isBackwards?(w.sibling=r.child,r.child=w):(i=m.last,i!==null?i.sibling=w:r.child=w,m.last=w)}return m.tail!==null?(r=m.tail,m.rendering=r,m.tail=r.sibling,m.renderingStartTime=yt(),r.sibling=null,i=dt.current,st(dt,c?i&1|2:i&1),r):(Lt(r),null);case 22:case 23:return $l(),c=r.memoizedState!==null,t!==null&&t.memoizedState!==null!==c&&(r.flags|=8192),c&&(r.mode&1)!==0?(nn&1073741824)!==0&&(Lt(r),r.subtreeFlags&6&&(r.flags|=8192)):Lt(r),null;case 24:return null;case 25:return null}throw Error(a(156,r.tag))}function fy(t,r){switch(Uo(r),r.tag){case 1:return Gt(r.type)&&Da(),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return es(),lt(Vt),lt($t),tl(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 5:return Zo(r),null;case 13:if(lt(dt),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(a(340));Jr()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return lt(dt),null;case 4:return es(),null;case 10:return qo(r.type._context),null;case 22:case 23:return $l(),null;case 24:return null;default:return null}}var oi=!1,zt=!1,hy=typeof WeakSet=="function"?WeakSet:Set,je=null;function ns(t,r){var i=t.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(c){ht(t,r,c)}else i.current=null}function jl(t,r,i){try{i()}catch(c){ht(t,r,c)}}var tf=!1;function my(t,r){if($o=Ea,t=$u(),No(t)){if("selectionStart"in t)var i={start:t.selectionStart,end:t.selectionEnd};else e:{i=(i=t.ownerDocument)&&i.defaultView||window;var c=i.getSelection&&i.getSelection();if(c&&c.rangeCount!==0){i=c.anchorNode;var d=c.anchorOffset,m=c.focusNode;c=c.focusOffset;try{i.nodeType,m.nodeType}catch{i=null;break e}var w=0,C=-1,R=-1,V=0,ae=0,ce=t,se=null;t:for(;;){for(var we;ce!==i||d!==0&&ce.nodeType!==3||(C=w+d),ce!==m||c!==0&&ce.nodeType!==3||(R=w+c),ce.nodeType===3&&(w+=ce.nodeValue.length),(we=ce.firstChild)!==null;)se=ce,ce=we;for(;;){if(ce===t)break t;if(se===i&&++V===d&&(C=w),se===m&&++ae===c&&(R=w),(we=ce.nextSibling)!==null)break;ce=se,se=ce.parentNode}ce=we}i=C===-1||R===-1?null:{start:C,end:R}}else i=null}i=i||{start:0,end:0}}else i=null;for(_o={focusedElem:t,selectionRange:i},Ea=!1,je=r;je!==null;)if(r=je,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,je=t;else for(;je!==null;){r=je;try{var be=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(be!==null){var Ne=be.memoizedProps,vt=be.memoizedState,M=r.stateNode,_=M.getSnapshotBeforeUpdate(r.elementType===r.type?Ne:gn(r.type,Ne),vt);M.__reactInternalSnapshotBeforeUpdate=_}break;case 3:var D=r.stateNode.containerInfo;D.nodeType===1?D.textContent="":D.nodeType===9&&D.documentElement&&D.removeChild(D.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(he){ht(r,r.return,he)}if(t=r.sibling,t!==null){t.return=r.return,je=t;break}je=r.return}return be=tf,tf=!1,be}function Vs(t,r,i){var c=r.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var d=c=c.next;do{if((d.tag&t)===t){var m=d.destroy;d.destroy=void 0,m!==void 0&&jl(r,i,m)}d=d.next}while(d!==c)}}function li(t,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var c=i.create;i.destroy=c()}i=i.next}while(i!==r)}}function Sl(t){var r=t.ref;if(r!==null){var i=t.stateNode;switch(t.tag){case 5:t=i;break;default:t=i}typeof r=="function"?r(t):r.current=t}}function nf(t){var r=t.alternate;r!==null&&(t.alternate=null,nf(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&(delete r[Cn],delete r[_s],delete r[Mo],delete r[Jg],delete r[Qg])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function rf(t){return t.tag===5||t.tag===3||t.tag===4}function sf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||rf(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function bl(t,r,i){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?i.nodeType===8?i.parentNode.insertBefore(t,r):i.insertBefore(t,r):(i.nodeType===8?(r=i.parentNode,r.insertBefore(t,i)):(r=i,r.appendChild(t)),i=i._reactRootContainer,i!=null||r.onclick!==null||(r.onclick=Oa));else if(c!==4&&(t=t.child,t!==null))for(bl(t,r,i),t=t.sibling;t!==null;)bl(t,r,i),t=t.sibling}function kl(t,r,i){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?i.insertBefore(t,r):i.appendChild(t);else if(c!==4&&(t=t.child,t!==null))for(kl(t,r,i),t=t.sibling;t!==null;)kl(t,r,i),t=t.sibling}var It=null,yn=!1;function nr(t,r,i){for(i=i.child;i!==null;)af(t,r,i),i=i.sibling}function af(t,r,i){if(Nn&&typeof Nn.onCommitFiberUnmount=="function")try{Nn.onCommitFiberUnmount(ja,i)}catch{}switch(i.tag){case 5:zt||ns(i,r);case 6:var c=It,d=yn;It=null,nr(t,r,i),It=c,yn=d,It!==null&&(yn?(t=It,i=i.stateNode,t.nodeType===8?t.parentNode.removeChild(i):t.removeChild(i)):It.removeChild(i.stateNode));break;case 18:It!==null&&(yn?(t=It,i=i.stateNode,t.nodeType===8?Fo(t.parentNode,i):t.nodeType===1&&Fo(t,i),bs(t)):Fo(It,i.stateNode));break;case 4:c=It,d=yn,It=i.stateNode.containerInfo,yn=!0,nr(t,r,i),It=c,yn=d;break;case 0:case 11:case 14:case 15:if(!zt&&(c=i.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){d=c=c.next;do{var m=d,w=m.destroy;m=m.tag,w!==void 0&&((m&2)!==0||(m&4)!==0)&&jl(i,r,w),d=d.next}while(d!==c)}nr(t,r,i);break;case 1:if(!zt&&(ns(i,r),c=i.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=i.memoizedProps,c.state=i.memoizedState,c.componentWillUnmount()}catch(C){ht(i,r,C)}nr(t,r,i);break;case 21:nr(t,r,i);break;case 22:i.mode&1?(zt=(c=zt)||i.memoizedState!==null,nr(t,r,i),zt=c):nr(t,r,i);break;default:nr(t,r,i)}}function of(t){var r=t.updateQueue;if(r!==null){t.updateQueue=null;var i=t.stateNode;i===null&&(i=t.stateNode=new hy),r.forEach(function(c){var d=by.bind(null,t,c);i.has(c)||(i.add(c),c.then(d,d))})}}function vn(t,r){var i=r.deletions;if(i!==null)for(var c=0;c<i.length;c++){var d=i[c];try{var m=t,w=r,C=w;e:for(;C!==null;){switch(C.tag){case 5:It=C.stateNode,yn=!1;break e;case 3:It=C.stateNode.containerInfo,yn=!0;break e;case 4:It=C.stateNode.containerInfo,yn=!0;break e}C=C.return}if(It===null)throw Error(a(160));af(m,w,d),It=null,yn=!1;var R=d.alternate;R!==null&&(R.return=null),d.return=null}catch(V){ht(d,r,V)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)lf(r,t),r=r.sibling}function lf(t,r){var i=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(vn(r,t),An(t),c&4){try{Vs(3,t,t.return),li(3,t)}catch(Ne){ht(t,t.return,Ne)}try{Vs(5,t,t.return)}catch(Ne){ht(t,t.return,Ne)}}break;case 1:vn(r,t),An(t),c&512&&i!==null&&ns(i,i.return);break;case 5:if(vn(r,t),An(t),c&512&&i!==null&&ns(i,i.return),t.flags&32){var d=t.stateNode;try{ye(d,"")}catch(Ne){ht(t,t.return,Ne)}}if(c&4&&(d=t.stateNode,d!=null)){var m=t.memoizedProps,w=i!==null?i.memoizedProps:m,C=t.type,R=t.updateQueue;if(t.updateQueue=null,R!==null)try{C==="input"&&m.type==="radio"&&m.name!=null&&Be(d,m),W(C,w);var V=W(C,m);for(w=0;w<R.length;w+=2){var ae=R[w],ce=R[w+1];ae==="style"?Ht(d,ce):ae==="dangerouslySetInnerHTML"?J(d,ce):ae==="children"?ye(d,ce):P(d,ae,ce,V)}switch(C){case"input":ze(d,m);break;case"textarea":Me(d,m);break;case"select":var se=d._wrapperState.wasMultiple;d._wrapperState.wasMultiple=!!m.multiple;var we=m.value;we!=null?Ye(d,!!m.multiple,we,!1):se!==!!m.multiple&&(m.defaultValue!=null?Ye(d,!!m.multiple,m.defaultValue,!0):Ye(d,!!m.multiple,m.multiple?[]:"",!1))}d[_s]=m}catch(Ne){ht(t,t.return,Ne)}}break;case 6:if(vn(r,t),An(t),c&4){if(t.stateNode===null)throw Error(a(162));d=t.stateNode,m=t.memoizedProps;try{d.nodeValue=m}catch(Ne){ht(t,t.return,Ne)}}break;case 3:if(vn(r,t),An(t),c&4&&i!==null&&i.memoizedState.isDehydrated)try{bs(r.containerInfo)}catch(Ne){ht(t,t.return,Ne)}break;case 4:vn(r,t),An(t);break;case 13:vn(r,t),An(t),d=t.child,d.flags&8192&&(m=d.memoizedState!==null,d.stateNode.isHidden=m,!m||d.alternate!==null&&d.alternate.memoizedState!==null||(El=yt())),c&4&&of(t);break;case 22:if(ae=i!==null&&i.memoizedState!==null,t.mode&1?(zt=(V=zt)||ae,vn(r,t),zt=V):vn(r,t),An(t),c&8192){if(V=t.memoizedState!==null,(t.stateNode.isHidden=V)&&!ae&&(t.mode&1)!==0)for(je=t,ae=t.child;ae!==null;){for(ce=je=ae;je!==null;){switch(se=je,we=se.child,se.tag){case 0:case 11:case 14:case 15:Vs(4,se,se.return);break;case 1:ns(se,se.return);var be=se.stateNode;if(typeof be.componentWillUnmount=="function"){c=se,i=se.return;try{r=c,be.props=r.memoizedProps,be.state=r.memoizedState,be.componentWillUnmount()}catch(Ne){ht(c,i,Ne)}}break;case 5:ns(se,se.return);break;case 22:if(se.memoizedState!==null){df(ce);continue}}we!==null?(we.return=se,je=we):df(ce)}ae=ae.sibling}e:for(ae=null,ce=t;;){if(ce.tag===5){if(ae===null){ae=ce;try{d=ce.stateNode,V?(m=d.style,typeof m.setProperty=="function"?m.setProperty("display","none","important"):m.display="none"):(C=ce.stateNode,R=ce.memoizedProps.style,w=R!=null&&R.hasOwnProperty("display")?R.display:null,C.style.display=nt("display",w))}catch(Ne){ht(t,t.return,Ne)}}}else if(ce.tag===6){if(ae===null)try{ce.stateNode.nodeValue=V?"":ce.memoizedProps}catch(Ne){ht(t,t.return,Ne)}}else if((ce.tag!==22&&ce.tag!==23||ce.memoizedState===null||ce===t)&&ce.child!==null){ce.child.return=ce,ce=ce.child;continue}if(ce===t)break e;for(;ce.sibling===null;){if(ce.return===null||ce.return===t)break e;ae===ce&&(ae=null),ce=ce.return}ae===ce&&(ae=null),ce.sibling.return=ce.return,ce=ce.sibling}}break;case 19:vn(r,t),An(t),c&4&&of(t);break;case 21:break;default:vn(r,t),An(t)}}function An(t){var r=t.flags;if(r&2){try{e:{for(var i=t.return;i!==null;){if(rf(i)){var c=i;break e}i=i.return}throw Error(a(160))}switch(c.tag){case 5:var d=c.stateNode;c.flags&32&&(ye(d,""),c.flags&=-33);var m=sf(t);kl(t,m,d);break;case 3:case 4:var w=c.stateNode.containerInfo,C=sf(t);bl(t,C,w);break;default:throw Error(a(161))}}catch(R){ht(t,t.return,R)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function py(t,r,i){je=t,cf(t)}function cf(t,r,i){for(var c=(t.mode&1)!==0;je!==null;){var d=je,m=d.child;if(d.tag===22&&c){var w=d.memoizedState!==null||oi;if(!w){var C=d.alternate,R=C!==null&&C.memoizedState!==null||zt;C=oi;var V=zt;if(oi=w,(zt=R)&&!V)for(je=d;je!==null;)w=je,R=w.child,w.tag===22&&w.memoizedState!==null?ff(d):R!==null?(R.return=w,je=R):ff(d);for(;m!==null;)je=m,cf(m),m=m.sibling;je=d,oi=C,zt=V}uf(t)}else(d.subtreeFlags&8772)!==0&&m!==null?(m.return=d,je=m):uf(t)}}function uf(t){for(;je!==null;){var r=je;if((r.flags&8772)!==0){var i=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:zt||li(5,r);break;case 1:var c=r.stateNode;if(r.flags&4&&!zt)if(i===null)c.componentDidMount();else{var d=r.elementType===r.type?i.memoizedProps:gn(r.type,i.memoizedProps);c.componentDidUpdate(d,i.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var m=r.updateQueue;m!==null&&ud(r,m,c);break;case 3:var w=r.updateQueue;if(w!==null){if(i=null,r.child!==null)switch(r.child.tag){case 5:i=r.child.stateNode;break;case 1:i=r.child.stateNode}ud(r,w,i)}break;case 5:var C=r.stateNode;if(i===null&&r.flags&4){i=C;var R=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":R.autoFocus&&i.focus();break;case"img":R.src&&(i.src=R.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var V=r.alternate;if(V!==null){var ae=V.memoizedState;if(ae!==null){var ce=ae.dehydrated;ce!==null&&bs(ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}zt||r.flags&512&&Sl(r)}catch(se){ht(r,r.return,se)}}if(r===t){je=null;break}if(i=r.sibling,i!==null){i.return=r.return,je=i;break}je=r.return}}function df(t){for(;je!==null;){var r=je;if(r===t){je=null;break}var i=r.sibling;if(i!==null){i.return=r.return,je=i;break}je=r.return}}function ff(t){for(;je!==null;){var r=je;try{switch(r.tag){case 0:case 11:case 15:var i=r.return;try{li(4,r)}catch(R){ht(r,i,R)}break;case 1:var c=r.stateNode;if(typeof c.componentDidMount=="function"){var d=r.return;try{c.componentDidMount()}catch(R){ht(r,d,R)}}var m=r.return;try{Sl(r)}catch(R){ht(r,m,R)}break;case 5:var w=r.return;try{Sl(r)}catch(R){ht(r,w,R)}}}catch(R){ht(r,r.return,R)}if(r===t){je=null;break}var C=r.sibling;if(C!==null){C.return=r.return,je=C;break}je=r.return}}var gy=Math.ceil,ci=I.ReactCurrentDispatcher,Nl=I.ReactCurrentOwner,cn=I.ReactCurrentBatchConfig,qe=0,Tt=null,wt=null,Rt=0,nn=0,rs=Qn(0),kt=0,Gs=null,vr=0,ui=0,Cl=0,Ks=null,qt=null,El=0,ss=1/0,Mn=null,di=!1,Tl=null,rr=null,fi=!1,sr=null,hi=0,qs=0,Al=null,mi=-1,pi=0;function Dt(){return(qe&6)!==0?yt():mi!==-1?mi:mi=yt()}function ar(t){return(t.mode&1)===0?1:(qe&2)!==0&&Rt!==0?Rt&-Rt:Zg.transition!==null?(pi===0&&(pi=su()),pi):(t=et,t!==0||(t=window.event,t=t===void 0?16:hu(t.type)),t)}function xn(t,r,i,c){if(50<qs)throw qs=0,Al=null,Error(a(185));vs(t,i,c),((qe&2)===0||t!==Tt)&&(t===Tt&&((qe&2)===0&&(ui|=i),kt===4&&ir(t,Rt)),Yt(t,c),i===1&&qe===0&&(r.mode&1)===0&&(ss=yt()+500,Wa&&Zn()))}function Yt(t,r){var i=t.callbackNode;Zp(t,r);var c=ka(t,t===Tt?Rt:0);if(c===0)i!==null&&tu(i),t.callbackNode=null,t.callbackPriority=0;else if(r=c&-c,t.callbackPriority!==r){if(i!=null&&tu(i),r===1)t.tag===0?Xg(mf.bind(null,t)):Xu(mf.bind(null,t)),qg(function(){(qe&6)===0&&Zn()}),i=null;else{switch(au(c)){case 1:i=oo;break;case 4:i=nu;break;case 16:i=wa;break;case 536870912:i=ru;break;default:i=wa}i=Sf(i,hf.bind(null,t))}t.callbackPriority=r,t.callbackNode=i}}function hf(t,r){if(mi=-1,pi=0,(qe&6)!==0)throw Error(a(327));var i=t.callbackNode;if(as()&&t.callbackNode!==i)return null;var c=ka(t,t===Tt?Rt:0);if(c===0)return null;if((c&30)!==0||(c&t.expiredLanes)!==0||r)r=gi(t,c);else{r=c;var d=qe;qe|=2;var m=gf();(Tt!==t||Rt!==r)&&(Mn=null,ss=yt()+500,wr(t,r));do try{xy();break}catch(C){pf(t,C)}while(!0);Ko(),ci.current=m,qe=d,wt!==null?r=0:(Tt=null,Rt=0,r=kt)}if(r!==0){if(r===2&&(d=lo(t),d!==0&&(c=d,r=Il(t,d))),r===1)throw i=Gs,wr(t,0),ir(t,c),Yt(t,yt()),i;if(r===6)ir(t,c);else{if(d=t.current.alternate,(c&30)===0&&!yy(d)&&(r=gi(t,c),r===2&&(m=lo(t),m!==0&&(c=m,r=Il(t,m))),r===1))throw i=Gs,wr(t,0),ir(t,c),Yt(t,yt()),i;switch(t.finishedWork=d,t.finishedLanes=c,r){case 0:case 1:throw Error(a(345));case 2:jr(t,qt,Mn);break;case 3:if(ir(t,c),(c&130023424)===c&&(r=El+500-yt(),10<r)){if(ka(t,0)!==0)break;if(d=t.suspendedLanes,(d&c)!==c){Dt(),t.pingedLanes|=t.suspendedLanes&d;break}t.timeoutHandle=zo(jr.bind(null,t,qt,Mn),r);break}jr(t,qt,Mn);break;case 4:if(ir(t,c),(c&4194240)===c)break;for(r=t.eventTimes,d=-1;0<c;){var w=31-hn(c);m=1<<w,w=r[w],w>d&&(d=w),c&=~m}if(c=d,c=yt()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*gy(c/1960))-c,10<c){t.timeoutHandle=zo(jr.bind(null,t,qt,Mn),c);break}jr(t,qt,Mn);break;case 5:jr(t,qt,Mn);break;default:throw Error(a(329))}}}return Yt(t,yt()),t.callbackNode===i?hf.bind(null,t):null}function Il(t,r){var i=Ks;return t.current.memoizedState.isDehydrated&&(wr(t,r).flags|=256),t=gi(t,r),t!==2&&(r=qt,qt=i,r!==null&&Rl(r)),t}function Rl(t){qt===null?qt=t:qt.push.apply(qt,t)}function yy(t){for(var r=t;;){if(r.flags&16384){var i=r.updateQueue;if(i!==null&&(i=i.stores,i!==null))for(var c=0;c<i.length;c++){var d=i[c],m=d.getSnapshot;d=d.value;try{if(!mn(m(),d))return!1}catch{return!1}}}if(i=r.child,r.subtreeFlags&16384&&i!==null)i.return=r,r=i;else{if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function ir(t,r){for(r&=~Cl,r&=~ui,t.suspendedLanes|=r,t.pingedLanes&=~r,t=t.expirationTimes;0<r;){var i=31-hn(r),c=1<<i;t[i]=-1,r&=~c}}function mf(t){if((qe&6)!==0)throw Error(a(327));as();var r=ka(t,0);if((r&1)===0)return Yt(t,yt()),null;var i=gi(t,r);if(t.tag!==0&&i===2){var c=lo(t);c!==0&&(r=c,i=Il(t,c))}if(i===1)throw i=Gs,wr(t,0),ir(t,r),Yt(t,yt()),i;if(i===6)throw Error(a(345));return t.finishedWork=t.current.alternate,t.finishedLanes=r,jr(t,qt,Mn),Yt(t,yt()),null}function Pl(t,r){var i=qe;qe|=1;try{return t(r)}finally{qe=i,qe===0&&(ss=yt()+500,Wa&&Zn())}}function xr(t){sr!==null&&sr.tag===0&&(qe&6)===0&&as();var r=qe;qe|=1;var i=cn.transition,c=et;try{if(cn.transition=null,et=1,t)return t()}finally{et=c,cn.transition=i,qe=r,(qe&6)===0&&Zn()}}function $l(){nn=rs.current,lt(rs)}function wr(t,r){t.finishedWork=null,t.finishedLanes=0;var i=t.timeoutHandle;if(i!==-1&&(t.timeoutHandle=-1,Kg(i)),wt!==null)for(i=wt.return;i!==null;){var c=i;switch(Uo(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Da();break;case 3:es(),lt(Vt),lt($t),tl();break;case 5:Zo(c);break;case 4:es();break;case 13:lt(dt);break;case 19:lt(dt);break;case 10:qo(c.type._context);break;case 22:case 23:$l()}i=i.return}if(Tt=t,wt=t=or(t.current,null),Rt=nn=r,kt=0,Gs=null,Cl=ui=vr=0,qt=Ks=null,pr!==null){for(r=0;r<pr.length;r++)if(i=pr[r],c=i.interleaved,c!==null){i.interleaved=null;var d=c.next,m=i.pending;if(m!==null){var w=m.next;m.next=d,c.next=w}i.pending=c}pr=null}return t}function pf(t,r){do{var i=wt;try{if(Ko(),Za.current=ri,ei){for(var c=ft.memoizedState;c!==null;){var d=c.queue;d!==null&&(d.pending=null),c=c.next}ei=!1}if(yr=0,Et=bt=ft=null,Bs=!1,Ds=0,Nl.current=null,i===null||i.return===null){kt=1,Gs=r,wt=null;break}e:{var m=t,w=i.return,C=i,R=r;if(r=Rt,C.flags|=32768,R!==null&&typeof R=="object"&&typeof R.then=="function"){var V=R,ae=C,ce=ae.tag;if((ae.mode&1)===0&&(ce===0||ce===11||ce===15)){var se=ae.alternate;se?(ae.updateQueue=se.updateQueue,ae.memoizedState=se.memoizedState,ae.lanes=se.lanes):(ae.updateQueue=null,ae.memoizedState=null)}var we=Od(w);if(we!==null){we.flags&=-257,Bd(we,w,C,m,r),we.mode&1&&Md(m,V,r),r=we,R=V;var be=r.updateQueue;if(be===null){var Ne=new Set;Ne.add(R),r.updateQueue=Ne}else be.add(R);break e}else{if((r&1)===0){Md(m,V,r),_l();break e}R=Error(a(426))}}else if(ct&&C.mode&1){var vt=Od(w);if(vt!==null){(vt.flags&65536)===0&&(vt.flags|=256),Bd(vt,w,C,m,r),Vo(ts(R,C));break e}}m=R=ts(R,C),kt!==4&&(kt=2),Ks===null?Ks=[m]:Ks.push(m),m=w;do{switch(m.tag){case 3:m.flags|=65536,r&=-r,m.lanes|=r;var M=zd(m,R,r);cd(m,M);break e;case 1:C=R;var _=m.type,D=m.stateNode;if((m.flags&128)===0&&(typeof _.getDerivedStateFromError=="function"||D!==null&&typeof D.componentDidCatch=="function"&&(rr===null||!rr.has(D)))){m.flags|=65536,r&=-r,m.lanes|=r;var he=Fd(m,C,r);cd(m,he);break e}}m=m.return}while(m!==null)}vf(i)}catch(Ee){r=Ee,wt===i&&i!==null&&(wt=i=i.return);continue}break}while(!0)}function gf(){var t=ci.current;return ci.current=ri,t===null?ri:t}function _l(){(kt===0||kt===3||kt===2)&&(kt=4),Tt===null||(vr&268435455)===0&&(ui&268435455)===0||ir(Tt,Rt)}function gi(t,r){var i=qe;qe|=2;var c=gf();(Tt!==t||Rt!==r)&&(Mn=null,wr(t,r));do try{vy();break}catch(d){pf(t,d)}while(!0);if(Ko(),qe=i,ci.current=c,wt!==null)throw Error(a(261));return Tt=null,Rt=0,kt}function vy(){for(;wt!==null;)yf(wt)}function xy(){for(;wt!==null&&!Hp();)yf(wt)}function yf(t){var r=jf(t.alternate,t,nn);t.memoizedProps=t.pendingProps,r===null?vf(t):wt=r,Nl.current=null}function vf(t){var r=t;do{var i=r.alternate;if(t=r.return,(r.flags&32768)===0){if(i=dy(i,r,nn),i!==null){wt=i;return}}else{if(i=fy(i,r),i!==null){i.flags&=32767,wt=i;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{kt=6,wt=null;return}}if(r=r.sibling,r!==null){wt=r;return}wt=r=t}while(r!==null);kt===0&&(kt=5)}function jr(t,r,i){var c=et,d=cn.transition;try{cn.transition=null,et=1,wy(t,r,i,c)}finally{cn.transition=d,et=c}return null}function wy(t,r,i,c){do as();while(sr!==null);if((qe&6)!==0)throw Error(a(327));i=t.finishedWork;var d=t.finishedLanes;if(i===null)return null;if(t.finishedWork=null,t.finishedLanes=0,i===t.current)throw Error(a(177));t.callbackNode=null,t.callbackPriority=0;var m=i.lanes|i.childLanes;if(eg(t,m),t===Tt&&(wt=Tt=null,Rt=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||fi||(fi=!0,Sf(wa,function(){return as(),null})),m=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||m){m=cn.transition,cn.transition=null;var w=et;et=1;var C=qe;qe|=4,Nl.current=null,my(t,i),lf(i,t),Bg(_o),Ea=!!$o,_o=$o=null,t.current=i,py(i),Vp(),qe=C,et=w,cn.transition=m}else t.current=i;if(fi&&(fi=!1,sr=t,hi=d),m=t.pendingLanes,m===0&&(rr=null),qp(i.stateNode),Yt(t,yt()),r!==null)for(c=t.onRecoverableError,i=0;i<r.length;i++)d=r[i],c(d.value,{componentStack:d.stack,digest:d.digest});if(di)throw di=!1,t=Tl,Tl=null,t;return(hi&1)!==0&&t.tag!==0&&as(),m=t.pendingLanes,(m&1)!==0?t===Al?qs++:(qs=0,Al=t):qs=0,Zn(),null}function as(){if(sr!==null){var t=au(hi),r=cn.transition,i=et;try{if(cn.transition=null,et=16>t?16:t,sr===null)var c=!1;else{if(t=sr,sr=null,hi=0,(qe&6)!==0)throw Error(a(331));var d=qe;for(qe|=4,je=t.current;je!==null;){var m=je,w=m.child;if((je.flags&16)!==0){var C=m.deletions;if(C!==null){for(var R=0;R<C.length;R++){var V=C[R];for(je=V;je!==null;){var ae=je;switch(ae.tag){case 0:case 11:case 15:Vs(8,ae,m)}var ce=ae.child;if(ce!==null)ce.return=ae,je=ce;else for(;je!==null;){ae=je;var se=ae.sibling,we=ae.return;if(nf(ae),ae===V){je=null;break}if(se!==null){se.return=we,je=se;break}je=we}}}var be=m.alternate;if(be!==null){var Ne=be.child;if(Ne!==null){be.child=null;do{var vt=Ne.sibling;Ne.sibling=null,Ne=vt}while(Ne!==null)}}je=m}}if((m.subtreeFlags&2064)!==0&&w!==null)w.return=m,je=w;else e:for(;je!==null;){if(m=je,(m.flags&2048)!==0)switch(m.tag){case 0:case 11:case 15:Vs(9,m,m.return)}var M=m.sibling;if(M!==null){M.return=m.return,je=M;break e}je=m.return}}var _=t.current;for(je=_;je!==null;){w=je;var D=w.child;if((w.subtreeFlags&2064)!==0&&D!==null)D.return=w,je=D;else e:for(w=_;je!==null;){if(C=je,(C.flags&2048)!==0)try{switch(C.tag){case 0:case 11:case 15:li(9,C)}}catch(Ee){ht(C,C.return,Ee)}if(C===w){je=null;break e}var he=C.sibling;if(he!==null){he.return=C.return,je=he;break e}je=C.return}}if(qe=d,Zn(),Nn&&typeof Nn.onPostCommitFiberRoot=="function")try{Nn.onPostCommitFiberRoot(ja,t)}catch{}c=!0}return c}finally{et=i,cn.transition=r}}return!1}function xf(t,r,i){r=ts(i,r),r=zd(t,r,1),t=tr(t,r,1),r=Dt(),t!==null&&(vs(t,1,r),Yt(t,r))}function ht(t,r,i){if(t.tag===3)xf(t,t,i);else for(;r!==null;){if(r.tag===3){xf(r,t,i);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(rr===null||!rr.has(c))){t=ts(i,t),t=Fd(r,t,1),r=tr(r,t,1),t=Dt(),r!==null&&(vs(r,1,t),Yt(r,t));break}}r=r.return}}function jy(t,r,i){var c=t.pingCache;c!==null&&c.delete(r),r=Dt(),t.pingedLanes|=t.suspendedLanes&i,Tt===t&&(Rt&i)===i&&(kt===4||kt===3&&(Rt&130023424)===Rt&&500>yt()-El?wr(t,0):Cl|=i),Yt(t,r)}function wf(t,r){r===0&&((t.mode&1)===0?r=1:(r=ba,ba<<=1,(ba&130023424)===0&&(ba=4194304)));var i=Dt();t=Ln(t,r),t!==null&&(vs(t,r,i),Yt(t,i))}function Sy(t){var r=t.memoizedState,i=0;r!==null&&(i=r.retryLane),wf(t,i)}function by(t,r){var i=0;switch(t.tag){case 13:var c=t.stateNode,d=t.memoizedState;d!==null&&(i=d.retryLane);break;case 19:c=t.stateNode;break;default:throw Error(a(314))}c!==null&&c.delete(r),wf(t,i)}var jf;jf=function(t,r,i){if(t!==null)if(t.memoizedProps!==r.pendingProps||Vt.current)Kt=!0;else{if((t.lanes&i)===0&&(r.flags&128)===0)return Kt=!1,uy(t,r,i);Kt=(t.flags&131072)!==0}else Kt=!1,ct&&(r.flags&1048576)!==0&&Zu(r,Va,r.index);switch(r.lanes=0,r.tag){case 2:var c=r.type;ii(t,r),t=r.pendingProps;var d=Kr(r,$t.current);Zr(r,i),d=sl(null,r,c,t,d,i);var m=al();return r.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,Gt(c)?(m=!0,Ua(r)):m=!1,r.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,Qo(r),d.updater=si,r.stateNode=d,d._reactInternals=r,dl(r,c,t,i),r=pl(null,r,c,!0,m,i)):(r.tag=0,ct&&m&&Do(r),Bt(null,r,d,i),r=r.child),r;case 16:c=r.elementType;e:{switch(ii(t,r),t=r.pendingProps,d=c._init,c=d(c._payload),r.type=c,d=r.tag=Ny(c),t=gn(c,t),d){case 0:r=ml(null,r,c,t,i);break e;case 1:r=Gd(null,r,c,t,i);break e;case 11:r=Dd(null,r,c,t,i);break e;case 14:r=Ud(null,r,c,gn(c.type,t),i);break e}throw Error(a(306,c,""))}return r;case 0:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),ml(t,r,c,d,i);case 1:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),Gd(t,r,c,d,i);case 3:e:{if(Kd(r),t===null)throw Error(a(387));c=r.pendingProps,m=r.memoizedState,d=m.element,ld(t,r),Qa(r,c,null,i);var w=r.memoizedState;if(c=w.element,m.isDehydrated)if(m={element:c,isDehydrated:!1,cache:w.cache,pendingSuspenseBoundaries:w.pendingSuspenseBoundaries,transitions:w.transitions},r.updateQueue.baseState=m,r.memoizedState=m,r.flags&256){d=ts(Error(a(423)),r),r=qd(t,r,c,i,d);break e}else if(c!==d){d=ts(Error(a(424)),r),r=qd(t,r,c,i,d);break e}else for(tn=Jn(r.stateNode.containerInfo.firstChild),en=r,ct=!0,pn=null,i=id(r,null,c,i),r.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Jr(),c===d){r=Fn(t,r,i);break e}Bt(t,r,c,i)}r=r.child}return r;case 5:return dd(r),t===null&&Ho(r),c=r.type,d=r.pendingProps,m=t!==null?t.memoizedProps:null,w=d.children,Lo(c,d)?w=null:m!==null&&Lo(c,m)&&(r.flags|=32),Vd(t,r),Bt(t,r,w,i),r.child;case 6:return t===null&&Ho(r),null;case 13:return Yd(t,r,i);case 4:return Xo(r,r.stateNode.containerInfo),c=r.pendingProps,t===null?r.child=Qr(r,null,c,i):Bt(t,r,c,i),r.child;case 11:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),Dd(t,r,c,d,i);case 7:return Bt(t,r,r.pendingProps,i),r.child;case 8:return Bt(t,r,r.pendingProps.children,i),r.child;case 12:return Bt(t,r,r.pendingProps.children,i),r.child;case 10:e:{if(c=r.type._context,d=r.pendingProps,m=r.memoizedProps,w=d.value,st(qa,c._currentValue),c._currentValue=w,m!==null)if(mn(m.value,w)){if(m.children===d.children&&!Vt.current){r=Fn(t,r,i);break e}}else for(m=r.child,m!==null&&(m.return=r);m!==null;){var C=m.dependencies;if(C!==null){w=m.child;for(var R=C.firstContext;R!==null;){if(R.context===c){if(m.tag===1){R=zn(-1,i&-i),R.tag=2;var V=m.updateQueue;if(V!==null){V=V.shared;var ae=V.pending;ae===null?R.next=R:(R.next=ae.next,ae.next=R),V.pending=R}}m.lanes|=i,R=m.alternate,R!==null&&(R.lanes|=i),Yo(m.return,i,r),C.lanes|=i;break}R=R.next}}else if(m.tag===10)w=m.type===r.type?null:m.child;else if(m.tag===18){if(w=m.return,w===null)throw Error(a(341));w.lanes|=i,C=w.alternate,C!==null&&(C.lanes|=i),Yo(w,i,r),w=m.sibling}else w=m.child;if(w!==null)w.return=m;else for(w=m;w!==null;){if(w===r){w=null;break}if(m=w.sibling,m!==null){m.return=w.return,w=m;break}w=w.return}m=w}Bt(t,r,d.children,i),r=r.child}return r;case 9:return d=r.type,c=r.pendingProps.children,Zr(r,i),d=on(d),c=c(d),r.flags|=1,Bt(t,r,c,i),r.child;case 14:return c=r.type,d=gn(c,r.pendingProps),d=gn(c.type,d),Ud(t,r,c,d,i);case 15:return Wd(t,r,r.type,r.pendingProps,i);case 17:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),ii(t,r),r.tag=1,Gt(c)?(t=!0,Ua(r)):t=!1,Zr(r,i),_d(r,c,d),dl(r,c,d,i),pl(null,r,c,!0,t,i);case 19:return Qd(t,r,i);case 22:return Hd(t,r,i)}throw Error(a(156,r.tag))};function Sf(t,r){return eu(t,r)}function ky(t,r,i,c){this.tag=t,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function un(t,r,i,c){return new ky(t,r,i,c)}function Ll(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Ny(t){if(typeof t=="function")return Ll(t)?1:0;if(t!=null){if(t=t.$$typeof,t===F)return 11;if(t===te)return 14}return 2}function or(t,r){var i=t.alternate;return i===null?(i=un(t.tag,r,t.key,t.mode),i.elementType=t.elementType,i.type=t.type,i.stateNode=t.stateNode,i.alternate=t,t.alternate=i):(i.pendingProps=r,i.type=t.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=t.flags&14680064,i.childLanes=t.childLanes,i.lanes=t.lanes,i.child=t.child,i.memoizedProps=t.memoizedProps,i.memoizedState=t.memoizedState,i.updateQueue=t.updateQueue,r=t.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},i.sibling=t.sibling,i.index=t.index,i.ref=t.ref,i}function yi(t,r,i,c,d,m){var w=2;if(c=t,typeof t=="function")Ll(t)&&(w=1);else if(typeof t=="string")w=5;else e:switch(t){case K:return Sr(i.children,d,m,r);case z:w=8,d|=8;break;case U:return t=un(12,i,r,d|2),t.elementType=U,t.lanes=m,t;case ne:return t=un(13,i,r,d),t.elementType=ne,t.lanes=m,t;case fe:return t=un(19,i,r,d),t.elementType=fe,t.lanes=m,t;case ke:return vi(i,d,m,r);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case ee:w=10;break e;case X:w=9;break e;case F:w=11;break e;case te:w=14;break e;case ge:w=16,c=null;break e}throw Error(a(130,t==null?t:typeof t,""))}return r=un(w,i,r,d),r.elementType=t,r.type=c,r.lanes=m,r}function Sr(t,r,i,c){return t=un(7,t,c,r),t.lanes=i,t}function vi(t,r,i,c){return t=un(22,t,c,r),t.elementType=ke,t.lanes=i,t.stateNode={isHidden:!1},t}function zl(t,r,i){return t=un(6,t,null,r),t.lanes=i,t}function Fl(t,r,i){return r=un(4,t.children!==null?t.children:[],t.key,r),r.lanes=i,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}function Cy(t,r,i,c,d){this.tag=r,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=co(0),this.expirationTimes=co(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=co(0),this.identifierPrefix=c,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function Ml(t,r,i,c,d,m,w,C,R){return t=new Cy(t,r,i,C,R),r===1?(r=1,m===!0&&(r|=8)):r=0,m=un(3,null,null,r),t.current=m,m.stateNode=t,m.memoizedState={element:c,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Qo(m),t}function Ey(t,r,i){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:c==null?null:""+c,children:t,containerInfo:r,implementation:i}}function bf(t){if(!t)return Xn;t=t._reactInternals;e:{if(bn(t)!==t||t.tag!==1)throw Error(a(170));var r=t;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Gt(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(a(171))}if(t.tag===1){var i=t.type;if(Gt(i))return Ju(t,i,r)}return r}function kf(t,r,i,c,d,m,w,C,R){return t=Ml(i,c,!0,t,d,m,w,C,R),t.context=bf(null),i=t.current,c=Dt(),d=ar(i),m=zn(c,d),m.callback=r??null,tr(i,m,d),t.current.lanes=d,vs(t,d,c),Yt(t,c),t}function xi(t,r,i,c){var d=r.current,m=Dt(),w=ar(d);return i=bf(i),r.context===null?r.context=i:r.pendingContext=i,r=zn(m,w),r.payload={element:t},c=c===void 0?null:c,c!==null&&(r.callback=c),t=tr(d,r,w),t!==null&&(xn(t,d,w,m),Ja(t,d,w)),w}function wi(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function Nf(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var i=t.retryLane;t.retryLane=i!==0&&i<r?i:r}}function Ol(t,r){Nf(t,r),(t=t.alternate)&&Nf(t,r)}function Ty(){return null}var Cf=typeof reportError=="function"?reportError:function(t){console.error(t)};function Bl(t){this._internalRoot=t}ji.prototype.render=Bl.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(a(409));xi(t,r,null,null)},ji.prototype.unmount=Bl.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;xr(function(){xi(null,t,null,null)}),r[Rn]=null}};function ji(t){this._internalRoot=t}ji.prototype.unstable_scheduleHydration=function(t){if(t){var r=lu();t={blockedOn:null,target:t,priority:r};for(var i=0;i<Kn.length&&r!==0&&r<Kn[i].priority;i++);Kn.splice(i,0,t),i===0&&du(t)}};function Dl(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Si(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function Ef(){}function Ay(t,r,i,c,d){if(d){if(typeof c=="function"){var m=c;c=function(){var V=wi(w);m.call(V)}}var w=kf(r,c,t,0,null,!1,!1,"",Ef);return t._reactRootContainer=w,t[Rn]=w.current,Ps(t.nodeType===8?t.parentNode:t),xr(),w}for(;d=t.lastChild;)t.removeChild(d);if(typeof c=="function"){var C=c;c=function(){var V=wi(R);C.call(V)}}var R=Ml(t,0,!1,null,null,!1,!1,"",Ef);return t._reactRootContainer=R,t[Rn]=R.current,Ps(t.nodeType===8?t.parentNode:t),xr(function(){xi(r,R,i,c)}),R}function bi(t,r,i,c,d){var m=i._reactRootContainer;if(m){var w=m;if(typeof d=="function"){var C=d;d=function(){var R=wi(w);C.call(R)}}xi(r,w,t,d)}else w=Ay(i,r,t,d,c);return wi(w)}iu=function(t){switch(t.tag){case 3:var r=t.stateNode;if(r.current.memoizedState.isDehydrated){var i=ys(r.pendingLanes);i!==0&&(uo(r,i|1),Yt(r,yt()),(qe&6)===0&&(ss=yt()+500,Zn()))}break;case 13:xr(function(){var c=Ln(t,1);if(c!==null){var d=Dt();xn(c,t,1,d)}}),Ol(t,1)}},fo=function(t){if(t.tag===13){var r=Ln(t,134217728);if(r!==null){var i=Dt();xn(r,t,134217728,i)}Ol(t,134217728)}},ou=function(t){if(t.tag===13){var r=ar(t),i=Ln(t,r);if(i!==null){var c=Dt();xn(i,t,r,c)}Ol(t,r)}},lu=function(){return et},cu=function(t,r){var i=et;try{return et=t,r()}finally{et=i}},rt=function(t,r,i){switch(r){case"input":if(ze(t,i),r=i.name,i.type==="radio"&&r!=null){for(i=t;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<i.length;r++){var c=i[r];if(c!==t&&c.form===t.form){var d=Ba(c);if(!d)throw Error(a(90));Se(c),ze(c,d)}}}break;case"textarea":Me(t,i);break;case"select":r=i.value,r!=null&&Ye(t,!!i.multiple,r,!1)}},de=Pl,Ce=xr;var Iy={usingClientEntryPoint:!1,Events:[Ls,Vr,Ba,St,Xt,Pl]},Ys={findFiberByHostInstance:dr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Ry={bundleType:Ys.bundleType,version:Ys.version,rendererPackageName:Ys.rendererPackageName,rendererConfig:Ys.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:I.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=kn(t),t===null?null:t.stateNode},findFiberByHostInstance:Ys.findFiberByHostInstance||Ty,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 ki=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ki.isDisabled&&ki.supportsFiber)try{ja=ki.inject(Ry),Nn=ki}catch{}}return Jt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Iy,Jt.createPortal=function(t,r){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Dl(r))throw Error(a(200));return Ey(t,r,null,i)},Jt.createRoot=function(t,r){if(!Dl(t))throw Error(a(299));var i=!1,c="",d=Cf;return r!=null&&(r.unstable_strictMode===!0&&(i=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onRecoverableError!==void 0&&(d=r.onRecoverableError)),r=Ml(t,1,!1,null,null,i,!1,c,d),t[Rn]=r.current,Ps(t.nodeType===8?t.parentNode:t),new Bl(r)},Jt.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var r=t._reactInternals;if(r===void 0)throw typeof t.render=="function"?Error(a(188)):(t=Object.keys(t).join(","),Error(a(268,t)));return t=kn(r),t=t===null?null:t.stateNode,t},Jt.flushSync=function(t){return xr(t)},Jt.hydrate=function(t,r,i){if(!Si(r))throw Error(a(200));return bi(null,t,r,!0,i)},Jt.hydrateRoot=function(t,r,i){if(!Dl(t))throw Error(a(405));var c=i!=null&&i.hydratedSources||null,d=!1,m="",w=Cf;if(i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(m=i.identifierPrefix),i.onRecoverableError!==void 0&&(w=i.onRecoverableError)),r=kf(r,null,t,1,i??null,d,!1,m,w),t[Rn]=r.current,Ps(t),c)for(t=0;t<c.length;t++)i=c[t],d=i._getVersion,d=d(i._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[i,d]:r.mutableSourceEagerHydrationData.push(i,d);return new ji(r)},Jt.render=function(t,r,i){if(!Si(r))throw Error(a(200));return bi(null,t,r,!1,i)},Jt.unmountComponentAtNode=function(t){if(!Si(t))throw Error(a(40));return t._reactRootContainer?(xr(function(){bi(null,null,t,!1,function(){t._reactRootContainer=null,t[Rn]=null})}),!0):!1},Jt.unstable_batchedUpdates=Pl,Jt.unstable_renderSubtreeIntoContainer=function(t,r,i,c){if(!Si(i))throw Error(a(200));if(t==null||t._reactInternals===void 0)throw Error(a(38));return bi(t,r,i,!1,c)},Jt.version="18.3.1-next-f1338f8080-20240426",Jt}var Lf;function qh(){if(Lf)return Hl.exports;Lf=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(s){console.error(s)}}return e(),Hl.exports=By(),Hl.exports}var zf;function Dy(){if(zf)return Ni;zf=1;var e=qh();return Ni.createRoot=e.createRoot,Ni.hydrateRoot=e.hydrateRoot,Ni}var Uy=Dy();/**
|
|
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 kc=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Yh=/^[\\/]{2}/;function Wy(e,s){return s+e.replace(/\\/g,"/")}var Ff="popstate";function Mf(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Hy(e={}){function s(o,l){var v;let u=(v=l.state)==null?void 0:v.masked,{pathname:f,search:p,hash:g}=u||o.location;return lc("",{pathname:f,search:p,hash:g},l.state&&l.state.usr||null,l.state&&l.state.key||"default",u?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function a(o,l){return typeof l=="string"?l:Tr(l)}return Gy(s,a,null,e)}function ut(e,s){if(e===!1||e===null||typeof e>"u")throw new Error(s)}function fn(e,s){if(!e){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function Vy(){return Math.random().toString(36).substring(2,10)}function Of(e,s){return{usr:e.state,key:e.key,idx:s,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function lc(e,s,a=null,o,l){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof s=="string"?fs(s):s,state:a,key:s&&s.key||o||Vy(),mask:l}}function Tr({pathname:e="/",search:s="",hash:a=""}){return s&&s!=="?"&&(e+=s.charAt(0)==="?"?s:"?"+s),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function fs(e){let s={};if(e){let a=e.indexOf("#");a>=0&&(s.hash=e.substring(a),e=e.substring(0,a));let o=e.indexOf("?");o>=0&&(s.search=e.substring(o),e=e.substring(0,o)),e&&(s.pathname=e)}return s}function Gy(e,s,a,o={}){let{window:l=document.defaultView,v5Compat:u=!1}=o,f=l.history,p="POP",g=null,v=y();v==null&&(v=0,f.replaceState({...f.state,idx:v},""));function y(){return(f.state||{idx:null}).idx}function x(){p="POP";let N=y(),E=N==null?null:N-v;v=N,g&&g({action:p,location:S.location,delta:E})}function j(N,E){p="PUSH";let T=Mf(N)?N:lc(S.location,N,E);v=y()+1;let P=Of(T,v),I=S.createHref(T.mask||T);try{f.pushState(P,"",I)}catch(B){if(B instanceof DOMException&&B.name==="DataCloneError")throw B;l.location.assign(I)}u&&g&&g({action:p,location:S.location,delta:1})}function k(N,E){p="REPLACE";let T=Mf(N)?N:lc(S.location,N,E);v=y();let P=Of(T,v),I=S.createHref(T.mask||T);f.replaceState(P,"",I),u&&g&&g({action:p,location:S.location,delta:0})}function b(N){return Ky(l,N)}let S={get action(){return p},get location(){return e(l,f)},listen(N){if(g)throw new Error("A history only accepts one active listener");return l.addEventListener(Ff,x),g=N,()=>{l.removeEventListener(Ff,x),g=null}},createHref(N){return s(l,N)},createURL:b,encodeLocation(N){let E=b(N);return{pathname:E.pathname,search:E.search,hash:E.hash}},push:j,replace:k,go(N){return f.go(N)}};return S}function Ky(e,s,a=!1){let o="http://localhost";e&&(o=e.location.origin!=="null"?e.location.origin:e.location.href),ut(o,"No window.location.(origin|href) available to create URL");let l=typeof s=="string"?s:Tr(s);return l=l.replace(/ $/,"%20"),!a&&Yh.test(l)&&(l=o+l),new URL(l,o)}function Jh(e,s,a="/"){return qy(e,s,a,!1)}function qy(e,s,a,o,l){let u=typeof s=="string"?fs(s):s,f=Dn(u.pathname||"/",a);if(f==null)return null;let p=Yy(e),g=null,v=iv(f);for(let y=0;g==null&&y<p.length;++y)g=av(p[y],v,o);return g}function Yy(e){let s=Qh(e);return Jy(s),s}function Qh(e,s=[],a=[],o="",l=!1){let u=(f,p,g=l,v)=>{let y={relativePath:v===void 0?f.path||"":v,caseSensitive:f.caseSensitive===!0,childrenIndex:p,route:f};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&g)return;ut(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let x=wn([o,y.relativePath]),j=a.concat(y);f.children&&f.children.length>0&&(ut(f.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${x}".`),Qh(f.children,s,j,x,g)),!(f.path==null&&!f.index)&&s.push({path:x,score:rv(x,f.index),routesMeta:j.map((k,b)=>{let[S,N]=em(k.relativePath,k.caseSensitive,b===j.length-1);return{...k,matcher:S,compiledParams:N}})})};return e.forEach((f,p)=>{var g;if(f.path===""||!((g=f.path)!=null&&g.includes("?")))u(f,p);else for(let v of Xh(f.path))u(f,p,!0,v)}),s}function Xh(e){let s=e.split("/");if(s.length===0)return[];let[a,...o]=s,l=a.endsWith("?"),u=a.replace(/\?$/,"");if(o.length===0)return l?[u,""]:[u];let f=Xh(o.join("/")),p=[];return p.push(...f.map(g=>g===""?u:[u,g].join("/"))),l&&p.push(...f),p.map(g=>e.startsWith("/")&&g===""?"/":g)}function Jy(e){e.sort((s,a)=>s.score!==a.score?a.score-s.score:sv(s.routesMeta.map(o=>o.childrenIndex),a.routesMeta.map(o=>o.childrenIndex)))}var Qy=/^:[\w-]+$/,Xy=3,Zy=2,ev=1,tv=10,nv=-2,Bf=e=>e==="*";function rv(e,s){let a=e.split("/"),o=a.length;return a.some(Bf)&&(o+=nv),s&&(o+=Zy),a.filter(l=>!Bf(l)).reduce((l,u)=>l+(Qy.test(u)?Xy:u===""?ev:tv),o)}function sv(e,s){return e.length===s.length&&e.slice(0,-1).every((o,l)=>o===s[l])?e[e.length-1]-s[s.length-1]:0}function av(e,s,a=!1){let{routesMeta:o}=e,l={},u="/",f=[];for(let p=0;p<o.length;++p){let g=o[p],v=p===o.length-1,y=u==="/"?s:s.slice(u.length)||"/",x={path:g.relativePath,caseSensitive:g.caseSensitive,end:v},j=g.matcher&&g.compiledParams?Zh(x,y,g.matcher,g.compiledParams):zi(x,y),k=g.route;if(!j&&v&&a&&!o[o.length-1].route.index&&(j=zi({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},y)),!j)return null;Object.assign(l,j.params),f.push({params:l,pathname:wn([u,j.pathname]),pathnameBase:cv(wn([u,j.pathnameBase])),route:k}),j.pathnameBase!=="/"&&(u=wn([u,j.pathnameBase]))}return f}function zi(e,s){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[a,o]=em(e.path,e.caseSensitive,e.end);return Zh(e,s,a,o)}function Zh(e,s,a,o){let l=s.match(a);if(!l)return null;let u=l[0],f=us(u,1),p=l.slice(1);return{params:o.reduce((v,{paramName:y,isOptional:x},j)=>{if(y==="*"){let b=p[j]||"";f=us(u.slice(0,u.length-b.length),1)}const k=p[j];return x&&!k?v[y]=void 0:v[y]=(k||"").replace(/%2F/g,"/"),v},{}),pathname:u,pathnameBase:f,pattern:e}}function em(e,s=!1,a=!0){fn(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let o=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(f,p,g,v,y)=>{if(o.push({paramName:p,isOptional:g!=null}),g){let x=y.charAt(v+f.length);return x&&x!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(o.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,s?void 0:"i"),o]}function iv(e){try{return e.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return fn(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),e}}function Dn(e,s){if(s==="/")return e;if(!e.toLowerCase().startsWith(s.toLowerCase()))return null;let a=s.endsWith("/")?s.length-1:s.length,o=e.charAt(a);return o&&o!=="/"?null:e.slice(a)||"/"}function ov(e,s="/"){let{pathname:a,search:o="",hash:l=""}=typeof e=="string"?fs(e):e,u;return a?(a=tm(a),a.startsWith("/")||a.startsWith("\\")?u=Df(a.substring(1),"/"):u=Df(a,s)):u=s,{pathname:u,search:uv(o),hash:dv(l)}}function Df(e,s){let a=us(s).split("/");return e.split("/").forEach(l=>{l===".."?a.length>1&&a.pop():l!=="."&&a.push(l)}),a.length>1?a.join("/"):"/"}function Kl(e,s,a,o){return`Cannot include a '${e}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function lv(e){return e.filter((s,a)=>a===0||s.route.path&&s.route.path.length>0)}function Nc(e){let s=lv(e);return s.map((a,o)=>o===s.length-1?a.pathname:a.pathnameBase)}function Ji(e,s,a,o=!1){let l;typeof e=="string"?l=fs(e):(l={...e},ut(!l.pathname||!l.pathname.includes("?"),Kl("?","pathname","search",l)),ut(!l.pathname||!l.pathname.includes("#"),Kl("#","pathname","hash",l)),ut(!l.search||!l.search.includes("#"),Kl("#","search","hash",l)));let u=e===""||l.pathname==="",f=u?"/":l.pathname,p;if(f==null)p=a;else{let x=s.length-1;if(!o&&f.startsWith("..")){let j=f.split("/");for(;j[0]==="..";)j.shift(),x-=1;l.pathname=j.join("/")}p=x>=0?s[x]:"/"}let g=ov(l,p),v=f&&f!=="/"&&f.endsWith("/"),y=(u||f===".")&&a.endsWith("/");return!g.pathname.endsWith("/")&&(v||y)&&(g.pathname+="/"),g}var tm=e=>e.replace(/[\\/]{2,}/g,"/"),wn=e=>tm(e.join("/"));function us(e,s=0){let a=e.length;for(;a>s&&e.charCodeAt(a-1)===47;)a--;return a===e.length?e:e.slice(0,a)}var cv=e=>us(e).replace(/^\/*/,"/"),uv=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,dv=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,fv=class{constructor(e,s,a,o=!1){this.status=e,this.statusText=s||"",this.internal=o,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function hv(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function mv(e){let s=e.map(a=>a.route.path).filter(Boolean);return wn(s)||"/"}var nm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function rm(e,s){let a=e;if(typeof a!="string"||!kc.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let o=a,l=!1;if(nm)try{let u=new URL(window.location.href),f=Yh.test(a)?new URL(Wy(a,u.protocol)):new URL(a),p=Dn(f.pathname,s);f.origin===u.origin&&p!=null?a=p+f.search+f.hash:l=!0}catch{fn(!1,`<Link to="${a}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:l,to:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Uf=new URL("http://localhost");function Cc(e){if(e.createURL)return e.createURL("/");try{return new URL(e.createHref("/"),Uf)}catch{return Uf}}function ql(e,s){return e.origin===s.origin&&(e.origin!=="null"||e.protocol===s.protocol&&e.host===s.host)}function pv(e,s){if(e.startsWith("//"))return!0;let a=s.protocol.toLowerCase();return e.toLowerCase().startsWith(a)?s.host===""||e.slice(a.length).startsWith("//"):!1}function Ec(e,s,a,o){let l=null;try{l=e==null?null:new URL(e,a)}catch{}let u=new URL(s,a),f=l!=null&&!ql(l,a),p=!ql(u,a);if(o==="reject"){if(f||p)throw new Error("External navigation is not allowed")}else if(p&&(l==null||!pv(e,l)||!ql(l,u)))throw new Error("External navigation is not allowed")}var sm=["POST","PUT","PATCH","DELETE"];new Set(sm);var gv=["GET",...sm];new Set(gv);var yv=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function vv(e){try{return yv.includes(new URL(e).protocol)}catch{return!1}}var hs=h.createContext(null);hs.displayName="DataRouter";var Qi=h.createContext(null);Qi.displayName="DataRouterState";var am=h.createContext(!1);function xv(){return h.useContext(am)}var im=h.createContext({isTransitioning:!1});im.displayName="ViewTransition";var wv=h.createContext(new Map);wv.displayName="Fetchers";var jv=h.createContext(null);jv.displayName="Await";var rn=h.createContext(null);rn.displayName="Navigation";var fa=h.createContext(null);fa.displayName="Location";var jn=h.createContext({outlet:null,matches:[],isDataRoute:!1});jn.displayName="Route";var Tc=h.createContext(null);Tc.displayName="RouteError";var om="REACT_ROUTER_ERROR",Sv="REDIRECT",bv="ROUTE_ERROR_RESPONSE";function kv(e){if(e.startsWith(`${om}:${Sv}:{`))try{let s=JSON.parse(e.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 Nv(e){if(e.startsWith(`${om}:${bv}:{`))try{let s=JSON.parse(e.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new fv(s.status,s.statusText,s.data)}catch{}}function Cv(e,{relative:s}={}){ut(ms(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:o}=h.useContext(rn),{hash:l,pathname:u,search:f}=ha(e,{relative:s}),p=u;return a!=="/"&&(p=u==="/"?a:wn([a,u])),o.createHref({pathname:p,search:f,hash:l})}function ms(){return h.useContext(fa)!=null}function Qt(){return ut(ms(),"useLocation() may be used only in the context of a <Router> component."),h.useContext(fa).location}var lm="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function cm(e){h.useContext(rn).static||h.useLayoutEffect(e)}function Sn(){let{isDataRoute:e}=h.useContext(jn);return e?Dv():Ev()}function Ev(){ut(ms(),"useNavigate() may be used only in the context of a <Router> component.");let e=h.useContext(hs),{basename:s,navigator:a}=h.useContext(rn),{matches:o}=h.useContext(jn),{pathname:l}=Qt(),u=JSON.stringify(Nc(o)),f=h.useRef(!1);return cm(()=>{f.current=!0}),h.useCallback((g,v={})=>{if(fn(f.current,lm),!f.current)return;if(typeof g=="number"){a.go(g);return}let y=Ji(g,JSON.parse(u),l,v.relative==="path");e==null&&s!=="/"&&(y.pathname=y.pathname==="/"?s:wn([s,y.pathname])),Ec(typeof g=="string"?g:Tr(g),a.createHref(y),Cc(a),"reject"),(v.replace?a.replace:a.push)(y,v.state,v)},[s,a,u,l,e])}var Tv=h.createContext(null);function Av(e){let s=h.useContext(jn).outlet;return h.useMemo(()=>s&&h.createElement(Tv.Provider,{value:e},s),[s,e])}function ha(e,{relative:s}={}){let{matches:a}=h.useContext(jn),{pathname:o}=Qt(),l=JSON.stringify(Nc(a));return h.useMemo(()=>Ji(e,JSON.parse(l),o,s==="path"),[e,l,o,s])}function Iv(e,s){return um(e,s)}function um(e,s,a){var N;ut(ms(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=h.useContext(rn),{matches:l}=h.useContext(jn),u=l[l.length-1],f=u?u.params:{},p=u?u.pathname:"/",g=u?u.pathnameBase:"/",v=u&&u.route;{let E=v&&v.path||"";fm(p,!v||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${p}" (under <Route path="${E}">) 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="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let y=Qt(),x;if(s){let E=typeof s=="string"?fs(s):s;ut(g==="/"||((N=E.pathname)==null?void 0:N.startsWith(g)),`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 "${g}" but pathname "${E.pathname}" was given in the \`location\` prop.`),x=E}else x=y;let j=x.pathname||"/",k=j;if(g!=="/"){let E=g.replace(/^\//,"").split("/");k="/"+j.replace(/^\//,"").split("/").slice(E.length).join("/")}let b=a&&a.state.matches.length?a.state.matches.map(E=>Object.assign(E,{route:a.manifest[E.route.id]||E.route})):Jh(e,{pathname:k});fn(v||b!=null,`No routes matched location "${x.pathname}${x.search}${x.hash}" `),fn(b==null||b[b.length-1].route.element!==void 0||b[b.length-1].route.Component!==void 0||b[b.length-1].route.lazy!==void 0,`Matched leaf route at location "${x.pathname}${x.search}${x.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 S=Lv(b&&b.map(E=>Object.assign({},E,{params:Object.assign({},f,E.params),pathname:wn([g,o.encodeLocation?o.encodeLocation(E.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?g:wn([g,o.encodeLocation?o.encodeLocation(E.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),l,a);return s&&S?h.createElement(fa.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...x},navigationType:"POP"}},S):S}function Rv(){let e=Bv(),s=hv(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),a=e instanceof Error?e.stack:null,o="rgba(200,200,200, 0.5)",l={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},f=null;return console.error("Error handled by React Router default ErrorBoundary:",e),f=h.createElement(h.Fragment,null,h.createElement("p",null,"💿 Hey developer 👋"),h.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",h.createElement("code",{style:u},"ErrorBoundary")," or"," ",h.createElement("code",{style:u},"errorElement")," prop on your route.")),h.createElement(h.Fragment,null,h.createElement("h2",null,"Unexpected Application Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},s),a?h.createElement("pre",{style:l},a):null,f)}var Pv=h.createElement(Rv,null),dm=class extends h.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,s){return s.location!==e.location||s.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:s.error,location:s.location,revalidation:e.revalidation||s.revalidation}}componentDidCatch(e,s){this.props.onError?this.props.onError(e,s):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const a=Nv(e.digest);a&&(e=a)}let s=e!==void 0?h.createElement(jn.Provider,{value:this.props.routeContext},h.createElement(Tc.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?h.createElement($v,{error:e},s):s}};dm.contextType=am;var Yl=new WeakMap;function $v({children:e,error:s}){let{basename:a,navigator:o}=h.useContext(rn);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let l=kv(s.digest);if(l){let u=Yl.get(s);if(u)throw u;let f=rm(l.location,a),p=f.absoluteURL||f.to;if(Ec(l.location,p,Cc(o),"allow-explicit"),vv(p))throw new Error("Invalid redirect location");if(nm&&!Yl.get(s))if(f.isExternal||l.reloadDocument)window.location.href=p;else{const g=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(f.to,{replace:l.replace}));throw Yl.set(s,g),g}return h.createElement("meta",{httpEquiv:"refresh",content:`0;url=${p}`})}}return e}function _v({routeContext:e,match:s,children:a}){let o=h.useContext(hs);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),h.createElement(jn.Provider,{value:e},a)}function Lv(e,s=[],a){let o=a==null?void 0:a.state;if(e==null){if(!o)return null;if(o.errors)e=o.matches;else if(s.length===0&&!o.initialized&&o.matches.length>0)e=o.matches;else return null}let l=e,u=o==null?void 0:o.errors;if(u!=null){let y=l.findIndex(x=>x.route.id&&(u==null?void 0:u[x.route.id])!==void 0);ut(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),l=l.slice(0,Math.min(l.length,y+1))}let f=!1,p=-1;if(a&&o){f=o.renderFallback;for(let y=0;y<l.length;y++){let x=l[y];if((x.route.HydrateFallback||x.route.hydrateFallbackElement)&&(p=y),x.route.id){let{loaderData:j,errors:k}=o,b=x.route.loader&&!j.hasOwnProperty(x.route.id)&&(!k||k[x.route.id]===void 0);if(x.route.lazy||b){a.isStatic&&(f=!0),p>=0?l=l.slice(0,p+1):l=[l[0]];break}}}}let g=a==null?void 0:a.onError,v=o&&g?(y,x)=>{var j,k;g(y,{location:o.location,params:((k=(j=o.matches)==null?void 0:j[0])==null?void 0:k.params)??{},pattern:mv(o.matches),errorInfo:x})}:void 0;return l.reduceRight((y,x,j)=>{let k,b=!1,S=null,N=null;o&&(k=u&&x.route.id?u[x.route.id]:void 0,S=x.route.errorElement||Pv,f&&(p<0&&j===0?(fm("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,N=null):p===j&&(b=!0,N=x.route.hydrateFallbackElement||null)));let E=s.concat(l.slice(0,j+1)),T=()=>{let P;return k?P=S:b?P=N:x.route.Component?P=h.createElement(x.route.Component,null):x.route.element?P=x.route.element:P=y,h.createElement(_v,{match:x,routeContext:{outlet:y,matches:E,isDataRoute:o!=null},children:P})};return o&&(x.route.ErrorBoundary||x.route.errorElement||j===0)?h.createElement(dm,{location:o.location,revalidation:o.revalidation,component:S,error:k,children:T(),routeContext:{outlet:null,matches:E,isDataRoute:!0},onError:v}):T()},null)}function Ac(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function zv(e){let s=h.useContext(hs);return ut(s,Ac(e)),s}function Fv(e){let s=h.useContext(Qi);return ut(s,Ac(e)),s}function Mv(e){let s=h.useContext(jn);return ut(s,Ac(e)),s}function Ic(e){let s=Mv(e),a=s.matches[s.matches.length-1];return ut(a.route.id,`${e} can only be used on routes that contain a unique "id"`),a.route.id}function Ov(){return Ic("useRouteId")}function Bv(){var o;let e=h.useContext(Tc),s=Fv("useRouteError"),a=Ic("useRouteError");return e!==void 0?e:(o=s.errors)==null?void 0:o[a]}function Dv(){let{router:e}=zv("useNavigate"),s=Ic("useNavigate"),a=h.useRef(!1);return cm(()=>{a.current=!0}),h.useCallback(async(l,u={})=>{fn(a.current,lm),a.current&&(typeof l=="number"?await e.navigate(l):await e.navigate(l,{fromRouteId:s,...u}))},[e,s])}var Wf={};function fm(e,s,a){!s&&!Wf[e]&&(Wf[e]=!0,fn(!1,a))}h.memo(Uv);function Uv({routes:e,manifest:s,future:a,state:o,isStatic:l,onError:u}){return um(e,void 0,{manifest:s,state:o,isStatic:l,onError:u})}function On({to:e,replace:s,state:a,relative:o}){ut(ms(),"<Navigate> may be used only in the context of a <Router> component.");let{static:l,navigator:u}=h.useContext(rn);fn(!l,"<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:f}=h.useContext(jn),{pathname:p}=Qt(),g=Sn(),v=Ji(e,Nc(f),p,o==="path");Ec(typeof e=="string"?e:Tr(e),u.createHref(v),Cc(u),"reject");let y=JSON.stringify(v);return h.useEffect(()=>{g(JSON.parse(y),{replace:s,state:a,relative:o})},[g,y,o,s,a]),null}function Wv(e){return Av(e.context)}function at(e){ut(!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 Hv({basename:e="/",children:s=null,location:a,navigationType:o="POP",navigator:l,static:u=!1,useTransitions:f}){ut(!ms(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let p=e.replace(/^\/*/,"/"),g=h.useMemo(()=>({basename:p,navigator:l,static:u,useTransitions:f,future:{}}),[p,l,u,f]);typeof a=="string"&&(a=fs(a));let{pathname:v="/",search:y="",hash:x="",state:j=null,key:k="default",mask:b}=a,S=h.useMemo(()=>{let N=Dn(v,p);return N==null?null:{location:{pathname:N,search:y,hash:x,state:j,key:k,mask:b},navigationType:o}},[p,v,y,x,j,k,o,b]);return fn(S!=null,`<Router basename="${p}"> is not able to match the URL "${v}${y}${x}" because it does not start with the basename, so the <Router> won't render anything.`),S==null?null:h.createElement(rn.Provider,{value:g},h.createElement(fa.Provider,{children:s,value:S}))}function Vv({children:e,location:s}){return Iv(cc(e),s)}function cc(e,s=[]){let a=[];return h.Children.forEach(e,(o,l)=>{if(!h.isValidElement(o))return;let u=[...s,l];if(o.type===h.Fragment){a.push.apply(a,cc(o.props.children,u));return}ut(o.type===at,`[${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>`),ut(!o.props.index||!o.props.children,"An index route cannot have child routes.");let f={id:o.props.id||u.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&&(f.children=cc(o.props.children,u)),a.push(f)}),a}var $i="get",_i="application/x-www-form-urlencoded";function Xi(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Gv(e){return Xi(e)&&e.tagName.toLowerCase()==="button"}function Kv(e){return Xi(e)&&e.tagName.toLowerCase()==="form"}function qv(e){return Xi(e)&&e.tagName.toLowerCase()==="input"}function Yv(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Jv(e,s){return e.button===0&&(!s||s==="_self")&&!Yv(e)}function uc(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((s,a)=>{let o=e[a];return s.concat(Array.isArray(o)?o.map(l=>[a,l]):[[a,o]])},[]))}function Qv(e,s){let a=uc(e);return s&&s.forEach((o,l)=>{a.has(l)||s.getAll(l).forEach(u=>{a.append(l,u)})}),a}var Ci=null;function Xv(){if(Ci===null)try{new FormData(document.createElement("form"),0),Ci=!1}catch{Ci=!0}return Ci}var Zv=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Jl(e){return e!=null&&!Zv.has(e)?(fn(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${_i}"`),null):e}function ex(e,s){let a,o,l,u,f;if(Kv(e)){let p=e.getAttribute("action");o=p?Dn(p,s):null,a=e.getAttribute("method")||$i,l=Jl(e.getAttribute("enctype"))||_i,u=new FormData(e)}else if(Gv(e)||qv(e)&&(e.type==="submit"||e.type==="image")){let p=e.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=e.getAttribute("formaction")||p.getAttribute("action");if(o=g?Dn(g,s):null,a=e.getAttribute("formmethod")||p.getAttribute("method")||$i,l=Jl(e.getAttribute("formenctype"))||Jl(p.getAttribute("enctype"))||_i,u=new FormData(p,e),!Xv()){let{name:v,type:y,value:x}=e;if(y==="image"){let j=v?`${v}.`:"";u.append(`${j}x`,"0"),u.append(`${j}y`,"0")}else v&&u.append(v,x)}}else{if(Xi(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=$i,o=null,l=_i,f=e}return u&&l==="text/plain"&&(f=u,u=void 0),{action:o,method:a.toLowerCase(),encType:l,formData:u,body:f}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Rc(e,s){if(e===!1||e===null||typeof e>"u")throw new Error(s)}function hm(e,s,a,o){let l=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return a?l.pathname.endsWith("/")?l.pathname=`${l.pathname}_.${o}`:l.pathname=`${l.pathname}.${o}`:l.pathname==="/"?l.pathname=`_root.${o}`:s&&Dn(l.pathname,s)==="/"?l.pathname=`${us(s)}/_root.${o}`:l.pathname=`${us(l.pathname)}.${o}`,l}async function tx(e,s){if(e.id in s)return s[e.id];try{let a=await import(e.module);return s[e.id]=a,a}catch(a){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function nx(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function rx(e,s,a){let o=await Promise.all(e.map(async l=>{let u=s.routes[l.route.id];if(u){let f=await tx(u,a);return f.links?f.links():[]}return[]}));return ox(o.flat(1).filter(nx).filter(l=>l.rel==="stylesheet"||l.rel==="preload").map(l=>l.rel==="stylesheet"?{...l,rel:"prefetch",as:"style"}:{...l,rel:"prefetch"}))}function Hf(e,s,a,o,l,u){let f=(g,v)=>a[v]?g.route.id!==a[v].route.id:!0,p=(g,v)=>{var y;return a[v].pathname!==g.pathname||((y=a[v].route.path)==null?void 0:y.endsWith("*"))&&a[v].params["*"]!==g.params["*"]};return u==="assets"?s.filter((g,v)=>f(g,v)||p(g,v)):u==="data"?s.filter((g,v)=>{var x;let y=o.routes[g.route.id];if(!y||!y.hasLoader)return!1;if(f(g,v)||p(g,v))return!0;if(g.route.shouldRevalidate){let j=g.route.shouldRevalidate({currentUrl:new URL(l.pathname+l.search+l.hash,window.origin),currentParams:((x=a[0])==null?void 0:x.params)||{},nextUrl:new URL(e,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof j=="boolean")return j}return!0}):[]}function sx(e,s,{includeHydrateFallback:a}={}){return ax(e.map(o=>{let l=s.routes[o.route.id];if(!l)return[];let u=[l.module];return l.clientActionModule&&(u=u.concat(l.clientActionModule)),l.clientLoaderModule&&(u=u.concat(l.clientLoaderModule)),a&&l.hydrateFallbackModule&&(u=u.concat(l.hydrateFallbackModule)),l.imports&&(u=u.concat(l.imports)),u}).flat(1))}function ax(e){return[...new Set(e)]}function ix(e){let s={},a=Object.keys(e).sort();for(let o of a)s[o]=e[o];return s}function ox(e,s){let a=new Set;return new Set(s),e.reduce((o,l)=>{let u=JSON.stringify(ix(l));return a.has(u)||(a.add(u),o.push({key:u,link:l})),o},[])}function Pc(){let e=h.useContext(hs);return Rc(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function lx(){let e=h.useContext(Qi);return Rc(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var $c=h.createContext(void 0);$c.displayName="FrameworkContext";function Zi(){let e=h.useContext($c);return Rc(e,"You must render this element inside a <HydratedRouter> element"),e}function cx(e,s){let a=h.useContext($c),[o,l]=h.useState(!1),[u,f]=h.useState(!1),{onFocus:p,onBlur:g,onMouseEnter:v,onMouseLeave:y,onTouchStart:x}=s,j=h.useRef(null);h.useEffect(()=>{if(e==="render"&&f(!0),e==="viewport"){let S=E=>{E.forEach(T=>{f(T.isIntersecting)})},N=new IntersectionObserver(S,{threshold:.5});return j.current&&N.observe(j.current),()=>{N.disconnect()}}},[e]),h.useEffect(()=>{if(o){let S=setTimeout(()=>{f(!0)},100);return()=>{clearTimeout(S)}}},[o]);let k=()=>{l(!0)},b=()=>{l(!1),f(!1)};return a?e!=="intent"?[u,j,{}]:[u,j,{onFocus:Xs(p,k),onBlur:Xs(g,b),onMouseEnter:Xs(v,k),onMouseLeave:Xs(y,b),onTouchStart:Xs(x,k)}]:[!1,j,{}]}function Xs(e,s){return a=>{e&&e(a),a.defaultPrevented||s(a)}}function ux({page:e,...s}){let a=xv(),{nonce:o}=Zi(),{router:l}=Pc(),u=h.useMemo(()=>Jh(l.routes,e,l.basename),[l.routes,e,l.basename]);return u?(s.nonce==null&&o&&(s={...s,nonce:o}),a?h.createElement(fx,{page:e,matches:u,...s}):h.createElement(hx,{page:e,matches:u,...s})):null}function dx(e){let{manifest:s,routeModules:a}=Zi(),[o,l]=h.useState([]);return h.useEffect(()=>{let u=!1;return rx(e,s,a).then(f=>{u||l(f)}),()=>{u=!0}},[e,s,a]),o}function fx({page:e,matches:s,...a}){let o=Qt(),{future:l}=Zi(),{basename:u}=Pc(),f=h.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let p=hm(e,u,l.v8_trailingSlashAwareDataRequests,"rsc"),g=!1,v=[];for(let y of s)typeof y.route.shouldRevalidate=="function"?g=!0:v.push(y.route.id);return g&&v.length>0&&p.searchParams.set("_routes",v.join(",")),[p.pathname+p.search]},[u,l.v8_trailingSlashAwareDataRequests,e,o,s]);return h.createElement(h.Fragment,null,f.map(p=>h.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...a})))}function hx({page:e,matches:s,...a}){let o=Qt(),{future:l,manifest:u,routeModules:f}=Zi(),{basename:p}=Pc(),{loaderData:g,matches:v}=lx(),y=h.useMemo(()=>Hf(e,s,v,u,o,"data"),[e,s,v,u,o]),x=h.useMemo(()=>Hf(e,s,v,u,o,"assets"),[e,s,v,u,o]),j=h.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let S=new Set,N=!1;if(s.forEach(T=>{var I;let P=u.routes[T.route.id];!P||!P.hasLoader||(!y.some(B=>B.route.id===T.route.id)&&T.route.id in g&&((I=f[T.route.id])!=null&&I.shouldRevalidate)||P.hasClientLoader?N=!0:S.add(T.route.id))}),S.size===0)return[];let E=hm(e,p,l.v8_trailingSlashAwareDataRequests,"data");return N&&S.size>0&&E.searchParams.set("_routes",s.filter(T=>S.has(T.route.id)).map(T=>T.route.id).join(",")),[E.pathname+E.search]},[p,l.v8_trailingSlashAwareDataRequests,g,o,u,y,s,e,f]),k=h.useMemo(()=>sx(x,u),[x,u]),b=dx(x);return h.createElement(h.Fragment,null,j.map(S=>h.createElement("link",{key:S,rel:"prefetch",as:"fetch",href:S,...a})),k.map(S=>h.createElement("link",{key:S,rel:"modulepreload",href:S,...a})),b.map(({key:S,link:N})=>h.createElement("link",{key:S,nonce:a.nonce,...N,crossOrigin:N.crossOrigin??a.crossOrigin})))}function mx(...e){return s=>{e.forEach(a=>{typeof a=="function"?a(s):a!=null&&(a.current=s)})}}var px=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{px&&(window.__reactRouterVersion="7.18.4")}catch{}function gx({basename:e,children:s,useTransitions:a,window:o}){let l=h.useRef();l.current==null&&(l.current=Hy({window:o,v5Compat:!0}));let u=l.current,[f,p]=h.useState({action:u.action,location:u.location}),g=h.useCallback(v=>{a===!1?p(v):h.startTransition(()=>p(v))},[a]);return h.useLayoutEffect(()=>u.listen(g),[u,g]),h.createElement(Hv,{basename:e,children:s,location:f.location,navigationType:f.action,navigator:u,useTransitions:a})}var mt=h.forwardRef(function({onClick:s,discover:a="render",prefetch:o="none",relative:l,reloadDocument:u,replace:f,mask:p,state:g,target:v,to:y,preventScrollReset:x,viewTransition:j,defaultShouldRevalidate:k,...b},S){let{basename:N,navigator:E,useTransitions:T}=h.useContext(rn),P=typeof y=="string"&&kc.test(y),I=rm(y,N);y=I.to;let B=Cv(y,{relative:l}),O=Qt(),K=null;if(p){let te=Ji(p,[],O.mask?O.mask.pathname:"/",!0);N!=="/"&&(te.pathname=te.pathname==="/"?N:wn([N,te.pathname])),K=E.createHref(te)}let[z,U,ee]=cx(o,b),X=xx(y,{replace:f,mask:p,state:g,target:v,preventScrollReset:x,relative:l,viewTransition:j,defaultShouldRevalidate:k,useTransitions:T});function F(te){s&&s(te),te.defaultPrevented||X(te)}let ne=!(I.isExternal||u),fe=h.createElement("a",{...b,...ee,href:(ne?K:void 0)||I.absoluteURL||B,onClick:ne?F:s,ref:mx(S,U),target:v,"data-discover":!P&&a==="render"?"true":void 0});return z&&!P?h.createElement(h.Fragment,null,fe,h.createElement(ux,{page:B})):fe});mt.displayName="Link";var _c=h.forwardRef(function({"aria-current":s="page",caseSensitive:a=!1,className:o="",end:l=!1,style:u,to:f,viewTransition:p,children:g,...v},y){let x=ha(f,{relative:v.relative}),j=Qt(),k=h.useContext(Qi),{navigator:b,basename:S}=h.useContext(rn),N=k!=null&&kx(x)&&p===!0,E=b.encodeLocation?b.encodeLocation(x).pathname:x.pathname,T=j.pathname,P=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;a||(T=T.toLowerCase(),P=P?P.toLowerCase():null,E=E.toLowerCase()),P&&S&&(P=Dn(P,S)||P);const I=E!=="/"&&E.endsWith("/")?E.length-1:E.length;let B=T===E||!l&&T.startsWith(E)&&T.charAt(I)==="/",O=P!=null&&(P===E||!l&&P.startsWith(E)&&P.charAt(E.length)==="/"),K={isActive:B,isPending:O,isTransitioning:N},z=B?s:void 0,U;typeof o=="function"?U=o(K):U=[o,B?"active":null,O?"pending":null,N?"transitioning":null].filter(Boolean).join(" ");let ee=typeof u=="function"?u(K):u;return h.createElement(mt,{...v,"aria-current":z,className:U,ref:y,style:ee,to:f,viewTransition:p},typeof g=="function"?g(K):g)});_c.displayName="NavLink";var yx=h.forwardRef(({discover:e="render",fetcherKey:s,navigate:a,reloadDocument:o,replace:l,state:u,method:f=$i,action:p,onSubmit:g,relative:v,preventScrollReset:y,viewTransition:x,defaultShouldRevalidate:j,...k},b)=>{let{useTransitions:S}=h.useContext(rn),N=Sx(),E=bx(p,{relative:v}),T=f.toLowerCase()==="get"?"get":"post",P=typeof p=="string"&&kc.test(p),I=B=>{if(g&&g(B),B.defaultPrevented)return;B.preventDefault();let O=B.nativeEvent.submitter,K=(O==null?void 0:O.getAttribute("formmethod"))||f,z=()=>N(O||B.currentTarget,{fetcherKey:s,method:K,navigate:a,replace:l,state:u,relative:v,preventScrollReset:y,viewTransition:x,defaultShouldRevalidate:j});S&&a!==!1?h.startTransition(()=>z()):z()};return h.createElement("form",{ref:b,method:T,action:E,onSubmit:o?g:I,...k,"data-discover":!P&&e==="render"?"true":void 0})});yx.displayName="Form";function vx(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function mm(e){let s=h.useContext(hs);return ut(s,vx(e)),s}function xx(e,{target:s,replace:a,mask:o,state:l,preventScrollReset:u,relative:f,viewTransition:p,defaultShouldRevalidate:g,useTransitions:v}={}){let y=Sn(),x=Qt(),j=ha(e,{relative:f});return h.useCallback(k=>{if(Jv(k,s)){k.preventDefault();let b=a!==void 0?a:Tr(x)===Tr(j),S=()=>y(e,{replace:b,mask:o,state:l,preventScrollReset:u,relative:f,viewTransition:p,defaultShouldRevalidate:g});v?h.startTransition(()=>S()):S()}},[x,y,j,a,o,l,s,e,u,f,p,g,v])}function ps(e){fn(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=h.useRef(uc(e)),a=h.useRef(!1),o=Qt(),l=h.useMemo(()=>Qv(o.search,a.current?null:s.current),[o.search]),u=Sn(),f=h.useCallback((p,g)=>{const v=uc(typeof p=="function"?p(new URLSearchParams(l)):p);a.current=!0,u("?"+v,g)},[u,l]);return[l,f]}var wx=0,jx=()=>`__${String(++wx)}__`;function Sx(){let{router:e}=mm("useSubmit"),{basename:s}=h.useContext(rn),a=Ov(),o=e.fetch,l=e.navigate;return h.useCallback(async(u,f={})=>{let{action:p,method:g,encType:v,formData:y,body:x}=ex(u,s);if(f.navigate===!1){let j=f.fetcherKey||jx();await o(j,a,f.action||p,{defaultShouldRevalidate:f.defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:x,formMethod:f.method||g,formEncType:f.encType||v,flushSync:f.flushSync})}else await l(f.action||p,{defaultShouldRevalidate:f.defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:x,formMethod:f.method||g,formEncType:f.encType||v,replace:f.replace,state:f.state,fromRouteId:a,flushSync:f.flushSync,viewTransition:f.viewTransition})},[o,l,s,a])}function bx(e,{relative:s}={}){let{basename:a}=h.useContext(rn),o=h.useContext(jn);ut(o,"useFormAction must be used inside a RouteContext");let[l]=o.matches.slice(-1),u={...ha(e||".",{relative:s})},f=Qt();if(e==null){u.search=f.search;let p=new URLSearchParams(u.search),g=p.getAll("index");if(g.some(y=>y==="")){p.delete("index"),g.filter(x=>x).forEach(x=>p.append("index",x));let y=p.toString();u.search=y?`?${y}`:""}}return(!e||e===".")&&l.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(u.pathname=u.pathname==="/"?a:wn([a,u.pathname])),Tr(u)}function kx(e,{relative:s}={}){let a=h.useContext(im);ut(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=mm("useViewTransitionState"),l=ha(e,{relative:s});if(!a.isTransitioning)return!1;let u=Dn(a.currentLocation.pathname,o)||a.currentLocation.pathname,f=Dn(a.nextLocation.pathname,o)||a.nextLocation.pathname;return zi(l.pathname,f)!=null||zi(l.pathname,u)!=null}var Nx=qh();const Cr="owner";function Cx(e){const s=e||Cr;return s===Cr?[Cr]:[s,Cr]}function Ex(e){const s=new Map;for(const a of e)for(const o of a)s.has(o.id)||s.set(o.id,o);return[...s.values()].sort((a,o)=>o.createdAt-a.createdAt)}function Tx(e,s){const a=s||Cr,o=(e==null?void 0:e.pendingDomains)??[];return o.includes(a)?a:o.includes(Cr)?Cr:a}class pm extends Error{constructor(a){super("different_account");Js(this,"summary");this.name="DifferentAccountError",this.summary=a}}function gm(e){return e.grantors??e.approvers}function Ax(e){return e.approvals??1}function He(e,s){const a=e??{},o=Array.isArray(a.errors)?a.errors[0]:void 0;return o!=null&&o.message?o.code?`${o.message} (${o.code})`:o.message:o!=null&&o.code?o.code:a.error||a.detail||s}function Ix(e){const s=e==null?void 0:e.pubkeys;return!s||typeof s!="object"||Array.isArray(s)?[]:Object.entries(s).filter(a=>typeof a[1]=="string"&&a[1].length>0).map(([a,o])=>({userId:a,publicKey:o}))}class Rx{constructor(){Js(this,"apiKey",null)}setApiKey(s){this.apiKey=s}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(s,a){return globalThis.fetch(s,{...a,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...a==null?void 0:a.headers}})}async login(s,a={}){const o=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":s,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:a.confirmWipe===!0})});if(o.status===409){const u=await o.json().catch(()=>({}));if(u!=null&&u.wouldWipe)throw new pm(u.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!o.ok){const u=await o.json().catch(()=>({error:"Invalid API key"}));throw new Error(He(u,`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 a=await s.json();return a.groups??a}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 a=await this.fetch(`/api/profiles/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch profile: ${a.status}`);return a.json()}async attest(s){const a=await this.fetch("/api/as/mandate",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(He(o,`Signing failed: ${a.status}`))}return a.json()}async getPending(s){const a=await this.fetch(`/api/mandates/pending?domain=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch pending: ${a.status}`);const o=await a.json();return o.pending??o}async getMyAttestations(s){const a=s?`?status=${encodeURIComponent(s)}`:"",o=await this.fetch(`/api/mandates/mine${a}`);if(!o.ok)throw new Error(`Failed to fetch attestations: ${o.status}`);return((await o.json()).mandates??[]).map(u=>{var f,p;return{authorization_id:u.authorization_id,profile_id:u.profileId,path:u.path,title:u.title??null,sp_status:u.status??null,frame:u.bounds??u.frame??{},required_domains:u.requiredDomains??[],attested_domains:u.attestedDomains??[],missing_domains:(u.requiredDomains??[]).filter(g=>!(u.attestedDomains??[]).includes(g)),deferred_commitment_domains:u.deferredCommitmentDomains??[],approvers_frozen:u.approversFrozen??[],above_cap:u.aboveCap??!1,created_at:u.createdAt?new Date(u.createdAt*1e3).toISOString():"",earliest_expiry:(f=u.attestations)!=null&&f.length?new Date(Math.min(...u.attestations.map(g=>g.expiresAt))*1e3).toISOString():null,remaining_seconds:(p=u.attestations)!=null&&p.length?Math.max(0,Math.min(...u.attestations.map(g=>g.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getDenials(s){const a=new URLSearchParams;s!=null&&s.since&&a.set("since",String(s.since)),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString()?`?${a.toString()}`:"",l=await this.fetch(`/denials${o}`);if(!l.ok)throw new Error(`Failed to fetch denials: ${l.status}`);return l.json()}async getMyReceipts(s){const a=new URLSearchParams;s!=null&&s.date&&a.set("date",s.date),s!=null&&s.profile&&a.set("profile",s.profile),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString(),l=await this.fetch(`/api/tickets/mine${o?"?"+o:""}`);if(!l.ok)throw new Error(`Failed to fetch receipts: ${l.status}`);return(await l.json()).tickets??[]}async fetchEvidenceBundle(){var l;const s=await this.fetch("/api/evidence-export"),a=await s.json();if(!s.ok)throw new Error(He(a,`Export failed (${s.status})`));const o=((l=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:l[1])??"suveren-evidence.json";return{bundle:a,filename:o}}async getLocalAuthorizations(){const s=await this.fetch("/api/evidence/authorizations");if(!s.ok)throw new Error(`Local evidence unavailable (${s.status})`);const a=await s.json();return{authorizations:a.authorizations??{},signatures:a.signatures??{}}}async getArchivedReceipt(s){const a=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(s)}`);if(a.status===404)return null;if(!a.ok)throw new Error(`Local evidence unavailable (${a.status})`);return await a.json()}async getTicketHeadlines(){const s=await this.fetch("/api/evidence/headlines");if(!s.ok)throw new Error(`Local evidence unavailable (${s.status})`);const a=await s.json();return(a==null?void 0:a.headlines)??{}}async getReport(){const s=await this.fetch("/api/report");if(!s.ok){const a=await s.json().catch(()=>({error:`Report unavailable (${s.status})`}));throw new Error(He(a,`Report unavailable (${s.status})`))}return s.json()}async saveReport(s){const a=await this.fetch("/api/report",{method:"POST",body:JSON.stringify({html:s})});if(!a.ok){const o=await a.json().catch(()=>({error:`Save failed (${a.status})`}));throw new Error(He(o,`Save failed (${a.status})`))}return a.json()}async recheckReport(){const s=await this.fetch("/api/report/recheck",{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:`Recheck failed (${s.status})`}));throw new Error(He(a,`Recheck failed (${s.status})`))}return s.json()}async exportReportWithProof(){var l;const s=await this.fetch("/api/report/export");if(!s.ok){const u=await s.json().catch(()=>({error:`Export failed (${s.status})`}));throw new Error(He(u,`Export failed (${s.status})`))}const a=await s.text(),o=((l=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:l[1])??"suveren-report.html";return{html:a,filename:o}}async revokeAttestation(s,a){const o=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/revoke`,{method:"POST",body:JSON.stringify({reason:a??"Revoked by user"})});if(!o.ok){const l=await o.json().catch(()=>({error:"Failed to revoke"}));throw new Error(He(l,`Revoke failed: ${o.status}`))}}async getAttestations(s){const a=await this.fetch(`/api/mandates?authorization_id=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch attestations: ${a.status}`);const o=await a.json();return{...o,attestations:o.mandates??o.attestations??[]}}async getGroupById(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch group: ${a.status}`);return a.json()}async createGroup(s){const a=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:s})});if(!a.ok){const u=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(He(u,`Create group failed: ${a.status}`))}const o=await a.json(),l=o.group||o;return{id:l.id,name:l.name,myDomains:l.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 a=await s.json().catch(()=>({error:"Unknown error"}));throw new Error(He(a,`Failed to preview team creation: ${s.status}`))}return s.json()}async getJoinPreview(s){const a=await this.fetch(`/api/groups/join/preview?inviteCode=${encodeURIComponent(s)}`);if(!a.ok){const o=await a.json().catch(()=>({error:"Invalid or expired invite code"}));throw new Error(He(o,`Invalid invite code: ${a.status}`))}return a.json()}async requestToJoinGroup(s){const a=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:s})});if(a.status!==202){const l=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(He(l,`Request to join failed: ${a.status}`))}return(await a.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(He(o,`Withdraw failed: ${s.status}`))}return(await s.json()).withdrawn===!0}async inviteToGroup(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/invite`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(He(o,`Invite failed: ${a.status}`))}return a.json()}async getMyTeam(){const s=await this.fetch("/api/groups/me");if(!s.ok)return{group:null,membership:null,pendingRequest:null};const a=await s.json();return{group:a.group??null,membership:a.membership??null,pendingRequest:a.pendingRequest??null}}async listUsers(){const s=await this.fetch("/api/users");return s.ok?(await s.json()).users??[]:[]}async setPubkey(s){const a=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:s})});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(He(o,`setPubkey failed: ${a.status}`))}}async getPubkey(s){const a=await this.fetch(`/api/users/${encodeURIComponent(s)}/pubkey`);return a.status===404||!a.ok?null:(await a.json()).pubkey??null}async leaveTeam(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/leave`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to leave team"}));throw new Error(He(o,`Leave failed: ${a.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 a=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error(`Failed to save settings: ${a.status}`);return a.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,a){const o=await this.fetch(`/api/archived-mandates/${encodeURIComponent(s)}`,{method:a?"PUT":"DELETE"});if(!o.ok)throw new Error(`Failed to ${a?"archive":"unarchive"} mandate: ${o.status}`);return(await o.json()).archived}async getLastSeenBlockedAt(){const s=await this.fetch("/api/blocked-seen");if(!s.ok)throw new Error(`Failed to load last-seen: ${s.status}`);return(await s.json()).lastSeenBlockedAt}async markBlockedSeen(s=Date.now()){const a=await this.fetch("/api/blocked-seen",{method:"POST",body:JSON.stringify({ts:s})});if(!a.ok)throw new Error(`Failed to mark blocked seen: ${a.status}`);return(await a.json()).lastSeenBlockedAt}async getLastSeenReportAt(){const s=await this.fetch("/api/report-seen");if(!s.ok)throw new Error(`Failed to load last-seen report: ${s.status}`);return(await s.json()).lastSeenReportAt}async markReportSeen(s=Date.now()){const a=await this.fetch("/api/report-seen",{method:"POST",body:JSON.stringify({ts:s})});if(!a.ok)throw new Error(`Failed to mark report seen: ${a.status}`);return(await a.json()).lastSeenReportAt}async getLastSeenTicketsAt(){const s=await this.fetch("/api/tickets-seen");if(!s.ok)throw new Error(`Failed to load last-seen tickets: ${s.status}`);return(await s.json()).lastSeenTicketsAt}async markTicketsSeen(s=Date.now()){const a=await this.fetch("/api/tickets-seen",{method:"POST",body:JSON.stringify({ts:s})});if(!a.ok)throw new Error(`Failed to mark tickets seen: ${a.status}`);return(await a.json()).lastSeenTicketsAt}async getCredential(s){const a=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to check credential: ${a.status}`);return a.json()}async setCredential(s,a){const o=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`,{method:"PUT",body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to save credential: ${o.status}`)}async testCredential(s){const a=await this.fetch(`/vault/test/${encodeURIComponent(s)}`,{method:"POST"});if(!a.ok)throw new Error(`Test failed: ${a.status}`);return a.json()}async aiAssist(s){const a=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:He(o,"AI request failed"),disclaimer:"AI surfaces reality. You supply intent."}}return a.json()}async aiIntentReview(s){const a=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:He(o,"AI request failed")}}return a.json()}async aiTest(s){const a=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`AI test failed: ${a.status}`);return a.json()}async aiModels(s){const a=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`Model list failed: ${a.status}`);return a.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 a=await this.fetch(`/auth/oauth/${encodeURIComponent(s)}/health`);return a.ok?await a.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 getLabelManifests(){const{manifests:s,builtins:a}=await this.getIntegrationManifests();return[...s??[],...a??[]]}async discoverScopeField(s,a){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/discover/${encodeURIComponent(a)}`);if(!o.ok){const l=await o.json().catch(()=>({error:`Discovery failed: ${o.status}`}));throw new Error(He(l,`Discovery failed: ${o.status}`))}return o.json()}async activateIntegration(s){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}/activate`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed"}));throw new Error(He(o,`Failed: ${a.status}`))}return a.json()}async removeMcpIntegration(s){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}`,{method:"DELETE"});if(!a.ok)throw new Error(`Failed to remove integration: ${a.status}`)}async setReadPolicy(s,a){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/read-policy`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAgeDays:a})});if(!o.ok){const l=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(He(l,`HTTP ${o.status}`))}}async getTeamProfileConfig(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`);if(o.status===404||!o.ok)return null;const l=await o.json();return(l==null?void 0:l.config)??null}async setTeamProfileConfig(s,a,o){const l=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(o)});if(!l.ok){const u=await l.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(He(u,`setTeamProfileConfig failed: ${l.status}`))}}async encryptIntent(s,a){const o=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:s,recipients:a})});if(!o.ok){const l=await o.json().catch(()=>({error:"Encryption failed"}));throw new Error(He(l,`encryptIntent failed: ${o.status}`))}return o.json()}async getToolDisplay(){const s=await this.fetch("/tool-display");if(!s.ok)return{};const a=await s.json();return(a==null?void 0:a.tools)??{}}async getApproversPubkeys(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}/approvers/pubkeys`);return o.ok?Ix(await o.json()):[]}async deleteTeamProfileConfig(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`,{method:"DELETE"});if(!o.ok){const l=await o.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(He(l,`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 a=await this.fetch("/api/users/me/identity-disclosure",{method:"PUT",body:JSON.stringify({always:s})});if(!a.ok)throw new Error(`Failed to save identity setting: ${a.status}`);return a.json()}async getProposals(s,a="pending"){const o=a==="all"?"&status=all":"",l=await this.fetch(`/api/proposals?domain=${encodeURIComponent(s)}${o}`);if(!l.ok)throw new Error(`Failed to fetch proposals: ${l.status}`);return(await l.json()).proposals??[]}async getMyProposals(s,a="pending"){const o=await Promise.all(Cx(s).map(l=>this.getProposals(l,a)));return Ex(o)}async resolveProposal(s,a,o,l){const{noteEncrypted:u,contentHash:f,shownHash:p,note:g,...v}=l??{},y=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/resolve`,{method:"POST",body:JSON.stringify({action:a,domain:o,...v,...u?{note_encrypted:u}:g?{note:g}:{},...f?{content_hash:f}:{},...p?{shown_hash:p}:{}})});if(!y.ok){const x=await y.json().catch(()=>({error:"Failed"}));throw new Error(He(x,`Failed: ${y.status}`))}return y.json()}async getProposal(s){const a=await this.fetch(`/api/proposals/${encodeURIComponent(s)}`);if(!a.ok){const l=await a.json().catch(()=>({error:"Failed"}));throw new Error(He(l,`getProposal failed: ${a.status}`))}const o=await a.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,a,o){const l={};a&&(l.content_hash=a),o&&(l.shown_hash=o);const u=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/approve`,{method:"POST",body:Object.keys(l).length>0?JSON.stringify(l):void 0});if(!u.ok){const f=await u.json().catch(()=>({error:"Failed"}));throw new Error(He(f,`approveProposal failed: ${u.status}`))}return u.json()}async rejectProposal(s,a,o,l){let u;if(typeof a=="string")u={reason:a};else{const{noteEncrypted:p,note:g,...v}=a??{};u={...v,...p?{note_encrypted:p}:g?{note:g}:{}}}o&&(u.content_hash=o),l&&(u.shown_hash=l);const f=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/reject`,{method:"POST",body:JSON.stringify(u)});if(!f.ok){const p=await f.json().catch(()=>({error:"Failed"}));throw new Error(He(p,`rejectProposal failed: ${f.status}`))}return f.json()}async getProposalsCreatedByMe(){const s=await this.fetch("/api/proposals?creator=me");if(s.status===400)return null;if(!s.ok)throw new Error(`Failed to fetch my proposals: ${s.status}`);return(await s.json()).proposals??[]}async withdrawProposal(s,a,o,l){const{noteEncrypted:u,note:f}=a??{},p={...u?{note_encrypted:u}:f?{note:f}:{}};o&&(p.content_hash=o),l&&(p.shown_hash=l);const g=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/withdraw`,{method:"POST",body:JSON.stringify(p)});if(!g.ok){const v=await g.json().catch(()=>({error:"Failed"}));throw new Error(He(v,`withdrawProposal failed: ${g.status}`))}return g.json()}async getProposalPreview(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/preview`);if(!a.ok)throw new Error(`Failed to fetch preview: ${a.status}`);return a.json()}async getProposalRequestContext(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/request-context`);if(!a.ok)throw new Error(`Failed to fetch request context: ${a.status}`);return a.json()}async saveShownSnapshot(s,a){const o=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/shown-snapshot`,{method:"POST",body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to store the shown snapshot: ${o.status}`);return o.json()}async getShownSnapshot(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/shown-snapshot`);if(!a.ok)throw new Error(`Failed to fetch the shown snapshot: ${a.status}`);return a.json()}async getProposalOutcome(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/outcome`);if(!a.ok)throw new Error(`Failed to fetch outcome: ${a.status}`);return a.json()}async getAttestationIntent(s){const a=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/intent`);return a.status===404||a.status===403||!a.ok?null:a.json()}async decryptIntent(s){const a=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const l=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(He(l,`decryptIntent failed: ${a.status}`))}return(await a.json()).intent}async decryptProposalContent(s){const a=await this.fetch("/api/decrypt-proposal-content",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(He(o,`decryptProposalContent failed: ${a.status}`))}return a.json()}async encryptProposalNote(s,a){const o=await this.fetch("/api/encrypt-proposal-note",{method:"POST",body:JSON.stringify({note:s,recipientUserIds:a})});if(!o.ok){const l=await o.json().catch(()=>({error:"Encryption failed"}));throw new Error(He(l,`encryptProposalNote failed: ${o.status}`))}return o.json()}async storeApprovedIntent(s,a){const o=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:s,intent:a})});if(!o.ok){const l=await o.json().catch(()=>({error:"Failed"}));throw new Error(He(l,`storeApprovedIntent failed: ${o.status}`))}}async listTeamAuthorizations(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/mandates`);if(!a.ok)throw new Error(`Failed to fetch team authorizations: ${a.status}`);return((await a.json()).mandates??[]).map(l=>{var p,g;const u=l.owner??{userId:""};return{authorization_id:l.authorization_id??l.authorizationId,profile_id:l.profileId??l.profile_id,path:l.path??"",title:l.title??null,sp_status:l.status??l.sp_status??null,frame:l.bounds??l.frame??{},required_domains:l.requiredDomains??l.required_domains??[],attested_domains:l.attestedDomains??l.attested_domains??[],missing_domains:(l.requiredDomains??l.required_domains??[]).filter(v=>!(l.attestedDomains??l.attested_domains??[]).includes(v)),deferred_commitment_domains:l.deferredCommitmentDomains??l.deferred_commitment_domains??[],approvers_frozen:l.approversFrozen??l.approvers_frozen??[],above_cap:l.aboveCap??l.above_cap??!1,created_at:l.createdAt?new Date(l.createdAt*1e3).toISOString():l.created_at??"",earliest_expiry:(p=l.mandates)!=null&&p.length?new Date(Math.min(...l.mandates.map(v=>v.expiresAt))*1e3).toISOString():null,remaining_seconds:(g=l.mandates)!=null&&g.length?Math.max(0,Math.min(...l.mandates.map(v=>v.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:u}})}async listTeamReceipts(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets`);if(!a.ok)throw new Error(`Failed to fetch team receipts: ${a.status}`);return(await a.json()).tickets??[]}async getMyReceiptsPage(s){const a=new URLSearchParams;s!=null&&s.before&&a.set("before",s.before),s!=null&&s.profile&&a.set("profile",s.profile),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString(),l=await this.fetch(`/api/tickets/mine${o?"?"+o:""}`);if(!l.ok)throw new Error(`Failed to fetch receipts: ${l.status}`);const u=await l.json();return{receipts:u.tickets??[],nextBefore:u.nextBefore??null}}async listTeamReceiptsPage(s,a){const o=new URLSearchParams;a!=null&&a.before&&o.set("before",a.before),a!=null&&a.profile&&o.set("profile",a.profile),a!=null&&a.limit&&o.set("limit",String(a.limit));const l=o.toString(),u=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets${l?"?"+l:""}`);if(!u.ok)throw new Error(`Failed to fetch team receipts: ${u.status}`);const f=await u.json();return{receipts:f.tickets??[],nextBefore:f.nextBefore??null}}async getThread(s){const a=s.sinceDays??7,o=s.status??"pending",l=await this.getMyProposals(s.domain,o);let u=[];if(o==="all"){const f=[],p=new Date;for(let v=0;v<a;v++){const y=new Date(p);y.setUTCDate(p.getUTCDate()-v),f.push(y.toISOString().slice(0,10))}u=(await Promise.all(f.map(v=>this.getMyReceipts({date:v,profile:s.profile})))).flat()}return{proposals:l,receipts:u}}async getAutostart(){const s=await this.fetch("/autostart");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async setAutostart(s){const a=await this.fetch("/autostart",{method:s?"POST":"DELETE"});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.message||`HTTP ${a.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 getMyPendingProposals(){const s=await this.fetch("/my-pending-proposals");return s.ok?(await s.json().catch(()=>({proposals:[]}))).proposals??[]:[]}async getGateContent(s){const a=await this.fetch(`/gate-content?path=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch gate content: ${a.status}`);return(await a.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 a=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(He(o,`Push gate content failed: ${a.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 a=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:s})});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(He(o,`Save failed: ${a.status}`))}}async aiChat(s){const a=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI chat failed"}));return{success:!1,error:He(o,`Chat failed: ${a.status}`)}}return a.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,a){const o=await this.fetch(`/ai-prompts/${s}`,{method:"PUT",body:JSON.stringify({value:a})});if(!o.ok){const l=await o.json().catch(()=>({error:"Save failed"}));throw new Error(He(l,`Save failed: ${o.status}`))}}}const L=new Rx,ym=h.createContext(null);function Px({children:e}){const[s,a]=h.useState(null),[o,l]=h.useState("personal"),[u,f]=h.useState(null),[p,g]=h.useState(""),[v,y]=h.useState(null),[x,j]=h.useState(null),[k,b]=h.useState(null),[S,N]=h.useState(!1),[E,T]=h.useState(""),P=h.useRef(!1),I=h.useRef(null),B=h.useCallback(async()=>{if(P.current)try{const X=await L.getMyTeam();if(b(X.pendingRequest),X.group&&X.membership){const{group:F,membership:ne}=X;y(F),j(ne),l("team"),f(F);const fe=I.current??ne.domains[0]??"owner";g(fe)}else y(null),j(null),l("personal")}catch{}},[]);h.useEffect(()=>{const X=()=>{document.visibilityState==="visible"&&B()};return document.addEventListener("visibilitychange",X),()=>document.removeEventListener("visibilitychange",X)},[B]),h.useEffect(()=>{fetch("/health").then(X=>X.json()).then(X=>{var F;((F=X.session)==null?void 0:F.lockedReason)==="as-url-changed"&&T(`Authority Server changed to ${X.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const O=h.useCallback(async(X,F={})=>{N(!0),T("");try{L.setApiKey(X),P.current=!0;const ne=await L.login(X,F);a(ne),I.current=ne.id;const fe=await L.getGroups(),te=fe.find(ge=>ge.isPersonal)??fe[0]??null;f(te),g("owner"),await B()}catch(ne){throw L.clearApiKey(),P.current=!1,T(ne instanceof Error?ne.message:"Login failed"),ne}finally{N(!1)}},[B]),K=h.useCallback(async()=>{await L.logout(),L.clearApiKey(),P.current=!1,I.current=null,a(null),f(null),g(""),y(null),j(null),b(null),l("personal"),T("")},[]),z=h.useCallback(X=>{L.clearApiKey(),P.current=!1,I.current=null,a(null),f(null),g(""),y(null),j(null),b(null),l("personal"),T(X??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),U=h.useCallback(()=>T(""),[]),ee=h.useCallback((X,F)=>{f(X),g(F)},[]);return n.jsx(ym.Provider,{value:{user:s,mode:o,group:u,domain:p,groupId:(u==null?void 0:u.id)??null,activeTeam:v,activeMembership:x,pendingRequest:k,isLoading:S,error:E,login:O,logout:K,clearError:U,handleSessionLocked:z,activeGroup:u,activeDomain:p,groups:u?[u]:[],setActiveContext:ee,refreshGroups:B},children:e})}function xt(){const e=h.useContext(ym);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const $x={"integration-changed":!0,"attestation-changed":!0,"proposal-added":!0,"proposal-resolved":!0,"team-membership-changed":!0,"action-approval-needed":!0,"action-resolved":!0,"proposal-approved":!0,"proposal-rejected":!0,"session-locked":!0,"execution-failed":!0,"denial-recorded":!0,"ticket-recorded":!0,"report-written":!0},_x=Object.keys($x),vm=h.createContext(null);function Lx({children:e}){const{user:s}=xt(),a=h.useRef(null),[o,l]=h.useState(!1),u=h.useRef(new Map),f=h.useCallback((p,g)=>{const v=u.current;return v.has(p)||v.set(p,new Set),v.get(p).add(g),()=>{var y;(y=v.get(p))==null||y.delete(g)}},[]);return h.useEffect(()=>{if(!s){a.current&&(a.current.close(),a.current=null,l(!1));return}if(a.current)return;const p=L.getApiKey();if(!p)return;const g=new EventSource(`/events?key=${encodeURIComponent(p)}`);a.current=g,g.onopen=()=>l(!0),g.onerror=()=>l(!1);for(const v of _x)g.addEventListener(v,y=>{let x;try{x=JSON.parse(y.data)}catch{x=null}const j=u.current.get(v);if(j)for(const k of j)try{k(x)}catch(b){console.error(`[EventSource] handler for "${v}" threw:`,b)}});return()=>{g.close(),a.current=null,l(!1)}},[s]),n.jsx(vm.Provider,{value:{connected:o,addListener:f},children:e})}function Fe(e,s){const a=h.useContext(vm);if(!a)return;const{addListener:o}=a;h.useEffect(()=>o(e,s),[e,s,o])}const aa="suveren-theme",Vf="hap-theme";function Ei(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const s=localStorage.getItem(Vf);s!==null&&localStorage.getItem(aa)===null&&localStorage.setItem(aa,s),s!==null&&localStorage.removeItem(Vf)})();function xm(){const[e,s]=h.useState(()=>{const u=localStorage.getItem(aa);return u==="light"||u==="dark"?u:"system"}),[a,o]=h.useState(()=>Ei(e));h.useEffect(()=>{const u=document.documentElement,f=Ei(e);u.setAttribute("data-theme",f),e==="system"?localStorage.removeItem(aa):localStorage.setItem(aa,e),o(Ei(e))},[e]),h.useEffect(()=>{if(e!=="system")return;const u=window.matchMedia("(prefers-color-scheme: dark)"),f=()=>o(Ei("system"));return u.addEventListener("change",f),()=>u.removeEventListener("change",f)},[e]);const l=h.useCallback(()=>{s(u=>u==="system"?"light":u==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:a,toggle:l}}const zx=300*1e3,Fx=2e3;function Lc(){const[e,s]=h.useState(!1),[a,o]=h.useState("docker"),[l,u]=h.useState(""),[f,p]=h.useState(null),[g,v]=h.useState(!1),[y,x]=h.useState(!1),[j,k]=h.useState(!1),b=h.useRef(null);return h.useEffect(()=>{let S=!1;const N=(P=!1)=>{fetch(P?"/health?refresh=1":"/health").then(I=>I.json()).then(I=>{S||(I.installMethod&&o(I.installMethod),typeof I.latestVersion<"u"&&p(I.latestVersion),I.updateAvailable&&s(!0),I.version&&(u(I.version),b.current===null?b.current=I.version:I.version!==b.current&&I.version!=="dev"&&v(!0)))}).catch(()=>{})};N(!0);const E=setInterval(()=>N(!1),j?Fx:zx),T=()=>{document.visibilityState==="visible"&&N(!1)};return document.addEventListener("visibilitychange",T),window.addEventListener("focus",T),()=>{S=!0,clearInterval(E),document.removeEventListener("visibilitychange",T),window.removeEventListener("focus",T)}},[j]),{updateAvailable:e&&!y,installMethod:a,version:l,latestVersion:f,serverRestarted:g,startFastPolling:()=>k(!0),dismiss:()=>x(!0)}}function Mx(e){return!e||typeof e!="object"?{managed:!1}:{managed:Array.isArray(e.policyLocked)&&e.policyLocked.includes("team")}}function Ox(){const[e,s]=h.useState({managed:!1});return h.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(Mx(o))}).catch(()=>{}),()=>{a=!0}},[]),e}function Bx({size:e=20}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[n.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),n.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function Dx(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const Gf={system:"◑",light:"☀",dark:"☾"};function zc({onMenuToggle:e}){const{user:s,logout:a,mode:o,activeTeam:l}=xt(),{theme:u,toggle:f}=xm(),{version:p,updateAvailable:g,latestVersion:v}=Lc(),{managed:y}=Ox(),x=Dx(p),j=o==="team"&&l?`Team ${l.name}`:"Personal";return n.jsx("nav",{className:"top-nav",children:n.jsxs("div",{className:"top-nav-inner",children:[n.jsxs("div",{className:"logo-group",children:[n.jsx(Bx,{size:20}),n.jsx("span",{className:"logo",children:"Suveren"}),n.jsx("span",{className:"version-badge",children:"Local Gateway"}),x&&n.jsxs("span",{className:"gw-version",title:g&&v?`Running v${x} — v${v} is available`:"Running gateway version","data-stale":g?"true":void 0,children:["v",x,g&&v?` → ${v}`:""]})]}),n.jsx("div",{className:"nav-spacer"}),n.jsx("div",{className:"nav-actions nav-actions-desktop",children:s?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"workspace-pill","data-managed":y?"true":void 0,title:y?`${j} — set by your IT`:j,children:[j,y&&n.jsx("span",{className:"workspace-pill-it",children:" · set by your IT"})]}),n.jsx("span",{className:"user-chip",children:n.jsx("strong",{children:s.name})}),n.jsx("button",{className:"theme-toggle",onClick:f,title:`Theme: ${u}`,children:Gf[u]}),n.jsx("button",{className:"nav-logout",onClick:a,children:"Logout"})]}):n.jsx("button",{className:"theme-toggle",onClick:f,title:`Theme: ${u}`,children:Gf[u]})}),s&&e&&n.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function Fc(e,s){var a;if((a=s==null?void 0:s.revokedSet)!=null&&a.has(e.authorization_id))return"revoked";switch(e.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return e.remaining_seconds===null||e.remaining_seconds<=0?"expired":e.missing_domains.length>0?"pending":"active"}function wm(e){return e==="expired"||e==="revoked"}function jm(e,s){var a;return!!((a=s==null?void 0:s.archivedSet)!=null&&a.has(e.authorization_id))&&wm(Fc(e,s))}function Fi(e,s){return jm(e,s)?"archived":Fc(e,s)}function Sm(e,s){const a={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const o of e)a[Fi(o,s)].push(o);return a}function Ux(e,s){return s==="expired"?e.earliest_expiry?{iso:e.earliest_expiry,meaning:"expired"}:null:e.created_at?{iso:e.created_at,meaning:"created"}:null}function Ft(e,s,a){const o=h.useRef(e);o.current=e,h.useEffect(()=>{let l=null;const u=()=>typeof document>"u"?!0:document.visibilityState==="visible",f=()=>{u()&&o.current()},p=()=>{l===null&&(l=setInterval(f,s))},g=()=>{l!==null&&(clearInterval(l),l=null)},v=()=>{u()?(o.current(),p()):g()};return u()&&(o.current(),p()),document.addEventListener("visibilitychange",v),()=>{g(),document.removeEventListener("visibilitychange",v)}},[s,a])}function Mc(){const[e,s]=h.useState(!1);return h.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(f=>f.json()).then(f=>{a||s(f.simulation===!0)}).catch(()=>{})};o();const l=setInterval(o,3e4),u=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(l),document.removeEventListener("visibilitychange",u)}},[]),e}function Wx(e,s){const a=e.simulation;return a?(((s==null?void 0:s[a.field])??"").trim().toLowerCase()||a.default.trim().toLowerCase())==="simulation":!1}function la(e){return!!(e!=null&&e.simulation)}const bm=h.createContext(null),Hx=3e4,Vx=5e3,Gx=3e5;function Kx(e,s,a){return s===0?"loading":e!=null&&e.running?"running":e!=null&&e.paused?"paused":e!=null&&e.error?"error":e&&a?"starting":"not-running"}function qx({children:e}){const[s,a]=h.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),o=h.useRef(null),l=h.useCallback(async()=>{let y=!1;const[x,j]=await Promise.all([L.getIntegrationManifests().catch(()=>(y=!0,{manifests:[]})),L.getMcpHealth().catch(()=>null)]);a(b=>({...b,manifests:x.manifests,integrations:(j==null?void 0:j.integrations)??b.integrations,activeSessions:(j==null?void 0:j.activeSessions)??b.activeSessions,mcpServerUp:!!j,manifestsError:y,fetchCount:b.fetchCount+1}));const k=x.manifests.filter(b=>b.oauth);if(k.length>0){const b=await Promise.all(k.map(async S=>[S.id,await L.getOAuthHealth(S.id)]));a(S=>({...S,authHealth:Object.fromEntries(b)}))}},[]),u=s.fetchCount>0&&s.manifests.some(y=>{const x=s.integrations.find(j=>j.id===y.id);return x&&!x.running&&!x.paused});Fe("integration-changed",l),Ft(l,u?Vx:Gx);const f=h.useMemo(()=>{const y=new Map(s.integrations.map(k=>[k.id,k])),x=Date.now();u&&o.current===null?o.current=x:u||(o.current=null);const j=o.current!==null&&x-o.current<Hx;return s.manifests.map(k=>{const b=y.get(k.id),S=Kx(b,s.fetchCount,j),N=s.authHealth[k.id];return{id:k.id,manifest:k,integration:b,state:S,authStatus:N==null?void 0:N.status,authAccount:N==null?void 0:N.account,authError:N==null?void 0:N.error}})},[s,u]),p=Mc(),g=h.useMemo(()=>f.filter(y=>!(p&&!la(y.manifest))&&(y.state==="not-running"||y.state==="error"||y.authStatus==="failed")).length,[f,p]),v={loading:s.fetchCount===0,mcpServerUp:s.mcpServerUp,manifestsError:s.manifestsError,entries:f,attentionCount:g,activeSessions:s.activeSessions,refresh:l};return n.jsx(bm.Provider,{value:v,children:e})}function Oc(){const e=h.useContext(bm);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const Yx={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},Bc=e=>Yx[e]??e,Jx={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 Qx(e){return(e&&Jx[e])??{chip:"Blocked",sev:"info"}}function Xx(e){const s=Bc(e.integrationId);switch(e.reason){case"resource":return e.integrationId==="calendar"?n.jsxs(n.Fragment,{children:["Tried to read your ",n.jsx("b",{children:e.target??"restricted"})," calendar"]}):n.jsxs(n.Fragment,{children:["Tried to read a restricted location in ",s]});case"spam":return n.jsxs(n.Fragment,{children:["Tried to open a message in ",n.jsx("b",{children:"spam or trash"})]});case"age":return n.jsxs(n.Fragment,{children:["Tried to read ",s," older than your read window"]});case"unset_age":return n.jsxs(n.Fragment,{children:["Your ",s," has ",n.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return n.jsxs(n.Fragment,{children:["Read access isn't granted on your ",s," mandate"]});case"ungoverned":return n.jsxs(n.Fragment,{children:["A ",s," tool isn't configured for safe reading"]});case"query_unsafe":return n.jsx(n.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return n.jsx(n.Fragment,{children:e.detail})}}function km(e,s){const a=Math.max(0,(s-e)/1e3);if(a<60)return"Just now";if(a<3600)return`${Math.floor(a/60)} min ago`;if(a<86400)return`${Math.floor(a/3600)} hr ago`;const o=Math.floor(a/86400);return o===1?"Yesterday":`${o} days ago`}const Zx=5,e0=1440*60*1e3,t0=7;function n0(e,s){const a=s-t0*e0;return{recent:e.filter(o=>o.ts>=a),all:e}}function r0(){const[e,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(()=>{L.getDenials({limit:200}).then(({records:x})=>{s(x),o(!1)}).catch(()=>o(!0)),L.getLastSeenBlockedAt().then(u).catch(()=>u(0))},[]);if(h.useEffect(()=>{f()},[f]),Ft(f,12e4),Fe("denial-recorded",f),h.useEffect(()=>(window.addEventListener("suveren:blocked-seen-changed",f),()=>window.removeEventListener("suveren:blocked-seen-changed",f)),[f]),a||e===null||l===null)return null;const{all:p}=n0(e,Date.now()),g=p.filter(x=>x.ts>l);if(g.length===0)return null;const v=g.slice(0,Zx),y=(x,j)=>{const k=Qx(x.reason);return n.jsxs("div",{className:"rb-row",children:[n.jsx("span",{className:`rb-dot ${k.sev==="act"?"act":k.sev==="info"?"info":""}`,"aria-hidden":"true"}),n.jsxs("div",{className:"rb-body",children:[n.jsx("div",{className:"rb-line",children:Xx(x)}),n.jsxs("div",{className:"rb-meta",children:[n.jsx("span",{className:`rb-chip ${k.sev==="act"?"act":k.sev==="warn"?"warn":""}`,children:k.chip}),n.jsx("span",{className:"rb-via",children:Bc(x.integrationId)})]}),k.fixTo&&n.jsx(mt,{className:"rb-fix",to:k.fixTo,children:"Set a read window →"})]}),n.jsx("div",{className:"rb-when",children:km(x.ts,Date.now())})]},`${x.ts}-${j}`)};return n.jsxs("section",{className:"card recent-blocks","aria-label":"Recent blocks",style:{marginTop:"1.5rem"},children:[n.jsxs("div",{className:"card-header",children:[n.jsx("h2",{className:"card-title",children:"Recent blocks"}),n.jsx("span",{className:"rb-count",children:g.length})]}),n.jsx("p",{className:"rb-sub",children:"New since you last looked. Limits you set that stopped your agent — the gateway doing its job."}),n.jsx("div",{className:"rb-rows",children:v.map(y)}),n.jsxs(mt,{className:"col-btn",to:"/blocked",children:["View all ",p.length," blocks from the last 30 days ›"]})]})}function eo(e){return e.kind??"read"}function s0(e,s){var u,f,p,g;if(!s)return"";if(!e)return s;const a=(f=(u=e.scopeSchema)==null?void 0:u.fields)==null?void 0:f[s];if(a!=null&&a.displayName)return a.displayName;const o=((p=e.boundsSchema)==null?void 0:p.fields)??{};if((g=o[s])!=null&&g.displayName)return o[s].displayName;const l=Object.values(o).find(v=>v.boundType&&"of"in v.boundType&&v.boundType.of===s);return l!=null&&l.displayName?l.displayName:s}const a0={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"},i0={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 Kf(e){return e===void 0?"":typeof e=="number"?e.toLocaleString():e}function o0(e,s){const a=eo(e),o=Kf(e.value),l=Kf(e.limit);switch(a){case"bound":return o&&l?`${s||"Value"} ${o} is above the limit ${l}.`:e.detail;case"scope":return o?`${s||"Value"} "${o}" is not within your mandate's allowed ${s||"scope"}.`:e.detail;case"cumulative":return o&&l?`${o} of ${l} used — the limit is reached.`:e.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 e.detail}}function Nm(e,s){if(e.mandateId){const a=s==null?void 0:s[e.mandateId];if(a)return a}return e.mandateTitle}function l0(e,s){const a=Nm(e,s);if(a){const o=[{text:` · mandate "${a}"`}];return e.mandateId&&o.push({text:` (${e.mandateId.slice(0,14)}…)`,dim:!0}),o}return e.mandateId?[{text:` · mandate ${e.mandateId.slice(0,14)}…`}]:[]}function c0(e,s){const a=eo(e),o=Bc(e.integrationId),l=e.who==="authority-server"?"refused by the Authority Server":a==="read"?"refused by this gateway":"refused by this gateway, before anything ran",u=e.code?` (${e.code})`:"";return[{text:`${o} · ${e.tool}`},...l0(e,s),{text:` · ${l}${u}`}]}function u0(e,s,a){const o=eo(e),l=s0(s,e.field);return{title:a0[o],sentence:o0(e,l),sourceLine:c0(e,a),whatYouCanDo:i0[o]}}function d0(e,s){const a=new Date(s);return a.setHours(0,0,0,0),e.filter(o=>o.ts>=a.getTime()).length}function f0(e,s){return e.filter(a=>a.ts>s).length}const h0=1440*60*1e3;function m0(e,s){const a=new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),o=new Date(s);o.setHours(0,0,0,0);const l=o.getTime();return e>=l?`Today · ${a}`:e>=l-h0?`Yesterday · ${a}`:`${new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})} · ${a}`}function Cm(e,s){return!!e&&e.savedAt*1e3>s}function p0(e){const s=/<h[1-3][^>]*>([\s\S]*?)<\/h[1-3]>/i.exec(e),a=s?s[1].replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/\s+/g," ").trim():"";return a?a.length>80?`${a.slice(0,79)}…`:a:"Report"}function g0(e){var s,a;return{verified:((a=(s=e.proof)==null?void 0:s.verifiedValues)==null?void 0:a.length)??0,unchecked:(e.elements??[]).filter(o=>o.status==="unverifiable").length}}const qf=(e,s)=>new Date(e*1e3).toLocaleString(s,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),Yf=(e,s)=>new Date(e*1e3).toLocaleString(s,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"});function Mi(e,s){const a=e==null?void 0:e.window;return a?{text:`Covers ${qf(a.start,s)} → ${qf(a.end,s)} (${a.days} day${a.days===1?"":"s"})`,title:`From ${Yf(a.start,s)} to ${Yf(a.end,s)}. Tickets up to 2 minutes after the end count, for small clock differences.`}:{text:"Period not recorded"}}function Em(e,s,a){const o=new Date(e*1e3),l=o.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"}),u=Math.floor((s-e*1e3)/864e5);if(new Date(s).toDateString()===o.toDateString())return`today ${l}`;const p=`${o.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`;return u>=2?`${p} (${u} days ago)`:p}const y0=[{to:"/",icon:"□",label:"Dashboard",group:"top"},{to:"/approvals",icon:"▷",iconClass:"nav-ic-approval",label:"Approvals",statusKey:"proposals",group:"core"},{to:"/mandates",icon:"☰",iconClass:"nav-ic-mandate",label:"Mandates",statusKey:"authorizations",group:"core",quietCount:!0},{to:"/tickets",icon:"▣",iconClass:"nav-ic-ticket",label:"Tickets",group:"core"},{to:"/reports",icon:"▥",label:"Reports",statusKey:"report",newLabel:!0,group:"core"},{to:"/blocked",icon:"⊘",iconClass:"nav-ic-blocked",label:"Blocked",statusKey:"blocked",group:"core"},{to:"/team",icon:"◉",label:"Team",teamOnly:!0,group:"setup"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief",group:"setup"},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations",group:"setup"},{to:"/settings",icon:"⚙",label:"Settings",statusKey:"assistant",group:"setup"}];function v0(){const{activeDomain:e}=xt(),[s,a]=h.useState({}),o=h.useCallback(async()=>{try{const[l,u,f,p,g,v,y,x,j,k]=await Promise.all([L.getCredential("ai-config").catch(()=>null),L.getMyAttestations().catch(()=>null),L.getMyProposals(e).catch(()=>null),L.getProposalsForApprover().catch(()=>null),L.getAgentContext().catch(()=>""),L.getArchivedMandates().catch(()=>[]),L.getDenials({limit:200}).catch(()=>null),L.getLastSeenBlockedAt().catch(()=>0),L.getReport().catch(()=>null),L.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]),b={};if(l&&!l.configured&&(b.assistant=1),u){const T=Sm(u,{archivedSet:new Set(v)}).expired.length;T>0&&(b.authorizations=T)}const S=(f==null?void 0:f.length)??0,N=(p==null?void 0:p.length)??0,E=S+N;if(E>0&&(b.proposals=E),(!g||!g.trim())&&(b.brief=1),y){const T=f0(y.records,x);T>0&&(b.blocked=T)}Cm(j==null?void 0:j.report,k)&&(b.report=1),a(b)}catch{}},[e]);return Fe("attestation-changed",o),Fe("proposal-added",o),Fe("proposal-resolved",o),Fe("proposal-approved",o),Fe("proposal-rejected",o),Fe("team-membership-changed",o),Fe("denial-recorded",o),Fe("report-written",o),h.useEffect(()=>(window.addEventListener("suveren:archived-changed",o),()=>window.removeEventListener("suveren:archived-changed",o)),[o]),h.useEffect(()=>(window.addEventListener("suveren:blocked-seen-changed",o),window.addEventListener("suveren:report-seen-changed",o),()=>{window.removeEventListener("suveren:blocked-seen-changed",o),window.removeEventListener("suveren:report-seen-changed",o)}),[o]),Ft(o,3e5,e),s}const x0={marginLeft:"auto",minWidth:"1.25rem",height:"1.25rem",padding:"0 0.375rem",borderRadius:"0.625rem",background:"var(--neutral)",color:"var(--bg-elevated)",fontSize:"0.7rem",fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},w0={position:"fixed",bottom:"1.5rem",left:"50%",transform:"translateX(-50%)",background:"var(--bg-elevated)",color:"var(--text-primary)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.625rem 1rem",fontSize:"0.85rem",boxShadow:"var(--elevation-2)",zIndex:9999,whiteSpace:"nowrap",pointerEvents:"none"};function j0(){const{mode:e,activeTeam:s}=xt(),a=v0(),{attentionCount:o}=Oc(),l={...a};o>0&&(l.integrations=o);const u=y0.filter(y=>!y.teamOnly||e==="team"),f=h.useRef(null),[p,g]=h.useState(null),v=Qt();return h.useEffect(()=>{if(f.current===null){f.current=e;return}f.current!==e&&(e==="team"&&s?g(`You are now acting in team context — ${s.name}`):e==="personal"&&g("You have left the team — back to personal context"),f.current=e)},[e,s]),h.useEffect(()=>{g(null)},[v.pathname]),n.jsxs("div",{className:"sidebar",children:[["top","core","setup"].map(y=>{const x=u.filter(j=>(j.group??"setup")===y);return x.length===0?null:n.jsxs("div",{className:`sidebar-${y}`,children:[y==="setup"&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sidebar-divider"}),n.jsx("div",{className:"sidebar-group-label",children:"Setup"})]}),n.jsx("ul",{className:"sidebar-nav",children:x.map(j=>{const k=j.statusKey?l[j.statusKey]:0;return n.jsx("li",{children:n.jsxs(_c,{to:j.to,end:j.to==="/",className:({isActive:b})=>`sidebar-item${b?" active":""}`,children:[n.jsx("span",{className:"icon",children:j.iconClass?n.jsx("span",{className:`nav-ic ${j.iconClass}`,"aria-hidden":"true"}):j.icon}),j.label,k?j.newLabel?n.jsx("span",{className:"nav-new","data-testid":`nav-new-${j.statusKey}`,children:"New"}):n.jsx("span",{style:x0,className:j.quietCount?"nav-count-quiet":void 0,title:j.quietCount?"Expired mandates":void 0,children:k}):null]})},j.to)})})]},y)}),p&&n.jsx("div",{style:w0,role:"status","aria-live":"polite",children:p})]})}const Ql="suveren:updatedTo";function S0(e){return e==="managed"||e==="msi"?null:e==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":e==="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 b0="Updates for this gateway come from your company's IT — no action needed here.";function k0(e){return e==="managed"?"update-banner is-managed":"update-banner"}const N0="Download the new installer and run it. Your settings and mandates stay.";function C0(e){const s="https://github.com/suverenai/suveren-gateway/releases";return e?`${s}/tag/v${e}`:`${s}/latest`}function E0(){const e=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const a of e)if(!a.closest(".update-overlay"))return!0;const s=document.activeElement;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)){const a=s.value;if(a&&a.trim())return!0}return!1}function Tm(){const{updateAvailable:e,installMethod:s,version:a,latestVersion:o,serverRestarted:l,startFastPolling:u,dismiss:f}=Lc(),[p,g]=h.useState(!1),[v,y]=h.useState(!1),[x,j]=h.useState(()=>{try{const P=sessionStorage.getItem(Ql);if(P)return sessionStorage.removeItem(Ql),P}catch{}return null}),k=S0(s),b=h.useRef(null),S=P=>{try{sessionStorage.setItem(Ql,P||o||"✓")}catch{}window.location.reload()};h.useEffect(()=>{if(!x)return;const P=setTimeout(()=>j(null),6e3);return()=>clearTimeout(P)},[x]),h.useEffect(()=>{if(!p||!l)return;const P=()=>E0()?!1:(S(a),!0);if(P())return;const I=setInterval(P,1500);return()=>clearInterval(I)},[p,l,a]),h.useEffect(()=>(document.body.classList.toggle("is-updating",p),()=>document.body.classList.remove("is-updating")),[p]);const N=e&&!p&&!x||!!x&&!p;h.useEffect(()=>{if(!N){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const P=()=>{var O;const B=((O=b.current)==null?void 0:O.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${B}px`)};P();const I=new ResizeObserver(P);return b.current&&I.observe(b.current),()=>{I.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[N]);const E=()=>{g(!0),u()},T=async()=>{if(k)try{await navigator.clipboard.writeText(k),y(!0),setTimeout(()=>y(!1),1800)}catch{}};return n.jsxs(n.Fragment,{children:[x&&!p&&n.jsx("div",{ref:b,className:"update-banner is-live",role:"status","aria-live":"polite",children:n.jsxs("div",{className:"update-banner-row",children:[n.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",x&&x!=="✓"?` — ${x} is live`:" — now live","."]}),n.jsx("button",{className:"update-banner-x",onClick:()=>j(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!p&&!x&&n.jsxs("div",{ref:b,className:k0(s),role:"status","aria-live":"polite",children:[n.jsxs("div",{className:"update-banner-row",children:[n.jsx("span",{className:"update-banner-text",children:s==="msi"&&o?`Update available — version ${o}.`:"Update available."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[s==="msi"&&n.jsx("a",{className:"btn btn-sm btn-secondary",href:C0(o),target:"_blank",rel:"noopener noreferrer",children:"Download installer"}),s!=="managed"&&s!=="msi"&&n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:E,children:"Update"}),n.jsx("button",{className:"update-banner-x",onClick:f,"aria-label":"Dismiss",children:"×"})]})]}),s==="managed"&&n.jsx("p",{className:"update-banner-hint",children:b0}),s==="msi"&&n.jsx("p",{className:"update-banner-hint",children:N0})]}),p&&n.jsx("div",{className:"update-overlay",children:n.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[n.jsx("div",{className:"update-spinner"}),n.jsxs("h2",{children:["Finishing the update","…"]}),n.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",n.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),n.jsxs("div",{className:"update-cmd-row",children:[n.jsx("code",{className:"update-cmd",children:k}),n.jsx("button",{className:"btn btn-sm btn-primary",onClick:T,children:v?"Copied":"Copy"})]}),n.jsxs("div",{className:"update-status",children:[n.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),n.jsxs("div",{className:"update-overlay-actions",children:[n.jsx("button",{className:"btn btn-primary",onClick:()=>S(a),children:"Reload now"}),n.jsx("button",{className:"btn btn-secondary",onClick:()=>g(!1),children:"Cancel"})]})]})})]})}function Am(){const e=Mc(),s=h.useRef(null);return h.useEffect(()=>{if(!e){document.documentElement.style.removeProperty("--sim-banner-h");return}const a=()=>{var u;const l=((u=s.current)==null?void 0:u.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${l}px`)};a();const o=new ResizeObserver(a);return s.current&&o.observe(s.current),()=>{o.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[e]),e?n.jsx("div",{ref:s,className:"simulation-banner",role:"status","aria-live":"polite",children:n.jsx("span",{className:"simulation-banner-text",children:"Simulation mode — real systems are blocked."})}):null}const T0={system:"◑",light:"☀",dark:"☾"},A0=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Approvals"},{to:"/mandates",icon:"☰",label:"Mandates"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/blocked",icon:"⊘",label:"Blocked"},{to:"/team",icon:"◉",label:"Team"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"Settings"}];function I0({open:e,onClose:s}){const{user:a,activeGroup:o,activeDomain:l,logout:u}=xt(),{theme:f,toggle:p}=xm(),g=Qt();return h.useEffect(()=>{s()},[g.pathname]),e?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mobile-menu-backdrop",onClick:s}),n.jsxs("div",{className:"mobile-menu-panel",children:[a&&n.jsxs("div",{className:"mobile-menu-header",children:[n.jsx("strong",{children:a.name}),n.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:o?`${o.name} / ${l}`:l||"personal"})]}),n.jsx("nav",{className:"mobile-menu-nav",children:A0.map(v=>n.jsxs(_c,{to:v.to,end:v.to==="/",className:({isActive:y})=>`mobile-menu-item${y?" active":""}`,onClick:s,children:[n.jsx("span",{className:"icon",children:v.icon}),v.label]},v.to))}),n.jsxs("div",{className:"mobile-menu-footer",children:[n.jsxs("button",{className:"mobile-menu-action",onClick:()=>{p()},children:[n.jsx("span",{className:"icon",children:T0[f]}),"Theme: ",f]}),n.jsx("button",{className:"mobile-menu-action",onClick:()=>{u(),s()},children:"Logout"})]})]})]}):null}function Im(e){return e.status==="pending"}function R0(e,s){return e.filter(Im).length+s.length}const br=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],P0=500;function Rm(){const{user:e,domain:s}=xt(),[a,o]=h.useState(0),l=h.useRef(null),u=h.useCallback(async()=>{if(!e){o(0);return}try{const[p,g]=await Promise.all([L.getMyProposals(s).catch(()=>[]),L.getProposalsForApprover().catch(()=>[])]);o(R0(p,g))}catch{o(0)}},[e,s]),f=h.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{u()},P0)},[u]);return h.useEffect(()=>(u(),()=>{l.current&&clearTimeout(l.current)}),[u]),Fe(br[0],f),Fe(br[1],f),Fe(br[2],f),Fe(br[3],f),Fe(br[4],f),Fe(br[5],f),Fe(br[6],f),a}const Jf="Suveren",$0="/favicon.svg",_0="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",Ti={x1:74.54,y1:22.74,x2:94.46,y2:34.24},L0=14,z0="#f59e0b";function F0(e){const s=Dc(e);return s>0?`(${s}) ${Jf}`:Jf}function Dc(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function M0(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
|
|
52
|
+
<path class="m" d="${_0}"/>
|
|
53
|
+
<line class="m" x1="${Ti.x1}" y1="${Ti.y1}" x2="${Ti.x2}" y2="${Ti.y2}"/>
|
|
54
|
+
<circle cx="103" cy="103" r="25" fill="${z0}"/>
|
|
55
|
+
<style>.m{stroke:#111111;stroke-width:${L0};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(e)}`}function O0(){return document.querySelector('link[rel="icon"]')}function Pm(e){const s=Dc(e);document.title=F0(s),$m(s);const a=O0();if(!a)return;const o=s>0?M0():$0;a.getAttribute("href")!==o&&a.setAttribute("href",o)}function B0(){Pm(0)}function $m(e,s=globalThis.navigator){var l;if(!s||typeof s.setAppBadge!="function")return;const a=Dc(e),o=a>0?s.setAppBadge(a):s.clearAppBadge?s.clearAppBadge():s.setAppBadge(0);(l=o==null?void 0:o.catch)==null||l.call(o,()=>{})}function D0(){const e=Rm();return h.useEffect(()=>{Pm(e)},[e]),h.useEffect(()=>B0,[]),null}const _m="suveren:dockBadgePrompt";function U0(){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 W0(){const[e,s]=h.useState(!1),a=Rm();if(h.useEffect(()=>{s(U0())},[]),!e)return null;const o=()=>{try{localStorage.setItem(_m,"1")}catch{}s(!1)},l=async()=>{try{await Notification.requestPermission()==="granted"&&$m(a)}catch{}o()};return n.jsxs("div",{className:"hint-box",style:{marginBottom:"1rem",alignItems:"center"},children:[n.jsxs("div",{className:"hint-body",children:[n.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."]}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:l,children:"Allow"}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:o,"aria-label":"Not now",children:"Not now"})]})}function H0(){const[e,s]=h.useState(!1);return n.jsxs(qx,{children:[n.jsx(D0,{}),n.jsx(zc,{onMenuToggle:()=>s(!e)}),n.jsx(Tm,{}),n.jsx(Am,{}),n.jsx(j0,{}),n.jsx(I0,{open:e,onClose:()=>s(!1)}),n.jsx("div",{className:"main-content",children:n.jsxs("div",{className:"page-inner",children:[n.jsx(W0,{}),n.jsx(Wv,{})]})})]})}function Lm({what:e}){return n.jsxs("div",{className:"human-only-note",role:"note",children:[n.jsx("strong",{children:"Only you."})," ",e==="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 Uc(){return typeof navigator<"u"&&navigator.webdriver===!0}const Wc="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function V0(){const[e,s]=h.useState(""),{login:a,isLoading:o,error:l,clearError:u}=xt(),[f,p]=h.useState(null),g=Uc(),v=async()=>{if(!(!e.trim()||g)){u();try{await a(e)}catch(j){if(j instanceof pm){p(j.summary);return}}}},y=async()=>{p(null),u();try{await a(e,{confirmWipe:!0})}catch{}},x=()=>{p(null)};return n.jsxs(n.Fragment,{children:[n.jsx(zc,{}),n.jsx(Tm,{}),n.jsx(Am,{}),n.jsxs("div",{className:"login-split",children:[n.jsx("div",{className:"login-split-left",children:n.jsxs("div",{style:{maxWidth:"28rem"},children:[n.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."}),n.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."})]})}),n.jsx("div",{className:"login-split-right",children:n.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),n.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage mandates."})]}),n.jsx(Lm,{what:"sign-in"}),g&&n.jsx("div",{className:"error-message",children:Wc}),l&&n.jsx("div",{className:"error-message",children:l}),n.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[n.jsx("label",{className:"form-label",children:"API Key"}),n.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:e,onChange:j=>s(j.target.value),onKeyDown:j=>j.key==="Enter"&&v(),disabled:o,style:{padding:"0.75rem"}}),n.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),n.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:v,disabled:o||g,style:{marginBottom:"2rem"},children:o?"Signing in...":"Sign In"}),n.jsx("div",{className:"login-divider",children:"New here?"}),n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",n.jsx("br",{}),"then come back to sign in."]}),n.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"})]}),n.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[n.jsxs(n.Fragment,{children:["Create an account at ",n.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((j,k)=>n.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:k<2?"0.5rem":0},children:[n.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[k+1,"."]}),j]},k))})]})]})})]}),f&&n.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wipe-warning-title",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-main) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:x,children:n.jsxs("div",{className:"card",onClick:j=>j.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[n.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),n.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 ",n.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),n.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[n.jsxs("li",{children:[f.credentialCount," stored service credential",f.credentialCount===1?"":"s",f.credentialIds.length>0&&n.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",f.credentialIds.slice(0,5).join(", "),f.credentialIds.length>5?`, +${f.credentialIds.length-5} more`:"",")"]})]}),n.jsxs("li",{children:[f.serviceCount," configured integration",f.serviceCount===1?"":"s"]}),n.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),n.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),n.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."}),n.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."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:x,disabled:o,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:y,disabled:o,children:o?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function G0(e,s){return!s&&e!=null}function K0(e,s){return e==="join-waiting"&&s==="team"}function q0(e,s,a,o){return a!=null||e!=="join-waiting"||s==="team"?null:o}function Y0(e){return`${e} personal mandate${e===1?"":"s"}`}function J0({mandates:e,pendingProposals:s}){return e.length===0&&s===0?n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)"},children:"You have no personal mandates to end."}):n.jsxs("div",{style:{background:"var(--bg-elevated)",borderRadius:"0.5rem",padding:"0.75rem 1rem",margin:"0.75rem 0"},children:[n.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"}),n.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,fontSize:"0.825rem"},children:e.map(a=>n.jsxs("li",{style:{display:"flex",justifyContent:"space-between",gap:"0.5rem",padding:"0.25rem 0",borderBottom:"1px solid var(--border)"},children:[n.jsx("span",{children:a.title||a.profileId}),n.jsx("span",{style:{color:"var(--text-tertiary)"},children:a.commitmentMode??""})]},a.id))}),n.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 Q0(){const{mode:e,pendingRequest:s,refreshGroups:a}=xt(),o=Sn(),[l,u]=h.useState("choose"),[f,p]=h.useState(""),[g,v]=h.useState(""),[y,x]=h.useState(null),[j,k]=h.useState(null),[b,S]=h.useState(""),[N,E]=h.useState(""),[T,P]=h.useState(!1),I=h.useRef(!1);h.useEffect(()=>{G0(s,I.current)&&(I.current=!0,u("join-waiting"))},[s]),h.useEffect(()=>{K0(l,e)&&o("/")},[l,e,o]);const B=h.useRef(null);h.useEffect(()=>{if(s){B.current=s.groupName;return}const F=q0(l,e,s,B.current);F&&(S(F),u("join-declined"),B.current=null)},[s,l,e]),h.useEffect(()=>{if(l!=="join-waiting")return;const F=setInterval(()=>{a()},5e3);return()=>clearInterval(F)},[l,a]);const O=h.useCallback(()=>{u("choose"),E(""),x(null),k(null),p(""),v("")},[]),K=async()=>{if(f.trim()){P(!0),E("");try{const F=await L.getJoinPreview(f.trim());x(F),u("join-preview")}catch(F){E(F instanceof Error?F.message:"Invalid or expired invite code")}finally{P(!1)}}},z=async()=>{P(!0),E("");try{await L.requestToJoinGroup(f.trim()),await a(),u("join-waiting")}catch(F){E(F instanceof Error?F.message:"Failed to join group")}finally{P(!1)}},U=async()=>{P(!0),E("");try{await L.withdrawJoinRequest(),await a(),O()}catch(F){E(F instanceof Error?F.message:"Failed to withdraw request")}finally{P(!1)}},ee=async()=>{u("create"),E(""),P(!0);try{const F=await L.getCreatePreview();k(F)}catch(F){E(F instanceof Error?F.message:"Failed to load preview")}finally{P(!1)}},X=async()=>{if(g.trim()){P(!0),E("");try{await L.createGroup(g.trim()),await a(),o("/")}catch(F){E(F instanceof Error?F.message:"Failed to create group")}finally{P(!1)}}};return n.jsxs(n.Fragment,{children:[n.jsx(zc,{}),n.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:n.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[N&&n.jsx("div",{className:"error-message",children:N}),l==="choose"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join or create a team"}),n.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)."})]}),n.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[n.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing team"}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),n.jsxs("div",{className:"invite-input-row",children:[n.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:f,onChange:F=>p(F.target.value),onKeyDown:F=>F.key==="Enter"&&K(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:T}),n.jsx("button",{className:"btn btn-primary",onClick:K,disabled:T||!f.trim(),children:T?"Checking…":"Continue"})]})]}),n.jsxs("div",{className:"card",children:[n.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new team"}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members."}),n.jsx("button",{className:"btn btn-secondary",onClick:ee,disabled:T,children:"Create a team"})]})]}),l==="join-preview"&&y&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Join team ",y.groupName,"?"]}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Your account ",n.jsx("strong",{children:"moves to the team"}),". From then on you work under the team's rules — its approvers and limits."]}),n.jsx(J0,{mandates:y.personalMandates,pendingProposals:y.pendingPersonalProposals}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:["The team admin (",y.admin.name,") confirms your request. Nothing changes until then."]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:z,disabled:T,children:T?"Asking…":"Ask to join"}),n.jsx("button",{className:"btn btn-ghost",onClick:O,disabled:T,children:"Cancel"})]})]}),l==="join-waiting"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request sent to team ",(s==null?void 0:s.groupName)??""]}),n.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."}),n.jsx("button",{className:"btn btn-secondary",onClick:U,disabled:T,children:T?"Withdrawing…":"Withdraw request"})]}),l==="join-declined"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request to ",b," ended"]}),n.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."}),n.jsx("button",{className:"btn btn-primary",onClick:O,disabled:T,children:"Back"})]}),l==="create"&&n.jsxs("div",{className:"card",children:[n.jsx("h3",{style:{marginBottom:"0.75rem"},children:"Create a team"}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:"Team name"}),n.jsx("input",{className:"form-input",placeholder:"e.g., Acme Corp",value:g,onChange:F=>v(F.target.value),onKeyDown:F=>F.key==="Enter"&&X(),disabled:T,autoFocus:!0})]}),j&&n.jsxs("div",{className:"alert alert-info",style:{color:"white"},children:["Your account moves to the new team. Your ",Y0(j.personalMandates.length)," end (kept in your history)."]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginTop:"1rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:X,disabled:T||!g.trim(),children:T?"Creating…":"Create team and move my account"}),n.jsx("button",{className:"btn btn-ghost",onClick:O,disabled:T,children:"Cancel"})]})]})]})})]})}const Qf={"claude-code":{label:"Claude Code",snippet:e=>`claude mcp add --transport http suveren ${e}/mcp`},"claude-desktop":{label:"Claude Desktop",snippet:e=>`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",`${e}/mcp`,"--allow-http"]}}},null,2)}`},"chatgpt-codex":{label:"ChatGPT / Codex",snippet:e=>`Add to ~/.codex/config.toml:
|
|
59
|
+
|
|
60
|
+
[mcp_servers.suveren]
|
|
61
|
+
url = "${e}/mcp"
|
|
62
|
+
|
|
63
|
+
Or: codex mcp add suveren --url ${e}/mcp`},other:{label:"Other",snippet:e=>`Streamable HTTP: POST ${e}/mcp
|
|
64
|
+
SSE transport: GET ${e}/sse
|
|
65
|
+
Health check: GET ${e}/health`}},Xf=["claude-code","claude-desktop","chatgpt-codex","other"];function dc({mcpEndpoint:e}){const[s,a]=h.useState(Xf[0]),[o,l]=h.useState(!1),u=h.useCallback(async p=>{try{await navigator.clipboard.writeText(p),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},[]),f=Qf[s].snippet(e);return n.jsxs("div",{children:[n.jsx("div",{className:"gate-content-label",children:"MCP Endpoint"}),n.jsx("div",{className:"mcp-endpoint",children:e}),n.jsx("div",{className:"mcp-tabs",children:Xf.map(p=>n.jsx("button",{className:`mcp-tab${s===p?" active":""}`,onClick:()=>a(p),children:Qf[p].label},p))}),n.jsx("pre",{className:"mcp-snippet",children:f}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>u(f),children:o?"Copied":"Copy"})]})}const fc="suveren-setup-ai-skipped",hc="suveren-setup-agent-done",mc="suveren-setup-dismissed",X0={"hap-setup-ai-skipped":fc,"hap-setup-agent-done":hc,"hap-setup-dismissed":mc};function Z0(){for(const[e,s]of Object.entries(X0)){const a=localStorage.getItem(e);a!==null&&localStorage.getItem(s)===null&&localStorage.setItem(s,a),a!==null&&localStorage.removeItem(e)}}Z0();function ew({aiConfigured:e,hasRunningIntegration:s,hasActiveAuth:a,hasAgentConnected:o,mcpEndpoint:l}){const[u,f]=h.useState(()=>localStorage.getItem(fc)==="true"),[p,g]=h.useState(()=>localStorage.getItem(hc)==="true"),[v,y]=h.useState(()=>localStorage.getItem(mc)==="true"),[x,j]=h.useState(null),k=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status:e?"done":u?"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:a?"done":"pending"},{label:"Connect your agent",status:o||p?"done":"pending"}],b=k.filter(I=>I.status==="done"||I.status==="skipped").length,S=b===k.length,N=h.useCallback(()=>{localStorage.setItem(fc,"true"),f(!0)},[]),E=h.useCallback(()=>{localStorage.setItem(hc,"true"),g(!0),j(null)},[]),T=h.useCallback(()=>{localStorage.setItem(mc,"true"),y(!0)},[]);if(v||S)return null;const P=k.findIndex(I=>I.status==="pending");return n.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[n.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),n.jsx("button",{onClick:T,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:"×"})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:k.map((I,B)=>{const O=B===P,K=I.status==="done"||I.status==="skipped"?"●":"○",z=I.status==="done"?"var(--text-primary)":I.status==="skipped"?"var(--text-tertiary)":O?"var(--accent)":"var(--text-tertiary)";return n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:O?"0.75rem":"0.25rem 0",borderRadius:O?"0.5rem":void 0,background:O?"var(--accent-subtle)":void 0},children:[n.jsx("span",{style:{color:z,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:K}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[I.to&&I.status==="pending"?n.jsx(mt,{to:I.to,style:{fontSize:"0.9rem",fontWeight:O?600:500,color:O?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:I.label}):I.status==="pending"&&B===3?n.jsx("button",{onClick:()=>j(x===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:O?600:500,color:O?"var(--accent)":"var(--text-primary)"},children:I.label}):n.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:I.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:I.label}),I.optional&&I.status==="pending"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),I.status==="skipped"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),I.detail&&I.status==="pending"&&O&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:I.detail})]}),I.optional&&I.status==="pending"&&n.jsx("button",{onClick:N,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),I.to&&I.status==="pending"&&n.jsx(mt,{to:I.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),B===3&&x===3&&n.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[n.jsx(dc,{mcpEndpoint:l}),n.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:E,children:"Done"})]})]},B)})}),n.jsxs("div",{style:{marginTop:"1.25rem"},children:[n.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:n.jsx("div",{style:{height:"100%",width:`${b/k.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),n.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[b," of ",k.length," complete"]})]})]})}function zm(e,s=null){const a=[e.hasContact,e.hasDelegationMandate,e.delegationProposalCount>0],o=a.every(Boolean),l=e.otherMandateCount===0&&!o,u=a.findIndex(v=>!v),f=s!==null&&a[s]===!1?s:u,p=e.managed?"managed":"self",g=v=>a[v]?{status:"done"}:v!==f?{status:"todo"}:v===1?{status:"open",variant:p,simulationOn:e.simulationOn}:v===0?{status:"open",variant:p}:{status:"open"};return{visible:l,step1:g(0),step2:g(1),step3:g(2)}}const tw="/mandates?new=1&profile=delegation";function Zf({text:e}){const[s,a]=h.useState(!1),o=h.useCallback(async()=>{try{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[e]);return n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:o,children:s?"Copied":"Copy"})}function Xl({todo:e,onOpen:s,children:a}){return e?n.jsx("button",{type:"button",className:"flow-step-title flow-todo-title flow-step-open-btn",onClick:s,children:a}):n.jsx("span",{className:"flow-step-title",children:a})}function nw({contact:e,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:l,simulationOn:u,mcpEndpoint:f}){const p={hasContact:e!==null,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:l,simulationOn:u},[g,v]=h.useState(null),y=zm(p,g);if(!y.visible)return null;const x=`Please connect to the Suveren gateway: MCP server at ${f}/mcp`;return n.jsxs("div",{className:"card setup-card",children:[n.jsx("h2",{className:"card-title",children:"Get started"}),n.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."}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step1.status==="open"?"open":y.step1.status==="done"?"done":"todo"}`,children:y.step1.status==="done"?"✓":"1"}),y.step1.status==="done"&&e?n.jsxs("span",{className:"flow-step-title flow-done-title",children:[e.clientName," connected · last contact ",km(Date.parse(e.lastSeenAt),Date.now()).toLowerCase()]}):n.jsx(Xl,{todo:y.step1.status==="todo",onOpen:()=>v(0),children:"Connect your AI"})]}),y.step1.status==="open"&&n.jsx("div",{className:"flow-step-body",children:y.step1.variant==="managed"?n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Your IT sets up the connection. Open your AI — if Suveren isn't there, contact your IT."}),n.jsxs("details",{className:"int-details",children:[n.jsx("summary",{children:"For your IT"}),n.jsx("div",{style:{marginTop:"0.75rem"},children:n.jsx(dc,{mcpEndpoint:f})})]})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Ask your AI to connect to Suveren. Copy this into it:"}),n.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.75rem"},children:n.jsxs("div",{className:"quote-box",children:[n.jsx("span",{className:"quote-text",children:x}),n.jsx(Zf,{text:x})]})}),n.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."}),n.jsxs("details",{className:"int-details",children:[n.jsx("summary",{children:"Set it up by hand"}),n.jsx("div",{style:{marginTop:"0.75rem"},children:n.jsx(dc,{mcpEndpoint:f})})]})]})})]}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step2.status==="open"?"open":y.step2.status==="done"?"done":"todo"}`,children:y.step2.status==="done"?"✓":"2"}),y.step2.status==="done"?n.jsxs("span",{className:"flow-step-title flow-done-title",children:["Delegation mandate given · ",n.jsx(mt,{to:"/mandates",children:"review or revoke under Mandates"})]}):n.jsx(Xl,{todo:y.step2.status==="todo",onOpen:()=>v(1),children:"Give the Delegation mandate"})]}),y.step2.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.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."}),n.jsxs("ul",{className:"bound-list",children:[n.jsx("li",{children:"Read the setup guides"}),n.jsx("li",{children:"Propose new mandates — each waits for your approval"}),n.jsx("li",{children:"Propose an updated agent brief — also waits for your approval"})]}),y.step2.simulationOn?n.jsxs(n.Fragment,{children:[n.jsx(mt,{to:tw,className:"btn btn-primary",children:"Give the Delegation mandate →"}),n.jsx("p",{className:"cta-helper",children:"You set the daily limit in the next step."}),y.step2.variant==="managed"&&n.jsx("p",{className:"managed-note",children:"In a company team you may need approver rights — ask your IT if the button is refused."})]}):n.jsx("p",{className:"managed-note",style:{marginTop:0},children:y.step2.variant==="managed"?"Delegation works in simulation mode only. Ask your IT to turn on simulation mode.":n.jsxs(n.Fragment,{children:["Delegation works in simulation mode only. Turn it on with ",n.jsx("code",{children:"suveren-gateway simulation on"})," and restart."]})})]})]}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step3.status==="open"?"open":"todo"}`,children:"3"}),n.jsx(Xl,{todo:y.step3.status==="todo",onOpen:()=>v(2),children:"Ask your AI: “How do I start with Suveren?”"})]}),y.step3.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.875rem"},children:n.jsxs("div",{className:"quote-box",children:[n.jsx("span",{className:"quote-text",children:"“How do I start with Suveren?”"}),n.jsx(Zf,{text:"How do I start with Suveren?"})]})}),n.jsxs("p",{children:["It will interview you, suggest test data, and propose mandates and a brief. Approve its proposals under ",n.jsx(mt,{to:"/approvals",children:"Approvals"}),"."]})]})]})]})}function rw(){const[e,s]=h.useState(null);return h.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{!a&&typeof o.mcpPort=="number"&&s(`http://localhost:${o.mcpPort}`)}).catch(()=>{}),()=>{a=!0}},[]),e}function sw(e){if(!e||typeof e!="object")return{simulation:null,locked:!1};const s=Array.isArray(e.policyLocked)&&e.policyLocked.includes("simulation");return{simulation:typeof e.simulation=="boolean"?e.simulation:null,locked:s}}function Fm(){const[e,s]=h.useState({simulation:null,locked:!1});return h.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(sw(o))}).catch(()=>{}),()=>{a=!0}},[]),e}function aw(e){return!e||typeof e!="object"?!1:Array.isArray(e.policyLocked)&&e.policyLocked.length>0}function iw(){const[e,s]=h.useState(!1);return h.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(f=>f.json()).then(f=>{a||s(aw(f))}).catch(()=>{})};o();const l=setInterval(o,3e4),u=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(l),document.removeEventListener("visibilitychange",u)}},[]),e}const eh=new Map;function Mm(e){let s=eh.get(e);return s||(s=(async()=>{try{let a=e;if(!e.includes("@")){const o=await L.listProfiles(),l=f=>f.replace(/@.*$/,"").split("/").pop(),u=o.filter(f=>l(f.id)===e).sort((f,p)=>(p.id.split("@")[1]??"").localeCompare(f.id.split("@")[1]??"",void 0,{numeric:!0}));if(!u[0])return null;a=u[0].id}return await L.getProfile(a)}catch{return null}})(),eh.set(e,s)),s}function ma(e){const[s,a]=h.useState(null);return h.useEffect(()=>{let o=!0;return e&&Mm(e).then(l=>{o&&a(l)}),()=>{o=!1}},[e]),s}const th=40;function Mt(e,s){const a=e.lastIndexOf("/"),o=a>=0?e.slice(a+1):e,l=o.indexOf("@"),u=l>=0?o.slice(0,l):o;return s?s.slice(0,th):(u.charAt(0).toUpperCase()+u.slice(1)).slice(0,th)}function In(e){const s=e.lastIndexOf("/"),a=s>=0?e.slice(s+1):e,o=a.indexOf("@");return(o>=0?a.slice(0,o):a).toLowerCase()}function Pr(e,s){const a=In(e),o=Ar(e),l=Mt(e,s==null?void 0:s.name);return{icon:o,name:l,testSetup:a==="delegation"}}function to(e){return e.startsWith("setup__")}const ow={customers:"customers",email:"email",charge:"payments",sales:"sales",calendar:"calendar",records:"records",publish:"publishing",deploy:"deployments",purchase:"purchasing",reporting:"reports",delegation:"setup"};function Ar(e){return ow[In(e)]??"unknown"}function nh(e){const s=e.indexOf("@");return s>=0?e.slice(s+1):""}function Bn(e,s){const a=In(e),o=s.filter(l=>In(l.id)===a).sort((l,u)=>nh(u.id).localeCompare(nh(l.id),void 0,{numeric:!0}))[0];return Mt(e,o==null?void 0:o.name)}function lw(e,s){const a=e==null?void 0:e.trim();return a?a.toLowerCase()!==s.trim().toLowerCase():!1}function Om(e){return e&&e.trim()?e.trim():null}function Bm(e,s){return s===null||In(e)===s}let Zl=null;function cw(){return Zl||(Zl=L.listProfiles().catch(()=>[])),Zl}function $r(){const[e,s]=h.useState([]);return h.useEffect(()=>{let a=!0;return cw().then(o=>{a&&s(o)}),()=>{a=!1}},[]),e}function uw(e){const s=$r();return Bn(e,s)}function no(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}const Dm=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview","_source"]);function Wt(e){const s=e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)}function Un(e){const s=e.indexOf("__");return s<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,s),toolName:e.slice(s+2)}}function dw(e){const{integrationId:s,toolName:a}=Un(e);return s?`${s} · ${a}`:a}function _r(e,s){const a=s==null?void 0:s.find(o=>o.id===e);return a!=null&&a.name?a.name:e?e.toUpperCase():"the system"}function fw(e){return Array.isArray(e)?"list":e&&typeof e=="object"?"object":typeof e=="string"&&(e.includes(`
|
|
66
|
+
`)||e.length>120)?"markdown":"text"}function Um(e,s){var f,p;const a=(s==null?void 0:s.approvalView)??{},o=((f=s==null?void 0:s.inputSchema)==null?void 0:f.properties)??{},l=[...new Set([...Object.keys(a),...Object.keys(o),...Object.keys(e)])],u=[];for(const g of l){if(!(g in e)||Dm.has(g))continue;const v=e[g],y=a[g]??{},x=y.kind??fw(v),j={key:g,label:y.label??Wt(g),kind:x,value:v,hint:(p=o[g])==null?void 0:p.description};x==="money"&&y.currencyArg&&typeof e[y.currencyArg]=="string"&&(j.currency=e[y.currencyArg]),x==="profile"&&typeof v=="string"&&(j.profileRef=v),(x==="profile-limits"||x==="profile-scope")&&y.profileArg&&typeof e[y.profileArg]=="string"&&(j.profileRef=e[y.profileArg]),u.push(j)}return u}function hw(e,s){var o,l;const a=(l=(o=s==null?void 0:s.scopeSchema)==null?void 0:o.fields)==null?void 0:l[e];return a?{label:a.displayName??e,hint:a.description}:{label:e}}function mw(e,s,a){if(!e||typeof e!="object"||Array.isArray(e))return[];const o=a==="limits"?s==null?void 0:s.boundsSchema:s==null?void 0:s.scopeSchema,l=(o==null?void 0:o.fields)??{},u=[...new Set([...(o==null?void 0:o.keyOrder)??[],...Object.keys(e)])],f=[];for(const p of u){if(p==="profile"||!(p in e))continue;const g=e[p],v=l[p],y=no(v==null?void 0:v.unit),x=Array.isArray(g)?g.join(", "):String(g);f.push({key:p,label:(v==null?void 0:v.displayName)??Wt(p),value:y?`${x} ${y}`:x,hint:v==null?void 0:v.description,unknown:s?!v:void 0})}return f}function Wm(e){const s=e.indexOf("__");return s<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,s),toolName:e.slice(s+2)}}function ro(e,s){var g,v,y;const{integrationId:a,toolName:o}=Wm(e.action),l=s.find(x=>x.id===a),u=(v=(g=l==null?void 0:l.toolGating)==null?void 0:g.overrides)==null?void 0:v[o];if(u!=null&&u.actionLabel)return u.actionLabel;const f=Mt(e.profileId),p=(y=e.executionContext)==null?void 0:y.action_type;return typeof p=="string"&&p?`${f} · ${p}`:`${f} · ${o}`}function pw(e,s){var l;const a=(l=s==null?void 0:s.scopeSchema)==null?void 0:l.fields;if(!a)return"";const o=[];for(const[u,f]of Object.entries(e.executionContext??{})){if(!(u in a))continue;const p=String(f??"").trim();p&&o.push(p.split(",").map(g=>g.trim()).filter(Boolean).join(", "))}return o.join(" · ")}function gw(e,s){var l,u;if(!e)return"";const a=((l=s==null?void 0:s.scopeSchema)==null?void 0:l.fields)??{},o=[];for(const[f,p]of Object.entries(e)){if(f==="action_type")continue;const g=String(p??"").trim();if(!g)continue;const v=((u=a[f])==null?void 0:u.displayName)??f;o.push(`${v} ${g.split(",").map(y=>y.trim()).filter(Boolean).join(", ")}`)}return o.join(" · ")}function rh(e){return e.appliesTo}function yw(e,s,a,o){var v,y,x;const l=(v=a==null?void 0:a.boundsSchema)==null?void 0:v.fields;if(!l||!s)return;const u=e.actionType??(typeof((y=e.executionContext)==null?void 0:y.action_type)=="string"?e.executionContext.action_type:void 0),f=Object.entries(l).filter(([j,k])=>{if(!(j in s))return!1;const b=k.boundType;if(!b||b.kind!=="cumulative_sum"&&b.kind!=="cumulative_count"||b.window!==o)return!1;const S=rh(k);return!S||!u||S.includes(u)}),g=(u?f.find(([,j])=>{var k;return(k=rh(j))==null?void 0:k.includes(u)}):void 0)??(f.length===1?f[0]:void 0);return g?{key:g[0],isAmount:((x=g[1].boundType)==null?void 0:x.kind)==="cumulative_sum"}:void 0}function Hm(e,s,a,o){var p;const l=(p=e.cumulativeState)==null?void 0:p[o];if(!l)return null;const u=yw(e,s,a,o),f=u?Number(s==null?void 0:s[u.key]):NaN;return u&&Number.isFinite(f)?{used:u.isAmount?l.amount:l.count,limit:f}:{count:l.count}}function vw(e,s,a){const o=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],l=[];for(const{window:u,label:f}of o){const p=Hm(e,s,a,u);p&&l.push("limit"in p?`${p.used} of ${p.limit} ${f}`:`${p.count} ${p.count===1?"call":"calls"} ${f}`)}return l.join(" · ")}function xw(e,s,a){var u;const o=(u=a==null?void 0:a.boundsSchema)==null?void 0:u.fields;if(!e||!s||!o)return[];const l=[];for(const[f,p]of Object.entries(o)){const g=p.boundType;if(!g||g.kind!=="per_transaction")continue;const v=g.of;if(!(v in e)||!(f in s))continue;const y=Number(e[v]),x=Number(s[f]);if(!Number.isFinite(y)||!Number.isFinite(x))continue;const j=no(p.unit),k=p.displayName??Wt(v),b=S=>j?`${S.toLocaleString()} ${j}`:S.toLocaleString();l.push({key:f,label:k,ok:y<=x,valueText:b(y),limitText:b(x)})}return l}function Oi(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function ww(e){const s=Mt(e),a=e.split("@")[1];return a?`${s}@${a}`:s}const jw=["automatic","approved","all"];function Sw(e){return e==="automatic"||e==="approved"?e:"all"}function pc(e,s){return s==="all"?!0:s==="approved"?Oi(e):!Oi(e)}function Ir(e,s){return Bn(e,s)}function pa(e,s){return _r(Wm(e).integrationId,s)}function bw(e,s){const a=Math.max(0,Math.floor((s-e)/1e3));if(a<60)return"just now";const o=Math.floor(a/60);if(o<60)return`${o} min`;const l=Math.floor(o/60);if(l<24)return`${l} h`;const u=Math.floor(l/24);return`${u} ${u===1?"day":"days"}`}function Vm(e,s){const a=bw(e*1e3,s);return a==="just now"?"waiting just now":`waiting ${a}`}const kw=24*3600;function Gm(e,s,a){const o=e-Math.floor(s/1e3);return o<=0||o>kw?null:`Decide by ${new Date(e*1e3).toLocaleString(a,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})} — otherwise it won't run`}function Km(e){return e.replace(/-/g,"").slice(0,8)}function Nw(e,s){const a=new Date(e),o=new Date(s);return a.getFullYear()===o.getFullYear()&&a.getMonth()===o.getMonth()&&a.getDate()===o.getDate()}function Hc(e,s){return Nw(e*1e3,s)}function Bi(e,s){return e.timestamp*1e3>s}function Cw(e,s){var l;const a=new Map;for(const u of e){if(Oi(u))continue;const f=ro(u,s.manifests),g=`${u.authorizationId??u.profileId}|${u.action}`;let v=a.get(g);v||(v={key:g,area:Ir(u.profileId,s.catalog),system:pa(u.action,s.manifests),profileId:u.profileId,mandateTitle:u.authorizationId?(l=s.titles)==null?void 0:l[u.authorizationId]:void 0,label:f,count:0,newCount:0,latestSec:0,tickets:[]},a.set(g,v)),v.count+=1,Bi(u,s.lastSeenMs)&&(v.newCount+=1),v.latestSec=Math.max(v.latestSec,u.timestamp),v.tickets.push(u)}const o=[...a.values()];for(const u of o)u.tickets.sort((f,p)=>p.timestamp-f.timestamp);return o.sort((u,f)=>+(f.newCount>0)-+(u.newCount>0)||f.latestSec-u.latestSec)}function Ew(e,s){var l,u,f,p,g;const a=new Map;for(const v of e){if(!v.authorizationId||!Hc(v.timestamp,s.nowMs))continue;const y=a.get(v.authorizationId);(!y||v.timestamp>y.timestamp||v.timestamp===y.timestamp&&(((u=(l=v.cumulativeState)==null?void 0:l.daily)==null?void 0:u.count)??0)>(((p=(f=y.cumulativeState)==null?void 0:f.daily)==null?void 0:p.count)??0))&&a.set(v.authorizationId,v)}const o=[];for(const[v,y]of a){const x=Hm(y,s.boundsOf(v)??y.limits,s.profileOf(y.profileId),"daily"),j={authorizationId:v,area:Ir(y.profileId,s.catalog),system:pa(y.action,s.manifests),profileId:y.profileId,mandateTitle:(g=s.titles)==null?void 0:g[v]};x&&"limit"in x?o.push({...j,used:x.used,limit:x.limit,ratio:x.limit>0?x.used/x.limit:0}):o.push({...j,used:x?x.count:1,ratio:0})}return o.sort((v,y)=>y.ratio-v.ratio||v.area.localeCompare(y.area))}function sh(e){return e.ratio>=.8}function Di(e,s,a){const o=new Date(e*1e3),l=o.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"});return Hc(e,s)?`today ${l}`:`${o.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`}const Tw={customers:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),n.jsx("path",{d:"M3 19c0-3.3 2.7-5.5 6-5.5s6 2.2 6 5.5"}),n.jsx("circle",{cx:"17",cy:"9",r:"2.4"}),n.jsx("path",{d:"M15.5 13.8c3 .1 5.5 2 5.5 5"})]}),email:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"1.5"}),n.jsx("path",{d:"m3.5 6 8.5 7 8.5-7"})]}),payments:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"1.5"}),n.jsx("path",{d:"M3 10h18M7 15h4"})]}),sales:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h9l4 4v14H6z"}),n.jsx("path",{d:"M15 3v4h4M9 12h7M9 16h5"})]}),calendar:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"5",width:"17",height:"15",rx:"1.5"}),n.jsx("path",{d:"M3.5 10h17M8 3v4M16 3v4"})]}),records:n.jsx("path",{d:"M3 7h7l2 2h9v10H3z"}),publishing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 10v4l11 4V6z"}),n.jsx("path",{d:"M15 9.5c2 .3 3 1.3 3 2.5s-1 2.2-3 2.5M7 14.5 8.5 19h2.5l-1.3-4"})]}),deployments:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12 3v12M7 8l5-5 5 5"}),n.jsx("path",{d:"M4 15v5h16v-5"})]}),purchasing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3 4h2.5l2.2 11h10.6L20.5 7H6.4"}),n.jsx("circle",{cx:"9",cy:"19",r:"1.4"}),n.jsx("circle",{cx:"17",cy:"19",r:"1.4"})]}),reports:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 20V4M4 20h16"}),n.jsx("path",{d:"M8 16v-4M12 16V8M16 16v-6"})]}),setup:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 7h10M18 7h2M4 17h4M12 17h8"}),n.jsx("circle",{cx:"16",cy:"7",r:"2"}),n.jsx("circle",{cx:"10",cy:"17",r:"2"})]}),unknown:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"9.2"}),n.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"}),n.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"17.05"})]})};function ga({icon:e,className:s}){return n.jsx("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Tw[e]})}function cs({profileId:e,area:s,system:a,time:o,trailing:l,leading:u}){return n.jsxs("div",{className:"obj-line",children:[u,n.jsx(ga,{icon:Ar(e)}),n.jsx("b",{children:s}),a&&n.jsxs("span",{children:["· via ",a]}),o&&n.jsxs("span",{children:["· ",o]}),l&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"obj-line-sp"}),l]})]})}function ca({title:e,area:s}){return lw(e,s)?n.jsxs("div",{className:"obj-mandate-line","data-testid":"mandate-line",children:["Mandate: ",e]}):null}async function ah(e){const s=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}function Aw(e){return e.normalize("NFC").replace(/\r\n?/g,`
|
|
67
|
+
`).split(`
|
|
68
|
+
`).map(l=>l.replace(/[ \t]+$/,"")).join(`
|
|
69
|
+
`).replace(/\n+$/,"")}function gc(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(l=>l===void 0?"null":gc(l)).join(",")+"]";const s=e,a=[];for(const o of Object.keys(s).sort()){const l=s[o];l!==void 0&&a.push(JSON.stringify(o)+":"+gc(l))}return"{"+a.join(",")+"}"}async function qm(e,s){if(e==="jcs"){if(typeof s=="string")throw new Error('content_binding kind="jcs" expects a record payload (object), got a string');return`sha256:${await ah(gc(s))}`}if(typeof s!="string")throw new Error('content_binding kind="text" expects a string, got an object');return`sha256:${await ah(Aw(s))}`}async function Ym(e){if(e.toolArgs)return e.toolArgs;if(!e.content)return null;try{const{plaintext:s}=await L.decryptProposalContent(e.content),a=JSON.parse(s);return typeof a!="object"||a===null||Array.isArray(a)?null:a}catch{return null}}function Iw(e){if(!e.content)return[];const s=new Set([...e.createdBy?[e.createdBy]:[],...e.pendingApprovers??[]]),a=new Set(Object.keys(e.content.keys));return Array.from(s).filter(o=>!a.has(o))}function Jm(e){return!e.loading&&e.readable}function Qm(e,s){const a=new Set;if(e.content)for(const o of Object.keys(e.content.keys))a.add(o);else{e.createdBy&&a.add(e.createdBy);for(const o of e.pendingApprovers??[])a.add(o)}return s&&a.add(s),Array.from(a)}async function ia(e){const s=await Ym(e);if(s)return qm("jcs",s)}function Rw(e){var o;const[s,a]=h.useState((e==null?void 0:e.note)??null);return h.useEffect(()=>{let l=!0;if(e!=null&&e.note){a(e.note);return}if(!(e!=null&&e.noteEncrypted)){a(null);return}return a(null),L.decryptProposalContent(e.noteEncrypted).then(({plaintext:u})=>{l&&a(u)}).catch(()=>{l&&a(null)}),()=>{l=!1}},[e==null?void 0:e.note,(o=e==null?void 0:e.noteEncrypted)==null?void 0:o.ciphertext]),s}const Pw={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function so(e){var o;const[s,a]=h.useState(Pw);return h.useEffect(()=>{let l=!0;if(e.toolArgs){a({toolArgs:e.toolArgs,loading:!1,sealed:!1,undecryptable:!1});return}if(!e.content){a({toolArgs:null,loading:!1,sealed:!1,undecryptable:!1});return}return a({toolArgs:null,loading:!0,sealed:!0,undecryptable:!1}),(async()=>{const u=await Ym(e);l&&a({toolArgs:u,loading:!1,sealed:!0,undecryptable:u===null})})(),()=>{l=!1}},[(o=e.content)==null?void 0:o.ciphertext,e.toolArgs]),s}const ih=140,oh=60,$w=/\{([^{}]+)\}/g;function Xm(e,s){var u,f;const{integrationId:a,toolName:o}=Un(e),l=s==null?void 0:s.find(p=>p.id===a);return((f=(u=l==null?void 0:l.toolGating)==null?void 0:u.overrides)==null?void 0:f[o])??void 0}function Zm(e,s){let a=e;for(const o of s.split(".")){if(a===null||typeof a!="object")return;a=a[o]}return a}function lh(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0}function _w(e,s,a,o){if(s==="money"){const u=typeof e=="number"?e:Number(e);if(!Number.isFinite(u))return String(e);if(a&&/^[A-Za-z]{3}$/.test(a))try{return new Intl.NumberFormat(o,{style:"currency",currency:a.toUpperCase()}).format(u)}catch{}return new Intl.NumberFormat(o,{maximumFractionDigits:2}).format(u)}if(s==="percent")return`${e}%`;if(s==="date"){const u=new Date(String(e));return Number.isNaN(u.getTime())?String(e):u.toLocaleDateString(o,{day:"numeric",month:"short"})}if(Array.isArray(e)){const u=e.map(f=>typeof f=="object"&&f!==null?JSON.stringify(f):String(f));return u.length>2?`${u.slice(0,2).join(", ")} +${u.length-2}`:u.join(", ")}const l=typeof e=="object"?JSON.stringify(e):String(e);return s==="short"&&l.length>oh?`${l.slice(0,oh-1).trimEnd()}…`:l}function ch(e,s,a,o){let l=!1;const u=e.replace($w,(f,p)=>{const[g,v]=p.split("|").map(x=>x.trim()),y=g.split(",").map(x=>Zm(s,x.trim())).find(lh);return lh(y)?_w(y,v,a,o):(l=!0,"")});return l?null:u}function ep(e,s,a={}){const o=Zm(s,a.currencyField??"currency"),l=typeof o=="string"?o:void 0,u=e.replace(/\[([^[\]]*)\]/g,(g,v)=>ch(v,s,l,a.locale)??""),f=ch(u,s,l,a.locale);if(f===null)return null;const p=f.replace(/\s+/g," ").trim();return p.length>ih?`${p.slice(0,ih-1).trimEnd()}…`:p}function tp(e,s,a,o){var f;const l=Wt(Un(e).toolName),u=Xm(e,a);return!(u!=null&&u.summary)||!s?l:ep(u.summary,s,{currencyField:(f=u.display)==null?void 0:f.currencyField,locale:o})??l}function Lw(e,s,a,o){var u;const l=Xm(e,a);return!(l!=null&&l.summary)||!s?null:ep(l.summary,s,{currencyField:(u=l.display)==null?void 0:u.currencyField,locale:o})}function np({proposal:e,manifests:s}){const a=so(e);return n.jsx(n.Fragment,{children:tp(e.tool,a.toolArgs,s)})}function ec({variant:e="base",style:s,className:a,...o}){const l=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return n.jsx("span",{className:`${l}${a?` ${a}`:""}`,style:s,role:"status","aria-busy":"true","aria-label":o["aria-label"]??"Loading"})}const is=5;function zw({auths:e,activeCount:s,waiting:a,waitingReady:o}){const[l,u]=h.useState(null),[f,p]=h.useState(null),[g,v]=h.useState([]),[y,x]=h.useState({}),[j,k]=h.useState({}),b=h.useCallback(()=>{L.getMyReceiptsPage({limit:200}).then(z=>u(z.receipts)).catch(()=>u(z=>z??[])),L.getLastSeenTicketsAt().then(p).catch(()=>p(Number.POSITIVE_INFINITY))},[]);Ft(b,3e5),Fe("ticket-recorded",b),h.useEffect(()=>{L.getLabelManifests().then(v).catch(()=>{}),L.getLocalAuthorizations().then(({authorizations:z})=>x(z)).catch(()=>{})},[]);const S=$r(),N=h.useMemo(()=>{const z={};for(const U of e)U.authorization_id&&U.title&&(z[U.authorization_id]=U.title);return z},[e]),E=Date.now(),T=h.useMemo(()=>{const z=Date.now();return(l??[]).filter(U=>Hc(U.timestamp,z))},[l]);h.useEffect(()=>{const z=[...new Set(T.map(U=>U.profileId))].filter(U=>!(U in j));z.length!==0&&Promise.all(z.map(U=>Mm(U).then(ee=>[U,ee]).catch(()=>[U,null]))).then(U=>k(ee=>({...ee,...Object.fromEntries(U)})))},[T,j]);const P=h.useMemo(()=>Cw(T,{catalog:S,manifests:g,titles:N,lastSeenMs:f??Number.POSITIVE_INFINITY}),[T,S,g,N,f]),I=T.filter(z=>pc(z,"approved")).length,B=h.useMemo(()=>Ew(T,{nowMs:Date.now(),catalog:S,manifests:g,titles:N,boundsOf:z=>{var U;return(U=y[z])==null?void 0:U.bounds},profileOf:z=>j[z]}),[T,S,g,N,y,j]),O=P.filter(z=>z.newCount>0).length,K=[...a].sort((z,U)=>z.createdAt-U.createdAt);return n.jsxs("div",{className:"core-cols","data-testid":"core-cols",children:[n.jsxs("section",{"aria-label":"Waiting for you","data-testid":"col-waiting",children:[n.jsxs("div",{className:"core-col-h is-main",children:[n.jsx("h2",{children:"Waiting for you"}),a.length>0&&n.jsx("span",{className:"pill-count",children:a.length})]}),o?K.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing waits for your decision."}):K.slice(0,is).map(z=>{const U=Gm(z.expiresAt,E);return n.jsxs(mt,{to:`/approvals?open=${encodeURIComponent(z.id)}`,className:"appr-item appr-item-link","data-testid":"dash-approval",children:[n.jsxs("div",{className:"appr-item-main",children:[n.jsx(cs,{profileId:z.profileId,area:Ir(z.profileId,S),system:pa(z.tool,g),time:Vm(z.createdAt,E)}),n.jsx("div",{className:"appr-item-sum",children:n.jsx(np,{proposal:z,manifests:g})}),n.jsx(ca,{title:z.authorizationId?N[z.authorizationId]:void 0,area:Ir(z.profileId,S)}),U&&n.jsx("div",{className:"obj-due",children:U})]}),n.jsx("span",{className:"appr-item-chev","aria-hidden":"true",children:"›"})]},z.id)}):n.jsx(ec,{variant:"line"}),K.length>0&&n.jsx(mt,{to:"/approvals",className:"col-btn",children:"All approvals ›"})]}),n.jsxs("section",{"aria-label":"Done automatically","data-testid":"col-automatic",children:[n.jsxs("div",{className:"core-col-h",children:[n.jsx("h2",{children:"Done automatically"}),O>0&&n.jsxs("span",{className:"meta",children:[P.reduce((z,U)=>z+U.newCount,0)," new"]})]}),l===null?n.jsx(ec,{variant:"line"}):P.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing was done automatically today."}):P.slice(0,is).map(z=>n.jsxs("details",{className:`auto-grp${z.newCount>0?"":" is-seen"}`,"data-testid":"auto-group",children:[n.jsxs("summary",{children:[n.jsx("span",{className:`seen-dot${z.newCount>0?" is-new":""}`,"aria-label":z.newCount>0?"new since your last visit":"seen"}),n.jsxs("span",{className:"auto-grp-txt",children:[n.jsx(cs,{profileId:z.profileId,area:z.area,system:z.system}),n.jsxs("b",{children:[z.count," × ",z.label]}),n.jsx(ca,{title:z.mandateTitle,area:z.area}),n.jsxs("span",{className:"meta",children:[z.newCount>0?`${z.newCount} new`:"seen"," · latest ",Di(z.latestSec,E)]})]})]}),n.jsxs("div",{className:"auto-grp-list",children:[z.tickets.slice(0,is).map(U=>n.jsxs("div",{className:"auto-grp-row",children:[n.jsx("span",{className:`seen-dot${Bi(U,f??Number.POSITIVE_INFINITY)?" is-new":""}`}),ro(U,g),n.jsxs("span",{className:"t",children:[Di(U.timestamp,E)," · ",Km(U.id)]})]},U.id)),z.tickets.length>is&&n.jsxs("div",{className:"auto-grp-row meta",children:["+ ",z.tickets.length-is," more in Tickets"]})]})]},z.key)),P.length>0&&n.jsx(mt,{to:"/tickets?filter=automatic",className:"col-btn","data-testid":"btn-automatic-tickets",children:"Automatic tickets ›"}),I>0&&n.jsxs("div",{className:"core-quiet-line",children:[I," approved today — ",n.jsx(mt,{to:"/tickets?filter=approved",children:"see approved tickets"})]})]}),n.jsxs("section",{"aria-label":"Mandates at work today","data-testid":"col-mandates",children:[n.jsx("div",{className:"core-col-h",children:n.jsx("h2",{children:"Mandates at work today"})}),l===null?n.jsx(ec,{variant:"line"}):B.length===0?n.jsx("p",{className:"core-col-empty",children:"No mandate has acted today."}):B.slice(0,is).map(z=>n.jsxs("div",{className:"mandate-obj","data-testid":"mandate-at-work",children:[n.jsx(cs,{profileId:z.profileId,area:z.area,system:z.system}),z.mandateTitle&&z.mandateTitle.trim().toLowerCase()!==z.area.trim().toLowerCase()&&n.jsx("div",{className:"mandate-obj-title",children:z.mandateTitle}),n.jsx("div",{className:`usage${sh(z)?" is-near":""}`,children:z.limit!==void 0?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"usage-bar",children:n.jsx("i",{style:{width:`${Math.min(100,Math.round(z.ratio*100))}%`}})}),n.jsxs("span",{children:[sh(z)?n.jsxs("b",{children:[z.used," of ",z.limit]}):`${z.used} of ${z.limit}`," today"]})]}):n.jsxs("span",{children:[z.used," ",z.used===1?"action":"actions"," today"]})})]},z.authorizationId)),l!==null&&s>B.length&&n.jsxs("div",{className:"meta",style:{marginTop:"var(--space-2)",fontSize:"var(--text-caption)"},children:[s-B.length," more mandate",s-B.length===1?"":"s"," in force — no actions today"]}),B.length>0&&n.jsx(mt,{to:"/mandates",className:"col-btn",children:"All mandates ›"})]})]})}function Fw(){const[e,s]=h.useState(null),[a,o]=h.useState(Number.POSITIVE_INFINITY),l=h.useCallback(()=>{Promise.all([L.getReport().then(p=>p.report).catch(()=>null),L.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]).then(([p,g])=>{s(p),o(g)})},[]);if(Ft(l,3e5),Fe("report-written",l),!e||!Cm(e,a))return null;const{verified:u,unchecked:f}=g0(e);return n.jsxs("div",{className:"report-line","data-testid":"report-line",children:[n.jsx("span",{className:"nav-new",style:{marginLeft:0},children:"New"}),n.jsxs("span",{className:"report-line-text",children:[n.jsx("b",{children:p0(e.renderedHtml)})," — ",n.jsx("span",{title:Mi(e.coverage).title,children:Mi(e.coverage).text})," · written ",Em(e.savedAt,Date.now()),f===0?n.jsxs(n.Fragment,{children:[" · all ",u," value",u===1?"":"s"," verified"]}):n.jsxs(n.Fragment,{children:[" · ",u," value",u===1?"":"s"," verified · ",n.jsxs("b",{children:["✕ ",f," could not be checked"]})]})]}),n.jsx(mt,{to:"/reports",className:"col-btn",children:"Open report ›"})]})}function Mw(){const[e,s]=h.useState([]);return Ft(async()=>{try{const{skipped:o}=await L.getSkippedCommitments();s(o)}catch{}},3e4),e.length===0?null:n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1.5rem",borderLeft:"3px dashed var(--text-primary)"},children:[n.jsxs("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:["Approved, but not run here (",e.length,")"]}),n.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."}),n.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",fontSize:"0.9rem"},children:e.map(o=>n.jsxs("li",{style:{marginBottom:"0.35rem"},children:[n.jsx("code",{children:o.tool})," ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",o.id,")"]})]},o.id))})]})}function Ow(e,s){return s&&!la(e.manifest)}function Bw(e,s=!1){var o;const a=[];for(const l of e)Ow(l,s)||(l.state==="error"?a.push({label:"Integration error",detail:(o=l.integration)!=null&&o.error?`${l.manifest.name}: ${l.integration.error}`:`${l.manifest.name} is not running`,to:"/integrations",color:"var(--text-primary)"}):l.state==="not-running"&&(la(l.manifest)?a.push({label:`${l.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--text-primary)"}):a.push({label:"Integration stopped",detail:`${l.manifest.name} is not running`,to:"/integrations",color:"var(--text-primary)"})));return a}function Dw(e){const s=e.filter(a=>a.state==="paused");return s.length===0?null:{count:s.length,namesText:s.map(a=>a.manifest.name).join(", ")}}const Uw=1800;function Zs(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Ww(){const{domain:e}=xt(),[s,a]=h.useState([]),[o,l]=h.useState([]),[u,f]=h.useState([]),[p,g]=h.useState(!0),[v,y]=h.useState(!1),[x,j]=h.useState([]),[k,b]=h.useState(!1),[S,N]=h.useState(!1),[E,T]=h.useState(null),[P,I]=h.useState(!1),{entries:B,activeSessions:O,loading:K}=Oc(),z=rw(),U=!K,{simulation:ee}=Fm(),X=ee===!0,F=iw(),ne=h.useCallback(()=>{L.getMyAttestations().then(le=>{a(le),y(!0)}).catch(()=>y(!0)),L.getArchivedMandates().then(j).catch(()=>j([])),L.getMyProposals(e).then(le=>{l(le),b(!0)}).catch(()=>b(!0)),L.getProposalsForApprover().then(le=>f(le)).catch(()=>f([])),L.getCredential("ai-config").then(le=>{g(le.configured),N(!0)}).catch(()=>N(!0)),L.getAgentContact().then(le=>{T(le.contact),I(!0)}).catch(()=>I(!0))},[e]);Fe("attestation-changed",ne),Fe("proposal-added",ne),Fe("proposal-resolved",ne),Fe("proposal-approved",ne),Fe("proposal-rejected",ne),Fe("execution-failed",ne),Ft(ne,3e5,e);const fe=v&&k&&S&&U&&P&&ee!==null,te=Sm(s,{archivedSet:new Set(x)}),ge=te.active,ke=te.expired,Z=ge.some(le=>Zs(le.profile_id)==="delegation"),Q=ge.filter(le=>Zs(le.profile_id)!=="delegation").length,q=o.filter(le=>Zs(le.profileId)==="delegation").length,A=zm({hasContact:E!==null,hasDelegationMandate:Z,otherMandateCount:Q,delegationProposalCount:q,managed:F,simulationOn:X}),$=X&&A.visible,ie=ge.filter(le=>le.remaining_seconds!==null&&le.remaining_seconds<=Uw),re=o.filter(Im),H=B.filter(le=>le.state==="running"),oe=B.filter(le=>le.state==="starting"),ue=Dw(B),pe=[...re,...u.filter(le=>!re.some(Ge=>Ge.id===le.id))],ve=[];for(const le of ie){const Ge=Math.ceil((le.remaining_seconds??0)/60);ve.push({label:"Expiring soon",detail:`${le.title??Zs(le.profile_id)} — ${Ge} min remaining`,to:"/mandates",color:"var(--text-primary)"})}for(const le of ke)ve.push({label:"Expired",detail:le.title??Zs(le.profile_id),to:"/mandates",color:"var(--text-primary)"});ve.push(...Bw(B,X));for(const le of oe)ve.push({label:"Integration starting",detail:`${le.manifest.name} is coming up…`,to:"/integrations",color:"var(--text-primary)"});for(const le of B)le.authStatus==="failed"&&le.state!=="not-running"&&le.state!=="error"&&le.state!=="paused"&&ve.push({label:"Reconnect needed",detail:`${le.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--text-primary)"});return p||ve.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Dashboard"})}),fe&&z&&($?n.jsx(nw,{contact:E,hasDelegationMandate:Z,otherMandateCount:Q,delegationProposalCount:q,managed:F,simulationOn:X,mcpEndpoint:z}):!X&&n.jsx(ew,{aiConfigured:p,hasRunningIntegration:H.length>0,hasActiveAuth:ge.length>0,hasAgentConnected:O>0,mcpEndpoint:z})),!$&&n.jsxs(n.Fragment,{children:[n.jsx(zw,{auths:s,activeCount:ge.length,waiting:pe,waitingReady:k}),n.jsx(Fw,{}),ve.length>0&&n.jsxs("section",{className:"card attention attention-quiet","aria-label":"Setup — needs attention",children:[n.jsxs("div",{className:"card-header",children:[n.jsx("h2",{className:"card-title",children:"Setup — needs attention"}),n.jsx("span",{className:"rb-count",children:ve.length})]}),n.jsx("div",{className:"attention-rows",children:ve.map((le,Ge)=>n.jsxs(mt,{to:le.to,className:"attention-row",children:[n.jsx("span",{className:"attention-dot",style:{background:le.color},"aria-hidden":"true"}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:le.label}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:le.detail})]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},Ge))})]})]}),ue&&n.jsxs("div",{className:"sim-paused-summary",role:"status",children:[n.jsx("span",{className:"sim-paused-summary-icon","aria-hidden":"true",children:"⏸"}),n.jsxs("span",{children:[n.jsxs("b",{children:[ue.count," real system",ue.count===1?"":"s"," ",ue.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",ue.namesText,"."]})]}),n.jsx(Mw,{}),n.jsx(r0,{})]})}const Hw=["Scope & Limits","Intent","Sign"];function rp({currentStep:e,onStepClick:s}){const a=Sn();return n.jsxs("div",{className:"wizard-progress",children:[n.jsx("ol",{className:"wizard-steps",children:Hw.map((o,l)=>{const u=l+2,f=u<e,p=u===e,g=u-1<e,v=f&&!!s;return n.jsxs("li",{className:`wizard-step${g?" reached":""}`,"aria-current":p?"step":void 0,children:[n.jsx("button",{type:"button",className:`step-circle${f?" completed":""}${p?" current":""}`,onClick:v?()=>s(u):void 0,disabled:!v,"aria-label":`${o}${f?" (done)":p?" (current)":""}`,children:f?"✓":l+1}),n.jsx("span",{className:`step-label-text${p?" current":f?" completed":""}`,children:o})]},u)})}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>a("/mandates?new=1"),children:"Cancel"})]})}function Vw({profileId:e,bounds:s,groupName:a,domain:o,onSwitch:l}){return n.jsxs("div",{className:"context-strip",children:[a&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"context-strip-label",children:"Team:"}),n.jsxs("span",{children:[n.jsx("strong",{children:a}),o?` / ${o}`:""]})]}),e&&n.jsxs("span",{children:[n.jsx("strong",{children:"Profile:"})," ",Mt(e)]}),s&&n.jsxs("span",{children:[n.jsx("strong",{children:"Bounds:"})," ",s]}),l&&n.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:l,children:"Switch"})]})}function Gw({integrationId:e,field:s,value:a,onChange:o,disabled:l,onLabels:u}){const[f,p]=h.useState(null),[g,v]=h.useState(null),[y,x]=h.useState(!0);h.useEffect(()=>{let b=!1;return L.discoverScopeField(e,s).then(S=>{var N;b||(p(S.options),x(!1),(N=S.options)!=null&&N.length&&(u==null||u(Object.fromEntries(S.options.map(E=>[E.value,E.label])))))}).catch(S=>{b||(v(S instanceof Error?S.message:String(S)),x(!1))}),()=>{b=!0}},[e,s]);const j=new Set(a.split(",").map(b=>b.trim()).filter(Boolean)),k=b=>{const S=new Set(j);S.has(b)?S.delete(b):S.add(b),o(Array.from(S).join(","))};return y?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):g||!f?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"msg-attention",style:{fontSize:"0.8rem",marginBottom:"0.5rem"},children:["Couldn't fetch options (",g??"no response","). Enter values manually, separated by commas."]}),n.jsx("input",{className:"form-input",type:"text",value:a,onChange:b=>o(b.target.value),disabled:l})]}):f.length===0?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",e," for this field."]}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:f.map(b=>{const S=b.extras??{},N=typeof S.access=="string"?S.access:void 0,E=N==="reader",T=S.primary===!0;return n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:E?"var(--text-tertiary)":"var(--text-primary)",cursor:l||E?"not-allowed":"pointer"},title:E?"Read-only — you can authorize list/read but not writes":void 0,children:[n.jsx("input",{type:"checkbox",checked:j.has(String(b.value)),onChange:()=>k(String(b.value)),disabled:l||E}),n.jsx("span",{children:b.label||b.value}),T&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),N&&n.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",N]})]},b.value)})})}function Vc(e){if(e.type!=="number")return 0;const s=e.boundType,a=e.unit;return(s==null?void 0:s.kind)==="per_transaction"&&a==="count"?1:0}function uh(e,s){if(s!==void 0)return String(s);const a=e.default;return typeof a=="string"||typeof a=="number"&&Number.isFinite(a)?String(a):Vc(e)===1?"1":""}function yc(e){const s=e.maximum;return typeof s=="number"&&Number.isFinite(s)?s:void 0}function dh(e,s){const a=Vc(e),o=yc(e),l=s===""?a:Math.max(a,Number(s));return o!==void 0?Math.min(o,l):l}function Kw(e,s){var o;const a=(o=e.capKinds)==null?void 0:o[s];return a||(e.approvers.length>0?"approval":"hard")}function Gc(e,s,a){var o;return e.approvers.length===0||(s==null?void 0:s.enforcedBy)==="gatekeeper"||((o=s==null?void 0:s.boundType)==null?void 0:o.kind)==="enum"?"hard":Kw(e,a)}function sp(e,s,a){const o=e.indexOf(s),l=e.indexOf(a);return o===-1||l===-1?!1:l<o}function Ui(e,s){var a;return((a=e.caps)==null?void 0:a[s])!==void 0}function qw(e,s,a){const o=Object.entries(s.caps??{}).filter(([u])=>Gc(s,a[u],u)==="approval");if(o.length===0)return null;const l=u=>{var f;return((f=a[u])==null?void 0:f.displayName)??u};for(const[u,f]of o){const p=a[u],g=p==null?void 0:p.boundType,v=(g==null?void 0:g.kind)==="per_transaction"||(g==null?void 0:g.kind)==="cumulative_sum"?g.of:void 0,y=v?e[v]:void 0;if(typeof f=="number"&&typeof y=="number"&&y>f)return{field:u,fieldLabel:l(u),cap:f,value:y}}if(o.length===1){const[u,f]=o[0];return{field:u,fieldLabel:l(u),cap:f}}return null}function Yw(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Kc(e,s){return s.displayName?s.displayName:e.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function Jw(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function Qw(e){var a;const s=e;return!!(s.enum&&((a=s.constraint)!=null&&a.enforceable.includes("subset")))}function fh(e,s){const a=e.trim();return a?s==="email"?a.includes("@")&&a.indexOf(".",a.indexOf("@"))>-1:s==="domain"?a.includes(".")&&!a.includes("@"):!0:!1}function Xw(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function Zw(e){return e?e==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:e==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:e==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:e==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:e.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function ej(e,s){if(!e||!s)return"";const a=Number(e);if(!Number.isFinite(a)||a<=0)return"";if(s==="minutes"&&a>=60){const o=Math.floor(a/60),l=a%60;return l===0?`${o} hour${o!==1?"s":""}`:`${o}h ${l}m`}if(s==="hours"&&a>=24&&a%24===0){const o=a/24;return`${o} day${o!==1?"s":""}`}if(s==="days"){if(a>=30&&a%30===0)return`${a/30} month${a/30!==1?"s":""}`;if(a>=7&&a%7===0)return`${a/7} week${a/7!==1?"s":""}`}return""}function tj({id:e,value:s,onChange:a,disabled:o,placeholder:l,unit:u,min:f=0,max:p}){const g=Xw(u),v=Zw(u).filter(S=>p===void 0||S.value<=p),y=no(u),x=ej(s,u),j=s===""?null:Number(s),k=()=>{const S=s===""?0:Number(s),N=S%g,E=N===0?S+g:S+(g-N);a(String(p!==void 0?Math.min(p,E):E))},b=()=>{const S=s===""?0:Number(s);if(S<=f)return;const N=S%g,E=N===0?S-g:S-N;a(String(Math.max(f,E)))};return n.jsxs("div",{className:"bounded-input",children:[n.jsxs("div",{className:"bounded-input-field",children:[n.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:b,disabled:o||s===""||Number(s)<=f,"aria-label":"Decrease",children:"−"}),n.jsx("input",{id:e,className:"stepper-input",type:"number",min:f,max:p,step:g,value:s,placeholder:l??String(f),onChange:S=>{const N=S.target.value;a(p!==void 0&&N!==""&&Number(N)>p?String(p):N)},onFocus:S=>S.target.select(),disabled:o}),n.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:k,disabled:o||p!==void 0&&s!==""&&Number(s)>=p,"aria-label":"Increase",children:"+"}),y&&n.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:y})]}),v.length>0&&!o&&n.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:v.map(S=>n.jsx("button",{type:"button",className:`preset-chip${j===S.value?" preset-chip-selected":""}`,onClick:()=>a(String(S.value)),children:S.label},S.value))}),x&&n.jsxs("div",{className:"bounded-input-echo",children:["≈ ",x]})]})}function hh({htmlFor:e,label:s,description:a}){const[o,l]=h.useState(!1);return n.jsxs("div",{className:"field-label-with-tip",children:[n.jsx("label",{className:"form-label",htmlFor:e,children:s}),a&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${s}" mean?`,"aria-expanded":o,onClick:()=>l(u=>!u),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onBlur:()=>l(!1),children:"i"}),o&&n.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:a})]})]})}function nj({id:e,value:s,onChange:a,disabled:o,format:l,placeholder:u}){const[f,p]=h.useState(""),[g,v]=h.useState(!1),y=h.useRef(null),x=s?s.split(",").map(E=>E.trim()).filter(Boolean):[],j=E=>{const T=E.trim();if(!T)return;if(!fh(T,l)){v(!0);return}v(!1);const P=x.includes(T)?x:[...x,T];a(P.join(",")),p("")},k=E=>{const T=x.filter((P,I)=>I!==E);a(T.join(","))},b=E=>{E.key==="Enter"||E.key===","||E.key==="Tab"?f.trim()&&(E.preventDefault(),j(f)):E.key==="Backspace"&&!f&&x.length>0&&k(x.length-1)},S=E=>{const T=E.clipboardData.getData("text");if(T.includes(",")){E.preventDefault();const I=T.split(",").map(O=>O.trim()).filter(Boolean).filter(O=>fh(O,l)),B=[...new Set([...x,...I])];a(B.join(",")),p(""),v(!1)}},N=l==="email"?"Type email and press Enter...":"Type domain and press Enter...";return n.jsxs("div",{className:`tag-input${g?" tag-input-invalid":""}`,onClick:()=>{var E;return(E=y.current)==null?void 0:E.focus()},children:[x.map((E,T)=>n.jsxs("span",{className:"tag-pill",children:[E,!o&&n.jsx("button",{type:"button",className:"tag-remove",onClick:P=>{P.stopPropagation(),k(T)},"aria-label":`Remove ${E}`,children:"×"})]},E)),!o&&n.jsx("input",{ref:y,id:e,className:"tag-input-field",type:"text",value:f,onChange:E=>{p(E.target.value),v(!1)},onKeyDown:b,onPaste:S,onBlur:()=>{f.trim()&&j(f)},placeholder:x.length===0?u??N:""})]})}function rj({id:e,options:s,value:a,onChange:o,disabled:l}){const u=a?a.split(",").map(p=>p.trim()).filter(Boolean):[],f=p=>{const g=u.includes(p)?u.filter(v=>v!==p):[...u,p];o(g.join(","))};return n.jsx("div",{className:"checkbox-group",id:e,children:s.map(p=>n.jsxs("label",{className:`checkbox-pill${u.includes(p)?" checkbox-pill-selected":""}`,children:[n.jsx("input",{type:"checkbox",checked:u.includes(p),onChange:()=>f(p),disabled:l}),n.jsx("span",{children:p})]},p))})}function mh({fieldKey:e,fieldDef:s,value:a,onChange:o,prefix:l,readOnly:u,twoColumn:f,discoveryIntegrationId:p,onLabels:g,capMax:v,enumAllowedFrom:y}){const x=Kc(e,s),j=`${l}-field-${e}`,k=n.jsx(n.Fragment,{children:Qw(s)?n.jsx(rj,{id:j,options:s.enum,value:a,onChange:b=>o(e,b),disabled:u}):(()=>{const b=s.boundType;return(b==null?void 0:b.kind)==="enum"&&Array.isArray(b.values)})()?n.jsxs("select",{id:j,className:"form-select",value:a,onChange:b=>o(e,b.target.value),disabled:u||y!==void 0&&s.boundType.values.length-y<=1,children:[n.jsx("option",{value:"",children:"Select..."}),s.boundType.values.map((b,S)=>n.jsx("option",{value:b,disabled:y!==void 0&&S<y,children:b},b))]}):s.enum?n.jsxs("select",{id:j,className:"form-select",value:a,onChange:b=>o(e,b.target.value),disabled:u,children:[n.jsx("option",{value:"",children:"Select..."}),s.enum.map(b=>n.jsx("option",{value:b,children:b},b))]}):s.type==="number"?n.jsx(tj,{id:j,value:a,onChange:b=>o(e,b),disabled:u,unit:s.unit,min:Vc(s),max:v!==void 0?Math.min(v,yc(s)??v):yc(s)}):Jw(s)?n.jsx(nj,{id:j,value:a,onChange:b=>o(e,b),disabled:u,format:s.format}):p?n.jsx(Gw,{integrationId:p,field:e,value:a,onChange:b=>o(e,b),disabled:u,onLabels:b=>g==null?void 0:g(e,b)}):n.jsx("input",{id:j,className:"form-input",type:"text",value:a,onChange:b=>o(e,b.target.value),disabled:u})});return f?n.jsxs("div",{className:"bounds-field-row",children:[n.jsx("div",{className:"bounds-field-label",children:n.jsx(hh,{htmlFor:j,label:x,description:s.description})}),n.jsx("div",{className:"bounds-field-input",children:k})]},`${l}-${e}`):n.jsxs("div",{className:"form-group",children:[n.jsx(hh,{htmlFor:j,label:x,description:s.description}),k]},`${l}-${e}`)}function sj(e,s,a,o){if(!o||!Ui(o,e))return null;const l=o.caps[e],u=Gc(o,s,e);let f=!1;if(typeof l=="number"){const p=a===""?NaN:Number(a);f=!Number.isNaN(p)&&p>l}else if(typeof l=="string"&&a!==""){const p=s.boundType;f=(p==null?void 0:p.kind)==="enum"?sp(p.values??[],l,a):!1}return{kind:u,cap:l,violating:f}}function ph(e,s,a,o){if(!o||!Ui(o,e))return a;const l=Gc(o,s,e),u=o.caps[e];if(l!=="hard")return a;if(typeof u=="number"){const f=a===""?NaN:Number(a);return String(Number.isNaN(f)?u:Math.min(f,u))}if(typeof u=="string"){const f=s.boundType,p=(f==null?void 0:f.kind)==="enum"?f.values??[]:[];return a!==""&&sp(p,u,a)?u:a}return a}function aj(e,s){if(typeof s!="string")return;const a=e.boundType;if((a==null?void 0:a.kind)!=="enum")return;const o=(a.values??[]).indexOf(s);return o===-1?void 0:o}function ij(e,s){return no(s.unit)||Kc(e,s).toLowerCase()}function ap(e,s){if(s&&s.length>0)return s.join(" or ");const a=(e==null?void 0:e.approvers)??[];return a.length>0?a.join(" or "):"your team's approvers"}function oj(e,s,a,o,l){var v;const u=s.enforcedBy==="gatekeeper",f=((v=s.boundType)==null?void 0:v.kind)==="enum";if(a.kind==="hard")return f?n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${e}`,children:["Disabled by your team's policy — ",Kc(e,s).toLowerCase()," is capped at"," ",String(a.cap)," for this profile."]}):n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${e}`,children:["Team limit ",String(a.cap),u?" — read limits are always hard, no approval path exists for this cap.":""]});const p=ij(e,s),g=ap(o,l);return n.jsxs("span",{className:"cap-note soft","data-testid":`cap-note-${e}`,children:["Every ",p," above ",String(a.cap)," goes to ",g," for approval."]})}function lj({profile:e,onConfirm:s,onCancel:a,readOnly:o,initialBounds:l,initialContext:u,initialFrame:f,profileConfig:p,approverNames:g,adminName:v}){var re;const y=e.boundsSchema,x=e.scopeSchema,j=H=>!!p&&Ui(p,H),k=y?Object.entries(y.fields).filter(([H,oe])=>!(H==="profile"||H==="path"||oe.enforced===!1||oe.enforcedBy==="gatekeeper"&&!j(H))):[],b=y?Object.entries(y.fields).filter(([H,oe])=>oe.enforcedBy==="gatekeeper"&&!j(H)).filter(([,H])=>H.enforced!==!1).map(([H,oe])=>oe.displayName??H):[],S=x&&x.keyOrder.length>0?Object.entries(x.fields):[],N=l??f??{},E=u??{},T={};for(const[H,oe]of k)T[H]=ph(H,oe,uh(oe,N[H]),p);const P={};for(const[H]of S)P[H]=E[H]!==void 0?String(E[H]):"";const[I,B]=h.useState(T),[O,K]=h.useState(P),[z,U]=h.useState({}),ee=h.useRef(new Set);h.useEffect(()=>{B(H=>{let oe=!1;const ue={...H};for(const[pe,ve]of k){if(ee.current.has(pe))continue;const le=H[pe]!==void 0?H[pe]:uh(ve,N[pe]),Ge=ph(pe,ve,le,p);ue[pe]!==Ge&&(ue[pe]=Ge,oe=!0)}return oe?ue:H})},[p]);const[X,F]=h.useState(null);h.useEffect(()=>{const H=Yw(e.id);L.getIntegrationManifests().then(({manifests:oe})=>{const ue=oe.find(pe=>pe.profile===H&&pe.contextDiscovery&&Object.keys(pe.contextDiscovery).length>0);F(ue??null)}).catch(()=>F(null))},[e.id]);const ne={};for(const[H,oe]of k)ne[H]=sj(H,oe,I[H]??"",p);const fe=Object.entries(ne).filter(([,H])=>(H==null?void 0:H.kind)==="hard"&&H.violating).map(([H])=>H),te=!!p&&(((re=p.approvers)==null?void 0:re.length)??0)>0&&k.every(([H])=>!Ui(p,H)),ge=(H,oe)=>{ee.current.add(H),B(ue=>({...ue,[H]:oe}))},ke=(H,oe)=>{K(ue=>({...ue,[H]:oe}))},Z=()=>{const H={profile:e.id};for(const[ue,pe]of k)pe.type==="number"?H[ue]=dh(pe,I[ue]):H[ue]=I[ue];const oe={};for(const[ue,pe]of S)pe.type==="number"?oe[ue]=O[ue]===""?0:Number(O[ue]):oe[ue]=O[ue];return[H,oe]},Q=()=>{const[H,oe]=Z();s(H,oe,z)},q=()=>{var pe;const H={...I};for(const ve of fe){const le=(pe=ne[ve])==null?void 0:pe.cap;le!==void 0&&(H[ve]=String(le))}B(H);const oe={profile:e.id};for(const[ve,le]of k)le.type==="number"?oe[ve]=dh(le,H[ve]??""):oe[ve]=H[ve]??"";const ue={};for(const[ve,le]of S)le.type==="number"?ue[ve]=O[ve]===""?0:Number(O[ve]):ue[ve]=O[ve];s(oe,ue,z)},A=()=>{if(!te)return null;const H=ap(p,g);return n.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:[n.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",H]}),n.jsxs("div",{children:["No caps are set on this profile, so ",H," 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(fe.length===0)return null;const H=v??"the team admin";return n.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"2px solid var(--border-strong)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[n.jsx("div",{className:"msg-error",style:{marginBottom:"0.25rem"},children:"Hard team ceiling."}),n.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Lower the bound(s) above, or ask ",H," to add an approver path above the cap."]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:q,children:"Save below cap"}),a&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:a,children:"Cancel"})]})]})},ie=fe.length>0;return n.jsxs("div",{children:[S.length>0&&n.jsxs("div",{className:"context-section",children:[n.jsxs("div",{className:"bounds-section-header",children:[n.jsx("span",{className:"bounds-section-icon",children:"🛡"}),n.jsxs("div",{children:[n.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),n.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the Authority Server"})]})]}),S.map(([H,oe])=>{var pe;const ue=!!((pe=X==null?void 0:X.contextDiscovery)!=null&&pe[H]);return n.jsx(mh,{fieldKey:H,fieldDef:oe,value:O[H],onChange:ke,prefix:"context",readOnly:o,discoveryIntegrationId:ue?X.id:void 0,onLabels:(ve,le)=>U(Ge=>({...Ge,[ve]:le}))},`context-${H}`)})]}),k.length>0&&n.jsxs("div",{className:"bounds-section",children:[n.jsxs("div",{className:"bounds-section-header",children:[n.jsx("span",{className:"bounds-section-icon",children:"🔒"}),n.jsxs("div",{children:[n.jsx("div",{className:"bounds-section-title",children:"Limits"}),n.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Authority Server"})]})]}),n.jsx("div",{className:"bounds-fields-grid",children:k.map(([H,oe])=>{const ue=ne[H];return n.jsxs("div",{style:{display:"contents"},children:[n.jsx(mh,{fieldKey:H,fieldDef:oe,value:I[H],onChange:ge,prefix:"bounds",readOnly:o,twoColumn:!0,capMax:(ue==null?void 0:ue.kind)==="hard"&&typeof ue.cap=="number"?ue.cap:void 0,enumAllowedFrom:(ue==null?void 0:ue.kind)==="hard"?aj(oe,ue.cap):void 0}),ue&&n.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:oj(H,oe,ue,p,g)})]},`bounds-${H}`)})}),A(),$(),b.length>0&&n.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[b.join(", ")," ",b.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"," ",n.jsx(mt,{to:"/integrations",children:"Integrations"}),"."]})]}),n.jsx("button",{className:"btn btn-primary",onClick:Q,disabled:ie,style:{marginTop:"0.5rem"},children:o?"Next: Gates":"Next: Problem Statement"})]})}function cj(e){var a;const s=e.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((a=s==null?void 0:s[1])==null?void 0:a.trim())??null}function uj(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const dj="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:e,currentText:s,onApply:a,greeting:o,placeholder:l,title:u}){const[f,p]=h.useState([{role:"assistant",content:o??dj}]),[g,v]=h.useState(""),[y,x]=h.useState(!1),[j,k]=h.useState(null),b=h.useRef(null),S=h.useRef(null);h.useEffect(()=>{const T=b.current;if(!T)return;const P=f[f.length-1],I=S.current;!y&&(P==null?void 0:P.role)==="assistant"&&f.length>1&&I?T.scrollTop=I.offsetTop:T.scrollTop=T.scrollHeight},[f,y]);const N=async()=>{const T=g.trim();if(!T||y)return;const P=[...f,{role:"user",content:T}];p(P),v(""),k(null),x(!0);try{const I=await L.aiChat({target:e,currentText:s,messages:P.filter((B,O)=>!(O===0&&B.role==="assistant"))});I.success&&I.reply?p(B=>[...B,{role:"assistant",content:I.reply}]):k(I.error??"AI returned no reply")}catch(I){k(I instanceof Error?I.message:"Chat failed")}finally{x(!1)}},E=T=>{T.key==="Enter"&&!T.shiftKey&&!T.nativeEvent.isComposing&&(T.preventDefault(),N())};return n.jsxs("div",{className:"intent-chat",children:[n.jsx("h3",{className:"card-title",children:u??"AI Assistant"}),n.jsxs("div",{ref:b,className:"chat-messages",children:[f.map((T,P)=>{const I=T.role==="assistant"?cj(T.content):null,B=I?uj(T.content):T.content;return n.jsx("div",{className:`chat-msg ${T.role}`,ref:P===f.length-1?S:void 0,children:n.jsxs("div",{className:"chat-msg-body",children:[B&&n.jsx("div",{className:"chat-msg-prose",children:B}),I!==null&&n.jsxs(n.Fragment,{children:[n.jsx("pre",{className:"chat-fenced-block",children:I}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>a(I),children:"Apply this draft"})]})]})},P)}),y&&n.jsx("div",{className:"chat-msg assistant",children:n.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),j&&n.jsx("div",{className:"error-message",children:j}),n.jsxs("div",{className:"chat-composer",children:[n.jsxs("div",{className:"chat-composer-pill",children:[n.jsx("textarea",{className:"chat-input",value:g,onChange:T=>v(T.target.value),onKeyDown:E,placeholder:l??"Ask for help articulating the intent…",rows:1,disabled:y}),n.jsx("button",{type:"button",className:"chat-send-btn",onClick:N,disabled:y||!g.trim(),"aria-label":"Send",children:"↑"})]}),n.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function ip({open:e,onClose:s,children:a,ariaLabel:o}){const l=h.useRef(null),u=h.useRef(null);return h.useEffect(()=>{var p;if(!e)return;u.current=document.activeElement,document.body.style.overflow="hidden";const f=g=>{g.key==="Escape"&&s()};return document.addEventListener("keydown",f),(p=l.current)==null||p.focus(),()=>{document.removeEventListener("keydown",f),document.body.style.overflow="",u.current instanceof HTMLElement&&u.current.focus()}},[e,s]),Nx.createPortal(n.jsxs(n.Fragment,{children:[n.jsx("div",{className:`bottom-sheet-backdrop${e?" is-open":""}`,onClick:s,"aria-hidden":"true"}),n.jsxs("aside",{ref:l,className:`bottom-sheet${e?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":o,tabIndex:-1,children:[n.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),n.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:s,"aria-label":"Close",children:"×"}),a]})]}),document.body)}function fj(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hj(e,s,a){if(s.length===0)return[{text:e,label:e,matched:null}];const o=[],l=new Set;for(const g of s)if(!(!g.scope||g.scope==="all (unscoped)"))for(const v of[g.scope,...g.scope.split(",").map(y=>y.trim())]){const y=v.toLowerCase();v&&!l.has(y)&&(l.add(y),o.push(v))}o.sort((g,v)=>v.length-g.length);const u=g=>{const v=g.toLowerCase();return s.filter(y=>{var x,j;return((x=y.scope)==null?void 0:x.toLowerCase())===v||((j=y.scope)==null?void 0:j.split(",").map(k=>k.trim().toLowerCase()).includes(v))})},f=["\\[\\d+\\]",...o.map(fj)],p=new RegExp(`(${f.join("|")})`,"gi");return e.split(p).filter(g=>g!=="").map(g=>{const v=/^\[(\d+)\]$/.exec(g);if(v){const y=s[Number(v[1])-1];if(y){const x=y.scope&&y.scope!=="all (unscoped)"?y.scope:"all recipients",j=a?`${a}: ${x}`:x;return{text:g,label:j,matched:[y]}}}else if(o.some(y=>y.toLowerCase()===g.toLowerCase())){const y=u(g);if(y.length>0)return{text:g,label:g,matched:y}}return{text:g,label:g,matched:null}})}const gh=`Why — What's the situation? Why does this need to happen?
|
|
70
|
+
|
|
71
|
+
Goal — What should the agent try to achieve?
|
|
72
|
+
|
|
73
|
+
Watch out — What should the agent avoid or be careful about?`;function mj(e,s,a,o){return hj(e,s,o).map((l,u)=>{if(!l.matched)return n.jsx("span",{children:l.text},u);const f=l.matched;return n.jsx("button",{type:"button",onClick:()=>a(f),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:l.label},u)})}function pj(){var Se;const e=Sn(),[s]=ps(),a=Number(s.get("step"))||2,[o,l]=h.useState(null),[u,f]=h.useState(null),[p,g]=h.useState(a),[v,y]=h.useState(null),[x,j]=h.useState(null),[k,b]=h.useState({}),[S,N]=h.useState(gh),[E,T]=h.useState(!1),[P,I]=h.useState(null),[B,O]=h.useState(!0),[K,z]=h.useState(null),[U,ee]=h.useState([]),[X,F]=h.useState(void 0),[ne,fe]=h.useState(!1),[te,ge]=h.useState(null),[ke,Z]=h.useState(null),[Q,q]=h.useState(null),[A,$]=h.useState([]),[ie,re]=h.useState(null);h.useEffect(()=>{var Be;const Y=sessionStorage.getItem("agentAuth");if(!Y){e("/mandates?new=1");return}const $e=JSON.parse(Y);l($e),$e.intentHint&&N($e.intentHint),L.getCredential("ai-config").then(ze=>I(ze.configured)).catch(()=>I(!1));const _e=sessionStorage.getItem("agentGate");if(_e){const ze=JSON.parse(_e);ze.bounds&&y(ze.bounds),ze.context&&j(ze.context),(Be=ze.gateContent)!=null&&Be.intent&&N(ze.gateContent.intent)}L.getProfile($e.profileId).then(ze=>f(ze)).catch(()=>e("/mandates?new=1")).finally(()=>O(!1)),$e.groupId&&Promise.all([L.getTeamProfileConfig($e.groupId,$e.profileId).catch(()=>null),L.getGroupById($e.groupId).catch(()=>null),L.listUsers().catch(()=>[])]).then(([ze,it,tt])=>{if(z(ze),ze){const Qe=new Map;for(const Me of tt){const me=Me.name&&Me.email?`${Me.name} (${Me.email})`:Me.name||Me.email||Me.id;Qe.set(Me.id,me)}const Ye=(it==null?void 0:it.members)??[];for(const Me of Ye){const me=Me.userId??Me.id;me&&(Me.name&&Me.email?Qe.set(me,`${Me.name} (${Me.email})`):Me.name&&Qe.set(me,Me.name))}const jt=(ze.approvers??[]).map(Me=>Qe.get(Me)??Me);ee(jt);const pt=Ye.find(Me=>Me.role==="admin");if(pt){const Me=pt.userId??pt.id;Me&&F(Qe.get(Me)??pt.name)}}})},[e]);const H=v?Object.entries(v).filter(([Y])=>Y!=="profile"&&Y!=="path").map(([Y,$e])=>`${Y} = ${$e}`).join(", "):"",oe=(Y,$e,_e)=>{y(Y),j($e),_e&&b(_e),g(3)},ue=S.trim()!==gh.trim()&&S.trim()!=="",pe=Y=>{ue&&!confirm("Replace your current intent with the AI draft?")||N(Y)},ve=()=>{const Y=u==null?void 0:u.ttl,$e={intent:S},_e=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({..._e,bounds:v,context:x,contextLabels:k,gateContent:$e,ttlConfig:Y})),e("/mandates/new/sign")},le=async()=>{if(o){fe(!0),ge(null),Z(null),q(null),$([]),re(null);try{const Y=await L.aiIntentReview({profileId:o.profileId,newIntent:S,context:x??void 0});$(Y.grants??[]),Y.success?Y.review?ge(Y.review):Z(Y.note??"No other mandates on this profile to compare against."):q(Y.error??"Check failed.")}catch(Y){q(Y instanceof Error?Y.message:"Check failed.")}finally{fe(!1)}}},Ge=Y=>{N(Y),(te||ke||Q)&&(ge(null),Z(null),q(null),$([]),re(null))};return B||!o||!u?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):n.jsxs(n.Fragment,{children:[n.jsx(rp,{currentStep:p,onStepClick:Y=>{Y>=2&&g(Y)}}),n.jsx(Vw,{profileId:o.profileId,bounds:H||void 0,groupName:o.groupName,domain:o.domain}),p===2&&n.jsx("div",{className:"card",children:n.jsx(lj,{profile:u,onConfirm:oe,onCancel:()=>e("/mandates?new=1"),initialBounds:v||void 0,initialContext:x||void 0,profileConfig:K,approverNames:U,adminName:X})}),p===3&&n.jsxs("div",{className:`intent-layout${P?"":" no-chat"}`,children:[P&&n.jsx("div",{className:"card intent-pane chat tool",children:n.jsx(Wi,{target:{kind:"intent",profileId:o.profileId,bounds:H||void 0},currentText:S,onApply:pe})}),n.jsxs("div",{className:"card intent-pane document",children:[n.jsx("h3",{className:"card-title",children:"What should your agent know?"}),n.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),n.jsx("textarea",{className:"intent-textarea",value:S,onChange:Y=>Ge(Y.target.value)}),n.jsxs("div",{className:"char-counter",children:[S.length," / 2000"]})]}),P===!1&&n.jsxs("p",{className:"intent-ai-hint",children:[n.jsx(mt,{to:"/settings",children:"Set up an AI assistant in Settings"})," to get help writing this."]}),P&&n.jsxs("div",{style:{marginTop:"0.5rem"},children:[n.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:le,disabled:ne||!ue,children:ne?"Checking…":"Check against my other grants"}),Q&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeft:"3px solid var(--text-primary)"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),n.jsx("div",{className:"hint-body",children:Q})]}),ke&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsx("div",{className:"hint-body",children:ke})]}),te&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:[n.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:mj(te,A,re,Mt(o.profileId))}),n.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),n.jsxs("div",{className:"intent-footer",children:[n.jsx("button",{className:"btn btn-ghost",onClick:()=>g(2),children:"Back"}),n.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:ve,disabled:!ue,children:"Continue to Review"})]}),(((Se=K==null?void 0:K.approvers)==null?void 0:Se.length)??0)>0&&n.jsxs("div",{className:"hint-box",role:"note",children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:[n.jsxs("div",{className:"hint-head",children:["Visible to ",U.length>0?U.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",U.length>0?U.join(", "):"this profile's required approvers",". Only they can decrypt it — your Authority Server cannot. Each approver stores a copy as their accountability record."]})]})]}),P&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"floating-help",onClick:()=>T(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),n.jsx(ip,{open:E,onClose:()=>T(!1),ariaLabel:"Intent assistant",children:n.jsx(Wi,{target:{kind:"intent",profileId:o.profileId,bounds:H||void 0},currentText:S,onApply:Y=>{pe(Y),T(!1)}})})]}),ie&&n.jsx("div",{className:"modal-backdrop",onClick:Y=>Y.target===Y.currentTarget&&re(null),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:ie.length>1?`Existing mandates (${ie.length})`:"Existing mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>re(null),children:"×"})]}),n.jsx("div",{className:"modal-body",children:ie.map((Y,$e)=>{var _e;return n.jsxs("div",{style:{marginBottom:$e<ie.length-1?"1rem":0,paddingBottom:$e<ie.length-1?"1rem":0,borderBottom:$e<ie.length-1?"1px solid var(--border)":"none"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),n.jsx("div",{style:{marginBottom:"0.75rem"},children:Y.scope}),n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),n.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((_e=Y.intent)==null?void 0:_e.trim())||"(no intent recorded)"}),Object.entries(Y.bounds).filter(([Be])=>Be!=="profile"&&Be!=="path").length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(Y.bounds).filter(([Be])=>Be!=="profile"&&Be!=="path").map(([Be,ze])=>`${Be}: ${ze}`).join(" · ")})]})]},$e)})})]})})]})]})}function gj(e){return e.normalize("NFC").replace(/\r\n?/g,`
|
|
74
|
+
`).split(`
|
|
75
|
+
`).map(l=>l.replace(/[ \t]+$/,"")).join(`
|
|
76
|
+
`).replace(/\n+$/,"")}async function qc(e){const a=new TextEncoder().encode(e),o=await crypto.subtle.digest("SHA-256",a);return Array.from(new Uint8Array(o)).map(u=>u.toString(16).padStart(2,"0")).join("")}class yj extends Error{constructor(a,o,l){super(l);Js(this,"code");Js(this,"field");this.name="CanonicalValueError",this.code=a,this.field=o}}function vj(e){const s=new TextEncoder().encode(e);let a="";for(const o of s)o===61||o===37||o<32||o>126?a+="%"+o.toString(16).toUpperCase().padStart(2,"0"):a+=String.fromCharCode(o);return a}function op(e,s,a){const o=[];for(const l of s){const u=e[l];if(u==null)continue;const f=String(u);if(f.includes(`
|
|
77
|
+
`)||f.includes("\r"))throw new yj(a,l,`Value for "${l}" contains a raw newline or carriage return. Refusing: a hash over stripped or normalized input would not represent what was authorized.`);o.push(`${l}=${vj(f)}`)}return o.join(`
|
|
78
|
+
`)}async function Li(e,s){const a=s.boundsSchema;if(!a)throw new Error("Profile has no boundsSchema");const o=op(e,a.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await qc(o)}`}async function lp(e,s){const a=s.scopeSchema?op(e,s.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await qc(a)}`}function vc(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(l=>l===void 0?"null":vc(l)).join(",")+"]";const s=e,a=[];for(const o of Object.keys(s).sort()){const l=s[o];l!==void 0&&a.push(JSON.stringify(o)+":"+vc(l))}return"{"+a.join(",")+"}"}async function cp(e){return`sha256:${await qc(vc(e))}`}async function Hi(e){const s=new TextEncoder().encode(gj(e)),a=await crypto.subtle.digest("SHA-256",s);return`sha256:${Array.from(new Uint8Array(a)).map(u=>u.toString(16).padStart(2,"0")).join("")}`}function up(e,s){if(!e.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:e.authorization_id,boundsHash:e.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 xj(e){const s=e.commitment_modes;return s===void 0?["review","automatic"]:Array.isArray(s)?["review","automatic"].filter(a=>s.includes(a)):[]}function wj(e){return e==="per-action"?"review":"automatic"}function yh(e){return e?xj(e).map(s=>s==="review"?"per-action":"immediate"):["per-action","immediate"]}function jj(e,s){return s.includes(e)?e:s[0]??null}function vh(e){return e==null?new Set:new Set(String(e).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean))}function Sj(e,s){for(const a of e)if(s.has(a))return!0;return!1}function bj(e,s,a){for(const o of e){const l=vh(s[o]),u=vh(a[o]);if(!(l.size===0||u.size===0)&&!Sj(l,u))return!1}return!0}function kj(e){return e.length>24?`${e.slice(0,10)}…`:e}function dp(e,s,a){const o=a==null?void 0:a[e];return String(s).split(",").map(u=>u.trim()).filter(Boolean).map(u=>{const f=o==null?void 0:o[u];return f?`${f} (${kj(u)})`:u}).join(", ")}function fp(e){var l;if(e.isPersonal)return{can:!0};if(!e.configLoaded)return{can:!0};const s=e.teamName?`"${e.teamName}"`:"this team";return e.grantors!=="all"&&(((l=e.grantors)==null?void 0:l.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${s}.`,fix:`Ask an admin of ${s} to enable ${e.profileName} and name who may give its mandates.`}:e.grantors==="all"||!!e.userId&&e.grantors.includes(e.userId)?{can:!0}:{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${e.profileName}'s grantors in ${s} can give this — you are not one of them.`,fix:"Ask one of them, or a team admin to add you."}}const Vi=500,Nj=["Lower the discount","Other recipient","Shorter","Different wording"];function Yc(e){const s=e.trim();return s.length===0?{valid:!1,error:"Describe what should change."}:s.length>Vi?{valid:!1,error:`At most ${Vi} characters (currently ${s.length}).`}:{valid:!0,trimmed:s}}function Cj(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hp(e,s){return e.toLowerCase().includes(s.toLowerCase())}function Ej(e,s){const a=e.trim();if(a.length===0)return s;if(!hp(a,s))return`${a}. ${s}`;const o=new RegExp(`\\.?\\s*${Cj(s)}\\.?`,"i");return a.replace(o,"").replace(/\s{2,}/g," ").replace(/^\.\s*/,"").trim()}function mp(){return{outcome:"rejected"}}function Tj(e){const s=Yc(e);if(!s.valid)throw new Error(s.error);return{outcome:"change_needed",note:s.trimmed}}function xh(){return{outcome:"replaced"}}function Aj(e,s){if((e.pendingApprovers??[]).includes(s))return{route:"approver"};const a=e.pendingDomains??[];return a.includes(s)?{route:"resolve",domain:s}:a.includes("owner")?{route:"resolve",domain:"owner"}:null}const Ij={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function Rj(e,s){const a=e.rejectedBy??e.approverRejectedBy;if(!a)return null;const o=a.outcome??"rejected",l=a.note??("reason"in a?a.reason:void 0);return{kind:Ij[o],who:a.userId===s?"You":a.userId,at:a.at,note:l}}function Pj(e){return e.refusal?{kind:"REFUSED",at:e.refusal.at,message:e.refusal.message}:null}function $j(){var Oe,G;const e=Sn(),{user:s,mode:a,domain:o}=xt(),[l,u]=h.useState(null),[f,p]=h.useState(null),[g,v]=h.useState(null),[y,x]=h.useState("per-action"),[j,k]=h.useState(1800),[b,S]=h.useState(86400),[N,E]=h.useState(""),[T,P]=h.useState("hours"),[I,B]=h.useState(""),[O,K]=h.useState(!0),[z,U]=h.useState(!1);h.useEffect(()=>{L.getIdentityDisclosure().then(J=>U(J.always)).catch(()=>{})},[]);const[ee,X]=h.useState(!1),[F,ne]=h.useState(""),[fe,te]=h.useState(null),[ge,ke]=h.useState([]),[Z,Q]=h.useState(!1),[q,A]=h.useState([]),[$,ie]=h.useState(0);h.useEffect(()=>{var Ot;const J=sessionStorage.getItem("agentAuth"),ye=sessionStorage.getItem("agentGate");if(!J||!ye){e("/mandates?new=1");return}const Ue=JSON.parse(J),We=JSON.parse(ye),nt={bounds:We.bounds??{},context:We.context??{},contextLabels:We.contextLabels??void 0,gateContent:We.gateContent};u(Ue),p(nt),We.ttlConfig&&(k(We.ttlConfig.default??1800),S(We.ttlConfig.max??86400)),We.templateMode==="automatic"?x("immediate"):We.templateMode==="review"&&x("per-action");const Ht=((Ot=We.ttlConfig)==null?void 0:Ot.max)??86400;if(typeof We.templateTtl=="number"&&We.templateTtl>0){const Ze=Math.min(We.templateTtl,Ht);k(Ze),[3600,86400,604800,2592e3,31536e3].includes(Ze)||(Ze%86400===0?(E(String(Ze/86400)),P("days")):(E(String(Math.max(1,Math.round(Ze/3600)))),P("hours")))}L.getProfile(Ue.profileId).then(Ze=>{var W;if(v(Ze),!I){const xe=Ze.name??((W=Ue.profileId.split("/").pop())==null?void 0:W.replace(/@.*$/,""))??"",Te=[];if(nt.context&&Ze.scopeSchema)for(const gt of Ze.scopeSchema.keyOrder){const Ke=nt.context[gt];if(Ke!==void 0&&Ke!==""){const Nt=String(Ke).split(",").map(St=>St.trim()).filter(Boolean);Te.push(Nt.join(", "))}}const rt=Te.length>0?`${xe}: ${Te.join(" · ")}`:xe;B(rt)}}).catch(()=>{}),Ue.isPersonal?Q(!0):Promise.all([L.getTeamProfileConfig(Ue.groupId,Ue.profileId).catch(()=>null),L.getGroupById(Ue.groupId).catch(()=>null),L.listUsers().catch(()=>[])]).then(([Ze,W,xe])=>{if(te(Ze),Ze){const Te=new Map;for(const Ke of xe){const Nt=Ke.name&&Ke.email?`${Ke.name} (${Ke.email})`:Ke.name||Ke.email||Ke.id;Te.set(Ke.id,Nt)}const rt=(W==null?void 0:W.members)??[];for(const Ke of rt){const Nt=Ke.userId??Ke.id;Nt&&(Ke.name&&Ke.email?Te.set(Nt,`${Ke.name} (${Ke.email})`):Ke.name&&Te.set(Nt,Ke.name))}const gt=(Ze.approvers??[]).map(Ke=>Te.get(Ke)??Ke);ke(gt)}}).finally(()=>{Q(!0)})},[e]),h.useEffect(()=>{if(!(l!=null&&l.profileId))return;const J=l.profileId,ye=sessionStorage.getItem("agentEditReplaces");L.getEnrichedAuthorizations().then(Ue=>{const We=Ue.filter(nt=>nt.profileId===J&&nt.authorizationId!==ye).map(nt=>({authorizationId:nt.authorizationId,bounds:nt.bounds,context:nt.context??{},intent:nt.intent}));A(We)}).catch(()=>A([]))},[l==null?void 0:l.profileId]),h.useEffect(()=>{if(!g)return;const J=jj(y,yh(g));J&&J!==y&&x(J)},[g,y]),h.useEffect(()=>{if(!f||!g||q.length===0){ie(0);return}let J=!1;return(async()=>{const ye=await Li(f.bounds,g),Ue=await Promise.all(q.map(We=>Li(We.bounds,g).catch(()=>null)));J||ie(Ue.filter(We=>We===ye).length)})().catch(()=>{J||ie(0)}),()=>{J=!0}},[f,g,q]);const re=async()=>{if(!(!l||!f||!g||!s)){if(!l.groupId){ne("No active group; cannot create mandate.");return}X(!0),ne("");try{const J=o||l.domain||"owner",ye=await Li(f.bounds,g),Ue=await lp(f.context,g),[We,nt]=await Promise.all([Hi(f.gateContent.intent),Hi(JSON.stringify({profile:l.profileId,domain:J,group:l.groupId}))]);let Ht,Ot,Ze,W;if(l.isTeam){const St=await L.getApproversPubkeys(l.groupId,l.profileId);if(St.length>0){const Xt=await L.encryptIntent(f.gateContent.intent,St);Ht=Xt.intentCiphertext,Ot=Xt.encryptedKeys,Ze=Xt.approversFrozen,W=Xt.intentDisclosureHash}}const xe=`authz_${crypto.randomUUID()}`,Te=sessionStorage.getItem("agentEditReplaces")||void 0,rt=sessionStorage.getItem("agentReplacesProposal")||void 0,gt=await cp(g),Ke=await L.attest({authorization_id:xe,replaces:Te,profile_id:l.profileId,profile_hash:gt,supported_versions:["0.7"],bounds:f.bounds,bounds_hash:ye,scope_hash:Ue,domain:J,did:s.did,mandate_owners:[{did:s.did}],gate_content_hashes:{intent:We},execution_context_hash:nt,group_id:l.groupId,ttl:j,commitment_mode:wj(y),title:I.trim(),intent_ciphertext:Ht,encrypted_keys:Ot,approvers_frozen:Ze,intent_disclosure_hash:W,disclose_identity:O});try{await L.pushGateContent(up(Ke,{boundsHash:ye,contextHash:Ue,context:f.context,contextLabels:f.contextLabels,gateContent:f.gateContent}))}catch(St){try{await L.revokeAttestation(xe,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${St instanceof Error?St.message:"Unknown error"})`)}if(Te)try{await L.revokeAttestation(Te,`Replaced by ${xe} (edit)`),L.resyncGates().catch(()=>{})}catch{}let Nt="";if(rt)try{const St=await L.getProposal(rt);if(St.status==="pending"){const Xt=Aj(St,(s==null?void 0:s.id)??"");Xt?Xt.route==="approver"?await L.rejectProposal(rt,xh()):await L.resolveProposal(rt,"reject",Xt.domain,xh()):Nt="you are not one of the people who may decide it"}}catch(St){Nt=St instanceof Error?St.message:"unknown error"}if(sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),sessionStorage.removeItem("agentReplacesProposal"),Nt){ne(`Your mandate is signed and active. The AI's proposal could not be withdrawn (${Nt}) — reject it under Approvals.`);return}e(`/mandates?highlight=${encodeURIComponent(xe)}`)}catch(J){ne(J instanceof Error?J.message:"Signing the mandate failed")}finally{X(!1)}}};if(!l||!f)return n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const H=Object.entries(f.bounds).filter(([J])=>J!=="profile"&&J!=="path"),oe=Object.entries(f.context),pe=((fe==null?void 0:fe.caps)!=null?Object.keys(fe.caps):[]).length!==0,ve=ge.length>0?ge.join(", "):((fe==null?void 0:fe.approvers)??[]).join(", "),le=pe?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${ve}, 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.",Ge=pe?`Over-cap actions will be reviewed by you and ${ve}. Within-cap actions run per the mode you chose above.`:`Approvers ${ve} can read your intent but won't gate any action — no caps configured on this profile.`,Se=!!((Oe=fe==null?void 0:fe.approvers)!=null&&Oe.length),Y=fp({isPersonal:l.isPersonal,configLoaded:Z,grantors:fe?gm(fe):void 0,userId:s==null?void 0:s.id,profileName:Mt(l.profileId),teamName:l.groupName}),$e=!Y.can,_e=yh(g),Be=_e.length===0,ze=j>b,it={flex:1,padding:"0.75rem",border:y==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius-md)",background:y==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},tt={flex:1,padding:"0.75rem",border:y==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius-md)",background:y==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Qe=((G=g==null?void 0:g.scopeSchema)==null?void 0:G.keyOrder)??[],Ye=q.filter(J=>bj(Qe,f.context,J.context)),jt=Ye.length>0,pt=Mt(l.profileId),Me=J=>{const ye=Object.values(J).map(Ue=>String(Ue).trim()).filter(Boolean);return ye.length>0?ye.join(", "):"all (unscoped)"},me=Ye.map(J=>Me(J.context)).join("; "),Ae=`This grant's scope overlaps an existing grant on ${pt} (scoped to: ${me}). 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 n.jsxs(n.Fragment,{children:[n.jsx(rp,{currentStep:4,onStepClick:J=>{J<=3&&e(`/mandates/new/intent?step=${J}`)}}),n.jsxs("div",{className:"card",children:[n.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),l.upgradedFromProfileId&&g&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginBottom:"1rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:["Updated to ",Mt(l.profileId)," ",g.version," — the current version of this profile."]})]}),F&&n.jsx("div",{className:"error-message",children:F}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Title"]}),n.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${Mt(l.profileId)}: daily operations`,value:I,onChange:J=>B(J.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),n.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this mandate on your dashboard."})]}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[_e.includes("per-action")&&n.jsxs("button",{onClick:()=>x("per-action"),style:tt,children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),_e.includes("immediate")&&n.jsxs("button",{onClick:()=>x("immediate"),style:it,children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]}),_e.length===1&&n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:_e[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),Be&&n.jsx("div",{className:"msg-error",style:{fontSize:"0.75rem",marginTop:"0.25rem"},children:"This profile allows no commitment mode, so no mandate can be signed under it. Its publisher must fix the profile."})]}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Duration"]}),n.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(J=>J.seconds<=b).map(J=>n.jsx("button",{onClick:()=>{k(J.seconds),E("")},style:{padding:"0.5rem 0.85rem",border:j===J.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:j===J.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:J.label},J.seconds)),n.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[n.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:N,onChange:J=>{E(J.target.value);const ye=parseInt(J.target.value,10);if(ye>0){const Ue=T==="days"?ye*86400:ye*3600;k(Math.min(Ue,b))}}}),n.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:T,onChange:J=>{P(J.target.value);const ye=parseInt(N,10);if(ye>0){const Ue=J.target.value==="days"?ye*86400:ye*3600;k(Math.min(Ue,b))}},children:[n.jsx("option",{value:"hours",children:"hours"}),n.jsx("option",{value:"days",children:"days"})]})]}),ze&&n.jsxs("span",{className:"msg-error",style:{fontSize:"0.75rem"},children:["Maximum: ",b>=86400?`${Math.floor(b/86400)} days`:`${Math.floor(b/3600)} hours`]})]})]}),n.jsx("div",{className:"field-editable",children:n.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[n.jsx("input",{type:"checkbox",checked:z||O,disabled:z,onChange:J=>K(J.target.checked),style:{marginTop:"0.15rem"}}),n.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this mandate",n.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.',z&&" Always on — you chose this in Settings."]})]})]})}),n.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),n.jsxs("div",{className:"info-block",children:[n.jsxs("div",{className:"info-head",children:[n.jsx("span",{className:"info-title",children:"Intent"}),n.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:f.gateContent.intent})]}),(!!H.length||!!oe.length)&&n.jsxs("div",{className:"info-block",children:[n.jsxs("div",{className:"info-head",children:[n.jsx("span",{className:"info-title",children:"Scope & Limits"}),n.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),n.jsxs("dl",{className:"info-kv",children:[oe.map(([J,ye])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:J}),n.jsx("dd",{children:dp(J,ye,f.contextLabels)})]},J)),H.map(([J,ye])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:J}),n.jsx("dd",{children:String(ye)})]},J))]})]}),n.jsxs("div",{className:"info-block",children:[n.jsx("div",{className:"info-head",children:n.jsx("span",{className:"info-title",children:"Authority"})}),n.jsxs("dl",{className:"info-kv",children:[n.jsx("dt",{children:"Profile"}),n.jsxs("dd",{children:[Mt(l.profileId),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:l.profileId})]}),!l.isPersonal&&l.groupName&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Team"}),n.jsx("dd",{children:l.groupName})]}),!l.isPersonal&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Approvers"}),n.jsx("dd",{children:Z?Y.can?n.jsxs(n.Fragment,{children:[ve,n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:le})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"msg-error",children:Y.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${l.groupName??"this team"}`:"You cannot give this mandate"}),Y.code==="OWNER_NOT_APPROVER"&&n.jsx("div",{children:ve}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[Y.reason," ",Y.fix]})]}):n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),$>0?n.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px dashed var(--border-strong)",borderLeft:"3px dashed var(--text-primary)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[n.jsx("span",{"aria-hidden":"true",style:{fontWeight:700},children:"!"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),n.jsxs("div",{children:[$===1?`An active grant on ${pt} already has exactly these limits.`:`${$} active grants on ${pt} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",n.jsx("strong",{children:"Extend"})," on the Mandates page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,jt?n.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px dashed var(--border-strong)",borderLeft:"3px dashed var(--text-primary)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[n.jsx("span",{"aria-hidden":"true",style:{fontWeight:700},children:"!"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,marginBottom:"0.2rem"},children:"Overlapping scope"}),n.jsx("div",{children:Ae})]})]}):null,n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:()=>e("/mandates/new/intent"),children:"Back"}),n.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:re,disabled:ee||!I.trim()||$e||Be,children:ee?"Signing...":y==="immediate"?"Sign mandate":"Sign mandate (asks first)"})]}),n.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:Se?"block":"none"},children:Ge})]})]})}const _j={card:"💳",mail:"✉️"};function pp(e){return _j[e]??"🔧"}function Lj(e){const s=e==null?void 0:e.overrides;return!s||typeof s!="object"?!1:Object.values(s).some(a=>{var o;return typeof((o=a==null?void 0:a.read)==null?void 0:o.ageField)=="string"})}const zj=[0,7,30,90,365,3650];function Ai(e){return e===null?"From your mandate":e===0?"Read nothing":e===1?"1 day back":e===365?"1 year back":e%365===0?`${e/365} years back`:`${e} days back`}function Fj(e){return(e==null?void 0:e.paused)==="simulation"?{chip:{c:"int-chip-paused",t:"Paused"},showStart:!1}:e&&!e.running&&e.error?{chip:{c:"int-chip-bad",t:"Crashed"},showStart:!0}:{chip:{c:"int-chip-idle",t:"Stopped"},showStart:!0}}function tc({manifest:e,integration:s,state:a,onStatusChange:o,onSuccess:l}){var Me;const[u,f]=h.useState({}),[p,g]=h.useState(!1),[v,y]=h.useState(!1),[x,j]=h.useState({}),[k,b]=h.useState({}),[S,N]=h.useState(void 0),[E,T]=h.useState(!1),[P,I]=h.useState(null),[B,O]=h.useState(!1),[K,z]=h.useState(!1),[U,ee]=h.useState(!1),[X,F]=h.useState(!1),[ne,fe]=h.useState({}),[te,ge]=h.useState(null),[ke,Z]=h.useState(!1),[Q,q]=h.useState(null),[A,$]=h.useState(!1);h.useEffect(()=>{let me=!1;return L.getCredential(e.id).then(Ae=>{var Oe;if(!(me||!Ae.configured)){if(g(!0),y(!0),Ae.fields){const G={};for(const J of e.credentials.fields)Ae.fields[J.key]!=null&&(G[J.key]=Ae.fields[J.key]);j(G)}if(b(Ae.secrets??{}),N(Ae.updatedAt),e.oauth){const G=((Oe=Ae.fieldNames)==null?void 0:Oe.includes(e.oauth.tokenStorage))??!1;T(G),G&&L.getOAuthHealth(e.id).then(J=>{me||I(J)})}}}).catch(()=>{}),()=>{me=!0}},[e.id,e.oauth]);const ie=Lj(e.toolGating),re=s?s.readAgeDays??null:void 0,H=ke&&te?te.value:re,oe=async me=>{ge({value:me}),Z(!0),q(null);try{await L.setReadPolicy(e.id,me),l(me===null?`${e.name} read window now follows your mandate`:`${e.name} read window set to ${Ai(me).toLowerCase()}`),o()}catch(Ae){q(Ae instanceof Error?Ae.message:"Could not save")}finally{Z(!1),ge(null)}},ue=!!e.oauth||e.credentials.fields.some(me=>!me.optional),pe=e.oauth?E:p,ve=!ue||pe,le=a==="starting"?"starting":ve?s!=null&&s.running?"running":!p&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&p&&!E?"needs-oauth":"unconfigured",Ge=async()=>{if(e.credentials.fields.some(Ae=>{var Oe;return(Oe=u[Ae.key])==null?void 0:Oe.trim()})){O(!0);try{await L.setCredential(e.id,u),g(!0),f({}),e.oauth?l(`${e.name} credentials saved!`):(l(`${e.name} credentials saved — starting integration...`),await Be())}catch{l(`Failed to save ${e.name} credentials`)}finally{O(!1)}}},Se=()=>{const me={};for(const Ae of e.credentials.fields){const Oe=u[Ae.key];Ae.type==="password"?Oe!=null&&Oe.trim()&&(me[Ae.key]=Oe):Oe!=null&&Oe!==(x[Ae.key]??"")&&(me[Ae.key]=Oe)}return me},Y=Object.keys(Se()).length>0,$e=async()=>{const me=Se();if(Object.keys(me).length!==0){O(!0);try{await L.setCredential(e.id,me),f({}),g(!0),e.oauth?l(`${e.name} credentials saved — now click Connect.`):(F(!1),l(`${e.name} credentials updated — restarting...`),await Be())}catch{l(`Failed to update ${e.name} credentials`)}finally{O(!1)}}},_e=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const me=setInterval(async()=>{var Ae;try{const Oe=await L.getCredential(e.id);Oe.configured&&e.oauth&&((Ae=Oe.fieldNames)!=null&&Ae.includes(e.oauth.tokenStorage))&&(T(!0),F(!1),I(null),clearInterval(me),l(`${e.name} connected — starting integration...`),L.getOAuthHealth(e.id).then(I).catch(()=>{}),await Be())}catch{}},2e3);setTimeout(()=>clearInterval(me),12e4)},Be=async()=>{ee(!0);try{const me=await L.activateIntegration(e.id);me.warning?l(me.warning):l(`${e.name} integration started with ${me.tools.length} tools`),o()}catch(me){l(`Failed to start ${e.name}: ${me instanceof Error?me.message:"Unknown error"}`)}finally{ee(!1)}},ze=async()=>{try{await L.removeMcpIntegration(e.id),l(`${e.name} integration removed`),o()}catch{l(`Failed to remove ${e.name}`)}},it=pp(e.icon),tt=Fj(s),Qe=le==="running"?{c:"int-chip-ok",t:"Running"}:le==="starting"?{c:"int-chip-idle",t:"Starting"}:tt.chip,Ye=e.oauth&&E&&(P==null?void 0:P.status)==="failed",jt=ue?Ye?{c:"int-chip-bad",t:"Auth failed"}:pe?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},pt=me=>me.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${e.id}/callback`);return n.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[n.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:it}),n.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:e.name}),n.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[le!=="unconfigured"&&le!=="needs-oauth"&&n.jsxs("span",{className:`int-chip ${Qe.c}`,children:[n.jsx("span",{className:"int-dot"}),Qe.t]}),n.jsxs("span",{className:`int-chip ${jt.c}`,children:[n.jsx("span",{className:"int-dot"}),jt.t]}),Wx(e,x)&&n.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:[n.jsx("span",{className:"int-dot"}),"Simulation"]})]})]}),e.oauth&&E&&n.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:P!=null&&P.account?n.jsxs(n.Fragment,{children:["Connected as ",n.jsx("b",{children:P.account})]}):n.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),Ye&&!X&&n.jsxs("div",{style:{marginTop:"0.7rem",border:"2px solid var(--border-strong)",borderRadius:"10px",padding:"0.8rem 0.95rem",background:"var(--bg-elevated)"},children:[n.jsxs("div",{style:{fontSize:"0.86rem",fontWeight:700},children:[e.name," stopped accepting the stored credentials"]}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0.3rem 0 0",lineHeight:1.55},children:[(P==null?void 0:P.error)==="invalid_grant"?n.jsxs(n.Fragment,{children:["The refresh token was revoked (",n.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):P!=null&&P.error?n.jsxs(n.Fragment,{children:["The provider reported ",n.jsx("code",{children:P.error}),"."]}):n.jsx(n.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",e.name," actions are ",n.jsx("b",{children:"blocked"}),", not failing silently."]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.6rem"},children:[n.jsxs("button",{className:"btn btn-primary btn-sm",onClick:_e,children:["Reconnect ",e.name]}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{f({...x}),F(!0)},children:"Edit credentials"})]})]}),n.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[n.jsx("summary",{children:"Details"}),n.jsxs("div",{className:"int-meta",children:[n.jsx("span",{className:"int-k",children:"What"}),n.jsx("span",{children:e.description}),e.profile&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Profile"}),n.jsx("span",{children:e.profile})]}),e.oauth&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Scopes"}),n.jsx("span",{children:((Me=e.oauth.scopes)==null?void 0:Me.join(", "))||"—"})]}),s&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Tools"}),n.jsxs("span",{children:[s.toolCount," gated"]})]})]})]}),e.setupGuide&&e.setupGuide.length>0&&(le!=="running"||Ye)&&n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n.jsxs("button",{onClick:()=>z(!K),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[n.jsx("span",{style:{transition:"transform 0.2s",transform:K?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),K&&n.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((me,Ae)=>n.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[n.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:Ae+1}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:me.title}),n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[pt(me.description),me.link&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("a",{href:me.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},Ae))})]}),le==="starting"&&n.jsxs("div",{className:"service-status",style:{color:"var(--text-primary)"},children:[n.jsx("span",{className:"service-status-dot",style:{background:"transparent",border:"1px dashed var(--text-primary)"}}),"Starting…"]}),X&&n.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[n.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),v&&n.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.",e.oauth?" Save, then Connect to re-link the account.":""]}),e.credentials.fields.map(me=>{var Ae;return n.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[n.jsx("label",{className:"form-label",children:me.label}),me.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:ne[me.key]?"text":"password",name:`${e.id}-${me.key}-credential`,autoComplete:"new-password",placeholder:(Ae=k[me.key])!=null&&Ae.preview?`Unchanged — ends in ${k[me.key].preview}`:v?"Unchanged — paste a new value to replace":me.placeholder,value:u[me.key]||"",onChange:Oe=>f(G=>({...G,[me.key]:Oe.target.value}))}),n.jsx("button",{className:"cred-toggle",onClick:()=>fe(Oe=>({...Oe,[me.key]:!Oe[me.key]})),children:ne[me.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${me.key}-credential`,autoComplete:"off",placeholder:me.placeholder,value:u[me.key]||"",onChange:Oe=>f(G=>({...G,[me.key]:Oe.target.value}))})]},me.key)}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:$e,disabled:B||!Y,children:B?"Saving…":"Save"}),!Y&&!B&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),e.oauth&&n.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:_e,children:["Connect ",e.name]}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{F(!1),f({})},children:"Cancel"})]})]}),!X&&le==="running"&&s&&n.jsxs(n.Fragment,{children:[(Object.keys(x).length>0||Object.keys(k).length>0)&&n.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:e.credentials.fields.map(me=>{const Ae=me.type==="password",Oe=k[me.key];return!Ae&&x[me.key]==null||Ae&&Oe==null?null:n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[n.jsx("span",{style:{color:"var(--text-muted)"},children:me.label}),n.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[Ae?Oe.preview??"set":x[me.key],Ae&&S&&n.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(S).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},me.key)})}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[n.jsx(mt,{to:"/mandates?new=1",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Give a mandate"}),(e.credentials.fields.length>0||e.oauth)&&n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{f({...x}),F(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),n.jsx("span",{style:{flex:1}}),n.jsx("button",{className:"btn btn-sm btn-outline-strong",onClick:ze,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"})]}),ie&&H!==void 0&&!A&&n.jsx("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"0.5rem",minWidth:0},children:[n.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"Reads"}),n.jsx("span",{style:{fontSize:"0.82rem",color:"var(--text-muted)"},children:H===null?"window from your mandate":Ai(H).toLowerCase()}),ke&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),Q&&n.jsx("span",{className:"msg-error",style:{fontSize:"0.78rem"},children:Q})]}),n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>$(!0),children:"Edit"})]})}),ie&&H!==void 0&&A&&n.jsxs("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem",marginBottom:"0.35rem"},children:[n.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"How far back may your agent read?"}),n.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>$(!1),children:"Done"})]}),n.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-tertiary)",margin:"0 0 0.55rem"},children:"Applies immediately — no Save, no new mandate."}),n.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[zj.map(me=>{const Ae=H===me;return n.jsx("button",{className:`btn btn-sm ${Ae?"btn-primary":"btn-secondary"}`,"aria-pressed":Ae,disabled:ke,onClick:()=>oe(me),children:Ai(me)},me)}),n.jsx("button",{className:`btn btn-sm ${H===null?"btn-primary":"btn-ghost"}`,"aria-pressed":H===null,disabled:ke,onClick:()=>oe(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:Ai(null)})]}),n.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:Q?n.jsx("span",{className:"msg-error",children:Q}):ke?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):H===null?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):H===0?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Your agent cannot read any mail."}):n.jsxs("span",{style:{color:"var(--text-muted)"},children:["Anything older than ",H," days is blocked, whoever it is from."]})})]}),n.jsx("div",{style:{display:"none"},children:n.jsx(mt,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),le==="unconfigured"&&(()=>{const me=e.credentials.fields.every(G=>G.optional),Ae=e.credentials.fields.some(G=>!G.optional),Oe=e.credentials.fields.some(G=>{var J;return(J=u[G.key])==null?void 0:J.trim()});return n.jsxs(n.Fragment,{children:[v&&n.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:[n.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"," ",n.jsx("button",{onClick:()=>{g(!0),e.oauth&&T(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),e.oauth&&!v&&n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Step 1 of 2 — enter credentials, then connect your account."}),e.setupHint&&!v&&n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:e.setupHint}),e.credentials.fields.map(G=>n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{className:"form-label",children:G.label}),G.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:ne[G.key]?"text":"password",name:`${e.id}-${G.key}-credential`,autoComplete:"new-password",placeholder:G.placeholder,value:u[G.key]||"",onChange:J=>f(ye=>({...ye,[G.key]:J.target.value}))}),n.jsx("button",{className:"cred-toggle",onClick:()=>fe(J=>({...J,[G.key]:!J[G.key]})),children:ne[G.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${G.key}-credential`,autoComplete:"off",placeholder:G.placeholder,value:u[G.key]||"",onChange:J=>f(ye=>({...ye,[G.key]:J.target.value}))})]},G.key)),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[Oe&&n.jsx("button",{className:"btn btn-primary",onClick:Ge,disabled:B||Ae&&!e.credentials.fields.filter(G=>!G.optional).every(G=>{var J;return(J=u[G.key])==null?void 0:J.trim()}),children:B?"Saving...":"Save & Encrypt"}),me&&!Oe&&n.jsx("button",{className:"btn btn-primary",onClick:Be,disabled:U,children:U?"Starting...":`Activate ${e.name}`})]})]})})(),le==="needs-oauth"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",e.name," account to authorize access."]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[n.jsxs("button",{className:"btn btn-primary",onClick:_e,children:["Connect ",e.name," Account"]}),n.jsx("button",{className:"btn btn-ghost",onClick:()=>g(!1),children:"Change Credentials"})]})]}),le==="ready"&&!s&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.75rem"},children:["✓"," ",e.oauth?`${e.name} account connected`:"Credentials configured"]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[n.jsx("button",{className:"btn btn-primary",onClick:Be,disabled:U,children:U?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&n.jsx("button",{className:"btn btn-ghost",onClick:()=>g(!1),children:"Update Credentials"}),e.oauth&&n.jsx("button",{className:"btn btn-ghost",onClick:()=>{g(!1),T(!1)},children:"Change Credentials"})]})]}),le==="ready"&&s&&!s.running&&(tt.showStart?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[n.jsx("span",{className:"service-status-dot"}),"Not running"]}),s.error&&n.jsx("div",{className:"msg-error",style:{fontSize:"0.8rem",marginBottom:"0.75rem"},children:s.error}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:Be,disabled:U,children:U?"Starting...":"Start"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:ze,children:"Disable"})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"service-status",style:{marginBottom:"0.5rem",color:"var(--text-muted)"},children:[n.jsx("span",{className:"service-status-dot",style:{background:"var(--text-muted)"}}),"Paused"]}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.75rem"},children:"Real systems are off while simulation mode is on."}),n.jsx("div",{style:{display:"flex",gap:"0.5rem"},children:n.jsx("button",{className:"btn btn-outline-strong",onClick:ze,children:"Disable"})})]}))]})}function wh(e,s){const a=new Map;for(const o of e){const l=o.manifest.profile;let u=a.get(l);u||(u={shortId:l,icon:Ar(l),name:Bn(l,s),entries:[]},a.set(l,u)),u.entries.push(o)}return[...a.values()].sort((o,l)=>o.name.localeCompare(l.name))}function Mj(e,s){if(!s)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:e};const a=e.filter(f=>la(f.manifest)),o=e.filter(f=>!la(f.manifest)),l=o.filter(f=>f.state==="error"),u=o.filter(f=>f.state!=="error");return{grouped:!0,testSystems:a,realErrors:l,pausedReal:u,ungrouped:[]}}function jh({group:e,children:s}){return n.jsxs("div",{className:"area-group","data-testid":"integration-area","data-area":e.shortId,children:[n.jsxs("div",{className:"area-group-h",children:[n.jsx(ga,{icon:e.icon}),n.jsx("b",{children:e.name})]}),s]})}function Oj({entry:e}){return n.jsxs("div",{className:"int-paused-row",children:[n.jsx("span",{"aria-hidden":"true",children:pp(e.manifest.icon)}),n.jsx("span",{className:"int-paused-name",children:e.manifest.name}),n.jsxs("span",{className:"int-chip int-chip-paused",children:[n.jsx("span",{className:"int-dot"}),"Paused"]})]})}function Bj(){const{loading:e,mcpServerUp:s,manifestsError:a,entries:o,refresh:l}=Oc(),u=Mc(),[f,p]=h.useState(""),g=$r(),v=h.useCallback(x=>{p(x),setTimeout(()=>p(""),5e3)},[]),y=Mj(o,u);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Integrations"}),n.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),f&&n.jsx("div",{className:"alert alert-success",children:f}),e?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):s===!1?n.jsxs("div",{className:"status-banner status-banner-error",children:[n.jsx("span",{className:"status-banner-icon",children:"!"}),n.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):y.grouped?n.jsxs(n.Fragment,{children:[y.testSystems.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Test systems"}),wh(y.testSystems,g).map(x=>n.jsx(jh,{group:x,children:x.entries.map(j=>n.jsx(tc,{manifest:j.manifest,integration:j.integration,state:j.state,onStatusChange:l,onSuccess:v},j.id))},x.shortId))]}),(y.realErrors.length>0||y.pausedReal.length>0)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Real systems"}),y.realErrors.map(x=>n.jsx(tc,{manifest:x.manifest,integration:x.integration,state:x.state,onStatusChange:l,onSuccess:v},x.id)),y.pausedReal.length>0&&n.jsxs("details",{className:"int-paused-group",open:!0,children:[n.jsxs("summary",{children:["Paused while simulation mode is on (",y.pausedReal.length,")"]}),n.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 (",n.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),y.pausedReal.map(x=>n.jsx(Oj,{entry:x},x.id))]})]}),o.length===0&&n.jsx(Sh,{manifestsError:a})]}):n.jsxs(n.Fragment,{children:[wh(o,g).map(x=>n.jsx(jh,{group:x,children:x.entries.map(j=>n.jsx(tc,{manifest:j.manifest,integration:j.integration,state:j.state,onStatusChange:l,onSuccess:v},j.id))},x.shortId)),o.length===0&&n.jsx(Sh,{manifestsError:a})]})]})}function Sh({manifestsError:e}){return e?n.jsxs("div",{className:"status-banner status-banner-error",children:[n.jsx("span",{className:"status-banner-icon",children:"!"}),n.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"," ",n.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):n.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."})}function Dj(){var F,ne,fe;const{activeTeam:e,activeMembership:s,refreshGroups:a,user:o}=xt(),l=Sn(),[u,f]=h.useState(null),[p,g]=h.useState(!1),[v,y]=h.useState(""),[x,j]=h.useState(""),[k,b]=h.useState(!1),[S,N]=h.useState(""),[E,T]=h.useState("");h.useEffect(()=>{fetch("/health").then(te=>te.json()).then(te=>{typeof te.spUrl=="string"&&T(te.spUrl)}).catch(()=>{})},[]),h.useEffect(()=>{if(!e){f(null);return}L.getGroupById(e.id).then(te=>{const ge=te.group??te,ke=te.members??[],Z=te.isAdmin??!1,Q=ke.map(q=>{const A=q.userId||q.id||"",$=q.role||(Z&&A===ge.createdBy?"admin":"member");return{id:A,name:q.name||A.slice(0,8)||"Member",email:q.email||"",domains:q.domains||[],role:$,isAdmin:$==="admin"||Z&&A===ge.createdBy}});f({id:ge.id,name:ge.name,members:Q})}).catch(()=>f(null))},[e==null?void 0:e.id]);const P=(u==null?void 0:u.members.filter(te=>te.isAdmin))??[],I=(e==null?void 0:e.isAdmin)===!0&&P.length<=1&&P.some(te=>te.id===(o==null?void 0:o.id)),B=(e==null?void 0:e.name)??"",O=S.trim()===B&&!p,K=()=>{N(""),b(!0)},z=()=>{b(!1),N("")},U=async()=>{if(!(!e||!O)){g(!0),y("");try{await L.leaveTeam(e.id),await a(),j("You have left the team."),f(null),z()}catch(te){y(te instanceof Error?te.message:"Failed to leave team")}finally{g(!1)}}},ee=e&&E?`${E}/dashboard/groups/${e.id}`:void 0,X=E?`${E}/dashboard/groups`:void 0;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"page-header",children:n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Team"}),n.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Authority Server dashboard."})]})}),v&&n.jsx("div",{className:"error-message",children:v}),x&&n.jsx("div",{className:"alert alert-success",children:x}),e?n.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[n.jsxs("div",{className:"card-header",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"card-title",children:e.name}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((F=u==null?void 0:u.members)==null?void 0:F.length)??0," ",(((ne=u==null?void 0:u.members)==null?void 0:ne.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),n.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(fe=u==null?void 0:u.members)==null?void 0:fe.map(te=>n.jsxs("div",{className:"member-row",children:[n.jsx("div",{className:"member-avatar",children:te.name.split(" ").map(ge=>ge[0]).join("").slice(0,2).toUpperCase()}),n.jsxs("div",{className:"member-info",children:[n.jsx("div",{className:"member-name",children:te.name}),n.jsx("div",{className:"member-email",children:te.email})]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:te.role})]},te.id)),n.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[ee&&n.jsx("a",{className:"btn btn-secondary btn-sm",href:ee,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server →"}),n.jsx("span",{title:I?"You are the only admin. Transfer admin to another member in your Authority Server dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:n.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:K,disabled:p||I,children:"Leave team"})})]})]}):n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[n.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),n.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."}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem",justifyContent:"center",flexWrap:"wrap"},children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>l("/onboarding"),children:"Join or create a team"}),X&&n.jsx("a",{className:"btn btn-ghost btn-sm",href:X,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server →"})]})]}),k&&e&&n.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"leave-team-title",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-main) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:z,children:n.jsxs("div",{className:"card",onClick:te=>te.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[n.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",B,"?"]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),n.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[n.jsx("li",{children:"Revoke all mandates you created in this team's context"}),n.jsx("li",{children:"Reject any pending action proposals you authored"}),n.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",n.jsx("strong",{children:"personal"})," mandates are not affected."]}),n.jsxs("div",{className:"form-group",children:[n.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",n.jsx("code",{children:B})," to confirm:"]}),n.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:S,onChange:te=>N(te.target.value),placeholder:B,disabled:p,autoFocus:!0})]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:z,disabled:p,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:U,disabled:!O,children:p?"Leaving...":"Leave team"})]})]})})]})}function Jc({areas:e,selected:s,onSelect:a,totalCount:o}){return e.length<2?null:n.jsxs("div",{className:"ftabs",role:"tablist","aria-label":"Which area","data-testid":"area-filter",children:[n.jsxs("button",{type:"button",role:"tab",className:"ftab","aria-selected":s===null,onClick:()=>a(null),children:["All ",n.jsx("span",{className:"n",children:o})]}),e.map(l=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`area-filter-${l.shortId}`,"aria-selected":s===l.shortId,onClick:()=>a(s===l.shortId?null:l.shortId),children:[n.jsx(ga,{icon:l.icon})," ",l.name," ",n.jsx("span",{className:"n",children:l.count})]},l.shortId))]})}const ua=e=>e.replace(/@.*$/,"").split("/").pop()??e,bh=e=>e.split("@")[1]??"";function Uj(e,s){const a=new Map;for(const o of e){const l=ua(o.id);if(!s.has(l))continue;const u=a.get(l);(!u||bh(o.id).localeCompare(bh(u.id),void 0,{numeric:!0})>0)&&a.set(l,o)}return a}function Wj(e,s,a,o){var p;const l=new Set([...s.filter(g=>g.profile).map(g=>g.profile),...o.map(g=>ua(g.profile))]),u=Uj(e,l),f=[];for(const g of s){const v=g.profile?u.get(g.profile):void 0;v&&f.push({key:`connector:${g.id}`,name:g.name,description:g.description||v.description,profile:v,kind:"connector",ready:((p=a.find(y=>y.id===g.id))==null?void 0:p.running)===!0,setupId:g.id,...g.intentHint?{intentHint:g.intentHint}:{}})}for(const g of o){const v=u.get(ua(g.profile));v&&f.push({key:`builtin:${g.id}`,name:g.name,description:g.description||v.description,profile:v,kind:"builtin",ready:g.available,unavailableReason:g.available?void 0:"Available only while simulation mode is on.",...g.intentHint?{intentHint:g.intentHint}:{}})}return f}function Hj(e,s,a){if(s)return e.find(o=>ua(o.profile.id)===ua(s)&&o.ready&&a(o))}function gp({icon:e,className:s}){return n.jsx(ga,{icon:e,className:s})}function Vj({onDismiss:e,preselectProfileId:s}){const a=Sn(),{group:o,groupId:l,domain:u,user:f}=xt(),[p,g]=h.useState([]),[v,y]=h.useState([]),[x,j]=h.useState([]),[k,b]=h.useState([]),[S,N]=h.useState(!0),[E,T]=h.useState({});h.useEffect(()=>{Promise.all([L.listProfiles().catch(()=>[]),L.getIntegrationManifests().then(U=>U.manifests??[]).catch(()=>[]),L.getMcpHealth().catch(()=>null)]).then(async([U,ee,X])=>{if(g(U),y(ee),j((X==null?void 0:X.integrations)??[]),b((X==null?void 0:X.builtins)??[]),l){const F=await Promise.all(U.map(fe=>L.getTeamProfileConfig(l,fe.id).catch(()=>null))),ne={};U.forEach((fe,te)=>{const ge=F[te];ge&&(ne[fe.id]=ge)}),T(ne)}}).finally(()=>N(!1))},[l]);const P=Wj(p,v,x,k),I=U=>{const ee=E[U.id];return fp({isPersonal:!!(o!=null&&o.isPersonal),configLoaded:!S,grantors:ee?gm(ee):void 0,userId:f==null?void 0:f.id,profileName:Mt(U.id),teamName:o==null?void 0:o.name})},B=U=>U in E,O=(U,ee)=>{if(!l){console.error("No active group when creating authorization");return}const X=B(U);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:U,groupId:l,groupName:(o==null?void 0:o.name)??null,domain:u,isTeam:X,isPersonal:!!(o!=null&&o.isPersonal),...ee?{intentHint:ee}:{}})),sessionStorage.removeItem("agentGate"),e==null||e(),a("/mandates/new/intent")},K=(U,ee)=>{l&&O(U,ee)},z=h.useRef(!1);return h.useEffect(()=>{if(S||!s||z.current)return;const U=Hj(P,s,ee=>I(ee.profile).can);U&&(z.current=!0,K(U.profile.id,U.intentHint))},[S,s]),n.jsxs(n.Fragment,{children:[n.jsx("style",{children:`
|
|
79
|
+
.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
|
|
80
|
+
.profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
|
|
81
|
+
@media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
|
|
82
|
+
@media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
|
|
83
|
+
`}),S?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):P.length===0?n.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[n.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),n.jsx(mt,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>e==null?void 0:e(),children:"Go to Integrations"})]}):n.jsx("div",{className:"profile-grid",children:P.map(U=>{const ee=U.profile,X=B(ee.id),F=I(ee),ne=!U.ready||!F.can,{icon:fe}=Pr(ee.id,{name:ee.name});return n.jsxs("div",{className:"card",style:ne?{opacity:.7}:void 0,children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[n.jsxs("h3",{className:"card-title profile-chip",style:{margin:0},children:[n.jsx(gp,{icon:fe,className:"profile-chip-icon"}),U.name]}),X?n.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?n.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]}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:U.description}),F.can?U.ready?n.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>K(ee.id,U.intentHint),children:"Give a mandate"}):U.kind==="builtin"?n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem"},children:U.unavailableReason})]}):n.jsxs(mt,{to:`/integrations?setup=${U.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",U.name]}):n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:[F.reason," ",n.jsx("span",{style:{color:"var(--text-tertiary)"},children:F.fix})]})]})]},U.key)})})]})}const Gj={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function Kj({status:e,label:s}){return n.jsx("span",{className:`status-badge status-${e}`,children:s||Gj[e]})}function qj({domain:e,attested:s}){const a=s===!0?"domain-attested":s===!1?"domain-missing":"";return n.jsx("span",{className:`domain-badge ${a}`,style:{fontSize:"0.75rem"},children:e})}const kr=86400,sa=3600,Ii=60,Yj=30*kr;function Jj(e){if(e<=0)return"Expired";if(e>90*kr){const s=Math.floor(e/Yj);return`${s} ${s===1?"month":"months"} remaining`}if(e>7*kr){const s=Math.floor(e/kr);return`${s} ${s===1?"day":"days"} remaining`}if(e>=2*kr){const s=Math.floor(e/kr),a=Math.floor(e%kr/sa);return`${s} ${s===1?"day":"days"} ${a}h remaining`}if(e>=2*sa){const s=Math.floor(e/sa),a=Math.floor(e%sa/Ii);return`${s}h ${String(a).padStart(2,"0")}m remaining`}if(e>=Ii){const s=Math.floor(e/Ii),a=Math.floor(e%Ii);return`${s}m ${String(a).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function Qj({expiresAt:e}){const[s,a]=h.useState(()=>e-Date.now()/1e3),o=s<2*sa;h.useEffect(()=>{const u=setInterval(()=>a(e-Date.now()/1e3),o?1e3:6e4);return()=>clearInterval(u)},[e,o]);const l=s<300;return n.jsx("span",{className:`ttl-badge ${l?"ttl-warn":"ttl-ok"}`,children:Jj(s)})}function ds({icon:e,title:s,text:a,children:o}){return n.jsxs("div",{className:"empty-state",children:[e&&n.jsx("div",{className:"empty-state-icon",children:e}),n.jsx("div",{className:"empty-state-title",children:s}),a&&n.jsx("div",{className:"empty-state-text",children:a}),o]})}function Xj(e){const s=Math.floor(e/86400);if(s>=1)return`${s} day${s===1?"":"s"}`;const a=Math.floor(e/3600);if(a>=1)return`${a} hour${a===1?"":"s"}`;const o=Math.ceil(e/60);return`${o} minute${o===1?"":"s"}`}const Zj=[{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 eS({item:e,onClose:s,onSuccess:a}){var P;const{user:o,activeDomain:l,groupId:u}=xt(),[f,p]=h.useState(null);h.useEffect(()=>{let I=!1;return L.getProfile(e.profile_id).then(B=>{var O;I||p(((O=B==null?void 0:B.ttl)==null?void 0:O.max)??null)}).catch(()=>{}),()=>{I=!0}},[e.profile_id]);const g=e.remaining_seconds??0,v=Zj.filter(I=>I.seconds>g&&(f===null||I.seconds<=f)),y=((P=v[0])==null?void 0:P.seconds)??2592e3,[x,j]=h.useState(y);h.useEffect(()=>{var I;if(f!==null&&x>f){const B=(I=v[v.length-1])==null?void 0:I.seconds;B&&j(B)}},[f]);const[k,b]=h.useState(!1),[S,N]=h.useState(""),E=Object.entries(e.frame).filter(([I])=>I!=="profile"&&I!=="path"),T=async()=>{var I;if(o){b(!0),N("");try{const B=e.authorization_id,O=await L.getGateContent(B);if(!O)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const K=await L.getProfile(e.profile_id),z=e.frame,U=O.context??{},ee=e.attested_domains[0]||l||"owner",X=await Li(z,K),F=await lp(U,K),[ne,fe]=await Promise.all([Hi(O.gateContent.intent),Hi(JSON.stringify({profile:e.profile_id,path:e.path,domain:ee}))]);if(!u)throw new Error("No active group; cannot extend mandate.");const te=(((I=e.deferred_commitment_domains)==null?void 0:I.length)??0)>0?"review":"automatic",ge=await cp(K),ke=await L.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,profile_hash:ge,supported_versions:["0.7"],bounds:z,bounds_hash:X,scope_hash:F,domain:ee,did:o.did,mandate_owners:[{did:o.did}],gate_content_hashes:{intent:ne},execution_context_hash:fe,group_id:u,commitment_mode:te,ttl:x});await L.pushGateContent(up(ke,{boundsHash:X,contextHash:F,context:U,path:e.path,gateContent:O.gateContent})),a()}catch(B){N(B instanceof Error?B.message:"Extension failed")}finally{b(!1)}}};return n.jsx("div",{className:"modal-backdrop",onClick:I=>I.target===I.currentTarget&&s(),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:"Extend mandate"}),n.jsx("button",{className:"modal-close",onClick:s,children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[Mt(e.profile_id)," / ",e.path]}),E.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:E.map(([I,B])=>`${I}=${B}`).join(" · ")})]}),n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),g>0&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",Xj(g),". Only longer durations are shown."]}),n.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:v.length===0?n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This mandate is already on the longest available duration. Nothing to extend."}):v.map(I=>n.jsx("button",{className:`btn ${x===I.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>j(I.seconds),style:{minWidth:"3.5rem"},children:I.label},I.seconds))})]}),n.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)."}),S&&n.jsx("div",{className:"error-message",children:S})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-secondary",onClick:s,disabled:k,children:"Cancel"}),n.jsx("button",{className:"btn btn-primary",onClick:T,disabled:k,children:k?"Extending...":"Extend"})]})]})})}function kh(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Nh(e){return e.split("@")[1]??""}function tS(e,s){return Nh(e).localeCompare(Nh(s),void 0,{numeric:!0})>0}function yp(e,s){const a=kh(e);let o;for(const l of s)kh(l.id)===a&&(!o||tS(l.id,o.id))&&(o=l);return o}function vp(e,s){var o;if(!s)return{};const a={};for(const l of s.keyOrder){if(l==="profile"||l==="path")continue;if(e[l]!==void 0){a[l]=e[l];continue}const u=(o=s.fields[l])==null?void 0:o.default;(typeof u=="string"||typeof u=="number"&&Number.isFinite(u))&&(a[l]=u)}return a}function xp(e,s){return vp(e,s.boundsSchema)}function wp(e,s){return vp(e,s.scopeSchema)}function nS(e,s,a){return[...e].sort((o,l)=>{if(a){if(o.authorization_id===a&&l.authorization_id!==a)return-1;if(l.authorization_id===a&&o.authorization_id!==a)return 1}const u=Fi(o,s),f=Fi(l,s),p={active:0,pending:1,expired:2,revoked:3,archived:4};return p[u]!==p[f]?p[u]-p[f]:new Date(l.created_at).getTime()-new Date(o.created_at).getTime()})}function rS({item:e,newerProfile:s,area:a,revokedSet:o,expandedHash:l,gateCache:u,gateLoading:f,copiedHash:p,revokingHash:g,copyingHash:v,profileConfigCache:y,mode:x,ownerLabel:j,isAdmin:k,onExpand:b,onCopyHash:S,onCopy:N,onRevoke:E,onExtend:T,archivedSet:P,archivingHash:I,onArchive:B,highlightHash:O,needsReapprovalSet:K}){var Ge;const z=Fc(e,{revokedSet:o}),U=z==="active"&&((K==null?void 0:K.has(e.authorization_id))??!1),ee=jm(e,{revokedSet:o,archivedSet:P}),X=!j&&!!B&&wm(z),F=l===e.authorization_id,ne=u[e.authorization_id],fe=z==="active"||z==="pending"||z==="expired",te=Object.entries(e.frame).filter(([Se])=>Se!=="profile"&&Se!=="path"),ge=y.get(e.profile_id)??null,ke=(((Ge=ge==null?void 0:ge.approvers)==null?void 0:Ge.length)??0)>0,Z=new Map;if(ge!=null&&ge.caps&&x==="team")for(const[Se,Y]of te){const $e=ge.caps[Se];typeof $e=="number"&&Number(Y)>$e&&Z.set(Se,{authorized:Number(Y),cap:$e})}const Q=Z.size>0,q=e.approvers_frozen??[],A=(ge==null?void 0:ge.approvers)??[],$=x==="team"&&q.length>0&&A.length>0&&(q.length!==A.length||q.some(Se=>!A.includes(Se))||A.some(Se=>!q.includes(Se))),ie=Array.from(Z.entries()).map(([Se,Y])=>`${Se}: ${Y.authorized} (cap ${Y.cap})`).join(", "),re=Array.from(Z.entries()).map(([Se,Y])=>`${Se}: ${Y.authorized} → ${Y.cap}`).join(", "),H=Q?ke?Z.size===1?`Above team cap: ${ie} — actions require approval`:`Above team cap (${Z.size}): ${ie} — actions require approval`:Z.size===1?`Reduced by hard cap: ${re}`:`Reduced by hard cap (${Z.size}): ${re}`:"",oe=Q?ke?"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,ue=Pr(e.profile_id),pe=ue.name,ve=s?n.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:[n.jsxs("strong",{style:{color:"var(--text-secondary)"},children:[pe,"@",s.version," available"]}),s.whatsNew?n.jsxs(n.Fragment,{children:[" — ",s.whatsNew]}):null,n.jsx("br",{}),n.jsxs("span",{children:["This mandate stays on ",e.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,le=O!=null&&e.authorization_id===O;return n.jsx("div",{className:`card mandate-card${le?" card-highlight":""}`,style:{marginBottom:0},children:n.jsxs("div",{className:"id-body",children:[e.created_at&&n.jsxs("div",{className:"obj-line",children:["since ",new Date(e.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})]}),ve,j&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",n.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:j})]}),n.jsxs("div",{className:"auth-card-header",children:[n.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:e.title||pe}),n.jsx(Kj,{status:z}),U&&n.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-primary)",background:"transparent",border:"1px dashed var(--text-primary)",borderRadius:"4px",padding:"2px 6px"},children:"Needs re-approval"}),ue.testSetup&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),z==="active"&&e.earliest_expiry&&n.jsx(Qj,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),z==="expired"&&(()=>{const Se=Ux(e,z);return Se?n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(Se.iso).toLocaleString()}`,children:new Date(Se.iso).toLocaleDateString(void 0,{month:"short",day:"numeric"})}):null})()]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[(e.required_domains.length>1||e.missing_domains.length>0)&&e.required_domains.map(Se=>n.jsx(qj,{domain:Se,attested:e.attested_domains.includes(Se)},Se)),e.deferred_commitment_domains.length>0&&n.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"}),Q&&n.jsx("span",{title:oe,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"transparent",color:"var(--text-primary)",border:ke?"1px dashed var(--text-primary)":"2px solid var(--text-primary)",fontWeight:600,cursor:"help"},children:H}),$&&n.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.65rem",padding:"0.15rem 0.5rem",borderRadius:"0.25rem",background:"transparent",color:"var(--text-primary)",fontWeight:600,border:"1px dashed var(--text-primary)",cursor:"pointer",lineHeight:1.4},onClick:()=>N(e),disabled:v===e.authorization_id,title:"The approver list for this profile has changed since this mandate was created. Copy to reissue with the current approvers.",children:v===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),te.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:te.map(([Se,Y],$e)=>{const _e=Z.get(Se);return n.jsxs("span",{children:[$e>0&&" · ",_e?ke?n.jsxs("span",{title:`Team cap on ${Se} is ${_e.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${_e.authorized}.`,children:[n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[Se,"=",String(Y)]}),n.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",_e.cap]})]}):n.jsxs("span",{title:`Team cap on ${Se} is ${_e.cap} with no approvers configured (hard cap). Authorized for ${_e.authorized}; effective ${_e.cap}.`,children:[n.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[Se,"=",String(Y)]}),n.jsxs("span",{style:{marginLeft:"0.25rem",fontWeight:700},children:["→"," ",_e.cap]})]}):n.jsxs("span",{children:[Se,"=",String(Y)]})]},Se)})}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[X&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>B(e.authorization_id,!ee),disabled:I===e.authorization_id,title:ee?"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:I===e.authorization_id?ee?"Unarchiving…":"Archiving…":ee?"↩ Unarchive":"⊟ Archive"}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>b(e),children:F?"▲ Hide Details":"▼ Details"})]}),F&&n.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[te.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Bounds"}),n.jsx("dl",{className:"review-grid",children:te.map(([Se,Y])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:Se}),n.jsx("dd",{children:String(Y)})]},Se))})]}),(ne==null?void 0:ne.context)&&Object.keys(ne.context).length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Scope"}),n.jsx("dl",{className:"review-grid",children:Object.entries(ne.context).map(([Se,Y])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:Se}),n.jsx("dd",{title:String(Y),children:dp(Se,Y,ne.contextLabels)})]},Se))})]}),n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Intent"}),f===e.authorization_id?n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):ne?n.jsx("div",{className:"gate-content-block",children:n.jsx("div",{className:"gate-content-item",children:n.jsx("div",{className:"gate-content-text",children:ne.gateContent.intent})})}):n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"1rem"},children:["Created: ",new Date(e.created_at).toLocaleString(),e.earliest_expiry&&` · Expires: ${new Date(e.earliest_expiry).toLocaleString()}`]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:e.authorization_id}),n.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>S(e.authorization_id),children:p===e.authorization_id?"copied":"copy"})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!j&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>N(e),disabled:v===e.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:v===e.authorization_id?"Copying…":"⧉ Copy"}),!j&&(z==="active"||z==="pending")&&n.jsx("button",{className:U?"btn btn-primary btn-sm":"btn btn-secondary btn-sm",onClick:()=>N(e,{asEdit:!0}),disabled:v===e.authorization_id,title:U?"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:U?"⚠ Re-approve":"✎ Edit"}),!j&&fe&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>T(e),children:"↻ Extend"}),j&&k&&z!=="revoked"?n.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>E(e.authorization_id,j,pe),disabled:g===e.authorization_id,children:g===e.authorization_id?"Revoking…":"Revoke"}):!j&&(z==="active"||z==="pending")?n.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>E(e.authorization_id),disabled:g===e.authorization_id,children:g===e.authorization_id?"Revoking…":"Revoke"}):null]})]})]})},e.authorization_id)}function sS(){const[e,s]=h.useState([]),[a,o]=h.useState(!0),[l,u]=h.useState([]),[f,p]=h.useState(!1),[g,v]=h.useState(new Map),[y,x]=h.useState("mine"),[j,k]=h.useState("active"),[b,S]=h.useState(null),[N,E]=h.useState(null),[T,P]=ps(),[I,B]=h.useState(()=>T.get("new")==="1"),[O]=h.useState(()=>T.get("profile")),[K,z]=h.useState(()=>T.get("highlight")),[U,ee]=h.useState(null),[X,F]=h.useState({}),[ne,fe]=h.useState(null),[te,ge]=h.useState(null),[ke,Z]=h.useState(null),[Q,q]=h.useState(new Set),[A,$]=h.useState(null),[ie,re]=h.useState(new Set),[H,oe]=h.useState(null),[ue,pe]=h.useState(null),[ve,le]=h.useState(new Set),Ge=Sn(),{group:Se,groupId:Y,domain:$e,mode:_e,activeTeam:Be}=xt(),ze=(Be==null?void 0:Be.isAdmin)===!0,[it,tt]=h.useState(()=>new Map),[Qe,Ye]=h.useState([]);h.useEffect(()=>{L.getLabelManifests().then(Ye).catch(()=>{})},[]);const jt=h.useCallback(()=>{o(!0),L.getMyAttestations().then(s).catch(()=>{}).finally(()=>o(!1))},[]),pt=h.useCallback(()=>{L.getArchivedMandates().then(de=>re(new Set(de))).catch(()=>{})},[]);h.useEffect(()=>{pt()},[pt]);const Me=h.useCallback(()=>{L.getEnrichedAuthorizations().then(de=>le(new Set(de.filter(Ce=>Ce.needsReapproval).map(Ce=>Ce.authorizationId)))).catch(()=>{})},[]);h.useEffect(()=>{Me()},[Me]);const me=async(de,Ce)=>{oe(de);try{const Ie=await L.setMandateArchived(de,Ce);re(new Set(Ie)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(Ie){alert(Ie instanceof Error?Ie.message:"Failed to update archive")}finally{oe(null)}},Ae=h.useCallback(()=>{Y&&(p(!0),L.listTeamAuthorizations(Y).then(u).catch(()=>{}).finally(()=>p(!1)))},[Y]);Fe("attestation-changed",()=>{jt(),ze&&Y&&Ae(),Me()}),h.useEffect(()=>{if(!K)return;T.get("highlight")&&(T.delete("highlight"),P(T,{replace:!0}));const de=window.setTimeout(()=>z(null),3e3);return()=>window.clearTimeout(de)},[]),Ft(jt,3e5),h.useEffect(()=>{y==="team"&&ze&&Y&&l.length===0&&!f&&Ae()},[y,ze,Y,l.length,f,Ae]),h.useEffect(()=>{let de=!1;return L.listProfiles().then(Ce=>{if(de)return;const Ie=Ct=>Ct.replace(/@.*$/,"").split("/").pop()??Ct,Ve=Ct=>Ct.split("@")[1]??"",Xe=new Map;for(const Ct of Ce){const Pt=Ie(Ct.id),Lr=Xe.get(Pt);(!Lr||Ve(Ct.id).localeCompare(Ve(Lr.id),void 0,{numeric:!0})>0)&&Xe.set(Pt,Ct)}v(Xe)}).catch(()=>{}),()=>{de=!0}},[]);const Oe=h.useCallback(de=>{const Ce=Pt=>Pt.replace(/@.*$/,"").split("/").pop()??Pt,Ie=Pt=>Pt.split("@")[1]??"",Ve=g.get(Ce(de));if(!Ve)return;const Xe=Ie(de),Ct=Ie(Ve.id);if(!(!Xe||!Ct))return Ct.localeCompare(Xe,void 0,{numeric:!0})>0?Ve:void 0},[g]),G=h.useCallback(de=>Bn(de,[...g.values()]),[g]);h.useEffect(()=>{if(_e!=="team"||!Y)return;const de=y==="mine"?e:l;if(de.length===0)return;const Ce=[...new Set(de.map(Ie=>Ie.profile_id))].filter(Ie=>!it.has(Ie));if(Ce.length!==0){tt(Ie=>{const Ve=new Map(Ie);for(const Xe of Ce)Ve.set(Xe,null);return Ve});for(const Ie of Ce)L.getTeamProfileConfig(Y,Ie).then(Ve=>{tt(Xe=>new Map(Xe).set(Ie,Ve))}).catch(()=>{})}},[e,l,y,Y,_e,it]);const J=async de=>{if(U===de.authorization_id){ee(null);return}ee(de.authorization_id);const Ce=de.authorization_id;if(!(Ce in X)){fe(de.authorization_id);try{const Ie=await L.getGateContent(Ce);F(Ve=>({...Ve,[Ce]:Ie}))}catch{F(Ie=>({...Ie,[Ce]:null}))}finally{fe(null)}}},ye=de=>{navigator.clipboard.writeText(de).then(()=>{Z(de),setTimeout(()=>Z(null),2e3)})},Ue=async(de,Ce)=>{var Ie;if(!Y){alert("No active group; cannot copy mandate.");return}pe(de.authorization_id);try{const Ve=de.authorization_id;let Xe=X[Ve]??null;Ve in X||(Xe=await L.getGateContent(Ve),F(kn=>({...kn,[Ve]:Xe})));const Ct=Object.fromEntries(Object.entries(de.frame).filter(([kn])=>kn!=="profile"&&kn!=="path")),Pt=(Xe==null?void 0:Xe.context)??{},Lr=((Ie=Xe==null?void 0:Xe.gateContent)==null?void 0:Ie.intent)??"",cr=de.deferred_commitment_domains.length>0?"review":"automatic",zr=de.attested_domains[0]||$e||"owner",Wn=Date.parse(de.created_at),ur=de.earliest_expiry?Date.parse(de.earliest_expiry):NaN,io=Number.isFinite(Wn)&&Number.isFinite(ur)&&ur>Wn?Math.round((ur-Wn)/1e3):void 0;let ya=de.profile_id,va=Ct,bn=Pt,gs;const xa=await L.listProfiles(),Fr=yp(de.profile_id,xa);if(Fr&&Fr.id!==de.profile_id){const kn=await L.getProfile(Fr.id);ya=Fr.id,va=xp(Ct,kn),bn=wp(Pt,kn),gs=de.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:ya,groupId:Y,groupName:(Se==null?void 0:Se.name)??null,domain:zr,isPersonal:!!(Se!=null&&Se.isPersonal),upgradedFromProfileId:gs})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:va,context:bn,gateContent:{intent:Lr},templateMode:cr,templateTtl:io})),Ce!=null&&Ce.asEdit?sessionStorage.setItem("agentEditReplaces",de.authorization_id):sessionStorage.removeItem("agentEditReplaces"),Ge("/mandates/new/intent")}catch(Ve){alert(Ve instanceof Error?Ve.message:"Failed to copy mandate")}finally{pe(null)}},We=async(de,Ce,Ie)=>{const Ve=Ce&&Ie?`Revoke ${Ce}'s ${Ie} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(Ve)){$(de);try{await L.revokeAttestation(de),q(Xe=>new Set(Xe).add(de)),L.resyncGates().catch(()=>{}),Ce&&Y&&Ae()}catch(Xe){alert(Xe instanceof Error?Xe.message:"Failed to revoke mandate")}finally{$(null)}}},nt=y==="mine"?e:l,Ht=y==="mine"?a:f,Ot=y==="mine"?{revokedSet:Q,archivedSet:ie}:{revokedSet:Q},Ze=de=>Fi(de,Ot),W={active:0,pending:0,expired:0,revoked:0,archived:0};for(const de of nt)W[Ze(de)]+=1;const xe=y==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],Te=(()=>{const de=new Map;for(const Ce of nt){if(Ze(Ce)!==j)continue;const Ie=In(Ce.profile_id),Ve=de.get(Ie);Ve?Ve.count+=1:de.set(Ie,{shortId:Ie,icon:Ar(Ce.profile_id),name:G(Ce.profile_id),count:1})}return[...de.values()].sort((Ce,Ie)=>Ce.name.localeCompare(Ie.name))})(),rt=Te.reduce((de,Ce)=>de+Ce.count,0),gt=nS(nt.filter(de=>{if(Ze(de)!==j||b!==null&&In(de.profile_id)!==b)return!1;if(N!==null){const Ce=de.deferred_commitment_domains.length>0;if(N==="review"&&!Ce||N==="auto"&&Ce)return!1}return!0}),Ot,K),Ke=h.useMemo(()=>{const de=new Map;for(const Ce of gt){const Ie=In(Ce.profile_id);let Ve=de.get(Ie);Ve||(Ve={shortId:Ie,icon:Ar(Ce.profile_id),name:G(Ce.profile_id),items:[]},de.set(Ie,Ve)),Ve.items.push(Ce)}return[...de.values()].sort((Ce,Ie)=>Ie.items.length-Ce.items.length||Ce.name.localeCompare(Ie.name))},[gt,G]),Nt=h.useCallback(de=>[...new Set(Qe.filter(Ce=>Ce.profile===de).map(Ce=>Ce.name))],[Qe]),St={revokedSet:Q,expandedHash:U,gateCache:X,gateLoading:ne,copiedHash:ke,revokingHash:A,copyingHash:ue,profileConfigCache:it,mode:_e,activeDomain:$e,group:Se,groupId:Y,onExpand:J,onCopyHash:ye,onCopy:Ue,onRevoke:We,onExtend:ge,highlightHash:K},Xt={...St,archivedSet:ie,archivingHash:H,onArchive:me,needsReapprovalSet:ve};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Mandates"}),n.jsx("p",{className:"page-subtitle",children:"Active, pending, expired, and archived agent mandates."})]}),n.jsx("button",{className:"btn btn-primary",onClick:()=>B(!0),children:"+ New mandate"})]}),I&&n.jsx("div",{className:"modal-backdrop",onClick:()=>{B(!1),(T.get("new")||T.get("profile"))&&(T.delete("new"),T.delete("profile"),P(T,{replace:!0}))},children:n.jsxs("div",{className:"modal",onClick:de=>de.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h2",{className:"modal-title",children:"New mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>{B(!1),(T.get("new")||T.get("profile"))&&(T.delete("new"),T.delete("profile"),P(T,{replace:!0}))},children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[n.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."}),n.jsx(Vj,{onDismiss:()=>B(!1),preselectProfileId:O})]})]})}),ze&&n.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[n.jsx("button",{className:`nav-tab${y==="mine"?" active":""}`,onClick:()=>{x("mine"),k("active"),S(null),E(null),ee(null)},children:"Mine"}),n.jsx("button",{className:`nav-tab${y==="team"?" active":""}`,onClick:()=>{x("team"),k("active"),S(null),E(null),ee(null)},children:"Team"})]}),n.jsx("div",{className:"nav-tabs",children:xe.map(de=>n.jsxs("button",{className:`nav-tab${j===de?" active":""}`,onClick:()=>{k(de),S(null),E(null)},children:[de.charAt(0).toUpperCase()+de.slice(1)," (",W[de],")"]},de))}),rt>0&&n.jsxs("div",{className:"mandate-filters",children:[n.jsx(Jc,{areas:Te,selected:b,onSelect:S,totalCount:rt}),n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which mode",children:["auto","review"].map(de=>{const Ce=N===de;return n.jsx("button",{type:"button",role:"tab",className:"ftab","data-testid":`mode-filter-${de}`,"aria-selected":Ce,onClick:()=>E(Ce?null:de),children:de==="auto"?"Automatic":"Review"},de)})})]}),Ht&&nt.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):gt.length===0?n.jsx(ds,{icon:"☰",title:"No mandates",text:j==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${j} mandates found.`}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:Ke.map(de=>n.jsxs("section",{"data-testid":"mandate-area","data-area":de.shortId,children:[n.jsxs("div",{className:"area-group-h",children:[n.jsx(ga,{icon:de.icon}),n.jsx("b",{children:de.name}),n.jsxs("span",{className:"meta",children:[de.items.length," mandate",de.items.length===1?"":"s",Nt(de.shortId).length>0&&n.jsxs(n.Fragment,{children:[" · via ",Nt(de.shortId).join(", ")]})]})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:de.items.map(Ce=>{const Ie=y==="team"?Ce:null,Ve=Ie!=null&&Ie.owner?Ie.owner.name??Ie.owner.email??Ie.owner.userId:void 0;return n.jsx(rS,{item:Ce,newerProfile:Oe(Ce.profile_id),area:de.name,ownerLabel:Ve,isAdmin:ze,...y==="mine"?Xt:St},Ce.authorization_id)})})]},de.shortId))}),te&&n.jsx(eS,{item:te,onClose:()=>ge(null),onSuccess:()=>{ge(null),jt()}})]})}function jp(e){const s=e.approved?e.proposalArgs:e.sentArgs;return Lw(e.tool,s??null,e.manifests)??e.label}function aS(e){if(e.offDevice)return{level:"off-device"};const s=e.sentArgs??e.proposalArgs,a=s?e.sentArgsCheck??"unchecked":"unchecked";return e.hasHashToCheck&&e.boundContent!==void 0?{level:"sealed",check:e.hashVerified===!0?"ok":"failed",bound:e.boundContent,extras:s?iS(e.boundContent,s):null,argsCheck:a}:s?{level:"recorded",content:s,check:a}:e.boundContent!==void 0?{level:"recorded",content:e.boundContent,check:"unchecked"}:{level:"not-kept",reason:e.sentArgsOmitted==="too_large"?"too_large":"older"}}function iS(e,s){const a={};for(const[o,l]of Object.entries(s))(typeof e=="string"?l===e:o in e)||(a[o]=l);return Object.keys(a).length>0?a:null}function Sp(e,s,a){return Um(e,s).map(o=>{var l;return{...o,inTicket:lS(o.value,(l=s==null?void 0:s.executionMapping)==null?void 0:l[o.key],a)}})}function oS(e,s){if(String(e)===String(s))return!0;if(typeof e=="boolean"||typeof s=="boolean"||e===""||s===""||e===null||s===null)return!1;const a=Number(e),o=Number(s);return Number.isFinite(a)&&Number.isFinite(o)&&a===o}function lS(e,s,a){return!s||!a||e===void 0||e===null?!1:(typeof s=="string"?[{field:s}]:Array.isArray(s)?s:[s]).some(l=>{if(!(l.field in a))return!1;const u=a[l.field];return l.divisor?Number.isFinite(Number(e))&&Number(e)/l.divisor===Number(u):l.transform==="join"?(Array.isArray(e)?e:[e]).map(p=>p&&typeof p=="object"&&"email"in p?String(p.email):String(p)).join(",")===String(u):l.transform?!1:oS(e,u)})}function nc(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function cS(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function Ch(e,s){return Object.entries(e).filter(([a,o])=>!cS(o)&&!(s&&a in s&&nc(s[a])===nc(o))).map(([a,o])=>({key:a,label:Wt(a),value:nc(o)}))}function uS(e,s){const a=e.structuredContent;if(a&&typeof a=="object"&&!Array.isArray(a)&&Object.keys(a).length>0)return{kind:"rows",rows:Ch(a,s)};const o=e.text.trim();if(o.startsWith("{"))try{const l=JSON.parse(o);if(l&&typeof l=="object"&&!Array.isArray(l)&&Object.keys(l).length>0)return{kind:"rows",rows:Ch(l,s)}}catch{}return{kind:"text",text:e.text}}const Eh=new Map;function dS(e){let s=Eh.get(e);return s||(s=L.getProposal(e).catch(()=>null),Eh.set(e,s)),s}let os=null;function fS(e){if(!os||e*1e3>os.fetchedAtMs){const s={fetchedAtMs:Date.now(),map:L.getTicketHeadlines().catch(()=>(os===s&&(os=null),{}))};os=s}return os.map}function hS({proposal:e,tool:s,manifests:a,label:o}){const l=so(e);return n.jsx(n.Fragment,{children:jp({tool:s,manifests:a,label:o,approved:!0,proposalArgs:l.toolArgs})})}function mS({ticketId:e,timestamp:s,proposalId:a,tool:o,manifests:l,label:u}){const[f,p]=h.useState(null),[g,v]=h.useState(null);return h.useEffect(()=>{let y=!0;return p(null),v(null),a?dS(a).then(x=>{y&&p(x)}):fS(s).then(x=>{y&&v(x[e]??null)}),()=>{y=!1}},[a,e,s]),a?f?n.jsx(hS,{proposal:f,tool:o,manifests:l,label:u}):n.jsx(n.Fragment,{children:u}):n.jsx(n.Fragment,{children:jp({tool:o,manifests:l,label:u,approved:!1,sentArgs:g})})}const pS=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function gS(e,s){return typeof s!="string"?!1:/^data:image\//i.test(s)?!0:pS.test(e)?/^https?:\/\//.test(s):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(s)}function Nr(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Th({row:e,which:s}){const a=ma(e.profileRef),o=mw(e.value,a,s);return o.length===0?n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"none"}):n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.75rem",margin:0},children:o.map(l=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-secondary)"},title:l.hint,children:l.label}),n.jsxs("dd",{style:{margin:0,fontWeight:600},children:[l.value,l.unknown&&n.jsx("span",{className:"msg-error",style:{marginLeft:"0.5rem"},children:"not defined by this profile"})]})]},l.key))})}function yS({row:e}){const s=ma(e.profileRef),a=(s==null?void 0:s.id)??e.profileRef??"";return n.jsxs(n.Fragment,{children:[(s==null?void 0:s.name)??Mt(a),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:a})]})}function bp({row:e,altText:s}){switch(e.kind){case"profile":return n.jsx(yS,{row:e});case"profile-limits":return n.jsx(Th,{row:e,which:"limits"});case"profile-scope":return n.jsx(Th,{row:e,which:"scope"});case"markdown":return n.jsx("div",{style:{whiteSpace:"pre-wrap",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.625rem"},children:Nr(e.value)});case"list":return Array.isArray(e.value)?n.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:e.value.map((a,o)=>n.jsx("li",{children:Nr(a)},o))}):n.jsx(n.Fragment,{children:Nr(e.value)});case"money":return n.jsxs(n.Fragment,{children:[Nr(e.value),e.currency?` ${e.currency}`:""]});case"object":return n.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Nr(e.value)});default:return gS(e.key,e.value)?n.jsx("img",{src:e.value,alt:s??e.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):n.jsx(n.Fragment,{children:Nr(e.value)})}}function xc({args:e,display:s,heading:a="Details",requestRefArg:o}){const l=Um(e,s);if(l.length===0)return null;const u=typeof e.altText=="string"?e.altText:void 0;return n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a&&n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:a}),n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:l.map(f=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:f.hint,children:f.key===o?"Replying to":f.label}),n.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:f.key===o?n.jsx("span",{"data-testid":"request-ref",title:Nr(f.value),children:"the message shown under Request"}):n.jsx(bp,{row:f,altText:u})})]},f.key))})]})}let Ri=null;function vS(){return Ri||(Ri=L.getToolDisplay().catch(()=>(Ri=null,{}))),Ri}function kp({args:e,display:s,executionContext:a,sealed:o}){const l=Sp(e,s,a);return l.length===0?null:n.jsx("dl",{className:"ticket-sent-fields",children:l.map(u=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{title:u.hint,children:u.label}),n.jsxs("dd",{className:o?"is-sealed":void 0,children:[n.jsx(bp,{row:u}),u.inTicket&&n.jsx("span",{className:"ticket-sent-tag",title:"This value is also in the signed ticket",children:"in the ticket"})]})]},u.key))})}function Ah({content:e,display:s,executionContext:a,sealed:o}){return typeof e=="string"?n.jsx("p",{className:`ticket-sent-text${o?" is-sealed":""}`,children:e}):n.jsx(kp,{args:e,display:s,executionContext:a,sealed:o})}function Ih({check:e}){return e==="match"?n.jsx("p",{className:"ticket-sent-check",children:"✓ Matches what this gateway executed"}):e==="mismatch"?n.jsx("p",{className:"ticket-sent-check is-failed",children:"✕ Does not match what this gateway executed"}):n.jsx("p",{className:"ticket-sent-check is-neutral",children:"Could not be checked against this gateway's execution record."})}function xS({view:e,display:s,executionContext:a}){return e.level==="off-device"?n.jsxs("div",{className:"ticket-sent-box","data-testid":"ticket-what-was-done","data-bound":"off-device",children:[n.jsx("h4",{children:"What was sent"}),n.jsx("p",{className:"ticket-sent-empty",children:"Only on the gateway that ran it — this device has no local copy. The signed ticket still proves the limits it ran under."})]}):e.level==="not-kept"?n.jsxs("div",{className:"ticket-sent-box","data-testid":"ticket-what-was-done","data-bound":"not-kept","data-reason":e.reason,children:[n.jsx("h4",{children:"What was sent"}),n.jsxs("p",{className:"ticket-sent-empty",children:[e.reason==="too_large"?"Not kept — what was sent was too large to keep on this device.":"Not kept — this ticket is older than the release that started keeping it."," ","The signed ticket still proves the limits it ran under."]})]}):e.level==="sealed"?n.jsxs("div",{className:"ticket-sent-box is-sealed","data-testid":"ticket-what-was-done","data-bound":"sealed","data-check":e.check,children:[n.jsxs("h4",{children:["What was sent ",n.jsx("span",{className:"ticket-sent-q",children:"sealed in the ticket"})]}),n.jsx(Ah,{content:e.bound,display:s,executionContext:a,sealed:!0}),e.check==="ok"?n.jsx("p",{className:"ticket-sent-check",children:"✓ Matches the fingerprint in the signed ticket"}):n.jsx("p",{className:"ticket-sent-check is-failed",children:"✕ Does not match the fingerprint in the signed ticket — this local copy was changed"}),e.extras&&Sp(e.extras,s,a).length>0&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ticket-sent-sub",children:"Also sent — recorded by this gateway, not sealed in the ticket"}),n.jsx(kp,{args:e.extras,display:s,executionContext:a,sealed:!1}),e.argsCheck==="mismatch"&&n.jsx(Ih,{check:"mismatch"})]})]}):n.jsxs("div",{className:"ticket-sent-box","data-testid":"ticket-what-was-done","data-bound":"recorded","data-check":e.check,children:[n.jsxs("h4",{children:["What was sent ",n.jsx("span",{className:"ticket-sent-q",children:"recorded by this gateway — not sealed in the ticket"})]}),n.jsx(Ah,{content:e.content,display:s,executionContext:a,sealed:!1}),n.jsx(Ih,{check:e.check})]})}const Rh=5;function wS({result:e,systemName:s,sent:a}){const o=uS(e,a),[l,u]=h.useState(!1);return n.jsxs("div",{className:"ticket-sent-box","data-testid":"ticket-result","data-ok":e.ok?"true":"false",children:[n.jsxs("h4",{children:["Result ",n.jsxs("span",{className:"ticket-sent-q",children:["what ",s," answered"]})]}),!e.ok&&n.jsx("p",{className:"ticket-sent-check",children:"The action failed."}),o.kind==="rows"?n.jsx("dl",{className:"ticket-sent-fields",children:(l?o.rows:o.rows.slice(0,Rh)).map(f=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{children:f.label}),n.jsx("dd",{className:"is-system",children:f.value})]},f.key))}):n.jsx("p",{className:"ticket-sent-text is-system",children:o.text}),o.kind==="rows"&&o.rows.length>Rh&&n.jsx("button",{type:"button",className:"ticket-sent-more",onClick:()=>u(f=>!f),children:l?"Show less":`Show all ${o.rows.length}`}),e.truncated&&n.jsx("p",{className:"ticket-sent-check is-neutral",children:"Shortened to fit what this device keeps."})]})}function jS(e){var a;const s=[e.entry.sentArgs,(a=e.entry.proposal)==null?void 0:a.toolArgs,e.entry.boundContent];for(const o of s)if(o&&typeof o=="object"&&!Array.isArray(o))return o;return null}function Np({receipt:e,manifests:s}){var j;const[a,o]=h.useState(void 0),[l,u]=h.useState(null),[f,p]=h.useState(void 0),g=!!(e.contentHash&&e.contentBinding);if(h.useEffect(()=>{let k=!0;return vS().then(b=>{k&&p(b[e.action])}),()=>{k=!1}},[e.action]),h.useEffect(()=>{let k=!0;return o(void 0),u(null),(async()=>{let b;try{b=await L.getArchivedReceipt(e.id)}catch{k&&o(null);return}let S=null;const N=b==null?void 0:b.entry.boundContent;if(N!==void 0&&g)try{S=await qm(e.contentBinding.kind,N)===e.contentHash}catch{S=!1}k&&(u(S),o(b))})(),()=>{k=!1}},[e.id,e.contentHash,e.contentBinding,g]),a===void 0)return n.jsx("div",{className:"ticket-sent-box ticket-sent-loading","data-testid":"ticket-what-was-done","data-bound":"loading","aria-busy":"true",children:"Loading…"});const v=(j=a==null?void 0:a.entry.proposal)==null?void 0:j.toolArgs,y=aS({offDevice:a===null,boundContent:a==null?void 0:a.entry.boundContent,sentArgs:a==null?void 0:a.entry.sentArgs,sentArgsOmitted:a==null?void 0:a.entry.sentArgsOmitted,proposalArgs:v&&typeof v=="object"&&!Array.isArray(v)?v:void 0,hasHashToCheck:g,hashVerified:l,sentArgsCheck:a==null?void 0:a.sentArgsCheck}),x=_r(Un(e.action).integrationId,s);return n.jsxs(n.Fragment,{children:[n.jsx(xS,{view:y,display:f,executionContext:e.executionContext}),(a==null?void 0:a.result)&&n.jsx(wS,{result:a.result,systemName:x,sent:jS(a)})]})}function dn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ut(e,s=!1){return e==null?"—":typeof e=="string"?e:typeof e=="boolean"?String(e):typeof e=="number"?s||Number.isInteger(e)?String(e):String(Math.round(e*100)/100):"—"}function SS(e){return e==null?!1:typeof e=="string"||Array.isArray(e)?e.length>0:!0}function Er(e,s,a){const o=s?Object.keys(s).filter(l=>l in e):Object.keys(e);return o.length===0?"—":o.map(l=>{var g,v;const u=e[l],f=((g=s==null?void 0:s[l])==null?void 0:g.title)??Wt(l),p=dn(u)?Er(u,(v=s==null?void 0:s[l])==null?void 0:v.properties,a):Ut(u,a);return`${f}: ${p}`}).join(" · ")}function bS(e,s){const a=s?Object.keys(s).filter(u=>e.some(f=>u in f)):[...new Set(e.flatMap(u=>Object.keys(u)))],o=a.map(u=>{var f;return{key:u,label:((f=s==null?void 0:s[u])==null?void 0:f.title)??Wt(u)}}),l=e.map(u=>({cells:a.map(f=>{var y,x;const p=u[f],g=dn(p)?Er(p,(y=s==null?void 0:s[f])==null?void 0:y.properties,!1):Ut(p),v=dn(p)?Er(p,(x=s==null?void 0:s[f])==null?void 0:x.properties,!0):Ut(p,!0);return v===g?{value:g,sealed:!1}:{value:g,valueTitle:v,sealed:!1}})}));return{columns:o,rows:l}}function kS(e){return e.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 NS(e,s){var l;if(Array.isArray(e)){if(e.length===0)return{value:"—"};if(e.every(y=>!dn(y)&&!Array.isArray(y))){if(e.every(j=>typeof j=="string"))return{lines:e};const y=e.map(j=>Ut(j)).join(", "),x=e.map(j=>Ut(j,!0)).join(", ");return x===y?{value:y}:{value:y,valueTitle:x}}const u=(l=s==null?void 0:s.items)==null?void 0:l.properties,f=e.map(y=>dn(y)?Er(y,u,!1):Ut(y)),p=e.map(y=>dn(y)?Er(y,u,!0):Ut(y,!0)),g=f.map((y,x)=>y===p[x]?void 0:p[x]),v=e.every(dn)?bS(e,u):void 0;return{lines:f,...g.some(y=>y!==void 0)?{lineTitles:g}:{},...v?{table:v}:{}}}if(dn(e)){const u=s==null?void 0:s.properties,f=u?Object.keys(u).filter(v=>v in e):Object.keys(e);if(f.length>0&&f.every(v=>!dn(e[v])&&!Array.isArray(e[v])))return{sublist:f.map(y=>{var S;const x=e[y],j=((S=u==null?void 0:u[y])==null?void 0:S.title)??Wt(y),k=Ut(x),b=Ut(x,!0);return b===k?{key:y,label:j,value:k}:{key:y,label:j,value:k,valueTitle:b}})};const p=Er(e,u,!1),g=Er(e,u,!0);return g===p?{value:p}:{value:p,valueTitle:g}}if(typeof e=="string"&&(s==null?void 0:s.contentMediaType)==="text/x-diff")return{diffLines:kS(e)};const a=Ut(e),o=Ut(e,!0);return o===a?{value:a}:{value:a,valueTitle:o}}function CS(e){let s;try{s=JSON.parse(e)}catch{return null}return dn(s)?s:null}function Rr(e){const s=e!=null&&e.structured&&Object.keys(e.structured).length>0?e.structured:void 0;if(s)return{obj:s,schema:e==null?void 0:e.outputSchema};const a=e!=null&&e.text?CS(e.text):null;return a?{obj:a}:null}function Gi(e){const s=Rr(e);if(!s)return[];const{obj:a,schema:o}=s,l=(o==null?void 0:o.properties)??{},u=[...new Set([...Object.keys(l),...Object.keys(a)])],f=[];for(const p of u){if(!(p in a))continue;const g=l[p],v=(g==null?void 0:g.title)??Wt(p),y={key:p,label:v,...NS(a[p],g)};g!=null&&g.description&&(y.description=g.description),f.push(y)}return f}function Cp(e,s){const a=Rr(e);if(a){const l=Gi(e),u=s==null?void 0:s.fields;let f;if(u&&u.length>0){const v=new Map(l.map(y=>[y.key,y]));f=u.map(y=>v.get(y)).filter(y=>y!==void 0)}else f=l.filter(v=>SS(a.obj[v.key]));const p=new Set(f.map(v=>v.key)),g=l.filter(v=>!p.has(v.key));return{kind:"structured",fields:f,moreFields:g,totalFields:l.length}}const o=e==null?void 0:e.text;return o&&o.trim().length>0?{kind:"text",fields:[],moreFields:[],totalFields:0,text:o}:{kind:"empty",fields:[],moreFields:[],totalFields:0}}function Ph(e){return e?e.lines?`lines:${JSON.stringify(e.lines)}`:e.sublist?`sublist:${JSON.stringify(e.sublist.map(s=>[s.key,s.value]))}`:e.diffLines?`diffLines:${JSON.stringify(e.diffLines)}`:`value:${e.value??""}`:""}function Pi(e){return{kind:e.length>0?"structured":"empty",fields:e,moreFields:[],totalFields:e.length}}function ES(e,s,a){const o=Rr(e),l=Rr(s);if(!o&&!l){const j=(e==null?void 0:e.text)??"",k=(s==null?void 0:s.text)??"";return j===k?{approved:Pi([]),current:Pi([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:j},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:k},unchanged:!1}}const u=new Map(Gi(e).map(j=>[j.key,j])),f=new Map(Gi(s).map(j=>[j.key,j])),g=[...new Set([...u.keys(),...f.keys()])].filter(j=>j===(a==null?void 0:a.excludeKey)?!1:Ph(u.get(j))!==Ph(f.get(j))),v=a!=null&&a.fields&&a.fields.length>0?[...a.fields.filter(j=>g.includes(j)),...g.filter(j=>!a.fields.includes(j))]:g,y=v.map(j=>u.get(j)).filter(j=>j!==void 0),x=v.map(j=>f.get(j)).filter(j=>j!==void 0);return{approved:Pi(y),current:Pi(x),unchanged:g.length===0}}function TS(e){const s=e==null?void 0:e.structured;if(Array.isArray(s)&&s.every(dn))return s;if(e!=null&&e.text){let a;try{a=JSON.parse(e.text)}catch{return null}if(Array.isArray(a)&&a.every(dn))return a}return null}function ao(e){const s=Ut(e),a=Ut(e,!0);return a===s?{value:s}:{value:s,valueTitle:a}}function Ep(e){return!e||e.status!=="ok"?[]:Gi(e.body)}function Tp(e){if(!e)return"Not read.";switch(e.status){case"not_found":return"Not found in the system.";case"none":return"Nothing to read.";default:return"Not available right now."}}function Ap(e,s,a){var g;const o=Ep(e);if(o.length===0)return{rawId:Ut(s),context:[],unresolved:Tp(e)};const l=e&&e.status==="ok"?(g=Rr(e.body))==null?void 0:g.obj:void 0,u=o.find(v=>["name","title","label"].includes(v.key))??o.find(v=>typeof(l==null?void 0:l[v.key])=="string"&&!v.lines&&!v.sublist&&!v.diffLines),f=a==null?void 0:a.pathPrefix,p=o.filter(v=>v.key!==(u==null?void 0:u.key)&&v.key!=="id").map(v=>{var b,S;if(!f)return v;const y=`${f}.${v.key}`,x=oa(a==null?void 0:a.displayHints,y,v.label);if(!da((b=a==null?void 0:a.displayHints)==null?void 0:b.money,y)&&!da((S=a==null?void 0:a.displayHints)==null?void 0:S.percent,y))return x===v.label?v:{...v,label:x};const{value:j,valueTitle:k}=Ki(l==null?void 0:l[v.key],a==null?void 0:a.displayHints,y,a==null?void 0:a.currency);return{...v,label:x,value:j,valueTitle:k}});return{name:u==null?void 0:u.value,rawId:Ut(s),context:p}}const AS=new Set(["id","name","title","label"]);function da(e,s){return!!(e!=null&&e.includes(s))}function oa(e,s,a){var o;return((o=e==null?void 0:e.labels)==null?void 0:o[s])??a}function IS(e,s){const a=typeof e=="number"?e:Number(e);return Number.isFinite(a)?{value:`${a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${s?` ${s}`:""}`}:ao(e)}function RS(e){return typeof e!="number"&&typeof e!="string"?ao(e):{value:`${e} %`}}function Ki(e,s,a,o){return da(s==null?void 0:s.money,a)?IS(e,o):da(s==null?void 0:s.percent,a)?RS(e):ao(e)}function Ip(e,s){return da(e==null?void 0:e.hidden,s)}function PS(e,s,a){var f;const o=e==null?void 0:e.currencyField;if(!o)return;const l=o.indexOf(".");if(l<0){const p=s[o];return typeof p=="string"?p:void 0}const u=(f=a(o.slice(0,l)))==null?void 0:f[o.slice(l+1)];return typeof u=="string"?u:void 0}function $S(e,s,a,o){const l=e.forEach??"",u=e.attach,f=e.elements??[],p=Math.min(s.length,f.length),g=s.slice(0,p),v=f.slice(0,p),y=[...new Set(g.flatMap(S=>Object.keys(S)))].filter(S=>S!==e.sourceArg).filter(S=>!Ip(a,`${l}[].${S}`)),x=new Map;if(u)for(const S of v)for(const N of Ep(S))x.has(N.key)||x.set(N.key,N.label);const j=u?[...x.keys()].filter(S=>!AS.has(S)):[],k=[];u&&k.push({key:`__attach:${u}`,label:oa(a,`${l}[].${u}`,Wt(e.sourceArg??u))});for(const S of y)k.push({key:`bound:${S}`,label:oa(a,`${l}[].${S}`,Wt(S))});for(const S of j)k.push({key:`attached:${S}`,label:oa(a,`${l}[].${u}.${S}`,x.get(S)??Wt(S))});const b=g.map((S,N)=>{var I;const E=v[N],T=[];if(u){const B=Ap(E,e.sourceArg?S[e.sourceArg]:void 0),O=B.name?`${B.name} (${B.rawId})`:B.unresolved?`${B.rawId} — ${B.unresolved}`:B.rawId;T.push({value:O,sealed:!1})}for(const B of y){const{value:O,valueTitle:K}=Ki(S[B],a,`${l}[].${B}`,o);T.push({value:O,valueTitle:K,sealed:!0})}const P=E&&E.status==="ok"?(I=Rr(E.body))==null?void 0:I.obj:void 0;for(const B of j){const O=P==null?void 0:P[B],{value:K,valueTitle:z}=O!==void 0?Ki(O,a,`${l}[].${u}.${B}`,o):{value:"—",valueTitle:void 0};T.push({value:K,valueTitle:z,sealed:!1})}return{cells:T}});return{columns:k,rows:b,...e.overflow?{overflowNote:`${e.overflow.total-e.overflow.shown} more not shown`}:{}}}function _S(e){return`${Wt(e)} — from the system`}function LS(e){const s=_S(e.tool),a=e.result;if(!a||a.status!=="ok")return{heading:s,note:Tp(a)};const o=TS(a.body);if(o){if(o.length===0)return{heading:s,note:"Nothing found."};const l=[...new Set(o.flatMap(p=>Object.keys(p)))],u=l.map(p=>({key:p,label:Wt(p)})),f=o.map(p=>({cells:l.map(g=>({...ao(p[g]),sealed:!1}))}));return{heading:s,table:{columns:u,rows:f}}}return{heading:s,body:Cp(a.body,{fields:e.fields})}}function zS(e,s,a){const o=new Map(s.filter(x=>x.attach&&!x.forEach).map(x=>[x.attach,x])),l=new Map(s.filter(x=>x.forEach).map(x=>[x.forEach,x])),u=s.filter(x=>!x.attach&&!x.forEach),p=PS(a,e,x=>{var k,b;const j=(k=o.get(x))==null?void 0:k.result;return j&&j.status==="ok"?(b=Rr(j.body))==null?void 0:b.obj:void 0}),g=(a==null?void 0:a.order)??[],v=[...new Set([...g,...Object.keys(e)])],y=[];for(const x of v){if(!(x in e)||Dm.has(x)||Ip(a,x))continue;const j=oa(a,x,Wt(x)),k=l.get(x);if(k){const E=Array.isArray(e[x])?e[x]:[];y.push({kind:"table",key:x,label:j,table:$S(k,E,a,p)});continue}const b=o.get(x);if(b){const E=Ap(b.result,e[x],{pathPrefix:x,displayHints:a,currency:p});y.push({kind:"identity",key:x,label:j,identity:E});continue}const{value:S,valueTitle:N}=Ki(e[x],a,x,p);y.push({kind:"scalar",key:x,label:j,value:S,valueTitle:N})}return{rows:y,sections:u.map(LS)}}const $h=500;function wc(e){return e.length>$h?`${e.slice(0,$h)}…`:e}function _h(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function FS(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Rp(e,s,a){switch(e.status){case"none":return e.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 e.reason==="no_connector"?{heading:"Preview not available",note:"Preview not available on this gateway."}:{heading:"Preview not available",note:e.message?`Preview not available — ${wc(e.message)}`:"Preview not available."};case"not_found":return{heading:"Not found in your system",note:e.message?`Not found in your system — ${wc(e.message)}`:"Not found in your system."};case"ok":{if("reads"in e)return{heading:`What will be created in ${s}`,note:`Read by the gateway, not by the AI — read at ${FS(e.readAt)}.`,creation:zS(a??{},e.reads,e.display)};const o=Cp(e.body,{fields:e.fields}),l={heading:`From ${s}, before it runs`,note:`Read by the gateway with ${e.tool} when you opened this card — the AI is not involved.`,rendered:o},u=e.version;if(u&&(l.versionNote=`You approve ${u.field} ${u.approved}; if it changes, ${s} refuses it.`,u.stale)){const f=ES(e.body,u.currentBody,{fields:e.fields,excludeKey:u.field});l.stale={heading:`A newer ${u.field} exists (${u.current})`,approvedLabel:`${_h(u.field)} ${u.approved}`,currentLabel:`${_h(u.field)} ${u.current}`,...f.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:f.approved,currentRendered:f.current}}}return l}}}function MS(e,s){if(e.state!=="failed")return null;const a=e.detail?wc(e.detail):void 0;return e.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${a?`: ${a}`:""} — nothing was done. Ask the AI to request it again.`}}function OS(e){return e!==null&&e!=="loading"&&e!=="ok"&&e!=="stale"}function qi({table:e}){return e.columns.length===0?n.jsx("p",{className:"preview-note",children:"Nothing to show."}):n.jsxs(n.Fragment,{children:[n.jsxs("table",{className:"preview-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.columns.map(s=>n.jsx("th",{children:s.label},s.key))})}),n.jsx("tbody",{children:e.rows.map((s,a)=>n.jsx("tr",{children:s.cells.map((o,l)=>n.jsx("td",{className:o.sealed?"src-tag-value src-tag-sealed-cell":"src-tag-value src-tag-system-cell",title:o.valueTitle,children:o.value},l))},a))})]}),e.overflowNote&&n.jsx("p",{className:"preview-note",children:e.overflowNote})]})}function Lh({row:e}){return n.jsxs("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:[e.label,e.description&&n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.72rem",fontWeight:400,whiteSpace:"normal",marginTop:"0.1rem"},children:e.description})]})}function BS({row:e}){return e.sublist?n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.6rem",margin:0},children:e.sublist.map(s=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:s.label}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},title:s.valueTitle,children:s.value})]},s.key))}):e.diffLines?n.jsx("div",{style:{fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.8rem"},children:e.diffLines.map((s,a)=>n.jsx("div",{style:s.kind==="remove"?{textDecoration:"line-through",color:"var(--text-muted)"}:s.kind==="add"?{fontWeight:600}:void 0,children:s.text||" "},a))}):e.table?n.jsx(qi,{table:e.table}):e.lines?n.jsx("div",{children:e.lines.map((s,a)=>{var o;return n.jsx("div",{title:(o=e.lineTitles)==null?void 0:o[a],children:s},a)})}):n.jsx("span",{title:e.valueTitle,children:e.value})}function jc({rows:e}){return n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.map(s=>s.table?n.jsxs("div",{style:{gridColumn:"1 / -1"},children:[n.jsx(Lh,{row:s}),n.jsx(qi,{table:s.table})]},s.key):n.jsxs(h.Fragment,{children:[n.jsx(Lh,{row:s}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:n.jsx(BS,{row:s})})]},s.key))})}function rc({rendered:e}){return e.kind==="empty"?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",margin:"0.4rem 0"},children:"No fields returned."}):e.kind==="text"?n.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.text}):n.jsxs(n.Fragment,{children:[n.jsx(jc,{rows:e.fields}),e.moreFields.length>0&&n.jsxs("details",{style:{fontSize:"0.8rem"},children:[n.jsxs("summary",{style:{cursor:"pointer",color:"var(--text-tertiary)"},children:["All fields (",e.totalFields,")"]}),n.jsx(jc,{rows:e.moreFields})]})]})}function DS({identity:e}){return e.unresolved?n.jsxs("span",{children:[n.jsx("span",{className:"id-raw",children:e.rawId})," ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["— ",e.unresolved]})]}):n.jsxs("span",{children:[e.name&&n.jsx("span",{className:"src-tag-value src-tag-system-cell",children:e.name})," ",n.jsx("span",{className:"id-raw",children:e.rawId}),e.context.length>0&&n.jsx("span",{className:"creation-context",children:e.context.map(s=>n.jsxs("span",{children:[" · ",s.label," ",s.value]},s.key))})]})}function US({view:e}){return n.jsxs(n.Fragment,{children:[n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.rows.map(s=>s.kind==="table"?null:n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:s.label}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:s.kind==="identity"?n.jsx(DS,{identity:s.identity}):n.jsx("span",{className:"src-tag-value src-tag-sealed-cell",title:s.valueTitle,children:s.value})})]},s.key))}),e.rows.filter(s=>s.kind==="table").map(s=>n.jsxs("div",{style:{margin:"0.5rem 0"},children:[n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.78rem",marginBottom:"0.2rem"},children:s.label}),n.jsx(qi,{table:s.table})]},s.key)),e.sections.map((s,a)=>n.jsxs("div",{className:"creation-own-section",children:[n.jsxs("h5",{children:[s.heading," ",n.jsx("span",{className:"src-tag src-tag-system",children:"from the system"})]}),s.table&&n.jsx(qi,{table:s.table}),s.body&&n.jsx(jc,{rows:s.body.fields}),s.note&&n.jsx("p",{className:"preview-note",children:s.note})]},a))]})}function Pp({resp:e,systemName:s,toolArgs:a,sealed:o}){const l=Rp(e,s,a??void 0),u=e.status==="ok"?l.stale?"stale":"ok":e.status;return u==="none"?n.jsx("p",{className:"sr-only","data-testid":"approval-preview","data-preview-status":"none",children:l.note}):n.jsxs("div",{className:`preview-box preview-box-${u}`,"data-testid":"approval-preview","data-preview-status":u,children:[n.jsxs("h4",{children:[l.heading,l.creation&&(o?n.jsx(n.Fragment,{children:n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})}):n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"}))]}),l.creation&&n.jsx(US,{view:l.creation}),l.rendered&&n.jsx(rc,{rendered:l.rendered}),n.jsx("p",{className:"preview-note",children:l.note}),l.versionNote&&!l.stale&&n.jsx("p",{className:"preview-note",children:l.versionNote}),l.stale&&n.jsxs("div",{className:"preview-stale",children:[n.jsx("h5",{children:l.stale.heading}),l.stale.unchangedNote?n.jsx("p",{className:"preview-note",children:l.stale.unchangedNote}):n.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.5rem 0 0"},children:[n.jsx("dt",{children:l.stale.approvedLabel}),n.jsx("dd",{children:n.jsx(rc,{rendered:l.stale.approvedRendered})}),n.jsx("dt",{children:l.stale.currentLabel}),n.jsx("dd",{children:n.jsx(rc,{rendered:l.stale.currentRendered})})]})]})]})}function WS({proposalId:e,systemName:s,toolArgs:a,sealed:o,onTone:l,onData:u}){const[f,p]=h.useState(null),[g,v]=h.useState(!1);return h.useEffect(()=>{let y=!0;return p(null),v(!1),L.getProposalPreview(e).then(x=>{y&&p(x)}).catch(()=>{y&&v(!0)}),()=>{y=!1}},[e]),h.useEffect(()=>{if(g){l==null||l("unavailable"),u==null||u({status:"unavailable",reason:"connector_error"});return}if(!f){u==null||u(null);return}const y=Rp(f,s,a??void 0);l==null||l(f.status==="ok"?y.stale?"stale":"ok":f.status),u==null||u(f)},[f,g,s,l,u]),g?n.jsxs("div",{className:"preview-box preview-box-unavailable","data-testid":"approval-preview","data-preview-status":"unavailable",children:[n.jsx("h4",{children:"Preview not available"}),n.jsx("p",{className:"preview-note",children:"Preview not available on this gateway."})]}):f?n.jsx(Pp,{resp:f,systemName:s,toolArgs:a,sealed:o}):n.jsxs("div",{className:"preview-box preview-box-loading","data-testid":"approval-preview","data-preview-status":"loading","aria-busy":"true",children:["Reading from ",s,"…"]})}const sc=6;function Yi(e){if(!e)return;const s=Date.parse(e);return Number.isNaN(s)?e:new Date(s).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function HS(e){if(!e)return{first:""};const s=e.split(`
|
|
85
|
+
`);return s.length<=sc?{first:e}:{first:s.slice(0,sc).join(`
|
|
86
|
+
`),more:s.slice(sc).join(`
|
|
87
|
+
`)}}const VS="Linked by the AI",GS="linked automatically — this action already carried a reference to it";function KS(e){if(e.status==="none")return{state:"none",note:"No request linked.",chain:[]};if(e.status==="unreadable")return{state:"unreadable",note:`Request: link not readable (${e.reason}).`,chain:[]};if(e.status==="not_found")return{state:"not_found",note:"Request: this message no longer exists.",chain:[]};const{first:s,more:a}=HS(e.body),o=[e.connector,e.kind,e.author?`from ${e.author}`:void 0,Yi(e.at)].filter(l=>!!l);return{state:"ok",implicit:e.implicit,tag:VS,...e.implicit?{implicitNote:GS}:{},metaLine:o.join(" · "),title:e.title,bodyFirst:s,bodyMore:a,attribution:e.author?`— from ${e.author}, not checked`:void 0,chain:e.chain.map(l=>({...l,at:Yi(l.at)}))}}const ea="Read by the gateway — same customer, not matched to this request";function qS(e){const s=e.matchedKeyType==="email_domain"?"matched by email domain":"matched by email";return`Latest entries for ${e.matchedKeyValue} (${s})`}function YS(e){var l;const s=!!e.aiWritten,a=s?"Activity":e.type??e.kind??"Entry";let o;if(s){const u=((l=e.aiWritten)==null?void 0:l.at)!==void 0?Yi(new Date(e.aiWritten.at).toISOString()):void 0;o=u?`— Written by the AI via Suveren, ${u} — not checked`:"— Written by the AI via Suveren — not checked"}else o=e.author?`— from ${e.author}, not checked`:"— not checked";return{headLabel:a,at:Yi(e.at),title:e.title,body:e.body,attribution:o,aiWritten:s}}function JS(e){if(e.status==="no_customer_link")return{state:"no_customer_link",label:ea,note:"No customer link — nothing to match history against.",matchNotes:[],items:[]};if(e.status==="no_match")return{state:"no_match",label:ea,note:"No match — no connector here matches on this customer's available identity key.",matchNotes:[],items:[]};if(e.status==="unreachable")return{state:"unreachable",label:ea,note:`${e.connectorIds.join(", ")} not reachable — history could not be read.`,matchNotes:[],items:[]};const s=e.matches.flatMap(l=>l.items.map(u=>({it:u,m:l}))).sort((l,u)=>(Date.parse(u.it.at??"")||0)-(Date.parse(l.it.at??"")||0)).map(({it:l})=>YS(l)),a=e.matches.map(qS),o=e.unreachableConnectorIds.length>0?`${e.unreachableConnectorIds.join(", ")} not reachable — showing what could be read.`:void 0;return s.length===0?{state:"empty",label:ea,note:"Nothing in the last few days.",matchNotes:a,items:[],unreachableNote:o}:{state:"ok",label:ea,note:"",matchNotes:a,items:s,unreachableNote:o}}function $p({resp:e}){const s=KS(e.request),a=JS(e.history);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"preview-box preview-box-ai","data-testid":"au10-request","data-request-status":s.state,children:[n.jsxs("h4",{children:["Request",s.tag&&n.jsx("span",{className:"src-tag src-tag-ai",children:s.tag})]}),s.state!=="ok"?n.jsx("p",{className:"au10-req-state",children:s.note}):n.jsxs(n.Fragment,{children:[s.implicitNote&&n.jsx("p",{className:"au10-req-meta",style:{marginTop:"-0.1rem"},children:s.implicitNote}),s.metaLine&&n.jsx("p",{className:"au10-req-meta",children:s.metaLine}),s.title&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("b",{children:s.title})}),s.bodyFirst&&n.jsx("p",{className:"au10-req-quote",children:s.bodyFirst}),s.bodyMore&&n.jsxs("details",{children:[n.jsx("summary",{children:"Show more"}),n.jsx("p",{className:"au10-req-quote",children:s.bodyMore})]}),s.attribution&&n.jsx("p",{className:"au10-req-attrib",children:s.attribution}),s.chain.length>0&&n.jsxs("details",{className:"au10-chain",children:[n.jsxs("summary",{children:["Earlier in this thread (",s.chain.length,")"]}),s.chain.map((o,l)=>n.jsxs("div",{className:"au10-chain-item",children:[(o.author||o.at)&&n.jsxs("p",{className:"au10-req-meta",children:[o.author?n.jsxs(n.Fragment,{children:["from ",n.jsx("b",{children:o.author})]}):null,o.author&&o.at?" · ":"",o.at]}),o.title&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("b",{children:o.title})}),o.body&&n.jsx("p",{className:"au10-req-quote",children:o.body}),o.author&&n.jsxs("p",{className:"au10-req-attrib",children:["— from ",o.author,", not checked"]})]},l))]})]})]}),n.jsxs("div",{className:`preview-box ${a.state==="unreachable"?"preview-box-unreachable":"preview-box-sys"}`,"data-testid":"au10-history","data-history-status":a.state,children:[n.jsxs("h4",{children:["History",n.jsx("span",{className:"src-tag src-tag-system",children:a.label})]}),a.state!=="ok"?n.jsx("p",{className:"au10-hist-state",children:a.note}):n.jsxs(n.Fragment,{children:[a.matchNotes.map((o,l)=>n.jsx("p",{className:"preview-note",style:{marginTop:0},children:o},l)),n.jsx("ul",{className:"au10-hist-list",children:a.items.map((o,l)=>n.jsxs("li",{className:"au10-hist-item",children:[n.jsxs("div",{className:"au10-hist-head",children:[n.jsxs("span",{children:[o.aiWritten&&n.jsx("span",{className:"au10-dot au10-dot-ai"}),o.headLabel]}),n.jsx("span",{children:o.at})]}),o.title&&n.jsx("div",{className:"au10-hist-title",children:o.title}),o.body&&n.jsx("div",{className:"au10-hist-body",children:o.body}),n.jsx("p",{className:"au10-hist-attrib",children:o.attribution})]},l))}),a.unreachableNote&&n.jsx("p",{className:"preview-note",children:a.unreachableNote})]})]})]})}function QS({proposalId:e,onData:s}){const[a,o]=h.useState(null),[l,u]=h.useState(!1);return h.useEffect(()=>{let f=!0;return o(null),u(!1),L.getProposalRequestContext(e).then(p=>{f&&o(p)}).catch(()=>{f&&u(!0)}),()=>{f=!1}},[e]),h.useEffect(()=>{s==null||s(l?null:a)},[a,l,s]),l||!a?null:n.jsx($p,{resp:a})}function XS(e,s,a){const o=Object.entries(e??{});if(o.length===0)return{entry:void 0,otherCount:0};const u=o.find(([,p])=>p.by===s)??(a?o.find(([p])=>p===`domain:${a}`):void 0),f=u?o.length-1:o.length;return{entry:u==null?void 0:u[1],otherCount:f}}function ZS(e){return e.offDevice?"off-device":e.recordedHash?e.localHash===e.recordedHash?"verified":"mismatch":"unchecked"}function eb(e){if(!(e<=0))return`${e} other approver${e===1?"":"s"} recorded their own.`}function tb(e){return new Date(e).toLocaleString([],{hour:"2-digit",minute:"2-digit"})}function _p({proposalId:e,tool:s,manifests:a}){const{user:o,domain:l}=xt(),[u,f]=h.useState(null),[p,g]=h.useState(null),[v,y]=h.useState(!1);if(h.useEffect(()=>{let P=!0;return f(null),g(null),y(!1),Promise.all([L.getShownSnapshot(e),L.getProposal(e)]).then(([I,B])=>{P&&(f(I),g(B))}).catch(()=>{P&&y(!0)}),()=>{P=!1}},[e]),v||!u||!p)return null;const x=u.status==="off_device",{entry:j,otherCount:k}=XS(p.shownHashes,(o==null?void 0:o.id)??"",l),b=ZS({offDevice:x,recordedHash:j==null?void 0:j.hash,localHash:u.status==="ok"?u.shownHash:void 0}),S=eb(k);if(x)return n.jsxs("div",{className:"ticket-box ticket-shown-off-device","data-testid":"au10-shown","data-shown-status":"off-device",children:[n.jsx("h4",{children:"What you saw"}),n.jsx("p",{className:"ticket-done-note",children:"Only on the approving gateway — this device has no local copy."})]});const{snapshot:N}=u,{integrationId:E}=Un(s),T=_r(E,a);return n.jsxs("div",{className:`ticket-box ticket-shown-${b}`,"data-testid":"au10-shown","data-shown-status":b,children:[n.jsxs("h4",{children:["What you saw (read ",tb(N.readAt),")",b==="verified"&&n.jsx("span",{className:"src-tag src-tag-sealed",children:"verified"}),b==="mismatch"&&n.jsx("span",{className:"src-tag src-tag-danger",children:"does not match what was approved"})]}),n.jsx(Pp,{resp:N.preview,systemName:T,toolArgs:N.toolArgs,sealed:N.sealed}),n.jsx($p,{resp:N.requestContext}),b==="verified"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-ok",children:"✓ Matches the fingerprint recorded with your approval."}),b==="mismatch"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-bad",children:"⚠ This copy differs from the fingerprint recorded with your approval."}),b==="unchecked"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-neutral",children:"This device's copy of what was shown, kept locally — the Authority Server does not record a fingerprint for you to check it against."}),S&&n.jsx("p",{className:"ticket-done-note ticket-done-note-neutral","data-testid":"au10-shown-others",children:S})]})}function ta({label:e,children:s}){return n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"receipt-row-label",children:e}),n.jsx("dd",{className:"receipt-row-value",children:s})]})}function nb({receipt:e,manifests:s,localAuth:a,localUnavailable:o,signature:l,grantTitle:u,ownerLabel:f,spUrl:p,formatDate:g,onOpenComplete:v,isNew:y=!1,defaultOpen:x=!1}){var ee;const j=ma(e.profileId),k=pw(e,j),b=gw(a==null?void 0:a.context,j),S=vw(e,(a==null?void 0:a.bounds)??e.limits,j),N=a==null?void 0:a.intent,E=Pr(e.profileId).testSetup||to(e.action),[T,P]=h.useState(!1),[I,B]=h.useState(x),O=Date.now(),K=$r(),z=Ir(e.profileId,K),U=l==="valid"||l==="valid-legacy";return n.jsxs("div",{className:`ticket-obj ticket-obj-card${y?" is-new":""}${I?" is-open":""}`,"data-new":y?"true":"false",children:[n.jsxs("div",{className:"ticket-obj-main",children:[n.jsxs("button",{type:"button",className:"ticket-obj-head","aria-expanded":I,onClick:()=>B(X=>!X),children:[n.jsx(cs,{profileId:e.profileId,area:z,system:pa(e.action,s),time:Di(e.timestamp,O),leading:y?n.jsx("span",{className:"seen-dot is-new","aria-label":"new since your last visit"}):void 0}),n.jsxs("div",{className:"receipt-head",children:[n.jsx("span",{className:"receipt-what","data-testid":"ticket-headline",children:n.jsx(mS,{ticketId:e.id,timestamp:e.timestamp,proposalId:e.proposalId,tool:e.action,manifests:s,label:ro(e,s)})}),n.jsx("span",{className:"receipt-tag",children:Oi(e)?"approved":"automatic"}),e.contentHash&&n.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(ee=e.contentBinding)!=null&&ee.fields?`Sealed in the ticket: ${e.contentBinding.fields.join(", ")} — exactly this content was sent`:"Sealed in the ticket — exactly this content was sent",children:"content sealed"}),E&&n.jsx("span",{className:"sim-mark",children:"Test setup"})]}),n.jsx(ca,{title:u,area:z}),k&&n.jsx("div",{className:"receipt-scope",children:k})]}),I&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"receipt-when",children:g(e.timestamp)}),n.jsx(Np,{receipt:e,manifests:s}),e.proposalId&&n.jsx(_p,{proposalId:e.proposalId,tool:e.action,manifests:s}),n.jsxs("dl",{className:"receipt-rows",children:[n.jsxs(ta,{label:"mandate",children:[n.jsx("strong",{children:u||ww(e.profileId)})," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),f&&n.jsx(ta,{label:"owner",children:f}),b&&n.jsxs(ta,{label:"allowed",children:[b," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),S&&n.jsxs(ta,{label:"used",children:[n.jsx("span",{className:"receipt-num",children:S})," ",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),n.jsx(ta,{label:"intent",children:N?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:`intent-text${T?"":" intent-clamped"}`,children:N}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>P(!T),children:T?"Show less":"Show full intent"})," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}):n.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"})})]}),n.jsxs("div",{className:"receipt-foot",children:[l==="valid"&&n.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"}),l==="valid-legacy"&&n.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"}),l==="invalid"&&n.jsx("span",{className:"receipt-tamper",title:"The stored ticket does not match what was signed.",children:"⚠ Signature check FAILED"}),n.jsx("button",{type:"button",className:"receipt-evidence-link",onClick:v,children:"Complete ticket"}),p&&n.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",n.jsx("a",{className:"receipt-link",href:`${p}/r/${e.id}`,target:"_blank",rel:"noreferrer",children:"public link ↗"})]})]}),n.jsxs("details",{className:"receipt-more",children:[n.jsx("summary",{children:"Raw"}),n.jsxs("div",{className:"receipt-kv",children:[n.jsxs("div",{children:["ticket · ",e.id]}),n.jsxs("div",{children:["action · ",e.action]}),n.jsxs("div",{children:["profile · ",e.profileId]}),e.authorizationId&&n.jsxs("div",{children:["mandate · ",e.authorizationId]}),Object.keys(e.executionContext??{}).length>0&&n.jsxs("div",{children:["scope ·"," ",Object.entries(e.executionContext).map(([X,F])=>`${X}=${F}`).join(" · ")]}),(a==null?void 0:a.boundsHash)&&n.jsxs("div",{children:["bounds hash · ",a.boundsHash]}),(a==null?void 0:a.contextHash)&&n.jsxs("div",{children:["scope hash · ",a.contextHash]}),e.contentHash&&n.jsxs("div",{children:["content · ",e.contentHash]}),e.proposalId&&n.jsxs("div",{children:["proposal · ",e.proposalId]}),n.jsxs("div",{children:["signature · ",e.signature]})]})]})]})]}),n.jsxs("div",{className:"ticket-obj-stub",children:[n.jsx("span",{className:"ticket-obj-no",title:e.id,children:Km(e.id)}),n.jsx("span",{className:"ticket-obj-time",children:Di(e.timestamp,O)}),U&&n.jsx("span",{className:"ticket-obj-sig",title:"Signature checked on this device",children:"✓ verified"})]})]})}function rb({receipt:e,onClose:s}){const[a,o]=h.useState(null),[l,u]=h.useState(null),[f,p]=h.useState(null),[g,v]=h.useState(!0),[y,x]=h.useState(!1);h.useEffect(()=>{let N=!1;return v(!0),L.getArchivedReceipt(e.id).then(E=>{N||(o(E),u(E?"local":"authority-server"),p((E==null?void 0:E.signature)??null))}).catch(()=>{N||u("authority-server")}).finally(()=>{N||v(!1)}),()=>{N=!0}},[e.id]);const j=a?a.entry:{receipt:e},k=JSON.stringify(j,null,2);function b(){const N=URL.createObjectURL(new Blob([k],{type:"application/json"})),E=document.createElement("a");E.href=N,E.download=`suveren-ticket-${e.id.slice(0,8)}.json`,E.click(),URL.revokeObjectURL(N)}async function S(){try{await navigator.clipboard.writeText(k),x(!0),setTimeout(()=>x(!1),2e3)}catch{x(!1)}}return n.jsx("div",{className:"modal-backdrop",onClick:N=>N.target===N.currentTarget&&s(),children:n.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:"Complete ticket"}),n.jsx("button",{className:"modal-close",onClick:s,"aria-label":"Close",children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[f==="valid"&&n.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."}),f==="valid-legacy"&&n.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."}),f==="invalid"&&n.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."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children:g?"Loading…":l==="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."}),n.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:k})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:b,children:"Download"}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:S,children:y?"Copied":"Copy"})]})]})})}function sb(e){return new Date(e*1e3).toLocaleString()}function ab(e,s){if(s==="all")return!0;const a=s==="1d"?1:s==="7d"?7:30,o=Math.floor(Date.now()/1e3)-a*86400;return e.timestamp>=o}function ib(e,s,a){const o=s.trim().toLowerCase();return o?[...a,e.id,e.action,e.profileId,JSON.stringify(e.executionContext??{})].some(u=>typeof u=="string"&&u.toLowerCase().includes(o)):!0}function zh(e,s){const a=new Map(e.map(o=>[o.id,o]));for(const o of s)a.set(o.id,o);return[...a.values()].sort((o,l)=>l.timestamp-o.timestamp)}function ob(){const{activeTeam:e,groupId:s}=xt(),a=(e==null?void 0:e.isAdmin)===!0,[o,l]=h.useState("mine"),[u,f]=ps(),p=Sw(u.get("filter")),g=W=>{const xe=new URLSearchParams(u);W==="all"?xe.delete("filter"):xe.set("filter",W),f(xe,{replace:!0})},v=Om(u.get("area")),y=W=>{const xe=new URLSearchParams(u);W===null?xe.delete("area"):xe.set("area",W),f(xe,{replace:!0})},x=$r(),[j,k]=h.useState(null),b=h.useRef(!1),[S,N]=h.useState([]),[E,T]=h.useState([]),[P,I]=h.useState(""),[B,O]=h.useState(!0),[K,z]=h.useState({}),[U,ee]=h.useState(new Set),[X,F]=h.useState(""),[ne,fe]=h.useState(new Set),[te,ge]=h.useState("all"),[ke,Z]=h.useState(!1),[Q,q]=h.useState(!1),[A,$]=h.useState(null),[ie,re]=h.useState({}),[H,oe]=h.useState(!1),[ue,pe]=h.useState({}),[ve,le]=h.useState({}),[Ge,Se]=h.useState(null),[Y,$e]=h.useState(null),[_e,Be]=h.useState(!1),[ze,it]=h.useState(!1),tt=h.useRef(""),Qe=h.useCallback(W=>o==="team"&&a&&s?L.listTeamReceiptsPage(s,{before:W,limit:200}):L.getMyReceiptsPage({before:W,limit:200}),[o,a,s]),Ye=h.useCallback(()=>{const W=o==="team"?`team:${s}`:"mine",xe=tt.current!==W;tt.current=W,O(!0),it(!1),Qe().then(Te=>{N(rt=>xe?Te.receipts:zh(rt,Te.receipts)),$e(rt=>xe?Te.nextBefore:rt??Te.nextBefore)}).catch(()=>{xe&&N([]),it(!0)}).finally(()=>O(!1))},[Qe,o,s]),jt=h.useCallback(()=>{!Y||_e||(Be(!0),it(!1),Qe(Y).then(W=>{N(xe=>zh(xe,W.receipts)),$e(W.nextBefore)}).catch(()=>it(!0)).finally(()=>Be(!1)))},[Y,_e,Qe]);Ft(Ye,12e4);const pt=h.useCallback(()=>{Ye(),j!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||L.markTicketsSeen(Date.now()).catch(()=>{}))},[Ye,j]);Fe("ticket-recorded",pt),h.useEffect(()=>{B||b.current||(b.current=!0,L.getLastSeenTicketsAt().then(W=>(k(W),L.markTicketsSeen(Date.now()))).catch(()=>k(Number.POSITIVE_INFINITY)))},[B]),h.useEffect(()=>{L.getLabelManifests().then(T).catch(()=>{}),fetch("/health").then(W=>W.json()).then(W=>{typeof W.spUrl=="string"&&I(W.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),h.useEffect(()=>{L.getLocalAuthorizations().then(({authorizations:W,signatures:xe})=>{re(W),pe(xe),oe(!1)}).catch(()=>{re({}),pe({}),oe(!0)}),L.getMyAttestations().then(W=>{const xe={};for(const Te of W)Te.authorization_id&&Te.title&&(xe[Te.authorization_id]=Te.title);le(xe)}).catch(()=>{})},[]),h.useEffect(()=>{o!=="team"||Object.keys(K).length>0||L.listUsers().then(W=>{const xe={};for(const Te of W)xe[Te.id]={name:Te.name,email:Te.email};z(xe)}).catch(()=>{})},[o,K]);const Me=h.useMemo(()=>{const W=new Set;for(const xe of S)W.add(xe.action);return[...W].sort()},[S]),me=h.useMemo(()=>{if(o!=="team")return[];const W=new Set;for(const xe of S)xe.userId&&W.add(xe.userId);return[...W].map(xe=>{var Te;return{id:xe,label:(Te=K[xe])!=null&&Te.name?`${K[xe].name} (${K[xe].email})`:xe}}).sort((xe,Te)=>xe.label.localeCompare(Te.label))},[o,S,K]),Ae=h.useMemo(()=>S.filter(W=>!(!ib(W,X,[Bn(W.profileId,x),ro(W,E),_r(Un(W.action).integrationId,E),W.authorizationId?ve[W.authorizationId]:null])||ne.size>0&&!ne.has(W.action)||U.size>0&&W.userId&&!U.has(W.userId)||!ab(W,te))),[S,X,x,E,ve,ne,U,te]),Oe=h.useMemo(()=>{const W={automatic:0,approved:0,all:0};for(const xe of Ae)W.all+=1,W[pc(xe,"approved")?"approved":"automatic"]+=1;return W},[Ae]),G=h.useMemo(()=>Ae.filter(W=>pc(W,p)),[Ae,p]),J=h.useMemo(()=>{const W=new Map;for(const xe of G){const Te=In(xe.profileId),rt=W.get(Te);rt?rt.count+=1:W.set(Te,{shortId:Te,icon:Ar(xe.profileId),name:Bn(xe.profileId,x),count:1})}return[...W.values()].sort((xe,Te)=>xe.name.localeCompare(Te.name))},[G,x]),ye=h.useMemo(()=>G.filter(W=>Bm(W.profileId,v)),[G,v]),Ue=h.useMemo(()=>j===null?0:ye.filter(W=>Bi(W,j)).length,[ye,j]),We=ne.size>0||U.size>0||te!=="all";function nt(W){fe(xe=>{const Te=new Set(xe);return Te.has(W)?Te.delete(W):Te.add(W),Te})}function Ht(W){ee(xe=>{const Te=new Set(xe);return Te.has(W)?Te.delete(W):Te.add(W),Te})}function Ot(){fe(new Set),ee(new Set),ge("all"),F("")}async function Ze(){q(!0),$(null);try{const{bundle:W,filename:xe}=await L.fetchEvidenceBundle(),Te=URL.createObjectURL(new Blob([JSON.stringify(W,null,2)],{type:"application/json"})),rt=document.createElement("a");rt.href=Te,rt.download=xe,rt.click(),URL.revokeObjectURL(Te);const gt=W.sources??{};gt.authorityServer?gt.local||$(`Downloaded Authority Server history only — ${gt.localError??"local archive unavailable."}`):$(`Downloaded local evidence only — ${gt.asError??"Authority Server export unavailable."}`)}catch(W){$(`Export failed: ${W instanceof Error?W.message:String(W)}`)}finally{q(!1)}}return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Tickets"}),n.jsxs("p",{className:"page-subtitle",children:["Execution history for agent actions.",Ue>0&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("b",{"data-testid":"tickets-new-count",children:[Ue," new since your last visit"]})]})]})]}),n.jsx("button",{className:"btn btn-secondary",onClick:Ze,disabled:Q,children:Q?"Preparing…":"Download evidence"})]}),A&&n.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:A}),a&&n.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(W=>n.jsx("button",{onClick:()=>l(W),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:o===W?"2px solid var(--accent)":"2px solid transparent",color:o===W?"var(--text-primary)":"var(--text-tertiary)",fontWeight:o===W?600:500},children:W==="mine"?"Mine":"Team"},W))}),n.jsxs("div",{className:"tickets-toolbar",children:[n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which tickets",children:jw.map(W=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`tickets-filter-${W}`,"aria-selected":p===W,onClick:()=>g(W),children:[W==="automatic"?"Automatic":W==="approved"?"Approved":"All",n.jsx("span",{className:"n",children:Oe[W]})]},W))}),n.jsxs("div",{className:"search-filter-bar",children:[n.jsxs("div",{className:"search-input-wrap",children:[n.jsx("span",{className:"search-icon",children:"⌕"}),n.jsx("input",{type:"text",className:"form-input search-input","data-testid":"tickets-search",placeholder:"Search tickets","aria-label":"Search tickets",value:X,onChange:W=>F(W.target.value)}),X&&n.jsx("button",{className:"search-clear",onClick:()=>F(""),children:"×"})]}),n.jsxs("button",{className:`btn btn-sm btn-secondary${ke?" active":""}`,onClick:()=>Z(!ke),children:["Filters",We?` (${ne.size+(te!=="all"?1:0)})`:""]})]})]}),p==="automatic"&&n.jsx("p",{className:"page-subtitle",style:{marginTop:"-0.25rem"},children:'Automatic — no person approved these. Approved tickets are under "Approved".'}),n.jsx(Jc,{areas:J,selected:v,onSelect:y,totalCount:G.length}),ke&&n.jsxs("div",{className:"filter-panel",children:[Me.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Action"}),n.jsx("div",{className:"filter-chips",children:Me.map(W=>n.jsx("button",{className:`filter-chip${ne.has(W)?" selected":""}`,onClick:()=>nt(W),children:W},W))})]}),o==="team"&&me.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Owner"}),n.jsx("div",{className:"filter-chips",children:me.map(W=>n.jsx("button",{className:`filter-chip${U.has(W.id)?" selected":""}`,onClick:()=>Ht(W.id),children:W.label},W.id))})]}),n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Time range"}),n.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([W,xe])=>n.jsx("button",{className:`filter-chip${te===W?" selected":""}`,onClick:()=>ge(W),children:xe},W))})]})]}),We&&n.jsxs("div",{className:"active-filters",children:[[...ne].map(W=>n.jsxs("span",{className:"active-chip",onClick:()=>nt(W),children:[W," ",n.jsx("span",{className:"chip-remove",children:"×"})]},W)),[...U].map(W=>{const xe=K[W],Te=xe?xe.name:W;return n.jsxs("span",{className:"active-chip",onClick:()=>Ht(W),children:[Te," ",n.jsx("span",{className:"chip-remove",children:"×"})]},W)}),te!=="all"&&n.jsxs("span",{className:"active-chip",onClick:()=>ge("all"),children:[te==="1d"?"Today":te==="7d"?"7 days":"30 days"," ",n.jsx("span",{className:"chip-remove",children:"×"})]}),n.jsx("button",{className:"clear-filters",onClick:Ot,children:"Clear all"})]}),ze&&n.jsx("div",{className:"card note-stopped",style:{marginBottom:"0.75rem"},children:n.jsx("span",{className:"msg-error",style:{fontSize:"0.85rem"},children:"Couldn’t load tickets — your session may have expired. Try signing out and back in."})}),B&&S.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ye.length===0?n.jsx(ds,{icon:"⌕",title:S.length===0?"No tickets in the last 30 days":"No matching tickets",text:S.length===0?"Tickets appear here after an agent uses an authorized tool. Older tickets can be loaded below.":"Try adjusting your search or filters."}):n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:ye.length===S.length?`${S.length} ticket${S.length!==1?"s":""}`:`${ye.length} of ${S.length} tickets`}),n.jsx("div",{className:"timeline",children:ye.map(W=>{const xe=W.userId?K[W.userId]:void 0;return n.jsx("div",{className:"timeline-event",children:n.jsx(nb,{receipt:W,manifests:E,localAuth:W.authorizationId?ie[W.authorizationId]:void 0,localUnavailable:H,signature:ue[W.id],grantTitle:W.authorizationId?ve[W.authorizationId]:null,ownerLabel:o==="team"&&W.userId?xe?`${xe.name} (${xe.email})`:W.userId:null,spUrl:P,formatDate:sb,onOpenComplete:()=>Se(W),isNew:j!==null&&Bi(W,j),defaultOpen:ye.length===1})},W.id)})})]}),Ge&&n.jsx(rb,{receipt:Ge,onClose:()=>Se(null)}),Y&&n.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:jt,disabled:_e,children:_e?"Loading…":"Load older"})})]})}function lb(){const[e,s]=h.useState(null),[a,o]=h.useState({}),[l,u]=h.useState(!1),f=$r(),[p,g]=ps(),v=Om(p.get("area")),y=h.useCallback(O=>{const K=new URLSearchParams(p);O===null?K.delete("area"):K.set("area",O),g(K,{replace:!0})},[p,g]),[x,j]=h.useState({}),k=h.useCallback(()=>{L.getMyAttestations().then(O=>{const K={};for(const z of O)z.title&&(K[z.authorization_id]=z.title);j(K)}).catch(()=>{})},[]);h.useEffect(()=>{k()},[k]),Ft(k,3e5);const[b,S]=h.useState(null),N=h.useRef(!1),E=h.useCallback(()=>{L.getDenials({limit:200}).then(({records:O})=>{s(O),u(!1)}).catch(()=>u(!0))},[]);h.useEffect(()=>{E()},[E]),Ft(E,6e4),h.useEffect(()=>{if(!e)return;const O=[...new Set(e.map(K=>K.profile).filter(K=>!!K))].filter(K=>!(K in a));O.length!==0&&Promise.all(O.map(K=>L.getProfile(K).catch(()=>null))).then(K=>{o(z=>{const U={...z};return O.forEach((ee,X)=>{K[X]&&(U[ee]=K[X])}),U})})},[e,a]),h.useEffect(()=>{!e||N.current||(N.current=!0,L.getLastSeenBlockedAt().then(O=>(S(O),L.markBlockedSeen(Date.now()))).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[e]);const T=h.useCallback(()=>{E(),k(),b!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||L.markBlockedSeen(Date.now()).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[E,k,b]);Fe("denial-recorded",T);const P=h.useMemo(()=>{const O=new Map;for(const K of e??[]){const z=K.profile??K.integrationId,U=In(z),ee=O.get(U);ee?ee.count+=1:O.set(U,{shortId:U,icon:Ar(z),name:Bn(z,f),count:1})}return[...O.values()].sort((K,z)=>K.name.localeCompare(z.name))},[e,f]);if(l)return n.jsx(ds,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(e===null)return null;const I=d0(e,Date.now()),B=e.filter(O=>Bm(O.profile??O.integrationId,v));return n.jsxs("div",{className:"blocked-page",children:[n.jsxs("div",{className:"page-header blocked-header",children:[n.jsx("h1",{className:"page-title",children:"Blocked actions"}),n.jsxs("span",{className:"blocked-today",children:[I," today · nothing ran"]})]}),e.length===0?n.jsx(ds,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):n.jsxs(n.Fragment,{children:[n.jsx(Jc,{areas:P,selected:v,onSelect:y,totalCount:e.length}),n.jsx("div",{className:"blocked-list",children:B.map((O,K)=>{const z=u0(O,O.profile?a[O.profile]:void 0,x),U=b!==null&&O.ts>b,ee=O.profile??O.integrationId;return n.jsx("div",{className:"card blocked-item blocked-card","data-seen":U?"false":"true",children:n.jsxs("div",{className:"id-body",children:[n.jsx(cs,{profileId:ee,area:Bn(ee,f),system:O.integrationId?_r(O.integrationId,void 0):void 0,time:m0(O.ts,Date.now()),trailing:U?n.jsx("span",{className:"new-pill",children:"New"}):void 0}),n.jsxs("div",{className:"blocked-row-head",children:[n.jsx("span",{className:`blocked-dot blocked-dot-${eo(O)}`,"aria-hidden":"true"}),n.jsx("span",{className:"blocked-title",children:z.title})]}),n.jsx(ca,{title:Nm(O,x),area:Bn(ee,f)}),n.jsx("div",{className:"blocked-sentence",children:z.sentence}),n.jsx("div",{className:"blocked-source",children:z.sourceLine.map((X,F)=>X.dim?n.jsx("span",{className:"mandate-id",children:X.text},F):n.jsx("span",{children:X.text},F))}),n.jsxs("details",{children:[n.jsx("summary",{children:"What you can do"}),n.jsx("div",{className:"blocked-advice",children:z.whatYouCanDo})]})]})},`${O.ts}-${K}`)})})]})]})}const cb={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function ub(){const[e,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{s(await L.getAutostart())}catch(v){u(v instanceof Error?v.message:"Could not read autostart state")}},[]);h.useEffect(()=>{f()},[f]);const p=h.useCallback(async()=>{if(!(!(e!=null&&e.supported)||a)){o(!0),u(null);try{await L.setAutostart(!e.installed)}catch(v){u(v instanceof Error?v.message:"Failed")}finally{try{s(await L.getAutostart()),u(null)}catch(v){u(v instanceof Error?v.message:"Could not re-read state")}o(!1)}}},[e,a,f]);if(!e)return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),n.jsx("p",{role:l?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:l?`Could not read autostart state: ${l}`:"Checking…"})]});const g=cb[e.platform]??"a login service";return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),n.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:e.supported?n.jsxs(n.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",g," — no admin rights needed."]}):e.reason})]}),e.supported&&n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e.installed,className:e.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Working…":e.installed?"Turn off":"Turn on"})]}),e.supported&&n.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",n.jsx("strong",{children:e.installed?"On — starts from your next login":"Off"})]}),e.supported&&n.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 ",n.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}function db(){const[e,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{const g=await L.getGatewaySettings();s(g.desktopNotifications),u(null)}catch(g){u(g instanceof Error?g.message:"Could not read notification setting")}},[]);h.useEffect(()=>{f()},[f]);const p=h.useCallback(async()=>{if(!(e===null||a)){o(!0),u(null);try{const g=await L.setGatewaySettings({desktopNotifications:!e});s(g.desktopNotifications)}catch(g){u(g instanceof Error?g.message:"Failed to save"),await f()}finally{o(!1)}}},[e,a,f]);return e===null?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),n.jsx("p",{role:l?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:l?`Could not read the setting: ${l}`:"Checking…"})]}):n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),n.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."})]}),n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e,className:e?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":e?"Turn off":"Turn on"})]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}const Fh={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function fb(){const[e,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{s(await L.getIdentityDisclosure()),u(null)}catch(y){u(y instanceof Error?y.message:"Could not read the setting")}},[]);h.useEffect(()=>{f()},[f]);const p=h.useCallback(async()=>{if(!(!e||a)){o(!0),u(null);try{s(await L.setIdentityDisclosure(!e.always))}catch(y){u(y instanceof Error?y.message:"Failed to save"),await f()}finally{o(!1)}}},[e,a,f]),g=n.jsx("h3",{className:"card-title",style:{margin:0},children:"Your name on mandates and tickets"});if(!e)return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[g,n.jsx("p",{role:l?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:l?`Could not read the setting: ${l}`:"Checking…"})]});const v=e.verified&&e.name?`${e.name} — ${e.method==="as_vouched"?`${Fh.as_vouched} ${e.verifier}`:Fh[e.method??""]??e.method}`:null;return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[g,n.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:[e.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."]}),n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:v?`Your identity: ${v}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e.always,className:e.always?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":e.always?"Turn off":"Always show my name"})]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}const hb={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 mb(){const{version:e,latestVersion:s,updateAvailable:a,installMethod:o}=Lc();return e?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Version"}),n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:["Running ",n.jsx("strong",{children:e}),a&&s?n.jsxs(n.Fragment,{children:[" — ",n.jsx("strong",{children:s})," is available"]}):null]}),n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:[hb[o]??"Update checking is unavailable",o==="dev"&&n.jsx(n.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function Sc({title:e}){return n.jsxs("span",{className:"it-locked-badge",title:e,children:[n.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function Mh(e){return e===!0}function pb(){const[e,s]=h.useState(null),[a,o]=h.useState(null);h.useEffect(()=>{let f=!1;return L.getAsPairing().then(p=>{f||s(p)}).catch(p=>{f||o(p instanceof Error?p.message:"Could not read Authority Server info")}),()=>{f=!0}},[]);const l=Mh(e==null?void 0:e.asUrlLockedByPolicy),u=Mh(e==null?void 0:e.pinTlsLockedByPolicy);return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Authority Server"}),l&&n.jsx(Sc,{})]}),!e&&!a&&n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Checking…"}),a&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.5rem 0 0",fontSize:"0.9rem"},children:a}),e&&n.jsxs(n.Fragment,{children:[n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"URL:"})," ",n.jsx("code",{children:e.asUrl})]}),e.paired&&e.fingerprint?n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"Key fingerprint:"})," ",n.jsx("code",{children:e.fingerprint}),n.jsx("br",{}),n.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."})]}):n.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."}),(e.tlsPinFingerprint||e.pinTlsEnabled)&&n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"TLS certificate pin:"})," ",u&&n.jsx(Sc,{title:"TLS pinning is set by your IT policy"})," ",e.tlsPinFingerprint?n.jsx("code",{children:e.tlsPinFingerprint}):n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["not yet captured — this URL has no recorded pairing over TLS",e.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]}),n.jsx("br",{}),n.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[e.pinTlsEnabled?n.jsxs(n.Fragment,{children:["TLS pinning is ON",u?n.jsx(n.Fragment,{children:", set by your organization's IT policy"}):n.jsxs(n.Fragment,{children:[" (",n.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."]}):n.jsxs(n.Fragment,{children:["Captured at sign-in; not currently enforced",u?n.jsx(n.Fragment,{children:" — controlled by your organization's IT policy on this computer"}):n.jsxs(n.Fragment,{children:[" (",n.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."]})]}),l?n.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."}):n.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:"," ",n.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 gb(){const{simulation:e,locked:s}=Fm();return s?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Simulation mode"}),n.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.',e!==null&&n.jsxs(n.Fragment,{children:[" ","Currently ",n.jsx("strong",{children:e?"ON":"OFF"}),e?" — real systems are not reachable from this gateway.":"."]})]})]}),n.jsx(Sc,{})]}),n.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",e!==null?` (currently ${e?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const yb={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"]}},na=["AI Assistant","Authority Server","This computer","Security","Version"],ra={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function vb(){const[e,s]=h.useState(""),[a,o]=h.useState("openrouter"),[l,u]=h.useState("openai-compatible"),[f,p]=h.useState("https://openrouter.ai/api/v1"),[g,v]=h.useState("google/gemma-4-31b-it"),[y,x]=h.useState(""),[j,k]=h.useState(!1),[b,S]=h.useState(!1),[N,E]=h.useState(!1),[T,P]=h.useState(null),[I,B]=h.useState([]),[O,K]=h.useState(!1),[z,U]=h.useState(null),[ee,X]=h.useState(""),F=h.useCallback(Q=>{s(Q),setTimeout(()=>s(""),3e3)},[]),ne=h.useCallback(async(Q,q,A)=>{K(!0),U(null);try{const $=await L.aiModels({provider:Q,endpoint:q,...A?{apiKey:A}:{}});$.ok&&$.models.length>0?(B($.models),U(`${$.models.length} models available`)):(B([]),U($.message||"No models returned — using defaults"))}catch($){B([]),U($ instanceof Error?$.message:"Failed to load models")}finally{K(!1)}},[]),fe=h.useCallback(async()=>{try{const Q=await L.getCredential("ai-config");if(k(Q.configured),Q.configured&&Q.fields){const q=Q.fields.provider||"openai-compatible",A=Q.fields.endpoint||"";Q.fields.provider&&u(q),Q.fields.endpoint&&p(A),Q.fields.model&&v(Q.fields.model),A.includes("openai.com")?o("openai"):A.includes("groq.com")?o("groq"):A.includes("together.xyz")?o("together"):A.includes("openrouter.ai")?o("openrouter"):o("ollama"),A&&ne(q,A)}}catch{}},[ne]);h.useEffect(()=>{fe()},[fe]);const te=Q=>{o(Q),B([]),U(null),X("");const q=yb[Q];q&&(u(q.provider),p(q.endpoint),v(""),ne(q.provider,q.endpoint,y||void 0))},ge=()=>ne(l,f,y||void 0),ke=async()=>{S(!0);try{await L.setCredential("ai-config",{provider:l,endpoint:f,model:g,...y?{apiKey:y}:{}}),k(!0),F("AI configuration saved!")}catch{F("Failed to save AI config")}finally{S(!1)}},Z=async()=>{E(!0),P(null);try{const Q=await L.aiTest({provider:l,endpoint:f,model:g,...y?{apiKey:y}:{}});P(Q.ok?`OK: ${Q.message}`:`Failed: ${Q.message}`)}catch(Q){P(`Error: ${Q instanceof Error?Q.message:"Unknown"}`)}finally{E(!1)}};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Settings"}),n.jsx("p",{className:"page-subtitle",children:"Your AI assistant, the connection to your Authority Server, security and version."})]}),e&&n.jsx("div",{className:"alert alert-success",children:e}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:ra,children:na[0]}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Advisory AI to help you think through intent when giving mandates."}),n.jsxs("div",{className:"card",children:[n.jsx("h3",{className:"card-title",children:"Configuration"}),n.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."}),j&&n.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[n.jsx("span",{className:"status-banner-icon",children:"✓"}),n.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{className:"form-label",children:"Provider Preset"}),n.jsxs("select",{className:"form-input",value:a,onChange:Q=>te(Q.target.value),children:[n.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),n.jsx("option",{value:"ollama",children:"Ollama (local)"}),n.jsx("option",{value:"openai",children:"OpenAI"}),n.jsx("option",{value:"groq",children:"Groq"}),n.jsx("option",{value:"together",children:"Together"})]})]}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsxs("label",{className:"form-label",children:["API Key ",l==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),n.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:y,onChange:Q=>x(Q.target.value),onBlur:()=>{y.trim()&&ne(l,f,y.trim())},placeholder:j?"••••••••••••••••":"sk-... (not needed for Ollama)"}),n.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."})]}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsx("label",{className:"form-label",children:"Model"}),n.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.75rem",padding:"0.125rem 0.5rem"},onClick:ge,disabled:O,title:"Re-fetch the model list from the provider",children:O?"Loading…":"↻ Refresh"})]}),I.length===0?n.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:O?"Loading models…":l==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const Q=I,q=Q.includes(g),A=Q.length>12,$=ee.trim().toLowerCase();let ie=$?Q.filter(re=>re.toLowerCase().includes($)):Q;return q&&!ie.includes(g)&&(ie=[g,...ie]),n.jsxs(n.Fragment,{children:[A&&n.jsx("input",{className:"form-input",value:ee,onChange:re=>X(re.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),n.jsxs("select",{className:"form-input",value:q?g:"__unset__",onChange:re=>v(re.target.value==="__unset__"?"":re.target.value),children:[n.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),ie.map(re=>n.jsx("option",{value:re,children:re},re)),$&&ie.length===0&&n.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",ee,"”"]})]})]})})(),z&&n.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:z})]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[n.jsx("button",{className:"btn btn-primary",onClick:ke,disabled:b||!g.trim(),title:g.trim()?void 0:"Select a model first",children:b?"Saving...":"Save & Encrypt"}),j&&n.jsx("button",{className:"btn btn-ghost",onClick:Z,disabled:N,children:N?"Testing...":"Test Connection"})]}),T&&n.jsx("div",{className:`alert ${T.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:T})]}),n.jsx(xb,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:ra,children:na[1]}),n.jsx(pb,{}),n.jsx(fb,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:ra,children:na[2]}),n.jsx(ub,{}),n.jsx(db,{}),n.jsx(gb,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:ra,children:na[3]}),n.jsx("div",{className:"card",style:{padding:"1.5rem"},children:n.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),n.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[n.jsx("li",{children:"Every tool call verified against your mandate bounds"}),n.jsx("li",{children:"Credentials never exposed to agents through MCP"}),n.jsx("li",{children:"Every action produces a signed ticket"})]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),n.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[n.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),n.jsx("li",{children:"For best security, run agents in sandboxed environments"}),n.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})})]}),n.jsxs("section",{children:[n.jsx("h2",{style:ra,children:na[4]}),n.jsx(mb,{})]})]})}function xb(){const[e,s]=h.useState(null),[a,o]=h.useState({intent:"",context:""}),[l,u]=h.useState(null),[f,p]=h.useState(null),[g,v]=h.useState(null),[y,x]=h.useState(!1),j=h.useCallback(async()=>{if(!y)try{const S=await L.getAIPrompts();s(S),o({intent:S.intent.current,context:S.context.current}),x(!0)}catch(S){p(S instanceof Error?S.message:"Failed to load prompts")}},[y]),k=async S=>{if(e){u(S),p(null);try{const N=a[S],E=N.trim()===e[S].default.trim()?"":N;await L.setAIPrompt(S,E);const T=await L.getAIPrompts();s(T),o({intent:T.intent.current,context:T.context.current}),v(S),setTimeout(()=>v(null),2e3)}catch(N){p(N instanceof Error?N.message:"Save failed")}finally{u(null)}}},b=async S=>{if(confirm(`Revert ${S} prompt to the built-in default?`)){u(S),p(null);try{await L.setAIPrompt(S,"");const N=await L.getAIPrompts();s(N),o({intent:N.intent.current,context:N.context.current})}catch(N){p(N instanceof Error?N.message:"Revert failed")}finally{u(null)}}};return n.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:S=>{S.currentTarget.open&&j()},children:[n.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),n.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."}),f&&n.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:f}),!y&&!f&&n.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),e&&n.jsxs(n.Fragment,{children:[n.jsx(Oh,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:e.intent,draft:a.intent,onChange:S=>o(N=>({...N,intent:S})),onSave:()=>k("intent"),onRevert:()=>b("intent"),saving:l==="intent",justSaved:g==="intent"}),n.jsx(Oh,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:e.context,draft:a.context,onChange:S=>o(N=>({...N,context:S})),onSave:()=>k("context"),onRevert:()=>b("context"),saving:l==="context",justSaved:g==="context"})]})]})}function Oh({kind:e,label:s,description:a,state:o,draft:l,onChange:u,onSave:f,onRevert:p,saving:g,justSaved:v}){const y=l!==o.current;return n.jsxs("section",{style:{marginBottom:"1.5rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:s}),n.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:a})]}),o.overridden&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),n.jsx("textarea",{className:"form-textarea",value:l,onChange:x=>u(x.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`}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:f,disabled:g||!y,children:g?"Saving…":"Save"}),o.overridden&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:p,disabled:g,title:"Discard the override and use the built-in default",children:"Revert to default"}),v&&n.jsx("span",{className:"msg-ok",style:{fontSize:"0.78rem"},children:"Saved"}),y&&!g&&!v&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),n.jsxs("details",{style:{marginTop:"0.5rem"},children:[n.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),n.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})]}),n.jsx("span",{style:{display:"none"},children:e})]})}function wb(e){return e.proposalId?"review":"automatic"}function Bh(e,s,a={}){const o=a.status??"pending",l=a.includeAutonomous??!1,u=[];for(const f of e)o==="pending"&&f.status!=="pending"||a.profile&&f.profileId!==a.profile||u.push({kind:"proposal",id:f.id,sortTimestamp:f.createdAt,commitmentMode:"review",profileId:f.profileId,proposal:f});if(o==="all")for(const f of s){const p=wb(f);!l&&p==="automatic"||a.profile&&f.profileId!==a.profile||u.push({kind:"receipt",id:f.id,sortTimestamp:f.timestamp,commitmentMode:p,profileId:f.profileId,receipt:f})}return u.sort((f,p)=>p.sortTimestamp-f.sortTimestamp),typeof a.limit=="number"&&a.limit>0?u.slice(0,a.limit):u}const jb=["https://","http://"];function Lp(e,s){return e!=null&&e.length?e.flatMap(a=>{const o=a.template.replace(/\{(\w+)\}/g,(l,u)=>{const f=s[u];return typeof f=="string"||typeof f=="number"?String(f):"\0"});return o.includes("\0")||/\{|\}/.test(o)?[]:jb.some(l=>o.toLowerCase().startsWith(l))?[{label:a.label,href:o,description:a.description}]:[]}):[]}function zp(e,s){const a=e-Math.floor(s/1e3);if(a<=0)return{label:"expired",urgent:!1,expired:!0};const o=Math.floor(a/86400),l=Math.floor(a%86400/3600),u=Math.floor(a%3600/60);let f;return o>0?f=`expires in ${o}d ${l}h`:l>0?f=`expires in ${l}h ${u}m`:f=`expires in ${Math.max(1,u)}m`,{label:f,urgent:a<2*3600,expired:!1}}function Qc({profileId:e,declared:s}){const{icon:a}=Pr(e,s),o=uw(e);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"id-rail",children:[n.jsx(gp,{icon:a,className:"id-rail-icon"}),n.jsx("span",{className:"id-rail-name",children:o})]}),n.jsx("div",{className:"id-sep"})]})}function Sb({proposalId:e,systemName:s}){const[a,o]=h.useState(null);if(h.useEffect(()=>{let u=!0;return o(null),L.getProposalOutcome(e).then(f=>{u&&o(f)}).catch(()=>{}),()=>{u=!1}},[e]),!a)return null;const l=MS(a,s);return l?n.jsxs("div",{className:"outcome-box",children:[n.jsx("h4",{children:l.heading}),n.jsx("p",{className:"outcome-note",children:l.note})]}):null}let ac=null;function bb(){return ac||(ac=L.getEnrichedAuthorizations().then(e=>new Map(e.map(s=>[s.authorizationId,s.bounds]))).catch(()=>new Map)),ac}function kb(e){const[s,a]=h.useState(void 0);return h.useEffect(()=>{let o=!0;if(e)return bb().then(l=>{o&&a(l.get(e))}),()=>{o=!1}},[e]),s}function Nb(e,s){const[a,o]=h.useState(null),[l,u]=h.useState(!1),[f,p]=h.useState(null);return h.useEffect(()=>{let g=!0;return o(null),p(null),u(!0),(async()=>{var v;try{try{const j=await L.getGateContent(e);if((v=j==null?void 0:j.gateContent)!=null&&v.intent){g&&o(j.gateContent.intent);return}}catch{}const y=await L.getAttestationIntent(e);if(!y){g&&p("Intent not available or you are not an authorized approver.");return}const x=await L.decryptIntent({intentCiphertext:y.intentCiphertext,encryptedKey:y.encryptedKey,approverId:s});g&&o(x)}catch(y){g&&p(y instanceof Error?y.message:"Failed to decrypt intent")}finally{g&&u(!1)}})(),()=>{g=!1}},[e,s]),{intent:a,loading:l,error:f}}function Dh(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const s={};for(const[a,o]of Object.entries(e))(typeof o=="string"||typeof o=="number")&&(s[a]=o);return s}function Cb(e){const s=Dh(e.limits),a=Dh(e.scope),o=typeof e.intent=="string"?e.intent:"",l={bounds:s,context:a,gateContent:{intent:o}};return(e.mode==="automatic"||e.mode==="review")&&(l.templateMode=e.mode),typeof e.duration_hours=="number"&&e.duration_hours>0&&(l.templateTtl=Math.round(e.duration_hours*3600)),l}function Fp(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(s=>Fp(s)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}const Eb="setup__create_mandate";function Mp({proposal:e,currentUserId:s,proposalLinks:a,toolDisplay:o,manifests:l,onContentState:u,onShownSnapshot:f,nameOf:p}){var pe,ve,le,Ge,Se;const[g,v]=h.useState(!1),[y,x]=h.useState(!1),[j,k]=h.useState(null),b=Sn(),{group:S,groupId:N,domain:E}=xt(),T=Object.entries(e.executionContext),P=ma(e.profileId),I=kb(e.authorizationId),B=xw(e.executionContext,I,P),O=dw(e.tool),{integrationId:K}=Un(e.tool),z=_r(K,l),{intent:U,loading:ee,error:X}=Nb(e.authorizationId,s),F=so(e),ne=F.toolArgs!==null;h.useEffect(()=>{u==null||u({loading:F.loading,readable:ne})},[F.loading,ne]);const fe=Iw(e),te=F.toolArgs?Lp(a,F.toolArgs):[],ge=async()=>{if(!N){k("No active workspace; cannot open the mandate screen.");return}x(!0),k(null);try{if(!F.toolArgs){k("This content is not readable on this device yet.");return}const Y=F.toolArgs,$e=typeof Y.profile=="string"?Y.profile:"",_e=await L.listProfiles(),Be=yp($e,_e);if(!Be){k(`Unknown profile "${$e}".`);return}const ze=await L.getProfile(Be.id),it=Cb(Y),tt=xp(it.bounds,ze),Qe=wp(it.context,ze);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Be.id,groupId:N,groupName:(S==null?void 0:S.name)??null,domain:E,isPersonal:!!(S!=null&&S.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...it,bounds:tt,context:Qe})),sessionStorage.setItem("agentReplacesProposal",e.id),b("/mandates/new/intent")}catch(Y){k(Y instanceof Error?Y.message:"Could not open the mandate screen.")}finally{x(!1)}},[ke,Z]=h.useState(null),Q=OS(ke),[q,A]=h.useState(null),[$,ie]=h.useState(null);h.useEffect(()=>{if(!q||!$){f==null||f(null);return}const Y=q.status==="ok"?q.readAt:Date.now();f==null||f({readAt:Y,preview:q,requestContext:$,...F.toolArgs?{toolArgs:F.toolArgs}:{},sealed:F.sealed})},[q,$,F.toolArgs,F.sealed,f]);const{toolName:re}=Un(e.tool),H=(Se=(Ge=(le=(ve=(pe=l==null?void 0:l.find(Y=>Y.id===K))==null?void 0:pe.toolGating)==null?void 0:ve.overrides)==null?void 0:le[re])==null?void 0:Ge.sourceFromArg)==null?void 0:Se.arg,oe=F.toolArgs?n.jsx(xc,{args:F.toolArgs,display:o,heading:"",requestRefArg:H}):null,ue=F.toolArgs?n.jsxs(n.Fragment,{children:[n.jsx(xc,{args:F.toolArgs,display:o,heading:"",requestRefArg:H}),T.length>0&&n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:T.map(([Y,$e],_e)=>{const{label:Be,hint:ze}=hw(Y,P);return n.jsxs("span",{children:[_e>0&&" · ",n.jsxs("span",{title:ze,children:[Be,"=",Fp($e)]})]},Y)})})]}):null;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"approval-summary","data-testid":"approval-summary",children:tp(e.tool,F.toolArgs,l)}),n.jsx("div",{className:"approval-headline",children:O}),F.sealed&&F.undecryptable&&n.jsxs("div",{className:"preview-box","data-testid":"proposal-undecryptable",style:{marginBottom:"0.5rem"},children:[n.jsx("strong",{children:"Encrypted for another device."}),n.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."})]}),F.sealed&&F.loading&&n.jsx("div",{className:"preview-box","data-testid":"proposal-decrypting",style:{marginBottom:"0.5rem"},children:"Decrypting…"}),Q&&ne&&n.jsxs("div",{className:"preview-box preview-box-ok","data-testid":"bound-values-open",style:{marginBottom:"0.5rem"},children:[n.jsxs("h4",{children:["What will be sent",F.sealed?n.jsx(n.Fragment,{children:n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})}):n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),oe]}),fe.length>0&&n.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: ",fe.map(Y=>(p==null?void 0:p(Y))??Y).join(", ")," — shared automatically once they sign in on a device."]}),ne&&n.jsx(WS,{proposalId:e.id,systemName:z,toolArgs:F.toolArgs,sealed:F.sealed,onTone:Z,onData:A}),ne&&n.jsx(QS,{proposalId:e.id,onData:ie}),ne&&n.jsxs("details",{className:"creation-legend-fold",children:[n.jsx("summary",{"aria-label":"What the marks mean",children:"?"}),n.jsxs("p",{className:"creation-legend","data-testid":"au10-legend",children:[n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot creation-legend-dot-sealed"}),"sealed — approved and executed exactly so"]}),n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot creation-legend-dot-system"}),"from the system — read by the gateway, not by the AI"]}),n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot au10-dot-ai"}),"the AI's own claim or text — not checked"]}),F.sealed&&n.jsx("span",{children:"Decrypted on this device — suveren.ai stores only an unreadable copy and its fingerprint."})]})]}),B.length>0&&n.jsxs("div",{className:"limit-checks",children:[n.jsx("h4",{children:"Within your limits"}),n.jsx("ul",{className:"limit-check-list",children:B.map(Y=>n.jsxs("li",{className:Y.ok?"ok":"bad",children:[n.jsx("span",{className:"limit-check-icon",children:Y.ok?"✓":"✗"}),n.jsxs("span",{children:[Y.label," ",Y.valueText," — your limit ",Y.limitText]})]},Y.key))})]}),n.jsxs("div",{className:"mandate-intent",children:[n.jsxs("dl",{children:[n.jsx("dt",{children:"Mandate"}),n.jsx("dd",{children:n.jsx("strong",{children:(P==null?void 0:P.name)??Mt(e.profileId)})})]}),n.jsxs("dl",{children:[n.jsx("dt",{children:"Intent"}),n.jsx("dd",{children:X?n.jsx("p",{className:"msg-error",style:{fontSize:"0.8rem",margin:0},children:X}):U!==null?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:`intent-text${g?"":" intent-clamped"}`,children:U}),n.jsx("button",{className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>v(!g),children:g?"Show less":"Show full intent"})]}):ee?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"Loading intent…"}):n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this mandate."})})]})]}),ne&&te.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:te.map(Y=>n.jsxs("a",{href:Y.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:Y.description??Y.href,children:[Y.label," ↗"]},Y.label))}),!Q&&ne&&n.jsxs("details",{className:"proposal-args-fold",style:{marginBottom:"0.75rem"},children:[n.jsx("summary",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",cursor:"pointer"},children:"Details (exactly what is bound)"}),n.jsx("div",{style:{marginTop:"0.5rem"},children:ue})]}),ne&&e.tool===Eb&&n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n.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 ",n.jsx("strong",{children:"your words"})," once you approve. Edit it first — nothing is created until you sign on the mandate screen."]}),n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm","data-testid":"edit-before-signing",onClick:ge,disabled:y,children:y?"Opening…":"Edit before signing"}),j&&n.jsx("p",{className:"msg-error",style:{fontSize:"0.8rem",margin:"0.4rem 0 0"},children:j})]})]})}function Op({note:e,onNoteChange:s,onSend:a,onCancel:o,sending:l,error:u}){return n.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:"var(--radius-md)",background:"var(--bg-main)",padding:"0.75rem 0.875rem",marginTop:"0.5rem"},children:[n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:[n.jsx("strong",{style:{color:"var(--text-primary)"},children:"What should change?"})," (the AI will read this)"]}),n.jsx("div",{style:{display:"flex",gap:"0.375rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:Nj.map(f=>n.jsx("button",{type:"button",className:`filter-chip${hp(e,f)?" selected":""}`,onClick:()=>s(Ej(e,f)),disabled:l,children:f},f))}),n.jsx("textarea",{"data-testid":"change-note",className:"form-input",value:e,maxLength:Vi,onChange:f=>s(f.target.value),rows:3,placeholder:"What should the AI do differently?",disabled:l,style:{width:"100%",resize:"vertical",fontFamily:"inherit"}}),n.jsxs("div",{style:{textAlign:"right",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[e.length," / ",Vi]}),u&&n.jsx("div",{className:"error-message",style:{marginTop:"0.4rem"},children:u}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.5rem"},children:[n.jsx("button",{"data-testid":"btn-send-back",className:"btn btn-primary",onClick:a,disabled:l,children:l?"Sending…":"Send back for change"}),n.jsx("button",{className:"btn btn-ghost",onClick:o,disabled:l,children:"Cancel"})]}),n.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 Tb={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired",refused:"Refused"},Ab={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired",refused:"status-revoked"},Uh={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced",REFUSED:"status-revoked"};function ic(e){const s=Date.now()-e*1e3,a=s/36e5;return a<48?a<1?`${Math.max(1,Math.round(s/6e4))}m ago`:`${Math.round(a)}h ago`:new Date(e*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Ib(e){return e.split("__").pop()??e}function Rb(e){const s=e.toLowerCase();return s.includes("delete")||s.includes("refund")||s.includes("cancel")||s.includes("revoke")}function Bp(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(s=>Bp(s)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Wh({item:e,onApprove:s,onReject:a,onChangeNeeded:o,resolving:l,proposalLinks:u,toolDisplay:f,manifests:p,currentUserId:g,inRow:v=!1}){const y=e.kind==="proposal",x=y?e.proposal.status:"executed",j=y?e.proposal.tool:e.receipt.action,k=Ib(j),b=Rb(j),{integrationId:S}=Un(j),N=_r(S,p),[E,T]=h.useState(!1),[P,I]=h.useState(""),[B,O]=h.useState(""),K=h.useRef(null),z=async()=>{const re=K.current;if(!(!re||!y))try{const{shownHash:H}=await L.saveShownSnapshot(e.proposal.id,re);return H}catch{return}},U=async()=>{const re=Yc(P);if(!re.valid){O(re.error);return}O("");const H=await z();o==null||o(e.id,re.trimmed,H)},ee=y&&x==="rejected"?Rj(e.proposal,g??""):null,X=y&&x==="refused"?Pj(e.proposal):null,F=Rw(y?e.proposal.rejectedBy??e.proposal.approverRejectedBy??null:null),ne=so(y?e.proposal:{toolArgs:void 0,content:void 0}),fe=y?ne.toolArgs:null,te=y?e.proposal.executionContext:e.receipt.executionContext,ge=y?null:e.receipt.cumulativeState,[ke,Z]=h.useState(!0),[Q,q]=h.useState(!1),A=y&&ne.toolArgs?Lp(u,ne.toolArgs):[],$=Object.entries(te??{}),ie=Pr(e.profileId).testSetup||to(j);return n.jsxs("div",{className:v?"card card-in-row":"card id-card",children:[!v&&n.jsx(Qc,{profileId:e.profileId}),n.jsxs("div",{className:"id-body",children:[v?ie?n.jsx("div",{style:{marginBottom:"0.5rem"},children:n.jsx("span",{className:"sim-mark",children:"Test setup"})}):null:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[n.jsx("code",{style:{fontSize:"0.85rem"},children:k}),ie&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),e.commitmentMode==="automatic"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),n.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[y&&x==="pending"&&(()=>{const re=zp(e.proposal.expiresAt,Date.now());return n.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",fontWeight:re.urgent?600:400,whiteSpace:"nowrap"},children:re.label})})(),n.jsx("span",{"data-testid":ee||X?"outcome-kind":void 0,className:`status-badge ${ee?Uh[ee.kind]:X?Uh.REFUSED:Ab[x]}`,children:ee?ee.kind:X?X.kind:Tb[x]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:ic(e.sortTimestamp)})]})]}),y&&e.proposal.status==="executed"&&n.jsx(Sb,{proposalId:e.proposal.id,systemName:N}),ee&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By ",ee.who,", ",ic(ee.at)]}),(F??ee.note)&&n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[ee.kind==="CHANGE NEEDED"?"Change: ":"Note: ",F??ee.note]})]}),X&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By the Authority Server, ",ic(X.at)]}),n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:["Reason: ",X.message]})]}),b&&n.jsx("div",{className:"note-attention",style:{display:"flex",alignItems:"center",gap:"0.4rem",fontSize:"0.8rem",padding:"0.4rem 0.6rem",marginBottom:"0.75rem"},children:n.jsx("span",{className:"msg-attention",children:"Irreversible action"})}),y&&typeof(fe==null?void 0:fe._imagePreview)=="string"&&n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),n.jsx("img",{src:fe._imagePreview,alt:typeof(fe==null?void 0:fe.altText)=="string"?fe.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),y&&x==="pending"?n.jsx(Mp,{proposal:e.proposal,currentUserId:g??"",proposalLinks:u,toolDisplay:f,manifests:p,onContentState:({loading:re,readable:H})=>{q(re),Z(H)},onShownSnapshot:re=>{K.current=re}}):n.jsxs(n.Fragment,{children:[A.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:A.map(re=>n.jsxs("a",{href:re.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:re.description??re.href,children:[re.label," ↗"]},re.label))}),y?n.jsxs(n.Fragment,{children:[fe&&n.jsx(xc,{args:fe,display:f}),$.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:$.map(([re,H])=>`${re}=${Bp(H)}`).join(" · ")})]}):n.jsxs(n.Fragment,{children:[n.jsx(Np,{receipt:e.receipt,manifests:p}),e.receipt.proposalId&&n.jsx(_p,{proposalId:e.receipt.proposalId,tool:e.receipt.action,manifests:p})]})]}),ge&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",ge.daily.count," action",ge.daily.count===1?"":"s",ge.daily.amount>0?`, ${ge.daily.amount}`:""," · ","this month: ",ge.monthly.count,ge.monthly.amount>0?`, ${ge.monthly.amount}`:""]}),y&&x==="pending"&&Jm({loading:Q,readable:ke})&&(E?n.jsx(Op,{note:P,onNoteChange:I,onSend:U,onCancel:()=>{T(!1),I(""),O("")},sending:!!l,error:B}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"approval-resp",children:"Approving sends exactly this. Your approval is recorded with your name."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:async()=>s==null?void 0:s(e.id,await z()),disabled:l,children:l?"Approving…":"Approve"}),n.jsxs("button",{"data-testid":"btn-change-needed",className:"btn btn-outline-strong",onClick:()=>T(!0),disabled:l,children:[n.jsx("span",{"aria-hidden":"true",children:"↩"})," Change needed"]}),n.jsxs("button",{"data-testid":"btn-reject",className:"btn btn-outline-strong",onClick:async()=>a==null?void 0:a(e.id,await z()),disabled:l,children:[n.jsx("span",{"aria-hidden":"true",children:"✕"})," Reject"]})]})]})),!v&&n.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[y?"Proposal":"Ticket",": ",e.id]})]})]})}function Pb(e,s=[]){const a=new Map;for(const o of e){const l=o.name&&o.email?`${o.name} (${o.email})`:o.name||o.email||o.id;a.set(o.id,l)}for(const o of s){const l=o.userId??o.id;l&&(o.name&&o.email?a.set(l,`${o.name} (${o.email})`):o.name&&a.set(l,o.name))}return a}function $b(e,s){return e.map(a=>s.get(a)??a)}function Dp(e){var k;const{groupId:s}=xt(),a=ma(e.profileId),[o,l]=h.useState(null),[u,f]=h.useState(new Map),[p,g]=h.useState(!0);h.useEffect(()=>{let b=!0;if(!s){g(!1);return}return g(!0),Promise.all([L.getTeamProfileConfig(s,e.profileId).catch(()=>null),L.getGroupById(s).catch(()=>null),L.listUsers().catch(()=>[])]).then(([S,N,E])=>{b&&(l(S),f(Pb(E,(N==null?void 0:N.members)??[])))}).finally(()=>{b&&g(!1)}),()=>{b=!1}},[s,e.profileId]);const v=Ax(o??{}),y=$b(e.pendingApprovers??[],u),x=b=>u.get(b)??b,j=o&&((k=a==null?void 0:a.boundsSchema)!=null&&k.fields)?qw(e.executionContext,o,a.boundsSchema.fields):null;return{loading:p,profileConfig:o,requiredApprovals:v,approverNames:y,nameOf:x,aboveCapReason:j}}function Up(e,s){return!!e.createdBy&&!!s&&e.createdBy===s}function Wp(e){return(e.pendingApprovers??[]).filter(s=>s!==e.createdBy)}function _b(e){const s=Date.now()-e*1e3,a=Math.floor(s/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Lb({proposal:e,currentUserId:s,onAction:a,onMessage:o,proposalLinks:l,toolDisplay:u,manifests:f,inRow:p=!1}){const[g,v]=h.useState(!1),[y,x]=h.useState(!1),[j,k]=h.useState(!1),[b,S]=h.useState(""),[N,E]=h.useState(""),[T,P]=h.useState(!1),[I,B]=h.useState(!1),[O,K]=h.useState(!0),z=h.useRef(null),U=async()=>{const $=z.current;if($)try{const{shownHash:ie}=await L.saveShownSnapshot(e.id,$);return ie}catch{return}},ee=Pr(e.profileId).testSetup||to(e.tool),X=Wp(e),F=e.approvedBy??{},ne=Object.keys(F).length,fe=s in F,te=Dp(e),ge=Up(e,s),ke=$=>{const ie=$ instanceof Error?$.message:"Approval failed";return ie.includes("APPROVER_IS_PROPOSER")?"You can't approve your own action. Ask another approver.":ie.includes("APPROVAL_IMPOSSIBLE")?"This action cannot be approved — there is no one else eligible to approve it. Ask a team admin to add another approver.":ie},Z=async()=>{if(Uc()){o(Wc);return}v(!0),o("");try{const $=await ia(e),ie=await U(),re=await L.approveProposal(e.id,$,ie);try{const pe=await L.getAttestationIntent(e.authorizationId);if(pe){const ve=await L.decryptIntent({intentCiphertext:pe.intentCiphertext,encryptedKey:pe.encryptedKey,approverId:s});await L.storeApprovedIntent(e.authorizationId,ve)}}catch{}const{requiredApprovals:H,approvedCount:oe}=re,ue=H!==void 0&&oe!==void 0?H-oe:void 0;o(ue===void 0?"Approved.":ue>0?`Approved. ${ue} more approval${ue===1?"":"s"} still needed.`:"Approved — the required number of approvals is met; the action is ready to execute."),a()}catch($){o(ke($))}finally{v(!1)}},Q=async()=>{x(!0),o("");try{const $=await ia(e),ie=await U();await L.rejectProposal(e.id,mp(),$,ie),o("Action rejected."),a()}catch($){o($ instanceof Error?$.message:"Rejection failed")}finally{x(!1)}},q=async()=>{const $=Yc(b);if(!$.valid){E($.error);return}E(""),P(!0),o("");try{const{noteEncrypted:ie}=await L.encryptProposalNote($.trimmed,Qm(e,s)),re=await ia(e),H=await U();await L.rejectProposal(e.id,{outcome:"change_needed",noteEncrypted:ie},re,H),o("Sent back for a change."),a()}catch(ie){o(ie instanceof Error?ie.message:"Failed to send back")}finally{P(!1)}},A=g||y||T;return n.jsxs("div",{className:p?"card card-in-row":"card id-card",children:[!p&&n.jsx(Qc,{profileId:e.profileId}),n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:p?"none":"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[ee&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),n.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const $=zp(e.expiresAt,Date.now());return n.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",fontWeight:$.urgent?600:400,whiteSpace:"nowrap"},children:$.label})})(),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:_b(e.createdAt)})]})]}),n.jsxs("div",{className:"approver-progress",style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Needs ",te.requiredApprovals," approval",te.requiredApprovals===1?"":"s"," from:"," ",X.map(($,ie)=>n.jsxs("span",{className:`who${$ in F?" done":""}`,style:{marginLeft:ie===0?"0.25rem":"0.5rem",fontWeight:$ in F?600:void 0},children:[$ in F?"✓ ":"",te.nameOf($),$===s?" (you)":"",ie<X.length-1?",":""]},$)),te.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",ne," of ",te.requiredApprovals,")"]})]}),te.aboveCapReason&&n.jsxs("div",{className:"over-limit-box","data-testid":"above-cap-reason",style:{display:"flex",gap:"0.5rem",alignItems:"flex-start",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.6rem 0.8rem",marginBottom:"0.6rem",fontSize:"0.82rem"},children:[n.jsx("span",{style:{fontWeight:700,whiteSpace:"nowrap"},children:"Above the team limit:"}),n.jsxs("span",{children:[te.aboveCapReason.fieldLabel,te.aboveCapReason.value!==void 0?` ${te.aboveCapReason.value}`:""," (limit ",String(te.aboveCapReason.cap),")."," ",e.createdBy?`Requested by ${te.nameOf(e.createdBy)}.`:""]})]}),n.jsx(Mp,{proposal:e,currentUserId:s,proposalLinks:l,toolDisplay:u,manifests:f,nameOf:te.nameOf,onContentState:({loading:$,readable:ie})=>{B($),K(ie)},onShownSnapshot:$=>{z.current=$}}),!fe&&Jm({loading:I,readable:O})&&(j?n.jsx(Op,{note:b,onNoteChange:S,onSend:q,onCancel:()=>{k(!1),S(""),E("")},sending:T,error:N}):n.jsxs(n.Fragment,{children:[!ge&&n.jsx("p",{className:"approval-resp",children:"Approving sends exactly this. Your approval is recorded with your name."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem",flexWrap:"wrap",alignItems:"center"},children:[ge?n.jsx("p",{className:"blocked-note","data-testid":"cant-approve-own-action",style:{fontSize:"0.82rem",color:"var(--text-tertiary)",margin:0},children:n.jsx("strong",{children:"You can't approve your own action."})}):n.jsx("button",{className:"btn btn-primary",onClick:Z,disabled:A,children:g?"Approving...":"Approve"}),n.jsxs("button",{"data-testid":"btn-change-needed",className:"btn btn-outline-strong",onClick:()=>k(!0),disabled:A,children:[n.jsx("span",{"aria-hidden":"true",children:"↩"})," Change needed"]}),n.jsxs("button",{"data-testid":"btn-reject",className:"btn btn-outline-strong",onClick:Q,disabled:A,children:[n.jsx("span",{"aria-hidden":"true",children:"✕"})," ",y?"Rejecting...":"Reject"]})]})]})),fe&&n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:["You approved this action.",te.requiredApprovals>1&&ne<te.requiredApprovals?` Waiting on ${te.requiredApprovals-ne} more approval(s).`:""]}),!p&&n.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",e.id]})]})]})}function Hh({proposal:e,manifests:s,titles:a,open:o,onToggle:l,who:u,children:f}){const p=Date.now(),g=Gm(e.expiresAt,p),v=$r(),y=h.useRef(null);return h.useEffect(()=>{var x;o&&((x=y.current)==null||x.scrollIntoView({block:"nearest"}))},[o]),n.jsxs("div",{ref:y,className:`appr-item${o?" is-open":""}`,"data-testid":"approval-row","data-proposal-id":e.id,children:[n.jsxs("button",{type:"button",className:"appr-item-head","aria-expanded":o,onClick:l,children:[n.jsxs("div",{className:"appr-item-main",children:[n.jsx(cs,{profileId:e.profileId,area:Ir(e.profileId,v),system:pa(e.tool,s),time:Vm(e.createdAt,p)}),n.jsx("div",{className:"appr-item-sum","data-testid":"approval-row-summary",children:n.jsx(np,{proposal:e,manifests:s})}),n.jsx(ca,{title:e.authorizationId?a[e.authorizationId]:void 0,area:Ir(e.profileId,v)}),g&&n.jsx("div",{className:"obj-due",children:g}),u&&n.jsx("div",{className:"appr-item-who",children:u})]}),n.jsx("span",{className:"appr-item-chev","aria-hidden":"true",children:"›"})]}),o&&n.jsx("div",{className:"appr-item-body",children:f})]})}function zb(){const{domain:e,user:s}=xt(),a=(s==null?void 0:s.id)??"",[o,l]=h.useState("awaiting-me"),[u,f]=h.useState([]),[p,g]=h.useState([]),[v,y]=h.useState({}),[x,j]=h.useState(!0),[k,b]=h.useState(""),S=h.useCallback(async()=>{try{const G=await L.getProposalsForApprover();f(G)}catch{}finally{j(!1)}},[]);Fe("proposal-added",S),Fe("proposal-approved",S),Fe("proposal-rejected",S),Fe("proposal-resolved",S),Ft(S,3e4);const[N,E]=h.useState([]),T=h.useCallback(async()=>{try{const G=await L.getMyProposals(e);E(G)}catch{}},[e]);Fe("proposal-added",T),Fe("proposal-approved",T),Fe("proposal-rejected",T),Fe("proposal-resolved",T),Fe("execution-failed",T),Ft(T,3e4,e);const P=h.useMemo(()=>N.filter(G=>{var J;return G.status==="pending"&&(((J=G.pendingApprovers)==null?void 0:J.length)??0)===0}),[N]),I=h.useMemo(()=>Bh(P,[],{status:"pending"}),[P]),[B,O]=h.useState([]),K=h.useCallback(async()=>{if(a)try{const J=(await L.getMyProposals(e)).filter(ye=>ye.status==="pending"&&ye.pendingApprovers&&ye.pendingApprovers.includes(a)&&ye.approvedBy&&a in ye.approvedBy);O(J)}catch{}},[a,e]);Fe("proposal-approved",K),Fe("proposal-rejected",K),Ft(K,3e4,`${a}:${e}`);const[z,U]=h.useState([]),ee=h.useCallback(async()=>{try{const G=await L.getProposalsCreatedByMe();if(G!==null){U(G);return}U(await L.getMyPendingProposals())}catch{}},[]);Fe("proposal-added",ee),Fe("proposal-approved",ee),Fe("proposal-rejected",ee),Ft(ee,3e4),h.useEffect(()=>{L.getLabelManifests().then(g).catch(()=>{}),L.getToolDisplay().then(y).catch(()=>{})},[]);const X=G=>{var J;return(J=p.find(ye=>ye.id===G.split("__")[0]))==null?void 0:J.proposalLinks};h.useEffect(()=>{S(),T(),K(),ee()},[]);const[F,ne]=h.useState([]),[fe,te]=h.useState([]),[ge,ke]=h.useState(!0),[Z,Q]=h.useState(null),[q,A]=h.useState(""),[$,ie]=h.useState("pending"),[re,H]=h.useState(null),[oe,ue]=h.useState(!1),pe=h.useCallback(async()=>{try{const{proposals:G,receipts:J}=await L.getThread({domain:e,status:$,sinceDays:7});ne(G),te(J)}catch{}finally{ke(!1)}},[e,$]);Ft(pe,3e4,`${e}:${$}`);const ve=async(G,J,ye,Ue)=>{if(J==="commit"&&Uc()){A(Wc);return}Q(G),A("");try{const We=F.find(W=>W.id===G)??N.find(W=>W.id===G),nt=Tx(We,e),Ht=We?await ia(We):void 0;let Ot=ye??{};if((ye==null?void 0:ye.outcome)==="change_needed"&&ye.note){const W=We?Qm(We,a):[a],{noteEncrypted:xe}=await L.encryptProposalNote(ye.note,W);Ot={outcome:"change_needed",noteEncrypted:xe}}const Ze=await L.resolveProposal(G,J,nt,{...Ot,contentHash:Ht,shownHash:Ue});A(J==="commit"?`Action approved. Status: ${Ze.status}`:(ye==null?void 0:ye.outcome)==="change_needed"?"Sent back for a change.":"Action rejected."),await Promise.all([pe(),T()])}catch(We){A(We instanceof Error?We.message:"Failed")}finally{Q(null)}},le=(G,J)=>ve(G,"commit",void 0,J),Ge=(G,J)=>ve(G,"reject",mp(),J),Se=(G,J,ye)=>ve(G,"reject",Tj(J),ye),Y=h.useMemo(()=>{const G=new Set;for(const J of F)G.add(J.profileId);for(const J of fe)G.add(J.profileId);return Array.from(G).sort()},[F,fe]),$e=h.useMemo(()=>Bh(F,fe,{status:$,profile:re??void 0,includeAutonomous:oe}),[F,fe,$,re,oe]),_e=h.useCallback(()=>{S(),K()},[S,K]),Be=h.useMemo(()=>{const G=new Set,J=[];for(const ye of[...B,...z])G.has(ye.id)||(G.add(ye.id),J.push(ye));return J.sort((ye,Ue)=>Ue.createdAt-ye.createdAt)},[B,z]),ze=u.length+I.length,[it]=ps(),[tt,Qe]=h.useState(()=>it.get("open")),Ye=h.useMemo(()=>[...I.map(G=>G.kind==="proposal"?G.proposal.id:G.id),...u.map(G=>G.id)],[I,u]),jt=h.useRef([]),pt=h.useRef(null);h.useEffect(()=>{const G=jt.current;if(jt.current=Ye,Ye.length===1&&tt===null&&pt.current!==Ye[0]){pt.current=Ye[0],Qe(Ye[0]);return}if(tt&&!Ye.includes(tt)&&G.includes(tt)){const J=G.indexOf(tt),ye=G.slice(J+1).find(Ue=>Ye.includes(Ue))??Ye[0]??null;Qe(ye)}},[Ye,tt]);const Me=G=>Qe(J=>J===G?null:G),[me,Ae]=h.useState({});h.useEffect(()=>{L.getMyAttestations().then(G=>{const J={};for(const ye of G)ye.authorization_id&&ye.title&&(J[ye.authorization_id]=ye.title);Ae(J)}).catch(()=>{})},[]);const Oe=Be.length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Approvals"}),n.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."}),n.jsx(Lm,{what:"approve"})]}),n.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[n.jsxs("button",{className:`nav-tab${o==="awaiting-me"?" active":""}`,onClick:()=>l("awaiting-me"),children:["Awaiting me ",ze>0&&n.jsx("span",{className:"pill-count",style:{marginLeft:"0.4rem"},children:ze})]}),n.jsxs("button",{className:`nav-tab${o==="awaiting-others"?" active":""}`,onClick:()=>l("awaiting-others"),children:["Awaiting others ",Oe>0&&n.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:Oe})]}),n.jsx("button",{className:`nav-tab${o==="all"?" active":""}`,onClick:()=>{l("all"),pe()},children:"All"})]}),o==="awaiting-me"&&n.jsx(n.Fragment,{children:x&&ze===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ze===0?n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[n.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):n.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[(k||q)&&n.jsx("div",{className:"alert alert-success",children:k||q}),I.map(G=>{const J=n.jsx(Wh,{proposalLinks:G.kind==="proposal"?X(G.proposal.tool):void 0,toolDisplay:G.kind==="proposal"?v[G.proposal.tool]:void 0,manifests:p,currentUserId:a,item:G,onApprove:le,onReject:Ge,onChangeNeeded:Se,resolving:Z===G.id,inRow:G.kind==="proposal"},G.id);if(G.kind!=="proposal")return J;const ye=G.proposal.id;return n.jsx(Hh,{proposal:G.proposal,manifests:p,titles:me,open:tt===ye,onToggle:()=>Me(ye),children:J},ye)}),u.map(G=>n.jsx(Hh,{proposal:G,manifests:p,titles:me,open:tt===G.id,onToggle:()=>Me(G.id),who:"Team approval — other people are involved",children:n.jsx(Lb,{inRow:!0,proposal:G,currentUserId:a,onAction:_e,onMessage:b,proposalLinks:X(G.tool),toolDisplay:v[G.tool],manifests:p},G.id)},G.id))]})}),o==="awaiting-others"&&n.jsx(n.Fragment,{children:Be.length===0?n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[n.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:Be.map(G=>n.jsx(Mb,{proposal:G,currentUserId:a,onCancel:async()=>{try{await L.rejectProposal(G.id,{reason:"cancelled by creator"}),K(),T()}catch(J){alert(J instanceof Error?J.message:"Cancel failed")}},onWithdraw:async()=>{const J=await ia(G);await L.withdrawProposal(G.id,void 0,J),ee(),K()}},G.id))})}),o==="all"&&n.jsxs(n.Fragment,{children:[q&&n.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:q}),n.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[n.jsx("button",{className:`filter-chip ${$==="pending"?"selected":""}`,onClick:()=>ie("pending"),children:"Pending"}),n.jsx("button",{className:`filter-chip ${$==="all"?"selected":""}`,onClick:()=>ie("all"),children:"All"}),Y.length>0&&n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),Y.map(G=>n.jsx("button",{className:`filter-chip ${re===G?"selected":""}`,onClick:()=>H(re===G?null:G),children:Mt(G)},G)),$==="all"&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),n.jsxs("button",{className:`filter-chip ${oe?"selected":""}`,onClick:()=>ue(!oe),title:"Include actions executed without human review (automatic commitment mode)",children:[oe?"✓ ":"","Autonomous actions"]})]})]}),ge&&$e.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):$e.length===0?n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[n.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:$==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:$==="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."})]}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:$e.map(G=>n.jsx(Wh,{proposalLinks:G.kind==="proposal"?X(G.proposal.tool):void 0,toolDisplay:G.kind==="proposal"?v[G.proposal.tool]:void 0,manifests:p,currentUserId:a,item:G,onApprove:le,onReject:Ge,onChangeNeeded:Se,resolving:Z===G.id},G.id))})]})]})}function Fb(e){const s=Date.now()-e*1e3,a=Math.floor(s/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Mb({proposal:e,currentUserId:s,onCancel:a,onWithdraw:o}){const[l,u]=h.useState(!1),[f,p]=h.useState(!1),[g,v]=h.useState(""),y=Dp(e),x=Up(e,s),j=Wp(e),k=e.approvedBy??{},b=Object.keys(k).length,S=j.length>0,N=async()=>{u(!0);try{await a()}finally{u(!1)}},E=async()=>{p(!0),v("");try{await o()}catch(P){v(P instanceof Error?P.message:"Withdraw failed")}finally{p(!1)}},T=Pr(e.profileId).testSetup||to(e.tool);return n.jsxs("div",{className:"card id-card",children:[n.jsx(Qc,{profileId:e.profileId}),n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[n.jsx("code",{style:{fontSize:"0.85rem"},children:e.tool.split("__").pop()??e.tool}),T&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),n.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Fb(e.createdAt)})]}),S&&n.jsxs("div",{className:"approver-progress",style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Needs ",y.requiredApprovals," approval",y.requiredApprovals===1?"":"s"," from:"," ",j.map((P,I)=>n.jsxs("span",{className:`who${P in k?" done":""}`,style:{marginLeft:I===0?"0.25rem":"0.5rem",fontWeight:P in k?600:void 0},children:[P in k?"✓ ":"",y.nameOf(P),P===s?" (you)":"",I<j.length-1?",":""]},P)),y.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",b," of ",y.requiredApprovals,")"]})]}),y.aboveCapReason&&n.jsxs("div",{className:"over-limit-box","data-testid":"above-cap-reason",style:{display:"flex",gap:"0.5rem",alignItems:"flex-start",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.6rem 0.8rem",marginBottom:"0.6rem",fontSize:"0.82rem"},children:[n.jsx("span",{style:{fontWeight:700,whiteSpace:"nowrap"},children:"Above the team limit:"}),n.jsxs("span",{children:[y.aboveCapReason.fieldLabel,y.aboveCapReason.value!==void 0?` ${y.aboveCapReason.value}`:""," (limit ",String(y.aboveCapReason.cap),")."," ",e.createdBy?`Requested by ${y.nameOf(e.createdBy)}.`:""]})]}),S&&x&&n.jsx("p",{"data-testid":"cant-approve-own-action",style:{fontSize:"0.82rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:n.jsx("strong",{children:"You can't approve your own action."})}),S&&x?n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"0.35rem",marginTop:"0.5rem"},children:[n.jsx("button",{className:"btn btn-outline-strong btn-sm",onClick:E,disabled:f,children:f?"Withdrawing...":"Withdraw"}),g&&n.jsx("p",{className:"msg-error",style:{fontSize:"0.78rem",margin:0},children:g})]}):n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:n.jsx("button",{className:"btn btn-outline-strong btn-sm",onClick:N,disabled:l,children:l?"Cancelling...":"Cancel"})})]})]})}const Ob=`# Agent Brief
|
|
88
|
+
|
|
89
|
+
You act on my behalf through Suveren — the gateway that gates every
|
|
90
|
+
privileged tool call you make. Suveren implements the bounded-authority
|
|
91
|
+
model from the open Human Agency Protocol (HAP): each mandate
|
|
92
|
+
describes an area of authority, a set of numeric limits, and a scope.
|
|
93
|
+
Operate inside those bounds or the Gatekeeper will reject your action.
|
|
94
|
+
|
|
95
|
+
## Before you act in a domain
|
|
96
|
+
|
|
97
|
+
1. Call \`list-authorizations(domain: "<domain>")\` to load the full
|
|
98
|
+
intent, scope, and usage for that area. The session brief shows only
|
|
99
|
+
a one-line summary per mandate — the Intent paragraph lives behind
|
|
100
|
+
that call, and often contains soft rules you MUST honor (e.g. "never
|
|
101
|
+
publish on weekends", "only reply in English").
|
|
102
|
+
2. If the action would exceed a bound or fall outside the scope, stop
|
|
103
|
+
and explain what would be blocked instead of trying.
|
|
104
|
+
3. If you're not sure whether an action is covered, ask me first.
|
|
105
|
+
|
|
106
|
+
## How to handle reviews
|
|
107
|
+
|
|
108
|
+
Mandates in review mode require my approval before the action
|
|
109
|
+
executes. When you propose an action:
|
|
110
|
+
- Include everything I need to judge it (title, recipients, amounts,
|
|
111
|
+
dates, attendees) in the tool arguments.
|
|
112
|
+
- Don't batch unrelated proposals — one proposal per decision.
|
|
113
|
+
|
|
114
|
+
## Standing orders
|
|
115
|
+
|
|
116
|
+
(Add your own here. Examples:)
|
|
117
|
+
|
|
118
|
+
- Every morning, summarize today's calendar and flag conflicts.
|
|
119
|
+
- On Fridays, give me a weekly review: what's done, what slipped, what's
|
|
120
|
+
next.
|
|
121
|
+
- Never email anyone outside the company without asking first.
|
|
122
|
+
- When drafting posts, prefer plain language over marketing copy.
|
|
123
|
+
`;function Bb(){const[e,s]=h.useState(""),[a,o]=h.useState(""),[l,u]=h.useState(!0),[f,p]=h.useState(!1),[g,v]=h.useState(null),[y,x]=h.useState(!1),j=e!==a,k=new Blob([e]).size,b=16*1024;h.useEffect(()=>{if(!j)return;const T=I=>{I.preventDefault(),I.returnValue=""},P=I=>{var K,z;if(I.defaultPrevented||I.button!==0||I.metaKey||I.ctrlKey||I.shiftKey||I.altKey)return;const B=(z=(K=I.target)==null?void 0:K.closest)==null?void 0:z.call(K,"a");if(!B||!B.href)return;let O;try{O=new URL(B.href)}catch{return}O.origin===window.location.origin&&O.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(I.preventDefault(),I.stopPropagation()))};return window.addEventListener("beforeunload",T),document.addEventListener("click",P,!0),()=>{window.removeEventListener("beforeunload",T),document.removeEventListener("click",P,!0)}},[j]),h.useEffect(()=>{let T=!1;return L.getAgentContext().then(P=>{T||(s(P),o(P))}).catch(P=>{T||v({kind:"error",text:P instanceof Error?P.message:"Failed to load context"})}).finally(()=>{T||u(!1)}),()=>{T=!0}},[]);const S=async()=>{p(!0),v(null);try{await L.saveAgentContext(e),o(e),v({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(T){v({kind:"error",text:T instanceof Error?T.message:"Save failed"})}finally{p(!1)}},N=()=>{s(a),v(null)},E=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||s(Ob)};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Agent Brief"}),n.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!e.trim()&&!l&&n.jsx("button",{className:"btn btn-primary btn-sm",onClick:E,disabled:f,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),g&&n.jsx("div",{className:g.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:g.text}),n.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[n.jsx("div",{className:"card intent-pane chat",children:n.jsx(Wi,{target:{kind:"context"},currentText:e,onApply:T=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||s(T)},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…"})}),n.jsxs("div",{className:"card intent-pane document",children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[n.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),n.jsxs("span",{className:k>b?"msg-error":void 0,style:{fontSize:"0.75rem",color:k>b?void 0:"var(--text-muted)"},children:[k.toLocaleString()," / ",b.toLocaleString()," bytes"]})]}),n.jsx("textarea",{className:"form-textarea",value:e,onChange:T=>s(T.target.value),placeholder:l?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:l,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),n.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:N,disabled:f||!j,children:"Revert"}),n.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:S,disabled:f||!j||k>b||l,children:f?"Saving…":"Save"})]})]}),n.jsx("button",{type:"button",className:"floating-help",onClick:()=>x(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),n.jsx(ip,{open:y,onClose:()=>x(!1),ariaLabel:"Brief assistant",children:n.jsx(Wi,{target:{kind:"context"},currentText:e,onApply:T=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(s(T),x(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function Db(e){const s=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(e);return s&&s[1].replace(/<[^>]+>/g,"").trim()||"Report"}function Ub(e){const s=e.find(l=>{var u;return l.kind==="sv-mandate"&&l.status!=="unverifiable"&&typeof((u=l.data)==null?void 0:u.profile)=="string"});if(!s)return null;const a=s.data;if(typeof a.profileLabel=="string"&&a.profileLabel)return a.profileLabel;const o=a.profile.split("@")[0].split("/").pop();return o?o.charAt(0).toUpperCase()+o.slice(1):null}function Wb(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Hb(e,s){const a=s.emailExportError?"cases unknown":`${s.coveredCases.length}/${s.loadedCases.length} cases`;return`${e.signaturesValid>0?`${e.signaturesValid} ✓ tickets`:`${e.signaturesValid} tickets`} · ${a} · ${s.ticketsReferenced.length}/${s.ticketsInPeriod.length} tickets covered`}function Vb(e){return e.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:e.emailExportError}:{kind:"ok",text:`${e.coveredCases.length} of ${e.loadedCases.length}`}}function Gb(e){return e.periodStart!==null?null:e.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:e.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function Vh(e,s="none in this report"){return e>0?{kind:"ok",text:`${e} ✓`}:{kind:"neutral",text:s}}function Kb(e){return/Labels?$/.test(e)||e==="limits"||e==="fields"}function qb(e,s){const a=s[e];return a==null||a===""||Kb(e)?null:typeof a=="object"?JSON.stringify(a):String(a)}function Yb(e){const s=[];return e.missingCases.length>0&&s.push(`cases ${e.missingCases.join(", ")}`),e.ticketsNotReferenced.length>0&&s.push(`${e.ticketsNotReferenced.length} ticket${e.ticketsNotReferenced.length===1?"":"s"}`),s.length>0?`Not in the report: ${s.join(" · ")}`:null}function Jb(e,s){var a;if(s)return s;if(!e)return null;if(e.kind==="sv-ticket")return e.attrs.ref||null;if(e.kind==="sv-approval"||e.kind==="sv-mandate")return e.attrs.ticket||null;if(e.kind==="sv-case"){const o=(a=e.data)==null?void 0:a.goal;return(o==null?void 0:o.ticketId)??null}return null}const Qb="allow-popups allow-popups-to-escape-sandbox",Xb="AI analysis — not verified",Zb="Green = verified by the gateway — raw signed fields only",ek="Grey dashed = the AI's own analysis, not verified",tk="= translation by the AI, not verified",nk="Übersetzung anzeigen / show translation";function Gh(e){var a;const s=((a=e.formatNotice)==null?void 0:a.blocksNotShown)??0;return s<=0?null:`${s} ${s===1?"block was":"blocks were"} not shown — not in the allowed form (the AI's own text belongs in an AI block). Ask the AI to write the report again.`}function rk(e){return(e.elements??[]).length===0&&e.renderedHtml.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<[^>]+>/g,"").replace(/ /g," ").trim()===""}function sk(e,s){return s&&e.renderedHtmlGloss?e.renderedHtmlGloss:e.renderedHtml}function ak(e,s,a){const o=new URLSearchParams(e);return o.set("element",s),a?o.set("ticket",a):o.delete("ticket"),o}const ik={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function ok(e){return e.filter(s=>s.status==="unverifiable").map(s=>({elementId:s.id,text:`${ik[s.kind]??"Element"}: ${s.reason??"could not be checked"}`}))}function lk(e){if(!e||e.kind!=="sv-case"||!e.data)return[];const s=Array.isArray(e.data.steps)?e.data.steps:[],a=e.data.goal,o=[...s.map(l=>({n:l,isGoal:!1})),...a?[{n:a,isGoal:!0}]:[]].filter(l=>typeof l.n.ticketId=="string"&&l.n.ticketId);return o.sort((l,u)=>(l.n.time??0)-(u.n.time??0)),o.map(({n:l,isGoal:u})=>({ticketId:l.ticketId,label:String(l.action??l.ticketId),isGoal:u}))}function ck(e){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>${e}</body></html>`}const Xc={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},uk={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function dk(e,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"]}[e].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 fk(e,s){const a=uk[e].filter(o=>s[o]!==void 0);return a.length===0?null:n.jsxs("details",{style:{marginTop:"0.5rem"},children:[n.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical details"}),n.jsx("dl",{style:{...Xc,marginTop:"0.5rem"},children:a.map(o=>n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:o}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:typeof s[o]=="object"?JSON.stringify(s[o]):String(s[o])})]},o))})]})}function oc(e,s){return s?n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:e}),s.status==="unverifiable"?n.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",s.reason??"no further detail."]}):n.jsxs(n.Fragment,{children:[n.jsx("dl",{style:Xc,children:dk(e,s.data??{}).map(({label:a,value:o})=>n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:a}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:o})]},a))}),fk(e,s.data??{})]})]}):null}function hk({report:e,elementId:s,ticketParam:a,onClose:o,onSelectTicket:l}){var x;const u=e.elements.find(j=>j.id===s),f=Jb(u,a),p=f?e.ticketDetails[f]:void 0,g=lk(u),v=(x=e.proof.verifiedValues.find(j=>j.elementId===s))==null?void 0:x.summary,y=h.useRef(null);return h.useEffect(()=>{const j=y.current;if(!j||typeof j.getBoundingClientRect!="function")return;const k=j.getBoundingClientRect().top;(k<0||k>window.innerHeight-80)&&j.scrollIntoView({block:"start",behavior:"smooth"})},[s,a]),n.jsxs("div",{className:"card reports-detail",ref:y,children:[n.jsxs("div",{className:"card-header",children:[n.jsx("div",{className:"card-title",children:"Details"}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:o,children:"Close"})]}),v&&n.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:v}),g.length>0&&n.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:g.map(j=>n.jsxs("button",{type:"button",className:`btn btn-sm ${j.ticketId===f?"btn-secondary":"btn-ghost"}`,"aria-pressed":j.ticketId===f,onClick:()=>l(j.ticketId),children:[j.isGoal?"Goal: ":"",j.label]},j.ticketId))}),!u&&n.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),u&&!f&&(u.status==="unverifiable"?n.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",u.reason??"no further detail."]}):n.jsx("dl",{style:Xc,children:Object.keys(u.data??{}).map(j=>{const k=qb(j,u.data??{});return k===null?null:n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:j}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:k})]},j)})})),p&&n.jsxs(n.Fragment,{children:[oc("Ticket",p.ticket),oc("Mandate",p.mandate),oc("Approval",p.approval)]}),f&&!p&&n.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",f,"."]})]})}async function mk(e){const{html:s,filename:a}=await e.exportReport();e.download(s,a),await e.refresh()}function Kh({detail:e}){return e?n.jsxs("details",{style:{marginTop:"0.25rem"},children:[n.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical detail"}),n.jsx("p",{className:"page-subtitle",style:{marginTop:"0.25rem",wordBreak:"break-word"},children:e})]}):null}function pk({report:e,open:s,selectedId:a,onOpenElement:o,detail:l}){const{proof:u,coverage:f}=e,p=ok(e.elements),g=Yb(f),v=Vb(f),y=Gb(f),x=Vh(u.signaturesValid),j=Vh(u.recordsChecked);return n.jsxs("div",{className:`reports-side${s?" reports-side-open":""}`,children:[l,n.jsxs("div",{className:"card",children:[n.jsx("div",{className:"card-title",children:"Proof"}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Tickets referenced"}),n.jsx("b",{children:u.ticketsReferenced.length})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Signatures valid"}),n.jsx("b",{className:x.kind==="ok"?"msg-ok":void 0,children:x.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Records checked"}),n.jsx("b",{className:j.kind==="ok"?"msg-ok":void 0,children:j.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Not verifiable"}),n.jsx("b",{children:u.unverifiableCount})]}),p.map(k=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${a===k.elementId?" reports-row-selected":""}`,onClick:()=>o(k.elementId),children:[n.jsx("span",{children:k.text}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},k.elementId))]}),n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:"Coverage"}),v.kind==="error"?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"reports-error",role:"alert",children:v.text}),n.jsx(Kh,{detail:v.detail})]}):n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Cases"}),n.jsx("b",{children:v.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Tickets in test period"}),n.jsxs("b",{children:[f.ticketsReferenced.length," of ",f.ticketsInPeriod.length]})]}),y&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:y.detail?"reports-error":"reports-note",role:y.detail?"alert":void 0,children:y.text}),n.jsx(Kh,{detail:y.detail})]}),g&&n.jsx("p",{className:"reports-missing",children:g})]}),u.verifiedValues.length>0&&n.jsxs("div",{className:"card reports-checked-values",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:"Checked values"}),u.verifiedValues.map(k=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button${a===k.elementId?" reports-row-selected":""}`,onClick:()=>o(k.elementId),title:"Show details",children:[n.jsx("span",{children:k.summary}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},k.elementId))]})]})}function gk(){const[e,s]=h.useState(null),[a,o]=h.useState(!0),[l,u]=h.useState(null),[f,p]=h.useState(!1),[g,v]=h.useState(!1),[y,x]=h.useState(null),[j,k]=h.useState(!1),[b,S]=h.useState(!1),[N,E]=ps(),T=h.useCallback(()=>L.getReport().then(({report:F})=>s(F)).catch(F=>u(F instanceof Error?F.message:String(F))),[]),P=h.useCallback(()=>{o(!0),u(null),T().finally(()=>o(!1))},[T]);h.useEffect(()=>{P()},[P]),h.useEffect(()=>{e&&L.markReportSeen(Date.now()).then(()=>window.dispatchEvent(new Event("suveren:report-seen-changed"))).catch(()=>{})},[e==null?void 0:e.savedAt]);const I=h.useCallback(()=>{p(!0),L.recheckReport().then(({report:F})=>s(F)).catch(F=>u(F instanceof Error?F.message:String(F))).finally(()=>p(!1))},[]),B=h.useCallback(async()=>{v(!0),x(null);try{await mk({exportReport:()=>L.exportReportWithProof(),download:(F,ne)=>{const fe=URL.createObjectURL(new Blob([F],{type:"text/html"})),te=document.createElement("a");te.href=fe,te.download=ne,te.click(),URL.revokeObjectURL(fe)},refresh:T})}catch(F){x(F instanceof Error?F.message:String(F))}finally{v(!1)}},[T]),O=N.get("element"),K=N.get("ticket"),z=h.useCallback((F,ne)=>{E(ak(N,F,ne))},[N,E]),U=h.useCallback(()=>{const F=new URLSearchParams(N);F.delete("element"),F.delete("ticket"),E(F,{replace:!0})},[N,E]);if(a)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(l)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(ds,{icon:"⚠",title:"Report unavailable",text:l})]});if(!e)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(ds,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const ee=Db(e.renderedHtml),X=Ub(e.elements);return n.jsx("div",{className:"page-inner reports-page",children:n.jsxs("div",{className:"reports-layout",children:[n.jsxs("div",{className:"reports-bar",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:ee}),n.jsxs("p",{className:"reports-period","data-testid":"report-period",title:Mi(e.coverage).title,children:[n.jsx("b",{children:Mi(e.coverage).text})," · written ",Em(e.savedAt,Date.now())]}),n.jsxs("p",{className:"page-subtitle",children:[X?`written by the AI under mandate ${X} · `:"","checked ",Wb(e.checkedAt)]})]}),n.jsxs("div",{className:"reports-bar-actions",children:[n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:I,disabled:f,children:f?"Checking…":"Check again"}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:B,disabled:g,children:g?"Exporting…":"Export with proof"})]})]}),y&&n.jsxs("p",{className:"reports-error",role:"alert",style:{margin:"0.5rem 0 0 0"},children:["Export failed: ",y]}),n.jsxs("div",{className:"reports-summary-chip",children:[n.jsx("span",{children:Hb(e.proof,e.coverage)}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>k(F=>!F),children:j?"hide":"details"})]}),n.jsxs("div",{className:"reports-grid",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"reports-legend",role:"note",children:[n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-v"}),Zb]}),n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-a"}),ek," (“",Xb,"”)"]}),e.renderedHtmlGloss&&n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",tk]})]}),Gh(e)&&n.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:Gh(e)}),e.renderedHtmlGloss&&n.jsxs("label",{className:"reports-gloss-switch",children:[n.jsx("input",{type:"checkbox",role:"switch",checked:b,onChange:F=>S(F.target.checked)}),n.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:n.jsx("span",{className:"reports-gloss-thumb"})}),n.jsx("span",{children:nk})]}),n.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."}),rk(e)?n.jsxs("div",{className:"note-stopped","data-testid":"report-empty",style:{padding:"var(--space-4)"},children:[n.jsx("span",{className:"msg-error",children:"Nothing in this report can be shown."})," ","Ask the AI to write it again — its own text inside an AI block, the checked values as gateway elements."]}):n.jsx("iframe",{title:"Report",sandbox:Qb,srcDoc:ck(sk(e,b)),className:"reports-iframe"})]}),n.jsx(pk,{report:e,open:j||!!O,selectedId:O,onOpenElement:F=>z(F),detail:O?n.jsx(hk,{report:e,elementId:O,ticketParam:K,onClose:U,onSelectTicket:F=>z(O,F)}):void 0})]})]})})}function ls({to:e}){const{search:s,hash:a}=Qt();return n.jsx(On,{to:`${e}${s}${a}`,replace:!0})}function yk({children:e}){const{user:s,mode:a,domain:o}=xt();return s?a==="team"&&!o?n.jsx(On,{to:"/onboarding",replace:!0}):n.jsx(n.Fragment,{children:e}):n.jsx(On,{to:"/login",replace:!0})}function vk(){const{user:e,handleSessionLocked:s,refreshGroups:a}=xt();return Fe("session-locked",o=>{const l=o==null?void 0:o.message;s(l)}),Fe("team-membership-changed",()=>{a()}),n.jsxs(Vv,{children:[n.jsx(at,{path:"/login",element:e?n.jsx(On,{to:"/",replace:!0}):n.jsx(V0,{})}),n.jsx(at,{path:"/onboarding",element:e?n.jsx(Q0,{}):n.jsx(On,{to:"/login",replace:!0})}),n.jsxs(at,{element:n.jsx(yk,{children:n.jsx(H0,{})}),children:[n.jsx(at,{path:"/",element:n.jsx(Ww,{})}),n.jsx(at,{path:"/mandates",element:n.jsx(sS,{})}),n.jsx(at,{path:"/mandates/new/intent",element:n.jsx(pj,{})}),n.jsx(at,{path:"/mandates/new/sign",element:n.jsx($j,{})}),n.jsx(at,{path:"/integrations",element:n.jsx(Bj,{})}),n.jsx(at,{path:"/team",element:n.jsx(Dj,{})}),n.jsx(at,{path:"/tickets",element:n.jsx(ob,{})}),n.jsx(at,{path:"/blocked",element:n.jsx(lb,{})}),n.jsx(at,{path:"/approvals",element:n.jsx(zb,{})}),n.jsx(at,{path:"/reports",element:n.jsx(gk,{})}),n.jsx(at,{path:"/agent/new",element:n.jsx(On,{to:"/mandates?new=1",replace:!0})}),n.jsx(at,{path:"/agent/gate",element:n.jsx(ls,{to:"/mandates/new/intent"})}),n.jsx(at,{path:"/agent/review",element:n.jsx(ls,{to:"/mandates/new/sign"})}),n.jsx(at,{path:"/authorizations",element:n.jsx(ls,{to:"/mandates"})}),n.jsx(at,{path:"/groups",element:n.jsx(ls,{to:"/team"})}),n.jsx(at,{path:"/audit",element:n.jsx(ls,{to:"/tickets"})}),n.jsx(at,{path:"/proposals",element:n.jsx(ls,{to:"/approvals"})}),n.jsx(at,{path:"/agent-brief",element:n.jsx(Bb,{})}),n.jsx(at,{path:"/settings",element:n.jsx(vb,{})}),n.jsx(at,{path:"/settings/services",element:n.jsx(On,{to:"/settings",replace:!0})}),n.jsx(at,{path:"/deploy",element:n.jsx(On,{to:"/integrations",replace:!0})})]}),n.jsx(at,{path:"*",element:n.jsx(On,{to:"/",replace:!0})})]})}function xk(){return n.jsx(gx,{children:n.jsx(Px,{children:n.jsx(Lx,{children:n.jsx(vk,{})})})})}Uy.createRoot(document.getElementById("root")).render(n.jsx(h.StrictMode,{children:n.jsx(xk,{})}));
|