@suveren/gateway 0.31.1 → 0.31.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,123 +0,0 @@
1
- var ny=Object.defineProperty;var ry=(t,s,a)=>s in t?ny(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var Ds=(t,s,a)=>ry(t,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 Il={exports:{}},Us={},Al={exports:{}},He={};/**
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 vf;function sy(){if(vf)return He;vf=1;var t=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"),g=Symbol.for("react.forward_ref"),p=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 N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,S={};function k(A,_,se){this.props=A,this.context=_,this.refs=S,this.updater=se||N}k.prototype.isReactComponent={},k.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")},k.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function E(){}E.prototype=k.prototype;function T(A,_,se){this.props=A,this.context=_,this.refs=S,this.updater=se||N}var P=T.prototype=new E;P.constructor=T,b(P,k.prototype),P.isPureReactComponent=!0;var I=Array.isArray,U=Object.prototype.hasOwnProperty,V={current:null},z={key:!0,ref:!0,__self:!0,__source:!0};function J(A,_,se){var me,O={},te=null,le=null;if(_!=null)for(me in _.ref!==void 0&&(le=_.ref),_.key!==void 0&&(te=""+_.key),_)U.call(_,me)&&!z.hasOwnProperty(me)&&(O[me]=_[me]);var pe=arguments.length-2;if(pe===1)O.children=se;else if(1<pe){for(var ge=Array(pe),ie=0;ie<pe;ie++)ge[ie]=arguments[ie+2];O.children=ge}if(A&&A.defaultProps)for(me in pe=A.defaultProps,pe)O[me]===void 0&&(O[me]=pe[me]);return{$$typeof:t,type:A,key:te,ref:le,props:O,_owner:V.current}}function Q(A,_){return{$$typeof:t,type:A.type,key:_,ref:A.ref,props:A.props,_owner:A._owner}}function ne(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function ee(A){var _={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(se){return _[se]})}var L=/\/+/g;function oe(A,_){return typeof A=="object"&&A!==null&&A.key!=null?ee(""+A.key):_.toString(36)}function de(A,_,se,me,O){var te=typeof A;(te==="undefined"||te==="boolean")&&(A=null);var le=!1;if(A===null)le=!0;else switch(te){case"string":case"number":le=!0;break;case"object":switch(A.$$typeof){case t:case s:le=!0}}if(le)return le=A,O=O(le),A=me===""?"."+oe(le,0):me,I(O)?(se="",A!=null&&(se=A.replace(L,"$&/")+"/"),de(O,_,se,"",function(ie){return ie})):O!=null&&(ne(O)&&(O=Q(O,se+(!O.key||le&&le.key===O.key?"":(""+O.key).replace(L,"$&/")+"/")+A)),_.push(O)),1;if(le=0,me=me===""?".":me+":",I(A))for(var pe=0;pe<A.length;pe++){te=A[pe];var ge=me+oe(te,pe);le+=de(te,_,se,ge,O)}else if(ge=j(A),typeof ge=="function")for(A=ge.call(A),pe=0;!(te=A.next()).done;)te=te.value,ge=me+oe(te,pe++),le+=de(te,_,se,ge,O);else if(te==="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 le}function Y(A,_,se){if(A==null)return A;var me=[],O=0;return de(A,me,"","",function(te){return _.call(se,te,O++)}),me}function je(A){if(A._status===-1){var _=A._result;_=_(),_.then(function(se){(A._status===0||A._status===-1)&&(A._status=1,A._result=se)},function(se){(A._status===0||A._status===-1)&&(A._status=2,A._result=se)}),A._status===-1&&(A._status=0,A._result=_)}if(A._status===1)return A._result.default;throw A._result}var xe={current:null},X={transition:null},q={ReactCurrentDispatcher:xe,ReactCurrentBatchConfig:X,ReactCurrentOwner:V};function G(){throw Error("act(...) is not supported in production builds of React.")}return He.Children={map:Y,forEach:function(A,_,se){Y(A,function(){_.apply(this,arguments)},se)},count:function(A){var _=0;return Y(A,function(){_++}),_},toArray:function(A){return Y(A,function(_){return _})||[]},only:function(A){if(!ne(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},He.Component=k,He.Fragment=a,He.Profiler=l,He.PureComponent=T,He.StrictMode=o,He.Suspense=p,He.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=q,He.act=G,He.cloneElement=function(A,_,se){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var me=b({},A.props),O=A.key,te=A.ref,le=A._owner;if(_!=null){if(_.ref!==void 0&&(te=_.ref,le=V.current),_.key!==void 0&&(O=""+_.key),A.type&&A.type.defaultProps)var pe=A.type.defaultProps;for(ge in _)U.call(_,ge)&&!z.hasOwnProperty(ge)&&(me[ge]=_[ge]===void 0&&pe!==void 0?pe[ge]:_[ge])}var ge=arguments.length-2;if(ge===1)me.children=se;else if(1<ge){pe=Array(ge);for(var ie=0;ie<ge;ie++)pe[ie]=arguments[ie+2];me.children=pe}return{$$typeof:t,type:A.type,key:O,ref:te,props:me,_owner:le}},He.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},He.createElement=J,He.createFactory=function(A){var _=J.bind(null,A);return _.type=A,_},He.createRef=function(){return{current:null}},He.forwardRef=function(A){return{$$typeof:g,render:A}},He.isValidElement=ne,He.lazy=function(A){return{$$typeof:y,_payload:{_status:-1,_result:A},_init:je}},He.memo=function(A,_){return{$$typeof:v,type:A,compare:_===void 0?null:_}},He.startTransition=function(A){var _=X.transition;X.transition={};try{A()}finally{X.transition=_}},He.unstable_act=G,He.useCallback=function(A,_){return xe.current.useCallback(A,_)},He.useContext=function(A){return xe.current.useContext(A)},He.useDebugValue=function(){},He.useDeferredValue=function(A){return xe.current.useDeferredValue(A)},He.useEffect=function(A,_){return xe.current.useEffect(A,_)},He.useId=function(){return xe.current.useId()},He.useImperativeHandle=function(A,_,se){return xe.current.useImperativeHandle(A,_,se)},He.useInsertionEffect=function(A,_){return xe.current.useInsertionEffect(A,_)},He.useLayoutEffect=function(A,_){return xe.current.useLayoutEffect(A,_)},He.useMemo=function(A,_){return xe.current.useMemo(A,_)},He.useReducer=function(A,_,se){return xe.current.useReducer(A,_,se)},He.useRef=function(A){return xe.current.useRef(A)},He.useState=function(A){return xe.current.useState(A)},He.useSyncExternalStore=function(A,_,se){return xe.current.useSyncExternalStore(A,_,se)},He.useTransition=function(){return xe.current.useTransition()},He.version="18.3.1",He}var xf;function lc(){return xf||(xf=1,Al.exports=sy()),Al.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 wf;function ay(){if(wf)return Us;wf=1;var t=lc(),s=Symbol.for("react.element"),a=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function f(g,p,v){var y,x={},j=null,N=null;v!==void 0&&(j=""+v),p.key!==void 0&&(j=""+p.key),p.ref!==void 0&&(N=p.ref);for(y in p)o.call(p,y)&&!u.hasOwnProperty(y)&&(x[y]=p[y]);if(g&&g.defaultProps)for(y in p=g.defaultProps,p)x[y]===void 0&&(x[y]=p[y]);return{$$typeof:s,type:g,key:j,ref:N,props:x,_owner:l.current}}return Us.Fragment=a,Us.jsx=f,Us.jsxs=f,Us}var jf;function iy(){return jf||(jf=1,Il.exports=ay()),Il.exports}var n=iy(),h=lc(),pi={},Rl={exports:{}},Wt={},Pl={exports:{}},$l={};/**
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 Sf;function oy(){return Sf||(Sf=1,(function(t){function s(X,q){var G=X.length;X.push(q);e:for(;0<G;){var A=G-1>>>1,_=X[A];if(0<l(_,q))X[A]=q,X[G]=_,G=A;else break e}}function a(X){return X.length===0?null:X[0]}function o(X){if(X.length===0)return null;var q=X[0],G=X.pop();if(G!==q){X[0]=G;e:for(var A=0,_=X.length,se=_>>>1;A<se;){var me=2*(A+1)-1,O=X[me],te=me+1,le=X[te];if(0>l(O,G))te<_&&0>l(le,O)?(X[A]=le,X[te]=G,A=te):(X[A]=O,X[me]=G,A=me);else if(te<_&&0>l(le,G))X[A]=le,X[te]=G,A=te;else break e}}return q}function l(X,q){var G=X.sortIndex-q.sortIndex;return G!==0?G:X.id-q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var f=Date,g=f.now();t.unstable_now=function(){return f.now()-g}}var p=[],v=[],y=1,x=null,j=3,N=!1,b=!1,S=!1,k=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(X){for(var q=a(v);q!==null;){if(q.callback===null)o(v);else if(q.startTime<=X)o(v),q.sortIndex=q.expirationTime,s(p,q);else break;q=a(v)}}function I(X){if(S=!1,P(X),!b)if(a(p)!==null)b=!0,je(U);else{var q=a(v);q!==null&&xe(I,q.startTime-X)}}function U(X,q){b=!1,S&&(S=!1,E(J),J=-1),N=!0;var G=j;try{for(P(q),x=a(p);x!==null&&(!(x.expirationTime>q)||X&&!ee());){var A=x.callback;if(typeof A=="function"){x.callback=null,j=x.priorityLevel;var _=A(x.expirationTime<=q);q=t.unstable_now(),typeof _=="function"?x.callback=_:x===a(p)&&o(p),P(q)}else o(p);x=a(p)}if(x!==null)var se=!0;else{var me=a(v);me!==null&&xe(I,me.startTime-q),se=!1}return se}finally{x=null,j=G,N=!1}}var V=!1,z=null,J=-1,Q=5,ne=-1;function ee(){return!(t.unstable_now()-ne<Q)}function L(){if(z!==null){var X=t.unstable_now();ne=X;var q=!0;try{q=z(!0,X)}finally{q?oe():(V=!1,z=null)}}else V=!1}var oe;if(typeof T=="function")oe=function(){T(L)};else if(typeof MessageChannel<"u"){var de=new MessageChannel,Y=de.port2;de.port1.onmessage=L,oe=function(){Y.postMessage(null)}}else oe=function(){k(L,0)};function je(X){z=X,V||(V=!0,oe())}function xe(X,q){J=k(function(){X(t.unstable_now())},q)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(X){X.callback=null},t.unstable_continueExecution=function(){b||N||(b=!0,je(U))},t.unstable_forceFrameRate=function(X){0>X||125<X?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Q=0<X?Math.floor(1e3/X):5},t.unstable_getCurrentPriorityLevel=function(){return j},t.unstable_getFirstCallbackNode=function(){return a(p)},t.unstable_next=function(X){switch(j){case 1:case 2:case 3:var q=3;break;default:q=j}var G=j;j=q;try{return X()}finally{j=G}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(X,q){switch(X){case 1:case 2:case 3:case 4:case 5:break;default:X=3}var G=j;j=X;try{return q()}finally{j=G}},t.unstable_scheduleCallback=function(X,q,G){var A=t.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?A+G:A):G=A,X){case 1:var _=-1;break;case 2:_=250;break;case 5:_=1073741823;break;case 4:_=1e4;break;default:_=5e3}return _=G+_,X={id:y++,callback:q,priorityLevel:X,startTime:G,expirationTime:_,sortIndex:-1},G>A?(X.sortIndex=G,s(v,X),a(p)===null&&X===a(v)&&(S?(E(J),J=-1):S=!0,xe(I,G-A))):(X.sortIndex=_,s(p,X),b||N||(b=!0,je(U))),X},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(X){var q=j;return function(){var G=j;j=q;try{return X.apply(this,arguments)}finally{j=G}}}})($l)),$l}var bf;function ly(){return bf||(bf=1,Pl.exports=oy()),Pl.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 kf;function cy(){if(kf)return Wt;kf=1;var t=lc(),s=ly();function a(e){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i<arguments.length;i++)r+="&args[]="+encodeURIComponent(arguments[i]);return"Minified React error #"+e+"; 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(e,r){f(e,r),f(e+"Capture",r)}function f(e,r){for(l[e]=r,e=0;e<r.length;e++)o.add(r[e])}var g=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=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(e){return p.call(x,e)?!0:p.call(y,e)?!1:v.test(e)?x[e]=!0:(y[e]=!0,!1)}function N(e,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:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function b(e,r,i,c){if(r===null||typeof r>"u"||N(e,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(e,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=e,this.type=r,this.sanitizeURL=m,this.removeEmptyString=w}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){k[e]=new S(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var r=e[0];k[r]=new S(r,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){k[e]=new S(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){k[e]=new S(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){k[e]=new S(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){k[e]=new S(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){k[e]=new S(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){k[e]=new S(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){k[e]=new S(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function T(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var r=e.replace(E,T);k[r]=new S(r,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var r=e.replace(E,T);k[r]=new S(r,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var r=e.replace(E,T);k[r]=new S(r,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){k[e]=new S(e,1,!1,e.toLowerCase(),null,!1,!1)}),k.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){k[e]=new S(e,1,!1,e.toLowerCase(),null,!0,!0)});function P(e,r,i,c){var d=k.hasOwnProperty(r)?k[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?e.removeAttribute(r):e.setAttribute(r,""+i)):d.mustUseProperty?e[d.propertyName]=i===null?d.type===3?!1:"":i:(r=d.attributeName,c=d.attributeNamespace,i===null?e.removeAttribute(r):(d=d.type,i=d===3||d===4&&i===!0?"":""+i,c?e.setAttributeNS(c,r,i):e.setAttribute(r,i))))}var I=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,U=Symbol.for("react.element"),V=Symbol.for("react.portal"),z=Symbol.for("react.fragment"),J=Symbol.for("react.strict_mode"),Q=Symbol.for("react.profiler"),ne=Symbol.for("react.provider"),ee=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),oe=Symbol.for("react.suspense"),de=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),je=Symbol.for("react.lazy"),xe=Symbol.for("react.offscreen"),X=Symbol.iterator;function q(e){return e===null||typeof e!="object"?null:(e=X&&e[X]||e["@@iterator"],typeof e=="function"?e:null)}var G=Object.assign,A;function _(e){if(A===void 0)try{throw Error()}catch(i){var r=i.stack.trim().match(/\n( *(at )?)/);A=r&&r[1]||""}return`
34
- `+A+e}var se=!1;function me(e,r){if(!e||se)return"";se=!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(W){var c=W}Reflect.construct(e,[],r)}else{try{r.call()}catch(W){c=W}e.call(r.prototype)}else{try{throw Error()}catch(W){c=W}e()}}catch(W){if(W&&c&&typeof W.stack=="string"){for(var d=W.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 e.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",e.displayName)),R}while(1<=w&&0<=C);break}}}finally{se=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?_(e):""}function O(e){switch(e.tag){case 5:return _(e.type);case 16:return _("Lazy");case 13:return _("Suspense");case 19:return _("SuspenseList");case 0:case 2:case 15:return e=me(e.type,!1),e;case 11:return e=me(e.type.render,!1),e;case 1:return e=me(e.type,!0),e;default:return""}}function te(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case z:return"Fragment";case V:return"Portal";case Q:return"Profiler";case J:return"StrictMode";case oe:return"Suspense";case de:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case ne:return(e._context.displayName||"Context")+".Provider";case L:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Y:return r=e.displayName||null,r!==null?r:te(e.type)||"Memo";case je:r=e._payload,e=e._init;try{return te(e(r))}catch{}}return null}function le(e){var r=e.type;switch(e.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 e=r.render,e=e.displayName||e.name||"",r.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return te(r);case 8:return r===J?"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(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ge(e){var r=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function ie(e){var r=ge(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,r),c=""+e[r];if(!e.hasOwnProperty(r)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var d=i.get,m=i.set;return Object.defineProperty(e,r,{configurable:!0,get:function(){return d.call(this)},set:function(w){c=""+w,m.call(this,w)}}),Object.defineProperty(e,r,{enumerable:i.enumerable}),{getValue:function(){return c},setValue:function(w){c=""+w},stopTracking:function(){e._valueTracker=null,delete e[r]}}}}function be(e){e._valueTracker||(e._valueTracker=ie(e))}function _e(e){if(!e)return!1;var r=e._valueTracker;if(!r)return!0;var i=r.getValue(),c="";return e&&(c=ge(e)?e.checked?"true":"false":e.value),e=c,e!==i?(r.setValue(e),!0):!1}function Z(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ae(e,r){var i=r.checked;return G({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Ke(e,r){var i=r.defaultValue==null?"":r.defaultValue,c=r.checked!=null?r.checked:r.defaultChecked;i=pe(r.value!=null?r.value:i),e._wrapperState={initialChecked:c,initialValue:i,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function De(e,r){r=r.checked,r!=null&&P(e,"checked",r,!1)}function Le(e,r){De(e,r);var i=pe(r.value),c=r.type;if(i!=null)c==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(c==="submit"||c==="reset"){e.removeAttribute("value");return}r.hasOwnProperty("value")?Xe(e,r.type,i):r.hasOwnProperty("defaultValue")&&Xe(e,r.type,pe(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(e.defaultChecked=!!r.defaultChecked)}function ut(e,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=""+e._wrapperState.initialValue,i||r===e.value||(e.value=r),e.defaultValue=r}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function Xe(e,r,i){(r!=="number"||Z(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var Qe=Array.isArray;function Je(e,r,i,c){if(e=e.options,r){r={};for(var d=0;d<i.length;d++)r["$"+i[d]]=!0;for(i=0;i<e.length;i++)d=r.hasOwnProperty("$"+e[i].value),e[i].selected!==d&&(e[i].selected=d),d&&c&&(e[i].defaultSelected=!0)}else{for(i=""+pe(i),r=null,d=0;d<e.length;d++){if(e[d].value===i){e[d].selected=!0,c&&(e[d].defaultSelected=!0);return}r!==null||e[d].disabled||(r=e[d])}r!==null&&(r.selected=!0)}}function wt(e,r){if(r.dangerouslySetInnerHTML!=null)throw Error(a(91));return G({},r,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function pt(e,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}e._wrapperState={initialValue:pe(i)}}function Fe(e,r){var i=pe(r.value),c=pe(r.defaultValue);i!=null&&(i=""+i,i!==e.value&&(e.value=i),r.defaultValue==null&&e.defaultValue!==i&&(e.defaultValue=i)),c!=null&&(e.defaultValue=""+c)}function he(e){var r=e.textContent;r===e._wrapperState.initialValue&&r!==""&&r!==null&&(e.value=r)}function $e(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Me(e,r){return e==null||e==="http://www.w3.org/1999/xhtml"?$e(r):e==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var H,K=(function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,i,c,d){MSApp.execUnsafeLocalFunction(function(){return e(r,i,c,d)})}:e})(function(e,r){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=r;else{for(H=H||document.createElement("div"),H.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=H.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;r.firstChild;)e.appendChild(r.firstChild)}});function ye(e,r){if(r){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=r;return}}e.textContent=r}var Ve={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(Ve).forEach(function(e){We.forEach(function(r){r=r+e.charAt(0).toUpperCase()+e.substring(1),Ve[r]=Ve[e]})});function st(e,r,i){return r==null||typeof r=="boolean"||r===""?"":i||typeof r!="number"||r===0||Ve.hasOwnProperty(e)&&Ve[e]?(""+r).trim():r+"px"}function zt(e,r){e=e.style;for(var i in r)if(r.hasOwnProperty(i)){var c=i.indexOf("--")===0,d=st(i,r[i],c);i==="float"&&(i="cssFloat"),c?e.setProperty(i,d):e[i]=d}}var Ft=G({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 B(e,r){if(r){if(Ft[e]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(a(137,e));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 ve(e,r){if(e.indexOf("-")===-1)return typeof r.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ie=null;function et(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ce=null,Ne=null,we=null;function Ue(e){if(e=Cs(e)){if(typeof ce!="function")throw Error(a(280));var r=e.stateNode;r&&(r=Aa(r),ce(e.stateNode,e.type,r))}}function Oe(e){Ne?we?we.push(e):we=[e]:Ne=e}function tt(){if(Ne){var e=Ne,r=we;if(we=Ne=null,Ue(e),r)for(e=0;e<r.length;e++)Ue(r[e])}}function Gt(e,r){return e(r)}function tr(){}var is=!1;function la(e,r,i){if(is)return e(r,i);is=!0;try{return Gt(e,r,i)}finally{is=!1,(Ne!==null||we!==null)&&(tr(),tt())}}function Sn(e,r){var i=e.stateNode;if(i===null)return null;var c=Aa(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)||(e=e.type,c=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!c;break e;default:e=!1}if(e)return null;if(i&&typeof i!="function")throw Error(a(231,r,typeof i));return i}var nr=!1;if(g)try{var rr={};Object.defineProperty(rr,"passive",{get:function(){nr=!0}}),window.addEventListener("test",rr,rr),window.removeEventListener("test",rr,rr)}catch{nr=!1}function ca(e,r,i,c,d,m,w,C,R){var W=Array.prototype.slice.call(arguments,3);try{r.apply(i,W)}catch(ae){this.onError(ae)}}var _n=!1,sr=null,ar=!1,os=null,Tr={onError:function(e){_n=!0,sr=e}};function bn(e,r,i,c,d,m,w,C,R){_n=!1,sr=null,ca.apply(Tr,arguments)}function dp(e,r,i,c,d,m,w,C,R){if(bn.apply(this,arguments),_n){if(_n){var W=sr;_n=!1,sr=null}else throw Error(a(198));ar||(ar=!0,os=W)}}function ir(e){var r=e,i=e;if(e.alternate)for(;r.return;)r=r.return;else{e=r;do r=e,(r.flags&4098)!==0&&(i=r.return),e=r.return;while(e)}return r.tag===3?i:null}function Bc(e){if(e.tag===13){var r=e.memoizedState;if(r===null&&(e=e.alternate,e!==null&&(r=e.memoizedState)),r!==null)return r.dehydrated}return null}function Dc(e){if(ir(e)!==e)throw Error(a(188))}function fp(e){var r=e.alternate;if(!r){if(r=ir(e),r===null)throw Error(a(188));return r!==e?null:e}for(var i=e,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 Dc(d),e;if(m===c)return Dc(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?e:r}function Uc(e){return e=fp(e),e!==null?Wc(e):null}function Wc(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var r=Wc(e);if(r!==null)return r;e=e.sibling}return null}var Hc=s.unstable_scheduleCallback,Vc=s.unstable_cancelCallback,hp=s.unstable_shouldYield,mp=s.unstable_requestPaint,gt=s.unstable_now,pp=s.unstable_getCurrentPriorityLevel,qi=s.unstable_ImmediatePriority,Gc=s.unstable_UserBlockingPriority,ua=s.unstable_NormalPriority,gp=s.unstable_LowPriority,Kc=s.unstable_IdlePriority,da=null,yn=null;function yp(e){if(yn&&typeof yn.onCommitFiberRoot=="function")try{yn.onCommitFiberRoot(da,e,void 0,(e.current.flags&128)===128)}catch{}}var on=Math.clz32?Math.clz32:wp,vp=Math.log,xp=Math.LN2;function wp(e){return e>>>=0,e===0?32:31-(vp(e)/xp|0)|0}var fa=64,ha=4194304;function ls(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ma(e,r){var i=e.pendingLanes;if(i===0)return 0;var c=0,d=e.suspendedLanes,m=e.pingedLanes,w=i&268435455;if(w!==0){var C=w&~d;C!==0?c=ls(C):(m&=w,m!==0&&(c=ls(m)))}else w=i&~d,w!==0?c=ls(w):m!==0&&(c=ls(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=e.entangledLanes,r!==0)for(e=e.entanglements,r&=c;0<r;)i=31-on(r),d=1<<i,c|=e[i],r&=~d;return c}function jp(e,r){switch(e){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 Sp(e,r){for(var i=e.suspendedLanes,c=e.pingedLanes,d=e.expirationTimes,m=e.pendingLanes;0<m;){var w=31-on(m),C=1<<w,R=d[w];R===-1?((C&i)===0||(C&c)!==0)&&(d[w]=jp(C,r)):R<=r&&(e.expiredLanes|=C),m&=~C}}function Yi(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function qc(){var e=fa;return fa<<=1,(fa&4194240)===0&&(fa=64),e}function Ji(e){for(var r=[],i=0;31>i;i++)r.push(e);return r}function cs(e,r,i){e.pendingLanes|=r,r!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,r=31-on(r),e[r]=i}function bp(e,r){var i=e.pendingLanes&~r;e.pendingLanes=r,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=r,e.mutableReadLanes&=r,e.entangledLanes&=r,r=e.entanglements;var c=e.eventTimes;for(e=e.expirationTimes;0<i;){var d=31-on(i),m=1<<d;r[d]=0,c[d]=-1,e[d]=-1,i&=~m}}function Qi(e,r){var i=e.entangledLanes|=r;for(e=e.entanglements;i;){var c=31-on(i),d=1<<c;d&r|e[c]&r&&(e[c]|=r),i&=~d}}var Ze=0;function Yc(e){return e&=-e,1<e?4<e?(e&268435455)!==0?16:536870912:4:1}var Jc,Xi,Qc,Xc,Zc,Zi=!1,pa=[],Ln=null,zn=null,Fn=null,us=new Map,ds=new Map,Mn=[],kp="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 eu(e,r){switch(e){case"focusin":case"focusout":Ln=null;break;case"dragenter":case"dragleave":zn=null;break;case"mouseover":case"mouseout":Fn=null;break;case"pointerover":case"pointerout":us.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":ds.delete(r.pointerId)}}function fs(e,r,i,c,d,m){return e===null||e.nativeEvent!==m?(e={blockedOn:r,domEventName:i,eventSystemFlags:c,nativeEvent:m,targetContainers:[d]},r!==null&&(r=Cs(r),r!==null&&Xi(r)),e):(e.eventSystemFlags|=c,r=e.targetContainers,d!==null&&r.indexOf(d)===-1&&r.push(d),e)}function Np(e,r,i,c,d){switch(r){case"focusin":return Ln=fs(Ln,e,r,i,c,d),!0;case"dragenter":return zn=fs(zn,e,r,i,c,d),!0;case"mouseover":return Fn=fs(Fn,e,r,i,c,d),!0;case"pointerover":var m=d.pointerId;return us.set(m,fs(us.get(m)||null,e,r,i,c,d)),!0;case"gotpointercapture":return m=d.pointerId,ds.set(m,fs(ds.get(m)||null,e,r,i,c,d)),!0}return!1}function tu(e){var r=or(e.target);if(r!==null){var i=ir(r);if(i!==null){if(r=i.tag,r===13){if(r=Bc(i),r!==null){e.blockedOn=r,Zc(e.priority,function(){Qc(i)});return}}else if(r===3&&i.stateNode.current.memoizedState.isDehydrated){e.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ga(e){if(e.blockedOn!==null)return!1;for(var r=e.targetContainers;0<r.length;){var i=to(e.domEventName,e.eventSystemFlags,r[0],e.nativeEvent);if(i===null){i=e.nativeEvent;var c=new i.constructor(i.type,i);Ie=c,i.target.dispatchEvent(c),Ie=null}else return r=Cs(i),r!==null&&Xi(r),e.blockedOn=i,!1;r.shift()}return!0}function nu(e,r,i){ga(e)&&i.delete(r)}function Cp(){Zi=!1,Ln!==null&&ga(Ln)&&(Ln=null),zn!==null&&ga(zn)&&(zn=null),Fn!==null&&ga(Fn)&&(Fn=null),us.forEach(nu),ds.forEach(nu)}function hs(e,r){e.blockedOn===r&&(e.blockedOn=null,Zi||(Zi=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Cp)))}function ms(e){function r(d){return hs(d,e)}if(0<pa.length){hs(pa[0],e);for(var i=1;i<pa.length;i++){var c=pa[i];c.blockedOn===e&&(c.blockedOn=null)}}for(Ln!==null&&hs(Ln,e),zn!==null&&hs(zn,e),Fn!==null&&hs(Fn,e),us.forEach(r),ds.forEach(r),i=0;i<Mn.length;i++)c=Mn[i],c.blockedOn===e&&(c.blockedOn=null);for(;0<Mn.length&&(i=Mn[0],i.blockedOn===null);)tu(i),i.blockedOn===null&&Mn.shift()}var Ir=I.ReactCurrentBatchConfig,ya=!0;function Ep(e,r,i,c){var d=Ze,m=Ir.transition;Ir.transition=null;try{Ze=1,eo(e,r,i,c)}finally{Ze=d,Ir.transition=m}}function Tp(e,r,i,c){var d=Ze,m=Ir.transition;Ir.transition=null;try{Ze=4,eo(e,r,i,c)}finally{Ze=d,Ir.transition=m}}function eo(e,r,i,c){if(ya){var d=to(e,r,i,c);if(d===null)xo(e,r,c,va,i),eu(e,c);else if(Np(d,e,r,i,c))c.stopPropagation();else if(eu(e,c),r&4&&-1<kp.indexOf(e)){for(;d!==null;){var m=Cs(d);if(m!==null&&Jc(m),m=to(e,r,i,c),m===null&&xo(e,r,c,va,i),m===d)break;d=m}d!==null&&c.stopPropagation()}else xo(e,r,c,null,i)}}var va=null;function to(e,r,i,c){if(va=null,e=et(c),e=or(e),e!==null)if(r=ir(e),r===null)e=null;else if(i=r.tag,i===13){if(e=Bc(r),e!==null)return e;e=null}else if(i===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;e=null}else r!==e&&(e=null);return va=e,null}function ru(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(pp()){case qi:return 1;case Gc:return 4;case ua:case gp:return 16;case Kc:return 536870912;default:return 16}default:return 16}}var On=null,no=null,xa=null;function su(){if(xa)return xa;var e,r=no,i=r.length,c,d="value"in On?On.value:On.textContent,m=d.length;for(e=0;e<i&&r[e]===d[e];e++);var w=i-e;for(c=1;c<=w&&r[i-c]===d[m-c];c++);return xa=d.slice(e,1<c?1-c:void 0)}function wa(e){var r=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&r===13&&(e=13)):e=r,e===10&&(e=13),32<=e||e===13?e:0}function ja(){return!0}function au(){return!1}function Kt(e){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 e)e.hasOwnProperty(C)&&(i=e[C],this[C]=i?i(m):m[C]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?ja:au,this.isPropagationStopped=au,this}return G(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=ja)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=ja)},persist:function(){},isPersistent:ja}),r}var Ar={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ro=Kt(Ar),ps=G({},Ar,{view:0,detail:0}),Ip=Kt(ps),so,ao,gs,Sa=G({},ps,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:oo,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==gs&&(gs&&e.type==="mousemove"?(so=e.screenX-gs.screenX,ao=e.screenY-gs.screenY):ao=so=0,gs=e),so)},movementY:function(e){return"movementY"in e?e.movementY:ao}}),iu=Kt(Sa),Ap=G({},Sa,{dataTransfer:0}),Rp=Kt(Ap),Pp=G({},ps,{relatedTarget:0}),io=Kt(Pp),$p=G({},Ar,{animationName:0,elapsedTime:0,pseudoElement:0}),_p=Kt($p),Lp=G({},Ar,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),zp=Kt(Lp),Fp=G({},Ar,{data:0}),ou=Kt(Fp),Mp={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Op={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"},Bp={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Dp(e){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(e):(e=Bp[e])?!!r[e]:!1}function oo(){return Dp}var Up=G({},ps,{key:function(e){if(e.key){var r=Mp[e.key]||e.key;if(r!=="Unidentified")return r}return e.type==="keypress"?(e=wa(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Op[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:oo,charCode:function(e){return e.type==="keypress"?wa(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?wa(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Wp=Kt(Up),Hp=G({},Sa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),lu=Kt(Hp),Vp=G({},ps,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:oo}),Gp=Kt(Vp),Kp=G({},Ar,{propertyName:0,elapsedTime:0,pseudoElement:0}),qp=Kt(Kp),Yp=G({},Sa,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Jp=Kt(Yp),Qp=[9,13,27,32],lo=g&&"CompositionEvent"in window,ys=null;g&&"documentMode"in document&&(ys=document.documentMode);var Xp=g&&"TextEvent"in window&&!ys,cu=g&&(!lo||ys&&8<ys&&11>=ys),uu=" ",du=!1;function fu(e,r){switch(e){case"keyup":return Qp.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function hu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Rr=!1;function Zp(e,r){switch(e){case"compositionend":return hu(r);case"keypress":return r.which!==32?null:(du=!0,uu);case"textInput":return e=r.data,e===uu&&du?null:e;default:return null}}function eg(e,r){if(Rr)return e==="compositionend"||!lo&&fu(e,r)?(e=su(),xa=no=On=null,Rr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return cu&&r.locale!=="ko"?null:r.data;default:return null}}var tg={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 mu(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r==="input"?!!tg[e.type]:r==="textarea"}function pu(e,r,i,c){Oe(c),r=Ea(r,"onChange"),0<r.length&&(i=new ro("onChange","change",null,i,c),e.push({event:i,listeners:r}))}var vs=null,xs=null;function ng(e){$u(e,0)}function ba(e){var r=zr(e);if(_e(r))return e}function rg(e,r){if(e==="change")return r}var gu=!1;if(g){var co;if(g){var uo="oninput"in document;if(!uo){var yu=document.createElement("div");yu.setAttribute("oninput","return;"),uo=typeof yu.oninput=="function"}co=uo}else co=!1;gu=co&&(!document.documentMode||9<document.documentMode)}function vu(){vs&&(vs.detachEvent("onpropertychange",xu),xs=vs=null)}function xu(e){if(e.propertyName==="value"&&ba(xs)){var r=[];pu(r,xs,e,et(e)),la(ng,r)}}function sg(e,r,i){e==="focusin"?(vu(),vs=r,xs=i,vs.attachEvent("onpropertychange",xu)):e==="focusout"&&vu()}function ag(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ba(xs)}function ig(e,r){if(e==="click")return ba(r)}function og(e,r){if(e==="input"||e==="change")return ba(r)}function lg(e,r){return e===r&&(e!==0||1/e===1/r)||e!==e&&r!==r}var ln=typeof Object.is=="function"?Object.is:lg;function ws(e,r){if(ln(e,r))return!0;if(typeof e!="object"||e===null||typeof r!="object"||r===null)return!1;var i=Object.keys(e),c=Object.keys(r);if(i.length!==c.length)return!1;for(c=0;c<i.length;c++){var d=i[c];if(!p.call(r,d)||!ln(e[d],r[d]))return!1}return!0}function wu(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ju(e,r){var i=wu(e);e=0;for(var c;i;){if(i.nodeType===3){if(c=e+i.textContent.length,e<=r&&c>=r)return{node:i,offset:r-e};e=c}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=wu(i)}}function Su(e,r){return e&&r?e===r?!0:e&&e.nodeType===3?!1:r&&r.nodeType===3?Su(e,r.parentNode):"contains"in e?e.contains(r):e.compareDocumentPosition?!!(e.compareDocumentPosition(r)&16):!1:!1}function bu(){for(var e=window,r=Z();r instanceof e.HTMLIFrameElement;){try{var i=typeof r.contentWindow.location.href=="string"}catch{i=!1}if(i)e=r.contentWindow;else break;r=Z(e.document)}return r}function fo(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r&&(r==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||r==="textarea"||e.contentEditable==="true")}function cg(e){var r=bu(),i=e.focusedElem,c=e.selectionRange;if(r!==i&&i&&i.ownerDocument&&Su(i.ownerDocument.documentElement,i)){if(c!==null&&fo(i)){if(r=c.start,e=c.end,e===void 0&&(e=r),"selectionStart"in i)i.selectionStart=r,i.selectionEnd=Math.min(e,i.value.length);else if(e=(r=i.ownerDocument||document)&&r.defaultView||window,e.getSelection){e=e.getSelection();var d=i.textContent.length,m=Math.min(c.start,d);c=c.end===void 0?m:Math.min(c.end,d),!e.extend&&m>c&&(d=c,c=m,m=d),d=ju(i,m);var w=ju(i,c);d&&w&&(e.rangeCount!==1||e.anchorNode!==d.node||e.anchorOffset!==d.offset||e.focusNode!==w.node||e.focusOffset!==w.offset)&&(r=r.createRange(),r.setStart(d.node,d.offset),e.removeAllRanges(),m>c?(e.addRange(r),e.extend(w.node,w.offset)):(r.setEnd(w.node,w.offset),e.addRange(r)))}}for(r=[],e=i;e=e.parentNode;)e.nodeType===1&&r.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<r.length;i++)e=r[i],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var ug=g&&"documentMode"in document&&11>=document.documentMode,Pr=null,ho=null,js=null,mo=!1;function ku(e,r,i){var c=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;mo||Pr==null||Pr!==Z(c)||(c=Pr,"selectionStart"in c&&fo(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}),js&&ws(js,c)||(js=c,c=Ea(ho,"onSelect"),0<c.length&&(r=new ro("onSelect","select",null,r,i),e.push({event:r,listeners:c}),r.target=Pr)))}function ka(e,r){var i={};return i[e.toLowerCase()]=r.toLowerCase(),i["Webkit"+e]="webkit"+r,i["Moz"+e]="moz"+r,i}var $r={animationend:ka("Animation","AnimationEnd"),animationiteration:ka("Animation","AnimationIteration"),animationstart:ka("Animation","AnimationStart"),transitionend:ka("Transition","TransitionEnd")},po={},Nu={};g&&(Nu=document.createElement("div").style,"AnimationEvent"in window||(delete $r.animationend.animation,delete $r.animationiteration.animation,delete $r.animationstart.animation),"TransitionEvent"in window||delete $r.transitionend.transition);function Na(e){if(po[e])return po[e];if(!$r[e])return e;var r=$r[e],i;for(i in r)if(r.hasOwnProperty(i)&&i in Nu)return po[e]=r[i];return e}var Cu=Na("animationend"),Eu=Na("animationiteration"),Tu=Na("animationstart"),Iu=Na("transitionend"),Au=new Map,Ru="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 Bn(e,r){Au.set(e,r),u(r,[e])}for(var go=0;go<Ru.length;go++){var yo=Ru[go],dg=yo.toLowerCase(),fg=yo[0].toUpperCase()+yo.slice(1);Bn(dg,"on"+fg)}Bn(Cu,"onAnimationEnd"),Bn(Eu,"onAnimationIteration"),Bn(Tu,"onAnimationStart"),Bn("dblclick","onDoubleClick"),Bn("focusin","onFocus"),Bn("focusout","onBlur"),Bn(Iu,"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 Ss="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(Ss));function Pu(e,r,i){var c=e.type||"unknown-event";e.currentTarget=i,dp(c,r,void 0,e),e.currentTarget=null}function $u(e,r){r=(r&4)!==0;for(var i=0;i<e.length;i++){var c=e[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,W=C.currentTarget;if(C=C.listener,R!==m&&d.isPropagationStopped())break e;Pu(d,C,W),m=R}else for(w=0;w<c.length;w++){if(C=c[w],R=C.instance,W=C.currentTarget,C=C.listener,R!==m&&d.isPropagationStopped())break e;Pu(d,C,W),m=R}}}if(ar)throw e=os,ar=!1,os=null,e}function at(e,r){var i=r[No];i===void 0&&(i=r[No]=new Set);var c=e+"__bubble";i.has(c)||(_u(r,e,2,!1),i.add(c))}function vo(e,r,i){var c=0;r&&(c|=4),_u(i,e,c,r)}var Ca="_reactListening"+Math.random().toString(36).slice(2);function bs(e){if(!e[Ca]){e[Ca]=!0,o.forEach(function(i){i!=="selectionchange"&&(hg.has(i)||vo(i,!1,e),vo(i,!0,e))});var r=e.nodeType===9?e:e.ownerDocument;r===null||r[Ca]||(r[Ca]=!0,vo("selectionchange",!1,r))}}function _u(e,r,i,c){switch(ru(r)){case 1:var d=Ep;break;case 4:d=Tp;break;default:d=eo}i=d.bind(null,r,i,e),d=void 0,!nr||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(d=!0),c?d!==void 0?e.addEventListener(r,i,{capture:!0,passive:d}):e.addEventListener(r,i,!0):d!==void 0?e.addEventListener(r,i,{passive:d}):e.addEventListener(r,i,!1)}function xo(e,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=or(C),w===null)return;if(R=w.tag,R===5||R===6){c=m=w;continue e}C=C.parentNode}}c=c.return}la(function(){var W=m,ae=et(i),ue=[];e:{var re=Au.get(e);if(re!==void 0){var Se=ro,Ce=e;switch(e){case"keypress":if(wa(i)===0)break e;case"keydown":case"keyup":Se=Wp;break;case"focusin":Ce="focus",Se=io;break;case"focusout":Ce="blur",Se=io;break;case"beforeblur":case"afterblur":Se=io;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":Se=iu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Se=Rp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Se=Gp;break;case Cu:case Eu:case Tu:Se=_p;break;case Iu:Se=qp;break;case"scroll":Se=Ip;break;case"wheel":Se=Jp;break;case"copy":case"cut":case"paste":Se=zp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Se=lu}var Ee=(r&4)!==0,yt=!Ee&&e==="scroll",M=Ee?re!==null?re+"Capture":null:re;Ee=[];for(var $=W,D;$!==null;){D=$;var fe=D.stateNode;if(D.tag===5&&fe!==null&&(D=fe,M!==null&&(fe=Sn($,M),fe!=null&&Ee.push(ks($,fe,D)))),yt)break;$=$.return}0<Ee.length&&(re=new Se(re,Ce,null,i,ae),ue.push({event:re,listeners:Ee}))}}if((r&7)===0){e:{if(re=e==="mouseover"||e==="pointerover",Se=e==="mouseout"||e==="pointerout",re&&i!==Ie&&(Ce=i.relatedTarget||i.fromElement)&&(or(Ce)||Ce[kn]))break e;if((Se||re)&&(re=ae.window===ae?ae:(re=ae.ownerDocument)?re.defaultView||re.parentWindow:window,Se?(Ce=i.relatedTarget||i.toElement,Se=W,Ce=Ce?or(Ce):null,Ce!==null&&(yt=ir(Ce),Ce!==yt||Ce.tag!==5&&Ce.tag!==6)&&(Ce=null)):(Se=null,Ce=W),Se!==Ce)){if(Ee=iu,fe="onMouseLeave",M="onMouseEnter",$="mouse",(e==="pointerout"||e==="pointerover")&&(Ee=lu,fe="onPointerLeave",M="onPointerEnter",$="pointer"),yt=Se==null?re:zr(Se),D=Ce==null?re:zr(Ce),re=new Ee(fe,$+"leave",Se,i,ae),re.target=yt,re.relatedTarget=D,fe=null,or(ae)===W&&(Ee=new Ee(M,$+"enter",Ce,i,ae),Ee.target=D,Ee.relatedTarget=yt,fe=Ee),yt=fe,Se&&Ce)t:{for(Ee=Se,M=Ce,$=0,D=Ee;D;D=_r(D))$++;for(D=0,fe=M;fe;fe=_r(fe))D++;for(;0<$-D;)Ee=_r(Ee),$--;for(;0<D-$;)M=_r(M),D--;for(;$--;){if(Ee===M||M!==null&&Ee===M.alternate)break t;Ee=_r(Ee),M=_r(M)}Ee=null}else Ee=null;Se!==null&&Lu(ue,re,Se,Ee,!1),Ce!==null&&yt!==null&&Lu(ue,yt,Ce,Ee,!0)}}e:{if(re=W?zr(W):window,Se=re.nodeName&&re.nodeName.toLowerCase(),Se==="select"||Se==="input"&&re.type==="file")var Te=rg;else if(mu(re))if(gu)Te=og;else{Te=ag;var Re=sg}else(Se=re.nodeName)&&Se.toLowerCase()==="input"&&(re.type==="checkbox"||re.type==="radio")&&(Te=ig);if(Te&&(Te=Te(e,W))){pu(ue,Te,i,ae);break e}Re&&Re(e,re,W),e==="focusout"&&(Re=re._wrapperState)&&Re.controlled&&re.type==="number"&&Xe(re,"number",re.value)}switch(Re=W?zr(W):window,e){case"focusin":(mu(Re)||Re.contentEditable==="true")&&(Pr=Re,ho=W,js=null);break;case"focusout":js=ho=Pr=null;break;case"mousedown":mo=!0;break;case"contextmenu":case"mouseup":case"dragend":mo=!1,ku(ue,i,ae);break;case"selectionchange":if(ug)break;case"keydown":case"keyup":ku(ue,i,ae)}var Pe;if(lo)e:{switch(e){case"compositionstart":var ze="onCompositionStart";break e;case"compositionend":ze="onCompositionEnd";break e;case"compositionupdate":ze="onCompositionUpdate";break e}ze=void 0}else Rr?fu(e,i)&&(ze="onCompositionEnd"):e==="keydown"&&i.keyCode===229&&(ze="onCompositionStart");ze&&(cu&&i.locale!=="ko"&&(Rr||ze!=="onCompositionStart"?ze==="onCompositionEnd"&&Rr&&(Pe=su()):(On=ae,no="value"in On?On.value:On.textContent,Rr=!0)),Re=Ea(W,ze),0<Re.length&&(ze=new ou(ze,e,null,i,ae),ue.push({event:ze,listeners:Re}),Pe?ze.data=Pe:(Pe=hu(i),Pe!==null&&(ze.data=Pe)))),(Pe=Xp?Zp(e,i):eg(e,i))&&(W=Ea(W,"onBeforeInput"),0<W.length&&(ae=new ou("onBeforeInput","beforeinput",null,i,ae),ue.push({event:ae,listeners:W}),ae.data=Pe))}$u(ue,r)})}function ks(e,r,i){return{instance:e,listener:r,currentTarget:i}}function Ea(e,r){for(var i=r+"Capture",c=[];e!==null;){var d=e,m=d.stateNode;d.tag===5&&m!==null&&(d=m,m=Sn(e,i),m!=null&&c.unshift(ks(e,m,d)),m=Sn(e,r),m!=null&&c.push(ks(e,m,d))),e=e.return}return c}function _r(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Lu(e,r,i,c,d){for(var m=r._reactName,w=[];i!==null&&i!==c;){var C=i,R=C.alternate,W=C.stateNode;if(R!==null&&R===c)break;C.tag===5&&W!==null&&(C=W,d?(R=Sn(i,m),R!=null&&w.unshift(ks(i,R,C))):d||(R=Sn(i,m),R!=null&&w.push(ks(i,R,C)))),i=i.return}w.length!==0&&e.push({event:r,listeners:w})}var mg=/\r\n?/g,pg=/\u0000|\uFFFD/g;function zu(e){return(typeof e=="string"?e:""+e).replace(mg,`
38
- `).replace(pg,"")}function Ta(e,r,i){if(r=zu(r),zu(e)!==r&&i)throw Error(a(425))}function Ia(){}var wo=null,jo=null;function So(e,r){return e==="textarea"||e==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var bo=typeof setTimeout=="function"?setTimeout:void 0,gg=typeof clearTimeout=="function"?clearTimeout:void 0,Fu=typeof Promise=="function"?Promise:void 0,yg=typeof queueMicrotask=="function"?queueMicrotask:typeof Fu<"u"?function(e){return Fu.resolve(null).then(e).catch(vg)}:bo;function vg(e){setTimeout(function(){throw e})}function ko(e,r){var i=r,c=0;do{var d=i.nextSibling;if(e.removeChild(i),d&&d.nodeType===8)if(i=d.data,i==="/$"){if(c===0){e.removeChild(d),ms(r);return}c--}else i!=="$"&&i!=="$?"&&i!=="$!"||c++;i=d}while(i);ms(r)}function Dn(e){for(;e!=null;e=e.nextSibling){var r=e.nodeType;if(r===1||r===3)break;if(r===8){if(r=e.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return e}function Mu(e){e=e.previousSibling;for(var r=0;e;){if(e.nodeType===8){var i=e.data;if(i==="$"||i==="$!"||i==="$?"){if(r===0)return e;r--}else i==="/$"&&r++}e=e.previousSibling}return null}var Lr=Math.random().toString(36).slice(2),vn="__reactFiber$"+Lr,Ns="__reactProps$"+Lr,kn="__reactContainer$"+Lr,No="__reactEvents$"+Lr,xg="__reactListeners$"+Lr,wg="__reactHandles$"+Lr;function or(e){var r=e[vn];if(r)return r;for(var i=e.parentNode;i;){if(r=i[kn]||i[vn]){if(i=r.alternate,r.child!==null||i!==null&&i.child!==null)for(e=Mu(e);e!==null;){if(i=e[vn])return i;e=Mu(e)}return r}e=i,i=e.parentNode}return null}function Cs(e){return e=e[vn]||e[kn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function zr(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(a(33))}function Aa(e){return e[Ns]||null}var Co=[],Fr=-1;function Un(e){return{current:e}}function it(e){0>Fr||(e.current=Co[Fr],Co[Fr]=null,Fr--)}function nt(e,r){Fr++,Co[Fr]=e.current,e.current=r}var Wn={},Tt=Un(Wn),Mt=Un(!1),lr=Wn;function Mr(e,r){var i=e.type.contextTypes;if(!i)return Wn;var c=e.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===r)return c.__reactInternalMemoizedMaskedChildContext;var d={},m;for(m in i)d[m]=r[m];return c&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=d),d}function Ot(e){return e=e.childContextTypes,e!=null}function Ra(){it(Mt),it(Tt)}function Ou(e,r,i){if(Tt.current!==Wn)throw Error(a(168));nt(Tt,r),nt(Mt,i)}function Bu(e,r,i){var c=e.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,le(e)||"Unknown",d));return G({},i,c)}function Pa(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Wn,lr=Tt.current,nt(Tt,e),nt(Mt,Mt.current),!0}function Du(e,r,i){var c=e.stateNode;if(!c)throw Error(a(169));i?(e=Bu(e,r,lr),c.__reactInternalMemoizedMergedChildContext=e,it(Mt),it(Tt),nt(Tt,e)):it(Mt),nt(Mt,i)}var Nn=null,$a=!1,Eo=!1;function Uu(e){Nn===null?Nn=[e]:Nn.push(e)}function jg(e){$a=!0,Uu(e)}function Hn(){if(!Eo&&Nn!==null){Eo=!0;var e=0,r=Ze;try{var i=Nn;for(Ze=1;e<i.length;e++){var c=i[e];do c=c(!0);while(c!==null)}Nn=null,$a=!1}catch(d){throw Nn!==null&&(Nn=Nn.slice(e+1)),Hc(qi,Hn),d}finally{Ze=r,Eo=!1}}return null}var Or=[],Br=0,_a=null,La=0,Xt=[],Zt=0,cr=null,Cn=1,En="";function ur(e,r){Or[Br++]=La,Or[Br++]=_a,_a=e,La=r}function Wu(e,r,i){Xt[Zt++]=Cn,Xt[Zt++]=En,Xt[Zt++]=cr,cr=e;var c=Cn;e=En;var d=32-on(c)-1;c&=~(1<<d),i+=1;var m=32-on(r)+d;if(30<m){var w=d-d%5;m=(c&(1<<w)-1).toString(32),c>>=w,d-=w,Cn=1<<32-on(r)+d|i<<d|c,En=m+e}else Cn=1<<m|i<<d|c,En=e}function To(e){e.return!==null&&(ur(e,1),Wu(e,1,0))}function Io(e){for(;e===_a;)_a=Or[--Br],Or[Br]=null,La=Or[--Br],Or[Br]=null;for(;e===cr;)cr=Xt[--Zt],Xt[Zt]=null,En=Xt[--Zt],Xt[Zt]=null,Cn=Xt[--Zt],Xt[Zt]=null}var qt=null,Yt=null,ot=!1,cn=null;function Hu(e,r){var i=rn(5,null,null,0);i.elementType="DELETED",i.stateNode=r,i.return=e,r=e.deletions,r===null?(e.deletions=[i],e.flags|=16):r.push(i)}function Vu(e,r){switch(e.tag){case 5:var i=e.type;return r=r.nodeType!==1||i.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(e.stateNode=r,qt=e,Yt=Dn(r.firstChild),!0):!1;case 6:return r=e.pendingProps===""||r.nodeType!==3?null:r,r!==null?(e.stateNode=r,qt=e,Yt=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(i=cr!==null?{id:Cn,overflow:En}:null,e.memoizedState={dehydrated:r,treeContext:i,retryLane:1073741824},i=rn(18,null,null,0),i.stateNode=r,i.return=e,e.child=i,qt=e,Yt=null,!0):!1;default:return!1}}function Ao(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Ro(e){if(ot){var r=Yt;if(r){var i=r;if(!Vu(e,r)){if(Ao(e))throw Error(a(418));r=Dn(i.nextSibling);var c=qt;r&&Vu(e,r)?Hu(c,i):(e.flags=e.flags&-4097|2,ot=!1,qt=e)}}else{if(Ao(e))throw Error(a(418));e.flags=e.flags&-4097|2,ot=!1,qt=e}}}function Gu(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;qt=e}function za(e){if(e!==qt)return!1;if(!ot)return Gu(e),ot=!0,!1;var r;if((r=e.tag!==3)&&!(r=e.tag!==5)&&(r=e.type,r=r!=="head"&&r!=="body"&&!So(e.type,e.memoizedProps)),r&&(r=Yt)){if(Ao(e))throw Ku(),Error(a(418));for(;r;)Hu(e,r),r=Dn(r.nextSibling)}if(Gu(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));e:{for(e=e.nextSibling,r=0;e;){if(e.nodeType===8){var i=e.data;if(i==="/$"){if(r===0){Yt=Dn(e.nextSibling);break e}r--}else i!=="$"&&i!=="$!"&&i!=="$?"||r++}e=e.nextSibling}Yt=null}}else Yt=qt?Dn(e.stateNode.nextSibling):null;return!0}function Ku(){for(var e=Yt;e;)e=Dn(e.nextSibling)}function Dr(){Yt=qt=null,ot=!1}function Po(e){cn===null?cn=[e]:cn.push(e)}var Sg=I.ReactCurrentBatchConfig;function Es(e,r,i){if(e=i.ref,e!==null&&typeof e!="function"&&typeof e!="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,e));var d=c,m=""+e;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 e!="string")throw Error(a(284));if(!i._owner)throw Error(a(290,e))}return e}function Fa(e,r){throw e=Object.prototype.toString.call(r),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":e))}function qu(e){var r=e._init;return r(e._payload)}function Yu(e){function r(M,$){if(e){var D=M.deletions;D===null?(M.deletions=[$],M.flags|=16):D.push($)}}function i(M,$){if(!e)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=Xn(M,$),M.index=0,M.sibling=null,M}function m(M,$,D){return M.index=D,e?(D=M.alternate,D!==null?(D=D.index,D<$?(M.flags|=2,$):D):(M.flags|=2,$)):(M.flags|=1048576,$)}function w(M){return e&&M.alternate===null&&(M.flags|=2),M}function C(M,$,D,fe){return $===null||$.tag!==6?($=bl(D,M.mode,fe),$.return=M,$):($=d($,D),$.return=M,$)}function R(M,$,D,fe){var Te=D.type;return Te===z?ae(M,$,D.props.children,fe,D.key):$!==null&&($.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===je&&qu(Te)===$.type)?(fe=d($,D.props),fe.ref=Es(M,$,D),fe.return=M,fe):(fe=oi(D.type,D.key,D.props,null,M.mode,fe),fe.ref=Es(M,$,D),fe.return=M,fe)}function W(M,$,D,fe){return $===null||$.tag!==4||$.stateNode.containerInfo!==D.containerInfo||$.stateNode.implementation!==D.implementation?($=kl(D,M.mode,fe),$.return=M,$):($=d($,D.children||[]),$.return=M,$)}function ae(M,$,D,fe,Te){return $===null||$.tag!==7?($=vr(D,M.mode,fe,Te),$.return=M,$):($=d($,D),$.return=M,$)}function ue(M,$,D){if(typeof $=="string"&&$!==""||typeof $=="number")return $=bl(""+$,M.mode,D),$.return=M,$;if(typeof $=="object"&&$!==null){switch($.$$typeof){case U:return D=oi($.type,$.key,$.props,null,M.mode,D),D.ref=Es(M,null,$),D.return=M,D;case V:return $=kl($,M.mode,D),$.return=M,$;case je:var fe=$._init;return ue(M,fe($._payload),D)}if(Qe($)||q($))return $=vr($,M.mode,D,null),$.return=M,$;Fa(M,$)}return null}function re(M,$,D,fe){var Te=$!==null?$.key:null;if(typeof D=="string"&&D!==""||typeof D=="number")return Te!==null?null:C(M,$,""+D,fe);if(typeof D=="object"&&D!==null){switch(D.$$typeof){case U:return D.key===Te?R(M,$,D,fe):null;case V:return D.key===Te?W(M,$,D,fe):null;case je:return Te=D._init,re(M,$,Te(D._payload),fe)}if(Qe(D)||q(D))return Te!==null?null:ae(M,$,D,fe,null);Fa(M,D)}return null}function Se(M,$,D,fe,Te){if(typeof fe=="string"&&fe!==""||typeof fe=="number")return M=M.get(D)||null,C($,M,""+fe,Te);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case U:return M=M.get(fe.key===null?D:fe.key)||null,R($,M,fe,Te);case V:return M=M.get(fe.key===null?D:fe.key)||null,W($,M,fe,Te);case je:var Re=fe._init;return Se(M,$,D,Re(fe._payload),Te)}if(Qe(fe)||q(fe))return M=M.get(D)||null,ae($,M,fe,Te,null);Fa($,fe)}return null}function Ce(M,$,D,fe){for(var Te=null,Re=null,Pe=$,ze=$=0,Nt=null;Pe!==null&&ze<D.length;ze++){Pe.index>ze?(Nt=Pe,Pe=null):Nt=Pe.sibling;var Ye=re(M,Pe,D[ze],fe);if(Ye===null){Pe===null&&(Pe=Nt);break}e&&Pe&&Ye.alternate===null&&r(M,Pe),$=m(Ye,$,ze),Re===null?Te=Ye:Re.sibling=Ye,Re=Ye,Pe=Nt}if(ze===D.length)return i(M,Pe),ot&&ur(M,ze),Te;if(Pe===null){for(;ze<D.length;ze++)Pe=ue(M,D[ze],fe),Pe!==null&&($=m(Pe,$,ze),Re===null?Te=Pe:Re.sibling=Pe,Re=Pe);return ot&&ur(M,ze),Te}for(Pe=c(M,Pe);ze<D.length;ze++)Nt=Se(Pe,M,ze,D[ze],fe),Nt!==null&&(e&&Nt.alternate!==null&&Pe.delete(Nt.key===null?ze:Nt.key),$=m(Nt,$,ze),Re===null?Te=Nt:Re.sibling=Nt,Re=Nt);return e&&Pe.forEach(function(Zn){return r(M,Zn)}),ot&&ur(M,ze),Te}function Ee(M,$,D,fe){var Te=q(D);if(typeof Te!="function")throw Error(a(150));if(D=Te.call(D),D==null)throw Error(a(151));for(var Re=Te=null,Pe=$,ze=$=0,Nt=null,Ye=D.next();Pe!==null&&!Ye.done;ze++,Ye=D.next()){Pe.index>ze?(Nt=Pe,Pe=null):Nt=Pe.sibling;var Zn=re(M,Pe,Ye.value,fe);if(Zn===null){Pe===null&&(Pe=Nt);break}e&&Pe&&Zn.alternate===null&&r(M,Pe),$=m(Zn,$,ze),Re===null?Te=Zn:Re.sibling=Zn,Re=Zn,Pe=Nt}if(Ye.done)return i(M,Pe),ot&&ur(M,ze),Te;if(Pe===null){for(;!Ye.done;ze++,Ye=D.next())Ye=ue(M,Ye.value,fe),Ye!==null&&($=m(Ye,$,ze),Re===null?Te=Ye:Re.sibling=Ye,Re=Ye);return ot&&ur(M,ze),Te}for(Pe=c(M,Pe);!Ye.done;ze++,Ye=D.next())Ye=Se(Pe,M,ze,Ye.value,fe),Ye!==null&&(e&&Ye.alternate!==null&&Pe.delete(Ye.key===null?ze:Ye.key),$=m(Ye,$,ze),Re===null?Te=Ye:Re.sibling=Ye,Re=Ye);return e&&Pe.forEach(function(ty){return r(M,ty)}),ot&&ur(M,ze),Te}function yt(M,$,D,fe){if(typeof D=="object"&&D!==null&&D.type===z&&D.key===null&&(D=D.props.children),typeof D=="object"&&D!==null){switch(D.$$typeof){case U:e:{for(var Te=D.key,Re=$;Re!==null;){if(Re.key===Te){if(Te=D.type,Te===z){if(Re.tag===7){i(M,Re.sibling),$=d(Re,D.props.children),$.return=M,M=$;break e}}else if(Re.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===je&&qu(Te)===Re.type){i(M,Re.sibling),$=d(Re,D.props),$.ref=Es(M,Re,D),$.return=M,M=$;break e}i(M,Re);break}else r(M,Re);Re=Re.sibling}D.type===z?($=vr(D.props.children,M.mode,fe,D.key),$.return=M,M=$):(fe=oi(D.type,D.key,D.props,null,M.mode,fe),fe.ref=Es(M,$,D),fe.return=M,M=fe)}return w(M);case V: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}$=kl(D,M.mode,fe),$.return=M,M=$}return w(M);case je:return Re=D._init,yt(M,$,Re(D._payload),fe)}if(Qe(D))return Ce(M,$,D,fe);if(q(D))return Ee(M,$,D,fe);Fa(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,$),$=bl(D,M.mode,fe),$.return=M,M=$),w(M)):i(M,$)}return yt}var Ur=Yu(!0),Ju=Yu(!1),Ma=Un(null),Oa=null,Wr=null,$o=null;function _o(){$o=Wr=Oa=null}function Lo(e){var r=Ma.current;it(Ma),e._currentValue=r}function zo(e,r,i){for(;e!==null;){var c=e.alternate;if((e.childLanes&r)!==r?(e.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),e===i)break;e=e.return}}function Hr(e,r){Oa=e,$o=Wr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&r)!==0&&(Bt=!0),e.firstContext=null)}function en(e){var r=e._currentValue;if($o!==e)if(e={context:e,memoizedValue:r,next:null},Wr===null){if(Oa===null)throw Error(a(308));Wr=e,Oa.dependencies={lanes:0,firstContext:e}}else Wr=Wr.next=e;return r}var dr=null;function Fo(e){dr===null?dr=[e]:dr.push(e)}function Qu(e,r,i,c){var d=r.interleaved;return d===null?(i.next=i,Fo(r)):(i.next=d.next,d.next=i),r.interleaved=i,Tn(e,c)}function Tn(e,r){e.lanes|=r;var i=e.alternate;for(i!==null&&(i.lanes|=r),i=e,e=e.return;e!==null;)e.childLanes|=r,i=e.alternate,i!==null&&(i.childLanes|=r),i=e,e=e.return;return i.tag===3?i.stateNode:null}var Vn=!1;function Mo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Xu(e,r){e=e.updateQueue,r.updateQueue===e&&(r.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function In(e,r){return{eventTime:e,lane:r,tag:0,payload:null,callback:null,next:null}}function Gn(e,r,i){var c=e.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,Tn(e,i)}return d=c.interleaved,d===null?(r.next=r,Fo(c)):(r.next=d.next,d.next=r),c.interleaved=r,Tn(e,i)}function Ba(e,r,i){if(r=r.updateQueue,r!==null&&(r=r.shared,(i&4194240)!==0)){var c=r.lanes;c&=e.pendingLanes,i|=c,r.lanes=i,Qi(e,i)}}function Zu(e,r){var i=e.updateQueue,c=e.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},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=r:e.next=r,i.lastBaseUpdate=r}function Da(e,r,i,c){var d=e.updateQueue;Vn=!1;var m=d.firstBaseUpdate,w=d.lastBaseUpdate,C=d.shared.pending;if(C!==null){d.shared.pending=null;var R=C,W=R.next;R.next=null,w===null?m=W:w.next=W,w=R;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,C=ae.lastBaseUpdate,C!==w&&(C===null?ae.firstBaseUpdate=W:C.next=W,ae.lastBaseUpdate=R))}if(m!==null){var ue=d.baseState;w=0,ae=W=R=null,C=m;do{var re=C.lane,Se=C.eventTime;if((c&re)===re){ae!==null&&(ae=ae.next={eventTime:Se,lane:0,tag:C.tag,payload:C.payload,callback:C.callback,next:null});e:{var Ce=e,Ee=C;switch(re=r,Se=i,Ee.tag){case 1:if(Ce=Ee.payload,typeof Ce=="function"){ue=Ce.call(Se,ue,re);break e}ue=Ce;break e;case 3:Ce.flags=Ce.flags&-65537|128;case 0:if(Ce=Ee.payload,re=typeof Ce=="function"?Ce.call(Se,ue,re):Ce,re==null)break e;ue=G({},ue,re);break e;case 2:Vn=!0}}C.callback!==null&&C.lane!==0&&(e.flags|=64,re=d.effects,re===null?d.effects=[C]:re.push(C))}else Se={eventTime:Se,lane:re,tag:C.tag,payload:C.payload,callback:C.callback,next:null},ae===null?(W=ae=Se,R=ue):ae=ae.next=Se,w|=re;if(C=C.next,C===null){if(C=d.shared.pending,C===null)break;re=C,C=re.next,re.next=null,d.lastBaseUpdate=re,d.shared.pending=null}}while(!0);if(ae===null&&(R=ue),d.baseState=R,d.firstBaseUpdate=W,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);mr|=w,e.lanes=w,e.memoizedState=ue}}function ed(e,r,i){if(e=r.effects,r.effects=null,e!==null)for(r=0;r<e.length;r++){var c=e[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 Ts={},xn=Un(Ts),Is=Un(Ts),As=Un(Ts);function fr(e){if(e===Ts)throw Error(a(174));return e}function Oo(e,r){switch(nt(As,r),nt(Is,e),nt(xn,Ts),e=r.nodeType,e){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Me(null,"");break;default:e=e===8?r.parentNode:r,r=e.namespaceURI||null,e=e.tagName,r=Me(r,e)}it(xn),nt(xn,r)}function Vr(){it(xn),it(Is),it(As)}function td(e){fr(As.current);var r=fr(xn.current),i=Me(r,e.type);r!==i&&(nt(Is,e),nt(xn,i))}function Bo(e){Is.current===e&&(it(xn),it(Is))}var dt=Un(0);function Ua(e){for(var r=e;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===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Do=[];function Uo(){for(var e=0;e<Do.length;e++)Do[e]._workInProgressVersionPrimary=null;Do.length=0}var Wa=I.ReactCurrentDispatcher,Wo=I.ReactCurrentBatchConfig,hr=0,ft=null,jt=null,bt=null,Ha=!1,Rs=!1,Ps=0,bg=0;function It(){throw Error(a(321))}function Ho(e,r){if(r===null)return!1;for(var i=0;i<r.length&&i<e.length;i++)if(!ln(e[i],r[i]))return!1;return!0}function Vo(e,r,i,c,d,m){if(hr=m,ft=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Wa.current=e===null||e.memoizedState===null?Eg:Tg,e=i(c,d),Rs){m=0;do{if(Rs=!1,Ps=0,25<=m)throw Error(a(301));m+=1,bt=jt=null,r.updateQueue=null,Wa.current=Ig,e=i(c,d)}while(Rs)}if(Wa.current=Ka,r=jt!==null&&jt.next!==null,hr=0,bt=jt=ft=null,Ha=!1,r)throw Error(a(300));return e}function Go(){var e=Ps!==0;return Ps=0,e}function wn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return bt===null?ft.memoizedState=bt=e:bt=bt.next=e,bt}function tn(){if(jt===null){var e=ft.alternate;e=e!==null?e.memoizedState:null}else e=jt.next;var r=bt===null?ft.memoizedState:bt.next;if(r!==null)bt=r,jt=e;else{if(e===null)throw Error(a(310));jt=e,e={memoizedState:jt.memoizedState,baseState:jt.baseState,baseQueue:jt.baseQueue,queue:jt.queue,next:null},bt===null?ft.memoizedState=bt=e:bt=bt.next=e}return bt}function $s(e,r){return typeof r=="function"?r(e):r}function Ko(e){var r=tn(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=e;var c=jt,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,W=m;do{var ae=W.lane;if((hr&ae)===ae)R!==null&&(R=R.next={lane:0,action:W.action,hasEagerState:W.hasEagerState,eagerState:W.eagerState,next:null}),c=W.hasEagerState?W.eagerState:e(c,W.action);else{var ue={lane:ae,action:W.action,hasEagerState:W.hasEagerState,eagerState:W.eagerState,next:null};R===null?(C=R=ue,w=c):R=R.next=ue,ft.lanes|=ae,mr|=ae}W=W.next}while(W!==null&&W!==m);R===null?w=c:R.next=C,ln(c,r.memoizedState)||(Bt=!0),r.memoizedState=c,r.baseState=w,r.baseQueue=R,i.lastRenderedState=c}if(e=i.interleaved,e!==null){d=e;do m=d.lane,ft.lanes|=m,mr|=m,d=d.next;while(d!==e)}else d===null&&(i.lanes=0);return[r.memoizedState,i.dispatch]}function qo(e){var r=tn(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=e;var c=i.dispatch,d=i.pending,m=r.memoizedState;if(d!==null){i.pending=null;var w=d=d.next;do m=e(m,w.action),w=w.next;while(w!==d);ln(m,r.memoizedState)||(Bt=!0),r.memoizedState=m,r.baseQueue===null&&(r.baseState=m),i.lastRenderedState=m}return[m,c]}function nd(){}function rd(e,r){var i=ft,c=tn(),d=r(),m=!ln(c.memoizedState,d);if(m&&(c.memoizedState=d,Bt=!0),c=c.queue,Yo(id.bind(null,i,c,e),[e]),c.getSnapshot!==r||m||bt!==null&&bt.memoizedState.tag&1){if(i.flags|=2048,_s(9,ad.bind(null,i,c,d,r),void 0,null),kt===null)throw Error(a(349));(hr&30)!==0||sd(i,r,d)}return d}function sd(e,r,i){e.flags|=16384,e={getSnapshot:r,value:i},r=ft.updateQueue,r===null?(r={lastEffect:null,stores:null},ft.updateQueue=r,r.stores=[e]):(i=r.stores,i===null?r.stores=[e]:i.push(e))}function ad(e,r,i,c){r.value=i,r.getSnapshot=c,od(r)&&ld(e)}function id(e,r,i){return i(function(){od(r)&&ld(e)})}function od(e){var r=e.getSnapshot;e=e.value;try{var i=r();return!ln(e,i)}catch{return!0}}function ld(e){var r=Tn(e,1);r!==null&&hn(r,e,1,-1)}function cd(e){var r=wn();return typeof e=="function"&&(e=e()),r.memoizedState=r.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:$s,lastRenderedState:e},r.queue=e,e=e.dispatch=Cg.bind(null,ft,e),[r.memoizedState,e]}function _s(e,r,i,c){return e={tag:e,create:r,destroy:i,deps:c,next:null},r=ft.updateQueue,r===null?(r={lastEffect:null,stores:null},ft.updateQueue=r,r.lastEffect=e.next=e):(i=r.lastEffect,i===null?r.lastEffect=e.next=e:(c=i.next,i.next=e,e.next=c,r.lastEffect=e)),e}function ud(){return tn().memoizedState}function Va(e,r,i,c){var d=wn();ft.flags|=e,d.memoizedState=_s(1|r,i,void 0,c===void 0?null:c)}function Ga(e,r,i,c){var d=tn();c=c===void 0?null:c;var m=void 0;if(jt!==null){var w=jt.memoizedState;if(m=w.destroy,c!==null&&Ho(c,w.deps)){d.memoizedState=_s(r,i,m,c);return}}ft.flags|=e,d.memoizedState=_s(1|r,i,m,c)}function dd(e,r){return Va(8390656,8,e,r)}function Yo(e,r){return Ga(2048,8,e,r)}function fd(e,r){return Ga(4,2,e,r)}function hd(e,r){return Ga(4,4,e,r)}function md(e,r){if(typeof r=="function")return e=e(),r(e),function(){r(null)};if(r!=null)return e=e(),r.current=e,function(){r.current=null}}function pd(e,r,i){return i=i!=null?i.concat([e]):null,Ga(4,4,md.bind(null,r,e),i)}function Jo(){}function gd(e,r){var i=tn();r=r===void 0?null:r;var c=i.memoizedState;return c!==null&&r!==null&&Ho(r,c[1])?c[0]:(i.memoizedState=[e,r],e)}function yd(e,r){var i=tn();r=r===void 0?null:r;var c=i.memoizedState;return c!==null&&r!==null&&Ho(r,c[1])?c[0]:(e=e(),i.memoizedState=[e,r],e)}function vd(e,r,i){return(hr&21)===0?(e.baseState&&(e.baseState=!1,Bt=!0),e.memoizedState=i):(ln(i,r)||(i=qc(),ft.lanes|=i,mr|=i,e.baseState=!0),r)}function kg(e,r){var i=Ze;Ze=i!==0&&4>i?i:4,e(!0);var c=Wo.transition;Wo.transition={};try{e(!1),r()}finally{Ze=i,Wo.transition=c}}function xd(){return tn().memoizedState}function Ng(e,r,i){var c=Jn(e);if(i={lane:c,action:i,hasEagerState:!1,eagerState:null,next:null},wd(e))jd(r,i);else if(i=Qu(e,r,i,c),i!==null){var d=$t();hn(i,e,c,d),Sd(i,r,c)}}function Cg(e,r,i){var c=Jn(e),d={lane:c,action:i,hasEagerState:!1,eagerState:null,next:null};if(wd(e))jd(r,d);else{var m=e.alternate;if(e.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,ln(C,w)){var R=r.interleaved;R===null?(d.next=d,Fo(r)):(d.next=R.next,R.next=d),r.interleaved=d;return}}catch{}finally{}i=Qu(e,r,d,c),i!==null&&(d=$t(),hn(i,e,c,d),Sd(i,r,c))}}function wd(e){var r=e.alternate;return e===ft||r!==null&&r===ft}function jd(e,r){Rs=Ha=!0;var i=e.pending;i===null?r.next=r:(r.next=i.next,i.next=r),e.pending=r}function Sd(e,r,i){if((i&4194240)!==0){var c=r.lanes;c&=e.pendingLanes,i|=c,r.lanes=i,Qi(e,i)}}var Ka={readContext:en,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useInsertionEffect:It,useLayoutEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useMutableSource:It,useSyncExternalStore:It,useId:It,unstable_isNewReconciler:!1},Eg={readContext:en,useCallback:function(e,r){return wn().memoizedState=[e,r===void 0?null:r],e},useContext:en,useEffect:dd,useImperativeHandle:function(e,r,i){return i=i!=null?i.concat([e]):null,Va(4194308,4,md.bind(null,r,e),i)},useLayoutEffect:function(e,r){return Va(4194308,4,e,r)},useInsertionEffect:function(e,r){return Va(4,2,e,r)},useMemo:function(e,r){var i=wn();return r=r===void 0?null:r,e=e(),i.memoizedState=[e,r],e},useReducer:function(e,r,i){var c=wn();return r=i!==void 0?i(r):r,c.memoizedState=c.baseState=r,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},c.queue=e,e=e.dispatch=Ng.bind(null,ft,e),[c.memoizedState,e]},useRef:function(e){var r=wn();return e={current:e},r.memoizedState=e},useState:cd,useDebugValue:Jo,useDeferredValue:function(e){return wn().memoizedState=e},useTransition:function(){var e=cd(!1),r=e[0];return e=kg.bind(null,e[1]),wn().memoizedState=e,[r,e]},useMutableSource:function(){},useSyncExternalStore:function(e,r,i){var c=ft,d=wn();if(ot){if(i===void 0)throw Error(a(407));i=i()}else{if(i=r(),kt===null)throw Error(a(349));(hr&30)!==0||sd(c,r,i)}d.memoizedState=i;var m={value:i,getSnapshot:r};return d.queue=m,dd(id.bind(null,c,m,e),[e]),c.flags|=2048,_s(9,ad.bind(null,c,m,i,r),void 0,null),i},useId:function(){var e=wn(),r=kt.identifierPrefix;if(ot){var i=En,c=Cn;i=(c&~(1<<32-on(c)-1)).toString(32)+i,r=":"+r+"R"+i,i=Ps++,0<i&&(r+="H"+i.toString(32)),r+=":"}else i=bg++,r=":"+r+"r"+i.toString(32)+":";return e.memoizedState=r},unstable_isNewReconciler:!1},Tg={readContext:en,useCallback:gd,useContext:en,useEffect:Yo,useImperativeHandle:pd,useInsertionEffect:fd,useLayoutEffect:hd,useMemo:yd,useReducer:Ko,useRef:ud,useState:function(){return Ko($s)},useDebugValue:Jo,useDeferredValue:function(e){var r=tn();return vd(r,jt.memoizedState,e)},useTransition:function(){var e=Ko($s)[0],r=tn().memoizedState;return[e,r]},useMutableSource:nd,useSyncExternalStore:rd,useId:xd,unstable_isNewReconciler:!1},Ig={readContext:en,useCallback:gd,useContext:en,useEffect:Yo,useImperativeHandle:pd,useInsertionEffect:fd,useLayoutEffect:hd,useMemo:yd,useReducer:qo,useRef:ud,useState:function(){return qo($s)},useDebugValue:Jo,useDeferredValue:function(e){var r=tn();return jt===null?r.memoizedState=e:vd(r,jt.memoizedState,e)},useTransition:function(){var e=qo($s)[0],r=tn().memoizedState;return[e,r]},useMutableSource:nd,useSyncExternalStore:rd,useId:xd,unstable_isNewReconciler:!1};function un(e,r){if(e&&e.defaultProps){r=G({},r),e=e.defaultProps;for(var i in e)r[i]===void 0&&(r[i]=e[i]);return r}return r}function Qo(e,r,i,c){r=e.memoizedState,i=i(c,r),i=i==null?r:G({},r,i),e.memoizedState=i,e.lanes===0&&(e.updateQueue.baseState=i)}var qa={isMounted:function(e){return(e=e._reactInternals)?ir(e)===e:!1},enqueueSetState:function(e,r,i){e=e._reactInternals;var c=$t(),d=Jn(e),m=In(c,d);m.payload=r,i!=null&&(m.callback=i),r=Gn(e,m,d),r!==null&&(hn(r,e,d,c),Ba(r,e,d))},enqueueReplaceState:function(e,r,i){e=e._reactInternals;var c=$t(),d=Jn(e),m=In(c,d);m.tag=1,m.payload=r,i!=null&&(m.callback=i),r=Gn(e,m,d),r!==null&&(hn(r,e,d,c),Ba(r,e,d))},enqueueForceUpdate:function(e,r){e=e._reactInternals;var i=$t(),c=Jn(e),d=In(i,c);d.tag=2,r!=null&&(d.callback=r),r=Gn(e,d,c),r!==null&&(hn(r,e,c,i),Ba(r,e,c))}};function bd(e,r,i,c,d,m,w){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(c,m,w):r.prototype&&r.prototype.isPureReactComponent?!ws(i,c)||!ws(d,m):!0}function kd(e,r,i){var c=!1,d=Wn,m=r.contextType;return typeof m=="object"&&m!==null?m=en(m):(d=Ot(r)?lr:Tt.current,c=r.contextTypes,m=(c=c!=null)?Mr(e,d):Wn),r=new r(i,m),e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=qa,e.stateNode=r,r._reactInternals=e,c&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=d,e.__reactInternalMemoizedMaskedChildContext=m),r}function Nd(e,r,i,c){e=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(i,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(i,c),r.state!==e&&qa.enqueueReplaceState(r,r.state,null)}function Xo(e,r,i,c){var d=e.stateNode;d.props=i,d.state=e.memoizedState,d.refs={},Mo(e);var m=r.contextType;typeof m=="object"&&m!==null?d.context=en(m):(m=Ot(r)?lr:Tt.current,d.context=Mr(e,m)),d.state=e.memoizedState,m=r.getDerivedStateFromProps,typeof m=="function"&&(Qo(e,r,m,i),d.state=e.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&&qa.enqueueReplaceState(d,d.state,null),Da(e,i,d,c),d.state=e.memoizedState),typeof d.componentDidMount=="function"&&(e.flags|=4194308)}function Gr(e,r){try{var i="",c=r;do i+=O(c),c=c.return;while(c);var d=i}catch(m){d=`
39
- Error generating stack: `+m.message+`
40
- `+m.stack}return{value:e,source:r,stack:d,digest:null}}function Zo(e,r,i){return{value:e,source:null,stack:i??null,digest:r??null}}function el(e,r){try{console.error(r.value)}catch(i){setTimeout(function(){throw i})}}var Ag=typeof WeakMap=="function"?WeakMap:Map;function Cd(e,r,i){i=In(-1,i),i.tag=3,i.payload={element:null};var c=r.value;return i.callback=function(){ti||(ti=!0,pl=c),el(e,r)},i}function Ed(e,r,i){i=In(-1,i),i.tag=3;var c=e.type.getDerivedStateFromError;if(typeof c=="function"){var d=r.value;i.payload=function(){return c(d)},i.callback=function(){el(e,r)}}var m=e.stateNode;return m!==null&&typeof m.componentDidCatch=="function"&&(i.callback=function(){el(e,r),typeof c!="function"&&(qn===null?qn=new Set([this]):qn.add(this));var w=r.stack;this.componentDidCatch(r.value,{componentStack:w!==null?w:""})}),i}function Td(e,r,i){var c=e.pingCache;if(c===null){c=e.pingCache=new Ag;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),e=Hg.bind(null,e,r,i),r.then(e,e))}function Id(e){do{var r;if((r=e.tag===13)&&(r=e.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return e;e=e.return}while(e!==null);return null}function Ad(e,r,i,c,d){return(e.mode&1)===0?(e===r?e.flags|=65536:(e.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(r=In(-1,1),r.tag=2,Gn(i,r,1))),i.lanes|=1),e):(e.flags|=65536,e.lanes=d,e)}var Rg=I.ReactCurrentOwner,Bt=!1;function Pt(e,r,i,c){r.child=e===null?Ju(r,null,i,c):Ur(r,e.child,i,c)}function Rd(e,r,i,c,d){i=i.render;var m=r.ref;return Hr(r,d),c=Vo(e,r,i,c,m,d),i=Go(),e!==null&&!Bt?(r.updateQueue=e.updateQueue,r.flags&=-2053,e.lanes&=~d,An(e,r,d)):(ot&&i&&To(r),r.flags|=1,Pt(e,r,c,d),r.child)}function Pd(e,r,i,c,d){if(e===null){var m=i.type;return typeof m=="function"&&!Sl(m)&&m.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(r.tag=15,r.type=m,$d(e,r,m,c,d)):(e=oi(i.type,null,c,r,r.mode,d),e.ref=r.ref,e.return=r,r.child=e)}if(m=e.child,(e.lanes&d)===0){var w=m.memoizedProps;if(i=i.compare,i=i!==null?i:ws,i(w,c)&&e.ref===r.ref)return An(e,r,d)}return r.flags|=1,e=Xn(m,c),e.ref=r.ref,e.return=r,r.child=e}function $d(e,r,i,c,d){if(e!==null){var m=e.memoizedProps;if(ws(m,c)&&e.ref===r.ref)if(Bt=!1,r.pendingProps=c=m,(e.lanes&d)!==0)(e.flags&131072)!==0&&(Bt=!0);else return r.lanes=e.lanes,An(e,r,d)}return tl(e,r,i,c,d)}function _d(e,r,i){var c=r.pendingProps,d=c.children,m=e!==null?e.memoizedState:null;if(c.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},nt(qr,Jt),Jt|=i;else{if((i&1073741824)===0)return e=m!==null?m.baseLanes|i:i,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:e,cachePool:null,transitions:null},r.updateQueue=null,nt(qr,Jt),Jt|=e,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=m!==null?m.baseLanes:i,nt(qr,Jt),Jt|=c}else m!==null?(c=m.baseLanes|i,r.memoizedState=null):c=i,nt(qr,Jt),Jt|=c;return Pt(e,r,d,i),r.child}function Ld(e,r){var i=r.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(r.flags|=512,r.flags|=2097152)}function tl(e,r,i,c,d){var m=Ot(i)?lr:Tt.current;return m=Mr(r,m),Hr(r,d),i=Vo(e,r,i,c,m,d),c=Go(),e!==null&&!Bt?(r.updateQueue=e.updateQueue,r.flags&=-2053,e.lanes&=~d,An(e,r,d)):(ot&&c&&To(r),r.flags|=1,Pt(e,r,i,d),r.child)}function zd(e,r,i,c,d){if(Ot(i)){var m=!0;Pa(r)}else m=!1;if(Hr(r,d),r.stateNode===null)Ja(e,r),kd(r,i,c),Xo(r,i,c,d),c=!0;else if(e===null){var w=r.stateNode,C=r.memoizedProps;w.props=C;var R=w.context,W=i.contextType;typeof W=="object"&&W!==null?W=en(W):(W=Ot(i)?lr:Tt.current,W=Mr(r,W));var ae=i.getDerivedStateFromProps,ue=typeof ae=="function"||typeof w.getSnapshotBeforeUpdate=="function";ue||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(C!==c||R!==W)&&Nd(r,w,c,W),Vn=!1;var re=r.memoizedState;w.state=re,Da(r,c,w,d),R=r.memoizedState,C!==c||re!==R||Mt.current||Vn?(typeof ae=="function"&&(Qo(r,i,ae,c),R=r.memoizedState),(C=Vn||bd(r,i,C,c,re,R,W))?(ue||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=W,c=C):(typeof w.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{w=r.stateNode,Xu(e,r),C=r.memoizedProps,W=r.type===r.elementType?C:un(r.type,C),w.props=W,ue=r.pendingProps,re=w.context,R=i.contextType,typeof R=="object"&&R!==null?R=en(R):(R=Ot(i)?lr:Tt.current,R=Mr(r,R));var Se=i.getDerivedStateFromProps;(ae=typeof Se=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(C!==ue||re!==R)&&Nd(r,w,c,R),Vn=!1,re=r.memoizedState,w.state=re,Da(r,c,w,d);var Ce=r.memoizedState;C!==ue||re!==Ce||Mt.current||Vn?(typeof Se=="function"&&(Qo(r,i,Se,c),Ce=r.memoizedState),(W=Vn||bd(r,i,W,c,re,Ce,R)||!1)?(ae||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(c,Ce,R),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(c,Ce,R)),typeof w.componentDidUpdate=="function"&&(r.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof w.componentDidUpdate!="function"||C===e.memoizedProps&&re===e.memoizedState||(r.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||C===e.memoizedProps&&re===e.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=Ce),w.props=c,w.state=Ce,w.context=R,c=W):(typeof w.componentDidUpdate!="function"||C===e.memoizedProps&&re===e.memoizedState||(r.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||C===e.memoizedProps&&re===e.memoizedState||(r.flags|=1024),c=!1)}return nl(e,r,i,c,m,d)}function nl(e,r,i,c,d,m){Ld(e,r);var w=(r.flags&128)!==0;if(!c&&!w)return d&&Du(r,i,!1),An(e,r,m);c=r.stateNode,Rg.current=r;var C=w&&typeof i.getDerivedStateFromError!="function"?null:c.render();return r.flags|=1,e!==null&&w?(r.child=Ur(r,e.child,null,m),r.child=Ur(r,null,C,m)):Pt(e,r,C,m),r.memoizedState=c.state,d&&Du(r,i,!0),r.child}function Fd(e){var r=e.stateNode;r.pendingContext?Ou(e,r.pendingContext,r.pendingContext!==r.context):r.context&&Ou(e,r.context,!1),Oo(e,r.containerInfo)}function Md(e,r,i,c,d){return Dr(),Po(d),r.flags|=256,Pt(e,r,i,c),r.child}var rl={dehydrated:null,treeContext:null,retryLane:0};function sl(e){return{baseLanes:e,cachePool:null,transitions:null}}function Od(e,r,i){var c=r.pendingProps,d=dt.current,m=!1,w=(r.flags&128)!==0,C;if((C=w)||(C=e!==null&&e.memoizedState===null?!1:(d&2)!==0),C?(m=!0,r.flags&=-129):(e===null||e.memoizedState!==null)&&(d|=1),nt(dt,d&1),e===null)return Ro(r),e=r.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((r.mode&1)===0?r.lanes=1:e.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(w=c.children,e=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=li(w,c,0,null),e=vr(e,c,i,null),m.return=r,e.return=r,m.sibling=e,r.child=m,r.child.memoizedState=sl(i),r.memoizedState=rl,e):al(r,w));if(d=e.memoizedState,d!==null&&(C=d.dehydrated,C!==null))return Pg(e,r,w,c,C,d,i);if(m){m=c.fallback,w=r.mode,d=e.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=Xn(d,R),c.subtreeFlags=d.subtreeFlags&14680064),C!==null?m=Xn(C,m):(m=vr(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=e.child.memoizedState,w=w===null?sl(i):{baseLanes:w.baseLanes|i,cachePool:null,transitions:w.transitions},m.memoizedState=w,m.childLanes=e.childLanes&~i,r.memoizedState=rl,c}return m=e.child,e=m.sibling,c=Xn(m,{mode:"visible",children:c.children}),(r.mode&1)===0&&(c.lanes=i),c.return=r,c.sibling=null,e!==null&&(i=r.deletions,i===null?(r.deletions=[e],r.flags|=16):i.push(e)),r.child=c,r.memoizedState=null,c}function al(e,r){return r=li({mode:"visible",children:r},e.mode,0,null),r.return=e,e.child=r}function Ya(e,r,i,c){return c!==null&&Po(c),Ur(r,e.child,null,i),e=al(r,r.pendingProps.children),e.flags|=2,r.memoizedState=null,e}function Pg(e,r,i,c,d,m,w){if(i)return r.flags&256?(r.flags&=-257,c=Zo(Error(a(422))),Ya(e,r,w,c)):r.memoizedState!==null?(r.child=e.child,r.flags|=128,null):(m=c.fallback,d=r.mode,c=li({mode:"visible",children:c.children},d,0,null),m=vr(m,d,w,null),m.flags|=2,c.return=r,m.return=r,c.sibling=m,r.child=c,(r.mode&1)!==0&&Ur(r,e.child,null,w),r.child.memoizedState=sl(w),r.memoizedState=rl,m);if((r.mode&1)===0)return Ya(e,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=Zo(m,c,void 0),Ya(e,r,w,c)}if(C=(w&e.childLanes)!==0,Bt||C){if(c=kt,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,Tn(e,d),hn(c,e,d,-1))}return jl(),c=Zo(Error(a(421))),Ya(e,r,w,c)}return d.data==="$?"?(r.flags|=128,r.child=e.child,r=Vg.bind(null,e),d._reactRetry=r,null):(e=m.treeContext,Yt=Dn(d.nextSibling),qt=r,ot=!0,cn=null,e!==null&&(Xt[Zt++]=Cn,Xt[Zt++]=En,Xt[Zt++]=cr,Cn=e.id,En=e.overflow,cr=r),r=al(r,c.children),r.flags|=4096,r)}function Bd(e,r,i){e.lanes|=r;var c=e.alternate;c!==null&&(c.lanes|=r),zo(e.return,r,i)}function il(e,r,i,c,d){var m=e.memoizedState;m===null?e.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 Dd(e,r,i){var c=r.pendingProps,d=c.revealOrder,m=c.tail;if(Pt(e,r,c.children,i),c=dt.current,(c&2)!==0)c=c&1|2,r.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=r.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Bd(e,i,r);else if(e.tag===19)Bd(e,i,r);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===r)break e;for(;e.sibling===null;){if(e.return===null||e.return===r)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}c&=1}if(nt(dt,c),(r.mode&1)===0)r.memoizedState=null;else switch(d){case"forwards":for(i=r.child,d=null;i!==null;)e=i.alternate,e!==null&&Ua(e)===null&&(d=i),i=i.sibling;i=d,i===null?(d=r.child,r.child=null):(d=i.sibling,i.sibling=null),il(r,!1,d,i,m);break;case"backwards":for(i=null,d=r.child,r.child=null;d!==null;){if(e=d.alternate,e!==null&&Ua(e)===null){r.child=d;break}e=d.sibling,d.sibling=i,i=d,d=e}il(r,!0,i,null,m);break;case"together":il(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function Ja(e,r){(r.mode&1)===0&&e!==null&&(e.alternate=null,r.alternate=null,r.flags|=2)}function An(e,r,i){if(e!==null&&(r.dependencies=e.dependencies),mr|=r.lanes,(i&r.childLanes)===0)return null;if(e!==null&&r.child!==e.child)throw Error(a(153));if(r.child!==null){for(e=r.child,i=Xn(e,e.pendingProps),r.child=i,i.return=r;e.sibling!==null;)e=e.sibling,i=i.sibling=Xn(e,e.pendingProps),i.return=r;i.sibling=null}return r.child}function $g(e,r,i){switch(r.tag){case 3:Fd(r),Dr();break;case 5:td(r);break;case 1:Ot(r.type)&&Pa(r);break;case 4:Oo(r,r.stateNode.containerInfo);break;case 10:var c=r.type._context,d=r.memoizedProps.value;nt(Ma,c._currentValue),c._currentValue=d;break;case 13:if(c=r.memoizedState,c!==null)return c.dehydrated!==null?(nt(dt,dt.current&1),r.flags|=128,null):(i&r.child.childLanes)!==0?Od(e,r,i):(nt(dt,dt.current&1),e=An(e,r,i),e!==null?e.sibling:null);nt(dt,dt.current&1);break;case 19:if(c=(i&r.childLanes)!==0,(e.flags&128)!==0){if(c)return Dd(e,r,i);r.flags|=128}if(d=r.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),nt(dt,dt.current),c)break;return null;case 22:case 23:return r.lanes=0,_d(e,r,i)}return An(e,r,i)}var Ud,ol,Wd,Hd;Ud=function(e,r){for(var i=r.child;i!==null;){if(i.tag===5||i.tag===6)e.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}},ol=function(){},Wd=function(e,r,i,c){var d=e.memoizedProps;if(d!==c){e=r.stateNode,fr(xn.current);var m=null;switch(i){case"input":d=Ae(e,d),c=Ae(e,c),m=[];break;case"select":d=G({},d,{value:void 0}),c=G({},c,{value:void 0}),m=[];break;case"textarea":d=wt(e,d),c=wt(e,c),m=[];break;default:typeof d.onClick!="function"&&typeof c.onClick=="function"&&(e.onclick=Ia)}B(i,c);var w;i=null;for(W in d)if(!c.hasOwnProperty(W)&&d.hasOwnProperty(W)&&d[W]!=null)if(W==="style"){var C=d[W];for(w in C)C.hasOwnProperty(w)&&(i||(i={}),i[w]="")}else W!=="dangerouslySetInnerHTML"&&W!=="children"&&W!=="suppressContentEditableWarning"&&W!=="suppressHydrationWarning"&&W!=="autoFocus"&&(l.hasOwnProperty(W)?m||(m=[]):(m=m||[]).push(W,null));for(W in c){var R=c[W];if(C=d!=null?d[W]:void 0,c.hasOwnProperty(W)&&R!==C&&(R!=null||C!=null))if(W==="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(W,i)),i=R;else W==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,C=C?C.__html:void 0,R!=null&&C!==R&&(m=m||[]).push(W,R)):W==="children"?typeof R!="string"&&typeof R!="number"||(m=m||[]).push(W,""+R):W!=="suppressContentEditableWarning"&&W!=="suppressHydrationWarning"&&(l.hasOwnProperty(W)?(R!=null&&W==="onScroll"&&at("scroll",e),m||C===R||(m=[])):(m=m||[]).push(W,R))}i&&(m=m||[]).push("style",i);var W=m;(r.updateQueue=W)&&(r.flags|=4)}},Hd=function(e,r,i,c){i!==c&&(r.flags|=4)};function Ls(e,r){if(!ot)switch(e.tailMode){case"hidden":r=e.tail;for(var i=null;r!==null;)r.alternate!==null&&(i=r),r=r.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var c=null;i!==null;)i.alternate!==null&&(c=i),i=i.sibling;c===null?r||e.tail===null?e.tail=null:e.tail.sibling=null:c.sibling=null}}function At(e){var r=e.alternate!==null&&e.alternate.child===e.child,i=0,c=0;if(r)for(var d=e.child;d!==null;)i|=d.lanes|d.childLanes,c|=d.subtreeFlags&14680064,c|=d.flags&14680064,d.return=e,d=d.sibling;else for(d=e.child;d!==null;)i|=d.lanes|d.childLanes,c|=d.subtreeFlags,c|=d.flags,d.return=e,d=d.sibling;return e.subtreeFlags|=c,e.childLanes=i,r}function _g(e,r,i){var c=r.pendingProps;switch(Io(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return At(r),null;case 1:return Ot(r.type)&&Ra(),At(r),null;case 3:return c=r.stateNode,Vr(),it(Mt),it(Tt),Uo(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(e===null||e.child===null)&&(za(r)?r.flags|=4:e===null||e.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,cn!==null&&(vl(cn),cn=null))),ol(e,r),At(r),null;case 5:Bo(r);var d=fr(As.current);if(i=r.type,e!==null&&r.stateNode!=null)Wd(e,r,i,c,d),e.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!c){if(r.stateNode===null)throw Error(a(166));return At(r),null}if(e=fr(xn.current),za(r)){c=r.stateNode,i=r.type;var m=r.memoizedProps;switch(c[vn]=r,c[Ns]=m,e=(r.mode&1)!==0,i){case"dialog":at("cancel",c),at("close",c);break;case"iframe":case"object":case"embed":at("load",c);break;case"video":case"audio":for(d=0;d<Ss.length;d++)at(Ss[d],c);break;case"source":at("error",c);break;case"img":case"image":case"link":at("error",c),at("load",c);break;case"details":at("toggle",c);break;case"input":Ke(c,m),at("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!m.multiple},at("invalid",c);break;case"textarea":pt(c,m),at("invalid",c)}B(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&&Ta(c.textContent,C,e),d=["children",C]):typeof C=="number"&&c.textContent!==""+C&&(m.suppressHydrationWarning!==!0&&Ta(c.textContent,C,e),d=["children",""+C]):l.hasOwnProperty(w)&&C!=null&&w==="onScroll"&&at("scroll",c)}switch(i){case"input":be(c),ut(c,m,!0);break;case"textarea":be(c),he(c);break;case"select":case"option":break;default:typeof m.onClick=="function"&&(c.onclick=Ia)}c=d,r.updateQueue=c,c!==null&&(r.flags|=4)}else{w=d.nodeType===9?d:d.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=$e(i)),e==="http://www.w3.org/1999/xhtml"?i==="script"?(e=w.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof c.is=="string"?e=w.createElement(i,{is:c.is}):(e=w.createElement(i),i==="select"&&(w=e,c.multiple?w.multiple=!0:c.size&&(w.size=c.size))):e=w.createElementNS(e,i),e[vn]=r,e[Ns]=c,Ud(e,r,!1,!1),r.stateNode=e;e:{switch(w=ve(i,c),i){case"dialog":at("cancel",e),at("close",e),d=c;break;case"iframe":case"object":case"embed":at("load",e),d=c;break;case"video":case"audio":for(d=0;d<Ss.length;d++)at(Ss[d],e);d=c;break;case"source":at("error",e),d=c;break;case"img":case"image":case"link":at("error",e),at("load",e),d=c;break;case"details":at("toggle",e),d=c;break;case"input":Ke(e,c),d=Ae(e,c),at("invalid",e);break;case"option":d=c;break;case"select":e._wrapperState={wasMultiple:!!c.multiple},d=G({},c,{value:void 0}),at("invalid",e);break;case"textarea":pt(e,c),d=wt(e,c),at("invalid",e);break;default:d=c}B(i,d),C=d;for(m in C)if(C.hasOwnProperty(m)){var R=C[m];m==="style"?zt(e,R):m==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,R!=null&&K(e,R)):m==="children"?typeof R=="string"?(i!=="textarea"||R!=="")&&ye(e,R):typeof R=="number"&&ye(e,""+R):m!=="suppressContentEditableWarning"&&m!=="suppressHydrationWarning"&&m!=="autoFocus"&&(l.hasOwnProperty(m)?R!=null&&m==="onScroll"&&at("scroll",e):R!=null&&P(e,m,R,w))}switch(i){case"input":be(e),ut(e,c,!1);break;case"textarea":be(e),he(e);break;case"option":c.value!=null&&e.setAttribute("value",""+pe(c.value));break;case"select":e.multiple=!!c.multiple,m=c.value,m!=null?Je(e,!!c.multiple,m,!1):c.defaultValue!=null&&Je(e,!!c.multiple,c.defaultValue,!0);break;default:typeof d.onClick=="function"&&(e.onclick=Ia)}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 At(r),null;case 6:if(e&&r.stateNode!=null)Hd(e,r,e.memoizedProps,c);else{if(typeof c!="string"&&r.stateNode===null)throw Error(a(166));if(i=fr(As.current),fr(xn.current),za(r)){if(c=r.stateNode,i=r.memoizedProps,c[vn]=r,(m=c.nodeValue!==i)&&(e=qt,e!==null))switch(e.tag){case 3:Ta(c.nodeValue,i,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Ta(c.nodeValue,i,(e.mode&1)!==0)}m&&(r.flags|=4)}else c=(i.nodeType===9?i:i.ownerDocument).createTextNode(c),c[vn]=r,r.stateNode=c}return At(r),null;case 13:if(it(dt),c=r.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ot&&Yt!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Ku(),Dr(),r.flags|=98560,m=!1;else if(m=za(r),c!==null&&c.dehydrated!==null){if(e===null){if(!m)throw Error(a(318));if(m=r.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(a(317));m[vn]=r}else Dr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;At(r),m=!1}else cn!==null&&(vl(cn),cn=null),m=!0;if(!m)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=i,r):(c=c!==null,c!==(e!==null&&e.memoizedState!==null)&&c&&(r.child.flags|=8192,(r.mode&1)!==0&&(e===null||(dt.current&1)!==0?St===0&&(St=3):jl())),r.updateQueue!==null&&(r.flags|=4),At(r),null);case 4:return Vr(),ol(e,r),e===null&&bs(r.stateNode.containerInfo),At(r),null;case 10:return Lo(r.type._context),At(r),null;case 17:return Ot(r.type)&&Ra(),At(r),null;case 19:if(it(dt),m=r.memoizedState,m===null)return At(r),null;if(c=(r.flags&128)!==0,w=m.rendering,w===null)if(c)Ls(m,!1);else{if(St!==0||e!==null&&(e.flags&128)!==0)for(e=r.child;e!==null;){if(w=Ua(e),w!==null){for(r.flags|=128,Ls(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,e=c,m.flags&=14680066,w=m.alternate,w===null?(m.childLanes=0,m.lanes=e,m.child=null,m.subtreeFlags=0,m.memoizedProps=null,m.memoizedState=null,m.updateQueue=null,m.dependencies=null,m.stateNode=null):(m.childLanes=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,e=w.dependencies,m.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),i=i.sibling;return nt(dt,dt.current&1|2),r.child}e=e.sibling}m.tail!==null&&gt()>Yr&&(r.flags|=128,c=!0,Ls(m,!1),r.lanes=4194304)}else{if(!c)if(e=Ua(w),e!==null){if(r.flags|=128,c=!0,i=e.updateQueue,i!==null&&(r.updateQueue=i,r.flags|=4),Ls(m,!0),m.tail===null&&m.tailMode==="hidden"&&!w.alternate&&!ot)return At(r),null}else 2*gt()-m.renderingStartTime>Yr&&i!==1073741824&&(r.flags|=128,c=!0,Ls(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=gt(),r.sibling=null,i=dt.current,nt(dt,c?i&1|2:i&1),r):(At(r),null);case 22:case 23:return wl(),c=r.memoizedState!==null,e!==null&&e.memoizedState!==null!==c&&(r.flags|=8192),c&&(r.mode&1)!==0?(Jt&1073741824)!==0&&(At(r),r.subtreeFlags&6&&(r.flags|=8192)):At(r),null;case 24:return null;case 25:return null}throw Error(a(156,r.tag))}function Lg(e,r){switch(Io(r),r.tag){case 1:return Ot(r.type)&&Ra(),e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 3:return Vr(),it(Mt),it(Tt),Uo(),e=r.flags,(e&65536)!==0&&(e&128)===0?(r.flags=e&-65537|128,r):null;case 5:return Bo(r),null;case 13:if(it(dt),e=r.memoizedState,e!==null&&e.dehydrated!==null){if(r.alternate===null)throw Error(a(340));Dr()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 19:return it(dt),null;case 4:return Vr(),null;case 10:return Lo(r.type._context),null;case 22:case 23:return wl(),null;case 24:return null;default:return null}}var Qa=!1,Rt=!1,zg=typeof WeakSet=="function"?WeakSet:Set,ke=null;function Kr(e,r){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(c){ht(e,r,c)}else i.current=null}function ll(e,r,i){try{i()}catch(c){ht(e,r,c)}}var Vd=!1;function Fg(e,r){if(wo=ya,e=bu(),fo(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.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,W=0,ae=0,ue=e,re=null;t:for(;;){for(var Se;ue!==i||d!==0&&ue.nodeType!==3||(C=w+d),ue!==m||c!==0&&ue.nodeType!==3||(R=w+c),ue.nodeType===3&&(w+=ue.nodeValue.length),(Se=ue.firstChild)!==null;)re=ue,ue=Se;for(;;){if(ue===e)break t;if(re===i&&++W===d&&(C=w),re===m&&++ae===c&&(R=w),(Se=ue.nextSibling)!==null)break;ue=re,re=ue.parentNode}ue=Se}i=C===-1||R===-1?null:{start:C,end:R}}else i=null}i=i||{start:0,end:0}}else i=null;for(jo={focusedElem:e,selectionRange:i},ya=!1,ke=r;ke!==null;)if(r=ke,e=r.child,(r.subtreeFlags&1028)!==0&&e!==null)e.return=r,ke=e;else for(;ke!==null;){r=ke;try{var Ce=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Ce!==null){var Ee=Ce.memoizedProps,yt=Ce.memoizedState,M=r.stateNode,$=M.getSnapshotBeforeUpdate(r.elementType===r.type?Ee:un(r.type,Ee),yt);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(fe){ht(r,r.return,fe)}if(e=r.sibling,e!==null){e.return=r.return,ke=e;break}ke=r.return}return Ce=Vd,Vd=!1,Ce}function zs(e,r,i){var c=r.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var d=c=c.next;do{if((d.tag&e)===e){var m=d.destroy;d.destroy=void 0,m!==void 0&&ll(r,i,m)}d=d.next}while(d!==c)}}function Xa(e,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var c=i.create;i.destroy=c()}i=i.next}while(i!==r)}}function cl(e){var r=e.ref;if(r!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof r=="function"?r(e):r.current=e}}function Gd(e){var r=e.alternate;r!==null&&(e.alternate=null,Gd(r)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(r=e.stateNode,r!==null&&(delete r[vn],delete r[Ns],delete r[No],delete r[xg],delete r[wg])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Kd(e){return e.tag===5||e.tag===3||e.tag===4}function qd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Kd(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ul(e,r,i){var c=e.tag;if(c===5||c===6)e=e.stateNode,r?i.nodeType===8?i.parentNode.insertBefore(e,r):i.insertBefore(e,r):(i.nodeType===8?(r=i.parentNode,r.insertBefore(e,i)):(r=i,r.appendChild(e)),i=i._reactRootContainer,i!=null||r.onclick!==null||(r.onclick=Ia));else if(c!==4&&(e=e.child,e!==null))for(ul(e,r,i),e=e.sibling;e!==null;)ul(e,r,i),e=e.sibling}function dl(e,r,i){var c=e.tag;if(c===5||c===6)e=e.stateNode,r?i.insertBefore(e,r):i.appendChild(e);else if(c!==4&&(e=e.child,e!==null))for(dl(e,r,i),e=e.sibling;e!==null;)dl(e,r,i),e=e.sibling}var Ct=null,dn=!1;function Kn(e,r,i){for(i=i.child;i!==null;)Yd(e,r,i),i=i.sibling}function Yd(e,r,i){if(yn&&typeof yn.onCommitFiberUnmount=="function")try{yn.onCommitFiberUnmount(da,i)}catch{}switch(i.tag){case 5:Rt||Kr(i,r);case 6:var c=Ct,d=dn;Ct=null,Kn(e,r,i),Ct=c,dn=d,Ct!==null&&(dn?(e=Ct,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):Ct.removeChild(i.stateNode));break;case 18:Ct!==null&&(dn?(e=Ct,i=i.stateNode,e.nodeType===8?ko(e.parentNode,i):e.nodeType===1&&ko(e,i),ms(e)):ko(Ct,i.stateNode));break;case 4:c=Ct,d=dn,Ct=i.stateNode.containerInfo,dn=!0,Kn(e,r,i),Ct=c,dn=d;break;case 0:case 11:case 14:case 15:if(!Rt&&(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)&&ll(i,r,w),d=d.next}while(d!==c)}Kn(e,r,i);break;case 1:if(!Rt&&(Kr(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)}Kn(e,r,i);break;case 21:Kn(e,r,i);break;case 22:i.mode&1?(Rt=(c=Rt)||i.memoizedState!==null,Kn(e,r,i),Rt=c):Kn(e,r,i);break;default:Kn(e,r,i)}}function Jd(e){var r=e.updateQueue;if(r!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new zg),r.forEach(function(c){var d=Gg.bind(null,e,c);i.has(c)||(i.add(c),c.then(d,d))})}}function fn(e,r){var i=r.deletions;if(i!==null)for(var c=0;c<i.length;c++){var d=i[c];try{var m=e,w=r,C=w;e:for(;C!==null;){switch(C.tag){case 5:Ct=C.stateNode,dn=!1;break e;case 3:Ct=C.stateNode.containerInfo,dn=!0;break e;case 4:Ct=C.stateNode.containerInfo,dn=!0;break e}C=C.return}if(Ct===null)throw Error(a(160));Yd(m,w,d),Ct=null,dn=!1;var R=d.alternate;R!==null&&(R.return=null),d.return=null}catch(W){ht(d,r,W)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Qd(r,e),r=r.sibling}function Qd(e,r){var i=e.alternate,c=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(fn(r,e),jn(e),c&4){try{zs(3,e,e.return),Xa(3,e)}catch(Ee){ht(e,e.return,Ee)}try{zs(5,e,e.return)}catch(Ee){ht(e,e.return,Ee)}}break;case 1:fn(r,e),jn(e),c&512&&i!==null&&Kr(i,i.return);break;case 5:if(fn(r,e),jn(e),c&512&&i!==null&&Kr(i,i.return),e.flags&32){var d=e.stateNode;try{ye(d,"")}catch(Ee){ht(e,e.return,Ee)}}if(c&4&&(d=e.stateNode,d!=null)){var m=e.memoizedProps,w=i!==null?i.memoizedProps:m,C=e.type,R=e.updateQueue;if(e.updateQueue=null,R!==null)try{C==="input"&&m.type==="radio"&&m.name!=null&&De(d,m),ve(C,w);var W=ve(C,m);for(w=0;w<R.length;w+=2){var ae=R[w],ue=R[w+1];ae==="style"?zt(d,ue):ae==="dangerouslySetInnerHTML"?K(d,ue):ae==="children"?ye(d,ue):P(d,ae,ue,W)}switch(C){case"input":Le(d,m);break;case"textarea":Fe(d,m);break;case"select":var re=d._wrapperState.wasMultiple;d._wrapperState.wasMultiple=!!m.multiple;var Se=m.value;Se!=null?Je(d,!!m.multiple,Se,!1):re!==!!m.multiple&&(m.defaultValue!=null?Je(d,!!m.multiple,m.defaultValue,!0):Je(d,!!m.multiple,m.multiple?[]:"",!1))}d[Ns]=m}catch(Ee){ht(e,e.return,Ee)}}break;case 6:if(fn(r,e),jn(e),c&4){if(e.stateNode===null)throw Error(a(162));d=e.stateNode,m=e.memoizedProps;try{d.nodeValue=m}catch(Ee){ht(e,e.return,Ee)}}break;case 3:if(fn(r,e),jn(e),c&4&&i!==null&&i.memoizedState.isDehydrated)try{ms(r.containerInfo)}catch(Ee){ht(e,e.return,Ee)}break;case 4:fn(r,e),jn(e);break;case 13:fn(r,e),jn(e),d=e.child,d.flags&8192&&(m=d.memoizedState!==null,d.stateNode.isHidden=m,!m||d.alternate!==null&&d.alternate.memoizedState!==null||(ml=gt())),c&4&&Jd(e);break;case 22:if(ae=i!==null&&i.memoizedState!==null,e.mode&1?(Rt=(W=Rt)||ae,fn(r,e),Rt=W):fn(r,e),jn(e),c&8192){if(W=e.memoizedState!==null,(e.stateNode.isHidden=W)&&!ae&&(e.mode&1)!==0)for(ke=e,ae=e.child;ae!==null;){for(ue=ke=ae;ke!==null;){switch(re=ke,Se=re.child,re.tag){case 0:case 11:case 14:case 15:zs(4,re,re.return);break;case 1:Kr(re,re.return);var Ce=re.stateNode;if(typeof Ce.componentWillUnmount=="function"){c=re,i=re.return;try{r=c,Ce.props=r.memoizedProps,Ce.state=r.memoizedState,Ce.componentWillUnmount()}catch(Ee){ht(c,i,Ee)}}break;case 5:Kr(re,re.return);break;case 22:if(re.memoizedState!==null){ef(ue);continue}}Se!==null?(Se.return=re,ke=Se):ef(ue)}ae=ae.sibling}e:for(ae=null,ue=e;;){if(ue.tag===5){if(ae===null){ae=ue;try{d=ue.stateNode,W?(m=d.style,typeof m.setProperty=="function"?m.setProperty("display","none","important"):m.display="none"):(C=ue.stateNode,R=ue.memoizedProps.style,w=R!=null&&R.hasOwnProperty("display")?R.display:null,C.style.display=st("display",w))}catch(Ee){ht(e,e.return,Ee)}}}else if(ue.tag===6){if(ae===null)try{ue.stateNode.nodeValue=W?"":ue.memoizedProps}catch(Ee){ht(e,e.return,Ee)}}else if((ue.tag!==22&&ue.tag!==23||ue.memoizedState===null||ue===e)&&ue.child!==null){ue.child.return=ue,ue=ue.child;continue}if(ue===e)break e;for(;ue.sibling===null;){if(ue.return===null||ue.return===e)break e;ae===ue&&(ae=null),ue=ue.return}ae===ue&&(ae=null),ue.sibling.return=ue.return,ue=ue.sibling}}break;case 19:fn(r,e),jn(e),c&4&&Jd(e);break;case 21:break;default:fn(r,e),jn(e)}}function jn(e){var r=e.flags;if(r&2){try{e:{for(var i=e.return;i!==null;){if(Kd(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=qd(e);dl(e,m,d);break;case 3:case 4:var w=c.stateNode.containerInfo,C=qd(e);ul(e,C,w);break;default:throw Error(a(161))}}catch(R){ht(e,e.return,R)}e.flags&=-3}r&4096&&(e.flags&=-4097)}function Mg(e,r,i){ke=e,Xd(e)}function Xd(e,r,i){for(var c=(e.mode&1)!==0;ke!==null;){var d=ke,m=d.child;if(d.tag===22&&c){var w=d.memoizedState!==null||Qa;if(!w){var C=d.alternate,R=C!==null&&C.memoizedState!==null||Rt;C=Qa;var W=Rt;if(Qa=w,(Rt=R)&&!W)for(ke=d;ke!==null;)w=ke,R=w.child,w.tag===22&&w.memoizedState!==null?tf(d):R!==null?(R.return=w,ke=R):tf(d);for(;m!==null;)ke=m,Xd(m),m=m.sibling;ke=d,Qa=C,Rt=W}Zd(e)}else(d.subtreeFlags&8772)!==0&&m!==null?(m.return=d,ke=m):Zd(e)}}function Zd(e){for(;ke!==null;){var r=ke;if((r.flags&8772)!==0){var i=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Rt||Xa(5,r);break;case 1:var c=r.stateNode;if(r.flags&4&&!Rt)if(i===null)c.componentDidMount();else{var d=r.elementType===r.type?i.memoizedProps:un(r.type,i.memoizedProps);c.componentDidUpdate(d,i.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var m=r.updateQueue;m!==null&&ed(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}ed(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 W=r.alternate;if(W!==null){var ae=W.memoizedState;if(ae!==null){var ue=ae.dehydrated;ue!==null&&ms(ue)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}Rt||r.flags&512&&cl(r)}catch(re){ht(r,r.return,re)}}if(r===e){ke=null;break}if(i=r.sibling,i!==null){i.return=r.return,ke=i;break}ke=r.return}}function ef(e){for(;ke!==null;){var r=ke;if(r===e){ke=null;break}var i=r.sibling;if(i!==null){i.return=r.return,ke=i;break}ke=r.return}}function tf(e){for(;ke!==null;){var r=ke;try{switch(r.tag){case 0:case 11:case 15:var i=r.return;try{Xa(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{cl(r)}catch(R){ht(r,m,R)}break;case 5:var w=r.return;try{cl(r)}catch(R){ht(r,w,R)}}}catch(R){ht(r,r.return,R)}if(r===e){ke=null;break}var C=r.sibling;if(C!==null){C.return=r.return,ke=C;break}ke=r.return}}var Og=Math.ceil,Za=I.ReactCurrentDispatcher,fl=I.ReactCurrentOwner,nn=I.ReactCurrentBatchConfig,qe=0,kt=null,xt=null,Et=0,Jt=0,qr=Un(0),St=0,Fs=null,mr=0,ei=0,hl=0,Ms=null,Dt=null,ml=0,Yr=1/0,Rn=null,ti=!1,pl=null,qn=null,ni=!1,Yn=null,ri=0,Os=0,gl=null,si=-1,ai=0;function $t(){return(qe&6)!==0?gt():si!==-1?si:si=gt()}function Jn(e){return(e.mode&1)===0?1:(qe&2)!==0&&Et!==0?Et&-Et:Sg.transition!==null?(ai===0&&(ai=qc()),ai):(e=Ze,e!==0||(e=window.event,e=e===void 0?16:ru(e.type)),e)}function hn(e,r,i,c){if(50<Os)throw Os=0,gl=null,Error(a(185));cs(e,i,c),((qe&2)===0||e!==kt)&&(e===kt&&((qe&2)===0&&(ei|=i),St===4&&Qn(e,Et)),Ut(e,c),i===1&&qe===0&&(r.mode&1)===0&&(Yr=gt()+500,$a&&Hn()))}function Ut(e,r){var i=e.callbackNode;Sp(e,r);var c=ma(e,e===kt?Et:0);if(c===0)i!==null&&Vc(i),e.callbackNode=null,e.callbackPriority=0;else if(r=c&-c,e.callbackPriority!==r){if(i!=null&&Vc(i),r===1)e.tag===0?jg(rf.bind(null,e)):Uu(rf.bind(null,e)),yg(function(){(qe&6)===0&&Hn()}),i=null;else{switch(Yc(c)){case 1:i=qi;break;case 4:i=Gc;break;case 16:i=ua;break;case 536870912:i=Kc;break;default:i=ua}i=ff(i,nf.bind(null,e))}e.callbackPriority=r,e.callbackNode=i}}function nf(e,r){if(si=-1,ai=0,(qe&6)!==0)throw Error(a(327));var i=e.callbackNode;if(Jr()&&e.callbackNode!==i)return null;var c=ma(e,e===kt?Et:0);if(c===0)return null;if((c&30)!==0||(c&e.expiredLanes)!==0||r)r=ii(e,c);else{r=c;var d=qe;qe|=2;var m=af();(kt!==e||Et!==r)&&(Rn=null,Yr=gt()+500,gr(e,r));do try{Ug();break}catch(C){sf(e,C)}while(!0);_o(),Za.current=m,qe=d,xt!==null?r=0:(kt=null,Et=0,r=St)}if(r!==0){if(r===2&&(d=Yi(e),d!==0&&(c=d,r=yl(e,d))),r===1)throw i=Fs,gr(e,0),Qn(e,c),Ut(e,gt()),i;if(r===6)Qn(e,c);else{if(d=e.current.alternate,(c&30)===0&&!Bg(d)&&(r=ii(e,c),r===2&&(m=Yi(e),m!==0&&(c=m,r=yl(e,m))),r===1))throw i=Fs,gr(e,0),Qn(e,c),Ut(e,gt()),i;switch(e.finishedWork=d,e.finishedLanes=c,r){case 0:case 1:throw Error(a(345));case 2:yr(e,Dt,Rn);break;case 3:if(Qn(e,c),(c&130023424)===c&&(r=ml+500-gt(),10<r)){if(ma(e,0)!==0)break;if(d=e.suspendedLanes,(d&c)!==c){$t(),e.pingedLanes|=e.suspendedLanes&d;break}e.timeoutHandle=bo(yr.bind(null,e,Dt,Rn),r);break}yr(e,Dt,Rn);break;case 4:if(Qn(e,c),(c&4194240)===c)break;for(r=e.eventTimes,d=-1;0<c;){var w=31-on(c);m=1<<w,w=r[w],w>d&&(d=w),c&=~m}if(c=d,c=gt()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*Og(c/1960))-c,10<c){e.timeoutHandle=bo(yr.bind(null,e,Dt,Rn),c);break}yr(e,Dt,Rn);break;case 5:yr(e,Dt,Rn);break;default:throw Error(a(329))}}}return Ut(e,gt()),e.callbackNode===i?nf.bind(null,e):null}function yl(e,r){var i=Ms;return e.current.memoizedState.isDehydrated&&(gr(e,r).flags|=256),e=ii(e,r),e!==2&&(r=Dt,Dt=i,r!==null&&vl(r)),e}function vl(e){Dt===null?Dt=e:Dt.push.apply(Dt,e)}function Bg(e){for(var r=e;;){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(!ln(m(),d))return!1}catch{return!1}}}if(i=r.child,r.subtreeFlags&16384&&i!==null)i.return=r,r=i;else{if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Qn(e,r){for(r&=~hl,r&=~ei,e.suspendedLanes|=r,e.pingedLanes&=~r,e=e.expirationTimes;0<r;){var i=31-on(r),c=1<<i;e[i]=-1,r&=~c}}function rf(e){if((qe&6)!==0)throw Error(a(327));Jr();var r=ma(e,0);if((r&1)===0)return Ut(e,gt()),null;var i=ii(e,r);if(e.tag!==0&&i===2){var c=Yi(e);c!==0&&(r=c,i=yl(e,c))}if(i===1)throw i=Fs,gr(e,0),Qn(e,r),Ut(e,gt()),i;if(i===6)throw Error(a(345));return e.finishedWork=e.current.alternate,e.finishedLanes=r,yr(e,Dt,Rn),Ut(e,gt()),null}function xl(e,r){var i=qe;qe|=1;try{return e(r)}finally{qe=i,qe===0&&(Yr=gt()+500,$a&&Hn())}}function pr(e){Yn!==null&&Yn.tag===0&&(qe&6)===0&&Jr();var r=qe;qe|=1;var i=nn.transition,c=Ze;try{if(nn.transition=null,Ze=1,e)return e()}finally{Ze=c,nn.transition=i,qe=r,(qe&6)===0&&Hn()}}function wl(){Jt=qr.current,it(qr)}function gr(e,r){e.finishedWork=null,e.finishedLanes=0;var i=e.timeoutHandle;if(i!==-1&&(e.timeoutHandle=-1,gg(i)),xt!==null)for(i=xt.return;i!==null;){var c=i;switch(Io(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Ra();break;case 3:Vr(),it(Mt),it(Tt),Uo();break;case 5:Bo(c);break;case 4:Vr();break;case 13:it(dt);break;case 19:it(dt);break;case 10:Lo(c.type._context);break;case 22:case 23:wl()}i=i.return}if(kt=e,xt=e=Xn(e.current,null),Et=Jt=r,St=0,Fs=null,hl=ei=mr=0,Dt=Ms=null,dr!==null){for(r=0;r<dr.length;r++)if(i=dr[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}dr=null}return e}function sf(e,r){do{var i=xt;try{if(_o(),Wa.current=Ka,Ha){for(var c=ft.memoizedState;c!==null;){var d=c.queue;d!==null&&(d.pending=null),c=c.next}Ha=!1}if(hr=0,bt=jt=ft=null,Rs=!1,Ps=0,fl.current=null,i===null||i.return===null){St=1,Fs=r,xt=null;break}e:{var m=e,w=i.return,C=i,R=r;if(r=Et,C.flags|=32768,R!==null&&typeof R=="object"&&typeof R.then=="function"){var W=R,ae=C,ue=ae.tag;if((ae.mode&1)===0&&(ue===0||ue===11||ue===15)){var re=ae.alternate;re?(ae.updateQueue=re.updateQueue,ae.memoizedState=re.memoizedState,ae.lanes=re.lanes):(ae.updateQueue=null,ae.memoizedState=null)}var Se=Id(w);if(Se!==null){Se.flags&=-257,Ad(Se,w,C,m,r),Se.mode&1&&Td(m,W,r),r=Se,R=W;var Ce=r.updateQueue;if(Ce===null){var Ee=new Set;Ee.add(R),r.updateQueue=Ee}else Ce.add(R);break e}else{if((r&1)===0){Td(m,W,r),jl();break e}R=Error(a(426))}}else if(ot&&C.mode&1){var yt=Id(w);if(yt!==null){(yt.flags&65536)===0&&(yt.flags|=256),Ad(yt,w,C,m,r),Po(Gr(R,C));break e}}m=R=Gr(R,C),St!==4&&(St=2),Ms===null?Ms=[m]:Ms.push(m),m=w;do{switch(m.tag){case 3:m.flags|=65536,r&=-r,m.lanes|=r;var M=Cd(m,R,r);Zu(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"&&(qn===null||!qn.has(D)))){m.flags|=65536,r&=-r,m.lanes|=r;var fe=Ed(m,C,r);Zu(m,fe);break e}}m=m.return}while(m!==null)}lf(i)}catch(Te){r=Te,xt===i&&i!==null&&(xt=i=i.return);continue}break}while(!0)}function af(){var e=Za.current;return Za.current=Ka,e===null?Ka:e}function jl(){(St===0||St===3||St===2)&&(St=4),kt===null||(mr&268435455)===0&&(ei&268435455)===0||Qn(kt,Et)}function ii(e,r){var i=qe;qe|=2;var c=af();(kt!==e||Et!==r)&&(Rn=null,gr(e,r));do try{Dg();break}catch(d){sf(e,d)}while(!0);if(_o(),qe=i,Za.current=c,xt!==null)throw Error(a(261));return kt=null,Et=0,St}function Dg(){for(;xt!==null;)of(xt)}function Ug(){for(;xt!==null&&!hp();)of(xt)}function of(e){var r=df(e.alternate,e,Jt);e.memoizedProps=e.pendingProps,r===null?lf(e):xt=r,fl.current=null}function lf(e){var r=e;do{var i=r.alternate;if(e=r.return,(r.flags&32768)===0){if(i=_g(i,r,Jt),i!==null){xt=i;return}}else{if(i=Lg(i,r),i!==null){i.flags&=32767,xt=i;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{St=6,xt=null;return}}if(r=r.sibling,r!==null){xt=r;return}xt=r=e}while(r!==null);St===0&&(St=5)}function yr(e,r,i){var c=Ze,d=nn.transition;try{nn.transition=null,Ze=1,Wg(e,r,i,c)}finally{nn.transition=d,Ze=c}return null}function Wg(e,r,i,c){do Jr();while(Yn!==null);if((qe&6)!==0)throw Error(a(327));i=e.finishedWork;var d=e.finishedLanes;if(i===null)return null;if(e.finishedWork=null,e.finishedLanes=0,i===e.current)throw Error(a(177));e.callbackNode=null,e.callbackPriority=0;var m=i.lanes|i.childLanes;if(bp(e,m),e===kt&&(xt=kt=null,Et=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||ni||(ni=!0,ff(ua,function(){return Jr(),null})),m=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||m){m=nn.transition,nn.transition=null;var w=Ze;Ze=1;var C=qe;qe|=4,fl.current=null,Fg(e,i),Qd(i,e),cg(jo),ya=!!wo,jo=wo=null,e.current=i,Mg(i),mp(),qe=C,Ze=w,nn.transition=m}else e.current=i;if(ni&&(ni=!1,Yn=e,ri=d),m=e.pendingLanes,m===0&&(qn=null),yp(i.stateNode),Ut(e,gt()),r!==null)for(c=e.onRecoverableError,i=0;i<r.length;i++)d=r[i],c(d.value,{componentStack:d.stack,digest:d.digest});if(ti)throw ti=!1,e=pl,pl=null,e;return(ri&1)!==0&&e.tag!==0&&Jr(),m=e.pendingLanes,(m&1)!==0?e===gl?Os++:(Os=0,gl=e):Os=0,Hn(),null}function Jr(){if(Yn!==null){var e=Yc(ri),r=nn.transition,i=Ze;try{if(nn.transition=null,Ze=16>e?16:e,Yn===null)var c=!1;else{if(e=Yn,Yn=null,ri=0,(qe&6)!==0)throw Error(a(331));var d=qe;for(qe|=4,ke=e.current;ke!==null;){var m=ke,w=m.child;if((ke.flags&16)!==0){var C=m.deletions;if(C!==null){for(var R=0;R<C.length;R++){var W=C[R];for(ke=W;ke!==null;){var ae=ke;switch(ae.tag){case 0:case 11:case 15:zs(8,ae,m)}var ue=ae.child;if(ue!==null)ue.return=ae,ke=ue;else for(;ke!==null;){ae=ke;var re=ae.sibling,Se=ae.return;if(Gd(ae),ae===W){ke=null;break}if(re!==null){re.return=Se,ke=re;break}ke=Se}}}var Ce=m.alternate;if(Ce!==null){var Ee=Ce.child;if(Ee!==null){Ce.child=null;do{var yt=Ee.sibling;Ee.sibling=null,Ee=yt}while(Ee!==null)}}ke=m}}if((m.subtreeFlags&2064)!==0&&w!==null)w.return=m,ke=w;else e:for(;ke!==null;){if(m=ke,(m.flags&2048)!==0)switch(m.tag){case 0:case 11:case 15:zs(9,m,m.return)}var M=m.sibling;if(M!==null){M.return=m.return,ke=M;break e}ke=m.return}}var $=e.current;for(ke=$;ke!==null;){w=ke;var D=w.child;if((w.subtreeFlags&2064)!==0&&D!==null)D.return=w,ke=D;else e:for(w=$;ke!==null;){if(C=ke,(C.flags&2048)!==0)try{switch(C.tag){case 0:case 11:case 15:Xa(9,C)}}catch(Te){ht(C,C.return,Te)}if(C===w){ke=null;break e}var fe=C.sibling;if(fe!==null){fe.return=C.return,ke=fe;break e}ke=C.return}}if(qe=d,Hn(),yn&&typeof yn.onPostCommitFiberRoot=="function")try{yn.onPostCommitFiberRoot(da,e)}catch{}c=!0}return c}finally{Ze=i,nn.transition=r}}return!1}function cf(e,r,i){r=Gr(i,r),r=Cd(e,r,1),e=Gn(e,r,1),r=$t(),e!==null&&(cs(e,1,r),Ut(e,r))}function ht(e,r,i){if(e.tag===3)cf(e,e,i);else for(;r!==null;){if(r.tag===3){cf(r,e,i);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(qn===null||!qn.has(c))){e=Gr(i,e),e=Ed(r,e,1),r=Gn(r,e,1),e=$t(),r!==null&&(cs(r,1,e),Ut(r,e));break}}r=r.return}}function Hg(e,r,i){var c=e.pingCache;c!==null&&c.delete(r),r=$t(),e.pingedLanes|=e.suspendedLanes&i,kt===e&&(Et&i)===i&&(St===4||St===3&&(Et&130023424)===Et&&500>gt()-ml?gr(e,0):hl|=i),Ut(e,r)}function uf(e,r){r===0&&((e.mode&1)===0?r=1:(r=ha,ha<<=1,(ha&130023424)===0&&(ha=4194304)));var i=$t();e=Tn(e,r),e!==null&&(cs(e,r,i),Ut(e,i))}function Vg(e){var r=e.memoizedState,i=0;r!==null&&(i=r.retryLane),uf(e,i)}function Gg(e,r){var i=0;switch(e.tag){case 13:var c=e.stateNode,d=e.memoizedState;d!==null&&(i=d.retryLane);break;case 19:c=e.stateNode;break;default:throw Error(a(314))}c!==null&&c.delete(r),uf(e,i)}var df;df=function(e,r,i){if(e!==null)if(e.memoizedProps!==r.pendingProps||Mt.current)Bt=!0;else{if((e.lanes&i)===0&&(r.flags&128)===0)return Bt=!1,$g(e,r,i);Bt=(e.flags&131072)!==0}else Bt=!1,ot&&(r.flags&1048576)!==0&&Wu(r,La,r.index);switch(r.lanes=0,r.tag){case 2:var c=r.type;Ja(e,r),e=r.pendingProps;var d=Mr(r,Tt.current);Hr(r,i),d=Vo(null,r,c,e,d,i);var m=Go();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,Ot(c)?(m=!0,Pa(r)):m=!1,r.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,Mo(r),d.updater=qa,r.stateNode=d,d._reactInternals=r,Xo(r,c,e,i),r=nl(null,r,c,!0,m,i)):(r.tag=0,ot&&m&&To(r),Pt(null,r,d,i),r=r.child),r;case 16:c=r.elementType;e:{switch(Ja(e,r),e=r.pendingProps,d=c._init,c=d(c._payload),r.type=c,d=r.tag=qg(c),e=un(c,e),d){case 0:r=tl(null,r,c,e,i);break e;case 1:r=zd(null,r,c,e,i);break e;case 11:r=Rd(null,r,c,e,i);break e;case 14:r=Pd(null,r,c,un(c.type,e),i);break e}throw Error(a(306,c,""))}return r;case 0:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:un(c,d),tl(e,r,c,d,i);case 1:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:un(c,d),zd(e,r,c,d,i);case 3:e:{if(Fd(r),e===null)throw Error(a(387));c=r.pendingProps,m=r.memoizedState,d=m.element,Xu(e,r),Da(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=Gr(Error(a(423)),r),r=Md(e,r,c,i,d);break e}else if(c!==d){d=Gr(Error(a(424)),r),r=Md(e,r,c,i,d);break e}else for(Yt=Dn(r.stateNode.containerInfo.firstChild),qt=r,ot=!0,cn=null,i=Ju(r,null,c,i),r.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Dr(),c===d){r=An(e,r,i);break e}Pt(e,r,c,i)}r=r.child}return r;case 5:return td(r),e===null&&Ro(r),c=r.type,d=r.pendingProps,m=e!==null?e.memoizedProps:null,w=d.children,So(c,d)?w=null:m!==null&&So(c,m)&&(r.flags|=32),Ld(e,r),Pt(e,r,w,i),r.child;case 6:return e===null&&Ro(r),null;case 13:return Od(e,r,i);case 4:return Oo(r,r.stateNode.containerInfo),c=r.pendingProps,e===null?r.child=Ur(r,null,c,i):Pt(e,r,c,i),r.child;case 11:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:un(c,d),Rd(e,r,c,d,i);case 7:return Pt(e,r,r.pendingProps,i),r.child;case 8:return Pt(e,r,r.pendingProps.children,i),r.child;case 12:return Pt(e,r,r.pendingProps.children,i),r.child;case 10:e:{if(c=r.type._context,d=r.pendingProps,m=r.memoizedProps,w=d.value,nt(Ma,c._currentValue),c._currentValue=w,m!==null)if(ln(m.value,w)){if(m.children===d.children&&!Mt.current){r=An(e,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=In(-1,i&-i),R.tag=2;var W=m.updateQueue;if(W!==null){W=W.shared;var ae=W.pending;ae===null?R.next=R:(R.next=ae.next,ae.next=R),W.pending=R}}m.lanes|=i,R=m.alternate,R!==null&&(R.lanes|=i),zo(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),zo(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}Pt(e,r,d.children,i),r=r.child}return r;case 9:return d=r.type,c=r.pendingProps.children,Hr(r,i),d=en(d),c=c(d),r.flags|=1,Pt(e,r,c,i),r.child;case 14:return c=r.type,d=un(c,r.pendingProps),d=un(c.type,d),Pd(e,r,c,d,i);case 15:return $d(e,r,r.type,r.pendingProps,i);case 17:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:un(c,d),Ja(e,r),r.tag=1,Ot(c)?(e=!0,Pa(r)):e=!1,Hr(r,i),kd(r,c,d),Xo(r,c,d,i),nl(null,r,c,!0,e,i);case 19:return Dd(e,r,i);case 22:return _d(e,r,i)}throw Error(a(156,r.tag))};function ff(e,r){return Hc(e,r)}function Kg(e,r,i,c){this.tag=e,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 rn(e,r,i,c){return new Kg(e,r,i,c)}function Sl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qg(e){if(typeof e=="function")return Sl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===L)return 11;if(e===Y)return 14}return 2}function Xn(e,r){var i=e.alternate;return i===null?(i=rn(e.tag,r,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=r,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,r=e.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function oi(e,r,i,c,d,m){var w=2;if(c=e,typeof e=="function")Sl(e)&&(w=1);else if(typeof e=="string")w=5;else e:switch(e){case z:return vr(i.children,d,m,r);case J:w=8,d|=8;break;case Q:return e=rn(12,i,r,d|2),e.elementType=Q,e.lanes=m,e;case oe:return e=rn(13,i,r,d),e.elementType=oe,e.lanes=m,e;case de:return e=rn(19,i,r,d),e.elementType=de,e.lanes=m,e;case xe:return li(i,d,m,r);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ne:w=10;break e;case ee:w=9;break e;case L:w=11;break e;case Y:w=14;break e;case je:w=16,c=null;break e}throw Error(a(130,e==null?e:typeof e,""))}return r=rn(w,i,r,d),r.elementType=e,r.type=c,r.lanes=m,r}function vr(e,r,i,c){return e=rn(7,e,c,r),e.lanes=i,e}function li(e,r,i,c){return e=rn(22,e,c,r),e.elementType=xe,e.lanes=i,e.stateNode={isHidden:!1},e}function bl(e,r,i){return e=rn(6,e,null,r),e.lanes=i,e}function kl(e,r,i){return r=rn(4,e.children!==null?e.children:[],e.key,r),r.lanes=i,r.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},r}function Yg(e,r,i,c,d){this.tag=r,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ji(0),this.expirationTimes=Ji(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ji(0),this.identifierPrefix=c,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function Nl(e,r,i,c,d,m,w,C,R){return e=new Yg(e,r,i,C,R),r===1?(r=1,m===!0&&(r|=8)):r=0,m=rn(3,null,null,r),e.current=m,m.stateNode=e,m.memoizedState={element:c,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Mo(m),e}function Jg(e,r,i){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:V,key:c==null?null:""+c,children:e,containerInfo:r,implementation:i}}function hf(e){if(!e)return Wn;e=e._reactInternals;e:{if(ir(e)!==e||e.tag!==1)throw Error(a(170));var r=e;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Ot(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(a(171))}if(e.tag===1){var i=e.type;if(Ot(i))return Bu(e,i,r)}return r}function mf(e,r,i,c,d,m,w,C,R){return e=Nl(i,c,!0,e,d,m,w,C,R),e.context=hf(null),i=e.current,c=$t(),d=Jn(i),m=In(c,d),m.callback=r??null,Gn(i,m,d),e.current.lanes=d,cs(e,d,c),Ut(e,c),e}function ci(e,r,i,c){var d=r.current,m=$t(),w=Jn(d);return i=hf(i),r.context===null?r.context=i:r.pendingContext=i,r=In(m,w),r.payload={element:e},c=c===void 0?null:c,c!==null&&(r.callback=c),e=Gn(d,r,w),e!==null&&(hn(e,d,w,m),Ba(e,d,w)),w}function ui(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function pf(e,r){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var i=e.retryLane;e.retryLane=i!==0&&i<r?i:r}}function Cl(e,r){pf(e,r),(e=e.alternate)&&pf(e,r)}function Qg(){return null}var gf=typeof reportError=="function"?reportError:function(e){console.error(e)};function El(e){this._internalRoot=e}di.prototype.render=El.prototype.render=function(e){var r=this._internalRoot;if(r===null)throw Error(a(409));ci(e,r,null,null)},di.prototype.unmount=El.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var r=e.containerInfo;pr(function(){ci(null,e,null,null)}),r[kn]=null}};function di(e){this._internalRoot=e}di.prototype.unstable_scheduleHydration=function(e){if(e){var r=Xc();e={blockedOn:null,target:e,priority:r};for(var i=0;i<Mn.length&&r!==0&&r<Mn[i].priority;i++);Mn.splice(i,0,e),i===0&&tu(e)}};function Tl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function fi(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function yf(){}function Xg(e,r,i,c,d){if(d){if(typeof c=="function"){var m=c;c=function(){var W=ui(w);m.call(W)}}var w=mf(r,c,e,0,null,!1,!1,"",yf);return e._reactRootContainer=w,e[kn]=w.current,bs(e.nodeType===8?e.parentNode:e),pr(),w}for(;d=e.lastChild;)e.removeChild(d);if(typeof c=="function"){var C=c;c=function(){var W=ui(R);C.call(W)}}var R=Nl(e,0,!1,null,null,!1,!1,"",yf);return e._reactRootContainer=R,e[kn]=R.current,bs(e.nodeType===8?e.parentNode:e),pr(function(){ci(r,R,i,c)}),R}function hi(e,r,i,c,d){var m=i._reactRootContainer;if(m){var w=m;if(typeof d=="function"){var C=d;d=function(){var R=ui(w);C.call(R)}}ci(r,w,e,d)}else w=Xg(i,r,e,d,c);return ui(w)}Jc=function(e){switch(e.tag){case 3:var r=e.stateNode;if(r.current.memoizedState.isDehydrated){var i=ls(r.pendingLanes);i!==0&&(Qi(r,i|1),Ut(r,gt()),(qe&6)===0&&(Yr=gt()+500,Hn()))}break;case 13:pr(function(){var c=Tn(e,1);if(c!==null){var d=$t();hn(c,e,1,d)}}),Cl(e,1)}},Xi=function(e){if(e.tag===13){var r=Tn(e,134217728);if(r!==null){var i=$t();hn(r,e,134217728,i)}Cl(e,134217728)}},Qc=function(e){if(e.tag===13){var r=Jn(e),i=Tn(e,r);if(i!==null){var c=$t();hn(i,e,r,c)}Cl(e,r)}},Xc=function(){return Ze},Zc=function(e,r){var i=Ze;try{return Ze=e,r()}finally{Ze=i}},ce=function(e,r,i){switch(r){case"input":if(Le(e,i),r=i.name,i.type==="radio"&&r!=null){for(i=e;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!==e&&c.form===e.form){var d=Aa(c);if(!d)throw Error(a(90));_e(c),Le(c,d)}}}break;case"textarea":Fe(e,i);break;case"select":r=i.value,r!=null&&Je(e,!!i.multiple,r,!1)}},Gt=xl,tr=pr;var Zg={usingClientEntryPoint:!1,Events:[Cs,zr,Aa,Oe,tt,xl]},Bs={findFiberByHostInstance:or,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ey={bundleType:Bs.bundleType,version:Bs.version,rendererPackageName:Bs.rendererPackageName,rendererConfig:Bs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:I.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Uc(e),e===null?null:e.stateNode},findFiberByHostInstance:Bs.findFiberByHostInstance||Qg,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 mi=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!mi.isDisabled&&mi.supportsFiber)try{da=mi.inject(ey),yn=mi}catch{}}return Wt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Zg,Wt.createPortal=function(e,r){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Tl(r))throw Error(a(200));return Jg(e,r,null,i)},Wt.createRoot=function(e,r){if(!Tl(e))throw Error(a(299));var i=!1,c="",d=gf;return r!=null&&(r.unstable_strictMode===!0&&(i=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onRecoverableError!==void 0&&(d=r.onRecoverableError)),r=Nl(e,1,!1,null,null,i,!1,c,d),e[kn]=r.current,bs(e.nodeType===8?e.parentNode:e),new El(r)},Wt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var r=e._reactInternals;if(r===void 0)throw typeof e.render=="function"?Error(a(188)):(e=Object.keys(e).join(","),Error(a(268,e)));return e=Uc(r),e=e===null?null:e.stateNode,e},Wt.flushSync=function(e){return pr(e)},Wt.hydrate=function(e,r,i){if(!fi(r))throw Error(a(200));return hi(null,e,r,!0,i)},Wt.hydrateRoot=function(e,r,i){if(!Tl(e))throw Error(a(405));var c=i!=null&&i.hydratedSources||null,d=!1,m="",w=gf;if(i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(m=i.identifierPrefix),i.onRecoverableError!==void 0&&(w=i.onRecoverableError)),r=mf(r,null,e,1,i??null,d,!1,m,w),e[kn]=r.current,bs(e),c)for(e=0;e<c.length;e++)i=c[e],d=i._getVersion,d=d(i._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[i,d]:r.mutableSourceEagerHydrationData.push(i,d);return new di(r)},Wt.render=function(e,r,i){if(!fi(r))throw Error(a(200));return hi(null,e,r,!1,i)},Wt.unmountComponentAtNode=function(e){if(!fi(e))throw Error(a(40));return e._reactRootContainer?(pr(function(){hi(null,null,e,!1,function(){e._reactRootContainer=null,e[kn]=null})}),!0):!1},Wt.unstable_batchedUpdates=xl,Wt.unstable_renderSubtreeIntoContainer=function(e,r,i,c){if(!fi(i))throw Error(a(200));if(e==null||e._reactInternals===void 0)throw Error(a(38));return hi(e,r,i,!1,c)},Wt.version="18.3.1-next-f1338f8080-20240426",Wt}var Nf;function Th(){if(Nf)return Rl.exports;Nf=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(s){console.error(s)}}return t(),Rl.exports=cy(),Rl.exports}var Cf;function uy(){if(Cf)return pi;Cf=1;var t=Th();return pi.createRoot=t.createRoot,pi.hydrateRoot=t.hydrateRoot,pi}var dy=uy();/**
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 cc=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Ih=/^[\\/]{2}/;function fy(t,s){return s+t.replace(/\\/g,"/")}var Ef="popstate";function Tf(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function hy(t={}){function s(o,l){var v;let u=(v=l.state)==null?void 0:v.masked,{pathname:f,search:g,hash:p}=u||o.location;return Gl("",{pathname:f,search:g,hash:p},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:Nr(l)}return py(s,a,null,t)}function ct(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function an(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function my(){return Math.random().toString(36).substring(2,10)}function If(t,s){return{usr:t.state,key:t.key,idx:s,masked:t.mask?{pathname:t.pathname,search:t.search,hash:t.hash}:void 0}}function Gl(t,s,a=null,o,l){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof s=="string"?ns(s):s,state:a,key:s&&s.key||o||my(),mask:l}}function Nr({pathname:t="/",search:s="",hash:a=""}){return s&&s!=="?"&&(t+=s.charAt(0)==="?"?s:"?"+s),a&&a!=="#"&&(t+=a.charAt(0)==="#"?a:"#"+a),t}function ns(t){let s={};if(t){let a=t.indexOf("#");a>=0&&(s.hash=t.substring(a),t=t.substring(0,a));let o=t.indexOf("?");o>=0&&(s.search=t.substring(o),t=t.substring(0,o)),t&&(s.pathname=t)}return s}function py(t,s,a,o={}){let{window:l=document.defaultView,v5Compat:u=!1}=o,f=l.history,g="POP",p=null,v=y();v==null&&(v=0,f.replaceState({...f.state,idx:v},""));function y(){return(f.state||{idx:null}).idx}function x(){g="POP";let k=y(),E=k==null?null:k-v;v=k,p&&p({action:g,location:S.location,delta:E})}function j(k,E){g="PUSH";let T=Tf(k)?k:Gl(S.location,k,E);v=y()+1;let P=If(T,v),I=S.createHref(T.mask||T);try{f.pushState(P,"",I)}catch(U){if(U instanceof DOMException&&U.name==="DataCloneError")throw U;l.location.assign(I)}u&&p&&p({action:g,location:S.location,delta:1})}function N(k,E){g="REPLACE";let T=Tf(k)?k:Gl(S.location,k,E);v=y();let P=If(T,v),I=S.createHref(T.mask||T);f.replaceState(P,"",I),u&&p&&p({action:g,location:S.location,delta:0})}function b(k){return gy(l,k)}let S={get action(){return g},get location(){return t(l,f)},listen(k){if(p)throw new Error("A history only accepts one active listener");return l.addEventListener(Ef,x),p=k,()=>{l.removeEventListener(Ef,x),p=null}},createHref(k){return s(l,k)},createURL:b,encodeLocation(k){let E=b(k);return{pathname:E.pathname,search:E.search,hash:E.hash}},push:j,replace:N,go(k){return f.go(k)}};return S}function gy(t,s,a=!1){let o="http://localhost";t&&(o=t.location.origin!=="null"?t.location.origin:t.location.href),ct(o,"No window.location.(origin|href) available to create URL");let l=typeof s=="string"?s:Nr(s);return l=l.replace(/ $/,"%20"),!a&&Ih.test(l)&&(l=o+l),new URL(l,o)}function Ah(t,s,a="/"){return yy(t,s,a,!1)}function yy(t,s,a,o,l){let u=typeof s=="string"?ns(s):s,f=$n(u.pathname||"/",a);if(f==null)return null;let g=vy(t),p=null,v=Iy(f);for(let y=0;p==null&&y<g.length;++y)p=Ty(g[y],v,o);return p}function vy(t){let s=Rh(t);return xy(s),s}function Rh(t,s=[],a=[],o="",l=!1){let u=(f,g,p=l,v)=>{let y={relativePath:v===void 0?f.path||"":v,caseSensitive:f.caseSensitive===!0,childrenIndex:g,route:f};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&p)return;ct(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=mn([o,y.relativePath]),j=a.concat(y);f.children&&f.children.length>0&&(ct(f.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${x}".`),Rh(f.children,s,j,x,p)),!(f.path==null&&!f.index)&&s.push({path:x,score:Cy(x,f.index),routesMeta:j.map((N,b)=>{let[S,k]=_h(N.relativePath,N.caseSensitive,b===j.length-1);return{...N,matcher:S,compiledParams:k}})})};return t.forEach((f,g)=>{var p;if(f.path===""||!((p=f.path)!=null&&p.includes("?")))u(f,g);else for(let v of Ph(f.path))u(f,g,!0,v)}),s}function Ph(t){let s=t.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=Ph(o.join("/")),g=[];return g.push(...f.map(p=>p===""?u:[u,p].join("/"))),l&&g.push(...f),g.map(p=>t.startsWith("/")&&p===""?"/":p)}function xy(t){t.sort((s,a)=>s.score!==a.score?a.score-s.score:Ey(s.routesMeta.map(o=>o.childrenIndex),a.routesMeta.map(o=>o.childrenIndex)))}var wy=/^:[\w-]+$/,jy=3,Sy=2,by=1,ky=10,Ny=-2,Af=t=>t==="*";function Cy(t,s){let a=t.split("/"),o=a.length;return a.some(Af)&&(o+=Ny),s&&(o+=Sy),a.filter(l=>!Af(l)).reduce((l,u)=>l+(wy.test(u)?jy:u===""?by:ky),o)}function Ey(t,s){return t.length===s.length&&t.slice(0,-1).every((o,l)=>o===s[l])?t[t.length-1]-s[s.length-1]:0}function Ty(t,s,a=!1){let{routesMeta:o}=t,l={},u="/",f=[];for(let g=0;g<o.length;++g){let p=o[g],v=g===o.length-1,y=u==="/"?s:s.slice(u.length)||"/",x={path:p.relativePath,caseSensitive:p.caseSensitive,end:v},j=p.matcher&&p.compiledParams?$h(x,y,p.matcher,p.compiledParams):Ci(x,y),N=p.route;if(!j&&v&&a&&!o[o.length-1].route.index&&(j=Ci({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},y)),!j)return null;Object.assign(l,j.params),f.push({params:l,pathname:mn([u,j.pathname]),pathnameBase:Py(mn([u,j.pathnameBase])),route:N}),j.pathnameBase!=="/"&&(u=mn([u,j.pathnameBase]))}return f}function Ci(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[a,o]=_h(t.path,t.caseSensitive,t.end);return $h(t,s,a,o)}function $h(t,s,a,o){let l=s.match(a);if(!l)return null;let u=l[0],f=es(u,1),g=l.slice(1);return{params:o.reduce((v,{paramName:y,isOptional:x},j)=>{if(y==="*"){let b=g[j]||"";f=es(u.slice(0,u.length-b.length),1)}const N=g[j];return x&&!N?v[y]=void 0:v[y]=(N||"").replace(/%2F/g,"/"),v},{}),pathname:u,pathnameBase:f,pattern:t}}function _h(t,s=!1,a=!0){an(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let o=[],l="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(f,g,p,v,y)=>{if(o.push({paramName:g,isOptional:p!=null}),p){let x=y.charAt(v+f.length);return x&&x!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(o.push({paramName:"*"}),l+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?l+="\\/*$":t!==""&&t!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,s?void 0:"i"),o]}function Iy(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return an(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),t}}function $n(t,s){if(s==="/")return t;if(!t.toLowerCase().startsWith(s.toLowerCase()))return null;let a=s.endsWith("/")?s.length-1:s.length,o=t.charAt(a);return o&&o!=="/"?null:t.slice(a)||"/"}function Ay(t,s="/"){let{pathname:a,search:o="",hash:l=""}=typeof t=="string"?ns(t):t,u;return a?(a=Lh(a),a.startsWith("/")||a.startsWith("\\")?u=Rf(a.substring(1),"/"):u=Rf(a,s)):u=s,{pathname:u,search:$y(o),hash:_y(l)}}function Rf(t,s){let a=es(s).split("/");return t.split("/").forEach(l=>{l===".."?a.length>1&&a.pop():l!=="."&&a.push(l)}),a.length>1?a.join("/"):"/"}function _l(t,s,a,o){return`Cannot include a '${t}' 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 Ry(t){return t.filter((s,a)=>a===0||s.route.path&&s.route.path.length>0)}function uc(t){let s=Ry(t);return s.map((a,o)=>o===s.length-1?a.pathname:a.pathnameBase)}function Bi(t,s,a,o=!1){let l;typeof t=="string"?l=ns(t):(l={...t},ct(!l.pathname||!l.pathname.includes("?"),_l("?","pathname","search",l)),ct(!l.pathname||!l.pathname.includes("#"),_l("#","pathname","hash",l)),ct(!l.search||!l.search.includes("#"),_l("#","search","hash",l)));let u=t===""||l.pathname==="",f=u?"/":l.pathname,g;if(f==null)g=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("/")}g=x>=0?s[x]:"/"}let p=Ay(l,g),v=f&&f!=="/"&&f.endsWith("/"),y=(u||f===".")&&a.endsWith("/");return!p.pathname.endsWith("/")&&(v||y)&&(p.pathname+="/"),p}var Lh=t=>t.replace(/[\\/]{2,}/g,"/"),mn=t=>Lh(t.join("/"));function es(t,s=0){let a=t.length;for(;a>s&&t.charCodeAt(a-1)===47;)a--;return a===t.length?t:t.slice(0,a)}var Py=t=>es(t).replace(/^\/*/,"/"),$y=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,_y=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,Ly=class{constructor(t,s,a,o=!1){this.status=t,this.statusText=s||"",this.internal=o,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function zy(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function Fy(t){let s=t.map(a=>a.route.path).filter(Boolean);return mn(s)||"/"}var zh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Fh(t,s){let a=t;if(typeof a!="string"||!cc.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let o=a,l=!1;if(zh)try{let u=new URL(window.location.href),f=Ih.test(a)?new URL(fy(a,u.protocol)):new URL(a),g=$n(f.pathname,s);f.origin===u.origin&&g!=null?a=g+f.search+f.hash:l=!0}catch{an(!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 Pf=new URL("http://localhost");function dc(t){if(t.createURL)return t.createURL("/");try{return new URL(t.createHref("/"),Pf)}catch{return Pf}}function Ll(t,s){return t.origin===s.origin&&(t.origin!=="null"||t.protocol===s.protocol&&t.host===s.host)}function My(t,s){if(t.startsWith("//"))return!0;let a=s.protocol.toLowerCase();return t.toLowerCase().startsWith(a)?s.host===""||t.slice(a.length).startsWith("//"):!1}function fc(t,s,a,o){let l=null;try{l=t==null?null:new URL(t,a)}catch{}let u=new URL(s,a),f=l!=null&&!Ll(l,a),g=!Ll(u,a);if(o==="reject"){if(f||g)throw new Error("External navigation is not allowed")}else if(g&&(l==null||!My(t,l)||!Ll(l,u)))throw new Error("External navigation is not allowed")}var Mh=["POST","PUT","PATCH","DELETE"];new Set(Mh);var Oy=["GET",...Mh];new Set(Oy);var By=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Dy(t){try{return By.includes(new URL(t).protocol)}catch{return!1}}var rs=h.createContext(null);rs.displayName="DataRouter";var Di=h.createContext(null);Di.displayName="DataRouterState";var Oh=h.createContext(!1);function Uy(){return h.useContext(Oh)}var Bh=h.createContext({isTransitioning:!1});Bh.displayName="ViewTransition";var Wy=h.createContext(new Map);Wy.displayName="Fetchers";var Hy=h.createContext(null);Hy.displayName="Await";var Qt=h.createContext(null);Qt.displayName="Navigation";var na=h.createContext(null);na.displayName="Location";var pn=h.createContext({outlet:null,matches:[],isDataRoute:!1});pn.displayName="Route";var hc=h.createContext(null);hc.displayName="RouteError";var Dh="REACT_ROUTER_ERROR",Vy="REDIRECT",Gy="ROUTE_ERROR_RESPONSE";function Ky(t){if(t.startsWith(`${Dh}:${Vy}:{`))try{let s=JSON.parse(t.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 qy(t){if(t.startsWith(`${Dh}:${Gy}:{`))try{let s=JSON.parse(t.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new Ly(s.status,s.statusText,s.data)}catch{}}function Yy(t,{relative:s}={}){ct(ss(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:o}=h.useContext(Qt),{hash:l,pathname:u,search:f}=ra(t,{relative:s}),g=u;return a!=="/"&&(g=u==="/"?a:mn([a,u])),o.createHref({pathname:g,search:f,hash:l})}function ss(){return h.useContext(na)!=null}function Vt(){return ct(ss(),"useLocation() may be used only in the context of a <Router> component."),h.useContext(na).location}var Uh="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Wh(t){h.useContext(Qt).static||h.useLayoutEffect(t)}function gn(){let{isDataRoute:t}=h.useContext(pn);return t?uv():Jy()}function Jy(){ct(ss(),"useNavigate() may be used only in the context of a <Router> component.");let t=h.useContext(rs),{basename:s,navigator:a}=h.useContext(Qt),{matches:o}=h.useContext(pn),{pathname:l}=Vt(),u=JSON.stringify(uc(o)),f=h.useRef(!1);return Wh(()=>{f.current=!0}),h.useCallback((p,v={})=>{if(an(f.current,Uh),!f.current)return;if(typeof p=="number"){a.go(p);return}let y=Bi(p,JSON.parse(u),l,v.relative==="path");t==null&&s!=="/"&&(y.pathname=y.pathname==="/"?s:mn([s,y.pathname])),fc(typeof p=="string"?p:Nr(p),a.createHref(y),dc(a),"reject"),(v.replace?a.replace:a.push)(y,v.state,v)},[s,a,u,l,t])}var Qy=h.createContext(null);function Xy(t){let s=h.useContext(pn).outlet;return h.useMemo(()=>s&&h.createElement(Qy.Provider,{value:t},s),[s,t])}function ra(t,{relative:s}={}){let{matches:a}=h.useContext(pn),{pathname:o}=Vt(),l=JSON.stringify(uc(a));return h.useMemo(()=>Bi(t,JSON.parse(l),o,s==="path"),[t,l,o,s])}function Zy(t,s){return Hh(t,s)}function Hh(t,s,a){var k;ct(ss(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=h.useContext(Qt),{matches:l}=h.useContext(pn),u=l[l.length-1],f=u?u.params:{},g=u?u.pathname:"/",p=u?u.pathnameBase:"/",v=u&&u.route;{let E=v&&v.path||"";Gh(g,!v||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (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=Vt(),x;if(s){let E=typeof s=="string"?ns(s):s;ct(p==="/"||((k=E.pathname)==null?void 0:k.startsWith(p)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${p}" but pathname "${E.pathname}" was given in the \`location\` prop.`),x=E}else x=y;let j=x.pathname||"/",N=j;if(p!=="/"){let E=p.replace(/^\//,"").split("/");N="/"+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})):Ah(t,{pathname:N});an(v||b!=null,`No routes matched location "${x.pathname}${x.search}${x.hash}" `),an(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=sv(b&&b.map(E=>Object.assign({},E,{params:Object.assign({},f,E.params),pathname:mn([p,o.encodeLocation?o.encodeLocation(E.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?p:mn([p,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(na.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...x},navigationType:"POP"}},S):S}function ev(){let t=cv(),s=zy(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),a=t instanceof Error?t.stack:null,o="rgba(200,200,200, 0.5)",l={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},f=null;return console.error("Error handled by React Router default ErrorBoundary:",t),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 tv=h.createElement(ev,null),Vh=class extends h.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,s){return s.location!==t.location||s.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:s.error,location:s.location,revalidation:t.revalidation||s.revalidation}}componentDidCatch(t,s){this.props.onError?this.props.onError(t,s):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const a=qy(t.digest);a&&(t=a)}let s=t!==void 0?h.createElement(pn.Provider,{value:this.props.routeContext},h.createElement(hc.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?h.createElement(nv,{error:t},s):s}};Vh.contextType=Oh;var zl=new WeakMap;function nv({children:t,error:s}){let{basename:a,navigator:o}=h.useContext(Qt);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let l=Ky(s.digest);if(l){let u=zl.get(s);if(u)throw u;let f=Fh(l.location,a),g=f.absoluteURL||f.to;if(fc(l.location,g,dc(o),"allow-explicit"),Dy(g))throw new Error("Invalid redirect location");if(zh&&!zl.get(s))if(f.isExternal||l.reloadDocument)window.location.href=g;else{const p=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(f.to,{replace:l.replace}));throw zl.set(s,p),p}return h.createElement("meta",{httpEquiv:"refresh",content:`0;url=${g}`})}}return t}function rv({routeContext:t,match:s,children:a}){let o=h.useContext(rs);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),h.createElement(pn.Provider,{value:t},a)}function sv(t,s=[],a){let o=a==null?void 0:a.state;if(t==null){if(!o)return null;if(o.errors)t=o.matches;else if(s.length===0&&!o.initialized&&o.matches.length>0)t=o.matches;else return null}let l=t,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);ct(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,g=-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)&&(g=y),x.route.id){let{loaderData:j,errors:N}=o,b=x.route.loader&&!j.hasOwnProperty(x.route.id)&&(!N||N[x.route.id]===void 0);if(x.route.lazy||b){a.isStatic&&(f=!0),g>=0?l=l.slice(0,g+1):l=[l[0]];break}}}}let p=a==null?void 0:a.onError,v=o&&p?(y,x)=>{var j,N;p(y,{location:o.location,params:((N=(j=o.matches)==null?void 0:j[0])==null?void 0:N.params)??{},pattern:Fy(o.matches),errorInfo:x})}:void 0;return l.reduceRight((y,x,j)=>{let N,b=!1,S=null,k=null;o&&(N=u&&x.route.id?u[x.route.id]:void 0,S=x.route.errorElement||tv,f&&(g<0&&j===0?(Gh("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,k=null):g===j&&(b=!0,k=x.route.hydrateFallbackElement||null)));let E=s.concat(l.slice(0,j+1)),T=()=>{let P;return N?P=S:b?P=k:x.route.Component?P=h.createElement(x.route.Component,null):x.route.element?P=x.route.element:P=y,h.createElement(rv,{match:x,routeContext:{outlet:y,matches:E,isDataRoute:o!=null},children:P})};return o&&(x.route.ErrorBoundary||x.route.errorElement||j===0)?h.createElement(Vh,{location:o.location,revalidation:o.revalidation,component:S,error:N,children:T(),routeContext:{outlet:null,matches:E,isDataRoute:!0},onError:v}):T()},null)}function mc(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function av(t){let s=h.useContext(rs);return ct(s,mc(t)),s}function iv(t){let s=h.useContext(Di);return ct(s,mc(t)),s}function ov(t){let s=h.useContext(pn);return ct(s,mc(t)),s}function pc(t){let s=ov(t),a=s.matches[s.matches.length-1];return ct(a.route.id,`${t} can only be used on routes that contain a unique "id"`),a.route.id}function lv(){return pc("useRouteId")}function cv(){var o;let t=h.useContext(hc),s=iv("useRouteError"),a=pc("useRouteError");return t!==void 0?t:(o=s.errors)==null?void 0:o[a]}function uv(){let{router:t}=av("useNavigate"),s=pc("useNavigate"),a=h.useRef(!1);return Wh(()=>{a.current=!0}),h.useCallback(async(l,u={})=>{an(a.current,Uh),a.current&&(typeof l=="number"?await t.navigate(l):await t.navigate(l,{fromRouteId:s,...u}))},[t,s])}var $f={};function Gh(t,s,a){!s&&!$f[t]&&($f[t]=!0,an(!1,a))}h.memo(dv);function dv({routes:t,manifest:s,future:a,state:o,isStatic:l,onError:u}){return Hh(t,void 0,{manifest:s,state:o,isStatic:l,onError:u})}function Pn({to:t,replace:s,state:a,relative:o}){ct(ss(),"<Navigate> may be used only in the context of a <Router> component.");let{static:l,navigator:u}=h.useContext(Qt);an(!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(pn),{pathname:g}=Vt(),p=gn(),v=Bi(t,uc(f),g,o==="path");fc(typeof t=="string"?t:Nr(t),u.createHref(v),dc(u),"reject");let y=JSON.stringify(v);return h.useEffect(()=>{p(JSON.parse(y),{replace:s,state:a,relative:o})},[p,y,o,s,a]),null}function fv(t){return Xy(t.context)}function rt(t){ct(!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:t="/",children:s=null,location:a,navigationType:o="POP",navigator:l,static:u=!1,useTransitions:f}){ct(!ss(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let g=t.replace(/^\/*/,"/"),p=h.useMemo(()=>({basename:g,navigator:l,static:u,useTransitions:f,future:{}}),[g,l,u,f]);typeof a=="string"&&(a=ns(a));let{pathname:v="/",search:y="",hash:x="",state:j=null,key:N="default",mask:b}=a,S=h.useMemo(()=>{let k=$n(v,g);return k==null?null:{location:{pathname:k,search:y,hash:x,state:j,key:N,mask:b},navigationType:o}},[g,v,y,x,j,N,o,b]);return an(S!=null,`<Router basename="${g}"> 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(Qt.Provider,{value:p},h.createElement(na.Provider,{children:s,value:S}))}function mv({children:t,location:s}){return Zy(Kl(t),s)}function Kl(t,s=[]){let a=[];return h.Children.forEach(t,(o,l)=>{if(!h.isValidElement(o))return;let u=[...s,l];if(o.type===h.Fragment){a.push.apply(a,Kl(o.props.children,u));return}ct(o.type===rt,`[${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>`),ct(!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=Kl(o.props.children,u)),a.push(f)}),a}var Si="get",bi="application/x-www-form-urlencoded";function Ui(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function pv(t){return Ui(t)&&t.tagName.toLowerCase()==="button"}function gv(t){return Ui(t)&&t.tagName.toLowerCase()==="form"}function yv(t){return Ui(t)&&t.tagName.toLowerCase()==="input"}function vv(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function xv(t,s){return t.button===0&&(!s||s==="_self")&&!vv(t)}function ql(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((s,a)=>{let o=t[a];return s.concat(Array.isArray(o)?o.map(l=>[a,l]):[[a,o]])},[]))}function wv(t,s){let a=ql(t);return s&&s.forEach((o,l)=>{a.has(l)||s.getAll(l).forEach(u=>{a.append(l,u)})}),a}var gi=null;function jv(){if(gi===null)try{new FormData(document.createElement("form"),0),gi=!1}catch{gi=!0}return gi}var Sv=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Fl(t){return t!=null&&!Sv.has(t)?(an(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${bi}"`),null):t}function bv(t,s){let a,o,l,u,f;if(gv(t)){let g=t.getAttribute("action");o=g?$n(g,s):null,a=t.getAttribute("method")||Si,l=Fl(t.getAttribute("enctype"))||bi,u=new FormData(t)}else if(pv(t)||yv(t)&&(t.type==="submit"||t.type==="image")){let g=t.form;if(g==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=t.getAttribute("formaction")||g.getAttribute("action");if(o=p?$n(p,s):null,a=t.getAttribute("formmethod")||g.getAttribute("method")||Si,l=Fl(t.getAttribute("formenctype"))||Fl(g.getAttribute("enctype"))||bi,u=new FormData(g,t),!jv()){let{name:v,type:y,value:x}=t;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(Ui(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=Si,o=null,l=bi,f=t}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 gc(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function Kh(t,s,a,o){let l=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return a?l.pathname.endsWith("/")?l.pathname=`${l.pathname}_.${o}`:l.pathname=`${l.pathname}.${o}`:l.pathname==="/"?l.pathname=`_root.${o}`:s&&$n(l.pathname,s)==="/"?l.pathname=`${es(s)}/_root.${o}`:l.pathname=`${es(l.pathname)}.${o}`,l}async function kv(t,s){if(t.id in s)return s[t.id];try{let a=await import(t.module);return s[t.id]=a,a}catch(a){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Nv(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function Cv(t,s,a){let o=await Promise.all(t.map(async l=>{let u=s.routes[l.route.id];if(u){let f=await kv(u,a);return f.links?f.links():[]}return[]}));return Av(o.flat(1).filter(Nv).filter(l=>l.rel==="stylesheet"||l.rel==="preload").map(l=>l.rel==="stylesheet"?{...l,rel:"prefetch",as:"style"}:{...l,rel:"prefetch"}))}function _f(t,s,a,o,l,u){let f=(p,v)=>a[v]?p.route.id!==a[v].route.id:!0,g=(p,v)=>{var y;return a[v].pathname!==p.pathname||((y=a[v].route.path)==null?void 0:y.endsWith("*"))&&a[v].params["*"]!==p.params["*"]};return u==="assets"?s.filter((p,v)=>f(p,v)||g(p,v)):u==="data"?s.filter((p,v)=>{var x;let y=o.routes[p.route.id];if(!y||!y.hasLoader)return!1;if(f(p,v)||g(p,v))return!0;if(p.route.shouldRevalidate){let j=p.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(t,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof j=="boolean")return j}return!0}):[]}function Ev(t,s,{includeHydrateFallback:a}={}){return Tv(t.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 Tv(t){return[...new Set(t)]}function Iv(t){let s={},a=Object.keys(t).sort();for(let o of a)s[o]=t[o];return s}function Av(t,s){let a=new Set;return new Set(s),t.reduce((o,l)=>{let u=JSON.stringify(Iv(l));return a.has(u)||(a.add(u),o.push({key:u,link:l})),o},[])}function yc(){let t=h.useContext(rs);return gc(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Rv(){let t=h.useContext(Di);return gc(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var vc=h.createContext(void 0);vc.displayName="FrameworkContext";function Wi(){let t=h.useContext(vc);return gc(t,"You must render this element inside a <HydratedRouter> element"),t}function Pv(t,s){let a=h.useContext(vc),[o,l]=h.useState(!1),[u,f]=h.useState(!1),{onFocus:g,onBlur:p,onMouseEnter:v,onMouseLeave:y,onTouchStart:x}=s,j=h.useRef(null);h.useEffect(()=>{if(t==="render"&&f(!0),t==="viewport"){let S=E=>{E.forEach(T=>{f(T.isIntersecting)})},k=new IntersectionObserver(S,{threshold:.5});return j.current&&k.observe(j.current),()=>{k.disconnect()}}},[t]),h.useEffect(()=>{if(o){let S=setTimeout(()=>{f(!0)},100);return()=>{clearTimeout(S)}}},[o]);let N=()=>{l(!0)},b=()=>{l(!1),f(!1)};return a?t!=="intent"?[u,j,{}]:[u,j,{onFocus:Ws(g,N),onBlur:Ws(p,b),onMouseEnter:Ws(v,N),onMouseLeave:Ws(y,b),onTouchStart:Ws(x,N)}]:[!1,j,{}]}function Ws(t,s){return a=>{t&&t(a),a.defaultPrevented||s(a)}}function $v({page:t,...s}){let a=Uy(),{nonce:o}=Wi(),{router:l}=yc(),u=h.useMemo(()=>Ah(l.routes,t,l.basename),[l.routes,t,l.basename]);return u?(s.nonce==null&&o&&(s={...s,nonce:o}),a?h.createElement(Lv,{page:t,matches:u,...s}):h.createElement(zv,{page:t,matches:u,...s})):null}function _v(t){let{manifest:s,routeModules:a}=Wi(),[o,l]=h.useState([]);return h.useEffect(()=>{let u=!1;return Cv(t,s,a).then(f=>{u||l(f)}),()=>{u=!0}},[t,s,a]),o}function Lv({page:t,matches:s,...a}){let o=Vt(),{future:l}=Wi(),{basename:u}=yc(),f=h.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let g=Kh(t,u,l.v8_trailingSlashAwareDataRequests,"rsc"),p=!1,v=[];for(let y of s)typeof y.route.shouldRevalidate=="function"?p=!0:v.push(y.route.id);return p&&v.length>0&&g.searchParams.set("_routes",v.join(",")),[g.pathname+g.search]},[u,l.v8_trailingSlashAwareDataRequests,t,o,s]);return h.createElement(h.Fragment,null,f.map(g=>h.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...a})))}function zv({page:t,matches:s,...a}){let o=Vt(),{future:l,manifest:u,routeModules:f}=Wi(),{basename:g}=yc(),{loaderData:p,matches:v}=Rv(),y=h.useMemo(()=>_f(t,s,v,u,o,"data"),[t,s,v,u,o]),x=h.useMemo(()=>_f(t,s,v,u,o,"assets"),[t,s,v,u,o]),j=h.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let S=new Set,k=!1;if(s.forEach(T=>{var I;let P=u.routes[T.route.id];!P||!P.hasLoader||(!y.some(U=>U.route.id===T.route.id)&&T.route.id in p&&((I=f[T.route.id])!=null&&I.shouldRevalidate)||P.hasClientLoader?k=!0:S.add(T.route.id))}),S.size===0)return[];let E=Kh(t,g,l.v8_trailingSlashAwareDataRequests,"data");return k&&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]},[g,l.v8_trailingSlashAwareDataRequests,p,o,u,y,s,t,f]),N=h.useMemo(()=>Ev(x,u),[x,u]),b=_v(x);return h.createElement(h.Fragment,null,j.map(S=>h.createElement("link",{key:S,rel:"prefetch",as:"fetch",href:S,...a})),N.map(S=>h.createElement("link",{key:S,rel:"modulepreload",href:S,...a})),b.map(({key:S,link:k})=>h.createElement("link",{key:S,nonce:a.nonce,...k,crossOrigin:k.crossOrigin??a.crossOrigin})))}function Fv(...t){return s=>{t.forEach(a=>{typeof a=="function"?a(s):a!=null&&(a.current=s)})}}var Mv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Mv&&(window.__reactRouterVersion="7.18.4")}catch{}function Ov({basename:t,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,g]=h.useState({action:u.action,location:u.location}),p=h.useCallback(v=>{a===!1?g(v):h.startTransition(()=>g(v))},[a]);return h.useLayoutEffect(()=>u.listen(p),[u,p]),h.createElement(hv,{basename:t,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:g,state:p,target:v,to:y,preventScrollReset:x,viewTransition:j,defaultShouldRevalidate:N,...b},S){let{basename:k,navigator:E,useTransitions:T}=h.useContext(Qt),P=typeof y=="string"&&cc.test(y),I=Fh(y,k);y=I.to;let U=Yy(y,{relative:l}),V=Vt(),z=null;if(g){let Y=Bi(g,[],V.mask?V.mask.pathname:"/",!0);k!=="/"&&(Y.pathname=Y.pathname==="/"?k:mn([k,Y.pathname])),z=E.createHref(Y)}let[J,Q,ne]=Pv(o,b),ee=Uv(y,{replace:f,mask:g,state:p,target:v,preventScrollReset:x,relative:l,viewTransition:j,defaultShouldRevalidate:N,useTransitions:T});function L(Y){s&&s(Y),Y.defaultPrevented||ee(Y)}let oe=!(I.isExternal||u),de=h.createElement("a",{...b,...ne,href:(oe?z:void 0)||I.absoluteURL||U,onClick:oe?L:s,ref:Fv(S,Q),target:v,"data-discover":!P&&a==="render"?"true":void 0});return J&&!P?h.createElement(h.Fragment,null,de,h.createElement($v,{page:U})):de});mt.displayName="Link";var xc=h.forwardRef(function({"aria-current":s="page",caseSensitive:a=!1,className:o="",end:l=!1,style:u,to:f,viewTransition:g,children:p,...v},y){let x=ra(f,{relative:v.relative}),j=Vt(),N=h.useContext(Di),{navigator:b,basename:S}=h.useContext(Qt),k=N!=null&&Kv(x)&&g===!0,E=b.encodeLocation?b.encodeLocation(x).pathname:x.pathname,T=j.pathname,P=N&&N.navigation&&N.navigation.location?N.navigation.location.pathname:null;a||(T=T.toLowerCase(),P=P?P.toLowerCase():null,E=E.toLowerCase()),P&&S&&(P=$n(P,S)||P);const I=E!=="/"&&E.endsWith("/")?E.length-1:E.length;let U=T===E||!l&&T.startsWith(E)&&T.charAt(I)==="/",V=P!=null&&(P===E||!l&&P.startsWith(E)&&P.charAt(E.length)==="/"),z={isActive:U,isPending:V,isTransitioning:k},J=U?s:void 0,Q;typeof o=="function"?Q=o(z):Q=[o,U?"active":null,V?"pending":null,k?"transitioning":null].filter(Boolean).join(" ");let ne=typeof u=="function"?u(z):u;return h.createElement(mt,{...v,"aria-current":J,className:Q,ref:y,style:ne,to:f,viewTransition:g},typeof p=="function"?p(z):p)});xc.displayName="NavLink";var Bv=h.forwardRef(({discover:t="render",fetcherKey:s,navigate:a,reloadDocument:o,replace:l,state:u,method:f=Si,action:g,onSubmit:p,relative:v,preventScrollReset:y,viewTransition:x,defaultShouldRevalidate:j,...N},b)=>{let{useTransitions:S}=h.useContext(Qt),k=Vv(),E=Gv(g,{relative:v}),T=f.toLowerCase()==="get"?"get":"post",P=typeof g=="string"&&cc.test(g),I=U=>{if(p&&p(U),U.defaultPrevented)return;U.preventDefault();let V=U.nativeEvent.submitter,z=(V==null?void 0:V.getAttribute("formmethod"))||f,J=()=>k(V||U.currentTarget,{fetcherKey:s,method:z,navigate:a,replace:l,state:u,relative:v,preventScrollReset:y,viewTransition:x,defaultShouldRevalidate:j});S&&a!==!1?h.startTransition(()=>J()):J()};return h.createElement("form",{ref:b,method:T,action:E,onSubmit:o?p:I,...N,"data-discover":!P&&t==="render"?"true":void 0})});Bv.displayName="Form";function Dv(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function qh(t){let s=h.useContext(rs);return ct(s,Dv(t)),s}function Uv(t,{target:s,replace:a,mask:o,state:l,preventScrollReset:u,relative:f,viewTransition:g,defaultShouldRevalidate:p,useTransitions:v}={}){let y=gn(),x=Vt(),j=ra(t,{relative:f});return h.useCallback(N=>{if(xv(N,s)){N.preventDefault();let b=a!==void 0?a:Nr(x)===Nr(j),S=()=>y(t,{replace:b,mask:o,state:l,preventScrollReset:u,relative:f,viewTransition:g,defaultShouldRevalidate:p});v?h.startTransition(()=>S()):S()}},[x,y,j,a,o,l,s,t,u,f,g,p,v])}function sa(t){an(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(ql(t)),a=h.useRef(!1),o=Vt(),l=h.useMemo(()=>wv(o.search,a.current?null:s.current),[o.search]),u=gn(),f=h.useCallback((g,p)=>{const v=ql(typeof g=="function"?g(new URLSearchParams(l)):g);a.current=!0,u("?"+v,p)},[u,l]);return[l,f]}var Wv=0,Hv=()=>`__${String(++Wv)}__`;function Vv(){let{router:t}=qh("useSubmit"),{basename:s}=h.useContext(Qt),a=lv(),o=t.fetch,l=t.navigate;return h.useCallback(async(u,f={})=>{let{action:g,method:p,encType:v,formData:y,body:x}=bv(u,s);if(f.navigate===!1){let j=f.fetcherKey||Hv();await o(j,a,f.action||g,{defaultShouldRevalidate:f.defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:x,formMethod:f.method||p,formEncType:f.encType||v,flushSync:f.flushSync})}else await l(f.action||g,{defaultShouldRevalidate:f.defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:x,formMethod:f.method||p,formEncType:f.encType||v,replace:f.replace,state:f.state,fromRouteId:a,flushSync:f.flushSync,viewTransition:f.viewTransition})},[o,l,s,a])}function Gv(t,{relative:s}={}){let{basename:a}=h.useContext(Qt),o=h.useContext(pn);ct(o,"useFormAction must be used inside a RouteContext");let[l]=o.matches.slice(-1),u={...ra(t||".",{relative:s})},f=Vt();if(t==null){u.search=f.search;let g=new URLSearchParams(u.search),p=g.getAll("index");if(p.some(y=>y==="")){g.delete("index"),p.filter(x=>x).forEach(x=>g.append("index",x));let y=g.toString();u.search=y?`?${y}`:""}}return(!t||t===".")&&l.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(u.pathname=u.pathname==="/"?a:mn([a,u.pathname])),Nr(u)}function Kv(t,{relative:s}={}){let a=h.useContext(Bh);ct(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=qh("useViewTransitionState"),l=ra(t,{relative:s});if(!a.isTransitioning)return!1;let u=$n(a.currentLocation.pathname,o)||a.currentLocation.pathname,f=$n(a.nextLocation.pathname,o)||a.nextLocation.pathname;return Ci(l.pathname,f)!=null||Ci(l.pathname,u)!=null}var qv=Th();const Sr="owner";function Yv(t){const s=t||Sr;return s===Sr?[Sr]:[s,Sr]}function Jv(t){const s=new Map;for(const a of t)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 Qv(t,s){const a=s||Sr,o=(t==null?void 0:t.pendingDomains)??[];return o.includes(a)?a:o.includes(Sr)?Sr:a}class Yh extends Error{constructor(a){super("different_account");Ds(this,"summary");this.name="DifferentAccountError",this.summary=a}}function Jh(t){return t.grantors??t.approvers}function Xv(t){return t.approvals??1}function Ge(t,s){const a=t??{},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 Zv(t){const s=t==null?void 0:t.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 ex{constructor(){Ds(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 Yh(u.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!o.ok){const u=await o.json().catch(()=>({error:"Invalid API key"}));throw new Error(Ge(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(Ge(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,g;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(p=>!(u.attestedDomains??[]).includes(p)),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(p=>p.expiresAt))*1e3).toISOString():null,remaining_seconds:(g=u.attestations)!=null&&g.length?Math.max(0,Math.min(...u.attestations.map(p=>p.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(Ge(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 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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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 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:Ge(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:Ge(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 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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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?Zv(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(Ge(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(Yv(s).map(l=>this.getProposals(l,a)));return Jv(o)}async resolveProposal(s,a,o,l){const{noteEncrypted:u,contentHash:f,shownHash:g,note:p,...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}:p?{note:p}:{},...f?{content_hash:f}:{},...g?{shown_hash:g}:{}})});if(!y.ok){const x=await y.json().catch(()=>({error:"Failed"}));throw new Error(Ge(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(Ge(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(Ge(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:g,note:p,...v}=a??{};u={...v,...g?{note_encrypted:g}:p?{note:p}:{}}}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 g=await f.json().catch(()=>({error:"Failed"}));throw new Error(Ge(g,`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??{},g={...u?{note_encrypted:u}:f?{note:f}:{}};o&&(g.content_hash=o),l&&(g.shown_hash=l);const p=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/withdraw`,{method:"POST",body:JSON.stringify(g)});if(!p.ok){const v=await p.json().catch(()=>({error:"Failed"}));throw new Error(Ge(v,`withdrawProposal failed: ${p.status}`))}return p.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(Ge(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(Ge(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(Ge(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(Ge(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 g,p;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:(g=l.mandates)!=null&&g.length?new Date(Math.min(...l.mandates.map(v=>v.expiresAt))*1e3).toISOString():null,remaining_seconds:(p=l.mandates)!=null&&p.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=[],g=new Date;for(let v=0;v<a;v++){const y=new Date(g);y.setUTCDate(g.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(Ge(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(Ge(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:Ge(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(Ge(l,`Save failed: ${o.status}`))}}}const F=new ex,Qh=h.createContext(null);function tx({children:t}){const[s,a]=h.useState(null),[o,l]=h.useState("personal"),[u,f]=h.useState(null),[g,p]=h.useState(""),[v,y]=h.useState(null),[x,j]=h.useState(null),[N,b]=h.useState(null),[S,k]=h.useState(!1),[E,T]=h.useState(""),P=h.useRef(!1),I=h.useRef(null),U=h.useCallback(async()=>{if(P.current)try{const ee=await F.getMyTeam();if(b(ee.pendingRequest),ee.group&&ee.membership){const{group:L,membership:oe}=ee;y(L),j(oe),l("team"),f(L);const de=I.current??oe.domains[0]??"owner";p(de)}else y(null),j(null),l("personal")}catch{}},[]);h.useEffect(()=>{const ee=()=>{document.visibilityState==="visible"&&U()};return document.addEventListener("visibilitychange",ee),()=>document.removeEventListener("visibilitychange",ee)},[U]),h.useEffect(()=>{fetch("/health").then(ee=>ee.json()).then(ee=>{var L;((L=ee.session)==null?void 0:L.lockedReason)==="as-url-changed"&&T(`Authority Server changed to ${ee.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const V=h.useCallback(async(ee,L={})=>{k(!0),T("");try{F.setApiKey(ee),P.current=!0;const oe=await F.login(ee,L);a(oe),I.current=oe.id;const de=await F.getGroups(),Y=de.find(je=>je.isPersonal)??de[0]??null;f(Y),p("owner"),await U()}catch(oe){throw F.clearApiKey(),P.current=!1,T(oe instanceof Error?oe.message:"Login failed"),oe}finally{k(!1)}},[U]),z=h.useCallback(async()=>{await F.logout(),F.clearApiKey(),P.current=!1,I.current=null,a(null),f(null),p(""),y(null),j(null),b(null),l("personal"),T("")},[]),J=h.useCallback(ee=>{F.clearApiKey(),P.current=!1,I.current=null,a(null),f(null),p(""),y(null),j(null),b(null),l("personal"),T(ee??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),Q=h.useCallback(()=>T(""),[]),ne=h.useCallback((ee,L)=>{f(ee),p(L)},[]);return n.jsx(Qh.Provider,{value:{user:s,mode:o,group:u,domain:g,groupId:(u==null?void 0:u.id)??null,activeTeam:v,activeMembership:x,pendingRequest:N,isLoading:S,error:E,login:V,logout:z,clearError:Q,handleSessionLocked:J,activeGroup:u,activeDomain:g,groups:u?[u]:[],setActiveContext:ne,refreshGroups:U},children:t})}function vt(){const t=h.useContext(Qh);if(!t)throw new Error("useAuth must be used within AuthProvider");return t}const nx={"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},rx=Object.keys(nx),Xh=h.createContext(null);function sx({children:t}){const{user:s}=vt(),a=h.useRef(null),[o,l]=h.useState(!1),u=h.useRef(new Map),f=h.useCallback((g,p)=>{const v=u.current;return v.has(g)||v.set(g,new Set),v.get(g).add(p),()=>{var y;(y=v.get(g))==null||y.delete(p)}},[]);return h.useEffect(()=>{if(!s){a.current&&(a.current.close(),a.current=null,l(!1));return}if(a.current)return;const g=F.getApiKey();if(!g)return;const p=new EventSource(`/events?key=${encodeURIComponent(g)}`);a.current=p,p.onopen=()=>l(!0),p.onerror=()=>l(!1);for(const v of rx)p.addEventListener(v,y=>{let x;try{x=JSON.parse(y.data)}catch{x=null}const j=u.current.get(v);if(j)for(const N of j)try{N(x)}catch(b){console.error(`[EventSource] handler for "${v}" threw:`,b)}});return()=>{p.close(),a.current=null,l(!1)}},[s]),n.jsx(Xh.Provider,{value:{connected:o,addListener:f},children:t})}function Be(t,s){const a=h.useContext(Xh);if(!a)return;const{addListener:o}=a;h.useEffect(()=>o(t,s),[t,s,o])}const Js="suveren-theme",Lf="hap-theme";function yi(t){return t!=="system"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const s=localStorage.getItem(Lf);s!==null&&localStorage.getItem(Js)===null&&localStorage.setItem(Js,s),s!==null&&localStorage.removeItem(Lf)})();function Zh(){const[t,s]=h.useState(()=>{const u=localStorage.getItem(Js);return u==="light"||u==="dark"?u:"system"}),[a,o]=h.useState(()=>yi(t));h.useEffect(()=>{const u=document.documentElement,f=yi(t);u.setAttribute("data-theme",f),t==="system"?localStorage.removeItem(Js):localStorage.setItem(Js,t),o(yi(t))},[t]),h.useEffect(()=>{if(t!=="system")return;const u=window.matchMedia("(prefers-color-scheme: dark)"),f=()=>o(yi("system"));return u.addEventListener("change",f),()=>u.removeEventListener("change",f)},[t]);const l=h.useCallback(()=>{s(u=>u==="system"?"light":u==="light"?"dark":"system")},[]);return{theme:t,effectiveTheme:a,toggle:l}}const ax=300*1e3,ix=2e3;function wc(){const[t,s]=h.useState(!1),[a,o]=h.useState("docker"),[l,u]=h.useState(""),[f,g]=h.useState(null),[p,v]=h.useState(!1),[y,x]=h.useState(!1),[j,N]=h.useState(!1),b=h.useRef(null);return h.useEffect(()=>{let S=!1;const k=(P=!1)=>{fetch(P?"/health?refresh=1":"/health").then(I=>I.json()).then(I=>{S||(I.installMethod&&o(I.installMethod),typeof I.latestVersion<"u"&&g(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(()=>{})};k(!0);const E=setInterval(()=>k(!1),j?ix:ax),T=()=>{document.visibilityState==="visible"&&k(!1)};return document.addEventListener("visibilitychange",T),window.addEventListener("focus",T),()=>{S=!0,clearInterval(E),document.removeEventListener("visibilitychange",T),window.removeEventListener("focus",T)}},[j]),{updateAvailable:t&&!y,installMethod:a,version:l,latestVersion:f,serverRestarted:p,startFastPolling:()=>N(!0),dismiss:()=>x(!0)}}function ox(t){return!t||typeof t!="object"?{managed:!1}:{managed:Array.isArray(t.policyLocked)&&t.policyLocked.includes("team")}}function lx(){const[t,s]=h.useState({managed:!1});return h.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(ox(o))}).catch(()=>{}),()=>{a=!0}},[]),t}function cx({size:t=20}){return n.jsxs("svg",{width:t,height:t,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 ux(t){return t?t==="dev"?"dev":/^[0-9a-f]{40}$/i.test(t)?t.slice(0,7):t:""}const zf={system:"◑",light:"☀",dark:"☾"};function jc({onMenuToggle:t}){const{user:s,logout:a,mode:o,activeTeam:l}=vt(),{theme:u,toggle:f}=Zh(),{version:g,updateAvailable:p,latestVersion:v}=wc(),{managed:y}=lx(),x=ux(g),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(cx,{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:p&&v?`Running v${x} — v${v} is available`:"Running gateway version","data-stale":p?"true":void 0,children:["v",x,p&&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:zf[u]}),n.jsx("button",{className:"nav-logout",onClick:a,children:"Logout"})]}):n.jsx("button",{className:"theme-toggle",onClick:f,title:`Theme: ${u}`,children:zf[u]})}),s&&t&&n.jsx("button",{className:"mobile-menu-btn",onClick:t,"aria-label":"Menu",children:"☰"})]})})}function Sc(t,s){var a;if((a=s==null?void 0:s.revokedSet)!=null&&a.has(t.authorization_id))return"revoked";switch(t.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return t.remaining_seconds===null||t.remaining_seconds<=0?"expired":t.missing_domains.length>0?"pending":"active"}function em(t){return t==="expired"||t==="revoked"}function tm(t,s){var a;return!!((a=s==null?void 0:s.archivedSet)!=null&&a.has(t.authorization_id))&&em(Sc(t,s))}function Ei(t,s){return tm(t,s)?"archived":Sc(t,s)}function nm(t,s){const a={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const o of t)a[Ei(o,s)].push(o);return a}function dx(t,s){return s==="expired"?t.earliest_expiry?{iso:t.earliest_expiry,meaning:"expired"}:null:t.created_at?{iso:t.created_at,meaning:"created"}:null}function Lt(t,s,a){const o=h.useRef(t);o.current=t,h.useEffect(()=>{let l=null;const u=()=>typeof document>"u"?!0:document.visibilityState==="visible",f=()=>{u()&&o.current()},g=()=>{l===null&&(l=setInterval(f,s))},p=()=>{l!==null&&(clearInterval(l),l=null)},v=()=>{u()?(o.current(),g()):p()};return u()&&(o.current(),g()),document.addEventListener("visibilitychange",v),()=>{p(),document.removeEventListener("visibilitychange",v)}},[s,a])}function bc(){const[t,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)}},[]),t}function fx(t,s){const a=t.simulation;return a?(((s==null?void 0:s[a.field])??"").trim().toLowerCase()||a.default.trim().toLowerCase())==="simulation":!1}function Zs(t){return!!(t!=null&&t.simulation)}const rm=h.createContext(null),hx=3e4,mx=5e3,px=3e5;function gx(t,s,a){return s===0?"loading":t!=null&&t.running?"running":t!=null&&t.paused?"paused":t!=null&&t.error?"error":t&&a?"starting":"not-running"}function yx({children:t}){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([F.getIntegrationManifests().catch(()=>(y=!0,{manifests:[]})),F.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 N=x.manifests.filter(b=>b.oauth);if(N.length>0){const b=await Promise.all(N.map(async S=>[S.id,await F.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});Be("integration-changed",l),Lt(l,u?mx:px);const f=h.useMemo(()=>{const y=new Map(s.integrations.map(N=>[N.id,N])),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(N=>{const b=y.get(N.id),S=gx(b,s.fetchCount,j),k=s.authHealth[N.id];return{id:N.id,manifest:N,integration:b,state:S,authStatus:k==null?void 0:k.status,authAccount:k==null?void 0:k.account,authError:k==null?void 0:k.error}})},[s,u]),g=bc(),p=h.useMemo(()=>f.filter(y=>!(g&&!Zs(y.manifest))&&(y.state==="not-running"||y.state==="error"||y.authStatus==="failed")).length,[f,g]),v={loading:s.fetchCount===0,mcpServerUp:s.mcpServerUp,manifestsError:s.manifestsError,entries:f,attentionCount:p,activeSessions:s.activeSessions,refresh:l};return n.jsx(rm.Provider,{value:v,children:t})}function kc(){const t=h.useContext(rm);if(!t)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return t}const vx={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},Nc=t=>vx[t]??t,xx={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 wx(t){return(t&&xx[t])??{chip:"Blocked",sev:"info"}}function jx(t){const s=Nc(t.integrationId);switch(t.reason){case"resource":return t.integrationId==="calendar"?n.jsxs(n.Fragment,{children:["Tried to read your ",n.jsx("b",{children:t.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:t.detail})}}function sm(t,s){const a=Math.max(0,(s-t)/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 Sx=5,bx=1440*60*1e3,Yl=7;function kx(t,s){const a=s-Yl*bx;return{recent:t.filter(o=>o.ts>=a),all:t}}function Nx(){const[t,s]=h.useState(null),[a,o]=h.useState(!1),l=h.useCallback(()=>{F.getDenials({limit:200}).then(({records:v})=>{s(v),o(!1)}).catch(()=>o(!0))},[]);if(h.useEffect(()=>{l()},[l]),Lt(l,12e4),a||t===null)return null;const{recent:u,all:f}=kx(t,Date.now()),g=u.slice(0,Sx),p=(v,y)=>{const x=wx(v.reason);return n.jsxs("div",{className:"rb-row",children:[n.jsx("span",{className:`rb-dot ${x.sev==="act"?"act":x.sev==="info"?"info":""}`,"aria-hidden":"true"}),n.jsxs("div",{className:"rb-body",children:[n.jsx("div",{className:"rb-line",children:jx(v)}),n.jsxs("div",{className:"rb-meta",children:[n.jsx("span",{className:`rb-chip ${x.sev==="act"?"act":x.sev==="warn"?"warn":""}`,children:x.chip}),n.jsx("span",{className:"rb-via",children:Nc(v.integrationId)})]}),x.fixTo&&n.jsx(mt,{className:"rb-fix",to:x.fixTo,children:"Set a read window →"})]}),n.jsx("div",{className:"rb-when",children:sm(v.ts,Date.now())})]},`${v.ts}-${y}`)};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"}),u.length>0&&n.jsx("span",{className:"rb-count",children:u.length})]}),g.length===0?n.jsxs("div",{className:"rb-empty",children:[n.jsx("span",{className:"rb-mark","aria-hidden":"true",children:n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M20 6 9 17l-5-5"})})}),n.jsxs("h3",{children:["Nothing blocked in the last ",Yl," days"]}),n.jsx("p",{children:"Your agent has stayed within every limit you set."}),f.length>0&&n.jsxs(mt,{className:"col-btn",to:"/blocked",children:["View all ",f.length," blocks from the last 30 days ›"]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"rb-sub",children:[`Last ${Yl} days. `,"Limits you set that stopped your agent. Seeing them here means the gateway is doing its job."]}),n.jsx("div",{className:"rb-rows",children:g.map(p)}),n.jsxs(mt,{className:"col-btn",to:"/blocked",children:["View all ",f.length," blocks from the last 30 days ›"]})]})]})}function Hi(t){return t.kind??"read"}function Cx(t,s){var u,f,g,p;if(!s)return"";if(!t)return s;const a=(f=(u=t.scopeSchema)==null?void 0:u.fields)==null?void 0:f[s];if(a!=null&&a.displayName)return a.displayName;const o=((g=t.boundsSchema)==null?void 0:g.fields)??{};if((p=o[s])!=null&&p.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 Ex={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"},Tx={bound:"Nothing ran. To allow this, raise the limit on the mandate (needs your signature) — or ask the AI to stay within it.",scope:"Nothing ran. To allow this, widen the mandate's scope (needs your signature) — or ask the AI to stay within it.",cumulative:"Nothing ran. Possible again once the window resets — or raise the limit in the mandate.",simulation:"Nothing ran. Turn off simulation mode in Settings to use real systems.",not_authorized:"Nothing ran. Grant a mandate for this, or ask the decision owner.",read:"Nothing was read."};function Ff(t){return t===void 0?"":typeof t=="number"?t.toLocaleString():t}function Ix(t,s){const a=Hi(t),o=Ff(t.value),l=Ff(t.limit);switch(a){case"bound":return o&&l?`${s||"Value"} ${o} is above the limit ${l}.`:t.detail;case"scope":return o?`${s||"Value"} "${o}" is not within your mandate's allowed ${s||"scope"}.`:t.detail;case"cumulative":return o&&l?`${o} of ${l} used — the limit is reached.`:t.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 t.detail}}function Ax(t,s){if(t.mandateId){const a=s==null?void 0:s[t.mandateId];if(a)return a}return t.mandateTitle}function Rx(t,s){const a=Ax(t,s);if(a){const o=[{text:` · mandate "${a}"`}];return t.mandateId&&o.push({text:` (${t.mandateId.slice(0,14)}…)`,dim:!0}),o}return t.mandateId?[{text:` · mandate ${t.mandateId.slice(0,14)}…`}]:[]}function Px(t,s){const a=Hi(t),o=Nc(t.integrationId),l=t.who==="authority-server"?"refused by the Authority Server":a==="read"?"refused by this gateway":"refused by this gateway, before anything ran",u=t.code?` (${t.code})`:"";return[{text:`${o} · ${t.tool}`},...Rx(t,s),{text:` · ${l}${u}`}]}function $x(t,s,a){const o=Hi(t),l=Cx(s,t.field);return{title:Ex[o],sentence:Ix(t,l),sourceLine:Px(t,a),whatYouCanDo:Tx[o]}}function _x(t,s){const a=new Date(s);return a.setHours(0,0,0,0),t.filter(o=>o.ts>=a.getTime()).length}function Lx(t,s){return t.filter(a=>a.ts>s).length}const zx=1440*60*1e3;function Fx(t,s){const a=new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),o=new Date(s);o.setHours(0,0,0,0);const l=o.getTime();return t>=l?`Today · ${a}`:t>=l-zx?`Yesterday · ${a}`:`${new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})} · ${a}`}const Mx=[{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"},{to:"/tickets",icon:"▣",iconClass:"nav-ic-ticket",label:"Tickets",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:"/reports",icon:"▥",label:"Reports",group:"setup"},{to:"/settings",icon:"⚙",label:"Settings",statusKey:"assistant",group:"setup"}];function Ox(){const{activeDomain:t}=vt(),[s,a]=h.useState({}),o=h.useCallback(async()=>{try{const[l,u,f,g,p,v,y,x]=await Promise.all([F.getCredential("ai-config").catch(()=>null),F.getMyAttestations().catch(()=>null),F.getMyProposals(t).catch(()=>null),F.getProposalsForApprover().catch(()=>null),F.getAgentContext().catch(()=>""),F.getArchivedMandates().catch(()=>[]),F.getDenials({limit:200}).catch(()=>null),F.getLastSeenBlockedAt().catch(()=>0)]),j={};if(l&&!l.configured&&(j.assistant=1),u){const k=nm(u,{archivedSet:new Set(v)}).expired.length;k>0&&(j.authorizations=k)}const N=(f==null?void 0:f.length)??0,b=(g==null?void 0:g.length)??0,S=N+b;if(S>0&&(j.proposals=S),(!p||!p.trim())&&(j.brief=1),y){const k=Lx(y.records,x);k>0&&(j.blocked=k)}a(j)}catch{}},[t]);return Be("attestation-changed",o),Be("proposal-added",o),Be("proposal-resolved",o),Be("proposal-approved",o),Be("proposal-rejected",o),Be("team-membership-changed",o),Be("denial-recorded",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.removeEventListener("suveren:blocked-seen-changed",o)),[o]),Lt(o,3e5,t),s}const Bx={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},Dx={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 Ux(){const{mode:t,group:s,domain:a,activeTeam:o}=vt(),l=Ox(),{attentionCount:u}=kc(),f={...l};u>0&&(f.integrations=u);const g=Mx.filter(j=>!j.teamOnly||t==="team"),p=h.useRef(null),[v,y]=h.useState(null),x=Vt();return h.useEffect(()=>{if(p.current===null){p.current=t;return}p.current!==t&&(t==="team"&&o?y(`You are now acting in team context — ${o.name}`):t==="personal"&&y("You have left the team — back to personal context"),p.current=t)},[t,o]),h.useEffect(()=>{y(null)},[x.pathname]),n.jsxs("div",{className:"sidebar",children:[["top","core","setup"].map(j=>{const N=g.filter(b=>(b.group??"setup")===j);return N.length===0?null:n.jsxs("div",{className:`sidebar-${j}`,children:[j==="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:N.map(b=>{const S=b.statusKey?f[b.statusKey]:0;return n.jsx("li",{children:n.jsxs(xc,{to:b.to,end:b.to==="/",className:({isActive:k})=>`sidebar-item${k?" active":""}`,children:[n.jsx("span",{className:"icon",children:b.iconClass?n.jsx("span",{className:`nav-ic ${b.iconClass}`,"aria-hidden":"true"}):b.icon}),b.label,S?n.jsx("span",{style:Bx,children:S}):null]})},b.to)})})]},j)}),n.jsxs("div",{className:"sidebar-context",children:[n.jsx("div",{className:"ctx-label",children:"Active context"}),n.jsx("div",{className:"ctx-value",children:t==="personal"?"personal":s?`${s.name} / ${a}`:a})]}),v&&n.jsx("div",{style:Dx,role:"status","aria-live":"polite",children:v})]})}const Ml="suveren:updatedTo";function Wx(t){return t==="managed"||t==="msi"?null:t==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":t==="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 Hx="Updates for this gateway come from your company's IT — no action needed here.";function Vx(t){return t==="managed"?"update-banner is-managed":"update-banner"}const Gx="Download the new installer and run it. Your settings and mandates stay.";function Kx(t){const s="https://github.com/suverenai/suveren-gateway/releases";return t?`${s}/tag/v${t}`:`${s}/latest`}function qx(){const t=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const a of t)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 am(){const{updateAvailable:t,installMethod:s,version:a,latestVersion:o,serverRestarted:l,startFastPolling:u,dismiss:f}=wc(),[g,p]=h.useState(!1),[v,y]=h.useState(!1),[x,j]=h.useState(()=>{try{const P=sessionStorage.getItem(Ml);if(P)return sessionStorage.removeItem(Ml),P}catch{}return null}),N=Wx(s),b=h.useRef(null),S=P=>{try{sessionStorage.setItem(Ml,P||o||"✓")}catch{}window.location.reload()};h.useEffect(()=>{if(!x)return;const P=setTimeout(()=>j(null),6e3);return()=>clearTimeout(P)},[x]),h.useEffect(()=>{if(!g||!l)return;const P=()=>qx()?!1:(S(a),!0);if(P())return;const I=setInterval(P,1500);return()=>clearInterval(I)},[g,l,a]),h.useEffect(()=>(document.body.classList.toggle("is-updating",g),()=>document.body.classList.remove("is-updating")),[g]);const k=t&&!g&&!x||!!x&&!g;h.useEffect(()=>{if(!k){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 V;const U=((V=b.current)==null?void 0:V.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${U}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")}},[k]);const E=()=>{p(!0),u()},T=async()=>{if(N)try{await navigator.clipboard.writeText(N),y(!0),setTimeout(()=>y(!1),1800)}catch{}};return n.jsxs(n.Fragment,{children:[x&&!g&&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:"×"})]})}),t&&!g&&!x&&n.jsxs("div",{ref:b,className:Vx(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:Kx(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:Hx}),s==="msi"&&n.jsx("p",{className:"update-banner-hint",children:Gx})]}),g&&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:N}),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:()=>p(!1),children:"Cancel"})]})]})})]})}function im(){const t=bc(),s=h.useRef(null);return h.useEffect(()=>{if(!t){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")}},[t]),t?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 Yx={system:"◑",light:"☀",dark:"☾"},Jx=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Approvals"},{to:"/mandates",icon:"☰",label:"Mandates"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/blocked",icon:"⊘",label:"Blocked"},{to:"/team",icon:"◉",label:"Team"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/settings",icon:"⚙",label:"Settings"}];function Qx({open:t,onClose:s}){const{user:a,activeGroup:o,activeDomain:l,logout:u}=vt(),{theme:f,toggle:g}=Zh(),p=Vt();return h.useEffect(()=>{s()},[p.pathname]),t?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:Jx.map(v=>n.jsxs(xc,{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:()=>{g()},children:[n.jsx("span",{className:"icon",children:Yx[f]}),"Theme: ",f]}),n.jsx("button",{className:"mobile-menu-action",onClick:()=>{u(),s()},children:"Logout"})]})]})]}):null}function om(t){return t.status==="pending"}function Xx(t,s){return t.filter(om).length+s.length}const xr=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],Zx=500;function lm(){const{user:t,domain:s}=vt(),[a,o]=h.useState(0),l=h.useRef(null),u=h.useCallback(async()=>{if(!t){o(0);return}try{const[g,p]=await Promise.all([F.getMyProposals(s).catch(()=>[]),F.getProposalsForApprover().catch(()=>[])]);o(Xx(g,p))}catch{o(0)}},[t,s]),f=h.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{u()},Zx)},[u]);return h.useEffect(()=>(u(),()=>{l.current&&clearTimeout(l.current)}),[u]),Be(xr[0],f),Be(xr[1],f),Be(xr[2],f),Be(xr[3],f),Be(xr[4],f),Be(xr[5],f),Be(xr[6],f),a}const Mf="Suveren",e0="/favicon.svg",t0="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",vi={x1:74.54,y1:22.74,x2:94.46,y2:34.24},n0=14,r0="#f59e0b";function s0(t){const s=Cc(t);return s>0?`(${s}) ${Mf}`:Mf}function Cc(t){return Number.isFinite(t)&&t>0?Math.floor(t):0}function a0(){const t=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
52
- <path class="m" d="${t0}"/>
53
- <line class="m" x1="${vi.x1}" y1="${vi.y1}" x2="${vi.x2}" y2="${vi.y2}"/>
54
- <circle cx="103" cy="103" r="25" fill="${r0}"/>
55
- <style>.m{stroke:#111111;stroke-width:${n0};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(t)}`}function i0(){return document.querySelector('link[rel="icon"]')}function cm(t){const s=Cc(t);document.title=s0(s),um(s);const a=i0();if(!a)return;const o=s>0?a0():e0;a.getAttribute("href")!==o&&a.setAttribute("href",o)}function o0(){cm(0)}function um(t,s=globalThis.navigator){var l;if(!s||typeof s.setAppBadge!="function")return;const a=Cc(t),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 l0(){const t=lm();return h.useEffect(()=>{cm(t)},[t]),h.useEffect(()=>o0,[]),null}const dm="suveren:dockBadgePrompt";function c0(){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(dm))return!1}catch{}return!0}function u0(){const[t,s]=h.useState(!1),a=lm();if(h.useEffect(()=>{s(c0())},[]),!t)return null;const o=()=>{try{localStorage.setItem(dm,"1")}catch{}s(!1)},l=async()=>{try{await Notification.requestPermission()==="granted"&&um(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 d0(){const[t,s]=h.useState(!1);return n.jsxs(yx,{children:[n.jsx(l0,{}),n.jsx(jc,{onMenuToggle:()=>s(!t)}),n.jsx(am,{}),n.jsx(im,{}),n.jsx(Ux,{}),n.jsx(Qx,{open:t,onClose:()=>s(!1)}),n.jsx("div",{className:"main-content",children:n.jsxs("div",{className:"page-inner",children:[n.jsx(u0,{}),n.jsx(fv,{})]})})]})}function fm({what:t}){return n.jsxs("div",{className:"human-only-note",role:"note",children:[n.jsx("strong",{children:"Only you."})," ",t==="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 Ec(){return typeof navigator<"u"&&navigator.webdriver===!0}const Tc="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function f0(){const[t,s]=h.useState(""),{login:a,isLoading:o,error:l,clearError:u}=vt(),[f,g]=h.useState(null),p=Ec(),v=async()=>{if(!(!t.trim()||p)){u();try{await a(t)}catch(j){if(j instanceof Yh){g(j.summary);return}}}},y=async()=>{g(null),u();try{await a(t,{confirmWipe:!0})}catch{}},x=()=>{g(null)};return n.jsxs(n.Fragment,{children:[n.jsx(jc,{}),n.jsx(am,{}),n.jsx(im,{}),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(fm,{what:"sign-in"}),p&&n.jsx("div",{className:"error-message",children:Tc}),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:t,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||p,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,N)=>n.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:N<2?"0.5rem":0},children:[n.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[N+1,"."]}),j]},N))})]})]})})]}),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 h0(t,s){return!s&&t!=null}function m0(t,s){return t==="join-waiting"&&s==="team"}function p0(t,s,a,o){return a!=null||t!=="join-waiting"||s==="team"?null:o}function g0(t){return`${t} personal mandate${t===1?"":"s"}`}function y0({mandates:t,pendingProposals:s}){return t.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:t.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 v0(){const{mode:t,pendingRequest:s,refreshGroups:a}=vt(),o=gn(),[l,u]=h.useState("choose"),[f,g]=h.useState(""),[p,v]=h.useState(""),[y,x]=h.useState(null),[j,N]=h.useState(null),[b,S]=h.useState(""),[k,E]=h.useState(""),[T,P]=h.useState(!1),I=h.useRef(!1);h.useEffect(()=>{h0(s,I.current)&&(I.current=!0,u("join-waiting"))},[s]),h.useEffect(()=>{m0(l,t)&&o("/")},[l,t,o]);const U=h.useRef(null);h.useEffect(()=>{if(s){U.current=s.groupName;return}const L=p0(l,t,s,U.current);L&&(S(L),u("join-declined"),U.current=null)},[s,l,t]),h.useEffect(()=>{if(l!=="join-waiting")return;const L=setInterval(()=>{a()},5e3);return()=>clearInterval(L)},[l,a]);const V=h.useCallback(()=>{u("choose"),E(""),x(null),N(null),g(""),v("")},[]),z=async()=>{if(f.trim()){P(!0),E("");try{const L=await F.getJoinPreview(f.trim());x(L),u("join-preview")}catch(L){E(L instanceof Error?L.message:"Invalid or expired invite code")}finally{P(!1)}}},J=async()=>{P(!0),E("");try{await F.requestToJoinGroup(f.trim()),await a(),u("join-waiting")}catch(L){E(L instanceof Error?L.message:"Failed to join group")}finally{P(!1)}},Q=async()=>{P(!0),E("");try{await F.withdrawJoinRequest(),await a(),V()}catch(L){E(L instanceof Error?L.message:"Failed to withdraw request")}finally{P(!1)}},ne=async()=>{u("create"),E(""),P(!0);try{const L=await F.getCreatePreview();N(L)}catch(L){E(L instanceof Error?L.message:"Failed to load preview")}finally{P(!1)}},ee=async()=>{if(p.trim()){P(!0),E("");try{await F.createGroup(p.trim()),await a(),o("/")}catch(L){E(L instanceof Error?L.message:"Failed to create group")}finally{P(!1)}}};return n.jsxs(n.Fragment,{children:[n.jsx(jc,{}),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:[k&&n.jsx("div",{className:"error-message",children:k}),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:L=>g(L.target.value),onKeyDown:L=>L.key==="Enter"&&z(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:T}),n.jsx("button",{className:"btn btn-primary",onClick:z,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:ne,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(y0,{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:J,disabled:T,children:T?"Asking…":"Ask to join"}),n.jsx("button",{className:"btn btn-ghost",onClick:V,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:Q,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:V,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:p,onChange:L=>v(L.target.value),onKeyDown:L=>L.key==="Enter"&&ee(),disabled:T,autoFocus:!0})]}),j&&n.jsxs("div",{className:"alert alert-info",style:{color:"white"},children:["Your account moves to the new team. Your ",g0(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:ee,disabled:T||!p.trim(),children:T?"Creating…":"Create team and move my account"}),n.jsx("button",{className:"btn btn-ghost",onClick:V,disabled:T,children:"Cancel"})]})]})]})})]})}const Of={"claude-code":{label:"Claude Code",snippet:t=>`claude mcp add --transport http suveren ${t}/mcp`},"claude-desktop":{label:"Claude Desktop",snippet:t=>`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",`${t}/mcp`,"--allow-http"]}}},null,2)}`},"chatgpt-codex":{label:"ChatGPT / Codex",snippet:t=>`Add to ~/.codex/config.toml:
59
-
60
- [mcp_servers.suveren]
61
- url = "${t}/mcp"
62
-
63
- Or: codex mcp add suveren --url ${t}/mcp`},other:{label:"Other",snippet:t=>`Streamable HTTP: POST ${t}/mcp
64
- SSE transport: GET ${t}/sse
65
- Health check: GET ${t}/health`}},Bf=["claude-code","claude-desktop","chatgpt-codex","other"];function Jl({mcpEndpoint:t}){const[s,a]=h.useState(Bf[0]),[o,l]=h.useState(!1),u=h.useCallback(async g=>{try{await navigator.clipboard.writeText(g),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},[]),f=Of[s].snippet(t);return n.jsxs("div",{children:[n.jsx("div",{className:"gate-content-label",children:"MCP Endpoint"}),n.jsx("div",{className:"mcp-endpoint",children:t}),n.jsx("div",{className:"mcp-tabs",children:Bf.map(g=>n.jsx("button",{className:`mcp-tab${s===g?" active":""}`,onClick:()=>a(g),children:Of[g].label},g))}),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 Ql="suveren-setup-ai-skipped",Xl="suveren-setup-agent-done",Zl="suveren-setup-dismissed",x0={"hap-setup-ai-skipped":Ql,"hap-setup-agent-done":Xl,"hap-setup-dismissed":Zl};function w0(){for(const[t,s]of Object.entries(x0)){const a=localStorage.getItem(t);a!==null&&localStorage.getItem(s)===null&&localStorage.setItem(s,a),a!==null&&localStorage.removeItem(t)}}w0();function j0({aiConfigured:t,hasRunningIntegration:s,hasActiveAuth:a,hasAgentConnected:o,mcpEndpoint:l}){const[u,f]=h.useState(()=>localStorage.getItem(Ql)==="true"),[g,p]=h.useState(()=>localStorage.getItem(Xl)==="true"),[v,y]=h.useState(()=>localStorage.getItem(Zl)==="true"),[x,j]=h.useState(null),N=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status:t?"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||g?"done":"pending"}],b=N.filter(I=>I.status==="done"||I.status==="skipped").length,S=b===N.length,k=h.useCallback(()=>{localStorage.setItem(Ql,"true"),f(!0)},[]),E=h.useCallback(()=>{localStorage.setItem(Xl,"true"),p(!0),j(null)},[]),T=h.useCallback(()=>{localStorage.setItem(Zl,"true"),y(!0)},[]);if(v||S)return null;const P=N.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:N.map((I,U)=>{const V=U===P,z=I.status==="done"||I.status==="skipped"?"●":"○",J=I.status==="done"?"var(--text-primary)":I.status==="skipped"?"var(--text-tertiary)":V?"var(--accent)":"var(--text-tertiary)";return n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:V?"0.75rem":"0.25rem 0",borderRadius:V?"0.5rem":void 0,background:V?"var(--accent-subtle)":void 0},children:[n.jsx("span",{style:{color:J,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:z}),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:V?600:500,color:V?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:I.label}):I.status==="pending"&&U===3?n.jsx("button",{onClick:()=>j(x===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:V?600:500,color:V?"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"&&V&&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:k,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:"›"})]}),U===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(Jl,{mcpEndpoint:l}),n.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:E,children:"Done"})]})]},U)})}),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/N.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 ",N.length," complete"]})]})]})}function hm(t,s=null){const a=[t.hasContact,t.hasDelegationMandate,t.delegationProposalCount>0],o=a.every(Boolean),l=t.otherMandateCount===0&&!o,u=a.findIndex(v=>!v),f=s!==null&&a[s]===!1?s:u,g=t.managed?"managed":"self",p=v=>a[v]?{status:"done"}:v!==f?{status:"todo"}:v===1?{status:"open",variant:g,simulationOn:t.simulationOn}:v===0?{status:"open",variant:g}:{status:"open"};return{visible:l,step1:p(0),step2:p(1),step3:p(2)}}const S0="/mandates?new=1&profile=delegation";function Df({text:t}){const[s,a]=h.useState(!1),o=h.useCallback(async()=>{try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[t]);return n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:o,children:s?"Copied":"Copy"})}function Ol({todo:t,onOpen:s,children:a}){return t?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 b0({contact:t,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:l,simulationOn:u,mcpEndpoint:f}){const g={hasContact:t!==null,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:l,simulationOn:u},[p,v]=h.useState(null),y=hm(g,p);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"&&t?n.jsxs("span",{className:"flow-step-title flow-done-title",children:[t.clientName," connected · last contact ",sm(Date.parse(t.lastSeenAt),Date.now()).toLowerCase()]}):n.jsx(Ol,{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(Jl,{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(Df,{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(Jl,{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(Ol,{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:S0,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(Ol,{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(Df,{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 k0(){const[t,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}},[]),t}function N0(t){if(!t||typeof t!="object")return{simulation:null,locked:!1};const s=Array.isArray(t.policyLocked)&&t.policyLocked.includes("simulation");return{simulation:typeof t.simulation=="boolean"?t.simulation:null,locked:s}}function mm(){const[t,s]=h.useState({simulation:null,locked:!1});return h.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(N0(o))}).catch(()=>{}),()=>{a=!0}},[]),t}function C0(t){return!t||typeof t!="object"?!1:Array.isArray(t.policyLocked)&&t.policyLocked.length>0}function E0(){const[t,s]=h.useState(!1);return h.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(f=>f.json()).then(f=>{a||s(C0(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)}},[]),t}function Zr({variant:t="base",style:s,className:a,...o}){const l=t==="title"?"skeleton skeleton-title":t==="line"?"skeleton skeleton-line":t==="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"})}function Bl(){return n.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[n.jsx(Zr,{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",flexShrink:0}}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.35rem"},children:[n.jsx(Zr,{variant:"line",style:{width:"35%"}}),n.jsx(Zr,{variant:"line-sm",style:{width:"65%"}})]})]})}const Uf=new Map;function pm(t){let s=Uf.get(t);return s||(s=(async()=>{try{let a=t;if(!t.includes("@")){const o=await F.listProfiles(),l=f=>f.replace(/@.*$/,"").split("/").pop(),u=o.filter(f=>l(f.id)===t).sort((f,g)=>(g.id.split("@")[1]??"").localeCompare(f.id.split("@")[1]??"",void 0,{numeric:!0}));if(!u[0])return null;a=u[0].id}return await F.getProfile(a)}catch{return null}})(),Uf.set(t,s)),s}function as(t){const[s,a]=h.useState(null);return h.useEffect(()=>{let o=!0;return t&&pm(t).then(l=>{o&&a(l)}),()=>{o=!1}},[t]),s}const Wf=40,T0={delegation:"Delegation"};function lt(t,s){const a=t.lastIndexOf("/"),o=a>=0?t.slice(a+1):t,l=o.indexOf("@"),u=l>=0?o.slice(0,l):o,f=T0[u.toLowerCase()];return f||(s?s.slice(0,Wf):(u.charAt(0).toUpperCase()+u.slice(1)).slice(0,Wf))}function Vi(t){return!t||t==="count"?"":t==="minutes"?"min":t==="hours"?"hr":t==="days"?"days":t==="percent"?"%":t.startsWith("currency:")?t.slice(9):t}const gm=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview","_source"]);function Ht(t){const s=t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)}function Cr(t){const s=t.indexOf("__");return s<0?{integrationId:"",toolName:t}:{integrationId:t.slice(0,s),toolName:t.slice(s+2)}}function I0(t){const{integrationId:s,toolName:a}=Cr(t);return s?`${s} · ${a}`:a}function aa(t,s){const a=s==null?void 0:s.find(o=>o.id===t);return a!=null&&a.name?a.name:t?t.toUpperCase():"the system"}function A0(t){return Array.isArray(t)?"list":t&&typeof t=="object"?"object":typeof t=="string"&&(t.includes(`
66
- `)||t.length>120)?"markdown":"text"}function R0(t,s){var f,g;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(t)])],u=[];for(const p of l){if(!(p in t)||gm.has(p))continue;const v=t[p],y=a[p]??{},x=y.kind??A0(v),j={key:p,label:y.label??Ht(p),kind:x,value:v,hint:(g=o[p])==null?void 0:g.description};x==="money"&&y.currencyArg&&typeof t[y.currencyArg]=="string"&&(j.currency=t[y.currencyArg]),x==="profile"&&typeof v=="string"&&(j.profileRef=v),(x==="profile-limits"||x==="profile-scope")&&y.profileArg&&typeof t[y.profileArg]=="string"&&(j.profileRef=t[y.profileArg]),u.push(j)}return u}function ym(t,s){var o,l;const a=(l=(o=s==null?void 0:s.scopeSchema)==null?void 0:o.fields)==null?void 0:l[t];return a?{label:a.displayName??t,hint:a.description}:{label:t}}function P0(t,s,a){if(!t||typeof t!="object"||Array.isArray(t))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(t)])],f=[];for(const g of u){if(g==="profile"||!(g in t))continue;const p=t[g],v=l[g],y=Vi(v==null?void 0:v.unit),x=Array.isArray(p)?p.join(", "):String(p);f.push({key:g,label:(v==null?void 0:v.displayName)??Ht(g),value:y?`${x} ${y}`:x,hint:v==null?void 0:v.description,unknown:s?!v:void 0})}return f}function vm(t){const s=t.indexOf("__");return s<0?{integrationId:"",toolName:t}:{integrationId:t.slice(0,s),toolName:t.slice(s+2)}}function Ic(t,s){var p,v,y;const{integrationId:a,toolName:o}=vm(t.action),l=s.find(x=>x.id===a),u=(v=(p=l==null?void 0:l.toolGating)==null?void 0:p.overrides)==null?void 0:v[o];if(u!=null&&u.actionLabel)return u.actionLabel;const f=lt(t.profileId),g=(y=t.executionContext)==null?void 0:y.action_type;return typeof g=="string"&&g?`${f} · ${g}`:`${f} · ${o}`}function $0(t,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(t.executionContext??{})){if(!(u in a))continue;const g=String(f??"").trim();g&&o.push(g.split(",").map(p=>p.trim()).filter(Boolean).join(", "))}return o.join(" · ")}function _0(t,s){var l,u;if(!t)return"";const a=((l=s==null?void 0:s.scopeSchema)==null?void 0:l.fields)??{},o=[];for(const[f,g]of Object.entries(t)){if(f==="action_type")continue;const p=String(g??"").trim();if(!p)continue;const v=((u=a[f])==null?void 0:u.displayName)??f;o.push(`${v} ${p.split(",").map(y=>y.trim()).filter(Boolean).join(", ")}`)}return o.join(" · ")}function Hf(t){return t.appliesTo}function L0(t,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=t.actionType??(typeof((y=t.executionContext)==null?void 0:y.action_type)=="string"?t.executionContext.action_type:void 0),f=Object.entries(l).filter(([j,N])=>{if(!(j in s))return!1;const b=N.boundType;if(!b||b.kind!=="cumulative_sum"&&b.kind!=="cumulative_count"||b.window!==o)return!1;const S=Hf(N);return!S||!u||S.includes(u)}),p=(u?f.find(([,j])=>{var N;return(N=Hf(j))==null?void 0:N.includes(u)}):void 0)??(f.length===1?f[0]:void 0);return p?{key:p[0],isAmount:((x=p[1].boundType)==null?void 0:x.kind)==="cumulative_sum"}:void 0}function xm(t,s,a,o){var g;const l=(g=t.cumulativeState)==null?void 0:g[o];if(!l)return null;const u=L0(t,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 z0(t,s,a){const o=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],l=[];for(const{window:u,label:f}of o){const g=xm(t,s,a,u);g&&l.push("limit"in g?`${g.used} of ${g.limit} ${f}`:`${g.count} ${g.count===1?"call":"calls"} ${f}`)}return l.join(" · ")}function F0(t,s,a){var u;const o=(u=a==null?void 0:a.boundsSchema)==null?void 0:u.fields;if(!t||!s||!o)return[];const l=[];for(const[f,g]of Object.entries(o)){const p=g.boundType;if(!p||p.kind!=="per_transaction")continue;const v=p.of;if(!(v in t)||!(f in s))continue;const y=Number(t[v]),x=Number(s[f]);if(!Number.isFinite(y)||!Number.isFinite(x))continue;const j=Vi(g.unit),N=g.displayName??Ht(v),b=S=>j?`${S.toLocaleString()} ${j}`:S.toLocaleString();l.push({key:f,label:N,ok:y<=x,valueText:b(y),limitText:b(x)})}return l}function Ti(t){return typeof t.proposalId=="string"&&t.proposalId.length>0}function M0(t){const s=lt(t),a=t.split("@")[1];return a?`${s}@${a}`:s}const O0=["automatic","approved","all"];function B0(t){return t==="automatic"||t==="approved"?t:"all"}function ec(t,s){return s==="all"?!0:s==="approved"?Ti(t):!Ti(t)}function ia(t,s,a){const o=t?a[t]:void 0;return o&&o.trim()?o:lt(s)}function oa(t,s){return aa(vm(t).integrationId,s)}function D0(t,s){const a=Math.max(0,Math.floor((s-t)/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 wm(t,s){const a=D0(t*1e3,s);return a==="just now"?"waiting just now":`waiting ${a}`}const U0=24*3600;function jm(t,s,a){const o=t-Math.floor(s/1e3);return o<=0||o>U0?null:`Decide by ${new Date(t*1e3).toLocaleString(a,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})} — otherwise it won't run`}function Sm(t){return t.replace(/-/g,"").slice(0,8)}function W0(t,s){const a=new Date(t),o=new Date(s);return a.getFullYear()===o.getFullYear()&&a.getMonth()===o.getMonth()&&a.getDate()===o.getDate()}function Ac(t,s){return W0(t*1e3,s)}function Ii(t,s){return t.timestamp*1e3>s}function H0(t,s){const a=new Map;for(const l of t){if(Ti(l))continue;const u=Ic(l,s.manifests),g=`${l.authorizationId??l.profileId}|${l.action}`;let p=a.get(g);p||(p={key:g,area:ia(l.authorizationId,l.profileId,s.titles),system:oa(l.action,s.manifests),profileId:l.profileId,label:u,count:0,newCount:0,latestSec:0,tickets:[]},a.set(g,p)),p.count+=1,Ii(l,s.lastSeenMs)&&(p.newCount+=1),p.latestSec=Math.max(p.latestSec,l.timestamp),p.tickets.push(l)}const o=[...a.values()];for(const l of o)l.tickets.sort((u,f)=>f.timestamp-u.timestamp);return o.sort((l,u)=>+(u.newCount>0)-+(l.newCount>0)||u.latestSec-l.latestSec)}function V0(t,s){var l,u,f,g;const a=new Map;for(const p of t){if(!p.authorizationId||!Ac(p.timestamp,s.nowMs))continue;const v=a.get(p.authorizationId);(!v||p.timestamp>v.timestamp||p.timestamp===v.timestamp&&(((u=(l=p.cumulativeState)==null?void 0:l.daily)==null?void 0:u.count)??0)>(((g=(f=v.cumulativeState)==null?void 0:f.daily)==null?void 0:g.count)??0))&&a.set(p.authorizationId,p)}const o=[];for(const[p,v]of a){const y=xm(v,s.boundsOf(p)??v.limits,s.profileOf(v.profileId),"daily"),x={authorizationId:p,area:ia(p,v.profileId,s.titles),system:oa(v.action,s.manifests),profileId:v.profileId};y&&"limit"in y?o.push({...x,used:y.used,limit:y.limit,ratio:y.limit>0?y.used/y.limit:0}):o.push({...x,used:y?y.count:1,ratio:0})}return o.sort((p,v)=>v.ratio-p.ratio||p.area.localeCompare(v.area))}function Vf(t){return t.ratio>=.8}function Ai(t,s,a){const o=new Date(t*1e3),l=o.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"});return Ac(t,s)?`today ${l}`:`${o.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`}const G0={mail:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),n.jsx("path",{d:"m3 7 9 6 9-6"})]}),users:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),n.jsx("path",{d:"M3.5 20c0-3.6 2.5-6.3 5.5-6.3s5.5 2.7 5.5 6.3"}),n.jsx("circle",{cx:"17.2",cy:"9.2",r:"2.3"}),n.jsx("path",{d:"M16.8 13.9c2.4.5 4.2 2.6 4.2 5.4"})]}),receipt:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h12v18l-2.2-1.4L14 21l-2-1.4L10 21l-2-1.4L6 21V3Z"}),n.jsx("line",{x1:"9",y1:"7.5",x2:"15",y2:"7.5"}),n.jsx("line",{x1:"9",y1:"11.5",x2:"15",y2:"11.5"}),n.jsx("line",{x1:"9",y1:"15.5",x2:"13",y2:"15.5"})]}),"credit-card":n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2.2"}),n.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"}),n.jsx("line",{x1:"5.5",y1:"15",x2:"9.5",y2:"15"})]}),calendar:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"4.5",width:"18",height:"16.5",rx:"2"}),n.jsx("line",{x1:"3",y1:"9.5",x2:"21",y2:"9.5"}),n.jsx("line",{x1:"8",y1:"2.5",x2:"8",y2:"6.5"}),n.jsx("line",{x1:"16",y1:"2.5",x2:"16",y2:"6.5"})]}),megaphone:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3 10.2v3.6c0 .7.6 1.2 1.2 1.2h2.6l6.4 4V5l-6.4 4H4.2C3.6 9 3 9.5 3 10.2Z"}),n.jsx("path",{d:"M14.5 8.3a4.3 4.3 0 0 1 0 7.4"}),n.jsx("path",{d:"M17.6 6a7.6 7.6 0 0 1 0 12"})]}),archive:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"3.5",width:"18",height:"5",rx:"1.2"}),n.jsx("path",{d:"M5 8.5V18a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8.5"}),n.jsx("line",{x1:"10",y1:"13",x2:"14",y2:"13"})]}),rocket:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12 2.2c2.4 2 3.8 5.3 3.8 8.6 0 1.9-.9 3.9-.9 3.9H9.1s-.9-2-.9-3.9c0-3.3 1.4-6.6 3.8-8.6Z"}),n.jsx("path",{d:"M9 14.7 6.3 19.4l3.8-1.7"}),n.jsx("path",{d:"M15 14.7l2.7 4.7-3.8-1.7"}),n.jsx("circle",{cx:"12",cy:"9.3",r:"1.3"})]}),flask:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M9 3h6"}),n.jsx("path",{d:"M10 3v6.3l-5 9.1A2 2 0 0 0 6.7 21.5h10.6a2 2 0 0 0 1.7-3.1l-5-9.1V3"}),n.jsx("line",{x1:"8.3",y1:"14.5",x2:"15.7",y2:"14.5"})]}),"shopping-cart":n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"20",r:"1.4"}),n.jsx("circle",{cx:"18",cy:"20",r:"1.4"}),n.jsx("path",{d:"M2.5 3h2.4l2.1 11.2a2 2 0 0 0 2 1.6h8.6a2 2 0 0 0 2-1.6l1.4-7.6H6"})]}),"bar-chart":n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"4",y1:"20.5",x2:"20",y2:"20.5"}),n.jsx("rect",{x:"6",y:"13",width:"3.2",height:"7.5"}),n.jsx("rect",{x:"11.4",y:"8.5",width:"3.2",height:"12"}),n.jsx("rect",{x:"16.8",y:"4",width:"3.2",height:"16.5"})]}),"help-circle":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 Rc({icon:t,className:s}){return n.jsx("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:G0[t]})}const K0=new Set(["mail","users","receipt","credit-card","calendar","megaphone","archive","rocket","flask","shopping-cart","bar-chart","help-circle"]),q0={email:"mail",customers:"users",sales:"receipt",charge:"credit-card",calendar:"calendar",publish:"megaphone",records:"archive",deploy:"rocket",delegation:"flask",purchase:"shopping-cart",reporting:"bar-chart"};function Y0(t){const s=t.lastIndexOf("/"),a=s>=0?t.slice(s+1):t,o=a.indexOf("@");return(o>=0?a.slice(0,o):a).toLowerCase()}function er(t,s){const a=Y0(t),o=s!=null&&s.icon&&K0.has(s.icon)?s.icon:q0[a]??"help-circle",l=lt(t,s==null?void 0:s.name);return{icon:o,name:l,testSetup:a==="delegation"}}function Gi(t){return t.startsWith("setup__")}function kr({profileId:t,area:s,system:a,time:o,trailing:l,leading:u}){const{icon:f}=er(t);return n.jsxs("div",{className:"obj-line",children:[u,n.jsx(Rc,{icon:f}),n.jsx("b",{children:s}),a&&n.jsxs("span",{children:["· ",a]}),o&&n.jsxs("span",{children:["· ",o]}),l&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"obj-line-sp"}),l]})]})}async function Gf(t){const s=new TextEncoder().encode(t),a=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}function J0(t){return t.normalize("NFC").replace(/\r\n?/g,`
67
- `).split(`
68
- `).map(l=>l.replace(/[ \t]+$/,"")).join(`
69
- `).replace(/\n+$/,"")}function tc(t){if(t===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof t=="number"&&!Number.isFinite(t))throw new Error(`canonicalize: ${t} is not a valid JSON number`);if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return"["+t.map(l=>l===void 0?"null":tc(l)).join(",")+"]";const s=t,a=[];for(const o of Object.keys(s).sort()){const l=s[o];l!==void 0&&a.push(JSON.stringify(o)+":"+tc(l))}return"{"+a.join(",")+"}"}async function bm(t,s){if(t==="jcs"){if(typeof s=="string")throw new Error('content_binding kind="jcs" expects a record payload (object), got a string');return`sha256:${await Gf(tc(s))}`}if(typeof s!="string")throw new Error('content_binding kind="text" expects a string, got an object');return`sha256:${await Gf(J0(s))}`}async function km(t){if(t.toolArgs)return t.toolArgs;if(!t.content)return null;try{const{plaintext:s}=await F.decryptProposalContent(t.content),a=JSON.parse(s);return typeof a!="object"||a===null||Array.isArray(a)?null:a}catch{return null}}function Q0(t){if(!t.content)return[];const s=new Set([...t.createdBy?[t.createdBy]:[],...t.pendingApprovers??[]]),a=new Set(Object.keys(t.content.keys));return Array.from(s).filter(o=>!a.has(o))}function Nm(t){return!t.loading&&t.readable}function Cm(t,s){const a=new Set;if(t.content)for(const o of Object.keys(t.content.keys))a.add(o);else{t.createdBy&&a.add(t.createdBy);for(const o of t.pendingApprovers??[])a.add(o)}return s&&a.add(s),Array.from(a)}async function Qs(t){const s=await km(t);if(s)return bm("jcs",s)}function X0(t){var o;const[s,a]=h.useState((t==null?void 0:t.note)??null);return h.useEffect(()=>{let l=!0;if(t!=null&&t.note){a(t.note);return}if(!(t!=null&&t.noteEncrypted)){a(null);return}return a(null),F.decryptProposalContent(t.noteEncrypted).then(({plaintext:u})=>{l&&a(u)}).catch(()=>{l&&a(null)}),()=>{l=!1}},[t==null?void 0:t.note,(o=t==null?void 0:t.noteEncrypted)==null?void 0:o.ciphertext]),s}const Z0={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function Pc(t){var o;const[s,a]=h.useState(Z0);return h.useEffect(()=>{let l=!0;if(t.toolArgs){a({toolArgs:t.toolArgs,loading:!1,sealed:!1,undecryptable:!1});return}if(!t.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 km(t);l&&a({toolArgs:u,loading:!1,sealed:!0,undecryptable:u===null})})(),()=>{l=!1}},[(o=t.content)==null?void 0:o.ciphertext,t.toolArgs]),s}const Kf=140,qf=60,ew=/\{([^{}]+)\}/g;function tw(t,s){var u,f;const{integrationId:a,toolName:o}=Cr(t),l=s==null?void 0:s.find(g=>g.id===a);return((f=(u=l==null?void 0:l.toolGating)==null?void 0:u.overrides)==null?void 0:f[o])??void 0}function Em(t,s){let a=t;for(const o of s.split(".")){if(a===null||typeof a!="object")return;a=a[o]}return a}function Yf(t){return t==null?!1:typeof t=="string"?t.trim().length>0:Array.isArray(t)?t.length>0:!0}function nw(t,s,a,o){if(s==="money"){const u=typeof t=="number"?t:Number(t);if(!Number.isFinite(u))return String(t);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`${t}%`;if(s==="date"){const u=new Date(String(t));return Number.isNaN(u.getTime())?String(t):u.toLocaleDateString(o,{day:"numeric",month:"short"})}if(Array.isArray(t)){const u=t.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 t=="object"?JSON.stringify(t):String(t);return s==="short"&&l.length>qf?`${l.slice(0,qf-1).trimEnd()}…`:l}function Jf(t,s,a,o){let l=!1;const u=t.replace(ew,(f,g)=>{const[p,v]=g.split("|").map(x=>x.trim()),y=p.split(",").map(x=>Em(s,x.trim())).find(Yf);return Yf(y)?nw(y,v,a,o):(l=!0,"")});return l?null:u}function rw(t,s,a={}){const o=Em(s,a.currencyField??"currency"),l=typeof o=="string"?o:void 0,u=t.replace(/\[([^[\]]*)\]/g,(p,v)=>Jf(v,s,l,a.locale)??""),f=Jf(u,s,l,a.locale);if(f===null)return null;const g=f.replace(/\s+/g," ").trim();return g.length>Kf?`${g.slice(0,Kf-1).trimEnd()}…`:g}function Tm(t,s,a,o){var f;const l=Ht(Cr(t).toolName),u=tw(t,a);return!(u!=null&&u.summary)||!s?l:rw(u.summary,s,{currencyField:(f=u.display)==null?void 0:f.currencyField,locale:o})??l}function Im({proposal:t,manifests:s}){const a=Pc(t);return n.jsx(n.Fragment,{children:Tm(t.tool,a.toolArgs,s)})}const Qr=5;function sw({auths:t,activeCount:s,waiting:a,waitingReady:o}){const[l,u]=h.useState(null),[f,g]=h.useState(null),[p,v]=h.useState([]),[y,x]=h.useState({}),[j,N]=h.useState({}),b=h.useCallback(()=>{F.getMyReceiptsPage({limit:200}).then(z=>u(z.receipts)).catch(()=>u(z=>z??[])),F.getLastSeenTicketsAt().then(g).catch(()=>g(Number.POSITIVE_INFINITY))},[]);Lt(b,3e5),Be("ticket-recorded",b),h.useEffect(()=>{F.getIntegrationManifests().then(({manifests:z})=>v(z)).catch(()=>{}),F.getLocalAuthorizations().then(({authorizations:z})=>x(z)).catch(()=>{})},[]);const S=h.useMemo(()=>{const z={};for(const J of t)J.authorization_id&&J.title&&(z[J.authorization_id]=J.title);return z},[t]),k=Date.now(),E=h.useMemo(()=>{const z=Date.now();return(l??[]).filter(J=>Ac(J.timestamp,z))},[l]);h.useEffect(()=>{const z=[...new Set(E.map(J=>J.profileId))].filter(J=>!(J in j));z.length!==0&&Promise.all(z.map(J=>pm(J).then(Q=>[J,Q]).catch(()=>[J,null]))).then(J=>N(Q=>({...Q,...Object.fromEntries(J)})))},[E,j]);const T=h.useMemo(()=>H0(E,{titles:S,manifests:p,lastSeenMs:f??Number.POSITIVE_INFINITY}),[E,S,p,f]),P=E.filter(z=>ec(z,"approved")).length,I=h.useMemo(()=>V0(E,{nowMs:Date.now(),titles:S,manifests:p,boundsOf:z=>{var J;return(J=y[z])==null?void 0:J.bounds},profileOf:z=>j[z]}),[E,S,p,y,j]),U=T.filter(z=>z.newCount>0).length,V=[...a].sort((z,J)=>z.createdAt-J.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?V.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing waits for your decision."}):V.slice(0,Qr).map(z=>{const J=jm(z.expiresAt,k);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(kr,{profileId:z.profileId,area:ia(z.authorizationId,z.profileId,S),system:oa(z.tool,p),time:wm(z.createdAt,k)}),n.jsx("div",{className:"appr-item-sum",children:n.jsx(Im,{proposal:z,manifests:p})}),J&&n.jsx("div",{className:"obj-due",children:J})]}),n.jsx("span",{className:"appr-item-chev","aria-hidden":"true",children:"›"})]},z.id)}):n.jsx(Zr,{variant:"line"}),V.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"}),U>0&&n.jsxs("span",{className:"meta",children:[T.reduce((z,J)=>z+J.newCount,0)," new"]})]}),l===null?n.jsx(Zr,{variant:"line"}):T.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing was done automatically today."}):T.slice(0,Qr).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(kr,{profileId:z.profileId,area:z.area,system:z.system}),n.jsxs("b",{children:[z.count," × ",z.label]}),n.jsxs("span",{className:"meta",children:[z.newCount>0?`${z.newCount} new`:"seen"," · latest ",Ai(z.latestSec,k)]})]})]}),n.jsxs("div",{className:"auto-grp-list",children:[z.tickets.slice(0,Qr).map(J=>n.jsxs("div",{className:"auto-grp-row",children:[n.jsx("span",{className:`seen-dot${Ii(J,f??Number.POSITIVE_INFINITY)?" is-new":""}`}),Ic(J,p),n.jsxs("span",{className:"t",children:[Ai(J.timestamp,k)," · ",Sm(J.id)]})]},J.id)),z.tickets.length>Qr&&n.jsxs("div",{className:"auto-grp-row meta",children:["+ ",z.tickets.length-Qr," more in Tickets"]})]})]},z.key)),T.length>0&&n.jsx(mt,{to:"/tickets?filter=automatic",className:"col-btn","data-testid":"btn-automatic-tickets",children:"Automatic tickets ›"}),P>0&&n.jsxs("div",{className:"core-quiet-line",children:[P," 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(Zr,{variant:"line"}):I.length===0?n.jsx("p",{className:"core-col-empty",children:"No mandate has acted today."}):I.slice(0,Qr).map(z=>n.jsxs("div",{className:"mandate-obj","data-testid":"mandate-at-work",children:[n.jsx(kr,{profileId:z.profileId,area:z.area,system:z.system}),n.jsx("div",{className:`usage${Vf(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:[Vf(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>I.length&&n.jsxs("div",{className:"meta",style:{marginTop:"var(--space-2)",fontSize:"var(--text-caption)"},children:[s-I.length," more mandate",s-I.length===1?"":"s"," in force — no actions today"]}),I.length>0&&n.jsx(mt,{to:"/mandates",className:"col-btn",children:"All mandates ›"})]})]})}function aw(){const[t,s]=h.useState([]);return Lt(async()=>{try{const{skipped:o}=await F.getSkippedCommitments();s(o)}catch{}},3e4),t.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 (",t.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:t.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 iw(t,s){return s&&!Zs(t.manifest)}function ow(t,s=!1){var o;const a=[];for(const l of t)iw(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"&&(Zs(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 lw(t){const s=t.filter(a=>a.state==="paused");return s.length===0?null:{count:s.length,namesText:s.map(a=>a.manifest.name).join(", ")}}const cw=1800;function Hs(t){return t.replace(/@.*$/,"").split("/").pop()??t}function uw(){const{domain:t}=vt(),[s,a]=h.useState([]),[o,l]=h.useState([]),[u,f]=h.useState([]),[g,p]=h.useState(!0),[v,y]=h.useState(!1),[x,j]=h.useState([]),[N,b]=h.useState(!1),[S,k]=h.useState(!1),[E,T]=h.useState(null),[P,I]=h.useState(!1),{entries:U,activeSessions:V,loading:z}=kc(),J=k0(),Q=!z,{simulation:ne}=mm(),ee=ne===!0,L=E0(),oe=h.useCallback(()=>{F.getMyAttestations().then(ie=>{a(ie),y(!0)}).catch(()=>y(!0)),F.getArchivedMandates().then(j).catch(()=>j([])),F.getMyProposals(t).then(ie=>{l(ie),b(!0)}).catch(()=>b(!0)),F.getProposalsForApprover().then(ie=>f(ie)).catch(()=>f([])),F.getCredential("ai-config").then(ie=>{p(ie.configured),k(!0)}).catch(()=>k(!0)),F.getAgentContact().then(ie=>{T(ie.contact),I(!0)}).catch(()=>I(!0))},[t]);Be("attestation-changed",oe),Be("proposal-added",oe),Be("proposal-resolved",oe),Be("proposal-approved",oe),Be("proposal-rejected",oe),Be("execution-failed",oe),Lt(oe,3e5,t);const de=v&&N&&S&&Q&&P&&ne!==null,Y=nm(s,{archivedSet:new Set(x)}),je=Y.active,xe=Y.expired,X=je.some(ie=>Hs(ie.profile_id)==="delegation"),q=je.filter(ie=>Hs(ie.profile_id)!=="delegation").length,G=o.filter(ie=>Hs(ie.profileId)==="delegation").length,A=hm({hasContact:E!==null,hasDelegationMandate:X,otherMandateCount:q,delegationProposalCount:G,managed:L,simulationOn:ee}),_=ee&&A.visible,se=je.filter(ie=>ie.remaining_seconds!==null&&ie.remaining_seconds<=cw),me=o.filter(om),O=U.filter(ie=>ie.state==="running"),te=U.filter(ie=>ie.state==="starting"),le=lw(U),pe=[...me,...u.filter(ie=>!me.some(be=>be.id===ie.id))],ge=[];for(const ie of se){const be=Math.ceil((ie.remaining_seconds??0)/60);ge.push({label:"Expiring soon",detail:`${ie.title??Hs(ie.profile_id)} — ${be} min remaining`,to:"/mandates",color:"var(--text-primary)"})}for(const ie of xe)ge.push({label:"Expired",detail:ie.title??Hs(ie.profile_id),to:"/mandates",color:"var(--text-primary)"});ge.push(...ow(U,ee));for(const ie of te)ge.push({label:"Integration starting",detail:`${ie.manifest.name} is coming up…`,to:"/integrations",color:"var(--text-primary)"});for(const ie of U)ie.authStatus==="failed"&&ie.state!=="not-running"&&ie.state!=="error"&&ie.state!=="paused"&&ge.push({label:"Reconnect needed",detail:`${ie.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--text-primary)"});return g||ge.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"})}),de&&J&&(_?n.jsx(b0,{contact:E,hasDelegationMandate:X,otherMandateCount:q,delegationProposalCount:G,managed:L,simulationOn:ee,mcpEndpoint:J}):!ee&&n.jsx(j0,{aiConfigured:g,hasRunningIntegration:O.length>0,hasActiveAuth:je.length>0,hasAgentConnected:V>0,mcpEndpoint:J})),!_&&n.jsxs(n.Fragment,{children:[n.jsx(sw,{auths:s,activeCount:je.length,waiting:pe,waitingReady:N}),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"}),ge.length>0&&n.jsx("span",{className:"rb-count",children:ge.length})]}),ge.length>0?n.jsx("div",{className:"attention-rows",children:ge.map((ie,be)=>n.jsxs(mt,{to:ie.to,className:"attention-row",children:[n.jsx("span",{className:"attention-dot",style:{background:ie.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:ie.label}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ie.detail})]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},be))}):de?n.jsxs("div",{className:"all-clear",children:[n.jsx("span",{className:"rb-mark","aria-hidden":"true",children:n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M20 6 9 17l-5-5"})})}),n.jsx("h3",{children:"All clear"}),n.jsx("p",{children:"Nothing needs your attention."})]}):n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[n.jsx(Bl,{}),n.jsx(Bl,{}),n.jsx(Bl,{})]})]})]}),le&&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:[le.count," real system",le.count===1?"":"s"," ",le.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",le.namesText,"."]})]}),n.jsx(aw,{}),n.jsx(Nx,{})]})}const dw=["Scope & Limits","Intent","Sign"];function Am({currentStep:t,onStepClick:s}){const a=gn();return n.jsxs("div",{className:"wizard-progress",children:[n.jsx("ol",{className:"wizard-steps",children:dw.map((o,l)=>{const u=l+2,f=u<t,g=u===t,p=u-1<t,v=f&&!!s;return n.jsxs("li",{className:`wizard-step${p?" reached":""}`,"aria-current":g?"step":void 0,children:[n.jsx("button",{type:"button",className:`step-circle${f?" completed":""}${g?" current":""}`,onClick:v?()=>s(u):void 0,disabled:!v,"aria-label":`${o}${f?" (done)":g?" (current)":""}`,children:f?"✓":l+1}),n.jsx("span",{className:`step-label-text${g?" 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 fw({profileId:t,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}`:""]})]}),t&&n.jsxs("span",{children:[n.jsx("strong",{children:"Profile:"})," ",lt(t)]}),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 hw({integrationId:t,field:s,value:a,onChange:o,disabled:l,onLabels:u}){const[f,g]=h.useState(null),[p,v]=h.useState(null),[y,x]=h.useState(!0);h.useEffect(()=>{let b=!1;return F.discoverScopeField(t,s).then(S=>{var k;b||(g(S.options),x(!1),(k=S.options)!=null&&k.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}},[t,s]);const j=new Set(a.split(",").map(b=>b.trim()).filter(Boolean)),N=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 ",t,"…"]}):p||!f?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"msg-attention",style:{fontSize:"0.8rem",marginBottom:"0.5rem"},children:["Couldn't fetch options (",p??"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 ",t," for this field."]}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:f.map(b=>{const S=b.extras??{},k=typeof S.access=="string"?S.access:void 0,E=k==="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:()=>N(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"}),k&&n.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",k]})]},b.value)})})}function $c(t){if(t.type!=="number")return 0;const s=t.boundType,a=t.unit;return(s==null?void 0:s.kind)==="per_transaction"&&a==="count"?1:0}function Qf(t,s){if(s!==void 0)return String(s);const a=t.default;return typeof a=="string"||typeof a=="number"&&Number.isFinite(a)?String(a):$c(t)===1?"1":""}function nc(t){const s=t.maximum;return typeof s=="number"&&Number.isFinite(s)?s:void 0}function Xf(t,s){const a=$c(t),o=nc(t),l=s===""?a:Math.max(a,Number(s));return o!==void 0?Math.min(o,l):l}function mw(t,s){var o;const a=(o=t.capKinds)==null?void 0:o[s];return a||(t.approvers.length>0?"approval":"hard")}function _c(t,s,a){var o;return t.approvers.length===0||(s==null?void 0:s.enforcedBy)==="gatekeeper"||((o=s==null?void 0:s.boundType)==null?void 0:o.kind)==="enum"?"hard":mw(t,a)}function Rm(t,s,a){const o=t.indexOf(s),l=t.indexOf(a);return o===-1||l===-1?!1:l<o}function Ri(t,s){var a;return((a=t.caps)==null?void 0:a[s])!==void 0}function pw(t,s,a){const o=Object.entries(s.caps??{}).filter(([u])=>_c(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 g=a[u],p=g==null?void 0:g.boundType,v=(p==null?void 0:p.kind)==="per_transaction"||(p==null?void 0:p.kind)==="cumulative_sum"?p.of:void 0,y=v?t[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 gw(t){return t.replace(/@.*$/,"").split("/").pop()??t}function Lc(t,s){return s.displayName?s.displayName:t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function yw(t){return t.type==="string"&&(t.format==="email"||t.format==="domain")}function vw(t){var a;const s=t;return!!(s.enum&&((a=s.constraint)!=null&&a.enforceable.includes("subset")))}function Zf(t,s){const a=t.trim();return a?s==="email"?a.includes("@")&&a.indexOf(".",a.indexOf("@"))>-1:s==="domain"?a.includes(".")&&!a.includes("@"):!0:!1}function xw(t){return t?t==="minutes"?15:t==="percent"?5:t.startsWith("currency:")?10:1:1}function ww(t){return t?t==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:t==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:t==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:t==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:t.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function jw(t,s){if(!t||!s)return"";const a=Number(t);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 Sw({id:t,value:s,onChange:a,disabled:o,placeholder:l,unit:u,min:f=0,max:g}){const p=xw(u),v=ww(u).filter(S=>g===void 0||S.value<=g),y=Vi(u),x=jw(s,u),j=s===""?null:Number(s),N=()=>{const S=s===""?0:Number(s),k=S%p,E=k===0?S+p:S+(p-k);a(String(g!==void 0?Math.min(g,E):E))},b=()=>{const S=s===""?0:Number(s);if(S<=f)return;const k=S%p,E=k===0?S-p:S-k;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:t,className:"stepper-input",type:"number",min:f,max:g,step:p,value:s,placeholder:l??String(f),onChange:S=>{const k=S.target.value;a(g!==void 0&&k!==""&&Number(k)>g?String(g):k)},onFocus:S=>S.target.select(),disabled:o}),n.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:N,disabled:o||g!==void 0&&s!==""&&Number(s)>=g,"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 eh({htmlFor:t,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:t,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 bw({id:t,value:s,onChange:a,disabled:o,format:l,placeholder:u}){const[f,g]=h.useState(""),[p,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(!Zf(T,l)){v(!0);return}v(!1);const P=x.includes(T)?x:[...x,T];a(P.join(",")),g("")},N=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&&N(x.length-1)},S=E=>{const T=E.clipboardData.getData("text");if(T.includes(",")){E.preventDefault();const I=T.split(",").map(V=>V.trim()).filter(Boolean).filter(V=>Zf(V,l)),U=[...new Set([...x,...I])];a(U.join(",")),g(""),v(!1)}},k=l==="email"?"Type email and press Enter...":"Type domain and press Enter...";return n.jsxs("div",{className:`tag-input${p?" 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(),N(T)},"aria-label":`Remove ${E}`,children:"×"})]},E)),!o&&n.jsx("input",{ref:y,id:t,className:"tag-input-field",type:"text",value:f,onChange:E=>{g(E.target.value),v(!1)},onKeyDown:b,onPaste:S,onBlur:()=>{f.trim()&&j(f)},placeholder:x.length===0?u??k:""})]})}function kw({id:t,options:s,value:a,onChange:o,disabled:l}){const u=a?a.split(",").map(g=>g.trim()).filter(Boolean):[],f=g=>{const p=u.includes(g)?u.filter(v=>v!==g):[...u,g];o(p.join(","))};return n.jsx("div",{className:"checkbox-group",id:t,children:s.map(g=>n.jsxs("label",{className:`checkbox-pill${u.includes(g)?" checkbox-pill-selected":""}`,children:[n.jsx("input",{type:"checkbox",checked:u.includes(g),onChange:()=>f(g),disabled:l}),n.jsx("span",{children:g})]},g))})}function th({fieldKey:t,fieldDef:s,value:a,onChange:o,prefix:l,readOnly:u,twoColumn:f,discoveryIntegrationId:g,onLabels:p,capMax:v,enumAllowedFrom:y}){const x=Lc(t,s),j=`${l}-field-${t}`,N=n.jsx(n.Fragment,{children:vw(s)?n.jsx(kw,{id:j,options:s.enum,value:a,onChange:b=>o(t,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(t,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(t,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(Sw,{id:j,value:a,onChange:b=>o(t,b),disabled:u,unit:s.unit,min:$c(s),max:v!==void 0?Math.min(v,nc(s)??v):nc(s)}):yw(s)?n.jsx(bw,{id:j,value:a,onChange:b=>o(t,b),disabled:u,format:s.format}):g?n.jsx(hw,{integrationId:g,field:t,value:a,onChange:b=>o(t,b),disabled:u,onLabels:b=>p==null?void 0:p(t,b)}):n.jsx("input",{id:j,className:"form-input",type:"text",value:a,onChange:b=>o(t,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(eh,{htmlFor:j,label:x,description:s.description})}),n.jsx("div",{className:"bounds-field-input",children:N})]},`${l}-${t}`):n.jsxs("div",{className:"form-group",children:[n.jsx(eh,{htmlFor:j,label:x,description:s.description}),N]},`${l}-${t}`)}function Nw(t,s,a,o){if(!o||!Ri(o,t))return null;const l=o.caps[t],u=_c(o,s,t);let f=!1;if(typeof l=="number"){const g=a===""?NaN:Number(a);f=!Number.isNaN(g)&&g>l}else if(typeof l=="string"&&a!==""){const g=s.boundType;f=(g==null?void 0:g.kind)==="enum"?Rm(g.values??[],l,a):!1}return{kind:u,cap:l,violating:f}}function nh(t,s,a,o){if(!o||!Ri(o,t))return a;const l=_c(o,s,t),u=o.caps[t];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,g=(f==null?void 0:f.kind)==="enum"?f.values??[]:[];return a!==""&&Rm(g,u,a)?u:a}return a}function Cw(t,s){if(typeof s!="string")return;const a=t.boundType;if((a==null?void 0:a.kind)!=="enum")return;const o=(a.values??[]).indexOf(s);return o===-1?void 0:o}function Ew(t,s){return Vi(s.unit)||Lc(t,s).toLowerCase()}function Pm(t,s){if(s&&s.length>0)return s.join(" or ");const a=(t==null?void 0:t.approvers)??[];return a.length>0?a.join(" or "):"your team's approvers"}function Tw(t,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-${t}`,children:["Disabled by your team's policy — ",Lc(t,s).toLowerCase()," is capped at"," ",String(a.cap)," for this profile."]}):n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${t}`,children:["Team limit ",String(a.cap),u?" — read limits are always hard, no approval path exists for this cap.":""]});const g=Ew(t,s),p=Pm(o,l);return n.jsxs("span",{className:"cap-note soft","data-testid":`cap-note-${t}`,children:["Every ",g," above ",String(a.cap)," goes to ",p," for approval."]})}function Iw({profile:t,onConfirm:s,onCancel:a,readOnly:o,initialBounds:l,initialContext:u,initialFrame:f,profileConfig:g,approverNames:p,adminName:v}){var me;const y=t.boundsSchema,x=t.scopeSchema,j=O=>!!g&&Ri(g,O),N=y?Object.entries(y.fields).filter(([O,te])=>!(O==="profile"||O==="path"||te.enforced===!1||te.enforcedBy==="gatekeeper"&&!j(O))):[],b=y?Object.entries(y.fields).filter(([O,te])=>te.enforcedBy==="gatekeeper"&&!j(O)).filter(([,O])=>O.enforced!==!1).map(([O,te])=>te.displayName??O):[],S=x&&x.keyOrder.length>0?Object.entries(x.fields):[],k=l??f??{},E=u??{},T={};for(const[O,te]of N)T[O]=nh(O,te,Qf(te,k[O]),g);const P={};for(const[O]of S)P[O]=E[O]!==void 0?String(E[O]):"";const[I,U]=h.useState(T),[V,z]=h.useState(P),[J,Q]=h.useState({}),ne=h.useRef(new Set);h.useEffect(()=>{U(O=>{let te=!1;const le={...O};for(const[pe,ge]of N){if(ne.current.has(pe))continue;const ie=O[pe]!==void 0?O[pe]:Qf(ge,k[pe]),be=nh(pe,ge,ie,g);le[pe]!==be&&(le[pe]=be,te=!0)}return te?le:O})},[g]);const[ee,L]=h.useState(null);h.useEffect(()=>{const O=gw(t.id);F.getIntegrationManifests().then(({manifests:te})=>{const le=te.find(pe=>pe.profile===O&&pe.contextDiscovery&&Object.keys(pe.contextDiscovery).length>0);L(le??null)}).catch(()=>L(null))},[t.id]);const oe={};for(const[O,te]of N)oe[O]=Nw(O,te,I[O]??"",g);const de=Object.entries(oe).filter(([,O])=>(O==null?void 0:O.kind)==="hard"&&O.violating).map(([O])=>O),Y=!!g&&(((me=g.approvers)==null?void 0:me.length)??0)>0&&N.every(([O])=>!Ri(g,O)),je=(O,te)=>{ne.current.add(O),U(le=>({...le,[O]:te}))},xe=(O,te)=>{z(le=>({...le,[O]:te}))},X=()=>{const O={profile:t.id};for(const[le,pe]of N)pe.type==="number"?O[le]=Xf(pe,I[le]):O[le]=I[le];const te={};for(const[le,pe]of S)pe.type==="number"?te[le]=V[le]===""?0:Number(V[le]):te[le]=V[le];return[O,te]},q=()=>{const[O,te]=X();s(O,te,J)},G=()=>{var pe;const O={...I};for(const ge of de){const ie=(pe=oe[ge])==null?void 0:pe.cap;ie!==void 0&&(O[ge]=String(ie))}U(O);const te={profile:t.id};for(const[ge,ie]of N)ie.type==="number"?te[ge]=Xf(ie,O[ge]??""):te[ge]=O[ge]??"";const le={};for(const[ge,ie]of S)ie.type==="number"?le[ge]=V[ge]===""?0:Number(V[ge]):le[ge]=V[ge];s(te,le,J)},A=()=>{if(!Y)return null;const O=Pm(g,p);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: ",O]}),n.jsxs("div",{children:["No caps are set on this profile, so ",O," 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(de.length===0)return null;const O=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 ",O," 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:G,children:"Save below cap"}),a&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:a,children:"Cancel"})]})]})},se=de.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(([O,te])=>{var pe;const le=!!((pe=ee==null?void 0:ee.contextDiscovery)!=null&&pe[O]);return n.jsx(th,{fieldKey:O,fieldDef:te,value:V[O],onChange:xe,prefix:"context",readOnly:o,discoveryIntegrationId:le?ee.id:void 0,onLabels:(ge,ie)=>Q(be=>({...be,[ge]:ie}))},`context-${O}`)})]}),N.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:N.map(([O,te])=>{const le=oe[O];return n.jsxs("div",{style:{display:"contents"},children:[n.jsx(th,{fieldKey:O,fieldDef:te,value:I[O],onChange:je,prefix:"bounds",readOnly:o,twoColumn:!0,capMax:(le==null?void 0:le.kind)==="hard"&&typeof le.cap=="number"?le.cap:void 0,enumAllowedFrom:(le==null?void 0:le.kind)==="hard"?Cw(te,le.cap):void 0}),le&&n.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:Tw(O,te,le,g,p)})]},`bounds-${O}`)})}),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:se,style:{marginTop:"0.5rem"},children:o?"Next: Gates":"Next: Problem Statement"})]})}function Aw(t){var a;const s=t.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((a=s==null?void 0:s[1])==null?void 0:a.trim())??null}function Rw(t){return t.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const Pw="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 Pi({target:t,currentText:s,onApply:a,greeting:o,placeholder:l,title:u}){const[f,g]=h.useState([{role:"assistant",content:o??Pw}]),[p,v]=h.useState(""),[y,x]=h.useState(!1),[j,N]=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 k=async()=>{const T=p.trim();if(!T||y)return;const P=[...f,{role:"user",content:T}];g(P),v(""),N(null),x(!0);try{const I=await F.aiChat({target:t,currentText:s,messages:P.filter((U,V)=>!(V===0&&U.role==="assistant"))});I.success&&I.reply?g(U=>[...U,{role:"assistant",content:I.reply}]):N(I.error??"AI returned no reply")}catch(I){N(I instanceof Error?I.message:"Chat failed")}finally{x(!1)}},E=T=>{T.key==="Enter"&&!T.shiftKey&&!T.nativeEvent.isComposing&&(T.preventDefault(),k())};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"?Aw(T.content):null,U=I?Rw(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:[U&&n.jsx("div",{className:"chat-msg-prose",children:U}),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:p,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:k,disabled:y||!p.trim(),"aria-label":"Send",children:"↑"})]}),n.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function $m({open:t,onClose:s,children:a,ariaLabel:o}){const l=h.useRef(null),u=h.useRef(null);return h.useEffect(()=>{var g;if(!t)return;u.current=document.activeElement,document.body.style.overflow="hidden";const f=p=>{p.key==="Escape"&&s()};return document.addEventListener("keydown",f),(g=l.current)==null||g.focus(),()=>{document.removeEventListener("keydown",f),document.body.style.overflow="",u.current instanceof HTMLElement&&u.current.focus()}},[t,s]),qv.createPortal(n.jsxs(n.Fragment,{children:[n.jsx("div",{className:`bottom-sheet-backdrop${t?" is-open":""}`,onClick:s,"aria-hidden":"true"}),n.jsxs("aside",{ref:l,className:`bottom-sheet${t?" 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 $w(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _w(t,s,a){if(s.length===0)return[{text:t,label:t,matched:null}];const o=[],l=new Set;for(const p of s)if(!(!p.scope||p.scope==="all (unscoped)"))for(const v of[p.scope,...p.scope.split(",").map(y=>y.trim())]){const y=v.toLowerCase();v&&!l.has(y)&&(l.add(y),o.push(v))}o.sort((p,v)=>v.length-p.length);const u=p=>{const v=p.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(N=>N.trim().toLowerCase()).includes(v))})},f=["\\[\\d+\\]",...o.map($w)],g=new RegExp(`(${f.join("|")})`,"gi");return t.split(g).filter(p=>p!=="").map(p=>{const v=/^\[(\d+)\]$/.exec(p);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:p,label:j,matched:[y]}}}else if(o.some(y=>y.toLowerCase()===p.toLowerCase())){const y=u(p);if(y.length>0)return{text:p,label:p,matched:y}}return{text:p,label:p,matched:null}})}const rh=`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 Lw(t,s,a,o){return _w(t,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 zw(){var _e;const t=gn(),[s]=sa(),a=Number(s.get("step"))||2,[o,l]=h.useState(null),[u,f]=h.useState(null),[g,p]=h.useState(a),[v,y]=h.useState(null),[x,j]=h.useState(null),[N,b]=h.useState({}),[S,k]=h.useState(rh),[E,T]=h.useState(!1),[P,I]=h.useState(null),[U,V]=h.useState(!0),[z,J]=h.useState(null),[Q,ne]=h.useState([]),[ee,L]=h.useState(void 0),[oe,de]=h.useState(!1),[Y,je]=h.useState(null),[xe,X]=h.useState(null),[q,G]=h.useState(null),[A,_]=h.useState([]),[se,me]=h.useState(null);h.useEffect(()=>{var De;const Z=sessionStorage.getItem("agentAuth");if(!Z){t("/mandates?new=1");return}const Ae=JSON.parse(Z);l(Ae),Ae.intentHint&&k(Ae.intentHint),F.getCredential("ai-config").then(Le=>I(Le.configured)).catch(()=>I(!1));const Ke=sessionStorage.getItem("agentGate");if(Ke){const Le=JSON.parse(Ke);Le.bounds&&y(Le.bounds),Le.context&&j(Le.context),(De=Le.gateContent)!=null&&De.intent&&k(Le.gateContent.intent)}F.getProfile(Ae.profileId).then(Le=>f(Le)).catch(()=>t("/mandates?new=1")).finally(()=>V(!1)),Ae.groupId&&Promise.all([F.getTeamProfileConfig(Ae.groupId,Ae.profileId).catch(()=>null),F.getGroupById(Ae.groupId).catch(()=>null),F.listUsers().catch(()=>[])]).then(([Le,ut,Xe])=>{if(J(Le),Le){const Qe=new Map;for(const Fe of Xe){const he=Fe.name&&Fe.email?`${Fe.name} (${Fe.email})`:Fe.name||Fe.email||Fe.id;Qe.set(Fe.id,he)}const Je=(ut==null?void 0:ut.members)??[];for(const Fe of Je){const he=Fe.userId??Fe.id;he&&(Fe.name&&Fe.email?Qe.set(he,`${Fe.name} (${Fe.email})`):Fe.name&&Qe.set(he,Fe.name))}const wt=(Le.approvers??[]).map(Fe=>Qe.get(Fe)??Fe);ne(wt);const pt=Je.find(Fe=>Fe.role==="admin");if(pt){const Fe=pt.userId??pt.id;Fe&&L(Qe.get(Fe)??pt.name)}}})},[t]);const O=v?Object.entries(v).filter(([Z])=>Z!=="profile"&&Z!=="path").map(([Z,Ae])=>`${Z} = ${Ae}`).join(", "):"",te=(Z,Ae,Ke)=>{y(Z),j(Ae),Ke&&b(Ke),p(3)},le=S.trim()!==rh.trim()&&S.trim()!=="",pe=Z=>{le&&!confirm("Replace your current intent with the AI draft?")||k(Z)},ge=()=>{const Z=u==null?void 0:u.ttl,Ae={intent:S},Ke=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...Ke,bounds:v,context:x,contextLabels:N,gateContent:Ae,ttlConfig:Z})),t("/mandates/new/sign")},ie=async()=>{if(o){de(!0),je(null),X(null),G(null),_([]),me(null);try{const Z=await F.aiIntentReview({profileId:o.profileId,newIntent:S,context:x??void 0});_(Z.grants??[]),Z.success?Z.review?je(Z.review):X(Z.note??"No other mandates on this profile to compare against."):G(Z.error??"Check failed.")}catch(Z){G(Z instanceof Error?Z.message:"Check failed.")}finally{de(!1)}}},be=Z=>{k(Z),(Y||xe||q)&&(je(null),X(null),G(null),_([]),me(null))};return U||!o||!u?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):n.jsxs(n.Fragment,{children:[n.jsx(Am,{currentStep:g,onStepClick:Z=>{Z>=2&&p(Z)}}),n.jsx(fw,{profileId:o.profileId,bounds:O||void 0,groupName:o.groupName,domain:o.domain}),g===2&&n.jsx("div",{className:"card",children:n.jsx(Iw,{profile:u,onConfirm:te,onCancel:()=>t("/mandates?new=1"),initialBounds:v||void 0,initialContext:x||void 0,profileConfig:z,approverNames:Q,adminName:ee})}),g===3&&n.jsxs("div",{className:`intent-layout${P?"":" no-chat"}`,children:[P&&n.jsx("div",{className:"card intent-pane chat tool",children:n.jsx(Pi,{target:{kind:"intent",profileId:o.profileId,bounds:O||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:Z=>be(Z.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:ie,disabled:oe||!le,children:oe?"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})]}),xe&&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:xe})]}),Y&&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:Lw(Y,A,me,lt(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:()=>p(2),children:"Back"}),n.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:ge,disabled:!le,children:"Continue to Review"})]}),(((_e=z==null?void 0:z.approvers)==null?void 0:_e.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 ",Q.length>0?Q.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",Q.length>0?Q.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($m,{open:E,onClose:()=>T(!1),ariaLabel:"Intent assistant",children:n.jsx(Pi,{target:{kind:"intent",profileId:o.profileId,bounds:O||void 0},currentText:S,onApply:Z=>{pe(Z),T(!1)}})})]}),se&&n.jsx("div",{className:"modal-backdrop",onClick:Z=>Z.target===Z.currentTarget&&me(null),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:se.length>1?`Existing mandates (${se.length})`:"Existing mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>me(null),children:"×"})]}),n.jsx("div",{className:"modal-body",children:se.map((Z,Ae)=>{var Ke;return n.jsxs("div",{style:{marginBottom:Ae<se.length-1?"1rem":0,paddingBottom:Ae<se.length-1?"1rem":0,borderBottom:Ae<se.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:Z.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:((Ke=Z.intent)==null?void 0:Ke.trim())||"(no intent recorded)"}),Object.entries(Z.bounds).filter(([De])=>De!=="profile"&&De!=="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(Z.bounds).filter(([De])=>De!=="profile"&&De!=="path").map(([De,Le])=>`${De}: ${Le}`).join(" · ")})]})]},Ae)})})]})})]})]})}function Fw(t){return t.normalize("NFC").replace(/\r\n?/g,`
74
- `).split(`
75
- `).map(l=>l.replace(/[ \t]+$/,"")).join(`
76
- `).replace(/\n+$/,"")}async function zc(t){const a=new TextEncoder().encode(t),o=await crypto.subtle.digest("SHA-256",a);return Array.from(new Uint8Array(o)).map(u=>u.toString(16).padStart(2,"0")).join("")}class Mw extends Error{constructor(a,o,l){super(l);Ds(this,"code");Ds(this,"field");this.name="CanonicalValueError",this.code=a,this.field=o}}function Ow(t){const s=new TextEncoder().encode(t);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 _m(t,s,a){const o=[];for(const l of s){const u=t[l];if(u==null)continue;const f=String(u);if(f.includes(`
77
- `)||f.includes("\r"))throw new Mw(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}=${Ow(f)}`)}return o.join(`
78
- `)}async function ki(t,s){const a=s.boundsSchema;if(!a)throw new Error("Profile has no boundsSchema");const o=_m(t,a.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await zc(o)}`}async function Lm(t,s){const a=s.scopeSchema?_m(t,s.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await zc(a)}`}function rc(t){if(t===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof t=="number"&&!Number.isFinite(t))throw new Error(`canonicalize: ${t} is not a valid JSON number`);if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return"["+t.map(l=>l===void 0?"null":rc(l)).join(",")+"]";const s=t,a=[];for(const o of Object.keys(s).sort()){const l=s[o];l!==void 0&&a.push(JSON.stringify(o)+":"+rc(l))}return"{"+a.join(",")+"}"}async function zm(t){return`sha256:${await zc(rc(t))}`}async function $i(t){const s=new TextEncoder().encode(Fw(t)),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 Fm(t,s){if(!t.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:t.authorization_id,boundsHash:t.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 Bw(t){const s=t.commitment_modes;return s===void 0?["review","automatic"]:Array.isArray(s)?["review","automatic"].filter(a=>s.includes(a)):[]}function Dw(t){return t==="per-action"?"review":"automatic"}function sh(t){return t?Bw(t).map(s=>s==="review"?"per-action":"immediate"):["per-action","immediate"]}function Uw(t,s){return s.includes(t)?t:s[0]??null}function ah(t){return t==null?new Set:new Set(String(t).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean))}function Ww(t,s){for(const a of t)if(s.has(a))return!0;return!1}function Hw(t,s,a){for(const o of t){const l=ah(s[o]),u=ah(a[o]);if(!(l.size===0||u.size===0)&&!Ww(l,u))return!1}return!0}function Vw(t){return t.length>24?`${t.slice(0,10)}…`:t}function Mm(t,s,a){const o=a==null?void 0:a[t];return String(s).split(",").map(u=>u.trim()).filter(Boolean).map(u=>{const f=o==null?void 0:o[u];return f?`${f} (${Vw(u)})`:u}).join(", ")}function Om(t){var l;if(t.isPersonal)return{can:!0};if(!t.configLoaded)return{can:!0};const s=t.teamName?`"${t.teamName}"`:"this team";return t.grantors!=="all"&&(((l=t.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 ${t.profileName} and name who may give its mandates.`}:t.grantors==="all"||!!t.userId&&t.grantors.includes(t.userId)?{can:!0}:{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${t.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 _i=500,Gw=["Lower the discount","Other recipient","Shorter","Different wording"];function Fc(t){const s=t.trim();return s.length===0?{valid:!1,error:"Describe what should change."}:s.length>_i?{valid:!1,error:`At most ${_i} characters (currently ${s.length}).`}:{valid:!0,trimmed:s}}function Kw(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Bm(t,s){return t.toLowerCase().includes(s.toLowerCase())}function qw(t,s){const a=t.trim();if(a.length===0)return s;if(!Bm(a,s))return`${a}. ${s}`;const o=new RegExp(`\\.?\\s*${Kw(s)}\\.?`,"i");return a.replace(o,"").replace(/\s{2,}/g," ").replace(/^\.\s*/,"").trim()}function Dm(){return{outcome:"rejected"}}function Yw(t){const s=Fc(t);if(!s.valid)throw new Error(s.error);return{outcome:"change_needed",note:s.trimmed}}function ih(){return{outcome:"replaced"}}function Jw(t,s){if((t.pendingApprovers??[]).includes(s))return{route:"approver"};const a=t.pendingDomains??[];return a.includes(s)?{route:"resolve",domain:s}:a.includes("owner")?{route:"resolve",domain:"owner"}:null}const Qw={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function Xw(t,s){const a=t.rejectedBy??t.approverRejectedBy;if(!a)return null;const o=a.outcome??"rejected",l=a.note??("reason"in a?a.reason:void 0);return{kind:Qw[o],who:a.userId===s?"You":a.userId,at:a.at,note:l}}function Zw(t){return t.refusal?{kind:"REFUSED",at:t.refusal.at,message:t.refusal.message}:null}function ej(){var Me,H;const t=gn(),{user:s,mode:a,domain:o}=vt(),[l,u]=h.useState(null),[f,g]=h.useState(null),[p,v]=h.useState(null),[y,x]=h.useState("per-action"),[j,N]=h.useState(1800),[b,S]=h.useState(86400),[k,E]=h.useState(""),[T,P]=h.useState("hours"),[I,U]=h.useState(""),[V,z]=h.useState(!0),[J,Q]=h.useState(!1);h.useEffect(()=>{F.getIdentityDisclosure().then(K=>Q(K.always)).catch(()=>{})},[]);const[ne,ee]=h.useState(!1),[L,oe]=h.useState(""),[de,Y]=h.useState(null),[je,xe]=h.useState([]),[X,q]=h.useState(!1),[G,A]=h.useState([]),[_,se]=h.useState(0);h.useEffect(()=>{var Ft;const K=sessionStorage.getItem("agentAuth"),ye=sessionStorage.getItem("agentGate");if(!K||!ye){t("/mandates?new=1");return}const Ve=JSON.parse(K),We=JSON.parse(ye),st={bounds:We.bounds??{},context:We.context??{},contextLabels:We.contextLabels??void 0,gateContent:We.gateContent};u(Ve),g(st),We.ttlConfig&&(N(We.ttlConfig.default??1800),S(We.ttlConfig.max??86400)),We.templateMode==="automatic"?x("immediate"):We.templateMode==="review"&&x("per-action");const zt=((Ft=We.ttlConfig)==null?void 0:Ft.max)??86400;if(typeof We.templateTtl=="number"&&We.templateTtl>0){const B=Math.min(We.templateTtl,zt);N(B),[3600,86400,604800,2592e3,31536e3].includes(B)||(B%86400===0?(E(String(B/86400)),P("days")):(E(String(Math.max(1,Math.round(B/3600)))),P("hours")))}F.getProfile(Ve.profileId).then(B=>{var ve;if(v(B),!I){const Ie=B.name??((ve=Ve.profileId.split("/").pop())==null?void 0:ve.replace(/@.*$/,""))??"",et=[];if(st.context&&B.scopeSchema)for(const Ne of B.scopeSchema.keyOrder){const we=st.context[Ne];if(we!==void 0&&we!==""){const Ue=String(we).split(",").map(Oe=>Oe.trim()).filter(Boolean);et.push(Ue.join(", "))}}const ce=et.length>0?`${Ie}: ${et.join(" · ")}`:Ie;U(ce)}}).catch(()=>{}),Ve.isPersonal?q(!0):Promise.all([F.getTeamProfileConfig(Ve.groupId,Ve.profileId).catch(()=>null),F.getGroupById(Ve.groupId).catch(()=>null),F.listUsers().catch(()=>[])]).then(([B,ve,Ie])=>{if(Y(B),B){const et=new Map;for(const we of Ie){const Ue=we.name&&we.email?`${we.name} (${we.email})`:we.name||we.email||we.id;et.set(we.id,Ue)}const ce=(ve==null?void 0:ve.members)??[];for(const we of ce){const Ue=we.userId??we.id;Ue&&(we.name&&we.email?et.set(Ue,`${we.name} (${we.email})`):we.name&&et.set(Ue,we.name))}const Ne=(B.approvers??[]).map(we=>et.get(we)??we);xe(Ne)}}).finally(()=>{q(!0)})},[t]),h.useEffect(()=>{if(!(l!=null&&l.profileId))return;const K=l.profileId,ye=sessionStorage.getItem("agentEditReplaces");F.getEnrichedAuthorizations().then(Ve=>{const We=Ve.filter(st=>st.profileId===K&&st.authorizationId!==ye).map(st=>({authorizationId:st.authorizationId,bounds:st.bounds,context:st.context??{},intent:st.intent}));A(We)}).catch(()=>A([]))},[l==null?void 0:l.profileId]),h.useEffect(()=>{if(!p)return;const K=Uw(y,sh(p));K&&K!==y&&x(K)},[p,y]),h.useEffect(()=>{if(!f||!p||G.length===0){se(0);return}let K=!1;return(async()=>{const ye=await ki(f.bounds,p),Ve=await Promise.all(G.map(We=>ki(We.bounds,p).catch(()=>null)));K||se(Ve.filter(We=>We===ye).length)})().catch(()=>{K||se(0)}),()=>{K=!0}},[f,p,G]);const me=async()=>{if(!(!l||!f||!p||!s)){if(!l.groupId){oe("No active group; cannot create mandate.");return}ee(!0),oe("");try{const K=o||l.domain||"owner",ye=await ki(f.bounds,p),Ve=await Lm(f.context,p),[We,st]=await Promise.all([$i(f.gateContent.intent),$i(JSON.stringify({profile:l.profileId,domain:K,group:l.groupId}))]);let zt,Ft,B,ve;if(l.isTeam){const Oe=await F.getApproversPubkeys(l.groupId,l.profileId);if(Oe.length>0){const tt=await F.encryptIntent(f.gateContent.intent,Oe);zt=tt.intentCiphertext,Ft=tt.encryptedKeys,B=tt.approversFrozen,ve=tt.intentDisclosureHash}}const Ie=`authz_${crypto.randomUUID()}`,et=sessionStorage.getItem("agentEditReplaces")||void 0,ce=sessionStorage.getItem("agentReplacesProposal")||void 0,Ne=await zm(p),we=await F.attest({authorization_id:Ie,replaces:et,profile_id:l.profileId,profile_hash:Ne,supported_versions:["0.7"],bounds:f.bounds,bounds_hash:ye,scope_hash:Ve,domain:K,did:s.did,mandate_owners:[{did:s.did}],gate_content_hashes:{intent:We},execution_context_hash:st,group_id:l.groupId,ttl:j,commitment_mode:Dw(y),title:I.trim(),intent_ciphertext:zt,encrypted_keys:Ft,approvers_frozen:B,intent_disclosure_hash:ve,disclose_identity:V});try{await F.pushGateContent(Fm(we,{boundsHash:ye,contextHash:Ve,context:f.context,contextLabels:f.contextLabels,gateContent:f.gateContent}))}catch(Oe){try{await F.revokeAttestation(Ie,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${Oe instanceof Error?Oe.message:"Unknown error"})`)}if(et)try{await F.revokeAttestation(et,`Replaced by ${Ie} (edit)`),F.resyncGates().catch(()=>{})}catch{}let Ue="";if(ce)try{const Oe=await F.getProposal(ce);if(Oe.status==="pending"){const tt=Jw(Oe,(s==null?void 0:s.id)??"");tt?tt.route==="approver"?await F.rejectProposal(ce,ih()):await F.resolveProposal(ce,"reject",tt.domain,ih()):Ue="you are not one of the people who may decide it"}}catch(Oe){Ue=Oe instanceof Error?Oe.message:"unknown error"}if(sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),sessionStorage.removeItem("agentReplacesProposal"),Ue){oe(`Your mandate is signed and active. The AI's proposal could not be withdrawn (${Ue}) — reject it under Approvals.`);return}t(`/mandates?highlight=${encodeURIComponent(Ie)}`)}catch(K){oe(K instanceof Error?K.message:"Signing the mandate failed")}finally{ee(!1)}}};if(!l||!f)return n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const O=Object.entries(f.bounds).filter(([K])=>K!=="profile"&&K!=="path"),te=Object.entries(f.context),pe=((de==null?void 0:de.caps)!=null?Object.keys(de.caps):[]).length!==0,ge=je.length>0?je.join(", "):((de==null?void 0:de.approvers)??[]).join(", "),ie=pe?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${ge}, 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.",be=pe?`Over-cap actions will be reviewed by you and ${ge}. Within-cap actions run per the mode you chose above.`:`Approvers ${ge} can read your intent but won't gate any action — no caps configured on this profile.`,_e=!!((Me=de==null?void 0:de.approvers)!=null&&Me.length),Z=Om({isPersonal:l.isPersonal,configLoaded:X,grantors:de?Jh(de):void 0,userId:s==null?void 0:s.id,profileName:lt(l.profileId),teamName:l.groupName}),Ae=!Z.can,Ke=sh(p),De=Ke.length===0,Le=j>b,ut={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"},Xe={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=((H=p==null?void 0:p.scopeSchema)==null?void 0:H.keyOrder)??[],Je=G.filter(K=>Hw(Qe,f.context,K.context)),wt=Je.length>0,pt=lt(l.profileId),Fe=K=>{const ye=Object.values(K).map(Ve=>String(Ve).trim()).filter(Boolean);return ye.length>0?ye.join(", "):"all (unscoped)"},he=Je.map(K=>Fe(K.context)).join("; "),$e=`This grant's scope overlaps an existing grant on ${pt} (scoped to: ${he}). 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(Am,{currentStep:4,onStepClick:K=>{K<=3&&t(`/mandates/new/intent?step=${K}`)}}),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&&p&&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 ",lt(l.profileId)," ",p.version," — the current version of this profile."]})]}),L&&n.jsx("div",{className:"error-message",children:L}),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. ${lt(l.profileId)}: daily operations`,value:I,onChange:K=>U(K.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:[Ke.includes("per-action")&&n.jsxs("button",{onClick:()=>x("per-action"),style:Xe,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."})]}),Ke.includes("immediate")&&n.jsxs("button",{onClick:()=>x("immediate"),style:ut,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."})]})]}),Ke.length===1&&n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:Ke[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),De&&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(K=>K.seconds<=b).map(K=>n.jsx("button",{onClick:()=>{N(K.seconds),E("")},style:{padding:"0.5rem 0.85rem",border:j===K.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:j===K.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:K.label},K.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:k,onChange:K=>{E(K.target.value);const ye=parseInt(K.target.value,10);if(ye>0){const Ve=T==="days"?ye*86400:ye*3600;N(Math.min(Ve,b))}}}),n.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:T,onChange:K=>{P(K.target.value);const ye=parseInt(k,10);if(ye>0){const Ve=K.target.value==="days"?ye*86400:ye*3600;N(Math.min(Ve,b))}},children:[n.jsx("option",{value:"hours",children:"hours"}),n.jsx("option",{value:"days",children:"days"})]})]}),Le&&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:J||V,disabled:J,onChange:K=>z(K.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.',J&&" 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:()=>t("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:f.gateContent.intent})]}),(!!O.length||!!te.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:()=>t("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),n.jsxs("dl",{className:"info-kv",children:[te.map(([K,ye])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:K}),n.jsx("dd",{children:Mm(K,ye,f.contextLabels)})]},K)),O.map(([K,ye])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:K}),n.jsx("dd",{children:String(ye)})]},K))]})]}),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:[lt(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:X?Z.can?n.jsxs(n.Fragment,{children:[ge,n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:ie})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"msg-error",children:Z.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${l.groupName??"this team"}`:"You cannot give this mandate"}),Z.code==="OWNER_NOT_APPROVER"&&n.jsx("div",{children:ge}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[Z.reason," ",Z.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,wt?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:$e})]})]}):null,n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:()=>t("/mandates/new/intent"),children:"Back"}),n.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:me,disabled:ne||!I.trim()||Ae||De,children:ne?"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:_e?"block":"none"},children:be})]})]})}const tj={card:"💳",mail:"✉️"};function Um(t){return tj[t]??"🔧"}function nj(t){const s=t==null?void 0:t.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 rj=[0,7,30,90,365,3650];function xi(t){return t===null?"From your mandate":t===0?"Read nothing":t===1?"1 day back":t===365?"1 year back":t%365===0?`${t/365} years back`:`${t} days back`}function sj(t){return(t==null?void 0:t.paused)==="simulation"?{chip:{c:"int-chip-paused",t:"Paused"},showStart:!1}:t&&!t.running&&t.error?{chip:{c:"int-chip-bad",t:"Crashed"},showStart:!0}:{chip:{c:"int-chip-idle",t:"Stopped"},showStart:!0}}function Dl({manifest:t,integration:s,state:a,onStatusChange:o,onSuccess:l}){var Fe;const[u,f]=h.useState({}),[g,p]=h.useState(!1),[v,y]=h.useState(!1),[x,j]=h.useState({}),[N,b]=h.useState({}),[S,k]=h.useState(void 0),[E,T]=h.useState(!1),[P,I]=h.useState(null),[U,V]=h.useState(!1),[z,J]=h.useState(!1),[Q,ne]=h.useState(!1),[ee,L]=h.useState(!1),[oe,de]=h.useState({}),[Y,je]=h.useState(null),[xe,X]=h.useState(!1),[q,G]=h.useState(null),[A,_]=h.useState(!1);h.useEffect(()=>{let he=!1;return F.getCredential(t.id).then($e=>{var Me;if(!(he||!$e.configured)){if(p(!0),y(!0),$e.fields){const H={};for(const K of t.credentials.fields)$e.fields[K.key]!=null&&(H[K.key]=$e.fields[K.key]);j(H)}if(b($e.secrets??{}),k($e.updatedAt),t.oauth){const H=((Me=$e.fieldNames)==null?void 0:Me.includes(t.oauth.tokenStorage))??!1;T(H),H&&F.getOAuthHealth(t.id).then(K=>{he||I(K)})}}}).catch(()=>{}),()=>{he=!0}},[t.id,t.oauth]);const se=nj(t.toolGating),me=s?s.readAgeDays??null:void 0,O=xe&&Y?Y.value:me,te=async he=>{je({value:he}),X(!0),G(null);try{await F.setReadPolicy(t.id,he),l(he===null?`${t.name} read window now follows your mandate`:`${t.name} read window set to ${xi(he).toLowerCase()}`),o()}catch($e){G($e instanceof Error?$e.message:"Could not save")}finally{X(!1),je(null)}},le=!!t.oauth||t.credentials.fields.some(he=>!he.optional),pe=t.oauth?E:g,ge=!le||pe,ie=a==="starting"?"starting":ge?s!=null&&s.running?"running":!g&&t.credentials.fields.length>0?"unconfigured":"ready":t.oauth&&g&&!E?"needs-oauth":"unconfigured",be=async()=>{if(t.credentials.fields.some($e=>{var Me;return(Me=u[$e.key])==null?void 0:Me.trim()})){V(!0);try{await F.setCredential(t.id,u),p(!0),f({}),t.oauth?l(`${t.name} credentials saved!`):(l(`${t.name} credentials saved — starting integration...`),await De())}catch{l(`Failed to save ${t.name} credentials`)}finally{V(!1)}}},_e=()=>{const he={};for(const $e of t.credentials.fields){const Me=u[$e.key];$e.type==="password"?Me!=null&&Me.trim()&&(he[$e.key]=Me):Me!=null&&Me!==(x[$e.key]??"")&&(he[$e.key]=Me)}return he},Z=Object.keys(_e()).length>0,Ae=async()=>{const he=_e();if(Object.keys(he).length!==0){V(!0);try{await F.setCredential(t.id,he),f({}),p(!0),t.oauth?l(`${t.name} credentials saved — now click Connect.`):(L(!1),l(`${t.name} credentials updated — restarting...`),await De())}catch{l(`Failed to update ${t.name} credentials`)}finally{V(!1)}}},Ke=()=>{window.open(`/auth/oauth/${t.id}/start`,"_blank","width=600,height=700");const he=setInterval(async()=>{var $e;try{const Me=await F.getCredential(t.id);Me.configured&&t.oauth&&(($e=Me.fieldNames)!=null&&$e.includes(t.oauth.tokenStorage))&&(T(!0),L(!1),I(null),clearInterval(he),l(`${t.name} connected — starting integration...`),F.getOAuthHealth(t.id).then(I).catch(()=>{}),await De())}catch{}},2e3);setTimeout(()=>clearInterval(he),12e4)},De=async()=>{ne(!0);try{const he=await F.activateIntegration(t.id);he.warning?l(he.warning):l(`${t.name} integration started with ${he.tools.length} tools`),o()}catch(he){l(`Failed to start ${t.name}: ${he instanceof Error?he.message:"Unknown error"}`)}finally{ne(!1)}},Le=async()=>{try{await F.removeMcpIntegration(t.id),l(`${t.name} integration removed`),o()}catch{l(`Failed to remove ${t.name}`)}},ut=Um(t.icon),Xe=sj(s),Qe=ie==="running"?{c:"int-chip-ok",t:"Running"}:ie==="starting"?{c:"int-chip-idle",t:"Starting"}:Xe.chip,Je=t.oauth&&E&&(P==null?void 0:P.status)==="failed",wt=le?Je?{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=he=>he.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${t.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:ut}),n.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:t.name}),n.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[ie!=="unconfigured"&&ie!=="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 ${wt.c}`,children:[n.jsx("span",{className:"int-dot"}),wt.t]}),fx(t,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"]})]})]}),t.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"})}),Je&&!ee&&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:[t.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 ",t.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:Ke,children:["Reconnect ",t.name]}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{f({...x}),L(!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:t.description}),t.profile&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Profile"}),n.jsx("span",{children:t.profile})]}),t.oauth&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Scopes"}),n.jsx("span",{children:((Fe=t.oauth.scopes)==null?void 0:Fe.join(", "))||"—"})]}),s&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Tools"}),n.jsxs("span",{children:[s.toolCount," gated"]})]})]})]}),t.setupGuide&&t.setupGuide.length>0&&(ie!=="running"||Je)&&n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n.jsxs("button",{onClick:()=>J(!z),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:z?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",t.name]}),z&&n.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:t.setupGuide.map((he,$e)=>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:$e+1}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:he.title}),n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[pt(he.description),he.link&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("a",{href:he.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},$e))})]}),ie==="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…"]}),ee&&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.",t.oauth?" Save, then Connect to re-link the account.":""]}),t.credentials.fields.map(he=>{var $e;return n.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[n.jsx("label",{className:"form-label",children:he.label}),he.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:oe[he.key]?"text":"password",name:`${t.id}-${he.key}-credential`,autoComplete:"new-password",placeholder:($e=N[he.key])!=null&&$e.preview?`Unchanged — ends in ${N[he.key].preview}`:v?"Unchanged — paste a new value to replace":he.placeholder,value:u[he.key]||"",onChange:Me=>f(H=>({...H,[he.key]:Me.target.value}))}),n.jsx("button",{className:"cred-toggle",onClick:()=>de(Me=>({...Me,[he.key]:!Me[he.key]})),children:oe[he.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${t.id}-${he.key}-credential`,autoComplete:"off",placeholder:he.placeholder,value:u[he.key]||"",onChange:Me=>f(H=>({...H,[he.key]:Me.target.value}))})]},he.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:Ae,disabled:U||!Z,children:U?"Saving…":"Save"}),!Z&&!U&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),t.oauth&&n.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:Ke,children:["Connect ",t.name]}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{L(!1),f({})},children:"Cancel"})]})]}),!ee&&ie==="running"&&s&&n.jsxs(n.Fragment,{children:[(Object.keys(x).length>0||Object.keys(N).length>0)&&n.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:t.credentials.fields.map(he=>{const $e=he.type==="password",Me=N[he.key];return!$e&&x[he.key]==null||$e&&Me==null?null:n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[n.jsx("span",{style:{color:"var(--text-muted)"},children:he.label}),n.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[$e?Me.preview??"set":x[he.key],$e&&S&&n.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(S).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},he.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"}),(t.credentials.fields.length>0||t.oauth)&&n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{f({...x}),L(!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:Le,title:"Stops the subprocess and removes the integration from the registry. It will NOT auto-start on next gateway restart. Re-enable with Install.",children:"Disable"})]}),se&&O!==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:O===null?"window from your mandate":xi(O).toLowerCase()}),xe&&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"})]})}),se&&O!==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:[rj.map(he=>{const $e=O===he;return n.jsx("button",{className:`btn btn-sm ${$e?"btn-primary":"btn-secondary"}`,"aria-pressed":$e,disabled:xe,onClick:()=>te(he),children:xi(he)},he)}),n.jsx("button",{className:`btn btn-sm ${O===null?"btn-primary":"btn-ghost"}`,"aria-pressed":O===null,disabled:xe,onClick:()=>te(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:xi(null)})]}),n.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:q?n.jsx("span",{className:"msg-error",children:q}):xe?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):O===null?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):O===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 ",O," 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"})})]}),ie==="unconfigured"&&(()=>{const he=t.credentials.fields.every(H=>H.optional),$e=t.credentials.fields.some(H=>!H.optional),Me=t.credentials.fields.some(H=>{var K;return(K=u[H.key])==null?void 0:K.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:()=>{p(!0),t.oauth&&T(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),t.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."}),t.setupHint&&!v&&n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:t.setupHint}),t.credentials.fields.map(H=>n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{className:"form-label",children:H.label}),H.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:oe[H.key]?"text":"password",name:`${t.id}-${H.key}-credential`,autoComplete:"new-password",placeholder:H.placeholder,value:u[H.key]||"",onChange:K=>f(ye=>({...ye,[H.key]:K.target.value}))}),n.jsx("button",{className:"cred-toggle",onClick:()=>de(K=>({...K,[H.key]:!K[H.key]})),children:oe[H.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${t.id}-${H.key}-credential`,autoComplete:"off",placeholder:H.placeholder,value:u[H.key]||"",onChange:K=>f(ye=>({...ye,[H.key]:K.target.value}))})]},H.key)),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[Me&&n.jsx("button",{className:"btn btn-primary",onClick:be,disabled:U||$e&&!t.credentials.fields.filter(H=>!H.optional).every(H=>{var K;return(K=u[H.key])==null?void 0:K.trim()}),children:U?"Saving...":"Save & Encrypt"}),he&&!Me&&n.jsx("button",{className:"btn btn-primary",onClick:De,disabled:Q,children:Q?"Starting...":`Activate ${t.name}`})]})]})})(),ie==="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 ",t.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:Ke,children:["Connect ",t.name," Account"]}),n.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Change Credentials"})]})]}),ie==="ready"&&!s&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.75rem"},children:["✓"," ",t.oauth?`${t.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:De,disabled:Q,children:Q?"Starting...":`Start ${t.name} Integration`}),!t.oauth&&n.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Update Credentials"}),t.oauth&&n.jsx("button",{className:"btn btn-ghost",onClick:()=>{p(!1),T(!1)},children:"Change Credentials"})]})]}),ie==="ready"&&s&&!s.running&&(Xe.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:De,disabled:Q,children:Q?"Starting...":"Start"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:Le,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:Le,children:"Disable"})})]}))]})}function aj(t,s){if(!s)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:t};const a=t.filter(f=>Zs(f.manifest)),o=t.filter(f=>!Zs(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 ij({entry:t}){return n.jsxs("div",{className:"int-paused-row",children:[n.jsx("span",{"aria-hidden":"true",children:Um(t.manifest.icon)}),n.jsx("span",{className:"int-paused-name",children:t.manifest.name}),n.jsxs("span",{className:"int-chip int-chip-paused",children:[n.jsx("span",{className:"int-dot"}),"Paused"]})]})}function oj(){const{loading:t,mcpServerUp:s,manifestsError:a,entries:o,refresh:l}=kc(),u=bc(),[f,g]=h.useState(""),p=h.useCallback(y=>{g(y),setTimeout(()=>g(""),5e3)},[]),v=aj(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}),t?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."})]}):v.grouped?n.jsxs(n.Fragment,{children:[v.testSystems.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Test systems"}),v.testSystems.map(y=>n.jsx(Dl,{manifest:y.manifest,integration:y.integration,state:y.state,onStatusChange:l,onSuccess:p},y.id))]}),(v.realErrors.length>0||v.pausedReal.length>0)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Real systems"}),v.realErrors.map(y=>n.jsx(Dl,{manifest:y.manifest,integration:y.integration,state:y.state,onStatusChange:l,onSuccess:p},y.id)),v.pausedReal.length>0&&n.jsxs("details",{className:"int-paused-group",open:!0,children:[n.jsxs("summary",{children:["Paused while simulation mode is on (",v.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"}),")."]}),v.pausedReal.map(y=>n.jsx(ij,{entry:y},y.id))]})]}),o.length===0&&n.jsx(oh,{manifestsError:a})]}):n.jsxs(n.Fragment,{children:[o.map(y=>n.jsx(Dl,{manifest:y.manifest,integration:y.integration,state:y.state,onStatusChange:l,onSuccess:p},y.id)),o.length===0&&n.jsx(oh,{manifestsError:a})]})]})}function oh({manifestsError:t}){return t?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 lj(){var L,oe,de;const{activeTeam:t,activeMembership:s,refreshGroups:a,user:o}=vt(),l=gn(),[u,f]=h.useState(null),[g,p]=h.useState(!1),[v,y]=h.useState(""),[x,j]=h.useState(""),[N,b]=h.useState(!1),[S,k]=h.useState(""),[E,T]=h.useState("");h.useEffect(()=>{fetch("/health").then(Y=>Y.json()).then(Y=>{typeof Y.spUrl=="string"&&T(Y.spUrl)}).catch(()=>{})},[]),h.useEffect(()=>{if(!t){f(null);return}F.getGroupById(t.id).then(Y=>{const je=Y.group??Y,xe=Y.members??[],X=Y.isAdmin??!1,q=xe.map(G=>{const A=G.userId||G.id||"",_=G.role||(X&&A===je.createdBy?"admin":"member");return{id:A,name:G.name||A.slice(0,8)||"Member",email:G.email||"",domains:G.domains||[],role:_,isAdmin:_==="admin"||X&&A===je.createdBy}});f({id:je.id,name:je.name,members:q})}).catch(()=>f(null))},[t==null?void 0:t.id]);const P=(u==null?void 0:u.members.filter(Y=>Y.isAdmin))??[],I=(t==null?void 0:t.isAdmin)===!0&&P.length<=1&&P.some(Y=>Y.id===(o==null?void 0:o.id)),U=(t==null?void 0:t.name)??"",V=S.trim()===U&&!g,z=()=>{k(""),b(!0)},J=()=>{b(!1),k("")},Q=async()=>{if(!(!t||!V)){p(!0),y("");try{await F.leaveTeam(t.id),await a(),j("You have left the team."),f(null),J()}catch(Y){y(Y instanceof Error?Y.message:"Failed to leave team")}finally{p(!1)}}},ne=t&&E?`${E}/dashboard/groups/${t.id}`:void 0,ee=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}),t?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:t.name}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((L=u==null?void 0:u.members)==null?void 0:L.length)??0," ",(((oe=u==null?void 0:u.members)==null?void 0:oe.length)??0)===1?"member":"members",t.isAdmin&&" · You are admin"]})]}),n.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(de=u==null?void 0:u.members)==null?void 0:de.map(Y=>n.jsxs("div",{className:"member-row",children:[n.jsx("div",{className:"member-avatar",children:Y.name.split(" ").map(je=>je[0]).join("").slice(0,2).toUpperCase()}),n.jsxs("div",{className:"member-info",children:[n.jsx("div",{className:"member-name",children:Y.name}),n.jsx("div",{className:"member-email",children:Y.email})]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Y.role})]},Y.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:[ne&&n.jsx("a",{className:"btn btn-secondary btn-sm",href:ne,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:z,disabled:g||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"}),ee&&n.jsx("a",{className:"btn btn-ghost btn-sm",href:ee,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server →"})]})]}),N&&t&&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:J,children:n.jsxs("div",{className:"card",onClick:Y=>Y.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 ",U,"?"]}),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:U})," to confirm:"]}),n.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:S,onChange:Y=>k(Y.target.value),placeholder:U,disabled:g,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:J,disabled:g,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:Q,disabled:!V,children:g?"Leaving...":"Leave team"})]})]})})]})}const ea=t=>t.replace(/@.*$/,"").split("/").pop()??t,lh=t=>t.split("@")[1]??"";function cj(t,s){const a=new Map;for(const o of t){const l=ea(o.id);if(!s.has(l))continue;const u=a.get(l);(!u||lh(o.id).localeCompare(lh(u.id),void 0,{numeric:!0})>0)&&a.set(l,o)}return a}function uj(t,s,a,o){var g;const l=new Set([...s.filter(p=>p.profile).map(p=>p.profile),...o.map(p=>ea(p.profile))]),u=cj(t,l),f=[];for(const p of s){const v=p.profile?u.get(p.profile):void 0;v&&f.push({key:`connector:${p.id}`,name:p.name,description:p.description||v.description,profile:v,kind:"connector",ready:((g=a.find(y=>y.id===p.id))==null?void 0:g.running)===!0,setupId:p.id,...p.intentHint?{intentHint:p.intentHint}:{}})}for(const p of o){const v=u.get(ea(p.profile));v&&f.push({key:`builtin:${p.id}`,name:p.name,description:p.description||v.description,profile:v,kind:"builtin",ready:p.available,unavailableReason:p.available?void 0:"Available only while simulation mode is on.",...p.intentHint?{intentHint:p.intentHint}:{}})}return f}function dj(t,s,a){if(s)return t.find(o=>ea(o.profile.id)===ea(s)&&o.ready&&a(o))}function fj({onDismiss:t,preselectProfileId:s}){const a=gn(),{group:o,groupId:l,domain:u,user:f}=vt(),[g,p]=h.useState([]),[v,y]=h.useState([]),[x,j]=h.useState([]),[N,b]=h.useState([]),[S,k]=h.useState(!0),[E,T]=h.useState({});h.useEffect(()=>{Promise.all([F.listProfiles().catch(()=>[]),F.getIntegrationManifests().then(Q=>Q.manifests??[]).catch(()=>[]),F.getMcpHealth().catch(()=>null)]).then(async([Q,ne,ee])=>{if(p(Q),y(ne),j((ee==null?void 0:ee.integrations)??[]),b((ee==null?void 0:ee.builtins)??[]),l){const L=await Promise.all(Q.map(de=>F.getTeamProfileConfig(l,de.id).catch(()=>null))),oe={};Q.forEach((de,Y)=>{const je=L[Y];je&&(oe[de.id]=je)}),T(oe)}}).finally(()=>k(!1))},[l]);const P=uj(g,v,x,N),I=Q=>{const ne=E[Q.id];return Om({isPersonal:!!(o!=null&&o.isPersonal),configLoaded:!S,grantors:ne?Jh(ne):void 0,userId:f==null?void 0:f.id,profileName:lt(Q.id),teamName:o==null?void 0:o.name})},U=Q=>Q in E,V=(Q,ne)=>{if(!l){console.error("No active group when creating authorization");return}const ee=U(Q);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Q,groupId:l,groupName:(o==null?void 0:o.name)??null,domain:u,isTeam:ee,isPersonal:!!(o!=null&&o.isPersonal),...ne?{intentHint:ne}:{}})),sessionStorage.removeItem("agentGate"),t==null||t(),a("/mandates/new/intent")},z=(Q,ne)=>{l&&V(Q,ne)},J=h.useRef(!1);return h.useEffect(()=>{if(S||!s||J.current)return;const Q=dj(P,s,ne=>I(ne.profile).can);Q&&(J.current=!0,z(Q.profile.id,Q.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:()=>t==null?void 0:t(),children:"Go to Integrations"})]}):n.jsx("div",{className:"profile-grid",children:P.map(Q=>{const ne=Q.profile,ee=U(ne.id),L=I(ne),oe=!Q.ready||!L.can,{icon:de}=er(ne.id,{name:ne.name,icon:ne.icon});return n.jsxs("div",{className:"card",style:oe?{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(Rc,{icon:de,className:"profile-chip-icon"}),Q.name]}),ee?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:Q.description}),L.can?Q.ready?n.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>z(ne.id,Q.intentHint),children:"Give a mandate"}):Q.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:Q.unavailableReason})]}):n.jsxs(mt,{to:`/integrations?setup=${Q.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>t==null?void 0:t(),children:["Set up ",Q.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:[L.reason," ",n.jsx("span",{style:{color:"var(--text-tertiary)"},children:L.fix})]})]})]},Q.key)})})]})}const hj={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function mj({status:t,label:s}){return n.jsx("span",{className:`status-badge status-${t}`,children:s||hj[t]})}function pj({domain:t,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:t})}const wr=86400,Ys=3600,wi=60,gj=30*wr;function yj(t){if(t<=0)return"Expired";if(t>90*wr){const s=Math.floor(t/gj);return`${s} ${s===1?"month":"months"} remaining`}if(t>7*wr){const s=Math.floor(t/wr);return`${s} ${s===1?"day":"days"} remaining`}if(t>=2*wr){const s=Math.floor(t/wr),a=Math.floor(t%wr/Ys);return`${s} ${s===1?"day":"days"} ${a}h remaining`}if(t>=2*Ys){const s=Math.floor(t/Ys),a=Math.floor(t%Ys/wi);return`${s}h ${String(a).padStart(2,"0")}m remaining`}if(t>=wi){const s=Math.floor(t/wi),a=Math.floor(t%wi);return`${s}m ${String(a).padStart(2,"0")}s remaining`}return`${Math.floor(t)}s remaining`}function vj({expiresAt:t}){const[s,a]=h.useState(()=>t-Date.now()/1e3),o=s<2*Ys;h.useEffect(()=>{const u=setInterval(()=>a(t-Date.now()/1e3),o?1e3:6e4);return()=>clearInterval(u)},[t,o]);const l=s<300;return n.jsx("span",{className:`ttl-badge ${l?"ttl-warn":"ttl-ok"}`,children:yj(s)})}function ts({icon:t,title:s,text:a,children:o}){return n.jsxs("div",{className:"empty-state",children:[t&&n.jsx("div",{className:"empty-state-icon",children:t}),n.jsx("div",{className:"empty-state-title",children:s}),a&&n.jsx("div",{className:"empty-state-text",children:a}),o]})}function xj(t){const s=Math.floor(t/86400);if(s>=1)return`${s} day${s===1?"":"s"}`;const a=Math.floor(t/3600);if(a>=1)return`${a} hour${a===1?"":"s"}`;const o=Math.ceil(t/60);return`${o} minute${o===1?"":"s"}`}const wj=[{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 jj({item:t,onClose:s,onSuccess:a}){var P;const{user:o,activeDomain:l,groupId:u}=vt(),[f,g]=h.useState(null);h.useEffect(()=>{let I=!1;return F.getProfile(t.profile_id).then(U=>{var V;I||g(((V=U==null?void 0:U.ttl)==null?void 0:V.max)??null)}).catch(()=>{}),()=>{I=!0}},[t.profile_id]);const p=t.remaining_seconds??0,v=wj.filter(I=>I.seconds>p&&(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 U=(I=v[v.length-1])==null?void 0:I.seconds;U&&j(U)}},[f]);const[N,b]=h.useState(!1),[S,k]=h.useState(""),E=Object.entries(t.frame).filter(([I])=>I!=="profile"&&I!=="path"),T=async()=>{var I;if(o){b(!0),k("");try{const U=t.authorization_id,V=await F.getGateContent(U);if(!V)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const z=await F.getProfile(t.profile_id),J=t.frame,Q=V.context??{},ne=t.attested_domains[0]||l||"owner",ee=await ki(J,z),L=await Lm(Q,z),[oe,de]=await Promise.all([$i(V.gateContent.intent),$i(JSON.stringify({profile:t.profile_id,path:t.path,domain:ne}))]);if(!u)throw new Error("No active group; cannot extend mandate.");const Y=(((I=t.deferred_commitment_domains)==null?void 0:I.length)??0)>0?"review":"automatic",je=await zm(z),xe=await F.attest({authorization_id:t.authorization_id,renew:!0,profile_id:t.profile_id,profile_hash:je,supported_versions:["0.7"],bounds:J,bounds_hash:ee,scope_hash:L,domain:ne,did:o.did,mandate_owners:[{did:o.did}],gate_content_hashes:{intent:oe},execution_context_hash:de,group_id:u,commitment_mode:Y,ttl:x});await F.pushGateContent(Fm(xe,{boundsHash:ee,contextHash:L,context:Q,path:t.path,gateContent:V.gateContent})),a()}catch(U){k(U instanceof Error?U.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:[lt(t.profile_id)," / ",t.path]}),E.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:E.map(([I,U])=>`${I}=${U}`).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"}),p>0&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",xj(p),". 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:N,children:"Cancel"}),n.jsx("button",{className:"btn btn-primary",onClick:T,disabled:N,children:N?"Extending...":"Extend"})]})]})})}function ch(t){return t.replace(/@.*$/,"").split("/").pop()??t}function uh(t){return t.split("@")[1]??""}function Sj(t,s){return uh(t).localeCompare(uh(s),void 0,{numeric:!0})>0}function Wm(t,s){const a=ch(t);let o;for(const l of s)ch(l.id)===a&&(!o||Sj(l.id,o.id))&&(o=l);return o}function Hm(t,s){var o;if(!s)return{};const a={};for(const l of s.keyOrder){if(l==="profile"||l==="path")continue;if(t[l]!==void 0){a[l]=t[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 Vm(t,s){return Hm(t,s.boundsSchema)}function Gm(t,s){return Hm(t,s.scopeSchema)}function bj(t,s,a){return[...t].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=Ei(o,s),f=Ei(l,s),g={active:0,pending:1,expired:2,revoked:3,archived:4};return g[u]!==g[f]?g[u]-g[f]:new Date(l.created_at).getTime()-new Date(o.created_at).getTime()})}function kj({item:t,newerProfile:s,revokedSet:a,expandedHash:o,gateCache:l,gateLoading:u,copiedHash:f,revokingHash:g,copyingHash:p,profileConfigCache:v,mode:y,ownerLabel:x,isAdmin:j,onExpand:N,onCopyHash:b,onCopy:S,onRevoke:k,onExtend:E,archivedSet:T,archivingHash:P,onArchive:I,highlightHash:U,needsReapprovalSet:V}){var ie;const z=Sc(t,{revokedSet:a}),J=z==="active"&&((V==null?void 0:V.has(t.authorization_id))??!1),Q=tm(t,{revokedSet:a,archivedSet:T}),ne=!x&&!!I&&em(z),ee=o===t.authorization_id,L=l[t.authorization_id],oe=z==="active"||z==="pending"||z==="expired",de=Object.entries(t.frame).filter(([be])=>be!=="profile"&&be!=="path"),Y=v.get(t.profile_id)??null,je=(((ie=Y==null?void 0:Y.approvers)==null?void 0:ie.length)??0)>0,xe=new Map;if(Y!=null&&Y.caps&&y==="team")for(const[be,_e]of de){const Z=Y.caps[be];typeof Z=="number"&&Number(_e)>Z&&xe.set(be,{authorized:Number(_e),cap:Z})}const X=xe.size>0,q=t.approvers_frozen??[],G=(Y==null?void 0:Y.approvers)??[],A=y==="team"&&q.length>0&&G.length>0&&(q.length!==G.length||q.some(be=>!G.includes(be))||G.some(be=>!q.includes(be))),_=Array.from(xe.entries()).map(([be,_e])=>`${be}: ${_e.authorized} (cap ${_e.cap})`).join(", "),se=Array.from(xe.entries()).map(([be,_e])=>`${be}: ${_e.authorized} → ${_e.cap}`).join(", "),me=X?je?xe.size===1?`Above team cap: ${_} — actions require approval`:`Above team cap (${xe.size}): ${_} — actions require approval`:xe.size===1?`Reduced by hard cap: ${se}`:`Reduced by hard cap (${xe.size}): ${se}`:"",O=X?je?"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,te=er(t.profile_id),le=te.name,pe=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:[le,"@",s.version," available"]}),s.whatsNew?n.jsxs(n.Fragment,{children:[" — ",s.whatsNew]}):null,n.jsx("br",{}),n.jsxs("span",{children:["This mandate stays on ",t.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,ge=U!=null&&t.authorization_id===U;return n.jsx("div",{className:`card mandate-card${ge?" card-highlight":""}`,style:{marginBottom:0},children:n.jsxs("div",{className:"id-body",children:[n.jsx(kr,{profileId:t.profile_id,area:lt(t.profile_id),time:t.created_at?`since ${new Date(t.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})}`:void 0}),pe,x&&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:x})]}),n.jsxs("div",{className:"auth-card-header",children:[n.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:t.title||le}),n.jsx(mj,{status:z}),J&&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"}),te.testSetup&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),z==="active"&&t.earliest_expiry&&n.jsx(vj,{expiresAt:new Date(t.earliest_expiry).getTime()/1e3}),z==="expired"&&(()=>{const be=dx(t,z);return be?n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(be.iso).toLocaleString()}`,children:new Date(be.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:[(t.required_domains.length>1||t.missing_domains.length>0)&&t.required_domains.map(be=>n.jsx(pj,{domain:be,attested:t.attested_domains.includes(be)},be)),t.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"}),X&&n.jsx("span",{title:O,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"transparent",color:"var(--text-primary)",border:je?"1px dashed var(--text-primary)":"2px solid var(--text-primary)",fontWeight:600,cursor:"help"},children:me}),A&&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:()=>S(t),disabled:p===t.authorization_id,title:"The approver list for this profile has changed since this mandate was created. Copy to reissue with the current approvers.",children:p===t.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),de.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:de.map(([be,_e],Z)=>{const Ae=xe.get(be);return n.jsxs("span",{children:[Z>0&&" · ",Ae?je?n.jsxs("span",{title:`Team cap on ${be} is ${Ae.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${Ae.authorized}.`,children:[n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[be,"=",String(_e)]}),n.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",Ae.cap]})]}):n.jsxs("span",{title:`Team cap on ${be} is ${Ae.cap} with no approvers configured (hard cap). Authorized for ${Ae.authorized}; effective ${Ae.cap}.`,children:[n.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[be,"=",String(_e)]}),n.jsxs("span",{style:{marginLeft:"0.25rem",fontWeight:700},children:["→"," ",Ae.cap]})]}):n.jsxs("span",{children:[be,"=",String(_e)]})]},be)})}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[ne&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>I(t.authorization_id,!Q),disabled:P===t.authorization_id,title:Q?"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:P===t.authorization_id?Q?"Unarchiving…":"Archiving…":Q?"↩ Unarchive":"⊟ Archive"}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>N(t),children:ee?"▲ Hide Details":"▼ Details"})]}),ee&&n.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[de.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:de.map(([be,_e])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:be}),n.jsx("dd",{children:String(_e)})]},be))})]}),(L==null?void 0:L.context)&&Object.keys(L.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(L.context).map(([be,_e])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:be}),n.jsx("dd",{title:String(_e),children:Mm(be,_e,L.contextLabels)})]},be))})]}),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"}),u===t.authorization_id?n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):L?n.jsx("div",{className:"gate-content-block",children:n.jsx("div",{className:"gate-content-item",children:n.jsx("div",{className:"gate-content-text",children:L.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(t.created_at).toLocaleString(),t.earliest_expiry&&` · Expires: ${new Date(t.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:t.authorization_id}),n.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>b(t.authorization_id),children:f===t.authorization_id?"copied":"copy"})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!x&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>S(t),disabled:p===t.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:p===t.authorization_id?"Copying…":"⧉ Copy"}),!x&&(z==="active"||z==="pending")&&n.jsx("button",{className:J?"btn btn-primary btn-sm":"btn btn-secondary btn-sm",onClick:()=>S(t,{asEdit:!0}),disabled:p===t.authorization_id,title:J?"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:J?"⚠ Re-approve":"✎ Edit"}),!x&&oe&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>E(t),children:"↻ Extend"}),x&&j&&z!=="revoked"?n.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>k(t.authorization_id,x,le),disabled:g===t.authorization_id,children:g===t.authorization_id?"Revoking…":"Revoke"}):!x&&(z==="active"||z==="pending")?n.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>k(t.authorization_id),disabled:g===t.authorization_id,children:g===t.authorization_id?"Revoking…":"Revoke"}):null]})]})]})},t.authorization_id)}function Nj(){const[t,s]=h.useState([]),[a,o]=h.useState(!0),[l,u]=h.useState([]),[f,g]=h.useState(!1),[p,v]=h.useState(new Map),[y,x]=h.useState("mine"),[j,N]=h.useState("active"),[b,S]=h.useState(null),[k,E]=h.useState(null),[T,P]=sa(),[I,U]=h.useState(()=>T.get("new")==="1"),[V]=h.useState(()=>T.get("profile")),[z,J]=h.useState(()=>T.get("highlight")),[Q,ne]=h.useState(null),[ee,L]=h.useState({}),[oe,de]=h.useState(null),[Y,je]=h.useState(null),[xe,X]=h.useState(null),[q,G]=h.useState(new Set),[A,_]=h.useState(null),[se,me]=h.useState(new Set),[O,te]=h.useState(null),[le,pe]=h.useState(null),[ge,ie]=h.useState(new Set),be=gn(),{group:_e,groupId:Z,domain:Ae,mode:Ke,activeTeam:De}=vt(),Le=(De==null?void 0:De.isAdmin)===!0,[ut,Xe]=h.useState(()=>new Map),Qe=h.useCallback(()=>{o(!0),F.getMyAttestations().then(s).catch(()=>{}).finally(()=>o(!1))},[]),Je=h.useCallback(()=>{F.getArchivedMandates().then(ce=>me(new Set(ce))).catch(()=>{})},[]);h.useEffect(()=>{Je()},[Je]);const wt=h.useCallback(()=>{F.getEnrichedAuthorizations().then(ce=>ie(new Set(ce.filter(Ne=>Ne.needsReapproval).map(Ne=>Ne.authorizationId)))).catch(()=>{})},[]);h.useEffect(()=>{wt()},[wt]);const pt=async(ce,Ne)=>{te(ce);try{const we=await F.setMandateArchived(ce,Ne);me(new Set(we)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(we){alert(we instanceof Error?we.message:"Failed to update archive")}finally{te(null)}},Fe=h.useCallback(()=>{Z&&(g(!0),F.listTeamAuthorizations(Z).then(u).catch(()=>{}).finally(()=>g(!1)))},[Z]);Be("attestation-changed",()=>{Qe(),Le&&Z&&Fe(),wt()}),h.useEffect(()=>{if(!z)return;T.get("highlight")&&(T.delete("highlight"),P(T,{replace:!0}));const ce=window.setTimeout(()=>J(null),3e3);return()=>window.clearTimeout(ce)},[]),Lt(Qe,3e5),h.useEffect(()=>{y==="team"&&Le&&Z&&l.length===0&&!f&&Fe()},[y,Le,Z,l.length,f,Fe]),h.useEffect(()=>{let ce=!1;return F.listProfiles().then(Ne=>{if(ce)return;const we=tt=>tt.replace(/@.*$/,"").split("/").pop()??tt,Ue=tt=>tt.split("@")[1]??"",Oe=new Map;for(const tt of Ne){const Gt=we(tt.id),tr=Oe.get(Gt);(!tr||Ue(tt.id).localeCompare(Ue(tr.id),void 0,{numeric:!0})>0)&&Oe.set(Gt,tt)}v(Oe)}).catch(()=>{}),()=>{ce=!0}},[]);const he=h.useCallback(ce=>{const Ne=Gt=>Gt.replace(/@.*$/,"").split("/").pop()??Gt,we=Gt=>Gt.split("@")[1]??"",Ue=p.get(Ne(ce));if(!Ue)return;const Oe=we(ce),tt=we(Ue.id);if(!(!Oe||!tt))return tt.localeCompare(Oe,void 0,{numeric:!0})>0?Ue:void 0},[p]);h.useEffect(()=>{if(Ke!=="team"||!Z)return;const ce=y==="mine"?t:l;if(ce.length===0)return;const Ne=[...new Set(ce.map(we=>we.profile_id))].filter(we=>!ut.has(we));if(Ne.length!==0){Xe(we=>{const Ue=new Map(we);for(const Oe of Ne)Ue.set(Oe,null);return Ue});for(const we of Ne)F.getTeamProfileConfig(Z,we).then(Ue=>{Xe(Oe=>new Map(Oe).set(we,Ue))}).catch(()=>{})}},[t,l,y,Z,Ke,ut]);const $e=async ce=>{if(Q===ce.authorization_id){ne(null);return}ne(ce.authorization_id);const Ne=ce.authorization_id;if(!(Ne in ee)){de(ce.authorization_id);try{const we=await F.getGateContent(Ne);L(Ue=>({...Ue,[Ne]:we}))}catch{L(we=>({...we,[Ne]:null}))}finally{de(null)}}},Me=ce=>{navigator.clipboard.writeText(ce).then(()=>{X(ce),setTimeout(()=>X(null),2e3)})},H=async(ce,Ne)=>{var we;if(!Z){alert("No active group; cannot copy mandate.");return}pe(ce.authorization_id);try{const Ue=ce.authorization_id;let Oe=ee[Ue]??null;Ue in ee||(Oe=await F.getGateContent(Ue),L(bn=>({...bn,[Ue]:Oe})));const tt=Object.fromEntries(Object.entries(ce.frame).filter(([bn])=>bn!=="profile"&&bn!=="path")),Gt=(Oe==null?void 0:Oe.context)??{},tr=((we=Oe==null?void 0:Oe.gateContent)==null?void 0:we.intent)??"",is=ce.deferred_commitment_domains.length>0?"review":"automatic",la=ce.attested_domains[0]||Ae||"owner",Sn=Date.parse(ce.created_at),nr=ce.earliest_expiry?Date.parse(ce.earliest_expiry):NaN,rr=Number.isFinite(Sn)&&Number.isFinite(nr)&&nr>Sn?Math.round((nr-Sn)/1e3):void 0;let ca=ce.profile_id,_n=tt,sr=Gt,ar;const os=await F.listProfiles(),Tr=Wm(ce.profile_id,os);if(Tr&&Tr.id!==ce.profile_id){const bn=await F.getProfile(Tr.id);ca=Tr.id,_n=Vm(tt,bn),sr=Gm(Gt,bn),ar=ce.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:ca,groupId:Z,groupName:(_e==null?void 0:_e.name)??null,domain:la,isPersonal:!!(_e!=null&&_e.isPersonal),upgradedFromProfileId:ar})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:_n,context:sr,gateContent:{intent:tr},templateMode:is,templateTtl:rr})),Ne!=null&&Ne.asEdit?sessionStorage.setItem("agentEditReplaces",ce.authorization_id):sessionStorage.removeItem("agentEditReplaces"),be("/mandates/new/intent")}catch(Ue){alert(Ue instanceof Error?Ue.message:"Failed to copy mandate")}finally{pe(null)}},K=async(ce,Ne,we)=>{const Ue=Ne&&we?`Revoke ${Ne}'s ${we} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(Ue)){_(ce);try{await F.revokeAttestation(ce),G(Oe=>new Set(Oe).add(ce)),F.resyncGates().catch(()=>{}),Ne&&Z&&Fe()}catch(Oe){alert(Oe instanceof Error?Oe.message:"Failed to revoke mandate")}finally{_(null)}}},ye=y==="mine"?t:l,Ve=y==="mine"?a:f,We=y==="mine"?{revokedSet:q,archivedSet:se}:{revokedSet:q},st=ce=>Ei(ce,We),zt={active:0,pending:0,expired:0,revoked:0,archived:0};for(const ce of ye)zt[st(ce)]+=1;const Ft=y==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],B=(()=>{const ce=new Map;for(const Ne of ye){if(st(Ne)!==j)continue;const we=ce.get(Ne.profile_id)??{count:0,review:!1};we.count+=1,Ne.deferred_commitment_domains.length>0&&(we.review=!0),ce.set(Ne.profile_id,we)}return Array.from(ce.entries()).map(([Ne,we])=>({profileId:Ne,...we})).sort((Ne,we)=>lt(Ne.profileId).localeCompare(lt(we.profileId)))})(),ve=bj(ye.filter(ce=>{if(st(ce)!==j||b!==null&&ce.profile_id!==b)return!1;if(k!==null){const Ne=ce.deferred_commitment_domains.length>0;if(k==="review"&&!Ne||k==="auto"&&Ne)return!1}return!0}),We,z),Ie={revokedSet:q,expandedHash:Q,gateCache:ee,gateLoading:oe,copiedHash:xe,revokingHash:A,copyingHash:le,profileConfigCache:ut,mode:Ke,activeDomain:Ae,group:_e,groupId:Z,onExpand:$e,onCopyHash:Me,onCopy:H,onRevoke:K,onExtend:je,highlightHash:z},et={...Ie,archivedSet:se,archivingHash:O,onArchive:pt,needsReapprovalSet:ge};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:()=>U(!0),children:"+ New mandate"})]}),I&&n.jsx("div",{className:"modal-backdrop",onClick:()=>{U(!1),(T.get("new")||T.get("profile"))&&(T.delete("new"),T.delete("profile"),P(T,{replace:!0}))},children:n.jsxs("div",{className:"modal",onClick:ce=>ce.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:()=>{U(!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(fj,{onDismiss:()=>U(!1),preselectProfileId:V})]})]})}),Le&&n.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[n.jsx("button",{className:`nav-tab${y==="mine"?" active":""}`,onClick:()=>{x("mine"),N("active"),S(null),E(null),ne(null)},children:"Mine"}),n.jsx("button",{className:`nav-tab${y==="team"?" active":""}`,onClick:()=>{x("team"),N("active"),S(null),E(null),ne(null)},children:"Team"})]}),n.jsx("div",{className:"nav-tabs",children:Ft.map(ce=>n.jsxs("button",{className:`nav-tab${j===ce?" active":""}`,onClick:()=>{N(ce),S(null),E(null)},children:[ce.charAt(0).toUpperCase()+ce.slice(1)," (",zt[ce],")"]},ce))}),B.length>0&&n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[B.map(ce=>{const Ne=b===ce.profileId;return n.jsx("button",{className:`btn btn-sm ${Ne?"btn-primary":"btn-secondary"}`,onClick:()=>S(Ne?null:ce.profileId),children:lt(ce.profileId)},ce.profileId)}),n.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(ce=>{const Ne=k===ce;return n.jsx("button",{className:`btn btn-sm ${Ne?"btn-primary":"btn-secondary"}`,onClick:()=>E(Ne?null:ce),children:ce==="auto"?"Auto":"Review"},ce)})]}),Ve&&ye.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ve.length===0?n.jsx(ts,{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:"0.75rem"},children:ve.map(ce=>{const Ne=y==="team"?ce:null,we=Ne!=null&&Ne.owner?Ne.owner.name??Ne.owner.email??Ne.owner.userId:void 0;return n.jsx(kj,{item:ce,newerProfile:he(ce.profile_id),ownerLabel:we,isAdmin:Le,...y==="mine"?et:Ie},ce.authorization_id)})}),Y&&n.jsx(jj,{item:Y,onClose:()=>je(null),onSuccess:()=>{je(null),Qe()}})]})}function sn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function _t(t,s=!1){return t==null?"—":typeof t=="string"?t:typeof t=="boolean"?String(t):typeof t=="number"?s||Number.isInteger(t)?String(t):String(Math.round(t*100)/100):"—"}function Cj(t){return t==null?!1:typeof t=="string"||Array.isArray(t)?t.length>0:!0}function br(t,s,a){const o=s?Object.keys(s).filter(l=>l in t):Object.keys(t);return o.length===0?"—":o.map(l=>{var p,v;const u=t[l],f=((p=s==null?void 0:s[l])==null?void 0:p.title)??Ht(l),g=sn(u)?br(u,(v=s==null?void 0:s[l])==null?void 0:v.properties,a):_t(u,a);return`${f}: ${g}`}).join(" · ")}function Ej(t,s){const a=s?Object.keys(s).filter(u=>t.some(f=>u in f)):[...new Set(t.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)??Ht(u)}}),l=t.map(u=>({cells:a.map(f=>{var y,x;const g=u[f],p=sn(g)?br(g,(y=s==null?void 0:s[f])==null?void 0:y.properties,!1):_t(g),v=sn(g)?br(g,(x=s==null?void 0:s[f])==null?void 0:x.properties,!0):_t(g,!0);return v===p?{value:p,sealed:!1}:{value:p,valueTitle:v,sealed:!1}})}));return{columns:o,rows:l}}function Tj(t){return t.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 Ij(t,s){var l;if(Array.isArray(t)){if(t.length===0)return{value:"—"};if(t.every(y=>!sn(y)&&!Array.isArray(y))){if(t.every(j=>typeof j=="string"))return{lines:t};const y=t.map(j=>_t(j)).join(", "),x=t.map(j=>_t(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=t.map(y=>sn(y)?br(y,u,!1):_t(y)),g=t.map(y=>sn(y)?br(y,u,!0):_t(y,!0)),p=f.map((y,x)=>y===g[x]?void 0:g[x]),v=t.every(sn)?Ej(t,u):void 0;return{lines:f,...p.some(y=>y!==void 0)?{lineTitles:p}:{},...v?{table:v}:{}}}if(sn(t)){const u=s==null?void 0:s.properties,f=u?Object.keys(u).filter(v=>v in t):Object.keys(t);if(f.length>0&&f.every(v=>!sn(t[v])&&!Array.isArray(t[v])))return{sublist:f.map(y=>{var S;const x=t[y],j=((S=u==null?void 0:u[y])==null?void 0:S.title)??Ht(y),N=_t(x),b=_t(x,!0);return b===N?{key:y,label:j,value:N}:{key:y,label:j,value:N,valueTitle:b}})};const g=br(t,u,!1),p=br(t,u,!0);return p===g?{value:g}:{value:g,valueTitle:p}}if(typeof t=="string"&&(s==null?void 0:s.contentMediaType)==="text/x-diff")return{diffLines:Tj(t)};const a=_t(t),o=_t(t,!0);return o===a?{value:a}:{value:a,valueTitle:o}}function Aj(t){let s;try{s=JSON.parse(t)}catch{return null}return sn(s)?s:null}function Er(t){const s=t!=null&&t.structured&&Object.keys(t.structured).length>0?t.structured:void 0;if(s)return{obj:s,schema:t==null?void 0:t.outputSchema};const a=t!=null&&t.text?Aj(t.text):null;return a?{obj:a}:null}function Li(t){const s=Er(t);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 g of u){if(!(g in a))continue;const p=l[g],v=(p==null?void 0:p.title)??Ht(g),y={key:g,label:v,...Ij(a[g],p)};p!=null&&p.description&&(y.description=p.description),f.push(y)}return f}function zi(t,s){const a=Er(t);if(a){const l=Li(t),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=>Cj(a.obj[v.key]));const g=new Set(f.map(v=>v.key)),p=l.filter(v=>!g.has(v.key));return{kind:"structured",fields:f,moreFields:p,totalFields:l.length}}const o=t==null?void 0:t.text;return o&&o.trim().length>0?{kind:"text",fields:[],moreFields:[],totalFields:0,text:o}:{kind:"empty",fields:[],moreFields:[],totalFields:0}}function dh(t){return t?t.lines?`lines:${JSON.stringify(t.lines)}`:t.sublist?`sublist:${JSON.stringify(t.sublist.map(s=>[s.key,s.value]))}`:t.diffLines?`diffLines:${JSON.stringify(t.diffLines)}`:`value:${t.value??""}`:""}function ji(t){return{kind:t.length>0?"structured":"empty",fields:t,moreFields:[],totalFields:t.length}}function Rj(t,s,a){const o=Er(t),l=Er(s);if(!o&&!l){const j=(t==null?void 0:t.text)??"",N=(s==null?void 0:s.text)??"";return j===N?{approved:ji([]),current:ji([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:j},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:N},unchanged:!1}}const u=new Map(Li(t).map(j=>[j.key,j])),f=new Map(Li(s).map(j=>[j.key,j])),p=[...new Set([...u.keys(),...f.keys()])].filter(j=>j===(a==null?void 0:a.excludeKey)?!1:dh(u.get(j))!==dh(f.get(j))),v=a!=null&&a.fields&&a.fields.length>0?[...a.fields.filter(j=>p.includes(j)),...p.filter(j=>!a.fields.includes(j))]:p,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:ji(y),current:ji(x),unchanged:p.length===0}}function Pj(t){const s=t==null?void 0:t.structured;if(Array.isArray(s)&&s.every(sn))return s;if(t!=null&&t.text){let a;try{a=JSON.parse(t.text)}catch{return null}if(Array.isArray(a)&&a.every(sn))return a}return null}function Ki(t){const s=_t(t),a=_t(t,!0);return a===s?{value:s}:{value:s,valueTitle:a}}function Km(t){return!t||t.status!=="ok"?[]:Li(t.body)}function qm(t){if(!t)return"Not read.";switch(t.status){case"not_found":return"Not found in the system.";case"none":return"Nothing to read.";default:return"Not available right now."}}function Ym(t,s,a){var p;const o=Km(t);if(o.length===0)return{rawId:_t(s),context:[],unresolved:qm(t)};const l=t&&t.status==="ok"?(p=Er(t.body))==null?void 0:p.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,g=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=Xs(a==null?void 0:a.displayHints,y,v.label);if(!ta((b=a==null?void 0:a.displayHints)==null?void 0:b.money,y)&&!ta((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:N}=Fi(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:N}});return{name:u==null?void 0:u.value,rawId:_t(s),context:g}}const $j=new Set(["id","name","title","label"]);function ta(t,s){return!!(t!=null&&t.includes(s))}function Xs(t,s,a){var o;return((o=t==null?void 0:t.labels)==null?void 0:o[s])??a}function _j(t,s){const a=typeof t=="number"?t:Number(t);return Number.isFinite(a)?{value:`${a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${s?` ${s}`:""}`}:Ki(t)}function Lj(t){return typeof t!="number"&&typeof t!="string"?Ki(t):{value:`${t} %`}}function Fi(t,s,a,o){return ta(s==null?void 0:s.money,a)?_j(t,o):ta(s==null?void 0:s.percent,a)?Lj(t):Ki(t)}function Jm(t,s){return ta(t==null?void 0:t.hidden,s)}function zj(t,s,a){var f;const o=t==null?void 0:t.currencyField;if(!o)return;const l=o.indexOf(".");if(l<0){const g=s[o];return typeof g=="string"?g: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 Fj(t,s,a,o){const l=t.forEach??"",u=t.attach,f=t.elements??[],g=Math.min(s.length,f.length),p=s.slice(0,g),v=f.slice(0,g),y=[...new Set(p.flatMap(S=>Object.keys(S)))].filter(S=>S!==t.sourceArg).filter(S=>!Jm(a,`${l}[].${S}`)),x=new Map;if(u)for(const S of v)for(const k of Km(S))x.has(k.key)||x.set(k.key,k.label);const j=u?[...x.keys()].filter(S=>!$j.has(S)):[],N=[];u&&N.push({key:`__attach:${u}`,label:Xs(a,`${l}[].${u}`,Ht(t.sourceArg??u))});for(const S of y)N.push({key:`bound:${S}`,label:Xs(a,`${l}[].${S}`,Ht(S))});for(const S of j)N.push({key:`attached:${S}`,label:Xs(a,`${l}[].${u}.${S}`,x.get(S)??Ht(S))});const b=p.map((S,k)=>{var I;const E=v[k],T=[];if(u){const U=Ym(E,t.sourceArg?S[t.sourceArg]:void 0),V=U.name?`${U.name} (${U.rawId})`:U.unresolved?`${U.rawId} — ${U.unresolved}`:U.rawId;T.push({value:V,sealed:!1})}for(const U of y){const{value:V,valueTitle:z}=Fi(S[U],a,`${l}[].${U}`,o);T.push({value:V,valueTitle:z,sealed:!0})}const P=E&&E.status==="ok"?(I=Er(E.body))==null?void 0:I.obj:void 0;for(const U of j){const V=P==null?void 0:P[U],{value:z,valueTitle:J}=V!==void 0?Fi(V,a,`${l}[].${u}.${U}`,o):{value:"—",valueTitle:void 0};T.push({value:z,valueTitle:J,sealed:!1})}return{cells:T}});return{columns:N,rows:b,...t.overflow?{overflowNote:`${t.overflow.total-t.overflow.shown} more not shown`}:{}}}function Mj(t){return`${Ht(t)} — from the system`}function Oj(t){const s=Mj(t.tool),a=t.result;if(!a||a.status!=="ok")return{heading:s,note:qm(a)};const o=Pj(a.body);if(o){if(o.length===0)return{heading:s,note:"Nothing found."};const l=[...new Set(o.flatMap(g=>Object.keys(g)))],u=l.map(g=>({key:g,label:Ht(g)})),f=o.map(g=>({cells:l.map(p=>({...Ki(g[p]),sealed:!1}))}));return{heading:s,table:{columns:u,rows:f}}}return{heading:s,body:zi(a.body,{fields:t.fields})}}function Bj(t,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),g=zj(a,t,x=>{var N,b;const j=(N=o.get(x))==null?void 0:N.result;return j&&j.status==="ok"?(b=Er(j.body))==null?void 0:b.obj:void 0}),p=(a==null?void 0:a.order)??[],v=[...new Set([...p,...Object.keys(t)])],y=[];for(const x of v){if(!(x in t)||gm.has(x)||Jm(a,x))continue;const j=Xs(a,x,Ht(x)),N=l.get(x);if(N){const E=Array.isArray(t[x])?t[x]:[];y.push({kind:"table",key:x,label:j,table:Fj(N,E,a,g)});continue}const b=o.get(x);if(b){const E=Ym(b.result,t[x],{pathPrefix:x,displayHints:a,currency:g});y.push({kind:"identity",key:x,label:j,identity:E});continue}const{value:S,valueTitle:k}=Fi(t[x],a,x,g);y.push({kind:"scalar",key:x,label:j,value:S,valueTitle:k})}return{rows:y,sections:u.map(Oj)}}function Dj(t){return t.offDevice?"off-device":t.boundContent===void 0?"none":t.hasHashToCheck?t.hashVerified===!0?"verified":"mismatch":"unchecked"}function Uj(t,s){return t===void 0?{kind:"empty",fields:[],moreFields:[],totalFields:0}:typeof t=="string"?zi({text:t}):zi({structured:t},{fields:s})}function Wj(t,s){return t?Object.entries(t).filter(([,a])=>a!=null&&a!=="").map(([a,o])=>({key:a,label:ym(a,s).label,value:String(o)})):[]}function Mi({table:t}){return t.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:t.columns.map(s=>n.jsx("th",{children:s.label},s.key))})}),n.jsx("tbody",{children:t.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))})]}),t.overflowNote&&n.jsx("p",{className:"preview-note",children:t.overflowNote})]})}function fh({row:t}){return n.jsxs("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:[t.label,t.description&&n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.72rem",fontWeight:400,whiteSpace:"normal",marginTop:"0.1rem"},children:t.description})]})}function Hj({row:t}){return t.sublist?n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.6rem",margin:0},children:t.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))}):t.diffLines?n.jsx("div",{style:{fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.8rem"},children:t.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))}):t.table?n.jsx(Mi,{table:t.table}):t.lines?n.jsx("div",{children:t.lines.map((s,a)=>{var o;return n.jsx("div",{title:(o=t.lineTitles)==null?void 0:o[a],children:s},a)})}):n.jsx("span",{title:t.valueTitle,children:t.value})}function sc({rows:t}){return n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:t.map(s=>s.table?n.jsxs("div",{style:{gridColumn:"1 / -1"},children:[n.jsx(fh,{row:s}),n.jsx(Mi,{table:s.table})]},s.key):n.jsxs(h.Fragment,{children:[n.jsx(fh,{row:s}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:n.jsx(Hj,{row:s})})]},s.key))})}function Ni({rendered:t}){return t.kind==="empty"?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",margin:"0.4rem 0"},children:"No fields returned."}):t.kind==="text"?n.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.85rem",margin:"0.4rem 0"},children:t.text}):n.jsxs(n.Fragment,{children:[n.jsx(sc,{rows:t.fields}),t.moreFields.length>0&&n.jsxs("details",{style:{fontSize:"0.8rem"},children:[n.jsxs("summary",{style:{cursor:"pointer",color:"var(--text-tertiary)"},children:["All fields (",t.totalFields,")"]}),n.jsx(sc,{rows:t.moreFields})]})]})}function Qm({receipt:t,profile:s}){var j;const[a,o]=h.useState(void 0),[l,u]=h.useState(null),f=!!(t.contentHash&&t.contentBinding);if(h.useEffect(()=>{let N=!0;return o(void 0),u(null),(async()=>{let b;try{b=await F.getArchivedReceipt(t.id)}catch{N&&o(null);return}let S=null;const k=b==null?void 0:b.entry.boundContent;if(k!==void 0&&f)try{S=await bm(t.contentBinding.kind,k)===t.contentHash}catch{S=!1}N&&(u(S),o(b))})(),()=>{N=!1}},[t.id,t.contentHash,t.contentBinding,f]),a===void 0)return n.jsx("div",{className:"ticket-done-box ticket-done-loading","data-testid":"ticket-what-was-done","data-bound":"loading","aria-busy":"true",children:"Loading…"});const g=a===null,p=a==null?void 0:a.entry.boundContent,v=Dj({offDevice:g,boundContent:p,hasHashToCheck:f,hashVerified:l});if(v==="off-device")return n.jsx("div",{className:"ticket-done-box ticket-done-off-device","data-testid":"ticket-what-was-done","data-bound":"off-device",children:n.jsx("p",{className:"ticket-done-note",children:"Content not on this device — only the signed values are shown."})});if(v==="none"){const N=Wj(t.executionContext,s);return n.jsxs("div",{className:"ticket-done-box","data-testid":"ticket-what-was-done","data-bound":"none",children:[n.jsx("h4",{children:"What was done"}),N.length>0?n.jsx("dl",{className:"ticket-done-fields",children:N.map(b=>n.jsxs("div",{className:"ticket-done-field-row",children:[n.jsx("dt",{children:b.label}),n.jsx("dd",{children:b.value})]},b.key))}):n.jsx("p",{className:"ticket-done-note",children:"No checked values recorded for this action."})]})}const y=Uj(p,(j=t.contentBinding)==null?void 0:j.fields),x=v==="verified"?"ticket-done-verified":v==="mismatch"?"ticket-done-mismatch":"ticket-done-unchecked";return n.jsxs("div",{className:`ticket-done-box ${x}`,"data-testid":"ticket-what-was-done","data-bound":v,children:[n.jsxs("h4",{children:["What was done",v!=="unchecked"&&n.jsxs(n.Fragment,{children:[" ",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]})]}),n.jsx(Ni,{rendered:y}),v==="verified"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-ok",children:"✓ This exact content is bound by hash — any change after the fact would break the ticket."}),v==="mismatch"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-bad",children:"⚠ This content does NOT match the ticket's signed hash — it may have been altered since archiving."}),v==="unchecked"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-neutral",children:"This content is kept on this device, but the ticket carries no content hash — it cannot be checked against the ticket."})]})}const hh=500;function ac(t){return t.length>hh?`${t.slice(0,hh)}…`:t}function mh(t){return t.length?t[0].toUpperCase()+t.slice(1):t}function Vj(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Xm(t,s,a){switch(t.status){case"none":return t.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 t.reason==="no_connector"?{heading:"Preview not available",note:"Preview not available on this gateway."}:{heading:"Preview not available",note:t.message?`Preview not available — ${ac(t.message)}`:"Preview not available."};case"not_found":return{heading:"Not found in your system",note:t.message?`Not found in your system — ${ac(t.message)}`:"Not found in your system."};case"ok":{if("reads"in t)return{heading:`What will be created in ${s}`,note:`Read by the gateway, not by the AI — read at ${Vj(t.readAt)}.`,creation:Bj(a??{},t.reads,t.display)};const o=zi(t.body,{fields:t.fields}),l={heading:`From ${s}, before it runs`,note:`Read by the gateway with ${t.tool} when you opened this card — the AI is not involved.`,rendered:o},u=t.version;if(u&&(l.versionNote=`You approve ${u.field} ${u.approved}; if it changes, ${s} refuses it.`,u.stale)){const f=Rj(t.body,u.currentBody,{fields:t.fields,excludeKey:u.field});l.stale={heading:`A newer ${u.field} exists (${u.current})`,approvedLabel:`${mh(u.field)} ${u.approved}`,currentLabel:`${mh(u.field)} ${u.current}`,...f.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:f.approved,currentRendered:f.current}}}return l}}}function Gj(t,s){if(t.state!=="failed")return null;const a=t.detail?ac(t.detail):void 0;return t.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 Kj(t){return t!==null&&t!=="loading"&&t!=="ok"&&t!=="stale"}function qj({identity:t}){return t.unresolved?n.jsxs("span",{children:[n.jsx("span",{className:"id-raw",children:t.rawId})," ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["— ",t.unresolved]})]}):n.jsxs("span",{children:[t.name&&n.jsx("span",{className:"src-tag-value src-tag-system-cell",children:t.name})," ",n.jsx("span",{className:"id-raw",children:t.rawId}),t.context.length>0&&n.jsx("span",{className:"creation-context",children:t.context.map(s=>n.jsxs("span",{children:[" · ",s.label," ",s.value]},s.key))})]})}function Yj({view:t}){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:t.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(qj,{identity:s.identity}):n.jsx("span",{className:"src-tag-value src-tag-sealed-cell",title:s.valueTitle,children:s.value})})]},s.key))}),t.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(Mi,{table:s.table})]},s.key)),t.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(Mi,{table:s.table}),s.body&&n.jsx(sc,{rows:s.body.fields}),s.note&&n.jsx("p",{className:"preview-note",children:s.note})]},a))]})}function Zm({resp:t,systemName:s,toolArgs:a,sealed:o}){const l=Xm(t,s,a??void 0),u=t.status==="ok"?l.stale?"stale":"ok":t.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(Yj,{view:l.creation}),l.rendered&&n.jsx(Ni,{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(Ni,{rendered:l.stale.approvedRendered})}),n.jsx("dt",{children:l.stale.currentLabel}),n.jsx("dd",{children:n.jsx(Ni,{rendered:l.stale.currentRendered})})]})]})]})}function Jj({proposalId:t,systemName:s,toolArgs:a,sealed:o,onTone:l,onData:u}){const[f,g]=h.useState(null),[p,v]=h.useState(!1);return h.useEffect(()=>{let y=!0;return g(null),v(!1),F.getProposalPreview(t).then(x=>{y&&g(x)}).catch(()=>{y&&v(!0)}),()=>{y=!1}},[t]),h.useEffect(()=>{if(p){l==null||l("unavailable"),u==null||u({status:"unavailable",reason:"connector_error"});return}if(!f){u==null||u(null);return}const y=Xm(f,s,a??void 0);l==null||l(f.status==="ok"?y.stale?"stale":"ok":f.status),u==null||u(f)},[f,p,s,l,u]),p?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(Zm,{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 Ul=6;function Oi(t){if(!t)return;const s=Date.parse(t);return Number.isNaN(s)?t:new Date(s).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Qj(t){if(!t)return{first:""};const s=t.split(`
85
- `);return s.length<=Ul?{first:t}:{first:s.slice(0,Ul).join(`
86
- `),more:s.slice(Ul).join(`
87
- `)}}const Xj="Linked by the AI",Zj="linked automatically — this action already carried a reference to it";function eS(t){if(t.status==="none")return{state:"none",note:"No request linked.",chain:[]};if(t.status==="unreadable")return{state:"unreadable",note:`Request: link not readable (${t.reason}).`,chain:[]};if(t.status==="not_found")return{state:"not_found",note:"Request: this message no longer exists.",chain:[]};const{first:s,more:a}=Qj(t.body),o=[t.connector,t.kind,t.author?`from ${t.author}`:void 0,Oi(t.at)].filter(l=>!!l);return{state:"ok",implicit:t.implicit,tag:Xj,...t.implicit?{implicitNote:Zj}:{},metaLine:o.join(" · "),title:t.title,bodyFirst:s,bodyMore:a,attribution:t.author?`— from ${t.author}, not checked`:void 0,chain:t.chain.map(l=>({...l,at:Oi(l.at)}))}}const Vs="Read by the gateway — same customer, not matched to this request";function tS(t){const s=t.matchedKeyType==="email_domain"?"matched by email domain":"matched by email";return`Latest entries for ${t.matchedKeyValue} (${s})`}function nS(t){var l;const s=!!t.aiWritten,a=s?"Activity":t.type??t.kind??"Entry";let o;if(s){const u=((l=t.aiWritten)==null?void 0:l.at)!==void 0?Oi(new Date(t.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=t.author?`— from ${t.author}, not checked`:"— not checked";return{headLabel:a,at:Oi(t.at),title:t.title,body:t.body,attribution:o,aiWritten:s}}function rS(t){if(t.status==="no_customer_link")return{state:"no_customer_link",label:Vs,note:"No customer link — nothing to match history against.",matchNotes:[],items:[]};if(t.status==="no_match")return{state:"no_match",label:Vs,note:"No match — no connector here matches on this customer's available identity key.",matchNotes:[],items:[]};if(t.status==="unreachable")return{state:"unreachable",label:Vs,note:`${t.connectorIds.join(", ")} not reachable — history could not be read.`,matchNotes:[],items:[]};const s=t.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})=>nS(l)),a=t.matches.map(tS),o=t.unreachableConnectorIds.length>0?`${t.unreachableConnectorIds.join(", ")} not reachable — showing what could be read.`:void 0;return s.length===0?{state:"empty",label:Vs,note:"Nothing in the last few days.",matchNotes:a,items:[],unreachableNote:o}:{state:"ok",label:Vs,note:"",matchNotes:a,items:s,unreachableNote:o}}function ep({resp:t}){const s=eS(t.request),a=rS(t.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 sS({proposalId:t,onData:s}){const[a,o]=h.useState(null),[l,u]=h.useState(!1);return h.useEffect(()=>{let f=!0;return o(null),u(!1),F.getProposalRequestContext(t).then(g=>{f&&o(g)}).catch(()=>{f&&u(!0)}),()=>{f=!1}},[t]),h.useEffect(()=>{s==null||s(l?null:a)},[a,l,s]),l||!a?null:n.jsx(ep,{resp:a})}function aS(t,s,a){const o=Object.entries(t??{});if(o.length===0)return{entry:void 0,otherCount:0};const u=o.find(([,g])=>g.by===s)??(a?o.find(([g])=>g===`domain:${a}`):void 0),f=u?o.length-1:o.length;return{entry:u==null?void 0:u[1],otherCount:f}}function iS(t){return t.offDevice?"off-device":t.recordedHash?t.localHash===t.recordedHash?"verified":"mismatch":"unchecked"}function oS(t){if(!(t<=0))return`${t} other approver${t===1?"":"s"} recorded their own.`}function lS(t){return new Date(t).toLocaleString([],{hour:"2-digit",minute:"2-digit"})}function tp({proposalId:t,tool:s,manifests:a}){const{user:o,domain:l}=vt(),[u,f]=h.useState(null),[g,p]=h.useState(null),[v,y]=h.useState(!1);if(h.useEffect(()=>{let P=!0;return f(null),p(null),y(!1),Promise.all([F.getShownSnapshot(t),F.getProposal(t)]).then(([I,U])=>{P&&(f(I),p(U))}).catch(()=>{P&&y(!0)}),()=>{P=!1}},[t]),v||!u||!g)return null;const x=u.status==="off_device",{entry:j,otherCount:N}=aS(g.shownHashes,(o==null?void 0:o.id)??"",l),b=iS({offDevice:x,recordedHash:j==null?void 0:j.hash,localHash:u.status==="ok"?u.shownHash:void 0}),S=oS(N);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:k}=u,{integrationId:E}=Cr(s),T=aa(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 ",lS(k.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(Zm,{resp:k.preview,systemName:T,toolArgs:k.toolArgs,sealed:k.sealed}),n.jsx(ep,{resp:k.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 Gs({label:t,children:s}){return n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"receipt-row-label",children:t}),n.jsx("dd",{className:"receipt-row-value",children:s})]})}function cS({receipt:t,manifests:s,localAuth:a,localUnavailable:o,signature:l,grantTitle:u,ownerLabel:f,spUrl:g,formatDate:p,onOpenComplete:v,isNew:y=!1,defaultOpen:x=!1}){var Q;const j=as(t.profileId),N=$0(t,j),b=_0(a==null?void 0:a.context,j),S=z0(t,(a==null?void 0:a.bounds)??t.limits,j),k=a==null?void 0:a.intent,E=er(t.profileId).testSetup||Gi(t.action),[T,P]=h.useState(!1),[I,U]=h.useState(x),V=Date.now(),z=ia(t.authorizationId,t.profileId,u?{[t.authorizationId??""]:u}:{}),J=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:()=>U(ne=>!ne),children:[n.jsx(kr,{profileId:t.profileId,area:z,system:oa(t.action,s),time:Ai(t.timestamp,V),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",children:Ic(t,s)}),n.jsx("span",{className:"receipt-tag",children:Ti(t)?"approved":"automatic"}),t.contentHash&&n.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(Q=t.contentBinding)!=null&&Q.fields?`The ticket binds: ${t.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),E&&n.jsx("span",{className:"sim-mark",children:"Test setup"})]}),N&&n.jsx("div",{className:"receipt-scope",children:N})]}),I&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"receipt-when",children:p(t.timestamp)}),n.jsx(Qm,{receipt:t,profile:j}),t.proposalId&&n.jsx(tp,{proposalId:t.proposalId,tool:t.action,manifests:s}),n.jsxs("dl",{className:"receipt-rows",children:[n.jsxs(Gs,{label:"mandate",children:[n.jsx("strong",{children:u||M0(t.profileId)})," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),f&&n.jsx(Gs,{label:"owner",children:f}),b&&n.jsxs(Gs,{label:"allowed",children:[b," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),S&&n.jsxs(Gs,{label:"used",children:[n.jsx("span",{className:"receipt-num",children:S})," ",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),n.jsx(Gs,{label:"intent",children:k?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:`intent-text${T?"":" intent-clamped"}`,children:k}),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"}),g&&n.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",n.jsx("a",{className:"receipt-link",href:`${g}/r/${t.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 · ",t.id]}),n.jsxs("div",{children:["action · ",t.action]}),n.jsxs("div",{children:["profile · ",t.profileId]}),t.authorizationId&&n.jsxs("div",{children:["mandate · ",t.authorizationId]}),Object.keys(t.executionContext??{}).length>0&&n.jsxs("div",{children:["scope ·"," ",Object.entries(t.executionContext).map(([ne,ee])=>`${ne}=${ee}`).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]}),t.contentHash&&n.jsxs("div",{children:["content · ",t.contentHash]}),t.proposalId&&n.jsxs("div",{children:["proposal · ",t.proposalId]}),n.jsxs("div",{children:["signature · ",t.signature]})]})]})]})]}),n.jsxs("div",{className:"ticket-obj-stub",children:[n.jsx("span",{className:"ticket-obj-no",title:t.id,children:Sm(t.id)}),n.jsx("span",{className:"ticket-obj-time",children:Ai(t.timestamp,V)}),J&&n.jsx("span",{className:"ticket-obj-sig",title:"Signature checked on this device",children:"✓ verified"})]})]})}function uS({receipt:t,onClose:s}){const[a,o]=h.useState(null),[l,u]=h.useState(null),[f,g]=h.useState(null),[p,v]=h.useState(!0),[y,x]=h.useState(!1);h.useEffect(()=>{let k=!1;return v(!0),F.getArchivedReceipt(t.id).then(E=>{k||(o(E),u(E?"local":"authority-server"),g((E==null?void 0:E.signature)??null))}).catch(()=>{k||u("authority-server")}).finally(()=>{k||v(!1)}),()=>{k=!0}},[t.id]);const j=a?a.entry:{receipt:t},N=JSON.stringify(j,null,2);function b(){const k=URL.createObjectURL(new Blob([N],{type:"application/json"})),E=document.createElement("a");E.href=k,E.download=`suveren-ticket-${t.id.slice(0,8)}.json`,E.click(),URL.revokeObjectURL(k)}async function S(){try{await navigator.clipboard.writeText(N),x(!0),setTimeout(()=>x(!1),2e3)}catch{x(!1)}}return n.jsx("div",{className:"modal-backdrop",onClick:k=>k.target===k.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:p?"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:N})]}),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 dS(t){return new Date(t*1e3).toLocaleString()}function fS(t,s){if(s==="all")return!0;const a=s==="1d"?1:s==="7d"?7:30,o=Math.floor(Date.now()/1e3)-a*86400;return t.timestamp>=o}function hS(t,s){if(!s)return!0;const a=s.toLowerCase();return t.profileId.toLowerCase().includes(a)||lt(t.profileId).toLowerCase().includes(a)||t.path.toLowerCase().includes(a)||t.action.toLowerCase().includes(a)||t.attestationHash.toLowerCase().includes(a)||t.id.toLowerCase().includes(a)||JSON.stringify(t.executionContext).toLowerCase().includes(a)}function ph(t,s){const a=new Map(t.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 mS(){const{activeTeam:t,groupId:s}=vt(),a=(t==null?void 0:t.isAdmin)===!0,[o,l]=h.useState("mine"),[u,f]=sa(),g=B0(u.get("filter")),p=B=>{const ve=new URLSearchParams(u);B==="all"?ve.delete("filter"):ve.set("filter",B),f(ve,{replace:!0})},[v,y]=h.useState(null),x=h.useRef(!1),[j,N]=h.useState([]),[b,S]=h.useState([]),[k,E]=h.useState(""),[T,P]=h.useState(!0),[I,U]=h.useState({}),[V,z]=h.useState(new Set),[J,Q]=h.useState(""),[ne,ee]=h.useState(new Set),[L,oe]=h.useState(new Set),[de,Y]=h.useState("all"),[je,xe]=h.useState(!1),[X,q]=h.useState(!1),[G,A]=h.useState(null),[_,se]=h.useState({}),[me,O]=h.useState(!1),[te,le]=h.useState({}),[pe,ge]=h.useState({}),[ie,be]=h.useState(null),[_e,Z]=h.useState(null),[Ae,Ke]=h.useState(!1),[De,Le]=h.useState(!1),ut=h.useRef(""),Xe=h.useCallback(B=>o==="team"&&a&&s?F.listTeamReceiptsPage(s,{before:B,limit:200}):F.getMyReceiptsPage({before:B,limit:200}),[o,a,s]),Qe=h.useCallback(()=>{const B=o==="team"?`team:${s}`:"mine",ve=ut.current!==B;ut.current=B,P(!0),Le(!1),Xe().then(Ie=>{N(et=>ve?Ie.receipts:ph(et,Ie.receipts)),Z(et=>ve?Ie.nextBefore:et??Ie.nextBefore)}).catch(()=>{ve&&N([]),Le(!0)}).finally(()=>P(!1))},[Xe,o,s]),Je=h.useCallback(()=>{!_e||Ae||(Ke(!0),Le(!1),Xe(_e).then(B=>{N(ve=>ph(ve,B.receipts)),Z(B.nextBefore)}).catch(()=>Le(!0)).finally(()=>Ke(!1)))},[_e,Ae,Xe]);Lt(Qe,12e4);const wt=h.useCallback(()=>{Qe(),v!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||F.markTicketsSeen(Date.now()).catch(()=>{}))},[Qe,v]);Be("ticket-recorded",wt),h.useEffect(()=>{T||x.current||(x.current=!0,F.getLastSeenTicketsAt().then(B=>(y(B),F.markTicketsSeen(Date.now()))).catch(()=>y(Number.POSITIVE_INFINITY)))},[T]),h.useEffect(()=>{F.getIntegrationManifests().then(({manifests:B})=>S(B)).catch(()=>{}),fetch("/health").then(B=>B.json()).then(B=>{typeof B.spUrl=="string"&&E(B.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),h.useEffect(()=>{F.getLocalAuthorizations().then(({authorizations:B,signatures:ve})=>{se(B),le(ve),O(!1)}).catch(()=>{se({}),le({}),O(!0)}),F.getMyAttestations().then(B=>{const ve={};for(const Ie of B)Ie.authorization_id&&Ie.title&&(ve[Ie.authorization_id]=Ie.title);ge(ve)}).catch(()=>{})},[]),h.useEffect(()=>{o!=="team"||Object.keys(I).length>0||F.listUsers().then(B=>{const ve={};for(const Ie of B)ve[Ie.id]={name:Ie.name,email:Ie.email};U(ve)}).catch(()=>{})},[o,I]);const pt=h.useMemo(()=>{const B=new Set;for(const ve of j)B.add(lt(ve.profileId));return[...B].sort()},[j]),Fe=h.useMemo(()=>{const B=new Set;for(const ve of j)B.add(ve.action);return[...B].sort()},[j]),he=h.useMemo(()=>{if(o!=="team")return[];const B=new Set;for(const ve of j)ve.userId&&B.add(ve.userId);return[...B].map(ve=>{var Ie;return{id:ve,label:(Ie=I[ve])!=null&&Ie.name?`${I[ve].name} (${I[ve].email})`:ve}}).sort((ve,Ie)=>ve.label.localeCompare(Ie.label))},[o,j,I]),$e=h.useMemo(()=>j.filter(B=>!(!hS(B,J)||ne.size>0&&!ne.has(lt(B.profileId))||L.size>0&&!L.has(B.action)||V.size>0&&B.userId&&!V.has(B.userId)||!fS(B,de))),[j,J,ne,L,V,de]),Me=h.useMemo(()=>{const B={automatic:0,approved:0,all:0};for(const ve of $e)B.all+=1,B[ec(ve,"approved")?"approved":"automatic"]+=1;return B},[$e]),H=h.useMemo(()=>$e.filter(B=>ec(B,g)),[$e,g]),K=h.useMemo(()=>v===null?0:H.filter(B=>Ii(B,v)).length,[H,v]),ye=ne.size>0||L.size>0||V.size>0||de!=="all";function Ve(B){ee(ve=>{const Ie=new Set(ve);return Ie.has(B)?Ie.delete(B):Ie.add(B),Ie})}function We(B){oe(ve=>{const Ie=new Set(ve);return Ie.has(B)?Ie.delete(B):Ie.add(B),Ie})}function st(B){z(ve=>{const Ie=new Set(ve);return Ie.has(B)?Ie.delete(B):Ie.add(B),Ie})}function zt(){ee(new Set),oe(new Set),z(new Set),Y("all"),Q("")}async function Ft(){q(!0),A(null);try{const{bundle:B,filename:ve}=await F.fetchEvidenceBundle(),Ie=URL.createObjectURL(new Blob([JSON.stringify(B,null,2)],{type:"application/json"})),et=document.createElement("a");et.href=Ie,et.download=ve,et.click(),URL.revokeObjectURL(Ie);const ce=B.sources??{};ce.authorityServer?ce.local||A(`Downloaded Authority Server history only — ${ce.localError??"local archive unavailable."}`):A(`Downloaded local evidence only — ${ce.asError??"Authority Server export unavailable."}`)}catch(B){A(`Export failed: ${B instanceof Error?B.message:String(B)}`)}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.",K>0&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("b",{"data-testid":"tickets-new-count",children:[K," new since your last visit"]})]})]})]}),n.jsx("button",{className:"btn btn-secondary",onClick:Ft,disabled:X,children:X?"Preparing…":"Download evidence"})]}),G&&n.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:G}),a&&n.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(B=>n.jsx("button",{onClick:()=>l(B),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:o===B?"2px solid var(--accent)":"2px solid transparent",color:o===B?"var(--text-primary)":"var(--text-tertiary)",fontWeight:o===B?600:500},children:B==="mine"?"Mine":"Team"},B))}),n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which tickets",children:O0.map(B=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`tickets-filter-${B}`,"aria-selected":g===B,onClick:()=>p(B),children:[B==="automatic"?"Automatic":B==="approved"?"Approved":"All",n.jsx("span",{className:"n",children:Me[B]})]},B))}),g==="automatic"&&n.jsx("p",{className:"page-subtitle",style:{marginTop:"-0.25rem"},children:'Automatic — no person approved these. Approved tickets are under "Approved".'}),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",placeholder:"Search by profile, action, path, or hash…",value:J,onChange:B=>Q(B.target.value)}),J&&n.jsx("button",{className:"search-clear",onClick:()=>Q(""),children:"×"})]}),n.jsxs("button",{className:`btn btn-sm btn-secondary${je?" active":""}`,onClick:()=>xe(!je),children:["Filters",ye?` (${ne.size+L.size+(de!=="all"?1:0)})`:""]})]}),je&&n.jsxs("div",{className:"filter-panel",children:[pt.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Profile"}),n.jsx("div",{className:"filter-chips",children:pt.map(B=>n.jsx("button",{className:`filter-chip${ne.has(B)?" selected":""}`,onClick:()=>Ve(B),children:B},B))})]}),Fe.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Action"}),n.jsx("div",{className:"filter-chips",children:Fe.map(B=>n.jsx("button",{className:`filter-chip${L.has(B)?" selected":""}`,onClick:()=>We(B),children:B},B))})]}),o==="team"&&he.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Owner"}),n.jsx("div",{className:"filter-chips",children:he.map(B=>n.jsx("button",{className:`filter-chip${V.has(B.id)?" selected":""}`,onClick:()=>st(B.id),children:B.label},B.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(([B,ve])=>n.jsx("button",{className:`filter-chip${de===B?" selected":""}`,onClick:()=>Y(B),children:ve},B))})]})]}),ye&&n.jsxs("div",{className:"active-filters",children:[[...ne].map(B=>n.jsxs("span",{className:"active-chip",onClick:()=>Ve(B),children:[B," ",n.jsx("span",{className:"chip-remove",children:"×"})]},B)),[...L].map(B=>n.jsxs("span",{className:"active-chip",onClick:()=>We(B),children:[B," ",n.jsx("span",{className:"chip-remove",children:"×"})]},B)),[...V].map(B=>{const ve=I[B],Ie=ve?ve.name:B;return n.jsxs("span",{className:"active-chip",onClick:()=>st(B),children:[Ie," ",n.jsx("span",{className:"chip-remove",children:"×"})]},B)}),de!=="all"&&n.jsxs("span",{className:"active-chip",onClick:()=>Y("all"),children:[de==="1d"?"Today":de==="7d"?"7 days":"30 days"," ",n.jsx("span",{className:"chip-remove",children:"×"})]}),n.jsx("button",{className:"clear-filters",onClick:zt,children:"Clear all"})]}),De&&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."})}),T&&j.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):H.length===0?n.jsx(ts,{icon:"⌕",title:j.length===0?"No tickets in the last 30 days":"No matching tickets",text:j.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:H.length===j.length?`${j.length} ticket${j.length!==1?"s":""}`:`${H.length} of ${j.length} tickets`}),n.jsx("div",{className:"timeline",children:H.map(B=>{const ve=B.userId?I[B.userId]:void 0;return n.jsx("div",{className:"timeline-event",children:n.jsx(cS,{receipt:B,manifests:b,localAuth:B.authorizationId?_[B.authorizationId]:void 0,localUnavailable:me,signature:te[B.id],grantTitle:B.authorizationId?pe[B.authorizationId]:null,ownerLabel:o==="team"&&B.userId?ve?`${ve.name} (${ve.email})`:B.userId:null,spUrl:k,formatDate:dS,onOpenComplete:()=>be(B),isNew:v!==null&&Ii(B,v),defaultOpen:H.length===1})},B.id)})})]}),ie&&n.jsx(uS,{receipt:ie,onClose:()=>be(null)}),_e&&n.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:Je,disabled:Ae,children:Ae?"Loading…":"Load older"})})]})}function pS(){const[t,s]=h.useState(null),[a,o]=h.useState({}),[l,u]=h.useState(!1),[f,g]=h.useState({}),p=h.useCallback(()=>{F.getMyAttestations().then(S=>{const k={};for(const E of S)E.title&&(k[E.authorization_id]=E.title);g(k)}).catch(()=>{})},[]);h.useEffect(()=>{p()},[p]),Lt(p,3e5);const[v,y]=h.useState(null),x=h.useRef(!1),j=h.useCallback(()=>{F.getDenials({limit:200}).then(({records:S})=>{s(S),u(!1)}).catch(()=>u(!0))},[]);h.useEffect(()=>{j()},[j]),Lt(j,6e4),h.useEffect(()=>{if(!t)return;const S=[...new Set(t.map(k=>k.profile).filter(k=>!!k))].filter(k=>!(k in a));S.length!==0&&Promise.all(S.map(k=>F.getProfile(k).catch(()=>null))).then(k=>{o(E=>{const T={...E};return S.forEach((P,I)=>{k[I]&&(T[P]=k[I])}),T})})},[t,a]),h.useEffect(()=>{!t||x.current||(x.current=!0,F.getLastSeenBlockedAt().then(S=>(y(S),F.markBlockedSeen(Date.now()))).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[t]);const N=h.useCallback(()=>{j(),p(),v!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||F.markBlockedSeen(Date.now()).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[j,p,v]);if(Be("denial-recorded",N),l)return n.jsx(ts,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(t===null)return null;const b=_x(t,Date.now());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:[b," today · nothing ran"]})]}),t.length===0?n.jsx(ts,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):n.jsx("div",{className:"blocked-list",children:t.map((S,k)=>{const E=$x(S,S.profile?a[S.profile]:void 0,f),T=v!==null&&S.ts>v;return n.jsx("div",{className:"card blocked-item blocked-card","data-seen":T?"false":"true",children:n.jsxs("div",{className:"id-body",children:[n.jsx(kr,{profileId:S.profile??S.integrationId,area:lt(S.profile??S.integrationId),system:S.integrationId?aa(S.integrationId,void 0):void 0,time:Fx(S.ts,Date.now()),trailing:T?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-${Hi(S)}`,"aria-hidden":"true"}),n.jsx("span",{className:"blocked-title",children:E.title})]}),n.jsx("div",{className:"blocked-sentence",children:E.sentence}),n.jsx("div",{className:"blocked-source",children:E.sourceLine.map((P,I)=>P.dim?n.jsx("span",{className:"mandate-id",children:P.text},I):n.jsx("span",{children:P.text},I))}),n.jsxs("details",{children:[n.jsx("summary",{children:"What you can do"}),n.jsx("div",{className:"blocked-advice",children:E.whatYouCanDo})]})]})},`${S.ts}-${k}`)})})]})}const gS={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function yS(){const[t,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{s(await F.getAutostart())}catch(v){u(v instanceof Error?v.message:"Could not read autostart state")}},[]);h.useEffect(()=>{f()},[f]);const g=h.useCallback(async()=>{if(!(!(t!=null&&t.supported)||a)){o(!0),u(null);try{await F.setAutostart(!t.installed)}catch(v){u(v instanceof Error?v.message:"Failed")}finally{try{s(await F.getAutostart()),u(null)}catch(v){u(v instanceof Error?v.message:"Could not re-read state")}o(!1)}}},[t,a,f]);if(!t)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 p=gS[t.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:t.supported?n.jsxs(n.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",p," — no admin rights needed."]}):t.reason})]}),t.supported&&n.jsx("button",{type:"button",onClick:()=>void g(),disabled:a,"aria-pressed":t.installed,className:t.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Working…":t.installed?"Turn off":"Turn on"})]}),t.supported&&n.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",n.jsx("strong",{children:t.installed?"On — starts from your next login":"Off"})]}),t.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 vS(){const[t,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{const p=await F.getGatewaySettings();s(p.desktopNotifications),u(null)}catch(p){u(p instanceof Error?p.message:"Could not read notification setting")}},[]);h.useEffect(()=>{f()},[f]);const g=h.useCallback(async()=>{if(!(t===null||a)){o(!0),u(null);try{const p=await F.setGatewaySettings({desktopNotifications:!t});s(p.desktopNotifications)}catch(p){u(p instanceof Error?p.message:"Failed to save"),await f()}finally{o(!1)}}},[t,a,f]);return t===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 g(),disabled:a,"aria-pressed":t,className:t?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":t?"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 gh={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function xS(){const[t,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{s(await F.getIdentityDisclosure()),u(null)}catch(y){u(y instanceof Error?y.message:"Could not read the setting")}},[]);h.useEffect(()=>{f()},[f]);const g=h.useCallback(async()=>{if(!(!t||a)){o(!0),u(null);try{s(await F.setIdentityDisclosure(!t.always))}catch(y){u(y instanceof Error?y.message:"Failed to save"),await f()}finally{o(!1)}}},[t,a,f]),p=n.jsx("h3",{className:"card-title",style:{margin:0},children:"Your name on mandates and tickets"});if(!t)return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[p,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=t.verified&&t.name?`${t.name} — ${t.method==="as_vouched"?`${gh.as_vouched} ${t.verifier}`:gh[t.method??""]??t.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:[p,n.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:[t.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 g(),disabled:a,"aria-pressed":t.always,className:t.always?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":t.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 wS={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 jS(){const{version:t,latestVersion:s,updateAvailable:a,installMethod:o}=wc();return t?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:t}),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:[wS[o]??"Update checking is unavailable",o==="dev"&&n.jsx(n.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function ic({title:t}){return n.jsxs("span",{className:"it-locked-badge",title:t,children:[n.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function yh(t){return t===!0}function SS(){const[t,s]=h.useState(null),[a,o]=h.useState(null);h.useEffect(()=>{let f=!1;return F.getAsPairing().then(g=>{f||s(g)}).catch(g=>{f||o(g instanceof Error?g.message:"Could not read Authority Server info")}),()=>{f=!0}},[]);const l=yh(t==null?void 0:t.asUrlLockedByPolicy),u=yh(t==null?void 0:t.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(ic,{})]}),!t&&!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}),t&&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:t.asUrl})]}),t.paired&&t.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:t.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."}),(t.tlsPinFingerprint||t.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(ic,{title:"TLS pinning is set by your IT policy"})," ",t.tlsPinFingerprint?n.jsx("code",{children:t.tlsPinFingerprint}):n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["not yet captured — this URL has no recorded pairing over TLS",t.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]}),n.jsx("br",{}),n.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[t.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 bS(){const{simulation:t,locked:s}=mm();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.',t!==null&&n.jsxs(n.Fragment,{children:[" ","Currently ",n.jsx("strong",{children:t?"ON":"OFF"}),t?" — real systems are not reachable from this gateway.":"."]})]})]}),n.jsx(ic,{})]}),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",t!==null?` (currently ${t?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const kS={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"]}},Ks=["AI Assistant","Authority Server","This computer","Security","Version"],qs={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function NS(){const[t,s]=h.useState(""),[a,o]=h.useState("openrouter"),[l,u]=h.useState("openai-compatible"),[f,g]=h.useState("https://openrouter.ai/api/v1"),[p,v]=h.useState("google/gemma-4-31b-it"),[y,x]=h.useState(""),[j,N]=h.useState(!1),[b,S]=h.useState(!1),[k,E]=h.useState(!1),[T,P]=h.useState(null),[I,U]=h.useState([]),[V,z]=h.useState(!1),[J,Q]=h.useState(null),[ne,ee]=h.useState(""),L=h.useCallback(q=>{s(q),setTimeout(()=>s(""),3e3)},[]),oe=h.useCallback(async(q,G,A)=>{z(!0),Q(null);try{const _=await F.aiModels({provider:q,endpoint:G,...A?{apiKey:A}:{}});_.ok&&_.models.length>0?(U(_.models),Q(`${_.models.length} models available`)):(U([]),Q(_.message||"No models returned — using defaults"))}catch(_){U([]),Q(_ instanceof Error?_.message:"Failed to load models")}finally{z(!1)}},[]),de=h.useCallback(async()=>{try{const q=await F.getCredential("ai-config");if(N(q.configured),q.configured&&q.fields){const G=q.fields.provider||"openai-compatible",A=q.fields.endpoint||"";q.fields.provider&&u(G),q.fields.endpoint&&g(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&&oe(G,A)}}catch{}},[oe]);h.useEffect(()=>{de()},[de]);const Y=q=>{o(q),U([]),Q(null),ee("");const G=kS[q];G&&(u(G.provider),g(G.endpoint),v(""),oe(G.provider,G.endpoint,y||void 0))},je=()=>oe(l,f,y||void 0),xe=async()=>{S(!0);try{await F.setCredential("ai-config",{provider:l,endpoint:f,model:p,...y?{apiKey:y}:{}}),N(!0),L("AI configuration saved!")}catch{L("Failed to save AI config")}finally{S(!1)}},X=async()=>{E(!0),P(null);try{const q=await F.aiTest({provider:l,endpoint:f,model:p,...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."})]}),t&&n.jsx("div",{className:"alert alert-success",children:t}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:qs,children:Ks[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=>Y(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()&&oe(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:je,disabled:V,title:"Re-fetch the model list from the provider",children:V?"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:V?"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,G=q.includes(p),A=q.length>12,_=ne.trim().toLowerCase();let se=_?q.filter(me=>me.toLowerCase().includes(_)):q;return G&&!se.includes(p)&&(se=[p,...se]),n.jsxs(n.Fragment,{children:[A&&n.jsx("input",{className:"form-input",value:ne,onChange:me=>ee(me.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),n.jsxs("select",{className:"form-input",value:G?p:"__unset__",onChange:me=>v(me.target.value==="__unset__"?"":me.target.value),children:[n.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),se.map(me=>n.jsx("option",{value:me,children:me},me)),_&&se.length===0&&n.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",ne,"”"]})]})]})})(),J&&n.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:J})]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[n.jsx("button",{className:"btn btn-primary",onClick:xe,disabled:b||!p.trim(),title:p.trim()?void 0:"Select a model first",children:b?"Saving...":"Save & Encrypt"}),j&&n.jsx("button",{className:"btn btn-ghost",onClick:X,disabled:k,children:k?"Testing...":"Test Connection"})]}),T&&n.jsx("div",{className:`alert ${T.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:T})]}),n.jsx(CS,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:qs,children:Ks[1]}),n.jsx(SS,{}),n.jsx(xS,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:qs,children:Ks[2]}),n.jsx(yS,{}),n.jsx(vS,{}),n.jsx(bS,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:qs,children:Ks[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:qs,children:Ks[4]}),n.jsx(jS,{})]})]})}function CS(){const[t,s]=h.useState(null),[a,o]=h.useState({intent:"",context:""}),[l,u]=h.useState(null),[f,g]=h.useState(null),[p,v]=h.useState(null),[y,x]=h.useState(!1),j=h.useCallback(async()=>{if(!y)try{const S=await F.getAIPrompts();s(S),o({intent:S.intent.current,context:S.context.current}),x(!0)}catch(S){g(S instanceof Error?S.message:"Failed to load prompts")}},[y]),N=async S=>{if(t){u(S),g(null);try{const k=a[S],E=k.trim()===t[S].default.trim()?"":k;await F.setAIPrompt(S,E);const T=await F.getAIPrompts();s(T),o({intent:T.intent.current,context:T.context.current}),v(S),setTimeout(()=>v(null),2e3)}catch(k){g(k instanceof Error?k.message:"Save failed")}finally{u(null)}}},b=async S=>{if(confirm(`Revert ${S} prompt to the built-in default?`)){u(S),g(null);try{await F.setAIPrompt(S,"");const k=await F.getAIPrompts();s(k),o({intent:k.intent.current,context:k.context.current})}catch(k){g(k instanceof Error?k.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…"}),t&&n.jsxs(n.Fragment,{children:[n.jsx(vh,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:t.intent,draft:a.intent,onChange:S=>o(k=>({...k,intent:S})),onSave:()=>N("intent"),onRevert:()=>b("intent"),saving:l==="intent",justSaved:p==="intent"}),n.jsx(vh,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:t.context,draft:a.context,onChange:S=>o(k=>({...k,context:S})),onSave:()=>N("context"),onRevert:()=>b("context"),saving:l==="context",justSaved:p==="context"})]})]})}function vh({kind:t,label:s,description:a,state:o,draft:l,onChange:u,onSave:f,onRevert:g,saving:p,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:p||!y,children:p?"Saving…":"Save"}),o.overridden&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:g,disabled:p,title:"Discard the override and use the built-in default",children:"Revert to default"}),v&&n.jsx("span",{className:"msg-ok",style:{fontSize:"0.78rem"},children:"Saved"}),y&&!p&&!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:t})]})}function ES(t){return t.proposalId?"review":"automatic"}function xh(t,s,a={}){const o=a.status??"pending",l=a.includeAutonomous??!1,u=[];for(const f of t)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 g=ES(f);!l&&g==="automatic"||a.profile&&f.profileId!==a.profile||u.push({kind:"receipt",id:f.id,sortTimestamp:f.timestamp,commitmentMode:g,profileId:f.profileId,receipt:f})}return u.sort((f,g)=>g.sortTimestamp-f.sortTimestamp),typeof a.limit=="number"&&a.limit>0?u.slice(0,a.limit):u}const TS=["https://","http://"];function np(t,s){return t!=null&&t.length?t.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)?[]:TS.some(l=>o.toLowerCase().startsWith(l))?[{label:a.label,href:o,description:a.description}]:[]}):[]}function rp(t,s){const a=t-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}}const IS=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function AS(t,s){return typeof s!="string"?!1:/^data:image\//i.test(s)?!0:IS.test(t)?/^https?:\/\//.test(s):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(s)}function jr(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t,null,2)}catch{return String(t)}}function wh({row:t,which:s}){const a=as(t.profileRef),o=P0(t.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 RS({row:t}){const s=as(t.profileRef),a=(s==null?void 0:s.id)??t.profileRef??"";return n.jsxs(n.Fragment,{children:[(s==null?void 0:s.name)??lt(a),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:a})]})}function PS({row:t,altText:s}){switch(t.kind){case"profile":return n.jsx(RS,{row:t});case"profile-limits":return n.jsx(wh,{row:t,which:"limits"});case"profile-scope":return n.jsx(wh,{row:t,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:jr(t.value)});case"list":return Array.isArray(t.value)?n.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:t.value.map((a,o)=>n.jsx("li",{children:jr(a)},o))}):n.jsx(n.Fragment,{children:jr(t.value)});case"money":return n.jsxs(n.Fragment,{children:[jr(t.value),t.currency?` ${t.currency}`:""]});case"object":return n.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:jr(t.value)});default:return AS(t.key,t.value)?n.jsx("img",{src:t.value,alt:s??t.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):n.jsx(n.Fragment,{children:jr(t.value)})}}function oc({args:t,display:s,heading:a="Details",requestRefArg:o}){const l=R0(t,s);if(l.length===0)return null;const u=typeof t.altText=="string"?t.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:jr(f.value),children:"the message shown under Request"}):n.jsx(PS,{row:f,altText:u})})]},f.key))})]})}function Mc({profileId:t,declared:s}){const{icon:a,name:o}=er(t,s);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"id-rail",children:[n.jsx(Rc,{icon:a,className:"id-rail-icon"}),n.jsx("span",{className:"id-rail-name",children:o})]}),n.jsx("div",{className:"id-sep"})]})}function $S({proposalId:t,systemName:s}){const[a,o]=h.useState(null);if(h.useEffect(()=>{let u=!0;return o(null),F.getProposalOutcome(t).then(f=>{u&&o(f)}).catch(()=>{}),()=>{u=!1}},[t]),!a)return null;const l=Gj(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 Wl=null;function _S(){return Wl||(Wl=F.getEnrichedAuthorizations().then(t=>new Map(t.map(s=>[s.authorizationId,s.bounds]))).catch(()=>new Map)),Wl}function LS(t){const[s,a]=h.useState(void 0);return h.useEffect(()=>{let o=!0;if(t)return _S().then(l=>{o&&a(l.get(t))}),()=>{o=!1}},[t]),s}function zS(t,s){const[a,o]=h.useState(null),[l,u]=h.useState(!1),[f,g]=h.useState(null);return h.useEffect(()=>{let p=!0;return o(null),g(null),u(!0),(async()=>{var v;try{try{const j=await F.getGateContent(t);if((v=j==null?void 0:j.gateContent)!=null&&v.intent){p&&o(j.gateContent.intent);return}}catch{}const y=await F.getAttestationIntent(t);if(!y){p&&g("Intent not available or you are not an authorized approver.");return}const x=await F.decryptIntent({intentCiphertext:y.intentCiphertext,encryptedKey:y.encryptedKey,approverId:s});p&&o(x)}catch(y){p&&g(y instanceof Error?y.message:"Failed to decrypt intent")}finally{p&&u(!1)}})(),()=>{p=!1}},[t,s]),{intent:a,loading:l,error:f}}function jh(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const s={};for(const[a,o]of Object.entries(t))(typeof o=="string"||typeof o=="number")&&(s[a]=o);return s}function FS(t){const s=jh(t.limits),a=jh(t.scope),o=typeof t.intent=="string"?t.intent:"",l={bounds:s,context:a,gateContent:{intent:o}};return(t.mode==="automatic"||t.mode==="review")&&(l.templateMode=t.mode),typeof t.duration_hours=="number"&&t.duration_hours>0&&(l.templateTtl=Math.round(t.duration_hours*3600)),l}function sp(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.map(s=>sp(s)).join(", ");try{return JSON.stringify(t,null,2)}catch{return String(t)}}const MS="setup__create_mandate";function ap({proposal:t,currentUserId:s,proposalLinks:a,toolDisplay:o,manifests:l,onContentState:u,onShownSnapshot:f,nameOf:g}){var pe,ge,ie,be,_e;const[p,v]=h.useState(!1),[y,x]=h.useState(!1),[j,N]=h.useState(null),b=gn(),{group:S,groupId:k,domain:E}=vt(),T=Object.entries(t.executionContext),P=as(t.profileId),I=LS(t.authorizationId),U=F0(t.executionContext,I,P),V=I0(t.tool),{integrationId:z}=Cr(t.tool),J=aa(z,l),{intent:Q,loading:ne,error:ee}=zS(t.authorizationId,s),L=Pc(t),oe=L.toolArgs!==null;h.useEffect(()=>{u==null||u({loading:L.loading,readable:oe})},[L.loading,oe]);const de=Q0(t),Y=L.toolArgs?np(a,L.toolArgs):[],je=async()=>{if(!k){N("No active workspace; cannot open the mandate screen.");return}x(!0),N(null);try{if(!L.toolArgs){N("This content is not readable on this device yet.");return}const Z=L.toolArgs,Ae=typeof Z.profile=="string"?Z.profile:"",Ke=await F.listProfiles(),De=Wm(Ae,Ke);if(!De){N(`Unknown profile "${Ae}".`);return}const Le=await F.getProfile(De.id),ut=FS(Z),Xe=Vm(ut.bounds,Le),Qe=Gm(ut.context,Le);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:De.id,groupId:k,groupName:(S==null?void 0:S.name)??null,domain:E,isPersonal:!!(S!=null&&S.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...ut,bounds:Xe,context:Qe})),sessionStorage.setItem("agentReplacesProposal",t.id),b("/mandates/new/intent")}catch(Z){N(Z instanceof Error?Z.message:"Could not open the mandate screen.")}finally{x(!1)}},[xe,X]=h.useState(null),q=Kj(xe),[G,A]=h.useState(null),[_,se]=h.useState(null);h.useEffect(()=>{if(!G||!_){f==null||f(null);return}const Z=G.status==="ok"?G.readAt:Date.now();f==null||f({readAt:Z,preview:G,requestContext:_,...L.toolArgs?{toolArgs:L.toolArgs}:{},sealed:L.sealed})},[G,_,L.toolArgs,L.sealed,f]);const{toolName:me}=Cr(t.tool),O=(_e=(be=(ie=(ge=(pe=l==null?void 0:l.find(Z=>Z.id===z))==null?void 0:pe.toolGating)==null?void 0:ge.overrides)==null?void 0:ie[me])==null?void 0:be.sourceFromArg)==null?void 0:_e.arg,te=L.toolArgs?n.jsx(oc,{args:L.toolArgs,display:o,heading:"",requestRefArg:O}):null,le=L.toolArgs?n.jsxs(n.Fragment,{children:[n.jsx(oc,{args:L.toolArgs,display:o,heading:"",requestRefArg:O}),T.length>0&&n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:T.map(([Z,Ae],Ke)=>{const{label:De,hint:Le}=ym(Z,P);return n.jsxs("span",{children:[Ke>0&&" · ",n.jsxs("span",{title:Le,children:[De,"=",sp(Ae)]})]},Z)})})]}):null;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"approval-summary","data-testid":"approval-summary",children:Tm(t.tool,L.toolArgs,l)}),n.jsx("div",{className:"approval-headline",children:V}),L.sealed&&L.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."})]}),L.sealed&&L.loading&&n.jsx("div",{className:"preview-box","data-testid":"proposal-decrypting",style:{marginBottom:"0.5rem"},children:"Decrypting…"}),q&&oe&&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",L.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"})]}),te]}),de.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: ",de.map(Z=>(g==null?void 0:g(Z))??Z).join(", ")," — shared automatically once they sign in on a device."]}),oe&&n.jsx(Jj,{proposalId:t.id,systemName:J,toolArgs:L.toolArgs,sealed:L.sealed,onTone:X,onData:A}),oe&&n.jsx(sS,{proposalId:t.id,onData:se}),oe&&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"]}),L.sealed&&n.jsx("span",{children:"Decrypted on this device — suveren.ai stores only an unreadable copy and its fingerprint."})]})]}),U.length>0&&n.jsxs("div",{className:"limit-checks",children:[n.jsx("h4",{children:"Within your limits"}),n.jsx("ul",{className:"limit-check-list",children:U.map(Z=>n.jsxs("li",{className:Z.ok?"ok":"bad",children:[n.jsx("span",{className:"limit-check-icon",children:Z.ok?"✓":"✗"}),n.jsxs("span",{children:[Z.label," ",Z.valueText," — your limit ",Z.limitText]})]},Z.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)??lt(t.profileId)})})]}),n.jsxs("dl",{children:[n.jsx("dt",{children:"Intent"}),n.jsx("dd",{children:ee?n.jsx("p",{className:"msg-error",style:{fontSize:"0.8rem",margin:0},children:ee}):Q!==null?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:`intent-text${p?"":" intent-clamped"}`,children:Q}),n.jsx("button",{className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>v(!p),children:p?"Show less":"Show full intent"})]}):ne?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."})})]})]}),oe&&Y.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:Y.map(Z=>n.jsxs("a",{href:Z.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:Z.description??Z.href,children:[Z.label," ↗"]},Z.label))}),!q&&oe&&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:le})]}),oe&&t.tool===MS&&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:je,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 ip({note:t,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:Gw.map(f=>n.jsx("button",{type:"button",className:`filter-chip${Bm(t,f)?" selected":""}`,onClick:()=>s(qw(t,f)),disabled:l,children:f},f))}),n.jsx("textarea",{"data-testid":"change-note",className:"form-input",value:t,maxLength:_i,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:[t.length," / ",_i]}),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 OS={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired",refused:"Refused"},BS={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired",refused:"status-revoked"},Sh={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced",REFUSED:"status-revoked"};function Hl(t){const s=Date.now()-t*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(t*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function DS(t){return t.split("__").pop()??t}function US(t){const s=t.toLowerCase();return s.includes("delete")||s.includes("refund")||s.includes("cancel")||s.includes("revoke")}function op(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.map(s=>op(s)).join(", ");try{return JSON.stringify(t,null,2)}catch{return String(t)}}function bh({item:t,onApprove:s,onReject:a,onChangeNeeded:o,resolving:l,proposalLinks:u,toolDisplay:f,manifests:g,currentUserId:p,inRow:v=!1}){const y=t.kind==="proposal",x=y?t.proposal.status:"executed",j=y?t.proposal.tool:t.receipt.action,N=DS(j),b=US(j),{integrationId:S}=Cr(j),k=aa(S,g),[E,T]=h.useState(!1),[P,I]=h.useState(""),[U,V]=h.useState(""),z=h.useRef(null),J=async()=>{const O=z.current;if(!(!O||!y))try{const{shownHash:te}=await F.saveShownSnapshot(t.proposal.id,O);return te}catch{return}},Q=async()=>{const O=Fc(P);if(!O.valid){V(O.error);return}V("");const te=await J();o==null||o(t.id,O.trimmed,te)},ne=y&&x==="rejected"?Xw(t.proposal,p??""):null,ee=y&&x==="refused"?Zw(t.proposal):null,L=X0(y?t.proposal.rejectedBy??t.proposal.approverRejectedBy??null:null),oe=as(t.profileId),de=Pc(y?t.proposal:{toolArgs:void 0,content:void 0}),Y=y?de.toolArgs:null,je=y?t.proposal.executionContext:t.receipt.executionContext,xe=y?null:t.receipt.cumulativeState,[X,q]=h.useState(!0),[G,A]=h.useState(!1),_=y&&de.toolArgs?np(u,de.toolArgs):[],se=Object.entries(je??{}),me=er(t.profileId).testSetup||Gi(j);return n.jsxs("div",{className:v?"card card-in-row":"card id-card",children:[!v&&n.jsx(Mc,{profileId:t.profileId}),n.jsxs("div",{className:"id-body",children:[v?me?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:N}),me&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),t.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 O=rp(t.proposal.expiresAt,Date.now());return n.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",fontWeight:O.urgent?600:400,whiteSpace:"nowrap"},children:O.label})})(),n.jsx("span",{"data-testid":ne||ee?"outcome-kind":void 0,className:`status-badge ${ne?Sh[ne.kind]:ee?Sh.REFUSED:BS[x]}`,children:ne?ne.kind:ee?ee.kind:OS[x]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Hl(t.sortTimestamp)})]})]}),y&&t.proposal.status==="executed"&&n.jsx($S,{proposalId:t.proposal.id,systemName:k}),ne&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By ",ne.who,", ",Hl(ne.at)]}),(L??ne.note)&&n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[ne.kind==="CHANGE NEEDED"?"Change: ":"Note: ",L??ne.note]})]}),ee&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By the Authority Server, ",Hl(ee.at)]}),n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:["Reason: ",ee.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(Y==null?void 0:Y._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:Y._imagePreview,alt:typeof(Y==null?void 0:Y.altText)=="string"?Y.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),y&&x==="pending"?n.jsx(ap,{proposal:t.proposal,currentUserId:p??"",proposalLinks:u,toolDisplay:f,manifests:g,onContentState:({loading:O,readable:te})=>{A(O),q(te)},onShownSnapshot:O=>{z.current=O}}):n.jsxs(n.Fragment,{children:[_.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:_.map(O=>n.jsxs("a",{href:O.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:O.description??O.href,children:[O.label," ↗"]},O.label))}),y?n.jsxs(n.Fragment,{children:[Y&&n.jsx(oc,{args:Y,display:f}),se.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:se.map(([O,te])=>`${O}=${op(te)}`).join(" · ")})]}):n.jsxs(n.Fragment,{children:[n.jsx(Qm,{receipt:t.receipt,profile:oe}),t.receipt.proposalId&&n.jsx(tp,{proposalId:t.receipt.proposalId,tool:t.receipt.action,manifests:g})]})]}),xe&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",xe.daily.count," action",xe.daily.count===1?"":"s",xe.daily.amount>0?`, ${xe.daily.amount}`:""," · ","this month: ",xe.monthly.count,xe.monthly.amount>0?`, ${xe.monthly.amount}`:""]}),y&&x==="pending"&&Nm({loading:G,readable:X})&&(E?n.jsx(ip,{note:P,onNoteChange:I,onSend:Q,onCancel:()=>{T(!1),I(""),V("")},sending:!!l,error:U}):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(t.id,await J()),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(t.id,await J()),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",": ",t.id]})]})]})}function WS(t,s=[]){const a=new Map;for(const o of t){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 HS(t,s){return t.map(a=>s.get(a)??a)}function lp(t){var N;const{groupId:s}=vt(),a=as(t.profileId),[o,l]=h.useState(null),[u,f]=h.useState(new Map),[g,p]=h.useState(!0);h.useEffect(()=>{let b=!0;if(!s){p(!1);return}return p(!0),Promise.all([F.getTeamProfileConfig(s,t.profileId).catch(()=>null),F.getGroupById(s).catch(()=>null),F.listUsers().catch(()=>[])]).then(([S,k,E])=>{b&&(l(S),f(WS(E,(k==null?void 0:k.members)??[])))}).finally(()=>{b&&p(!1)}),()=>{b=!1}},[s,t.profileId]);const v=Xv(o??{}),y=HS(t.pendingApprovers??[],u),x=b=>u.get(b)??b,j=o&&((N=a==null?void 0:a.boundsSchema)!=null&&N.fields)?pw(t.executionContext,o,a.boundsSchema.fields):null;return{loading:g,profileConfig:o,requiredApprovals:v,approverNames:y,nameOf:x,aboveCapReason:j}}function cp(t,s){return!!t.createdBy&&!!s&&t.createdBy===s}function up(t){return(t.pendingApprovers??[]).filter(s=>s!==t.createdBy)}function VS(t){const s=Date.now()-t*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 GS({proposal:t,currentUserId:s,onAction:a,onMessage:o,proposalLinks:l,toolDisplay:u,manifests:f,inRow:g=!1}){const[p,v]=h.useState(!1),[y,x]=h.useState(!1),[j,N]=h.useState(!1),[b,S]=h.useState(""),[k,E]=h.useState(""),[T,P]=h.useState(!1),[I,U]=h.useState(!1),[V,z]=h.useState(!0),J=h.useRef(null),Q=async()=>{const _=J.current;if(_)try{const{shownHash:se}=await F.saveShownSnapshot(t.id,_);return se}catch{return}},ne=er(t.profileId).testSetup||Gi(t.tool),ee=up(t),L=t.approvedBy??{},oe=Object.keys(L).length,de=s in L,Y=lp(t),je=cp(t,s),xe=_=>{const se=_ instanceof Error?_.message:"Approval failed";return se.includes("APPROVER_IS_PROPOSER")?"You can't approve your own action. Ask another approver.":se.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.":se},X=async()=>{if(Ec()){o(Tc);return}v(!0),o("");try{const _=await Qs(t),se=await Q(),me=await F.approveProposal(t.id,_,se);try{const pe=await F.getAttestationIntent(t.authorizationId);if(pe){const ge=await F.decryptIntent({intentCiphertext:pe.intentCiphertext,encryptedKey:pe.encryptedKey,approverId:s});await F.storeApprovedIntent(t.authorizationId,ge)}}catch{}const{requiredApprovals:O,approvedCount:te}=me,le=O!==void 0&&te!==void 0?O-te:void 0;o(le===void 0?"Approved.":le>0?`Approved. ${le} more approval${le===1?"":"s"} still needed.`:"Approved — the required number of approvals is met; the action is ready to execute."),a()}catch(_){o(xe(_))}finally{v(!1)}},q=async()=>{x(!0),o("");try{const _=await Qs(t),se=await Q();await F.rejectProposal(t.id,Dm(),_,se),o("Action rejected."),a()}catch(_){o(_ instanceof Error?_.message:"Rejection failed")}finally{x(!1)}},G=async()=>{const _=Fc(b);if(!_.valid){E(_.error);return}E(""),P(!0),o("");try{const{noteEncrypted:se}=await F.encryptProposalNote(_.trimmed,Cm(t,s)),me=await Qs(t),O=await Q();await F.rejectProposal(t.id,{outcome:"change_needed",noteEncrypted:se},me,O),o("Sent back for a change."),a()}catch(se){o(se instanceof Error?se.message:"Failed to send back")}finally{P(!1)}},A=p||y||T;return n.jsxs("div",{className:g?"card card-in-row":"card id-card",children:[!g&&n.jsx(Mc,{profileId:t.profileId}),n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:g?"none":"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[ne&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),n.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const _=rp(t.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:VS(t.createdAt)})]})]}),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:"," ",ee.map((_,se)=>n.jsxs("span",{className:`who${_ in L?" done":""}`,style:{marginLeft:se===0?"0.25rem":"0.5rem",fontWeight:_ in L?600:void 0},children:[_ in L?"✓ ":"",Y.nameOf(_),_===s?" (you)":"",se<ee.length-1?",":""]},_)),Y.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",oe," 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),")."," ",t.createdBy?`Requested by ${Y.nameOf(t.createdBy)}.`:""]})]}),n.jsx(ap,{proposal:t,currentUserId:s,proposalLinks:l,toolDisplay:u,manifests:f,nameOf:Y.nameOf,onContentState:({loading:_,readable:se})=>{U(_),z(se)},onShownSnapshot:_=>{J.current=_}}),!de&&Nm({loading:I,readable:V})&&(j?n.jsx(ip,{note:b,onNoteChange:S,onSend:G,onCancel:()=>{N(!1),S(""),E("")},sending:T,error:k}):n.jsxs(n.Fragment,{children:[!je&&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:[je?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:X,disabled:A,children:p?"Approving...":"Approve"}),n.jsxs("button",{"data-testid":"btn-change-needed",className:"btn btn-outline-strong",onClick:()=>N(!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"]})]})]})),de&&n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:["You approved this action.",Y.requiredApprovals>1&&oe<Y.requiredApprovals?` Waiting on ${Y.requiredApprovals-oe} more approval(s).`:""]}),!g&&n.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",t.id]})]})]})}function kh({proposal:t,manifests:s,titles:a,open:o,onToggle:l,who:u,children:f}){const g=Date.now(),p=jm(t.expiresAt,g),v=h.useRef(null);return h.useEffect(()=>{var y;o&&((y=v.current)==null||y.scrollIntoView({block:"nearest"}))},[o]),n.jsxs("div",{ref:v,className:`appr-item${o?" is-open":""}`,"data-testid":"approval-row","data-proposal-id":t.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(kr,{profileId:t.profileId,area:ia(t.authorizationId,t.profileId,a),system:oa(t.tool,s),time:wm(t.createdAt,g)}),n.jsx("div",{className:"appr-item-sum","data-testid":"approval-row-summary",children:n.jsx(Im,{proposal:t,manifests:s})}),p&&n.jsx("div",{className:"obj-due",children:p}),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 KS(){const{domain:t,user:s}=vt(),a=(s==null?void 0:s.id)??"",[o,l]=h.useState("awaiting-me"),[u,f]=h.useState([]),[g,p]=h.useState([]),[v,y]=h.useState({}),[x,j]=h.useState(!0),[N,b]=h.useState(""),S=h.useCallback(async()=>{try{const H=await F.getProposalsForApprover();f(H)}catch{}finally{j(!1)}},[]);Be("proposal-added",S),Be("proposal-approved",S),Be("proposal-rejected",S),Be("proposal-resolved",S),Lt(S,3e4);const[k,E]=h.useState([]),T=h.useCallback(async()=>{try{const H=await F.getMyProposals(t);E(H)}catch{}},[t]);Be("proposal-added",T),Be("proposal-approved",T),Be("proposal-rejected",T),Be("proposal-resolved",T),Be("execution-failed",T),Lt(T,3e4,t);const P=h.useMemo(()=>k.filter(H=>{var K;return H.status==="pending"&&(((K=H.pendingApprovers)==null?void 0:K.length)??0)===0}),[k]),I=h.useMemo(()=>xh(P,[],{status:"pending"}),[P]),[U,V]=h.useState([]),z=h.useCallback(async()=>{if(a)try{const K=(await F.getMyProposals(t)).filter(ye=>ye.status==="pending"&&ye.pendingApprovers&&ye.pendingApprovers.includes(a)&&ye.approvedBy&&a in ye.approvedBy);V(K)}catch{}},[a,t]);Be("proposal-approved",z),Be("proposal-rejected",z),Lt(z,3e4,`${a}:${t}`);const[J,Q]=h.useState([]),ne=h.useCallback(async()=>{try{const H=await F.getProposalsCreatedByMe();if(H!==null){Q(H);return}Q(await F.getMyPendingProposals())}catch{}},[]);Be("proposal-added",ne),Be("proposal-approved",ne),Be("proposal-rejected",ne),Lt(ne,3e4),h.useEffect(()=>{F.getIntegrationManifests().then(H=>p(H.manifests??[])).catch(()=>{}),F.getToolDisplay().then(y).catch(()=>{})},[]);const ee=H=>{var K;return(K=g.find(ye=>ye.id===H.split("__")[0]))==null?void 0:K.proposalLinks};h.useEffect(()=>{S(),T(),z(),ne()},[]);const[L,oe]=h.useState([]),[de,Y]=h.useState([]),[je,xe]=h.useState(!0),[X,q]=h.useState(null),[G,A]=h.useState(""),[_,se]=h.useState("pending"),[me,O]=h.useState(null),[te,le]=h.useState(!1),pe=h.useCallback(async()=>{try{const{proposals:H,receipts:K}=await F.getThread({domain:t,status:_,sinceDays:7});oe(H),Y(K)}catch{}finally{xe(!1)}},[t,_]);Lt(pe,3e4,`${t}:${_}`);const ge=async(H,K,ye,Ve)=>{if(K==="commit"&&Ec()){A(Tc);return}q(H),A("");try{const We=L.find(ve=>ve.id===H)??k.find(ve=>ve.id===H),st=Qv(We,t),zt=We?await Qs(We):void 0;let Ft=ye??{};if((ye==null?void 0:ye.outcome)==="change_needed"&&ye.note){const ve=We?Cm(We,a):[a],{noteEncrypted:Ie}=await F.encryptProposalNote(ye.note,ve);Ft={outcome:"change_needed",noteEncrypted:Ie}}const B=await F.resolveProposal(H,K,st,{...Ft,contentHash:zt,shownHash:Ve});A(K==="commit"?`Action approved. Status: ${B.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)}},ie=(H,K)=>ge(H,"commit",void 0,K),be=(H,K)=>ge(H,"reject",Dm(),K),_e=(H,K,ye)=>ge(H,"reject",Yw(K),ye),Z=h.useMemo(()=>{const H=new Set;for(const K of L)H.add(K.profileId);for(const K of de)H.add(K.profileId);return Array.from(H).sort()},[L,de]),Ae=h.useMemo(()=>xh(L,de,{status:_,profile:me??void 0,includeAutonomous:te}),[L,de,_,me,te]),Ke=h.useCallback(()=>{S(),z()},[S,z]),De=h.useMemo(()=>{const H=new Set,K=[];for(const ye of[...U,...J])H.has(ye.id)||(H.add(ye.id),K.push(ye));return K.sort((ye,Ve)=>Ve.createdAt-ye.createdAt)},[U,J]),Le=u.length+I.length,[ut]=sa(),[Xe,Qe]=h.useState(()=>ut.get("open")),Je=h.useMemo(()=>[...I.map(H=>H.kind==="proposal"?H.proposal.id:H.id),...u.map(H=>H.id)],[I,u]),wt=h.useRef([]),pt=h.useRef(null);h.useEffect(()=>{const H=wt.current;if(wt.current=Je,Je.length===1&&Xe===null&&pt.current!==Je[0]){pt.current=Je[0],Qe(Je[0]);return}if(Xe&&!Je.includes(Xe)&&H.includes(Xe)){const K=H.indexOf(Xe),ye=H.slice(K+1).find(Ve=>Je.includes(Ve))??Je[0]??null;Qe(ye)}},[Je,Xe]);const Fe=H=>Qe(K=>K===H?null:H),[he,$e]=h.useState({});h.useEffect(()=>{F.getMyAttestations().then(H=>{const K={};for(const ye of H)ye.authorization_id&&ye.title&&(K[ye.authorization_id]=ye.title);$e(K)}).catch(()=>{})},[]);const Me=De.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(fm,{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 ",Le>0&&n.jsx("span",{className:"pill-count",style:{marginLeft:"0.4rem"},children:Le})]}),n.jsxs("button",{className:`nav-tab${o==="awaiting-others"?" active":""}`,onClick:()=>l("awaiting-others"),children:["Awaiting others ",Me>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:Me})]}),n.jsx("button",{className:`nav-tab${o==="all"?" active":""}`,onClick:()=>{l("all"),pe()},children:"All"})]}),o==="awaiting-me"&&n.jsx(n.Fragment,{children:x&&Le===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Le===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:[(N||G)&&n.jsx("div",{className:"alert alert-success",children:N||G}),I.map(H=>{const K=n.jsx(bh,{proposalLinks:H.kind==="proposal"?ee(H.proposal.tool):void 0,toolDisplay:H.kind==="proposal"?v[H.proposal.tool]:void 0,manifests:g,currentUserId:a,item:H,onApprove:ie,onReject:be,onChangeNeeded:_e,resolving:X===H.id,inRow:H.kind==="proposal"},H.id);if(H.kind!=="proposal")return K;const ye=H.proposal.id;return n.jsx(kh,{proposal:H.proposal,manifests:g,titles:he,open:Xe===ye,onToggle:()=>Fe(ye),children:K},ye)}),u.map(H=>n.jsx(kh,{proposal:H,manifests:g,titles:he,open:Xe===H.id,onToggle:()=>Fe(H.id),who:"Team approval — other people are involved",children:n.jsx(GS,{inRow:!0,proposal:H,currentUserId:a,onAction:Ke,onMessage:b,proposalLinks:ee(H.tool),toolDisplay:v[H.tool],manifests:g},H.id)},H.id))]})}),o==="awaiting-others"&&n.jsx(n.Fragment,{children:De.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:De.map(H=>n.jsx(YS,{proposal:H,currentUserId:a,onCancel:async()=>{try{await F.rejectProposal(H.id,{reason:"cancelled by creator"}),z(),T()}catch(K){alert(K instanceof Error?K.message:"Cancel failed")}},onWithdraw:async()=>{const K=await Qs(H);await F.withdrawProposal(H.id,void 0,K),ne(),z()}},H.id))})}),o==="all"&&n.jsxs(n.Fragment,{children:[G&&n.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:G}),n.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[n.jsx("button",{className:`filter-chip ${_==="pending"?"selected":""}`,onClick:()=>se("pending"),children:"Pending"}),n.jsx("button",{className:`filter-chip ${_==="all"?"selected":""}`,onClick:()=>se("all"),children:"All"}),Z.length>0&&n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),Z.map(H=>n.jsx("button",{className:`filter-chip ${me===H?"selected":""}`,onClick:()=>O(me===H?null:H),children:lt(H)},H)),_==="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 ${te?"selected":""}`,onClick:()=>le(!te),title:"Include actions executed without human review (automatic commitment mode)",children:[te?"✓ ":"","Autonomous actions"]})]})]}),je&&Ae.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Ae.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:Ae.map(H=>n.jsx(bh,{proposalLinks:H.kind==="proposal"?ee(H.proposal.tool):void 0,toolDisplay:H.kind==="proposal"?v[H.proposal.tool]:void 0,manifests:g,currentUserId:a,item:H,onApprove:ie,onReject:be,onChangeNeeded:_e,resolving:X===H.id},H.id))})]})]})}function qS(t){const s=Date.now()-t*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 YS({proposal:t,currentUserId:s,onCancel:a,onWithdraw:o}){const[l,u]=h.useState(!1),[f,g]=h.useState(!1),[p,v]=h.useState(""),y=lp(t),x=cp(t,s),j=up(t),N=t.approvedBy??{},b=Object.keys(N).length,S=j.length>0,k=async()=>{u(!0);try{await a()}finally{u(!1)}},E=async()=>{g(!0),v("");try{await o()}catch(P){v(P instanceof Error?P.message:"Withdraw failed")}finally{g(!1)}},T=er(t.profileId).testSetup||Gi(t.tool);return n.jsxs("div",{className:"card id-card",children:[n.jsx(Mc,{profileId:t.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:t.tool.split("__").pop()??t.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:qS(t.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 N?" done":""}`,style:{marginLeft:I===0?"0.25rem":"0.5rem",fontWeight:P in N?600:void 0},children:[P in N?"✓ ":"",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),")."," ",t.createdBy?`Requested by ${y.nameOf(t.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"}),p&&n.jsx("p",{className:"msg-error",style:{fontSize:"0.78rem",margin:0},children:p})]}):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:k,disabled:l,children:l?"Cancelling...":"Cancel"})})]})]})}const JS=`# 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 QS(){const[t,s]=h.useState(""),[a,o]=h.useState(""),[l,u]=h.useState(!0),[f,g]=h.useState(!1),[p,v]=h.useState(null),[y,x]=h.useState(!1),j=t!==a,N=new Blob([t]).size,b=16*1024;h.useEffect(()=>{if(!j)return;const T=I=>{I.preventDefault(),I.returnValue=""},P=I=>{var z,J;if(I.defaultPrevented||I.button!==0||I.metaKey||I.ctrlKey||I.shiftKey||I.altKey)return;const U=(J=(z=I.target)==null?void 0:z.closest)==null?void 0:J.call(z,"a");if(!U||!U.href)return;let V;try{V=new URL(U.href)}catch{return}V.origin===window.location.origin&&V.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 F.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()=>{g(!0),v(null);try{await F.saveAgentContext(t),o(t),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{g(!1)}},k=()=>{s(a),v(null)},E=()=>{t.trim()&&!confirm("Replace current context with the starter template?")||s(JS)};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."}),!t.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"})]}),p&&n.jsx("div",{className:p.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:p.text}),n.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[n.jsx("div",{className:"card intent-pane chat",children:n.jsx(Pi,{target:{kind:"context"},currentText:t,onApply:T=>{t.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:N>b?"msg-error":void 0,style:{fontSize:"0.75rem",color:N>b?void 0:"var(--text-muted)"},children:[N.toLocaleString()," / ",b.toLocaleString()," bytes"]})]}),n.jsx("textarea",{className:"form-textarea",value:t,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:k,disabled:f||!j,children:"Revert"}),n.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:S,disabled:f||!j||N>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($m,{open:y,onClose:()=>x(!1),ariaLabel:"Brief assistant",children:n.jsx(Pi,{target:{kind:"context"},currentText:t,onApply:T=>{t.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 XS(t){const s=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(t);return s&&s[1].replace(/<[^>]+>/g,"").trim()||"Report"}function ZS(t){const s=t.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 eb(t){return new Date(t*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function tb(t,s){const a=s.emailExportError?"cases unknown":`${s.coveredCases.length}/${s.loadedCases.length} cases`;return`${t.signaturesValid>0?`${t.signaturesValid} ✓ tickets`:`${t.signaturesValid} tickets`} · ${a} · ${s.ticketsReferenced.length}/${s.ticketsInPeriod.length} tickets covered`}function nb(t){return t.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:t.emailExportError}:{kind:"ok",text:`${t.coveredCases.length} of ${t.loadedCases.length}`}}function rb(t){return t.periodStart!==null?null:t.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:t.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function Nh(t,s="none in this report"){return t>0?{kind:"ok",text:`${t} ✓`}:{kind:"neutral",text:s}}function sb(t){return/Labels?$/.test(t)||t==="limits"||t==="fields"}function ab(t,s){const a=s[t];return a==null||a===""||sb(t)?null:typeof a=="object"?JSON.stringify(a):String(a)}function ib(t){const s=[];return t.missingCases.length>0&&s.push(`cases ${t.missingCases.join(", ")}`),t.ticketsNotReferenced.length>0&&s.push(`${t.ticketsNotReferenced.length} ticket${t.ticketsNotReferenced.length===1?"":"s"}`),s.length>0?`Not in the report: ${s.join(" · ")}`:null}function ob(t,s){var a;if(s)return s;if(!t)return null;if(t.kind==="sv-ticket")return t.attrs.ref||null;if(t.kind==="sv-approval"||t.kind==="sv-mandate")return t.attrs.ticket||null;if(t.kind==="sv-case"){const o=(a=t.data)==null?void 0:a.goal;return(o==null?void 0:o.ticketId)??null}return null}const lb="allow-popups allow-popups-to-escape-sandbox",cb="AI analysis — not verified",ub="Green = verified by the gateway — raw signed fields only",db="Grey dashed = the AI's own analysis, not verified",fb="= translation by the AI, not verified",hb="Übersetzung anzeigen / show translation";function Ch(t){var a;const s=((a=t.formatNotice)==null?void 0:a.blocksNotShown)??0;return s<=0?null:`This report was written in an older format — ${s} ${s===1?"block was":"blocks were"} not shown. Ask the AI to write it again.`}function mb(t,s){return s&&t.renderedHtmlGloss?t.renderedHtmlGloss:t.renderedHtml}function pb(t,s,a){const o=new URLSearchParams(t);return o.set("element",s),a?o.set("ticket",a):o.delete("ticket"),o}const gb={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function yb(t){return t.filter(s=>s.status==="unverifiable").map(s=>({elementId:s.id,text:`${gb[s.kind]??"Element"}: ${s.reason??"could not be checked"}`}))}function vb(t){if(!t||t.kind!=="sv-case"||!t.data)return[];const s=Array.isArray(t.data.steps)?t.data.steps:[],a=t.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 xb(t){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>${t}</body></html>`}const Oc={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},wb={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function jb(t,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"]}[t].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 Sb(t,s){const a=wb[t].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:{...Oc,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 Vl(t,s){return s?n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:t}),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:Oc,children:jb(t,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))}),Sb(t,s.data??{})]})]}):null}function bb({report:t,elementId:s,ticketParam:a,onClose:o,onSelectTicket:l}){var x;const u=t.elements.find(j=>j.id===s),f=ob(u,a),g=f?t.ticketDetails[f]:void 0,p=vb(u),v=(x=t.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 N=j.getBoundingClientRect().top;(N<0||N>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}),p.length>0&&n.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:p.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:Oc,children:Object.keys(u.data??{}).map(j=>{const N=ab(j,u.data??{});return N===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:N})]},j)})})),g&&n.jsxs(n.Fragment,{children:[Vl("Ticket",g.ticket),Vl("Mandate",g.mandate),Vl("Approval",g.approval)]}),f&&!g&&n.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",f,"."]})]})}async function kb(t){const{html:s,filename:a}=await t.exportReport();t.download(s,a),await t.refresh()}function Eh({detail:t}){return t?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:t})]}):null}function Nb({report:t,open:s,selectedId:a,onOpenElement:o,detail:l}){const{proof:u,coverage:f}=t,g=yb(t.elements),p=ib(f),v=nb(f),y=rb(f),x=Nh(u.signaturesValid),j=Nh(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})]}),g.map(N=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${a===N.elementId?" reports-row-selected":""}`,onClick:()=>o(N.elementId),children:[n.jsx("span",{children:N.text}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},N.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(Eh,{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(Eh,{detail:y.detail})]}),p&&n.jsx("p",{className:"reports-missing",children:p})]}),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(N=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button${a===N.elementId?" reports-row-selected":""}`,onClick:()=>o(N.elementId),title:"Show details",children:[n.jsx("span",{children:N.summary}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},N.elementId))]})]})}function Cb(){const[t,s]=h.useState(null),[a,o]=h.useState(!0),[l,u]=h.useState(null),[f,g]=h.useState(!1),[p,v]=h.useState(!1),[y,x]=h.useState(null),[j,N]=h.useState(!1),[b,S]=h.useState(!1),[k,E]=sa(),T=h.useCallback(()=>F.getReport().then(({report:L})=>s(L)).catch(L=>u(L instanceof Error?L.message:String(L))),[]),P=h.useCallback(()=>{o(!0),u(null),T().finally(()=>o(!1))},[T]);h.useEffect(()=>{P()},[P]);const I=h.useCallback(()=>{g(!0),F.recheckReport().then(({report:L})=>s(L)).catch(L=>u(L instanceof Error?L.message:String(L))).finally(()=>g(!1))},[]),U=h.useCallback(async()=>{v(!0),x(null);try{await kb({exportReport:()=>F.exportReportWithProof(),download:(L,oe)=>{const de=URL.createObjectURL(new Blob([L],{type:"text/html"})),Y=document.createElement("a");Y.href=de,Y.download=oe,Y.click(),URL.revokeObjectURL(de)},refresh:T})}catch(L){x(L instanceof Error?L.message:String(L))}finally{v(!1)}},[T]),V=k.get("element"),z=k.get("ticket"),J=h.useCallback((L,oe)=>{E(pb(k,L,oe))},[k,E]),Q=h.useCallback(()=>{const L=new URLSearchParams(k);L.delete("element"),L.delete("ticket"),E(L,{replace:!0})},[k,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(ts,{icon:"⚠",title:"Report unavailable",text:l})]});if(!t)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(ts,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const ne=XS(t.renderedHtml),ee=ZS(t.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:ne}),n.jsxs("p",{className:"page-subtitle",children:[ee?`written by the AI under mandate ${ee} · `:"","checked ",eb(t.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:U,disabled:p,children:p?"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:tb(t.proof,t.coverage)}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>N(L=>!L),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"}),ub]}),n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-a"}),db," (“",cb,"”)"]}),t.renderedHtmlGloss&&n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",fb]})]}),Ch(t)&&n.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:Ch(t)}),t.renderedHtmlGloss&&n.jsxs("label",{className:"reports-gloss-switch",children:[n.jsx("input",{type:"checkbox",role:"switch",checked:b,onChange:L=>S(L.target.checked)}),n.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:n.jsx("span",{className:"reports-gloss-thumb"})}),n.jsx("span",{children:hb})]}),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."}),n.jsx("iframe",{title:"Report",sandbox:lb,srcDoc:xb(mb(t,b)),className:"reports-iframe"})]}),n.jsx(Nb,{report:t,open:j||!!V,selectedId:V,onOpenElement:L=>J(L),detail:V?n.jsx(bb,{report:t,elementId:V,ticketParam:z,onClose:Q,onSelectTicket:L=>J(V,L)}):void 0})]})]})})}function Xr({to:t}){const{search:s,hash:a}=Vt();return n.jsx(Pn,{to:`${t}${s}${a}`,replace:!0})}function Eb({children:t}){const{user:s,mode:a,domain:o}=vt();return s?a==="team"&&!o?n.jsx(Pn,{to:"/onboarding",replace:!0}):n.jsx(n.Fragment,{children:t}):n.jsx(Pn,{to:"/login",replace:!0})}function Tb(){const{user:t,handleSessionLocked:s,refreshGroups:a}=vt();return Be("session-locked",o=>{const l=o==null?void 0:o.message;s(l)}),Be("team-membership-changed",()=>{a()}),n.jsxs(mv,{children:[n.jsx(rt,{path:"/login",element:t?n.jsx(Pn,{to:"/",replace:!0}):n.jsx(f0,{})}),n.jsx(rt,{path:"/onboarding",element:t?n.jsx(v0,{}):n.jsx(Pn,{to:"/login",replace:!0})}),n.jsxs(rt,{element:n.jsx(Eb,{children:n.jsx(d0,{})}),children:[n.jsx(rt,{path:"/",element:n.jsx(uw,{})}),n.jsx(rt,{path:"/mandates",element:n.jsx(Nj,{})}),n.jsx(rt,{path:"/mandates/new/intent",element:n.jsx(zw,{})}),n.jsx(rt,{path:"/mandates/new/sign",element:n.jsx(ej,{})}),n.jsx(rt,{path:"/integrations",element:n.jsx(oj,{})}),n.jsx(rt,{path:"/team",element:n.jsx(lj,{})}),n.jsx(rt,{path:"/tickets",element:n.jsx(mS,{})}),n.jsx(rt,{path:"/blocked",element:n.jsx(pS,{})}),n.jsx(rt,{path:"/approvals",element:n.jsx(KS,{})}),n.jsx(rt,{path:"/reports",element:n.jsx(Cb,{})}),n.jsx(rt,{path:"/agent/new",element:n.jsx(Pn,{to:"/mandates?new=1",replace:!0})}),n.jsx(rt,{path:"/agent/gate",element:n.jsx(Xr,{to:"/mandates/new/intent"})}),n.jsx(rt,{path:"/agent/review",element:n.jsx(Xr,{to:"/mandates/new/sign"})}),n.jsx(rt,{path:"/authorizations",element:n.jsx(Xr,{to:"/mandates"})}),n.jsx(rt,{path:"/groups",element:n.jsx(Xr,{to:"/team"})}),n.jsx(rt,{path:"/audit",element:n.jsx(Xr,{to:"/tickets"})}),n.jsx(rt,{path:"/proposals",element:n.jsx(Xr,{to:"/approvals"})}),n.jsx(rt,{path:"/agent-brief",element:n.jsx(QS,{})}),n.jsx(rt,{path:"/settings",element:n.jsx(NS,{})}),n.jsx(rt,{path:"/settings/services",element:n.jsx(Pn,{to:"/settings",replace:!0})}),n.jsx(rt,{path:"/deploy",element:n.jsx(Pn,{to:"/integrations",replace:!0})})]}),n.jsx(rt,{path:"*",element:n.jsx(Pn,{to:"/",replace:!0})})]})}function Ib(){return n.jsx(Ov,{children:n.jsx(tx,{children:n.jsx(sx,{children:n.jsx(Tb,{})})})})}dy.createRoot(document.getElementById("root")).render(n.jsx(h.StrictMode,{children:n.jsx(Ib,{})}));