@suveren/gateway 0.31.2 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,123 @@
1
+ var Sy=Object.defineProperty;var by=(t,s,a)=>s in t?Sy(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var Js=(t,s,a)=>by(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 Ul={exports:{}},Qs={},Wl={exports:{}},De={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Cf;function ky(){if(Cf)return De;Cf=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(I){return I===null||typeof I!="object"?null:(I=x&&I[x]||I["@@iterator"],typeof I=="function"?I:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,S={};function N(I,$,ie){this.props=I,this.context=$,this.refs=S,this.updater=ie||k}N.prototype.isReactComponent={},N.prototype.setState=function(I,$){if(typeof I!="object"&&typeof I!="function"&&I!=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,I,$,"setState")},N.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function E(){}E.prototype=N.prototype;function T(I,$,ie){this.props=I,this.context=$,this.refs=S,this.updater=ie||k}var P=T.prototype=new E;P.constructor=T,b(P,N.prototype),P.isPureReactComponent=!0;var A=Array.isArray,D=Object.prototype.hasOwnProperty,O={current:null},K={key:!0,ref:!0,__self:!0,__source:!0};function L(I,$,ie){var fe,B={},re=null,ce=null;if($!=null)for(fe in $.ref!==void 0&&(ce=$.ref),$.key!==void 0&&(re=""+$.key),$)D.call($,fe)&&!K.hasOwnProperty(fe)&&(B[fe]=$[fe]);var pe=arguments.length-2;if(pe===1)B.children=ie;else if(1<pe){for(var ye=Array(pe),oe=0;oe<pe;oe++)ye[oe]=arguments[oe+2];B.children=ye}if(I&&I.defaultProps)for(fe in pe=I.defaultProps,pe)B[fe]===void 0&&(B[fe]=pe[fe]);return{$$typeof:t,type:I,key:re,ref:ce,props:B,_owner:O.current}}function W(I,$){return{$$typeof:t,type:I.type,key:$,ref:I.ref,props:I.props,_owner:I._owner}}function te(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function Z(I){var $={"=":"=0",":":"=2"};return"$"+I.replace(/[=:]/g,function(ie){return $[ie]})}var F=/\/+/g;function ne(I,$){return typeof I=="object"&&I!==null&&I.key!=null?Z(""+I.key):$.toString(36)}function he(I,$,ie,fe,B){var re=typeof I;(re==="undefined"||re==="boolean")&&(I=null);var ce=!1;if(I===null)ce=!0;else switch(re){case"string":case"number":ce=!0;break;case"object":switch(I.$$typeof){case t:case s:ce=!0}}if(ce)return ce=I,B=B(ce),I=fe===""?"."+ne(ce,0):fe,A(B)?(ie="",I!=null&&(ie=I.replace(F,"$&/")+"/"),he(B,$,ie,"",function(oe){return oe})):B!=null&&(te(B)&&(B=W(B,ie+(!B.key||ce&&ce.key===B.key?"":(""+B.key).replace(F,"$&/")+"/")+I)),$.push(B)),1;if(ce=0,fe=fe===""?".":fe+":",A(I))for(var pe=0;pe<I.length;pe++){re=I[pe];var ye=fe+ne(re,pe);ce+=he(re,$,ie,ye,B)}else if(ye=j(I),typeof ye=="function")for(I=ye.call(I),pe=0;!(re=I.next()).done;)re=re.value,ye=fe+ne(re,pe++),ce+=he(re,$,ie,ye,B);else if(re==="object")throw $=String(I),Error("Objects are not valid as a React child (found: "+($==="[object Object]"?"object with keys {"+Object.keys(I).join(", ")+"}":$)+"). If you meant to render a collection of children, use an array instead.");return ce}function Q(I,$,ie){if(I==null)return I;var fe=[],B=0;return he(I,fe,"","",function(re){return $.call(ie,re,B++)}),fe}function ve(I){if(I._status===-1){var $=I._result;$=$(),$.then(function(ie){(I._status===0||I._status===-1)&&(I._status=1,I._result=ie)},function(ie){(I._status===0||I._status===-1)&&(I._status=2,I._result=ie)}),I._status===-1&&(I._status=0,I._result=$)}if(I._status===1)return I._result.default;throw I._result}var we={current:null},ee={transition:null},X={ReactCurrentDispatcher:we,ReactCurrentBatchConfig:ee,ReactCurrentOwner:O};function q(){throw Error("act(...) is not supported in production builds of React.")}return De.Children={map:Q,forEach:function(I,$,ie){Q(I,function(){$.apply(this,arguments)},ie)},count:function(I){var $=0;return Q(I,function(){$++}),$},toArray:function(I){return Q(I,function($){return $})||[]},only:function(I){if(!te(I))throw Error("React.Children.only expected to receive a single React element child.");return I}},De.Component=N,De.Fragment=a,De.Profiler=l,De.PureComponent=T,De.StrictMode=o,De.Suspense=p,De.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=X,De.act=q,De.cloneElement=function(I,$,ie){if(I==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+I+".");var fe=b({},I.props),B=I.key,re=I.ref,ce=I._owner;if($!=null){if($.ref!==void 0&&(re=$.ref,ce=O.current),$.key!==void 0&&(B=""+$.key),I.type&&I.type.defaultProps)var pe=I.type.defaultProps;for(ye in $)D.call($,ye)&&!K.hasOwnProperty(ye)&&(fe[ye]=$[ye]===void 0&&pe!==void 0?pe[ye]:$[ye])}var ye=arguments.length-2;if(ye===1)fe.children=ie;else if(1<ye){pe=Array(ye);for(var oe=0;oe<ye;oe++)pe[oe]=arguments[oe+2];fe.children=pe}return{$$typeof:t,type:I.type,key:B,ref:re,props:fe,_owner:ce}},De.createContext=function(I){return I={$$typeof:f,_currentValue:I,_currentValue2:I,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},I.Provider={$$typeof:u,_context:I},I.Consumer=I},De.createElement=L,De.createFactory=function(I){var $=L.bind(null,I);return $.type=I,$},De.createRef=function(){return{current:null}},De.forwardRef=function(I){return{$$typeof:g,render:I}},De.isValidElement=te,De.lazy=function(I){return{$$typeof:y,_payload:{_status:-1,_result:I},_init:ve}},De.memo=function(I,$){return{$$typeof:v,type:I,compare:$===void 0?null:$}},De.startTransition=function(I){var $=ee.transition;ee.transition={};try{I()}finally{ee.transition=$}},De.unstable_act=q,De.useCallback=function(I,$){return we.current.useCallback(I,$)},De.useContext=function(I){return we.current.useContext(I)},De.useDebugValue=function(){},De.useDeferredValue=function(I){return we.current.useDeferredValue(I)},De.useEffect=function(I,$){return we.current.useEffect(I,$)},De.useId=function(){return we.current.useId()},De.useImperativeHandle=function(I,$,ie){return we.current.useImperativeHandle(I,$,ie)},De.useInsertionEffect=function(I,$){return we.current.useInsertionEffect(I,$)},De.useLayoutEffect=function(I,$){return we.current.useLayoutEffect(I,$)},De.useMemo=function(I,$){return we.current.useMemo(I,$)},De.useReducer=function(I,$,ie){return we.current.useReducer(I,$,ie)},De.useRef=function(I){return we.current.useRef(I)},De.useState=function(I){return we.current.useState(I)},De.useSyncExternalStore=function(I,$,ie){return we.current.useSyncExternalStore(I,$,ie)},De.useTransition=function(){return we.current.useTransition()},De.version="18.3.1",De}var Ef;function jc(){return Ef||(Ef=1,Wl.exports=ky()),Wl.exports}/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var Tf;function Ny(){if(Tf)return Qs;Tf=1;var t=jc(),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,k=null;v!==void 0&&(j=""+v),p.key!==void 0&&(j=""+p.key),p.ref!==void 0&&(k=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:k,props:x,_owner:l.current}}return Qs.Fragment=a,Qs.jsx=f,Qs.jsxs=f,Qs}var If;function Cy(){return If||(If=1,Ul.exports=Ny()),Ul.exports}var n=Cy(),m=jc(),ki={},Hl={exports:{}},Yt={},Vl={exports:{}},Gl={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */var Af;function Ey(){return Af||(Af=1,(function(t){function s(ee,X){var q=ee.length;ee.push(X);e:for(;0<q;){var I=q-1>>>1,$=ee[I];if(0<l($,X))ee[I]=X,ee[q]=$,q=I;else break e}}function a(ee){return ee.length===0?null:ee[0]}function o(ee){if(ee.length===0)return null;var X=ee[0],q=ee.pop();if(q!==X){ee[0]=q;e:for(var I=0,$=ee.length,ie=$>>>1;I<ie;){var fe=2*(I+1)-1,B=ee[fe],re=fe+1,ce=ee[re];if(0>l(B,q))re<$&&0>l(ce,B)?(ee[I]=ce,ee[re]=q,I=re):(ee[I]=B,ee[fe]=q,I=fe);else if(re<$&&0>l(ce,q))ee[I]=ce,ee[re]=q,I=re;else break e}}return X}function l(ee,X){var q=ee.sortIndex-X.sortIndex;return q!==0?q:ee.id-X.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,k=!1,b=!1,S=!1,N=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function P(ee){for(var X=a(v);X!==null;){if(X.callback===null)o(v);else if(X.startTime<=ee)o(v),X.sortIndex=X.expirationTime,s(p,X);else break;X=a(v)}}function A(ee){if(S=!1,P(ee),!b)if(a(p)!==null)b=!0,ve(D);else{var X=a(v);X!==null&&we(A,X.startTime-ee)}}function D(ee,X){b=!1,S&&(S=!1,E(L),L=-1),k=!0;var q=j;try{for(P(X),x=a(p);x!==null&&(!(x.expirationTime>X)||ee&&!Z());){var I=x.callback;if(typeof I=="function"){x.callback=null,j=x.priorityLevel;var $=I(x.expirationTime<=X);X=t.unstable_now(),typeof $=="function"?x.callback=$:x===a(p)&&o(p),P(X)}else o(p);x=a(p)}if(x!==null)var ie=!0;else{var fe=a(v);fe!==null&&we(A,fe.startTime-X),ie=!1}return ie}finally{x=null,j=q,k=!1}}var O=!1,K=null,L=-1,W=5,te=-1;function Z(){return!(t.unstable_now()-te<W)}function F(){if(K!==null){var ee=t.unstable_now();te=ee;var X=!0;try{X=K(!0,ee)}finally{X?ne():(O=!1,K=null)}}else O=!1}var ne;if(typeof T=="function")ne=function(){T(F)};else if(typeof MessageChannel<"u"){var he=new MessageChannel,Q=he.port2;he.port1.onmessage=F,ne=function(){Q.postMessage(null)}}else ne=function(){N(F,0)};function ve(ee){K=ee,O||(O=!0,ne())}function we(ee,X){L=N(function(){ee(t.unstable_now())},X)}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(ee){ee.callback=null},t.unstable_continueExecution=function(){b||k||(b=!0,ve(D))},t.unstable_forceFrameRate=function(ee){0>ee||125<ee?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):W=0<ee?Math.floor(1e3/ee):5},t.unstable_getCurrentPriorityLevel=function(){return j},t.unstable_getFirstCallbackNode=function(){return a(p)},t.unstable_next=function(ee){switch(j){case 1:case 2:case 3:var X=3;break;default:X=j}var q=j;j=X;try{return ee()}finally{j=q}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(ee,X){switch(ee){case 1:case 2:case 3:case 4:case 5:break;default:ee=3}var q=j;j=ee;try{return X()}finally{j=q}},t.unstable_scheduleCallback=function(ee,X,q){var I=t.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?I+q:I):q=I,ee){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=q+$,ee={id:y++,callback:X,priorityLevel:ee,startTime:q,expirationTime:$,sortIndex:-1},q>I?(ee.sortIndex=q,s(v,ee),a(p)===null&&ee===a(v)&&(S?(E(L),L=-1):S=!0,we(A,q-I))):(ee.sortIndex=$,s(p,ee),b||k||(b=!0,ve(D))),ee},t.unstable_shouldYield=Z,t.unstable_wrapCallback=function(ee){var X=j;return function(){var q=j;j=X;try{return ee.apply(this,arguments)}finally{j=q}}}})(Gl)),Gl}var Rf;function Ty(){return Rf||(Rf=1,Vl.exports=Ey()),Vl.exports}/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var Pf;function Iy(){if(Pf)return Yt;Pf=1;var t=jc(),s=Ty();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 k(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"||k(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,h,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=h,this.removeEmptyString=w}var N={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){N[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];N[r]=new S(r,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){N[e]=new S(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){N[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){N[e]=new S(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){N[e]=new S(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){N[e]=new S(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){N[e]=new S(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){N[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);N[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);N[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);N[r]=new S(r,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){N[e]=new S(e,1,!1,e.toLowerCase(),null,!1,!1)}),N.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){N[e]=new S(e,1,!1,e.toLowerCase(),null,!0,!0)});function P(e,r,i,c){var d=N.hasOwnProperty(r)?N[r]:null;(d!==null?d.type!==0:c||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(b(r,i,d,c)&&(i=null),c||d===null?j(r)&&(i===null?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 A=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,D=Symbol.for("react.element"),O=Symbol.for("react.portal"),K=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),te=Symbol.for("react.provider"),Z=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),ne=Symbol.for("react.suspense"),he=Symbol.for("react.suspense_list"),Q=Symbol.for("react.memo"),ve=Symbol.for("react.lazy"),we=Symbol.for("react.offscreen"),ee=Symbol.iterator;function X(e){return e===null||typeof e!="object"?null:(e=ee&&e[ee]||e["@@iterator"],typeof e=="function"?e:null)}var q=Object.assign,I;function $(e){if(I===void 0)try{throw Error()}catch(i){var r=i.stack.trim().match(/\n( *(at )?)/);I=r&&r[1]||""}return`
34
+ `+I+e}var ie=!1;function fe(e,r){if(!e||ie)return"";ie=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(V){var c=V}Reflect.construct(e,[],r)}else{try{r.call()}catch(V){c=V}e.call(r.prototype)}else{try{throw Error()}catch(V){c=V}e()}}catch(V){if(V&&c&&typeof V.stack=="string"){for(var d=V.stack.split(`
35
+ `),h=c.stack.split(`
36
+ `),w=d.length-1,C=h.length-1;1<=w&&0<=C&&d[w]!==h[C];)C--;for(;1<=w&&0<=C;w--,C--)if(d[w]!==h[C]){if(w!==1||C!==1)do if(w--,C--,0>C||d[w]!==h[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{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?$(e):""}function B(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=fe(e.type,!1),e;case 11:return e=fe(e.type.render,!1),e;case 1:return e=fe(e.type,!0),e;default:return""}}function re(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 K:return"Fragment";case O:return"Portal";case W:return"Profiler";case L:return"StrictMode";case ne:return"Suspense";case he:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Z:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case F:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Q:return r=e.displayName||null,r!==null?r:re(e.type)||"Memo";case ve:r=e._payload,e=e._init;try{return re(e(r))}catch{}}return null}function ce(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 re(r);case 8:return r===L?"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 ye(e){var r=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function oe(e){var r=ye(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,h=i.set;return Object.defineProperty(e,r,{configurable:!0,get:function(){return d.call(this)},set:function(w){c=""+w,h.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 Ge(e){e._valueTracker||(e._valueTracker=oe(e))}function be(e){if(!e)return!1;var r=e._valueTracker;if(!r)return!0;var i=r.getValue(),c="";return e&&(c=ye(e)?e.checked?"true":"false":e.value),e=c,e!==i?(r.setValue(e),!0):!1}function Y(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 $e(e,r){var i=r.checked;return q({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function _e(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 Be(e,r){r=r.checked,r!=null&&P(e,"checked",r,!1)}function ze(e,r){Be(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")?tt(e,r.type,i):r.hasOwnProperty("defaultValue")&&tt(e,r.type,pe(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(e.defaultChecked=!!r.defaultChecked)}function it(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 tt(e,r,i){(r!=="number"||Y(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var Qe=Array.isArray;function Ye(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 jt(e,r){if(r.dangerouslySetInnerHTML!=null)throw Error(a(91));return q({},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 Me(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 me(e){var r=e.textContent;r===e._wrapperState.initialValue&&r!==""&&r!==null&&(e.value=r)}function Ie(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 Oe(e,r){return e==null||e==="http://www.w3.org/1999/xhtml"?Ie(r):e==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var G,J=(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(G=G||document.createElement("div"),G.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=G.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;r.firstChild;)e.appendChild(r.firstChild)}});function ge(e,r){if(r){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=r;return}}e.textContent=r}var Ue={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},We=["Webkit","ms","Moz","O"];Object.keys(Ue).forEach(function(e){We.forEach(function(r){r=r+e.charAt(0).toUpperCase()+e.substring(1),Ue[r]=Ue[e]})});function nt(e,r,i){return r==null||typeof r=="boolean"||r===""?"":i||typeof r!="number"||r===0||Ue.hasOwnProperty(e)&&Ue[e]?(""+r).trim():r+"px"}function Wt(e,r){e=e.style;for(var i in r)if(r.hasOwnProperty(i)){var c=i.indexOf("--")===0,d=nt(i,r[i],c);i==="float"&&(i="cssFloat"),c?e.setProperty(i,d):e[i]=d}}var Ot=q({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ze(e,r){if(r){if(Ot[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 H(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 xe=null;function Te(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var rt=null,gt=null,Ke=null;function Nt(e){if(e=Ls(e)){if(typeof rt!="function")throw Error(a(280));var r=e.stateNode;r&&(r=Oa(r),rt(e.stateNode,e.type,r))}}function St(e){gt?Ke?Ke.push(e):Ke=[e]:gt=e}function Xt(){if(gt){var e=gt,r=Ke;if(Ke=gt=null,Nt(e),r)for(e=0;e<r.length;e++)Nt(r[e])}}function ue(e,r){return e(r)}function Ce(){}var Ae=!1;function Ve(e,r,i){if(Ae)return e(r,i);Ae=!0;try{return ue(e,r,i)}finally{Ae=!1,(gt!==null||Ke!==null)&&(Ce(),Xt())}}function Xe(e,r){var i=e.stateNode;if(i===null)return null;var c=Oa(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 Ct=!1;if(g)try{var Pt={};Object.defineProperty(Pt,"passive",{get:function(){Ct=!0}}),window.addEventListener("test",Pt,Pt),window.removeEventListener("test",Pt,Pt)}catch{Ct=!1}function _r(e,r,i,c,d,h,w,C,R){var V=Array.prototype.slice.call(arguments,3);try{r.apply(i,V)}catch(ae){this.onError(ae)}}var cr=!1,Lr=null,Un=!1,ur=null,io={onError:function(e){cr=!0,Lr=e}};function ga(e,r,i,c,d,h,w,C,R){cr=!1,Lr=null,_r.apply(io,arguments)}function ya(e,r,i,c,d,h,w,C,R){if(ga.apply(this,arguments),cr){if(cr){var V=Lr;cr=!1,Lr=null}else throw Error(a(198));Un||(Un=!0,ur=V)}}function bn(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 gs(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 va(e){if(bn(e)!==e)throw Error(a(188))}function zr(e){var r=e.alternate;if(!r){if(r=bn(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 h=d.alternate;if(h===null){if(c=d.return,c!==null){i=c;continue}break}if(d.child===h.child){for(h=d.child;h;){if(h===i)return va(d),e;if(h===c)return va(d),r;h=h.sibling}throw Error(a(188))}if(i.return!==c.return)i=d,c=h;else{for(var w=!1,C=d.child;C;){if(C===i){w=!0,i=d,c=h;break}if(C===c){w=!0,c=d,i=h;break}C=C.sibling}if(!w){for(C=h.child;C;){if(C===i){w=!0,i=h,c=d;break}if(C===c){w=!0,c=h,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 kn(e){return e=zr(e),e!==null?Qc(e):null}function Qc(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var r=Qc(e);if(r!==null)return r;e=e.sibling}return null}var Xc=s.unstable_scheduleCallback,Zc=s.unstable_cancelCallback,$p=s.unstable_shouldYield,_p=s.unstable_requestPaint,yt=s.unstable_now,Lp=s.unstable_getCurrentPriorityLevel,oo=s.unstable_ImmediatePriority,eu=s.unstable_UserBlockingPriority,xa=s.unstable_NormalPriority,zp=s.unstable_LowPriority,tu=s.unstable_IdlePriority,wa=null,Nn=null;function Fp(e){if(Nn&&typeof Nn.onCommitFiberRoot=="function")try{Nn.onCommitFiberRoot(wa,e,void 0,(e.current.flags&128)===128)}catch{}}var mn=Math.clz32?Math.clz32:Bp,Mp=Math.log,Op=Math.LN2;function Bp(e){return e>>>=0,e===0?32:31-(Mp(e)/Op|0)|0}var ja=64,Sa=4194304;function ys(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 ba(e,r){var i=e.pendingLanes;if(i===0)return 0;var c=0,d=e.suspendedLanes,h=e.pingedLanes,w=i&268435455;if(w!==0){var C=w&~d;C!==0?c=ys(C):(h&=w,h!==0&&(c=ys(h)))}else w=i&~d,w!==0?c=ys(w):h!==0&&(c=ys(h));if(c===0)return 0;if(r!==0&&r!==c&&(r&d)===0&&(d=c&-c,h=r&-r,d>=h||d===16&&(h&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-mn(r),d=1<<i,c|=e[i],r&=~d;return c}function Dp(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 Up(e,r){for(var i=e.suspendedLanes,c=e.pingedLanes,d=e.expirationTimes,h=e.pendingLanes;0<h;){var w=31-mn(h),C=1<<w,R=d[w];R===-1?((C&i)===0||(C&c)!==0)&&(d[w]=Dp(C,r)):R<=r&&(e.expiredLanes|=C),h&=~C}}function lo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function nu(){var e=ja;return ja<<=1,(ja&4194240)===0&&(ja=64),e}function co(e){for(var r=[],i=0;31>i;i++)r.push(e);return r}function vs(e,r,i){e.pendingLanes|=r,r!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,r=31-mn(r),e[r]=i}function Wp(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-mn(i),h=1<<d;r[d]=0,c[d]=-1,e[d]=-1,i&=~h}}function uo(e,r){var i=e.entangledLanes|=r;for(e=e.entanglements;i;){var c=31-mn(i),d=1<<c;d&r|e[c]&r&&(e[c]|=r),i&=~d}}var et=0;function ru(e){return e&=-e,1<e?4<e?(e&268435455)!==0?16:536870912:4:1}var su,fo,au,iu,ou,mo=!1,ka=[],Wn=null,Hn=null,Vn=null,xs=new Map,ws=new Map,Gn=[],Hp="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 lu(e,r){switch(e){case"focusin":case"focusout":Wn=null;break;case"dragenter":case"dragleave":Hn=null;break;case"mouseover":case"mouseout":Vn=null;break;case"pointerover":case"pointerout":xs.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":ws.delete(r.pointerId)}}function js(e,r,i,c,d,h){return e===null||e.nativeEvent!==h?(e={blockedOn:r,domEventName:i,eventSystemFlags:c,nativeEvent:h,targetContainers:[d]},r!==null&&(r=Ls(r),r!==null&&fo(r)),e):(e.eventSystemFlags|=c,r=e.targetContainers,d!==null&&r.indexOf(d)===-1&&r.push(d),e)}function Vp(e,r,i,c,d){switch(r){case"focusin":return Wn=js(Wn,e,r,i,c,d),!0;case"dragenter":return Hn=js(Hn,e,r,i,c,d),!0;case"mouseover":return Vn=js(Vn,e,r,i,c,d),!0;case"pointerover":var h=d.pointerId;return xs.set(h,js(xs.get(h)||null,e,r,i,c,d)),!0;case"gotpointercapture":return h=d.pointerId,ws.set(h,js(ws.get(h)||null,e,r,i,c,d)),!0}return!1}function cu(e){var r=dr(e.target);if(r!==null){var i=bn(r);if(i!==null){if(r=i.tag,r===13){if(r=gs(i),r!==null){e.blockedOn=r,ou(e.priority,function(){au(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 Na(e){if(e.blockedOn!==null)return!1;for(var r=e.targetContainers;0<r.length;){var i=po(e.domEventName,e.eventSystemFlags,r[0],e.nativeEvent);if(i===null){i=e.nativeEvent;var c=new i.constructor(i.type,i);xe=c,i.target.dispatchEvent(c),xe=null}else return r=Ls(i),r!==null&&fo(r),e.blockedOn=i,!1;r.shift()}return!0}function uu(e,r,i){Na(e)&&i.delete(r)}function Gp(){mo=!1,Wn!==null&&Na(Wn)&&(Wn=null),Hn!==null&&Na(Hn)&&(Hn=null),Vn!==null&&Na(Vn)&&(Vn=null),xs.forEach(uu),ws.forEach(uu)}function Ss(e,r){e.blockedOn===r&&(e.blockedOn=null,mo||(mo=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Gp)))}function bs(e){function r(d){return Ss(d,e)}if(0<ka.length){Ss(ka[0],e);for(var i=1;i<ka.length;i++){var c=ka[i];c.blockedOn===e&&(c.blockedOn=null)}}for(Wn!==null&&Ss(Wn,e),Hn!==null&&Ss(Hn,e),Vn!==null&&Ss(Vn,e),xs.forEach(r),ws.forEach(r),i=0;i<Gn.length;i++)c=Gn[i],c.blockedOn===e&&(c.blockedOn=null);for(;0<Gn.length&&(i=Gn[0],i.blockedOn===null);)cu(i),i.blockedOn===null&&Gn.shift()}var Fr=A.ReactCurrentBatchConfig,Ca=!0;function Kp(e,r,i,c){var d=et,h=Fr.transition;Fr.transition=null;try{et=1,ho(e,r,i,c)}finally{et=d,Fr.transition=h}}function qp(e,r,i,c){var d=et,h=Fr.transition;Fr.transition=null;try{et=4,ho(e,r,i,c)}finally{et=d,Fr.transition=h}}function ho(e,r,i,c){if(Ca){var d=po(e,r,i,c);if(d===null)Po(e,r,c,Ea,i),lu(e,c);else if(Vp(d,e,r,i,c))c.stopPropagation();else if(lu(e,c),r&4&&-1<Hp.indexOf(e)){for(;d!==null;){var h=Ls(d);if(h!==null&&su(h),h=po(e,r,i,c),h===null&&Po(e,r,c,Ea,i),h===d)break;d=h}d!==null&&c.stopPropagation()}else Po(e,r,c,null,i)}}var Ea=null;function po(e,r,i,c){if(Ea=null,e=Te(c),e=dr(e),e!==null)if(r=bn(e),r===null)e=null;else if(i=r.tag,i===13){if(e=gs(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 Ea=e,null}function du(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(Lp()){case oo:return 1;case eu:return 4;case xa:case zp:return 16;case tu:return 536870912;default:return 16}default:return 16}}var Kn=null,go=null,Ta=null;function fu(){if(Ta)return Ta;var e,r=go,i=r.length,c,d="value"in Kn?Kn.value:Kn.textContent,h=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[h-c];c++);return Ta=d.slice(e,1<c?1-c:void 0)}function Ia(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 Aa(){return!0}function mu(){return!1}function Zt(e){function r(i,c,d,h,w){this._reactName=i,this._targetInst=d,this.type=c,this.nativeEvent=h,this.target=w,this.currentTarget=null;for(var C in e)e.hasOwnProperty(C)&&(i=e[C],this[C]=i?i(h):h[C]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?Aa:mu,this.isPropagationStopped=mu,this}return q(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=Aa)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=Aa)},persist:function(){},isPersistent:Aa}),r}var Mr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},yo=Zt(Mr),ks=q({},Mr,{view:0,detail:0}),Yp=Zt(ks),vo,xo,Ns,Ra=q({},ks,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:jo,button:0,buttons:0,relatedTarget:function(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!==Ns&&(Ns&&e.type==="mousemove"?(vo=e.screenX-Ns.screenX,xo=e.screenY-Ns.screenY):xo=vo=0,Ns=e),vo)},movementY:function(e){return"movementY"in e?e.movementY:xo}}),hu=Zt(Ra),Jp=q({},Ra,{dataTransfer:0}),Qp=Zt(Jp),Xp=q({},ks,{relatedTarget:0}),wo=Zt(Xp),Zp=q({},Mr,{animationName:0,elapsedTime:0,pseudoElement:0}),eg=Zt(Zp),tg=q({},Mr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ng=Zt(tg),rg=q({},Mr,{data:0}),pu=Zt(rg),sg={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ag={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"},ig={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function og(e){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(e):(e=ig[e])?!!r[e]:!1}function jo(){return og}var lg=q({},ks,{key:function(e){if(e.key){var r=sg[e.key]||e.key;if(r!=="Unidentified")return r}return e.type==="keypress"?(e=Ia(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?ag[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:jo,charCode:function(e){return e.type==="keypress"?Ia(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ia(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),cg=Zt(lg),ug=q({},Ra,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),gu=Zt(ug),dg=q({},ks,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:jo}),fg=Zt(dg),mg=q({},Mr,{propertyName:0,elapsedTime:0,pseudoElement:0}),hg=Zt(mg),pg=q({},Ra,{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}),gg=Zt(pg),yg=[9,13,27,32],So=g&&"CompositionEvent"in window,Cs=null;g&&"documentMode"in document&&(Cs=document.documentMode);var vg=g&&"TextEvent"in window&&!Cs,yu=g&&(!So||Cs&&8<Cs&&11>=Cs),vu=" ",xu=!1;function wu(e,r){switch(e){case"keyup":return yg.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ju(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Or=!1;function xg(e,r){switch(e){case"compositionend":return ju(r);case"keypress":return r.which!==32?null:(xu=!0,vu);case"textInput":return e=r.data,e===vu&&xu?null:e;default:return null}}function wg(e,r){if(Or)return e==="compositionend"||!So&&wu(e,r)?(e=fu(),Ta=go=Kn=null,Or=!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 yu&&r.locale!=="ko"?null:r.data;default:return null}}var jg={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 Su(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r==="input"?!!jg[e.type]:r==="textarea"}function bu(e,r,i,c){St(c),r=za(r,"onChange"),0<r.length&&(i=new yo("onChange","change",null,i,c),e.push({event:i,listeners:r}))}var Es=null,Ts=null;function Sg(e){Du(e,0)}function Pa(e){var r=Hr(e);if(be(r))return e}function bg(e,r){if(e==="change")return r}var ku=!1;if(g){var bo;if(g){var ko="oninput"in document;if(!ko){var Nu=document.createElement("div");Nu.setAttribute("oninput","return;"),ko=typeof Nu.oninput=="function"}bo=ko}else bo=!1;ku=bo&&(!document.documentMode||9<document.documentMode)}function Cu(){Es&&(Es.detachEvent("onpropertychange",Eu),Ts=Es=null)}function Eu(e){if(e.propertyName==="value"&&Pa(Ts)){var r=[];bu(r,Ts,e,Te(e)),Ve(Sg,r)}}function kg(e,r,i){e==="focusin"?(Cu(),Es=r,Ts=i,Es.attachEvent("onpropertychange",Eu)):e==="focusout"&&Cu()}function Ng(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Pa(Ts)}function Cg(e,r){if(e==="click")return Pa(r)}function Eg(e,r){if(e==="input"||e==="change")return Pa(r)}function Tg(e,r){return e===r&&(e!==0||1/e===1/r)||e!==e&&r!==r}var hn=typeof Object.is=="function"?Object.is:Tg;function Is(e,r){if(hn(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)||!hn(e[d],r[d]))return!1}return!0}function Tu(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Iu(e,r){var i=Tu(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=Tu(i)}}function Au(e,r){return e&&r?e===r?!0:e&&e.nodeType===3?!1:r&&r.nodeType===3?Au(e,r.parentNode):"contains"in e?e.contains(r):e.compareDocumentPosition?!!(e.compareDocumentPosition(r)&16):!1:!1}function Ru(){for(var e=window,r=Y();r instanceof e.HTMLIFrameElement;){try{var i=typeof r.contentWindow.location.href=="string"}catch{i=!1}if(i)e=r.contentWindow;else break;r=Y(e.document)}return r}function No(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 Ig(e){var r=Ru(),i=e.focusedElem,c=e.selectionRange;if(r!==i&&i&&i.ownerDocument&&Au(i.ownerDocument.documentElement,i)){if(c!==null&&No(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,h=Math.min(c.start,d);c=c.end===void 0?h:Math.min(c.end,d),!e.extend&&h>c&&(d=c,c=h,h=d),d=Iu(i,h);var w=Iu(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(),h>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 Ag=g&&"documentMode"in document&&11>=document.documentMode,Br=null,Co=null,As=null,Eo=!1;function Pu(e,r,i){var c=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Eo||Br==null||Br!==Y(c)||(c=Br,"selectionStart"in c&&No(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),As&&Is(As,c)||(As=c,c=za(Co,"onSelect"),0<c.length&&(r=new yo("onSelect","select",null,r,i),e.push({event:r,listeners:c}),r.target=Br)))}function $a(e,r){var i={};return i[e.toLowerCase()]=r.toLowerCase(),i["Webkit"+e]="webkit"+r,i["Moz"+e]="moz"+r,i}var Dr={animationend:$a("Animation","AnimationEnd"),animationiteration:$a("Animation","AnimationIteration"),animationstart:$a("Animation","AnimationStart"),transitionend:$a("Transition","TransitionEnd")},To={},$u={};g&&($u=document.createElement("div").style,"AnimationEvent"in window||(delete Dr.animationend.animation,delete Dr.animationiteration.animation,delete Dr.animationstart.animation),"TransitionEvent"in window||delete Dr.transitionend.transition);function _a(e){if(To[e])return To[e];if(!Dr[e])return e;var r=Dr[e],i;for(i in r)if(r.hasOwnProperty(i)&&i in $u)return To[e]=r[i];return e}var _u=_a("animationend"),Lu=_a("animationiteration"),zu=_a("animationstart"),Fu=_a("transitionend"),Mu=new Map,Ou="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 qn(e,r){Mu.set(e,r),u(r,[e])}for(var Io=0;Io<Ou.length;Io++){var Ao=Ou[Io],Rg=Ao.toLowerCase(),Pg=Ao[0].toUpperCase()+Ao.slice(1);qn(Rg,"on"+Pg)}qn(_u,"onAnimationEnd"),qn(Lu,"onAnimationIteration"),qn(zu,"onAnimationStart"),qn("dblclick","onDoubleClick"),qn("focusin","onFocus"),qn("focusout","onBlur"),qn(Fu,"onTransitionEnd"),f("onMouseEnter",["mouseout","mouseover"]),f("onMouseLeave",["mouseout","mouseover"]),f("onPointerEnter",["pointerout","pointerover"]),f("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Rs="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),$g=new Set("cancel close invalid load scroll toggle".split(" ").concat(Rs));function Bu(e,r,i){var c=e.type||"unknown-event";e.currentTarget=i,ya(c,r,void 0,e),e.currentTarget=null}function Du(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 h=void 0;if(r)for(var w=c.length-1;0<=w;w--){var C=c[w],R=C.instance,V=C.currentTarget;if(C=C.listener,R!==h&&d.isPropagationStopped())break e;Bu(d,C,V),h=R}else for(w=0;w<c.length;w++){if(C=c[w],R=C.instance,V=C.currentTarget,C=C.listener,R!==h&&d.isPropagationStopped())break e;Bu(d,C,V),h=R}}}if(Un)throw e=ur,Un=!1,ur=null,e}function ot(e,r){var i=r[Mo];i===void 0&&(i=r[Mo]=new Set);var c=e+"__bubble";i.has(c)||(Uu(r,e,2,!1),i.add(c))}function Ro(e,r,i){var c=0;r&&(c|=4),Uu(i,e,c,r)}var La="_reactListening"+Math.random().toString(36).slice(2);function Ps(e){if(!e[La]){e[La]=!0,o.forEach(function(i){i!=="selectionchange"&&($g.has(i)||Ro(i,!1,e),Ro(i,!0,e))});var r=e.nodeType===9?e:e.ownerDocument;r===null||r[La]||(r[La]=!0,Ro("selectionchange",!1,r))}}function Uu(e,r,i,c){switch(du(r)){case 1:var d=Kp;break;case 4:d=qp;break;default:d=ho}i=d.bind(null,r,i,e),d=void 0,!Ct||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 Po(e,r,i,c,d){var h=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var w=c.tag;if(w===3||w===4){var C=c.stateNode.containerInfo;if(C===d||C.nodeType===8&&C.parentNode===d)break;if(w===4)for(w=c.return;w!==null;){var R=w.tag;if((R===3||R===4)&&(R=w.stateNode.containerInfo,R===d||R.nodeType===8&&R.parentNode===d))return;w=w.return}for(;C!==null;){if(w=dr(C),w===null)return;if(R=w.tag,R===5||R===6){c=h=w;continue e}C=C.parentNode}}c=c.return}Ve(function(){var V=h,ae=Te(i),le=[];e:{var se=Mu.get(e);if(se!==void 0){var je=yo,ke=e;switch(e){case"keypress":if(Ia(i)===0)break e;case"keydown":case"keyup":je=cg;break;case"focusin":ke="focus",je=wo;break;case"focusout":ke="blur",je=wo;break;case"beforeblur":case"afterblur":je=wo;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":je=hu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=Qp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=fg;break;case _u:case Lu:case zu:je=eg;break;case Fu:je=hg;break;case"scroll":je=Yp;break;case"wheel":je=gg;break;case"copy":case"cut":case"paste":je=ng;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=gu}var Ne=(r&4)!==0,vt=!Ne&&e==="scroll",M=Ne?se!==null?se+"Capture":null:se;Ne=[];for(var _=V,U;_!==null;){U=_;var de=U.stateNode;if(U.tag===5&&de!==null&&(U=de,M!==null&&(de=Xe(_,M),de!=null&&Ne.push($s(_,de,U)))),vt)break;_=_.return}0<Ne.length&&(se=new je(se,ke,null,i,ae),le.push({event:se,listeners:Ne}))}}if((r&7)===0){e:{if(se=e==="mouseover"||e==="pointerover",je=e==="mouseout"||e==="pointerout",se&&i!==xe&&(ke=i.relatedTarget||i.fromElement)&&(dr(ke)||ke[Rn]))break e;if((je||se)&&(se=ae.window===ae?ae:(se=ae.ownerDocument)?se.defaultView||se.parentWindow:window,je?(ke=i.relatedTarget||i.toElement,je=V,ke=ke?dr(ke):null,ke!==null&&(vt=bn(ke),ke!==vt||ke.tag!==5&&ke.tag!==6)&&(ke=null)):(je=null,ke=V),je!==ke)){if(Ne=hu,de="onMouseLeave",M="onMouseEnter",_="mouse",(e==="pointerout"||e==="pointerover")&&(Ne=gu,de="onPointerLeave",M="onPointerEnter",_="pointer"),vt=je==null?se:Hr(je),U=ke==null?se:Hr(ke),se=new Ne(de,_+"leave",je,i,ae),se.target=vt,se.relatedTarget=U,de=null,dr(ae)===V&&(Ne=new Ne(M,_+"enter",ke,i,ae),Ne.target=U,Ne.relatedTarget=vt,de=Ne),vt=de,je&&ke)t:{for(Ne=je,M=ke,_=0,U=Ne;U;U=Ur(U))_++;for(U=0,de=M;de;de=Ur(de))U++;for(;0<_-U;)Ne=Ur(Ne),_--;for(;0<U-_;)M=Ur(M),U--;for(;_--;){if(Ne===M||M!==null&&Ne===M.alternate)break t;Ne=Ur(Ne),M=Ur(M)}Ne=null}else Ne=null;je!==null&&Wu(le,se,je,Ne,!1),ke!==null&&vt!==null&&Wu(le,vt,ke,Ne,!0)}}e:{if(se=V?Hr(V):window,je=se.nodeName&&se.nodeName.toLowerCase(),je==="select"||je==="input"&&se.type==="file")var Ee=bg;else if(Su(se))if(ku)Ee=Eg;else{Ee=Ng;var Re=kg}else(je=se.nodeName)&&je.toLowerCase()==="input"&&(se.type==="checkbox"||se.type==="radio")&&(Ee=Cg);if(Ee&&(Ee=Ee(e,V))){bu(le,Ee,i,ae);break e}Re&&Re(e,se,V),e==="focusout"&&(Re=se._wrapperState)&&Re.controlled&&se.type==="number"&&tt(se,"number",se.value)}switch(Re=V?Hr(V):window,e){case"focusin":(Su(Re)||Re.contentEditable==="true")&&(Br=Re,Co=V,As=null);break;case"focusout":As=Co=Br=null;break;case"mousedown":Eo=!0;break;case"contextmenu":case"mouseup":case"dragend":Eo=!1,Pu(le,i,ae);break;case"selectionchange":if(Ag)break;case"keydown":case"keyup":Pu(le,i,ae)}var Pe;if(So)e:{switch(e){case"compositionstart":var Le="onCompositionStart";break e;case"compositionend":Le="onCompositionEnd";break e;case"compositionupdate":Le="onCompositionUpdate";break e}Le=void 0}else Or?wu(e,i)&&(Le="onCompositionEnd"):e==="keydown"&&i.keyCode===229&&(Le="onCompositionStart");Le&&(yu&&i.locale!=="ko"&&(Or||Le!=="onCompositionStart"?Le==="onCompositionEnd"&&Or&&(Pe=fu()):(Kn=ae,go="value"in Kn?Kn.value:Kn.textContent,Or=!0)),Re=za(V,Le),0<Re.length&&(Le=new pu(Le,e,null,i,ae),le.push({event:Le,listeners:Re}),Pe?Le.data=Pe:(Pe=ju(i),Pe!==null&&(Le.data=Pe)))),(Pe=vg?xg(e,i):wg(e,i))&&(V=za(V,"onBeforeInput"),0<V.length&&(ae=new pu("onBeforeInput","beforeinput",null,i,ae),le.push({event:ae,listeners:V}),ae.data=Pe))}Du(le,r)})}function $s(e,r,i){return{instance:e,listener:r,currentTarget:i}}function za(e,r){for(var i=r+"Capture",c=[];e!==null;){var d=e,h=d.stateNode;d.tag===5&&h!==null&&(d=h,h=Xe(e,i),h!=null&&c.unshift($s(e,h,d)),h=Xe(e,r),h!=null&&c.push($s(e,h,d))),e=e.return}return c}function Ur(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Wu(e,r,i,c,d){for(var h=r._reactName,w=[];i!==null&&i!==c;){var C=i,R=C.alternate,V=C.stateNode;if(R!==null&&R===c)break;C.tag===5&&V!==null&&(C=V,d?(R=Xe(i,h),R!=null&&w.unshift($s(i,R,C))):d||(R=Xe(i,h),R!=null&&w.push($s(i,R,C)))),i=i.return}w.length!==0&&e.push({event:r,listeners:w})}var _g=/\r\n?/g,Lg=/\u0000|\uFFFD/g;function Hu(e){return(typeof e=="string"?e:""+e).replace(_g,`
38
+ `).replace(Lg,"")}function Fa(e,r,i){if(r=Hu(r),Hu(e)!==r&&i)throw Error(a(425))}function Ma(){}var $o=null,_o=null;function Lo(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 zo=typeof setTimeout=="function"?setTimeout:void 0,zg=typeof clearTimeout=="function"?clearTimeout:void 0,Vu=typeof Promise=="function"?Promise:void 0,Fg=typeof queueMicrotask=="function"?queueMicrotask:typeof Vu<"u"?function(e){return Vu.resolve(null).then(e).catch(Mg)}:zo;function Mg(e){setTimeout(function(){throw e})}function Fo(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),bs(r);return}c--}else i!=="$"&&i!=="$?"&&i!=="$!"||c++;i=d}while(i);bs(r)}function Yn(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 Gu(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 Wr=Math.random().toString(36).slice(2),Cn="__reactFiber$"+Wr,_s="__reactProps$"+Wr,Rn="__reactContainer$"+Wr,Mo="__reactEvents$"+Wr,Og="__reactListeners$"+Wr,Bg="__reactHandles$"+Wr;function dr(e){var r=e[Cn];if(r)return r;for(var i=e.parentNode;i;){if(r=i[Rn]||i[Cn]){if(i=r.alternate,r.child!==null||i!==null&&i.child!==null)for(e=Gu(e);e!==null;){if(i=e[Cn])return i;e=Gu(e)}return r}e=i,i=e.parentNode}return null}function Ls(e){return e=e[Cn]||e[Rn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Hr(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(a(33))}function Oa(e){return e[_s]||null}var Oo=[],Vr=-1;function Jn(e){return{current:e}}function lt(e){0>Vr||(e.current=Oo[Vr],Oo[Vr]=null,Vr--)}function st(e,r){Vr++,Oo[Vr]=e.current,e.current=r}var Qn={},$t=Jn(Qn),Ht=Jn(!1),fr=Qn;function Gr(e,r){var i=e.type.contextTypes;if(!i)return Qn;var c=e.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===r)return c.__reactInternalMemoizedMaskedChildContext;var d={},h;for(h in i)d[h]=r[h];return c&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=d),d}function Vt(e){return e=e.childContextTypes,e!=null}function Ba(){lt(Ht),lt($t)}function Ku(e,r,i){if($t.current!==Qn)throw Error(a(168));st($t,r),st(Ht,i)}function qu(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,ce(e)||"Unknown",d));return q({},i,c)}function Da(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Qn,fr=$t.current,st($t,e),st(Ht,Ht.current),!0}function Yu(e,r,i){var c=e.stateNode;if(!c)throw Error(a(169));i?(e=qu(e,r,fr),c.__reactInternalMemoizedMergedChildContext=e,lt(Ht),lt($t),st($t,e)):lt(Ht),st(Ht,i)}var Pn=null,Ua=!1,Bo=!1;function Ju(e){Pn===null?Pn=[e]:Pn.push(e)}function Dg(e){Ua=!0,Ju(e)}function Xn(){if(!Bo&&Pn!==null){Bo=!0;var e=0,r=et;try{var i=Pn;for(et=1;e<i.length;e++){var c=i[e];do c=c(!0);while(c!==null)}Pn=null,Ua=!1}catch(d){throw Pn!==null&&(Pn=Pn.slice(e+1)),Xc(oo,Xn),d}finally{et=r,Bo=!1}}return null}var Kr=[],qr=0,Wa=null,Ha=0,sn=[],an=0,mr=null,$n=1,_n="";function hr(e,r){Kr[qr++]=Ha,Kr[qr++]=Wa,Wa=e,Ha=r}function Qu(e,r,i){sn[an++]=$n,sn[an++]=_n,sn[an++]=mr,mr=e;var c=$n;e=_n;var d=32-mn(c)-1;c&=~(1<<d),i+=1;var h=32-mn(r)+d;if(30<h){var w=d-d%5;h=(c&(1<<w)-1).toString(32),c>>=w,d-=w,$n=1<<32-mn(r)+d|i<<d|c,_n=h+e}else $n=1<<h|i<<d|c,_n=e}function Do(e){e.return!==null&&(hr(e,1),Qu(e,1,0))}function Uo(e){for(;e===Wa;)Wa=Kr[--qr],Kr[qr]=null,Ha=Kr[--qr],Kr[qr]=null;for(;e===mr;)mr=sn[--an],sn[an]=null,_n=sn[--an],sn[an]=null,$n=sn[--an],sn[an]=null}var en=null,tn=null,ct=!1,pn=null;function Xu(e,r){var i=un(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 Zu(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,en=e,tn=Yn(r.firstChild),!0):!1;case 6:return r=e.pendingProps===""||r.nodeType!==3?null:r,r!==null?(e.stateNode=r,en=e,tn=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(i=mr!==null?{id:$n,overflow:_n}:null,e.memoizedState={dehydrated:r,treeContext:i,retryLane:1073741824},i=un(18,null,null,0),i.stateNode=r,i.return=e,e.child=i,en=e,tn=null,!0):!1;default:return!1}}function Wo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Ho(e){if(ct){var r=tn;if(r){var i=r;if(!Zu(e,r)){if(Wo(e))throw Error(a(418));r=Yn(i.nextSibling);var c=en;r&&Zu(e,r)?Xu(c,i):(e.flags=e.flags&-4097|2,ct=!1,en=e)}}else{if(Wo(e))throw Error(a(418));e.flags=e.flags&-4097|2,ct=!1,en=e}}}function ed(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;en=e}function Va(e){if(e!==en)return!1;if(!ct)return ed(e),ct=!0,!1;var r;if((r=e.tag!==3)&&!(r=e.tag!==5)&&(r=e.type,r=r!=="head"&&r!=="body"&&!Lo(e.type,e.memoizedProps)),r&&(r=tn)){if(Wo(e))throw td(),Error(a(418));for(;r;)Xu(e,r),r=Yn(r.nextSibling)}if(ed(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){tn=Yn(e.nextSibling);break e}r--}else i!=="$"&&i!=="$!"&&i!=="$?"||r++}e=e.nextSibling}tn=null}}else tn=en?Yn(e.stateNode.nextSibling):null;return!0}function td(){for(var e=tn;e;)e=Yn(e.nextSibling)}function Yr(){tn=en=null,ct=!1}function Vo(e){pn===null?pn=[e]:pn.push(e)}var Ug=A.ReactCurrentBatchConfig;function zs(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,h=""+e;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===h?r.ref:(r=function(w){var C=d.refs;w===null?delete C[h]:C[h]=w},r._stringRef=h,r)}if(typeof e!="string")throw Error(a(284));if(!i._owner)throw Error(a(290,e))}return e}function Ga(e,r){throw e=Object.prototype.toString.call(r),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":e))}function nd(e){var r=e._init;return r(e._payload)}function rd(e){function r(M,_){if(e){var U=M.deletions;U===null?(M.deletions=[_],M.flags|=16):U.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=ir(M,_),M.index=0,M.sibling=null,M}function h(M,_,U){return M.index=U,e?(U=M.alternate,U!==null?(U=U.index,U<_?(M.flags|=2,_):U):(M.flags|=2,_)):(M.flags|=1048576,_)}function w(M){return e&&M.alternate===null&&(M.flags|=2),M}function C(M,_,U,de){return _===null||_.tag!==6?(_=zl(U,M.mode,de),_.return=M,_):(_=d(_,U),_.return=M,_)}function R(M,_,U,de){var Ee=U.type;return Ee===K?ae(M,_,U.props.children,de,U.key):_!==null&&(_.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===ve&&nd(Ee)===_.type)?(de=d(_,U.props),de.ref=zs(M,_,U),de.return=M,de):(de=gi(U.type,U.key,U.props,null,M.mode,de),de.ref=zs(M,_,U),de.return=M,de)}function V(M,_,U,de){return _===null||_.tag!==4||_.stateNode.containerInfo!==U.containerInfo||_.stateNode.implementation!==U.implementation?(_=Fl(U,M.mode,de),_.return=M,_):(_=d(_,U.children||[]),_.return=M,_)}function ae(M,_,U,de,Ee){return _===null||_.tag!==7?(_=Sr(U,M.mode,de,Ee),_.return=M,_):(_=d(_,U),_.return=M,_)}function le(M,_,U){if(typeof _=="string"&&_!==""||typeof _=="number")return _=zl(""+_,M.mode,U),_.return=M,_;if(typeof _=="object"&&_!==null){switch(_.$$typeof){case D:return U=gi(_.type,_.key,_.props,null,M.mode,U),U.ref=zs(M,null,_),U.return=M,U;case O:return _=Fl(_,M.mode,U),_.return=M,_;case ve:var de=_._init;return le(M,de(_._payload),U)}if(Qe(_)||X(_))return _=Sr(_,M.mode,U,null),_.return=M,_;Ga(M,_)}return null}function se(M,_,U,de){var Ee=_!==null?_.key:null;if(typeof U=="string"&&U!==""||typeof U=="number")return Ee!==null?null:C(M,_,""+U,de);if(typeof U=="object"&&U!==null){switch(U.$$typeof){case D:return U.key===Ee?R(M,_,U,de):null;case O:return U.key===Ee?V(M,_,U,de):null;case ve:return Ee=U._init,se(M,_,Ee(U._payload),de)}if(Qe(U)||X(U))return Ee!==null?null:ae(M,_,U,de,null);Ga(M,U)}return null}function je(M,_,U,de,Ee){if(typeof de=="string"&&de!==""||typeof de=="number")return M=M.get(U)||null,C(_,M,""+de,Ee);if(typeof de=="object"&&de!==null){switch(de.$$typeof){case D:return M=M.get(de.key===null?U:de.key)||null,R(_,M,de,Ee);case O:return M=M.get(de.key===null?U:de.key)||null,V(_,M,de,Ee);case ve:var Re=de._init;return je(M,_,U,Re(de._payload),Ee)}if(Qe(de)||X(de))return M=M.get(U)||null,ae(_,M,de,Ee,null);Ga(_,de)}return null}function ke(M,_,U,de){for(var Ee=null,Re=null,Pe=_,Le=_=0,It=null;Pe!==null&&Le<U.length;Le++){Pe.index>Le?(It=Pe,Pe=null):It=Pe.sibling;var Je=se(M,Pe,U[Le],de);if(Je===null){Pe===null&&(Pe=It);break}e&&Pe&&Je.alternate===null&&r(M,Pe),_=h(Je,_,Le),Re===null?Ee=Je:Re.sibling=Je,Re=Je,Pe=It}if(Le===U.length)return i(M,Pe),ct&&hr(M,Le),Ee;if(Pe===null){for(;Le<U.length;Le++)Pe=le(M,U[Le],de),Pe!==null&&(_=h(Pe,_,Le),Re===null?Ee=Pe:Re.sibling=Pe,Re=Pe);return ct&&hr(M,Le),Ee}for(Pe=c(M,Pe);Le<U.length;Le++)It=je(Pe,M,Le,U[Le],de),It!==null&&(e&&It.alternate!==null&&Pe.delete(It.key===null?Le:It.key),_=h(It,_,Le),Re===null?Ee=It:Re.sibling=It,Re=It);return e&&Pe.forEach(function(or){return r(M,or)}),ct&&hr(M,Le),Ee}function Ne(M,_,U,de){var Ee=X(U);if(typeof Ee!="function")throw Error(a(150));if(U=Ee.call(U),U==null)throw Error(a(151));for(var Re=Ee=null,Pe=_,Le=_=0,It=null,Je=U.next();Pe!==null&&!Je.done;Le++,Je=U.next()){Pe.index>Le?(It=Pe,Pe=null):It=Pe.sibling;var or=se(M,Pe,Je.value,de);if(or===null){Pe===null&&(Pe=It);break}e&&Pe&&or.alternate===null&&r(M,Pe),_=h(or,_,Le),Re===null?Ee=or:Re.sibling=or,Re=or,Pe=It}if(Je.done)return i(M,Pe),ct&&hr(M,Le),Ee;if(Pe===null){for(;!Je.done;Le++,Je=U.next())Je=le(M,Je.value,de),Je!==null&&(_=h(Je,_,Le),Re===null?Ee=Je:Re.sibling=Je,Re=Je);return ct&&hr(M,Le),Ee}for(Pe=c(M,Pe);!Je.done;Le++,Je=U.next())Je=je(Pe,M,Le,Je.value,de),Je!==null&&(e&&Je.alternate!==null&&Pe.delete(Je.key===null?Le:Je.key),_=h(Je,_,Le),Re===null?Ee=Je:Re.sibling=Je,Re=Je);return e&&Pe.forEach(function(jy){return r(M,jy)}),ct&&hr(M,Le),Ee}function vt(M,_,U,de){if(typeof U=="object"&&U!==null&&U.type===K&&U.key===null&&(U=U.props.children),typeof U=="object"&&U!==null){switch(U.$$typeof){case D:e:{for(var Ee=U.key,Re=_;Re!==null;){if(Re.key===Ee){if(Ee=U.type,Ee===K){if(Re.tag===7){i(M,Re.sibling),_=d(Re,U.props.children),_.return=M,M=_;break e}}else if(Re.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===ve&&nd(Ee)===Re.type){i(M,Re.sibling),_=d(Re,U.props),_.ref=zs(M,Re,U),_.return=M,M=_;break e}i(M,Re);break}else r(M,Re);Re=Re.sibling}U.type===K?(_=Sr(U.props.children,M.mode,de,U.key),_.return=M,M=_):(de=gi(U.type,U.key,U.props,null,M.mode,de),de.ref=zs(M,_,U),de.return=M,M=de)}return w(M);case O:e:{for(Re=U.key;_!==null;){if(_.key===Re)if(_.tag===4&&_.stateNode.containerInfo===U.containerInfo&&_.stateNode.implementation===U.implementation){i(M,_.sibling),_=d(_,U.children||[]),_.return=M,M=_;break e}else{i(M,_);break}else r(M,_);_=_.sibling}_=Fl(U,M.mode,de),_.return=M,M=_}return w(M);case ve:return Re=U._init,vt(M,_,Re(U._payload),de)}if(Qe(U))return ke(M,_,U,de);if(X(U))return Ne(M,_,U,de);Ga(M,U)}return typeof U=="string"&&U!==""||typeof U=="number"?(U=""+U,_!==null&&_.tag===6?(i(M,_.sibling),_=d(_,U),_.return=M,M=_):(i(M,_),_=zl(U,M.mode,de),_.return=M,M=_),w(M)):i(M,_)}return vt}var Jr=rd(!0),sd=rd(!1),Ka=Jn(null),qa=null,Qr=null,Go=null;function Ko(){Go=Qr=qa=null}function qo(e){var r=Ka.current;lt(Ka),e._currentValue=r}function Yo(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 Xr(e,r){qa=e,Go=Qr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&r)!==0&&(Gt=!0),e.firstContext=null)}function on(e){var r=e._currentValue;if(Go!==e)if(e={context:e,memoizedValue:r,next:null},Qr===null){if(qa===null)throw Error(a(308));Qr=e,qa.dependencies={lanes:0,firstContext:e}}else Qr=Qr.next=e;return r}var pr=null;function Jo(e){pr===null?pr=[e]:pr.push(e)}function ad(e,r,i,c){var d=r.interleaved;return d===null?(i.next=i,Jo(r)):(i.next=d.next,d.next=i),r.interleaved=i,Ln(e,c)}function Ln(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 Zn=!1;function Qo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function id(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 zn(e,r){return{eventTime:e,lane:r,tag:0,payload:null,callback:null,next:null}}function er(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,Ln(e,i)}return d=c.interleaved,d===null?(r.next=r,Jo(c)):(r.next=d.next,d.next=r),c.interleaved=r,Ln(e,i)}function Ya(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,uo(e,i)}}function od(e,r){var i=e.updateQueue,c=e.alternate;if(c!==null&&(c=c.updateQueue,i===c)){var d=null,h=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};h===null?d=h=w:h=h.next=w,i=i.next}while(i!==null);h===null?d=h=r:h=h.next=r}else d=h=r;i={baseState:c.baseState,firstBaseUpdate:d,lastBaseUpdate:h,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 Ja(e,r,i,c){var d=e.updateQueue;Zn=!1;var h=d.firstBaseUpdate,w=d.lastBaseUpdate,C=d.shared.pending;if(C!==null){d.shared.pending=null;var R=C,V=R.next;R.next=null,w===null?h=V:w.next=V,w=R;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,C=ae.lastBaseUpdate,C!==w&&(C===null?ae.firstBaseUpdate=V:C.next=V,ae.lastBaseUpdate=R))}if(h!==null){var le=d.baseState;w=0,ae=V=R=null,C=h;do{var se=C.lane,je=C.eventTime;if((c&se)===se){ae!==null&&(ae=ae.next={eventTime:je,lane:0,tag:C.tag,payload:C.payload,callback:C.callback,next:null});e:{var ke=e,Ne=C;switch(se=r,je=i,Ne.tag){case 1:if(ke=Ne.payload,typeof ke=="function"){le=ke.call(je,le,se);break e}le=ke;break e;case 3:ke.flags=ke.flags&-65537|128;case 0:if(ke=Ne.payload,se=typeof ke=="function"?ke.call(je,le,se):ke,se==null)break e;le=q({},le,se);break e;case 2:Zn=!0}}C.callback!==null&&C.lane!==0&&(e.flags|=64,se=d.effects,se===null?d.effects=[C]:se.push(C))}else je={eventTime:je,lane:se,tag:C.tag,payload:C.payload,callback:C.callback,next:null},ae===null?(V=ae=je,R=le):ae=ae.next=je,w|=se;if(C=C.next,C===null){if(C=d.shared.pending,C===null)break;se=C,C=se.next,se.next=null,d.lastBaseUpdate=se,d.shared.pending=null}}while(!0);if(ae===null&&(R=le),d.baseState=R,d.firstBaseUpdate=V,d.lastBaseUpdate=ae,r=d.shared.interleaved,r!==null){d=r;do w|=d.lane,d=d.next;while(d!==r)}else h===null&&(d.shared.lanes=0);vr|=w,e.lanes=w,e.memoizedState=le}}function ld(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 Fs={},En=Jn(Fs),Ms=Jn(Fs),Os=Jn(Fs);function gr(e){if(e===Fs)throw Error(a(174));return e}function Xo(e,r){switch(st(Os,r),st(Ms,e),st(En,Fs),e=r.nodeType,e){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Oe(null,"");break;default:e=e===8?r.parentNode:r,r=e.namespaceURI||null,e=e.tagName,r=Oe(r,e)}lt(En),st(En,r)}function Zr(){lt(En),lt(Ms),lt(Os)}function cd(e){gr(Os.current);var r=gr(En.current),i=Oe(r,e.type);r!==i&&(st(Ms,e),st(En,i))}function Zo(e){Ms.current===e&&(lt(En),lt(Ms))}var dt=Jn(0);function Qa(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 el=[];function tl(){for(var e=0;e<el.length;e++)el[e]._workInProgressVersionPrimary=null;el.length=0}var Xa=A.ReactCurrentDispatcher,nl=A.ReactCurrentBatchConfig,yr=0,ft=null,bt=null,Et=null,Za=!1,Bs=!1,Ds=0,Wg=0;function _t(){throw Error(a(321))}function rl(e,r){if(r===null)return!1;for(var i=0;i<r.length&&i<e.length;i++)if(!hn(e[i],r[i]))return!1;return!0}function sl(e,r,i,c,d,h){if(yr=h,ft=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Xa.current=e===null||e.memoizedState===null?Kg:qg,e=i(c,d),Bs){h=0;do{if(Bs=!1,Ds=0,25<=h)throw Error(a(301));h+=1,Et=bt=null,r.updateQueue=null,Xa.current=Yg,e=i(c,d)}while(Bs)}if(Xa.current=ni,r=bt!==null&&bt.next!==null,yr=0,Et=bt=ft=null,Za=!1,r)throw Error(a(300));return e}function al(){var e=Ds!==0;return Ds=0,e}function Tn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Et===null?ft.memoizedState=Et=e:Et=Et.next=e,Et}function ln(){if(bt===null){var e=ft.alternate;e=e!==null?e.memoizedState:null}else e=bt.next;var r=Et===null?ft.memoizedState:Et.next;if(r!==null)Et=r,bt=e;else{if(e===null)throw Error(a(310));bt=e,e={memoizedState:bt.memoizedState,baseState:bt.baseState,baseQueue:bt.baseQueue,queue:bt.queue,next:null},Et===null?ft.memoizedState=Et=e:Et=Et.next=e}return Et}function Us(e,r){return typeof r=="function"?r(e):r}function il(e){var r=ln(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=e;var c=bt,d=c.baseQueue,h=i.pending;if(h!==null){if(d!==null){var w=d.next;d.next=h.next,h.next=w}c.baseQueue=d=h,i.pending=null}if(d!==null){h=d.next,c=c.baseState;var C=w=null,R=null,V=h;do{var ae=V.lane;if((yr&ae)===ae)R!==null&&(R=R.next={lane:0,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),c=V.hasEagerState?V.eagerState:e(c,V.action);else{var le={lane:ae,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null};R===null?(C=R=le,w=c):R=R.next=le,ft.lanes|=ae,vr|=ae}V=V.next}while(V!==null&&V!==h);R===null?w=c:R.next=C,hn(c,r.memoizedState)||(Gt=!0),r.memoizedState=c,r.baseState=w,r.baseQueue=R,i.lastRenderedState=c}if(e=i.interleaved,e!==null){d=e;do h=d.lane,ft.lanes|=h,vr|=h,d=d.next;while(d!==e)}else d===null&&(i.lanes=0);return[r.memoizedState,i.dispatch]}function ol(e){var r=ln(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=e;var c=i.dispatch,d=i.pending,h=r.memoizedState;if(d!==null){i.pending=null;var w=d=d.next;do h=e(h,w.action),w=w.next;while(w!==d);hn(h,r.memoizedState)||(Gt=!0),r.memoizedState=h,r.baseQueue===null&&(r.baseState=h),i.lastRenderedState=h}return[h,c]}function ud(){}function dd(e,r){var i=ft,c=ln(),d=r(),h=!hn(c.memoizedState,d);if(h&&(c.memoizedState=d,Gt=!0),c=c.queue,ll(hd.bind(null,i,c,e),[e]),c.getSnapshot!==r||h||Et!==null&&Et.memoizedState.tag&1){if(i.flags|=2048,Ws(9,md.bind(null,i,c,d,r),void 0,null),Tt===null)throw Error(a(349));(yr&30)!==0||fd(i,r,d)}return d}function fd(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 md(e,r,i,c){r.value=i,r.getSnapshot=c,pd(r)&&gd(e)}function hd(e,r,i){return i(function(){pd(r)&&gd(e)})}function pd(e){var r=e.getSnapshot;e=e.value;try{var i=r();return!hn(e,i)}catch{return!0}}function gd(e){var r=Ln(e,1);r!==null&&xn(r,e,1,-1)}function yd(e){var r=Tn();return typeof e=="function"&&(e=e()),r.memoizedState=r.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Us,lastRenderedState:e},r.queue=e,e=e.dispatch=Gg.bind(null,ft,e),[r.memoizedState,e]}function Ws(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 vd(){return ln().memoizedState}function ei(e,r,i,c){var d=Tn();ft.flags|=e,d.memoizedState=Ws(1|r,i,void 0,c===void 0?null:c)}function ti(e,r,i,c){var d=ln();c=c===void 0?null:c;var h=void 0;if(bt!==null){var w=bt.memoizedState;if(h=w.destroy,c!==null&&rl(c,w.deps)){d.memoizedState=Ws(r,i,h,c);return}}ft.flags|=e,d.memoizedState=Ws(1|r,i,h,c)}function xd(e,r){return ei(8390656,8,e,r)}function ll(e,r){return ti(2048,8,e,r)}function wd(e,r){return ti(4,2,e,r)}function jd(e,r){return ti(4,4,e,r)}function Sd(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 bd(e,r,i){return i=i!=null?i.concat([e]):null,ti(4,4,Sd.bind(null,r,e),i)}function cl(){}function kd(e,r){var i=ln();r=r===void 0?null:r;var c=i.memoizedState;return c!==null&&r!==null&&rl(r,c[1])?c[0]:(i.memoizedState=[e,r],e)}function Nd(e,r){var i=ln();r=r===void 0?null:r;var c=i.memoizedState;return c!==null&&r!==null&&rl(r,c[1])?c[0]:(e=e(),i.memoizedState=[e,r],e)}function Cd(e,r,i){return(yr&21)===0?(e.baseState&&(e.baseState=!1,Gt=!0),e.memoizedState=i):(hn(i,r)||(i=nu(),ft.lanes|=i,vr|=i,e.baseState=!0),r)}function Hg(e,r){var i=et;et=i!==0&&4>i?i:4,e(!0);var c=nl.transition;nl.transition={};try{e(!1),r()}finally{et=i,nl.transition=c}}function Ed(){return ln().memoizedState}function Vg(e,r,i){var c=sr(e);if(i={lane:c,action:i,hasEagerState:!1,eagerState:null,next:null},Td(e))Id(r,i);else if(i=ad(e,r,i,c),i!==null){var d=Dt();xn(i,e,c,d),Ad(i,r,c)}}function Gg(e,r,i){var c=sr(e),d={lane:c,action:i,hasEagerState:!1,eagerState:null,next:null};if(Td(e))Id(r,d);else{var h=e.alternate;if(e.lanes===0&&(h===null||h.lanes===0)&&(h=r.lastRenderedReducer,h!==null))try{var w=r.lastRenderedState,C=h(w,i);if(d.hasEagerState=!0,d.eagerState=C,hn(C,w)){var R=r.interleaved;R===null?(d.next=d,Jo(r)):(d.next=R.next,R.next=d),r.interleaved=d;return}}catch{}finally{}i=ad(e,r,d,c),i!==null&&(d=Dt(),xn(i,e,c,d),Ad(i,r,c))}}function Td(e){var r=e.alternate;return e===ft||r!==null&&r===ft}function Id(e,r){Bs=Za=!0;var i=e.pending;i===null?r.next=r:(r.next=i.next,i.next=r),e.pending=r}function Ad(e,r,i){if((i&4194240)!==0){var c=r.lanes;c&=e.pendingLanes,i|=c,r.lanes=i,uo(e,i)}}var ni={readContext:on,useCallback:_t,useContext:_t,useEffect:_t,useImperativeHandle:_t,useInsertionEffect:_t,useLayoutEffect:_t,useMemo:_t,useReducer:_t,useRef:_t,useState:_t,useDebugValue:_t,useDeferredValue:_t,useTransition:_t,useMutableSource:_t,useSyncExternalStore:_t,useId:_t,unstable_isNewReconciler:!1},Kg={readContext:on,useCallback:function(e,r){return Tn().memoizedState=[e,r===void 0?null:r],e},useContext:on,useEffect:xd,useImperativeHandle:function(e,r,i){return i=i!=null?i.concat([e]):null,ei(4194308,4,Sd.bind(null,r,e),i)},useLayoutEffect:function(e,r){return ei(4194308,4,e,r)},useInsertionEffect:function(e,r){return ei(4,2,e,r)},useMemo:function(e,r){var i=Tn();return r=r===void 0?null:r,e=e(),i.memoizedState=[e,r],e},useReducer:function(e,r,i){var c=Tn();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=Vg.bind(null,ft,e),[c.memoizedState,e]},useRef:function(e){var r=Tn();return e={current:e},r.memoizedState=e},useState:yd,useDebugValue:cl,useDeferredValue:function(e){return Tn().memoizedState=e},useTransition:function(){var e=yd(!1),r=e[0];return e=Hg.bind(null,e[1]),Tn().memoizedState=e,[r,e]},useMutableSource:function(){},useSyncExternalStore:function(e,r,i){var c=ft,d=Tn();if(ct){if(i===void 0)throw Error(a(407));i=i()}else{if(i=r(),Tt===null)throw Error(a(349));(yr&30)!==0||fd(c,r,i)}d.memoizedState=i;var h={value:i,getSnapshot:r};return d.queue=h,xd(hd.bind(null,c,h,e),[e]),c.flags|=2048,Ws(9,md.bind(null,c,h,i,r),void 0,null),i},useId:function(){var e=Tn(),r=Tt.identifierPrefix;if(ct){var i=_n,c=$n;i=(c&~(1<<32-mn(c)-1)).toString(32)+i,r=":"+r+"R"+i,i=Ds++,0<i&&(r+="H"+i.toString(32)),r+=":"}else i=Wg++,r=":"+r+"r"+i.toString(32)+":";return e.memoizedState=r},unstable_isNewReconciler:!1},qg={readContext:on,useCallback:kd,useContext:on,useEffect:ll,useImperativeHandle:bd,useInsertionEffect:wd,useLayoutEffect:jd,useMemo:Nd,useReducer:il,useRef:vd,useState:function(){return il(Us)},useDebugValue:cl,useDeferredValue:function(e){var r=ln();return Cd(r,bt.memoizedState,e)},useTransition:function(){var e=il(Us)[0],r=ln().memoizedState;return[e,r]},useMutableSource:ud,useSyncExternalStore:dd,useId:Ed,unstable_isNewReconciler:!1},Yg={readContext:on,useCallback:kd,useContext:on,useEffect:ll,useImperativeHandle:bd,useInsertionEffect:wd,useLayoutEffect:jd,useMemo:Nd,useReducer:ol,useRef:vd,useState:function(){return ol(Us)},useDebugValue:cl,useDeferredValue:function(e){var r=ln();return bt===null?r.memoizedState=e:Cd(r,bt.memoizedState,e)},useTransition:function(){var e=ol(Us)[0],r=ln().memoizedState;return[e,r]},useMutableSource:ud,useSyncExternalStore:dd,useId:Ed,unstable_isNewReconciler:!1};function gn(e,r){if(e&&e.defaultProps){r=q({},r),e=e.defaultProps;for(var i in e)r[i]===void 0&&(r[i]=e[i]);return r}return r}function ul(e,r,i,c){r=e.memoizedState,i=i(c,r),i=i==null?r:q({},r,i),e.memoizedState=i,e.lanes===0&&(e.updateQueue.baseState=i)}var ri={isMounted:function(e){return(e=e._reactInternals)?bn(e)===e:!1},enqueueSetState:function(e,r,i){e=e._reactInternals;var c=Dt(),d=sr(e),h=zn(c,d);h.payload=r,i!=null&&(h.callback=i),r=er(e,h,d),r!==null&&(xn(r,e,d,c),Ya(r,e,d))},enqueueReplaceState:function(e,r,i){e=e._reactInternals;var c=Dt(),d=sr(e),h=zn(c,d);h.tag=1,h.payload=r,i!=null&&(h.callback=i),r=er(e,h,d),r!==null&&(xn(r,e,d,c),Ya(r,e,d))},enqueueForceUpdate:function(e,r){e=e._reactInternals;var i=Dt(),c=sr(e),d=zn(i,c);d.tag=2,r!=null&&(d.callback=r),r=er(e,d,c),r!==null&&(xn(r,e,c,i),Ya(r,e,c))}};function Rd(e,r,i,c,d,h,w){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(c,h,w):r.prototype&&r.prototype.isPureReactComponent?!Is(i,c)||!Is(d,h):!0}function Pd(e,r,i){var c=!1,d=Qn,h=r.contextType;return typeof h=="object"&&h!==null?h=on(h):(d=Vt(r)?fr:$t.current,c=r.contextTypes,h=(c=c!=null)?Gr(e,d):Qn),r=new r(i,h),e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=ri,e.stateNode=r,r._reactInternals=e,c&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=d,e.__reactInternalMemoizedMaskedChildContext=h),r}function $d(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&&ri.enqueueReplaceState(r,r.state,null)}function dl(e,r,i,c){var d=e.stateNode;d.props=i,d.state=e.memoizedState,d.refs={},Qo(e);var h=r.contextType;typeof h=="object"&&h!==null?d.context=on(h):(h=Vt(r)?fr:$t.current,d.context=Gr(e,h)),d.state=e.memoizedState,h=r.getDerivedStateFromProps,typeof h=="function"&&(ul(e,r,h,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&&ri.enqueueReplaceState(d,d.state,null),Ja(e,i,d,c),d.state=e.memoizedState),typeof d.componentDidMount=="function"&&(e.flags|=4194308)}function es(e,r){try{var i="",c=r;do i+=B(c),c=c.return;while(c);var d=i}catch(h){d=`
39
+ Error generating stack: `+h.message+`
40
+ `+h.stack}return{value:e,source:r,stack:d,digest:null}}function fl(e,r,i){return{value:e,source:null,stack:i??null,digest:r??null}}function ml(e,r){try{console.error(r.value)}catch(i){setTimeout(function(){throw i})}}var Jg=typeof WeakMap=="function"?WeakMap:Map;function _d(e,r,i){i=zn(-1,i),i.tag=3,i.payload={element:null};var c=r.value;return i.callback=function(){ui||(ui=!0,Tl=c),ml(e,r)},i}function Ld(e,r,i){i=zn(-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(){ml(e,r)}}var h=e.stateNode;return h!==null&&typeof h.componentDidCatch=="function"&&(i.callback=function(){ml(e,r),typeof c!="function"&&(nr===null?nr=new Set([this]):nr.add(this));var w=r.stack;this.componentDidCatch(r.value,{componentStack:w!==null?w:""})}),i}function zd(e,r,i){var c=e.pingCache;if(c===null){c=e.pingCache=new Jg;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=uy.bind(null,e,r,i),r.then(e,e))}function Fd(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 Md(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=zn(-1,1),r.tag=2,er(i,r,1))),i.lanes|=1),e):(e.flags|=65536,e.lanes=d,e)}var Qg=A.ReactCurrentOwner,Gt=!1;function Bt(e,r,i,c){r.child=e===null?sd(r,null,i,c):Jr(r,e.child,i,c)}function Od(e,r,i,c,d){i=i.render;var h=r.ref;return Xr(r,d),c=sl(e,r,i,c,h,d),i=al(),e!==null&&!Gt?(r.updateQueue=e.updateQueue,r.flags&=-2053,e.lanes&=~d,Fn(e,r,d)):(ct&&i&&Do(r),r.flags|=1,Bt(e,r,c,d),r.child)}function Bd(e,r,i,c,d){if(e===null){var h=i.type;return typeof h=="function"&&!Ll(h)&&h.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(r.tag=15,r.type=h,Dd(e,r,h,c,d)):(e=gi(i.type,null,c,r,r.mode,d),e.ref=r.ref,e.return=r,r.child=e)}if(h=e.child,(e.lanes&d)===0){var w=h.memoizedProps;if(i=i.compare,i=i!==null?i:Is,i(w,c)&&e.ref===r.ref)return Fn(e,r,d)}return r.flags|=1,e=ir(h,c),e.ref=r.ref,e.return=r,r.child=e}function Dd(e,r,i,c,d){if(e!==null){var h=e.memoizedProps;if(Is(h,c)&&e.ref===r.ref)if(Gt=!1,r.pendingProps=c=h,(e.lanes&d)!==0)(e.flags&131072)!==0&&(Gt=!0);else return r.lanes=e.lanes,Fn(e,r,d)}return hl(e,r,i,c,d)}function Ud(e,r,i){var c=r.pendingProps,d=c.children,h=e!==null?e.memoizedState:null;if(c.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},st(ns,nn),nn|=i;else{if((i&1073741824)===0)return e=h!==null?h.baseLanes|i:i,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:e,cachePool:null,transitions:null},r.updateQueue=null,st(ns,nn),nn|=e,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=h!==null?h.baseLanes:i,st(ns,nn),nn|=c}else h!==null?(c=h.baseLanes|i,r.memoizedState=null):c=i,st(ns,nn),nn|=c;return Bt(e,r,d,i),r.child}function Wd(e,r){var i=r.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(r.flags|=512,r.flags|=2097152)}function hl(e,r,i,c,d){var h=Vt(i)?fr:$t.current;return h=Gr(r,h),Xr(r,d),i=sl(e,r,i,c,h,d),c=al(),e!==null&&!Gt?(r.updateQueue=e.updateQueue,r.flags&=-2053,e.lanes&=~d,Fn(e,r,d)):(ct&&c&&Do(r),r.flags|=1,Bt(e,r,i,d),r.child)}function Hd(e,r,i,c,d){if(Vt(i)){var h=!0;Da(r)}else h=!1;if(Xr(r,d),r.stateNode===null)ai(e,r),Pd(r,i,c),dl(r,i,c,d),c=!0;else if(e===null){var w=r.stateNode,C=r.memoizedProps;w.props=C;var R=w.context,V=i.contextType;typeof V=="object"&&V!==null?V=on(V):(V=Vt(i)?fr:$t.current,V=Gr(r,V));var ae=i.getDerivedStateFromProps,le=typeof ae=="function"||typeof w.getSnapshotBeforeUpdate=="function";le||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(C!==c||R!==V)&&$d(r,w,c,V),Zn=!1;var se=r.memoizedState;w.state=se,Ja(r,c,w,d),R=r.memoizedState,C!==c||se!==R||Ht.current||Zn?(typeof ae=="function"&&(ul(r,i,ae,c),R=r.memoizedState),(C=Zn||Rd(r,i,C,c,se,R,V))?(le||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount()),typeof w.componentDidMount=="function"&&(r.flags|=4194308)):(typeof w.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=R),w.props=c,w.state=R,w.context=V,c=C):(typeof w.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{w=r.stateNode,id(e,r),C=r.memoizedProps,V=r.type===r.elementType?C:gn(r.type,C),w.props=V,le=r.pendingProps,se=w.context,R=i.contextType,typeof R=="object"&&R!==null?R=on(R):(R=Vt(i)?fr:$t.current,R=Gr(r,R));var je=i.getDerivedStateFromProps;(ae=typeof je=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(C!==le||se!==R)&&$d(r,w,c,R),Zn=!1,se=r.memoizedState,w.state=se,Ja(r,c,w,d);var ke=r.memoizedState;C!==le||se!==ke||Ht.current||Zn?(typeof je=="function"&&(ul(r,i,je,c),ke=r.memoizedState),(V=Zn||Rd(r,i,V,c,se,ke,R)||!1)?(ae||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(c,ke,R),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(c,ke,R)),typeof w.componentDidUpdate=="function"&&(r.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof w.componentDidUpdate!="function"||C===e.memoizedProps&&se===e.memoizedState||(r.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||C===e.memoizedProps&&se===e.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=ke),w.props=c,w.state=ke,w.context=R,c=V):(typeof w.componentDidUpdate!="function"||C===e.memoizedProps&&se===e.memoizedState||(r.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||C===e.memoizedProps&&se===e.memoizedState||(r.flags|=1024),c=!1)}return pl(e,r,i,c,h,d)}function pl(e,r,i,c,d,h){Wd(e,r);var w=(r.flags&128)!==0;if(!c&&!w)return d&&Yu(r,i,!1),Fn(e,r,h);c=r.stateNode,Qg.current=r;var C=w&&typeof i.getDerivedStateFromError!="function"?null:c.render();return r.flags|=1,e!==null&&w?(r.child=Jr(r,e.child,null,h),r.child=Jr(r,null,C,h)):Bt(e,r,C,h),r.memoizedState=c.state,d&&Yu(r,i,!0),r.child}function Vd(e){var r=e.stateNode;r.pendingContext?Ku(e,r.pendingContext,r.pendingContext!==r.context):r.context&&Ku(e,r.context,!1),Xo(e,r.containerInfo)}function Gd(e,r,i,c,d){return Yr(),Vo(d),r.flags|=256,Bt(e,r,i,c),r.child}var gl={dehydrated:null,treeContext:null,retryLane:0};function yl(e){return{baseLanes:e,cachePool:null,transitions:null}}function Kd(e,r,i){var c=r.pendingProps,d=dt.current,h=!1,w=(r.flags&128)!==0,C;if((C=w)||(C=e!==null&&e.memoizedState===null?!1:(d&2)!==0),C?(h=!0,r.flags&=-129):(e===null||e.memoizedState!==null)&&(d|=1),st(dt,d&1),e===null)return Ho(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,h?(c=r.mode,h=r.child,w={mode:"hidden",children:w},(c&1)===0&&h!==null?(h.childLanes=0,h.pendingProps=w):h=yi(w,c,0,null),e=Sr(e,c,i,null),h.return=r,e.return=r,h.sibling=e,r.child=h,r.child.memoizedState=yl(i),r.memoizedState=gl,e):vl(r,w));if(d=e.memoizedState,d!==null&&(C=d.dehydrated,C!==null))return Xg(e,r,w,c,C,d,i);if(h){h=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=ir(d,R),c.subtreeFlags=d.subtreeFlags&14680064),C!==null?h=ir(C,h):(h=Sr(h,w,i,null),h.flags|=2),h.return=r,c.return=r,c.sibling=h,r.child=c,c=h,h=r.child,w=e.child.memoizedState,w=w===null?yl(i):{baseLanes:w.baseLanes|i,cachePool:null,transitions:w.transitions},h.memoizedState=w,h.childLanes=e.childLanes&~i,r.memoizedState=gl,c}return h=e.child,e=h.sibling,c=ir(h,{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 vl(e,r){return r=yi({mode:"visible",children:r},e.mode,0,null),r.return=e,e.child=r}function si(e,r,i,c){return c!==null&&Vo(c),Jr(r,e.child,null,i),e=vl(r,r.pendingProps.children),e.flags|=2,r.memoizedState=null,e}function Xg(e,r,i,c,d,h,w){if(i)return r.flags&256?(r.flags&=-257,c=fl(Error(a(422))),si(e,r,w,c)):r.memoizedState!==null?(r.child=e.child,r.flags|=128,null):(h=c.fallback,d=r.mode,c=yi({mode:"visible",children:c.children},d,0,null),h=Sr(h,d,w,null),h.flags|=2,c.return=r,h.return=r,c.sibling=h,r.child=c,(r.mode&1)!==0&&Jr(r,e.child,null,w),r.child.memoizedState=yl(w),r.memoizedState=gl,h);if((r.mode&1)===0)return si(e,r,w,null);if(d.data==="$!"){if(c=d.nextSibling&&d.nextSibling.dataset,c)var C=c.dgst;return c=C,h=Error(a(419)),c=fl(h,c,void 0),si(e,r,w,c)}if(C=(w&e.childLanes)!==0,Gt||C){if(c=Tt,c!==null){switch(w&-w){case 4:d=2;break;case 16:d=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(c.suspendedLanes|w))!==0?0:d,d!==0&&d!==h.retryLane&&(h.retryLane=d,Ln(e,d),xn(c,e,d,-1))}return _l(),c=fl(Error(a(421))),si(e,r,w,c)}return d.data==="$?"?(r.flags|=128,r.child=e.child,r=dy.bind(null,e),d._reactRetry=r,null):(e=h.treeContext,tn=Yn(d.nextSibling),en=r,ct=!0,pn=null,e!==null&&(sn[an++]=$n,sn[an++]=_n,sn[an++]=mr,$n=e.id,_n=e.overflow,mr=r),r=vl(r,c.children),r.flags|=4096,r)}function qd(e,r,i){e.lanes|=r;var c=e.alternate;c!==null&&(c.lanes|=r),Yo(e.return,r,i)}function xl(e,r,i,c,d){var h=e.memoizedState;h===null?e.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:i,tailMode:d}:(h.isBackwards=r,h.rendering=null,h.renderingStartTime=0,h.last=c,h.tail=i,h.tailMode=d)}function Yd(e,r,i){var c=r.pendingProps,d=c.revealOrder,h=c.tail;if(Bt(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&&qd(e,i,r);else if(e.tag===19)qd(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(st(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&&Qa(e)===null&&(d=i),i=i.sibling;i=d,i===null?(d=r.child,r.child=null):(d=i.sibling,i.sibling=null),xl(r,!1,d,i,h);break;case"backwards":for(i=null,d=r.child,r.child=null;d!==null;){if(e=d.alternate,e!==null&&Qa(e)===null){r.child=d;break}e=d.sibling,d.sibling=i,i=d,d=e}xl(r,!0,i,null,h);break;case"together":xl(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function ai(e,r){(r.mode&1)===0&&e!==null&&(e.alternate=null,r.alternate=null,r.flags|=2)}function Fn(e,r,i){if(e!==null&&(r.dependencies=e.dependencies),vr|=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=ir(e,e.pendingProps),r.child=i,i.return=r;e.sibling!==null;)e=e.sibling,i=i.sibling=ir(e,e.pendingProps),i.return=r;i.sibling=null}return r.child}function Zg(e,r,i){switch(r.tag){case 3:Vd(r),Yr();break;case 5:cd(r);break;case 1:Vt(r.type)&&Da(r);break;case 4:Xo(r,r.stateNode.containerInfo);break;case 10:var c=r.type._context,d=r.memoizedProps.value;st(Ka,c._currentValue),c._currentValue=d;break;case 13:if(c=r.memoizedState,c!==null)return c.dehydrated!==null?(st(dt,dt.current&1),r.flags|=128,null):(i&r.child.childLanes)!==0?Kd(e,r,i):(st(dt,dt.current&1),e=Fn(e,r,i),e!==null?e.sibling:null);st(dt,dt.current&1);break;case 19:if(c=(i&r.childLanes)!==0,(e.flags&128)!==0){if(c)return Yd(e,r,i);r.flags|=128}if(d=r.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),st(dt,dt.current),c)break;return null;case 22:case 23:return r.lanes=0,Ud(e,r,i)}return Fn(e,r,i)}var Jd,wl,Qd,Xd;Jd=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}},wl=function(){},Qd=function(e,r,i,c){var d=e.memoizedProps;if(d!==c){e=r.stateNode,gr(En.current);var h=null;switch(i){case"input":d=$e(e,d),c=$e(e,c),h=[];break;case"select":d=q({},d,{value:void 0}),c=q({},c,{value:void 0}),h=[];break;case"textarea":d=jt(e,d),c=jt(e,c),h=[];break;default:typeof d.onClick!="function"&&typeof c.onClick=="function"&&(e.onclick=Ma)}Ze(i,c);var w;i=null;for(V in d)if(!c.hasOwnProperty(V)&&d.hasOwnProperty(V)&&d[V]!=null)if(V==="style"){var C=d[V];for(w in C)C.hasOwnProperty(w)&&(i||(i={}),i[w]="")}else V!=="dangerouslySetInnerHTML"&&V!=="children"&&V!=="suppressContentEditableWarning"&&V!=="suppressHydrationWarning"&&V!=="autoFocus"&&(l.hasOwnProperty(V)?h||(h=[]):(h=h||[]).push(V,null));for(V in c){var R=c[V];if(C=d!=null?d[V]:void 0,c.hasOwnProperty(V)&&R!==C&&(R!=null||C!=null))if(V==="style")if(C){for(w in C)!C.hasOwnProperty(w)||R&&R.hasOwnProperty(w)||(i||(i={}),i[w]="");for(w in R)R.hasOwnProperty(w)&&C[w]!==R[w]&&(i||(i={}),i[w]=R[w])}else i||(h||(h=[]),h.push(V,i)),i=R;else V==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,C=C?C.__html:void 0,R!=null&&C!==R&&(h=h||[]).push(V,R)):V==="children"?typeof R!="string"&&typeof R!="number"||(h=h||[]).push(V,""+R):V!=="suppressContentEditableWarning"&&V!=="suppressHydrationWarning"&&(l.hasOwnProperty(V)?(R!=null&&V==="onScroll"&&ot("scroll",e),h||C===R||(h=[])):(h=h||[]).push(V,R))}i&&(h=h||[]).push("style",i);var V=h;(r.updateQueue=V)&&(r.flags|=4)}},Xd=function(e,r,i,c){i!==c&&(r.flags|=4)};function Hs(e,r){if(!ct)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 Lt(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 ey(e,r,i){var c=r.pendingProps;switch(Uo(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Lt(r),null;case 1:return Vt(r.type)&&Ba(),Lt(r),null;case 3:return c=r.stateNode,Zr(),lt(Ht),lt($t),tl(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(e===null||e.child===null)&&(Va(r)?r.flags|=4:e===null||e.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,pn!==null&&(Rl(pn),pn=null))),wl(e,r),Lt(r),null;case 5:Zo(r);var d=gr(Os.current);if(i=r.type,e!==null&&r.stateNode!=null)Qd(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 Lt(r),null}if(e=gr(En.current),Va(r)){c=r.stateNode,i=r.type;var h=r.memoizedProps;switch(c[Cn]=r,c[_s]=h,e=(r.mode&1)!==0,i){case"dialog":ot("cancel",c),ot("close",c);break;case"iframe":case"object":case"embed":ot("load",c);break;case"video":case"audio":for(d=0;d<Rs.length;d++)ot(Rs[d],c);break;case"source":ot("error",c);break;case"img":case"image":case"link":ot("error",c),ot("load",c);break;case"details":ot("toggle",c);break;case"input":_e(c,h),ot("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!h.multiple},ot("invalid",c);break;case"textarea":pt(c,h),ot("invalid",c)}Ze(i,h),d=null;for(var w in h)if(h.hasOwnProperty(w)){var C=h[w];w==="children"?typeof C=="string"?c.textContent!==C&&(h.suppressHydrationWarning!==!0&&Fa(c.textContent,C,e),d=["children",C]):typeof C=="number"&&c.textContent!==""+C&&(h.suppressHydrationWarning!==!0&&Fa(c.textContent,C,e),d=["children",""+C]):l.hasOwnProperty(w)&&C!=null&&w==="onScroll"&&ot("scroll",c)}switch(i){case"input":Ge(c),it(c,h,!0);break;case"textarea":Ge(c),me(c);break;case"select":case"option":break;default:typeof h.onClick=="function"&&(c.onclick=Ma)}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=Ie(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[Cn]=r,e[_s]=c,Jd(e,r,!1,!1),r.stateNode=e;e:{switch(w=H(i,c),i){case"dialog":ot("cancel",e),ot("close",e),d=c;break;case"iframe":case"object":case"embed":ot("load",e),d=c;break;case"video":case"audio":for(d=0;d<Rs.length;d++)ot(Rs[d],e);d=c;break;case"source":ot("error",e),d=c;break;case"img":case"image":case"link":ot("error",e),ot("load",e),d=c;break;case"details":ot("toggle",e),d=c;break;case"input":_e(e,c),d=$e(e,c),ot("invalid",e);break;case"option":d=c;break;case"select":e._wrapperState={wasMultiple:!!c.multiple},d=q({},c,{value:void 0}),ot("invalid",e);break;case"textarea":pt(e,c),d=jt(e,c),ot("invalid",e);break;default:d=c}Ze(i,d),C=d;for(h in C)if(C.hasOwnProperty(h)){var R=C[h];h==="style"?Wt(e,R):h==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,R!=null&&J(e,R)):h==="children"?typeof R=="string"?(i!=="textarea"||R!=="")&&ge(e,R):typeof R=="number"&&ge(e,""+R):h!=="suppressContentEditableWarning"&&h!=="suppressHydrationWarning"&&h!=="autoFocus"&&(l.hasOwnProperty(h)?R!=null&&h==="onScroll"&&ot("scroll",e):R!=null&&P(e,h,R,w))}switch(i){case"input":Ge(e),it(e,c,!1);break;case"textarea":Ge(e),me(e);break;case"option":c.value!=null&&e.setAttribute("value",""+pe(c.value));break;case"select":e.multiple=!!c.multiple,h=c.value,h!=null?Ye(e,!!c.multiple,h,!1):c.defaultValue!=null&&Ye(e,!!c.multiple,c.defaultValue,!0);break;default:typeof d.onClick=="function"&&(e.onclick=Ma)}switch(i){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return Lt(r),null;case 6:if(e&&r.stateNode!=null)Xd(e,r,e.memoizedProps,c);else{if(typeof c!="string"&&r.stateNode===null)throw Error(a(166));if(i=gr(Os.current),gr(En.current),Va(r)){if(c=r.stateNode,i=r.memoizedProps,c[Cn]=r,(h=c.nodeValue!==i)&&(e=en,e!==null))switch(e.tag){case 3:Fa(c.nodeValue,i,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Fa(c.nodeValue,i,(e.mode&1)!==0)}h&&(r.flags|=4)}else c=(i.nodeType===9?i:i.ownerDocument).createTextNode(c),c[Cn]=r,r.stateNode=c}return Lt(r),null;case 13:if(lt(dt),c=r.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ct&&tn!==null&&(r.mode&1)!==0&&(r.flags&128)===0)td(),Yr(),r.flags|=98560,h=!1;else if(h=Va(r),c!==null&&c.dehydrated!==null){if(e===null){if(!h)throw Error(a(318));if(h=r.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(a(317));h[Cn]=r}else Yr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Lt(r),h=!1}else pn!==null&&(Rl(pn),pn=null),h=!0;if(!h)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?kt===0&&(kt=3):_l())),r.updateQueue!==null&&(r.flags|=4),Lt(r),null);case 4:return Zr(),wl(e,r),e===null&&Ps(r.stateNode.containerInfo),Lt(r),null;case 10:return qo(r.type._context),Lt(r),null;case 17:return Vt(r.type)&&Ba(),Lt(r),null;case 19:if(lt(dt),h=r.memoizedState,h===null)return Lt(r),null;if(c=(r.flags&128)!==0,w=h.rendering,w===null)if(c)Hs(h,!1);else{if(kt!==0||e!==null&&(e.flags&128)!==0)for(e=r.child;e!==null;){if(w=Qa(e),w!==null){for(r.flags|=128,Hs(h,!1),c=w.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),r.subtreeFlags=0,c=i,i=r.child;i!==null;)h=i,e=c,h.flags&=14680066,w=h.alternate,w===null?(h.childLanes=0,h.lanes=e,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=w.childLanes,h.lanes=w.lanes,h.child=w.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=w.memoizedProps,h.memoizedState=w.memoizedState,h.updateQueue=w.updateQueue,h.type=w.type,e=w.dependencies,h.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),i=i.sibling;return st(dt,dt.current&1|2),r.child}e=e.sibling}h.tail!==null&&yt()>rs&&(r.flags|=128,c=!0,Hs(h,!1),r.lanes=4194304)}else{if(!c)if(e=Qa(w),e!==null){if(r.flags|=128,c=!0,i=e.updateQueue,i!==null&&(r.updateQueue=i,r.flags|=4),Hs(h,!0),h.tail===null&&h.tailMode==="hidden"&&!w.alternate&&!ct)return Lt(r),null}else 2*yt()-h.renderingStartTime>rs&&i!==1073741824&&(r.flags|=128,c=!0,Hs(h,!1),r.lanes=4194304);h.isBackwards?(w.sibling=r.child,r.child=w):(i=h.last,i!==null?i.sibling=w:r.child=w,h.last=w)}return h.tail!==null?(r=h.tail,h.rendering=r,h.tail=r.sibling,h.renderingStartTime=yt(),r.sibling=null,i=dt.current,st(dt,c?i&1|2:i&1),r):(Lt(r),null);case 22:case 23:return $l(),c=r.memoizedState!==null,e!==null&&e.memoizedState!==null!==c&&(r.flags|=8192),c&&(r.mode&1)!==0?(nn&1073741824)!==0&&(Lt(r),r.subtreeFlags&6&&(r.flags|=8192)):Lt(r),null;case 24:return null;case 25:return null}throw Error(a(156,r.tag))}function ty(e,r){switch(Uo(r),r.tag){case 1:return Vt(r.type)&&Ba(),e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 3:return Zr(),lt(Ht),lt($t),tl(),e=r.flags,(e&65536)!==0&&(e&128)===0?(r.flags=e&-65537|128,r):null;case 5:return Zo(r),null;case 13:if(lt(dt),e=r.memoizedState,e!==null&&e.dehydrated!==null){if(r.alternate===null)throw Error(a(340));Yr()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 19:return lt(dt),null;case 4:return Zr(),null;case 10:return qo(r.type._context),null;case 22:case 23:return $l(),null;case 24:return null;default:return null}}var ii=!1,zt=!1,ny=typeof WeakSet=="function"?WeakSet:Set,Se=null;function ts(e,r){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(c){mt(e,r,c)}else i.current=null}function jl(e,r,i){try{i()}catch(c){mt(e,r,c)}}var Zd=!1;function ry(e,r){if($o=Ca,e=Ru(),No(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,h=c.focusNode;c=c.focusOffset;try{i.nodeType,h.nodeType}catch{i=null;break e}var w=0,C=-1,R=-1,V=0,ae=0,le=e,se=null;t:for(;;){for(var je;le!==i||d!==0&&le.nodeType!==3||(C=w+d),le!==h||c!==0&&le.nodeType!==3||(R=w+c),le.nodeType===3&&(w+=le.nodeValue.length),(je=le.firstChild)!==null;)se=le,le=je;for(;;){if(le===e)break t;if(se===i&&++V===d&&(C=w),se===h&&++ae===c&&(R=w),(je=le.nextSibling)!==null)break;le=se,se=le.parentNode}le=je}i=C===-1||R===-1?null:{start:C,end:R}}else i=null}i=i||{start:0,end:0}}else i=null;for(_o={focusedElem:e,selectionRange:i},Ca=!1,Se=r;Se!==null;)if(r=Se,e=r.child,(r.subtreeFlags&1028)!==0&&e!==null)e.return=r,Se=e;else for(;Se!==null;){r=Se;try{var ke=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(ke!==null){var Ne=ke.memoizedProps,vt=ke.memoizedState,M=r.stateNode,_=M.getSnapshotBeforeUpdate(r.elementType===r.type?Ne:gn(r.type,Ne),vt);M.__reactInternalSnapshotBeforeUpdate=_}break;case 3:var U=r.stateNode.containerInfo;U.nodeType===1?U.textContent="":U.nodeType===9&&U.documentElement&&U.removeChild(U.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(de){mt(r,r.return,de)}if(e=r.sibling,e!==null){e.return=r.return,Se=e;break}Se=r.return}return ke=Zd,Zd=!1,ke}function Vs(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 h=d.destroy;d.destroy=void 0,h!==void 0&&jl(r,i,h)}d=d.next}while(d!==c)}}function oi(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 Sl(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 ef(e){var r=e.alternate;r!==null&&(e.alternate=null,ef(r)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(r=e.stateNode,r!==null&&(delete r[Cn],delete r[_s],delete r[Mo],delete r[Og],delete r[Bg])),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 tf(e){return e.tag===5||e.tag===3||e.tag===4}function nf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||tf(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 bl(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=Ma));else if(c!==4&&(e=e.child,e!==null))for(bl(e,r,i),e=e.sibling;e!==null;)bl(e,r,i),e=e.sibling}function kl(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(kl(e,r,i),e=e.sibling;e!==null;)kl(e,r,i),e=e.sibling}var At=null,yn=!1;function tr(e,r,i){for(i=i.child;i!==null;)rf(e,r,i),i=i.sibling}function rf(e,r,i){if(Nn&&typeof Nn.onCommitFiberUnmount=="function")try{Nn.onCommitFiberUnmount(wa,i)}catch{}switch(i.tag){case 5:zt||ts(i,r);case 6:var c=At,d=yn;At=null,tr(e,r,i),At=c,yn=d,At!==null&&(yn?(e=At,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):At.removeChild(i.stateNode));break;case 18:At!==null&&(yn?(e=At,i=i.stateNode,e.nodeType===8?Fo(e.parentNode,i):e.nodeType===1&&Fo(e,i),bs(e)):Fo(At,i.stateNode));break;case 4:c=At,d=yn,At=i.stateNode.containerInfo,yn=!0,tr(e,r,i),At=c,yn=d;break;case 0:case 11:case 14:case 15:if(!zt&&(c=i.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){d=c=c.next;do{var h=d,w=h.destroy;h=h.tag,w!==void 0&&((h&2)!==0||(h&4)!==0)&&jl(i,r,w),d=d.next}while(d!==c)}tr(e,r,i);break;case 1:if(!zt&&(ts(i,r),c=i.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=i.memoizedProps,c.state=i.memoizedState,c.componentWillUnmount()}catch(C){mt(i,r,C)}tr(e,r,i);break;case 21:tr(e,r,i);break;case 22:i.mode&1?(zt=(c=zt)||i.memoizedState!==null,tr(e,r,i),zt=c):tr(e,r,i);break;default:tr(e,r,i)}}function sf(e){var r=e.updateQueue;if(r!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new ny),r.forEach(function(c){var d=fy.bind(null,e,c);i.has(c)||(i.add(c),c.then(d,d))})}}function vn(e,r){var i=r.deletions;if(i!==null)for(var c=0;c<i.length;c++){var d=i[c];try{var h=e,w=r,C=w;e:for(;C!==null;){switch(C.tag){case 5:At=C.stateNode,yn=!1;break e;case 3:At=C.stateNode.containerInfo,yn=!0;break e;case 4:At=C.stateNode.containerInfo,yn=!0;break e}C=C.return}if(At===null)throw Error(a(160));rf(h,w,d),At=null,yn=!1;var R=d.alternate;R!==null&&(R.return=null),d.return=null}catch(V){mt(d,r,V)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)af(r,e),r=r.sibling}function af(e,r){var i=e.alternate,c=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(vn(r,e),In(e),c&4){try{Vs(3,e,e.return),oi(3,e)}catch(Ne){mt(e,e.return,Ne)}try{Vs(5,e,e.return)}catch(Ne){mt(e,e.return,Ne)}}break;case 1:vn(r,e),In(e),c&512&&i!==null&&ts(i,i.return);break;case 5:if(vn(r,e),In(e),c&512&&i!==null&&ts(i,i.return),e.flags&32){var d=e.stateNode;try{ge(d,"")}catch(Ne){mt(e,e.return,Ne)}}if(c&4&&(d=e.stateNode,d!=null)){var h=e.memoizedProps,w=i!==null?i.memoizedProps:h,C=e.type,R=e.updateQueue;if(e.updateQueue=null,R!==null)try{C==="input"&&h.type==="radio"&&h.name!=null&&Be(d,h),H(C,w);var V=H(C,h);for(w=0;w<R.length;w+=2){var ae=R[w],le=R[w+1];ae==="style"?Wt(d,le):ae==="dangerouslySetInnerHTML"?J(d,le):ae==="children"?ge(d,le):P(d,ae,le,V)}switch(C){case"input":ze(d,h);break;case"textarea":Me(d,h);break;case"select":var se=d._wrapperState.wasMultiple;d._wrapperState.wasMultiple=!!h.multiple;var je=h.value;je!=null?Ye(d,!!h.multiple,je,!1):se!==!!h.multiple&&(h.defaultValue!=null?Ye(d,!!h.multiple,h.defaultValue,!0):Ye(d,!!h.multiple,h.multiple?[]:"",!1))}d[_s]=h}catch(Ne){mt(e,e.return,Ne)}}break;case 6:if(vn(r,e),In(e),c&4){if(e.stateNode===null)throw Error(a(162));d=e.stateNode,h=e.memoizedProps;try{d.nodeValue=h}catch(Ne){mt(e,e.return,Ne)}}break;case 3:if(vn(r,e),In(e),c&4&&i!==null&&i.memoizedState.isDehydrated)try{bs(r.containerInfo)}catch(Ne){mt(e,e.return,Ne)}break;case 4:vn(r,e),In(e);break;case 13:vn(r,e),In(e),d=e.child,d.flags&8192&&(h=d.memoizedState!==null,d.stateNode.isHidden=h,!h||d.alternate!==null&&d.alternate.memoizedState!==null||(El=yt())),c&4&&sf(e);break;case 22:if(ae=i!==null&&i.memoizedState!==null,e.mode&1?(zt=(V=zt)||ae,vn(r,e),zt=V):vn(r,e),In(e),c&8192){if(V=e.memoizedState!==null,(e.stateNode.isHidden=V)&&!ae&&(e.mode&1)!==0)for(Se=e,ae=e.child;ae!==null;){for(le=Se=ae;Se!==null;){switch(se=Se,je=se.child,se.tag){case 0:case 11:case 14:case 15:Vs(4,se,se.return);break;case 1:ts(se,se.return);var ke=se.stateNode;if(typeof ke.componentWillUnmount=="function"){c=se,i=se.return;try{r=c,ke.props=r.memoizedProps,ke.state=r.memoizedState,ke.componentWillUnmount()}catch(Ne){mt(c,i,Ne)}}break;case 5:ts(se,se.return);break;case 22:if(se.memoizedState!==null){cf(le);continue}}je!==null?(je.return=se,Se=je):cf(le)}ae=ae.sibling}e:for(ae=null,le=e;;){if(le.tag===5){if(ae===null){ae=le;try{d=le.stateNode,V?(h=d.style,typeof h.setProperty=="function"?h.setProperty("display","none","important"):h.display="none"):(C=le.stateNode,R=le.memoizedProps.style,w=R!=null&&R.hasOwnProperty("display")?R.display:null,C.style.display=nt("display",w))}catch(Ne){mt(e,e.return,Ne)}}}else if(le.tag===6){if(ae===null)try{le.stateNode.nodeValue=V?"":le.memoizedProps}catch(Ne){mt(e,e.return,Ne)}}else if((le.tag!==22&&le.tag!==23||le.memoizedState===null||le===e)&&le.child!==null){le.child.return=le,le=le.child;continue}if(le===e)break e;for(;le.sibling===null;){if(le.return===null||le.return===e)break e;ae===le&&(ae=null),le=le.return}ae===le&&(ae=null),le.sibling.return=le.return,le=le.sibling}}break;case 19:vn(r,e),In(e),c&4&&sf(e);break;case 21:break;default:vn(r,e),In(e)}}function In(e){var r=e.flags;if(r&2){try{e:{for(var i=e.return;i!==null;){if(tf(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&&(ge(d,""),c.flags&=-33);var h=nf(e);kl(e,h,d);break;case 3:case 4:var w=c.stateNode.containerInfo,C=nf(e);bl(e,C,w);break;default:throw Error(a(161))}}catch(R){mt(e,e.return,R)}e.flags&=-3}r&4096&&(e.flags&=-4097)}function sy(e,r,i){Se=e,of(e)}function of(e,r,i){for(var c=(e.mode&1)!==0;Se!==null;){var d=Se,h=d.child;if(d.tag===22&&c){var w=d.memoizedState!==null||ii;if(!w){var C=d.alternate,R=C!==null&&C.memoizedState!==null||zt;C=ii;var V=zt;if(ii=w,(zt=R)&&!V)for(Se=d;Se!==null;)w=Se,R=w.child,w.tag===22&&w.memoizedState!==null?uf(d):R!==null?(R.return=w,Se=R):uf(d);for(;h!==null;)Se=h,of(h),h=h.sibling;Se=d,ii=C,zt=V}lf(e)}else(d.subtreeFlags&8772)!==0&&h!==null?(h.return=d,Se=h):lf(e)}}function lf(e){for(;Se!==null;){var r=Se;if((r.flags&8772)!==0){var i=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:zt||oi(5,r);break;case 1:var c=r.stateNode;if(r.flags&4&&!zt)if(i===null)c.componentDidMount();else{var d=r.elementType===r.type?i.memoizedProps:gn(r.type,i.memoizedProps);c.componentDidUpdate(d,i.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var h=r.updateQueue;h!==null&&ld(r,h,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}ld(r,w,i)}break;case 5:var C=r.stateNode;if(i===null&&r.flags&4){i=C;var R=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":R.autoFocus&&i.focus();break;case"img":R.src&&(i.src=R.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var V=r.alternate;if(V!==null){var ae=V.memoizedState;if(ae!==null){var le=ae.dehydrated;le!==null&&bs(le)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}zt||r.flags&512&&Sl(r)}catch(se){mt(r,r.return,se)}}if(r===e){Se=null;break}if(i=r.sibling,i!==null){i.return=r.return,Se=i;break}Se=r.return}}function cf(e){for(;Se!==null;){var r=Se;if(r===e){Se=null;break}var i=r.sibling;if(i!==null){i.return=r.return,Se=i;break}Se=r.return}}function uf(e){for(;Se!==null;){var r=Se;try{switch(r.tag){case 0:case 11:case 15:var i=r.return;try{oi(4,r)}catch(R){mt(r,i,R)}break;case 1:var c=r.stateNode;if(typeof c.componentDidMount=="function"){var d=r.return;try{c.componentDidMount()}catch(R){mt(r,d,R)}}var h=r.return;try{Sl(r)}catch(R){mt(r,h,R)}break;case 5:var w=r.return;try{Sl(r)}catch(R){mt(r,w,R)}}}catch(R){mt(r,r.return,R)}if(r===e){Se=null;break}var C=r.sibling;if(C!==null){C.return=r.return,Se=C;break}Se=r.return}}var ay=Math.ceil,li=A.ReactCurrentDispatcher,Nl=A.ReactCurrentOwner,cn=A.ReactCurrentBatchConfig,qe=0,Tt=null,wt=null,Rt=0,nn=0,ns=Jn(0),kt=0,Gs=null,vr=0,ci=0,Cl=0,Ks=null,Kt=null,El=0,rs=1/0,Mn=null,ui=!1,Tl=null,nr=null,di=!1,rr=null,fi=0,qs=0,Il=null,mi=-1,hi=0;function Dt(){return(qe&6)!==0?yt():mi!==-1?mi:mi=yt()}function sr(e){return(e.mode&1)===0?1:(qe&2)!==0&&Rt!==0?Rt&-Rt:Ug.transition!==null?(hi===0&&(hi=nu()),hi):(e=et,e!==0||(e=window.event,e=e===void 0?16:du(e.type)),e)}function xn(e,r,i,c){if(50<qs)throw qs=0,Il=null,Error(a(185));vs(e,i,c),((qe&2)===0||e!==Tt)&&(e===Tt&&((qe&2)===0&&(ci|=i),kt===4&&ar(e,Rt)),qt(e,c),i===1&&qe===0&&(r.mode&1)===0&&(rs=yt()+500,Ua&&Xn()))}function qt(e,r){var i=e.callbackNode;Up(e,r);var c=ba(e,e===Tt?Rt:0);if(c===0)i!==null&&Zc(i),e.callbackNode=null,e.callbackPriority=0;else if(r=c&-c,e.callbackPriority!==r){if(i!=null&&Zc(i),r===1)e.tag===0?Dg(ff.bind(null,e)):Ju(ff.bind(null,e)),Fg(function(){(qe&6)===0&&Xn()}),i=null;else{switch(ru(c)){case 1:i=oo;break;case 4:i=eu;break;case 16:i=xa;break;case 536870912:i=tu;break;default:i=xa}i=wf(i,df.bind(null,e))}e.callbackPriority=r,e.callbackNode=i}}function df(e,r){if(mi=-1,hi=0,(qe&6)!==0)throw Error(a(327));var i=e.callbackNode;if(ss()&&e.callbackNode!==i)return null;var c=ba(e,e===Tt?Rt:0);if(c===0)return null;if((c&30)!==0||(c&e.expiredLanes)!==0||r)r=pi(e,c);else{r=c;var d=qe;qe|=2;var h=hf();(Tt!==e||Rt!==r)&&(Mn=null,rs=yt()+500,wr(e,r));do try{ly();break}catch(C){mf(e,C)}while(!0);Ko(),li.current=h,qe=d,wt!==null?r=0:(Tt=null,Rt=0,r=kt)}if(r!==0){if(r===2&&(d=lo(e),d!==0&&(c=d,r=Al(e,d))),r===1)throw i=Gs,wr(e,0),ar(e,c),qt(e,yt()),i;if(r===6)ar(e,c);else{if(d=e.current.alternate,(c&30)===0&&!iy(d)&&(r=pi(e,c),r===2&&(h=lo(e),h!==0&&(c=h,r=Al(e,h))),r===1))throw i=Gs,wr(e,0),ar(e,c),qt(e,yt()),i;switch(e.finishedWork=d,e.finishedLanes=c,r){case 0:case 1:throw Error(a(345));case 2:jr(e,Kt,Mn);break;case 3:if(ar(e,c),(c&130023424)===c&&(r=El+500-yt(),10<r)){if(ba(e,0)!==0)break;if(d=e.suspendedLanes,(d&c)!==c){Dt(),e.pingedLanes|=e.suspendedLanes&d;break}e.timeoutHandle=zo(jr.bind(null,e,Kt,Mn),r);break}jr(e,Kt,Mn);break;case 4:if(ar(e,c),(c&4194240)===c)break;for(r=e.eventTimes,d=-1;0<c;){var w=31-mn(c);h=1<<w,w=r[w],w>d&&(d=w),c&=~h}if(c=d,c=yt()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*ay(c/1960))-c,10<c){e.timeoutHandle=zo(jr.bind(null,e,Kt,Mn),c);break}jr(e,Kt,Mn);break;case 5:jr(e,Kt,Mn);break;default:throw Error(a(329))}}}return qt(e,yt()),e.callbackNode===i?df.bind(null,e):null}function Al(e,r){var i=Ks;return e.current.memoizedState.isDehydrated&&(wr(e,r).flags|=256),e=pi(e,r),e!==2&&(r=Kt,Kt=i,r!==null&&Rl(r)),e}function Rl(e){Kt===null?Kt=e:Kt.push.apply(Kt,e)}function iy(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],h=d.getSnapshot;d=d.value;try{if(!hn(h(),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 ar(e,r){for(r&=~Cl,r&=~ci,e.suspendedLanes|=r,e.pingedLanes&=~r,e=e.expirationTimes;0<r;){var i=31-mn(r),c=1<<i;e[i]=-1,r&=~c}}function ff(e){if((qe&6)!==0)throw Error(a(327));ss();var r=ba(e,0);if((r&1)===0)return qt(e,yt()),null;var i=pi(e,r);if(e.tag!==0&&i===2){var c=lo(e);c!==0&&(r=c,i=Al(e,c))}if(i===1)throw i=Gs,wr(e,0),ar(e,r),qt(e,yt()),i;if(i===6)throw Error(a(345));return e.finishedWork=e.current.alternate,e.finishedLanes=r,jr(e,Kt,Mn),qt(e,yt()),null}function Pl(e,r){var i=qe;qe|=1;try{return e(r)}finally{qe=i,qe===0&&(rs=yt()+500,Ua&&Xn())}}function xr(e){rr!==null&&rr.tag===0&&(qe&6)===0&&ss();var r=qe;qe|=1;var i=cn.transition,c=et;try{if(cn.transition=null,et=1,e)return e()}finally{et=c,cn.transition=i,qe=r,(qe&6)===0&&Xn()}}function $l(){nn=ns.current,lt(ns)}function wr(e,r){e.finishedWork=null,e.finishedLanes=0;var i=e.timeoutHandle;if(i!==-1&&(e.timeoutHandle=-1,zg(i)),wt!==null)for(i=wt.return;i!==null;){var c=i;switch(Uo(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Ba();break;case 3:Zr(),lt(Ht),lt($t),tl();break;case 5:Zo(c);break;case 4:Zr();break;case 13:lt(dt);break;case 19:lt(dt);break;case 10:qo(c.type._context);break;case 22:case 23:$l()}i=i.return}if(Tt=e,wt=e=ir(e.current,null),Rt=nn=r,kt=0,Gs=null,Cl=ci=vr=0,Kt=Ks=null,pr!==null){for(r=0;r<pr.length;r++)if(i=pr[r],c=i.interleaved,c!==null){i.interleaved=null;var d=c.next,h=i.pending;if(h!==null){var w=h.next;h.next=d,c.next=w}i.pending=c}pr=null}return e}function mf(e,r){do{var i=wt;try{if(Ko(),Xa.current=ni,Za){for(var c=ft.memoizedState;c!==null;){var d=c.queue;d!==null&&(d.pending=null),c=c.next}Za=!1}if(yr=0,Et=bt=ft=null,Bs=!1,Ds=0,Nl.current=null,i===null||i.return===null){kt=1,Gs=r,wt=null;break}e:{var h=e,w=i.return,C=i,R=r;if(r=Rt,C.flags|=32768,R!==null&&typeof R=="object"&&typeof R.then=="function"){var V=R,ae=C,le=ae.tag;if((ae.mode&1)===0&&(le===0||le===11||le===15)){var se=ae.alternate;se?(ae.updateQueue=se.updateQueue,ae.memoizedState=se.memoizedState,ae.lanes=se.lanes):(ae.updateQueue=null,ae.memoizedState=null)}var je=Fd(w);if(je!==null){je.flags&=-257,Md(je,w,C,h,r),je.mode&1&&zd(h,V,r),r=je,R=V;var ke=r.updateQueue;if(ke===null){var Ne=new Set;Ne.add(R),r.updateQueue=Ne}else ke.add(R);break e}else{if((r&1)===0){zd(h,V,r),_l();break e}R=Error(a(426))}}else if(ct&&C.mode&1){var vt=Fd(w);if(vt!==null){(vt.flags&65536)===0&&(vt.flags|=256),Md(vt,w,C,h,r),Vo(es(R,C));break e}}h=R=es(R,C),kt!==4&&(kt=2),Ks===null?Ks=[h]:Ks.push(h),h=w;do{switch(h.tag){case 3:h.flags|=65536,r&=-r,h.lanes|=r;var M=_d(h,R,r);od(h,M);break e;case 1:C=R;var _=h.type,U=h.stateNode;if((h.flags&128)===0&&(typeof _.getDerivedStateFromError=="function"||U!==null&&typeof U.componentDidCatch=="function"&&(nr===null||!nr.has(U)))){h.flags|=65536,r&=-r,h.lanes|=r;var de=Ld(h,C,r);od(h,de);break e}}h=h.return}while(h!==null)}gf(i)}catch(Ee){r=Ee,wt===i&&i!==null&&(wt=i=i.return);continue}break}while(!0)}function hf(){var e=li.current;return li.current=ni,e===null?ni:e}function _l(){(kt===0||kt===3||kt===2)&&(kt=4),Tt===null||(vr&268435455)===0&&(ci&268435455)===0||ar(Tt,Rt)}function pi(e,r){var i=qe;qe|=2;var c=hf();(Tt!==e||Rt!==r)&&(Mn=null,wr(e,r));do try{oy();break}catch(d){mf(e,d)}while(!0);if(Ko(),qe=i,li.current=c,wt!==null)throw Error(a(261));return Tt=null,Rt=0,kt}function oy(){for(;wt!==null;)pf(wt)}function ly(){for(;wt!==null&&!$p();)pf(wt)}function pf(e){var r=xf(e.alternate,e,nn);e.memoizedProps=e.pendingProps,r===null?gf(e):wt=r,Nl.current=null}function gf(e){var r=e;do{var i=r.alternate;if(e=r.return,(r.flags&32768)===0){if(i=ey(i,r,nn),i!==null){wt=i;return}}else{if(i=ty(i,r),i!==null){i.flags&=32767,wt=i;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{kt=6,wt=null;return}}if(r=r.sibling,r!==null){wt=r;return}wt=r=e}while(r!==null);kt===0&&(kt=5)}function jr(e,r,i){var c=et,d=cn.transition;try{cn.transition=null,et=1,cy(e,r,i,c)}finally{cn.transition=d,et=c}return null}function cy(e,r,i,c){do ss();while(rr!==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 h=i.lanes|i.childLanes;if(Wp(e,h),e===Tt&&(wt=Tt=null,Rt=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||di||(di=!0,wf(xa,function(){return ss(),null})),h=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||h){h=cn.transition,cn.transition=null;var w=et;et=1;var C=qe;qe|=4,Nl.current=null,ry(e,i),af(i,e),Ig(_o),Ca=!!$o,_o=$o=null,e.current=i,sy(i),_p(),qe=C,et=w,cn.transition=h}else e.current=i;if(di&&(di=!1,rr=e,fi=d),h=e.pendingLanes,h===0&&(nr=null),Fp(i.stateNode),qt(e,yt()),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(ui)throw ui=!1,e=Tl,Tl=null,e;return(fi&1)!==0&&e.tag!==0&&ss(),h=e.pendingLanes,(h&1)!==0?e===Il?qs++:(qs=0,Il=e):qs=0,Xn(),null}function ss(){if(rr!==null){var e=ru(fi),r=cn.transition,i=et;try{if(cn.transition=null,et=16>e?16:e,rr===null)var c=!1;else{if(e=rr,rr=null,fi=0,(qe&6)!==0)throw Error(a(331));var d=qe;for(qe|=4,Se=e.current;Se!==null;){var h=Se,w=h.child;if((Se.flags&16)!==0){var C=h.deletions;if(C!==null){for(var R=0;R<C.length;R++){var V=C[R];for(Se=V;Se!==null;){var ae=Se;switch(ae.tag){case 0:case 11:case 15:Vs(8,ae,h)}var le=ae.child;if(le!==null)le.return=ae,Se=le;else for(;Se!==null;){ae=Se;var se=ae.sibling,je=ae.return;if(ef(ae),ae===V){Se=null;break}if(se!==null){se.return=je,Se=se;break}Se=je}}}var ke=h.alternate;if(ke!==null){var Ne=ke.child;if(Ne!==null){ke.child=null;do{var vt=Ne.sibling;Ne.sibling=null,Ne=vt}while(Ne!==null)}}Se=h}}if((h.subtreeFlags&2064)!==0&&w!==null)w.return=h,Se=w;else e:for(;Se!==null;){if(h=Se,(h.flags&2048)!==0)switch(h.tag){case 0:case 11:case 15:Vs(9,h,h.return)}var M=h.sibling;if(M!==null){M.return=h.return,Se=M;break e}Se=h.return}}var _=e.current;for(Se=_;Se!==null;){w=Se;var U=w.child;if((w.subtreeFlags&2064)!==0&&U!==null)U.return=w,Se=U;else e:for(w=_;Se!==null;){if(C=Se,(C.flags&2048)!==0)try{switch(C.tag){case 0:case 11:case 15:oi(9,C)}}catch(Ee){mt(C,C.return,Ee)}if(C===w){Se=null;break e}var de=C.sibling;if(de!==null){de.return=C.return,Se=de;break e}Se=C.return}}if(qe=d,Xn(),Nn&&typeof Nn.onPostCommitFiberRoot=="function")try{Nn.onPostCommitFiberRoot(wa,e)}catch{}c=!0}return c}finally{et=i,cn.transition=r}}return!1}function yf(e,r,i){r=es(i,r),r=_d(e,r,1),e=er(e,r,1),r=Dt(),e!==null&&(vs(e,1,r),qt(e,r))}function mt(e,r,i){if(e.tag===3)yf(e,e,i);else for(;r!==null;){if(r.tag===3){yf(r,e,i);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(nr===null||!nr.has(c))){e=es(i,e),e=Ld(r,e,1),r=er(r,e,1),e=Dt(),r!==null&&(vs(r,1,e),qt(r,e));break}}r=r.return}}function uy(e,r,i){var c=e.pingCache;c!==null&&c.delete(r),r=Dt(),e.pingedLanes|=e.suspendedLanes&i,Tt===e&&(Rt&i)===i&&(kt===4||kt===3&&(Rt&130023424)===Rt&&500>yt()-El?wr(e,0):Cl|=i),qt(e,r)}function vf(e,r){r===0&&((e.mode&1)===0?r=1:(r=Sa,Sa<<=1,(Sa&130023424)===0&&(Sa=4194304)));var i=Dt();e=Ln(e,r),e!==null&&(vs(e,r,i),qt(e,i))}function dy(e){var r=e.memoizedState,i=0;r!==null&&(i=r.retryLane),vf(e,i)}function fy(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),vf(e,i)}var xf;xf=function(e,r,i){if(e!==null)if(e.memoizedProps!==r.pendingProps||Ht.current)Gt=!0;else{if((e.lanes&i)===0&&(r.flags&128)===0)return Gt=!1,Zg(e,r,i);Gt=(e.flags&131072)!==0}else Gt=!1,ct&&(r.flags&1048576)!==0&&Qu(r,Ha,r.index);switch(r.lanes=0,r.tag){case 2:var c=r.type;ai(e,r),e=r.pendingProps;var d=Gr(r,$t.current);Xr(r,i),d=sl(null,r,c,e,d,i);var h=al();return r.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,Vt(c)?(h=!0,Da(r)):h=!1,r.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,Qo(r),d.updater=ri,r.stateNode=d,d._reactInternals=r,dl(r,c,e,i),r=pl(null,r,c,!0,h,i)):(r.tag=0,ct&&h&&Do(r),Bt(null,r,d,i),r=r.child),r;case 16:c=r.elementType;e:{switch(ai(e,r),e=r.pendingProps,d=c._init,c=d(c._payload),r.type=c,d=r.tag=hy(c),e=gn(c,e),d){case 0:r=hl(null,r,c,e,i);break e;case 1:r=Hd(null,r,c,e,i);break e;case 11:r=Od(null,r,c,e,i);break e;case 14:r=Bd(null,r,c,gn(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:gn(c,d),hl(e,r,c,d,i);case 1:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),Hd(e,r,c,d,i);case 3:e:{if(Vd(r),e===null)throw Error(a(387));c=r.pendingProps,h=r.memoizedState,d=h.element,id(e,r),Ja(r,c,null,i);var w=r.memoizedState;if(c=w.element,h.isDehydrated)if(h={element:c,isDehydrated:!1,cache:w.cache,pendingSuspenseBoundaries:w.pendingSuspenseBoundaries,transitions:w.transitions},r.updateQueue.baseState=h,r.memoizedState=h,r.flags&256){d=es(Error(a(423)),r),r=Gd(e,r,c,i,d);break e}else if(c!==d){d=es(Error(a(424)),r),r=Gd(e,r,c,i,d);break e}else for(tn=Yn(r.stateNode.containerInfo.firstChild),en=r,ct=!0,pn=null,i=sd(r,null,c,i),r.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Yr(),c===d){r=Fn(e,r,i);break e}Bt(e,r,c,i)}r=r.child}return r;case 5:return cd(r),e===null&&Ho(r),c=r.type,d=r.pendingProps,h=e!==null?e.memoizedProps:null,w=d.children,Lo(c,d)?w=null:h!==null&&Lo(c,h)&&(r.flags|=32),Wd(e,r),Bt(e,r,w,i),r.child;case 6:return e===null&&Ho(r),null;case 13:return Kd(e,r,i);case 4:return Xo(r,r.stateNode.containerInfo),c=r.pendingProps,e===null?r.child=Jr(r,null,c,i):Bt(e,r,c,i),r.child;case 11:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),Od(e,r,c,d,i);case 7:return Bt(e,r,r.pendingProps,i),r.child;case 8:return Bt(e,r,r.pendingProps.children,i),r.child;case 12:return Bt(e,r,r.pendingProps.children,i),r.child;case 10:e:{if(c=r.type._context,d=r.pendingProps,h=r.memoizedProps,w=d.value,st(Ka,c._currentValue),c._currentValue=w,h!==null)if(hn(h.value,w)){if(h.children===d.children&&!Ht.current){r=Fn(e,r,i);break e}}else for(h=r.child,h!==null&&(h.return=r);h!==null;){var C=h.dependencies;if(C!==null){w=h.child;for(var R=C.firstContext;R!==null;){if(R.context===c){if(h.tag===1){R=zn(-1,i&-i),R.tag=2;var V=h.updateQueue;if(V!==null){V=V.shared;var ae=V.pending;ae===null?R.next=R:(R.next=ae.next,ae.next=R),V.pending=R}}h.lanes|=i,R=h.alternate,R!==null&&(R.lanes|=i),Yo(h.return,i,r),C.lanes|=i;break}R=R.next}}else if(h.tag===10)w=h.type===r.type?null:h.child;else if(h.tag===18){if(w=h.return,w===null)throw Error(a(341));w.lanes|=i,C=w.alternate,C!==null&&(C.lanes|=i),Yo(w,i,r),w=h.sibling}else w=h.child;if(w!==null)w.return=h;else for(w=h;w!==null;){if(w===r){w=null;break}if(h=w.sibling,h!==null){h.return=w.return,w=h;break}w=w.return}h=w}Bt(e,r,d.children,i),r=r.child}return r;case 9:return d=r.type,c=r.pendingProps.children,Xr(r,i),d=on(d),c=c(d),r.flags|=1,Bt(e,r,c,i),r.child;case 14:return c=r.type,d=gn(c,r.pendingProps),d=gn(c.type,d),Bd(e,r,c,d,i);case 15:return Dd(e,r,r.type,r.pendingProps,i);case 17:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),ai(e,r),r.tag=1,Vt(c)?(e=!0,Da(r)):e=!1,Xr(r,i),Pd(r,c,d),dl(r,c,d,i),pl(null,r,c,!0,e,i);case 19:return Yd(e,r,i);case 22:return Ud(e,r,i)}throw Error(a(156,r.tag))};function wf(e,r){return Xc(e,r)}function my(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 un(e,r,i,c){return new my(e,r,i,c)}function Ll(e){return e=e.prototype,!(!e||!e.isReactComponent)}function hy(e){if(typeof e=="function")return Ll(e)?1:0;if(e!=null){if(e=e.$$typeof,e===F)return 11;if(e===Q)return 14}return 2}function ir(e,r){var i=e.alternate;return i===null?(i=un(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 gi(e,r,i,c,d,h){var w=2;if(c=e,typeof e=="function")Ll(e)&&(w=1);else if(typeof e=="string")w=5;else e:switch(e){case K:return Sr(i.children,d,h,r);case L:w=8,d|=8;break;case W:return e=un(12,i,r,d|2),e.elementType=W,e.lanes=h,e;case ne:return e=un(13,i,r,d),e.elementType=ne,e.lanes=h,e;case he:return e=un(19,i,r,d),e.elementType=he,e.lanes=h,e;case we:return yi(i,d,h,r);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:w=10;break e;case Z:w=9;break e;case F:w=11;break e;case Q:w=14;break e;case ve:w=16,c=null;break e}throw Error(a(130,e==null?e:typeof e,""))}return r=un(w,i,r,d),r.elementType=e,r.type=c,r.lanes=h,r}function Sr(e,r,i,c){return e=un(7,e,c,r),e.lanes=i,e}function yi(e,r,i,c){return e=un(22,e,c,r),e.elementType=we,e.lanes=i,e.stateNode={isHidden:!1},e}function zl(e,r,i){return e=un(6,e,null,r),e.lanes=i,e}function Fl(e,r,i){return r=un(4,e.children!==null?e.children:[],e.key,r),r.lanes=i,r.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},r}function py(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=co(0),this.expirationTimes=co(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=co(0),this.identifierPrefix=c,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function Ml(e,r,i,c,d,h,w,C,R){return e=new py(e,r,i,C,R),r===1?(r=1,h===!0&&(r|=8)):r=0,h=un(3,null,null,r),e.current=h,h.stateNode=e,h.memoizedState={element:c,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Qo(h),e}function gy(e,r,i){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:c==null?null:""+c,children:e,containerInfo:r,implementation:i}}function jf(e){if(!e)return Qn;e=e._reactInternals;e:{if(bn(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(Vt(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(Vt(i))return qu(e,i,r)}return r}function Sf(e,r,i,c,d,h,w,C,R){return e=Ml(i,c,!0,e,d,h,w,C,R),e.context=jf(null),i=e.current,c=Dt(),d=sr(i),h=zn(c,d),h.callback=r??null,er(i,h,d),e.current.lanes=d,vs(e,d,c),qt(e,c),e}function vi(e,r,i,c){var d=r.current,h=Dt(),w=sr(d);return i=jf(i),r.context===null?r.context=i:r.pendingContext=i,r=zn(h,w),r.payload={element:e},c=c===void 0?null:c,c!==null&&(r.callback=c),e=er(d,r,w),e!==null&&(xn(e,d,w,h),Ya(e,d,w)),w}function xi(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 bf(e,r){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var i=e.retryLane;e.retryLane=i!==0&&i<r?i:r}}function Ol(e,r){bf(e,r),(e=e.alternate)&&bf(e,r)}function yy(){return null}var kf=typeof reportError=="function"?reportError:function(e){console.error(e)};function Bl(e){this._internalRoot=e}wi.prototype.render=Bl.prototype.render=function(e){var r=this._internalRoot;if(r===null)throw Error(a(409));vi(e,r,null,null)},wi.prototype.unmount=Bl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var r=e.containerInfo;xr(function(){vi(null,e,null,null)}),r[Rn]=null}};function wi(e){this._internalRoot=e}wi.prototype.unstable_scheduleHydration=function(e){if(e){var r=iu();e={blockedOn:null,target:e,priority:r};for(var i=0;i<Gn.length&&r!==0&&r<Gn[i].priority;i++);Gn.splice(i,0,e),i===0&&cu(e)}};function Dl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ji(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Nf(){}function vy(e,r,i,c,d){if(d){if(typeof c=="function"){var h=c;c=function(){var V=xi(w);h.call(V)}}var w=Sf(r,c,e,0,null,!1,!1,"",Nf);return e._reactRootContainer=w,e[Rn]=w.current,Ps(e.nodeType===8?e.parentNode:e),xr(),w}for(;d=e.lastChild;)e.removeChild(d);if(typeof c=="function"){var C=c;c=function(){var V=xi(R);C.call(V)}}var R=Ml(e,0,!1,null,null,!1,!1,"",Nf);return e._reactRootContainer=R,e[Rn]=R.current,Ps(e.nodeType===8?e.parentNode:e),xr(function(){vi(r,R,i,c)}),R}function Si(e,r,i,c,d){var h=i._reactRootContainer;if(h){var w=h;if(typeof d=="function"){var C=d;d=function(){var R=xi(w);C.call(R)}}vi(r,w,e,d)}else w=vy(i,r,e,d,c);return xi(w)}su=function(e){switch(e.tag){case 3:var r=e.stateNode;if(r.current.memoizedState.isDehydrated){var i=ys(r.pendingLanes);i!==0&&(uo(r,i|1),qt(r,yt()),(qe&6)===0&&(rs=yt()+500,Xn()))}break;case 13:xr(function(){var c=Ln(e,1);if(c!==null){var d=Dt();xn(c,e,1,d)}}),Ol(e,1)}},fo=function(e){if(e.tag===13){var r=Ln(e,134217728);if(r!==null){var i=Dt();xn(r,e,134217728,i)}Ol(e,134217728)}},au=function(e){if(e.tag===13){var r=sr(e),i=Ln(e,r);if(i!==null){var c=Dt();xn(i,e,r,c)}Ol(e,r)}},iu=function(){return et},ou=function(e,r){var i=et;try{return et=e,r()}finally{et=i}},rt=function(e,r,i){switch(r){case"input":if(ze(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=Oa(c);if(!d)throw Error(a(90));be(c),ze(c,d)}}}break;case"textarea":Me(e,i);break;case"select":r=i.value,r!=null&&Ye(e,!!i.multiple,r,!1)}},ue=Pl,Ce=xr;var xy={usingClientEntryPoint:!1,Events:[Ls,Hr,Oa,St,Xt,Pl]},Ys={findFiberByHostInstance:dr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},wy={bundleType:Ys.bundleType,version:Ys.version,rendererPackageName:Ys.rendererPackageName,rendererConfig:Ys.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:A.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=kn(e),e===null?null:e.stateNode},findFiberByHostInstance:Ys.findFiberByHostInstance||yy,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 bi=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!bi.isDisabled&&bi.supportsFiber)try{wa=bi.inject(wy),Nn=bi}catch{}}return Yt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=xy,Yt.createPortal=function(e,r){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Dl(r))throw Error(a(200));return gy(e,r,null,i)},Yt.createRoot=function(e,r){if(!Dl(e))throw Error(a(299));var i=!1,c="",d=kf;return r!=null&&(r.unstable_strictMode===!0&&(i=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onRecoverableError!==void 0&&(d=r.onRecoverableError)),r=Ml(e,1,!1,null,null,i,!1,c,d),e[Rn]=r.current,Ps(e.nodeType===8?e.parentNode:e),new Bl(r)},Yt.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=kn(r),e=e===null?null:e.stateNode,e},Yt.flushSync=function(e){return xr(e)},Yt.hydrate=function(e,r,i){if(!ji(r))throw Error(a(200));return Si(null,e,r,!0,i)},Yt.hydrateRoot=function(e,r,i){if(!Dl(e))throw Error(a(405));var c=i!=null&&i.hydratedSources||null,d=!1,h="",w=kf;if(i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(h=i.identifierPrefix),i.onRecoverableError!==void 0&&(w=i.onRecoverableError)),r=Sf(r,null,e,1,i??null,d,!1,h,w),e[Rn]=r.current,Ps(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 wi(r)},Yt.render=function(e,r,i){if(!ji(r))throw Error(a(200));return Si(null,e,r,!1,i)},Yt.unmountComponentAtNode=function(e){if(!ji(e))throw Error(a(40));return e._reactRootContainer?(xr(function(){Si(null,null,e,!1,function(){e._reactRootContainer=null,e[Rn]=null})}),!0):!1},Yt.unstable_batchedUpdates=Pl,Yt.unstable_renderSubtreeIntoContainer=function(e,r,i,c){if(!ji(i))throw Error(a(200));if(e==null||e._reactInternals===void 0)throw Error(a(38));return Si(e,r,i,!1,c)},Yt.version="18.3.1-next-f1338f8080-20240426",Yt}var $f;function Um(){if($f)return Hl.exports;$f=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(),Hl.exports=Iy(),Hl.exports}var _f;function Ay(){if(_f)return ki;_f=1;var t=Um();return ki.createRoot=t.createRoot,ki.hydrateRoot=t.hydrateRoot,ki}var Ry=Ay();/**
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 Sc=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Wm=/^[\\/]{2}/;function Py(t,s){return s+t.replace(/\\/g,"/")}var Lf="popstate";function zf(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function $y(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 ic("",{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:Tr(l)}return Ly(s,a,null,t)}function ut(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function fn(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function _y(){return Math.random().toString(36).substring(2,10)}function Ff(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 ic(t,s,a=null,o,l){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof s=="string"?us(s):s,state:a,key:s&&s.key||o||_y(),mask:l}}function Tr({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 us(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 Ly(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 N=y(),E=N==null?null:N-v;v=N,p&&p({action:g,location:S.location,delta:E})}function j(N,E){g="PUSH";let T=zf(N)?N:ic(S.location,N,E);v=y()+1;let P=Ff(T,v),A=S.createHref(T.mask||T);try{f.pushState(P,"",A)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;l.location.assign(A)}u&&p&&p({action:g,location:S.location,delta:1})}function k(N,E){g="REPLACE";let T=zf(N)?N:ic(S.location,N,E);v=y();let P=Ff(T,v),A=S.createHref(T.mask||T);f.replaceState(P,"",A),u&&p&&p({action:g,location:S.location,delta:0})}function b(N){return zy(l,N)}let S={get action(){return g},get location(){return t(l,f)},listen(N){if(p)throw new Error("A history only accepts one active listener");return l.addEventListener(Lf,x),p=N,()=>{l.removeEventListener(Lf,x),p=null}},createHref(N){return s(l,N)},createURL:b,encodeLocation(N){let E=b(N);return{pathname:E.pathname,search:E.search,hash:E.hash}},push:j,replace:k,go(N){return f.go(N)}};return S}function zy(t,s,a=!1){let o="http://localhost";t&&(o=t.location.origin!=="null"?t.location.origin:t.location.href),ut(o,"No window.location.(origin|href) available to create URL");let l=typeof s=="string"?s:Tr(s);return l=l.replace(/ $/,"%20"),!a&&Wm.test(l)&&(l=o+l),new URL(l,o)}function Hm(t,s,a="/"){return Fy(t,s,a,!1)}function Fy(t,s,a,o,l){let u=typeof s=="string"?us(s):s,f=Dn(u.pathname||"/",a);if(f==null)return null;let g=My(t),p=null,v=Yy(f);for(let y=0;p==null&&y<g.length;++y)p=qy(g[y],v,o);return p}function My(t){let s=Vm(t);return Oy(s),s}function Vm(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;ut(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let x=wn([o,y.relativePath]),j=a.concat(y);f.children&&f.children.length>0&&(ut(f.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${x}".`),Vm(f.children,s,j,x,p)),!(f.path==null&&!f.index)&&s.push({path:x,score:Gy(x,f.index),routesMeta:j.map((k,b)=>{let[S,N]=qm(k.relativePath,k.caseSensitive,b===j.length-1);return{...k,matcher:S,compiledParams:N}})})};return t.forEach((f,g)=>{var p;if(f.path===""||!((p=f.path)!=null&&p.includes("?")))u(f,g);else for(let v of Gm(f.path))u(f,g,!0,v)}),s}function Gm(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=Gm(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 Oy(t){t.sort((s,a)=>s.score!==a.score?a.score-s.score:Ky(s.routesMeta.map(o=>o.childrenIndex),a.routesMeta.map(o=>o.childrenIndex)))}var By=/^:[\w-]+$/,Dy=3,Uy=2,Wy=1,Hy=10,Vy=-2,Mf=t=>t==="*";function Gy(t,s){let a=t.split("/"),o=a.length;return a.some(Mf)&&(o+=Vy),s&&(o+=Uy),a.filter(l=>!Mf(l)).reduce((l,u)=>l+(By.test(u)?Dy:u===""?Wy:Hy),o)}function Ky(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 qy(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?Km(x,y,p.matcher,p.compiledParams):Li(x,y),k=p.route;if(!j&&v&&a&&!o[o.length-1].route.index&&(j=Li({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},y)),!j)return null;Object.assign(l,j.params),f.push({params:l,pathname:wn([u,j.pathname]),pathnameBase:Xy(wn([u,j.pathnameBase])),route:k}),j.pathnameBase!=="/"&&(u=wn([u,j.pathnameBase]))}return f}function Li(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[a,o]=qm(t.path,t.caseSensitive,t.end);return Km(t,s,a,o)}function Km(t,s,a,o){let l=s.match(a);if(!l)return null;let u=l[0],f=ls(u,1),g=l.slice(1);return{params:o.reduce((v,{paramName:y,isOptional:x},j)=>{if(y==="*"){let b=g[j]||"";f=ls(u.slice(0,u.length-b.length),1)}const k=g[j];return x&&!k?v[y]=void 0:v[y]=(k||"").replace(/%2F/g,"/"),v},{}),pathname:u,pathnameBase:f,pattern:t}}function qm(t,s=!1,a=!0){fn(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 Yy(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return fn(!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 Dn(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 Jy(t,s="/"){let{pathname:a,search:o="",hash:l=""}=typeof t=="string"?us(t):t,u;return a?(a=Ym(a),a.startsWith("/")||a.startsWith("\\")?u=Of(a.substring(1),"/"):u=Of(a,s)):u=s,{pathname:u,search:Zy(o),hash:ev(l)}}function Of(t,s){let a=ls(s).split("/");return t.split("/").forEach(l=>{l===".."?a.length>1&&a.pop():l!=="."&&a.push(l)}),a.length>1?a.join("/"):"/"}function Kl(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 Qy(t){return t.filter((s,a)=>a===0||s.route.path&&s.route.path.length>0)}function bc(t){let s=Qy(t);return s.map((a,o)=>o===s.length-1?a.pathname:a.pathnameBase)}function Ji(t,s,a,o=!1){let l;typeof t=="string"?l=us(t):(l={...t},ut(!l.pathname||!l.pathname.includes("?"),Kl("?","pathname","search",l)),ut(!l.pathname||!l.pathname.includes("#"),Kl("#","pathname","hash",l)),ut(!l.search||!l.search.includes("#"),Kl("#","search","hash",l)));let u=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=Jy(l,g),v=f&&f!=="/"&&f.endsWith("/"),y=(u||f===".")&&a.endsWith("/");return!p.pathname.endsWith("/")&&(v||y)&&(p.pathname+="/"),p}var Ym=t=>t.replace(/[\\/]{2,}/g,"/"),wn=t=>Ym(t.join("/"));function ls(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 Xy=t=>ls(t).replace(/^\/*/,"/"),Zy=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,ev=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,tv=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 nv(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function rv(t){let s=t.map(a=>a.route.path).filter(Boolean);return wn(s)||"/"}var Jm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Qm(t,s){let a=t;if(typeof a!="string"||!Sc.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let o=a,l=!1;if(Jm)try{let u=new URL(window.location.href),f=Wm.test(a)?new URL(Py(a,u.protocol)):new URL(a),g=Dn(f.pathname,s);f.origin===u.origin&&g!=null?a=g+f.search+f.hash:l=!0}catch{fn(!1,`<Link to="${a}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:l,to:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Bf=new URL("http://localhost");function kc(t){if(t.createURL)return t.createURL("/");try{return new URL(t.createHref("/"),Bf)}catch{return Bf}}function ql(t,s){return t.origin===s.origin&&(t.origin!=="null"||t.protocol===s.protocol&&t.host===s.host)}function sv(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 Nc(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&&!ql(l,a),g=!ql(u,a);if(o==="reject"){if(f||g)throw new Error("External navigation is not allowed")}else if(g&&(l==null||!sv(t,l)||!ql(l,u)))throw new Error("External navigation is not allowed")}var Xm=["POST","PUT","PATCH","DELETE"];new Set(Xm);var av=["GET",...Xm];new Set(av);var iv=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function ov(t){try{return iv.includes(new URL(t).protocol)}catch{return!1}}var ds=m.createContext(null);ds.displayName="DataRouter";var Qi=m.createContext(null);Qi.displayName="DataRouterState";var Zm=m.createContext(!1);function lv(){return m.useContext(Zm)}var eh=m.createContext({isTransitioning:!1});eh.displayName="ViewTransition";var cv=m.createContext(new Map);cv.displayName="Fetchers";var uv=m.createContext(null);uv.displayName="Await";var rn=m.createContext(null);rn.displayName="Navigation";var fa=m.createContext(null);fa.displayName="Location";var jn=m.createContext({outlet:null,matches:[],isDataRoute:!1});jn.displayName="Route";var Cc=m.createContext(null);Cc.displayName="RouteError";var th="REACT_ROUTER_ERROR",dv="REDIRECT",fv="ROUTE_ERROR_RESPONSE";function mv(t){if(t.startsWith(`${th}:${dv}:{`))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 hv(t){if(t.startsWith(`${th}:${fv}:{`))try{let s=JSON.parse(t.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new tv(s.status,s.statusText,s.data)}catch{}}function pv(t,{relative:s}={}){ut(fs(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:o}=m.useContext(rn),{hash:l,pathname:u,search:f}=ma(t,{relative:s}),g=u;return a!=="/"&&(g=u==="/"?a:wn([a,u])),o.createHref({pathname:g,search:f,hash:l})}function fs(){return m.useContext(fa)!=null}function Qt(){return ut(fs(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(fa).location}var nh="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function rh(t){m.useContext(rn).static||m.useLayoutEffect(t)}function Sn(){let{isDataRoute:t}=m.useContext(jn);return t?Av():gv()}function gv(){ut(fs(),"useNavigate() may be used only in the context of a <Router> component.");let t=m.useContext(ds),{basename:s,navigator:a}=m.useContext(rn),{matches:o}=m.useContext(jn),{pathname:l}=Qt(),u=JSON.stringify(bc(o)),f=m.useRef(!1);return rh(()=>{f.current=!0}),m.useCallback((p,v={})=>{if(fn(f.current,nh),!f.current)return;if(typeof p=="number"){a.go(p);return}let y=Ji(p,JSON.parse(u),l,v.relative==="path");t==null&&s!=="/"&&(y.pathname=y.pathname==="/"?s:wn([s,y.pathname])),Nc(typeof p=="string"?p:Tr(p),a.createHref(y),kc(a),"reject"),(v.replace?a.replace:a.push)(y,v.state,v)},[s,a,u,l,t])}var yv=m.createContext(null);function vv(t){let s=m.useContext(jn).outlet;return m.useMemo(()=>s&&m.createElement(yv.Provider,{value:t},s),[s,t])}function ma(t,{relative:s}={}){let{matches:a}=m.useContext(jn),{pathname:o}=Qt(),l=JSON.stringify(bc(a));return m.useMemo(()=>Ji(t,JSON.parse(l),o,s==="path"),[t,l,o,s])}function xv(t,s){return sh(t,s)}function sh(t,s,a){var N;ut(fs(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=m.useContext(rn),{matches:l}=m.useContext(jn),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||"";ih(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=Qt(),x;if(s){let E=typeof s=="string"?us(s):s;ut(p==="/"||((N=E.pathname)==null?void 0:N.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||"/",k=j;if(p!=="/"){let E=p.replace(/^\//,"").split("/");k="/"+j.replace(/^\//,"").split("/").slice(E.length).join("/")}let b=a&&a.state.matches.length?a.state.matches.map(E=>Object.assign(E,{route:a.manifest[E.route.id]||E.route})):Hm(t,{pathname:k});fn(v||b!=null,`No routes matched location "${x.pathname}${x.search}${x.hash}" `),fn(b==null||b[b.length-1].route.element!==void 0||b[b.length-1].route.Component!==void 0||b[b.length-1].route.lazy!==void 0,`Matched leaf route at location "${x.pathname}${x.search}${x.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let S=kv(b&&b.map(E=>Object.assign({},E,{params:Object.assign({},f,E.params),pathname:wn([p,o.encodeLocation?o.encodeLocation(E.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?p:wn([p,o.encodeLocation?o.encodeLocation(E.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),l,a);return s&&S?m.createElement(fa.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...x},navigationType:"POP"}},S):S}function wv(){let t=Iv(),s=nv(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=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:u},"ErrorBoundary")," or"," ",m.createElement("code",{style:u},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},s),a?m.createElement("pre",{style:l},a):null,f)}var jv=m.createElement(wv,null),ah=class extends m.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=hv(t.digest);a&&(t=a)}let s=t!==void 0?m.createElement(jn.Provider,{value:this.props.routeContext},m.createElement(Cc.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?m.createElement(Sv,{error:t},s):s}};ah.contextType=Zm;var Yl=new WeakMap;function Sv({children:t,error:s}){let{basename:a,navigator:o}=m.useContext(rn);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let l=mv(s.digest);if(l){let u=Yl.get(s);if(u)throw u;let f=Qm(l.location,a),g=f.absoluteURL||f.to;if(Nc(l.location,g,kc(o),"allow-explicit"),ov(g))throw new Error("Invalid redirect location");if(Jm&&!Yl.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 Yl.set(s,p),p}return m.createElement("meta",{httpEquiv:"refresh",content:`0;url=${g}`})}}return t}function bv({routeContext:t,match:s,children:a}){let o=m.useContext(ds);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),m.createElement(jn.Provider,{value:t},a)}function kv(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);ut(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),l=l.slice(0,Math.min(l.length,y+1))}let f=!1,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:k}=o,b=x.route.loader&&!j.hasOwnProperty(x.route.id)&&(!k||k[x.route.id]===void 0);if(x.route.lazy||b){a.isStatic&&(f=!0),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,k;p(y,{location:o.location,params:((k=(j=o.matches)==null?void 0:j[0])==null?void 0:k.params)??{},pattern:rv(o.matches),errorInfo:x})}:void 0;return l.reduceRight((y,x,j)=>{let k,b=!1,S=null,N=null;o&&(k=u&&x.route.id?u[x.route.id]:void 0,S=x.route.errorElement||jv,f&&(g<0&&j===0?(ih("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,N=null):g===j&&(b=!0,N=x.route.hydrateFallbackElement||null)));let E=s.concat(l.slice(0,j+1)),T=()=>{let P;return k?P=S:b?P=N:x.route.Component?P=m.createElement(x.route.Component,null):x.route.element?P=x.route.element:P=y,m.createElement(bv,{match:x,routeContext:{outlet:y,matches:E,isDataRoute:o!=null},children:P})};return o&&(x.route.ErrorBoundary||x.route.errorElement||j===0)?m.createElement(ah,{location:o.location,revalidation:o.revalidation,component:S,error:k,children:T(),routeContext:{outlet:null,matches:E,isDataRoute:!0},onError:v}):T()},null)}function Ec(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Nv(t){let s=m.useContext(ds);return ut(s,Ec(t)),s}function Cv(t){let s=m.useContext(Qi);return ut(s,Ec(t)),s}function Ev(t){let s=m.useContext(jn);return ut(s,Ec(t)),s}function Tc(t){let s=Ev(t),a=s.matches[s.matches.length-1];return ut(a.route.id,`${t} can only be used on routes that contain a unique "id"`),a.route.id}function Tv(){return Tc("useRouteId")}function Iv(){var o;let t=m.useContext(Cc),s=Cv("useRouteError"),a=Tc("useRouteError");return t!==void 0?t:(o=s.errors)==null?void 0:o[a]}function Av(){let{router:t}=Nv("useNavigate"),s=Tc("useNavigate"),a=m.useRef(!1);return rh(()=>{a.current=!0}),m.useCallback(async(l,u={})=>{fn(a.current,nh),a.current&&(typeof l=="number"?await t.navigate(l):await t.navigate(l,{fromRouteId:s,...u}))},[t,s])}var Df={};function ih(t,s,a){!s&&!Df[t]&&(Df[t]=!0,fn(!1,a))}m.memo(Rv);function Rv({routes:t,manifest:s,future:a,state:o,isStatic:l,onError:u}){return sh(t,void 0,{manifest:s,state:o,isStatic:l,onError:u})}function On({to:t,replace:s,state:a,relative:o}){ut(fs(),"<Navigate> may be used only in the context of a <Router> component.");let{static:l,navigator:u}=m.useContext(rn);fn(!l,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:f}=m.useContext(jn),{pathname:g}=Qt(),p=Sn(),v=Ji(t,bc(f),g,o==="path");Nc(typeof t=="string"?t:Tr(t),u.createHref(v),kc(u),"reject");let y=JSON.stringify(v);return m.useEffect(()=>{p(JSON.parse(y),{replace:s,state:a,relative:o})},[p,y,o,s,a]),null}function Pv(t){return vv(t.context)}function at(t){ut(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function $v({basename:t="/",children:s=null,location:a,navigationType:o="POP",navigator:l,static:u=!1,useTransitions:f}){ut(!fs(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let g=t.replace(/^\/*/,"/"),p=m.useMemo(()=>({basename:g,navigator:l,static:u,useTransitions:f,future:{}}),[g,l,u,f]);typeof a=="string"&&(a=us(a));let{pathname:v="/",search:y="",hash:x="",state:j=null,key:k="default",mask:b}=a,S=m.useMemo(()=>{let N=Dn(v,g);return N==null?null:{location:{pathname:N,search:y,hash:x,state:j,key:k,mask:b},navigationType:o}},[g,v,y,x,j,k,o,b]);return fn(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:m.createElement(rn.Provider,{value:p},m.createElement(fa.Provider,{children:s,value:S}))}function _v({children:t,location:s}){return xv(oc(t),s)}function oc(t,s=[]){let a=[];return m.Children.forEach(t,(o,l)=>{if(!m.isValidElement(o))return;let u=[...s,l];if(o.type===m.Fragment){a.push.apply(a,oc(o.props.children,u));return}ut(o.type===at,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ut(!o.props.index||!o.props.children,"An index route cannot have child routes.");let f={id:o.props.id||u.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(f.children=oc(o.props.children,u)),a.push(f)}),a}var Ri="get",Pi="application/x-www-form-urlencoded";function Xi(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Lv(t){return Xi(t)&&t.tagName.toLowerCase()==="button"}function zv(t){return Xi(t)&&t.tagName.toLowerCase()==="form"}function Fv(t){return Xi(t)&&t.tagName.toLowerCase()==="input"}function Mv(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Ov(t,s){return t.button===0&&(!s||s==="_self")&&!Mv(t)}function lc(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 Bv(t,s){let a=lc(t);return s&&s.forEach((o,l)=>{a.has(l)||s.getAll(l).forEach(u=>{a.append(l,u)})}),a}var Ni=null;function Dv(){if(Ni===null)try{new FormData(document.createElement("form"),0),Ni=!1}catch{Ni=!0}return Ni}var Uv=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Jl(t){return t!=null&&!Uv.has(t)?(fn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Pi}"`),null):t}function Wv(t,s){let a,o,l,u,f;if(zv(t)){let g=t.getAttribute("action");o=g?Dn(g,s):null,a=t.getAttribute("method")||Ri,l=Jl(t.getAttribute("enctype"))||Pi,u=new FormData(t)}else if(Lv(t)||Fv(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?Dn(p,s):null,a=t.getAttribute("formmethod")||g.getAttribute("method")||Ri,l=Jl(t.getAttribute("formenctype"))||Jl(g.getAttribute("enctype"))||Pi,u=new FormData(g,t),!Dv()){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(Xi(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=Ri,o=null,l=Pi,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 Ic(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function oh(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&&Dn(l.pathname,s)==="/"?l.pathname=`${ls(s)}/_root.${o}`:l.pathname=`${ls(l.pathname)}.${o}`,l}async function Hv(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 Vv(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 Gv(t,s,a){let o=await Promise.all(t.map(async l=>{let u=s.routes[l.route.id];if(u){let f=await Hv(u,a);return f.links?f.links():[]}return[]}));return Jv(o.flat(1).filter(Vv).filter(l=>l.rel==="stylesheet"||l.rel==="preload").map(l=>l.rel==="stylesheet"?{...l,rel:"prefetch",as:"style"}:{...l,rel:"prefetch"}))}function Uf(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 Kv(t,s,{includeHydrateFallback:a}={}){return qv(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 qv(t){return[...new Set(t)]}function Yv(t){let s={},a=Object.keys(t).sort();for(let o of a)s[o]=t[o];return s}function Jv(t,s){let a=new Set;return new Set(s),t.reduce((o,l)=>{let u=JSON.stringify(Yv(l));return a.has(u)||(a.add(u),o.push({key:u,link:l})),o},[])}function Ac(){let t=m.useContext(ds);return Ic(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Qv(){let t=m.useContext(Qi);return Ic(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var Rc=m.createContext(void 0);Rc.displayName="FrameworkContext";function Zi(){let t=m.useContext(Rc);return Ic(t,"You must render this element inside a <HydratedRouter> element"),t}function Xv(t,s){let a=m.useContext(Rc),[o,l]=m.useState(!1),[u,f]=m.useState(!1),{onFocus:g,onBlur:p,onMouseEnter:v,onMouseLeave:y,onTouchStart:x}=s,j=m.useRef(null);m.useEffect(()=>{if(t==="render"&&f(!0),t==="viewport"){let S=E=>{E.forEach(T=>{f(T.isIntersecting)})},N=new IntersectionObserver(S,{threshold:.5});return j.current&&N.observe(j.current),()=>{N.disconnect()}}},[t]),m.useEffect(()=>{if(o){let S=setTimeout(()=>{f(!0)},100);return()=>{clearTimeout(S)}}},[o]);let k=()=>{l(!0)},b=()=>{l(!1),f(!1)};return a?t!=="intent"?[u,j,{}]:[u,j,{onFocus:Xs(g,k),onBlur:Xs(p,b),onMouseEnter:Xs(v,k),onMouseLeave:Xs(y,b),onTouchStart:Xs(x,k)}]:[!1,j,{}]}function Xs(t,s){return a=>{t&&t(a),a.defaultPrevented||s(a)}}function Zv({page:t,...s}){let a=lv(),{nonce:o}=Zi(),{router:l}=Ac(),u=m.useMemo(()=>Hm(l.routes,t,l.basename),[l.routes,t,l.basename]);return u?(s.nonce==null&&o&&(s={...s,nonce:o}),a?m.createElement(tx,{page:t,matches:u,...s}):m.createElement(nx,{page:t,matches:u,...s})):null}function ex(t){let{manifest:s,routeModules:a}=Zi(),[o,l]=m.useState([]);return m.useEffect(()=>{let u=!1;return Gv(t,s,a).then(f=>{u||l(f)}),()=>{u=!0}},[t,s,a]),o}function tx({page:t,matches:s,...a}){let o=Qt(),{future:l}=Zi(),{basename:u}=Ac(),f=m.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let g=oh(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 m.createElement(m.Fragment,null,f.map(g=>m.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...a})))}function nx({page:t,matches:s,...a}){let o=Qt(),{future:l,manifest:u,routeModules:f}=Zi(),{basename:g}=Ac(),{loaderData:p,matches:v}=Qv(),y=m.useMemo(()=>Uf(t,s,v,u,o,"data"),[t,s,v,u,o]),x=m.useMemo(()=>Uf(t,s,v,u,o,"assets"),[t,s,v,u,o]),j=m.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let S=new Set,N=!1;if(s.forEach(T=>{var A;let P=u.routes[T.route.id];!P||!P.hasLoader||(!y.some(D=>D.route.id===T.route.id)&&T.route.id in p&&((A=f[T.route.id])!=null&&A.shouldRevalidate)||P.hasClientLoader?N=!0:S.add(T.route.id))}),S.size===0)return[];let E=oh(t,g,l.v8_trailingSlashAwareDataRequests,"data");return N&&S.size>0&&E.searchParams.set("_routes",s.filter(T=>S.has(T.route.id)).map(T=>T.route.id).join(",")),[E.pathname+E.search]},[g,l.v8_trailingSlashAwareDataRequests,p,o,u,y,s,t,f]),k=m.useMemo(()=>Kv(x,u),[x,u]),b=ex(x);return m.createElement(m.Fragment,null,j.map(S=>m.createElement("link",{key:S,rel:"prefetch",as:"fetch",href:S,...a})),k.map(S=>m.createElement("link",{key:S,rel:"modulepreload",href:S,...a})),b.map(({key:S,link:N})=>m.createElement("link",{key:S,nonce:a.nonce,...N,crossOrigin:N.crossOrigin??a.crossOrigin})))}function rx(...t){return s=>{t.forEach(a=>{typeof a=="function"?a(s):a!=null&&(a.current=s)})}}var sx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{sx&&(window.__reactRouterVersion="7.18.4")}catch{}function ax({basename:t,children:s,useTransitions:a,window:o}){let l=m.useRef();l.current==null&&(l.current=$y({window:o,v5Compat:!0}));let u=l.current,[f,g]=m.useState({action:u.action,location:u.location}),p=m.useCallback(v=>{a===!1?g(v):m.startTransition(()=>g(v))},[a]);return m.useLayoutEffect(()=>u.listen(p),[u,p]),m.createElement($v,{basename:t,children:s,location:f.location,navigationType:f.action,navigator:u,useTransitions:a})}var ht=m.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:k,...b},S){let{basename:N,navigator:E,useTransitions:T}=m.useContext(rn),P=typeof y=="string"&&Sc.test(y),A=Qm(y,N);y=A.to;let D=pv(y,{relative:l}),O=Qt(),K=null;if(g){let Q=Ji(g,[],O.mask?O.mask.pathname:"/",!0);N!=="/"&&(Q.pathname=Q.pathname==="/"?N:wn([N,Q.pathname])),K=E.createHref(Q)}let[L,W,te]=Xv(o,b),Z=lx(y,{replace:f,mask:g,state:p,target:v,preventScrollReset:x,relative:l,viewTransition:j,defaultShouldRevalidate:k,useTransitions:T});function F(Q){s&&s(Q),Q.defaultPrevented||Z(Q)}let ne=!(A.isExternal||u),he=m.createElement("a",{...b,...te,href:(ne?K:void 0)||A.absoluteURL||D,onClick:ne?F:s,ref:rx(S,W),target:v,"data-discover":!P&&a==="render"?"true":void 0});return L&&!P?m.createElement(m.Fragment,null,he,m.createElement(Zv,{page:D})):he});ht.displayName="Link";var Pc=m.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=ma(f,{relative:v.relative}),j=Qt(),k=m.useContext(Qi),{navigator:b,basename:S}=m.useContext(rn),N=k!=null&&mx(x)&&g===!0,E=b.encodeLocation?b.encodeLocation(x).pathname:x.pathname,T=j.pathname,P=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;a||(T=T.toLowerCase(),P=P?P.toLowerCase():null,E=E.toLowerCase()),P&&S&&(P=Dn(P,S)||P);const A=E!=="/"&&E.endsWith("/")?E.length-1:E.length;let D=T===E||!l&&T.startsWith(E)&&T.charAt(A)==="/",O=P!=null&&(P===E||!l&&P.startsWith(E)&&P.charAt(E.length)==="/"),K={isActive:D,isPending:O,isTransitioning:N},L=D?s:void 0,W;typeof o=="function"?W=o(K):W=[o,D?"active":null,O?"pending":null,N?"transitioning":null].filter(Boolean).join(" ");let te=typeof u=="function"?u(K):u;return m.createElement(ht,{...v,"aria-current":L,className:W,ref:y,style:te,to:f,viewTransition:g},typeof p=="function"?p(K):p)});Pc.displayName="NavLink";var ix=m.forwardRef(({discover:t="render",fetcherKey:s,navigate:a,reloadDocument:o,replace:l,state:u,method:f=Ri,action:g,onSubmit:p,relative:v,preventScrollReset:y,viewTransition:x,defaultShouldRevalidate:j,...k},b)=>{let{useTransitions:S}=m.useContext(rn),N=dx(),E=fx(g,{relative:v}),T=f.toLowerCase()==="get"?"get":"post",P=typeof g=="string"&&Sc.test(g),A=D=>{if(p&&p(D),D.defaultPrevented)return;D.preventDefault();let O=D.nativeEvent.submitter,K=(O==null?void 0:O.getAttribute("formmethod"))||f,L=()=>N(O||D.currentTarget,{fetcherKey:s,method:K,navigate:a,replace:l,state:u,relative:v,preventScrollReset:y,viewTransition:x,defaultShouldRevalidate:j});S&&a!==!1?m.startTransition(()=>L()):L()};return m.createElement("form",{ref:b,method:T,action:E,onSubmit:o?p:A,...k,"data-discover":!P&&t==="render"?"true":void 0})});ix.displayName="Form";function ox(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function lh(t){let s=m.useContext(ds);return ut(s,ox(t)),s}function lx(t,{target:s,replace:a,mask:o,state:l,preventScrollReset:u,relative:f,viewTransition:g,defaultShouldRevalidate:p,useTransitions:v}={}){let y=Sn(),x=Qt(),j=ma(t,{relative:f});return m.useCallback(k=>{if(Ov(k,s)){k.preventDefault();let b=a!==void 0?a:Tr(x)===Tr(j),S=()=>y(t,{replace:b,mask:o,state:l,preventScrollReset:u,relative:f,viewTransition:g,defaultShouldRevalidate:p});v?m.startTransition(()=>S()):S()}},[x,y,j,a,o,l,s,t,u,f,g,p,v])}function ms(t){fn(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let s=m.useRef(lc(t)),a=m.useRef(!1),o=Qt(),l=m.useMemo(()=>Bv(o.search,a.current?null:s.current),[o.search]),u=Sn(),f=m.useCallback((g,p)=>{const v=lc(typeof g=="function"?g(new URLSearchParams(l)):g);a.current=!0,u("?"+v,p)},[u,l]);return[l,f]}var cx=0,ux=()=>`__${String(++cx)}__`;function dx(){let{router:t}=lh("useSubmit"),{basename:s}=m.useContext(rn),a=Tv(),o=t.fetch,l=t.navigate;return m.useCallback(async(u,f={})=>{let{action:g,method:p,encType:v,formData:y,body:x}=Wv(u,s);if(f.navigate===!1){let j=f.fetcherKey||ux();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 fx(t,{relative:s}={}){let{basename:a}=m.useContext(rn),o=m.useContext(jn);ut(o,"useFormAction must be used inside a RouteContext");let[l]=o.matches.slice(-1),u={...ma(t||".",{relative:s})},f=Qt();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:wn([a,u.pathname])),Tr(u)}function mx(t,{relative:s}={}){let a=m.useContext(eh);ut(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=lh("useViewTransitionState"),l=ma(t,{relative:s});if(!a.isTransitioning)return!1;let u=Dn(a.currentLocation.pathname,o)||a.currentLocation.pathname,f=Dn(a.nextLocation.pathname,o)||a.nextLocation.pathname;return Li(l.pathname,f)!=null||Li(l.pathname,u)!=null}var hx=Um();const Cr="owner";function px(t){const s=t||Cr;return s===Cr?[Cr]:[s,Cr]}function gx(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 yx(t,s){const a=s||Cr,o=(t==null?void 0:t.pendingDomains)??[];return o.includes(a)?a:o.includes(Cr)?Cr:a}class ch extends Error{constructor(a){super("different_account");Js(this,"summary");this.name="DifferentAccountError",this.summary=a}}function uh(t){return t.grantors??t.approvers}function vx(t){return t.approvals??1}function He(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 xx(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 wx{constructor(){Js(this,"apiKey",null)}setApiKey(s){this.apiKey=s}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(s,a){return globalThis.fetch(s,{...a,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...a==null?void 0:a.headers}})}async login(s,a={}){const o=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":s,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:a.confirmWipe===!0})});if(o.status===409){const u=await o.json().catch(()=>({}));if(u!=null&&u.wouldWipe)throw new ch(u.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!o.ok){const u=await o.json().catch(()=>({error:"Invalid API key"}));throw new Error(He(u,`Login failed: ${o.status}`))}return(await o.json()).user}async logout(){await this.fetch("/auth/logout",{method:"POST"})}async getGroups(){const s=await this.fetch("/api/groups");if(!s.ok)throw new Error(`Failed to fetch groups: ${s.status}`);const a=await s.json();return a.groups??a}async listProfiles(){const s=await this.fetch("/api/profiles");if(!s.ok)throw new Error(`Failed to fetch profiles: ${s.status}`);return(await s.json()).profiles}async getProfile(s){const a=await this.fetch(`/api/profiles/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch profile: ${a.status}`);return a.json()}async attest(s){const a=await this.fetch("/api/as/mandate",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(He(o,`Signing failed: ${a.status}`))}return a.json()}async getPending(s){const a=await this.fetch(`/api/mandates/pending?domain=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch pending: ${a.status}`);const o=await a.json();return o.pending??o}async getMyAttestations(s){const a=s?`?status=${encodeURIComponent(s)}`:"",o=await this.fetch(`/api/mandates/mine${a}`);if(!o.ok)throw new Error(`Failed to fetch attestations: ${o.status}`);return((await o.json()).mandates??[]).map(u=>{var f,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(He(a,`Export failed (${s.status})`));const o=((l=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:l[1])??"suveren-evidence.json";return{bundle:a,filename:o}}async getLocalAuthorizations(){const s=await this.fetch("/api/evidence/authorizations");if(!s.ok)throw new Error(`Local evidence unavailable (${s.status})`);const a=await s.json();return{authorizations:a.authorizations??{},signatures:a.signatures??{}}}async getArchivedReceipt(s){const a=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(s)}`);if(a.status===404)return null;if(!a.ok)throw new Error(`Local evidence unavailable (${a.status})`);return await a.json()}async getReport(){const s=await this.fetch("/api/report");if(!s.ok){const a=await s.json().catch(()=>({error:`Report unavailable (${s.status})`}));throw new Error(He(a,`Report unavailable (${s.status})`))}return s.json()}async saveReport(s){const a=await this.fetch("/api/report",{method:"POST",body:JSON.stringify({html:s})});if(!a.ok){const o=await a.json().catch(()=>({error:`Save failed (${a.status})`}));throw new Error(He(o,`Save failed (${a.status})`))}return a.json()}async recheckReport(){const s=await this.fetch("/api/report/recheck",{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:`Recheck failed (${s.status})`}));throw new Error(He(a,`Recheck failed (${s.status})`))}return s.json()}async exportReportWithProof(){var l;const s=await this.fetch("/api/report/export");if(!s.ok){const u=await s.json().catch(()=>({error:`Export failed (${s.status})`}));throw new Error(He(u,`Export failed (${s.status})`))}const a=await s.text(),o=((l=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:l[1])??"suveren-report.html";return{html:a,filename:o}}async revokeAttestation(s,a){const o=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/revoke`,{method:"POST",body:JSON.stringify({reason:a??"Revoked by user"})});if(!o.ok){const l=await o.json().catch(()=>({error:"Failed to revoke"}));throw new Error(He(l,`Revoke failed: ${o.status}`))}}async getAttestations(s){const a=await this.fetch(`/api/mandates?authorization_id=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch attestations: ${a.status}`);const o=await a.json();return{...o,attestations:o.mandates??o.attestations??[]}}async getGroupById(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch group: ${a.status}`);return a.json()}async createGroup(s){const a=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:s})});if(!a.ok){const u=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(He(u,`Create group failed: ${a.status}`))}const o=await a.json(),l=o.group||o;return{id:l.id,name:l.name,myDomains:l.myDomains||[],isAdmin:!0,ended:o.ended??{mandates:0,proposals:0}}}async getCreatePreview(){const s=await this.fetch("/api/groups/create/preview");if(!s.ok){const a=await s.json().catch(()=>({error:"Unknown error"}));throw new Error(He(a,`Failed to preview team creation: ${s.status}`))}return s.json()}async getJoinPreview(s){const a=await this.fetch(`/api/groups/join/preview?inviteCode=${encodeURIComponent(s)}`);if(!a.ok){const o=await a.json().catch(()=>({error:"Invalid or expired invite code"}));throw new Error(He(o,`Invalid invite code: ${a.status}`))}return a.json()}async requestToJoinGroup(s){const a=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:s})});if(a.status!==202){const l=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(He(l,`Request to join failed: ${a.status}`))}return(await a.json()).request}async withdrawJoinRequest(){const s=await this.fetch("/api/groups/join",{method:"DELETE"});if(s.status===404)return!1;if(!s.ok){const o=await s.json().catch(()=>({error:"Unknown error"}));throw new Error(He(o,`Withdraw failed: ${s.status}`))}return(await s.json()).withdrawn===!0}async inviteToGroup(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/invite`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(He(o,`Invite failed: ${a.status}`))}return a.json()}async getMyTeam(){const s=await this.fetch("/api/groups/me");if(!s.ok)return{group:null,membership:null,pendingRequest:null};const a=await s.json();return{group:a.group??null,membership:a.membership??null,pendingRequest:a.pendingRequest??null}}async listUsers(){const s=await this.fetch("/api/users");return s.ok?(await s.json()).users??[]:[]}async setPubkey(s){const a=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:s})});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(He(o,`setPubkey failed: ${a.status}`))}}async getPubkey(s){const a=await this.fetch(`/api/users/${encodeURIComponent(s)}/pubkey`);return a.status===404||!a.ok?null:(await a.json()).pubkey??null}async leaveTeam(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/leave`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to leave team"}));throw new Error(He(o,`Leave failed: ${a.status}`))}}async getVaultStatus(){const s=await this.fetch("/vault/status");if(!s.ok)throw new Error(`Failed to fetch vault status: ${s.status}`);return s.json()}async getGatewaySettings(){const s=await this.fetch("/api/gateway-settings");if(!s.ok)throw new Error(`Failed to load settings: ${s.status}`);return s.json()}async setGatewaySettings(s){const a=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error(`Failed to save settings: ${a.status}`);return a.json()}async getArchivedMandates(){const s=await this.fetch("/api/archived-mandates");if(!s.ok)throw new Error(`Failed to load archived mandates: ${s.status}`);return(await s.json()).archived}async setMandateArchived(s,a){const o=await this.fetch(`/api/archived-mandates/${encodeURIComponent(s)}`,{method:a?"PUT":"DELETE"});if(!o.ok)throw new Error(`Failed to ${a?"archive":"unarchive"} mandate: ${o.status}`);return(await o.json()).archived}async getLastSeenBlockedAt(){const s=await this.fetch("/api/blocked-seen");if(!s.ok)throw new Error(`Failed to load last-seen: ${s.status}`);return(await s.json()).lastSeenBlockedAt}async markBlockedSeen(s=Date.now()){const a=await this.fetch("/api/blocked-seen",{method:"POST",body:JSON.stringify({ts:s})});if(!a.ok)throw new Error(`Failed to mark blocked seen: ${a.status}`);return(await a.json()).lastSeenBlockedAt}async getLastSeenReportAt(){const s=await this.fetch("/api/report-seen");if(!s.ok)throw new Error(`Failed to load last-seen report: ${s.status}`);return(await s.json()).lastSeenReportAt}async markReportSeen(s=Date.now()){const a=await this.fetch("/api/report-seen",{method:"POST",body:JSON.stringify({ts:s})});if(!a.ok)throw new Error(`Failed to mark report seen: ${a.status}`);return(await a.json()).lastSeenReportAt}async getLastSeenTicketsAt(){const s=await this.fetch("/api/tickets-seen");if(!s.ok)throw new Error(`Failed to load last-seen tickets: ${s.status}`);return(await s.json()).lastSeenTicketsAt}async markTicketsSeen(s=Date.now()){const a=await this.fetch("/api/tickets-seen",{method:"POST",body:JSON.stringify({ts:s})});if(!a.ok)throw new Error(`Failed to mark tickets seen: ${a.status}`);return(await a.json()).lastSeenTicketsAt}async getCredential(s){const a=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to check credential: ${a.status}`);return a.json()}async setCredential(s,a){const o=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`,{method:"PUT",body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to save credential: ${o.status}`)}async testCredential(s){const a=await this.fetch(`/vault/test/${encodeURIComponent(s)}`,{method:"POST"});if(!a.ok)throw new Error(`Test failed: ${a.status}`);return a.json()}async aiAssist(s){const a=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:He(o,"AI request failed"),disclaimer:"AI surfaces reality. You supply intent."}}return a.json()}async aiIntentReview(s){const a=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:He(o,"AI request failed")}}return a.json()}async aiTest(s){const a=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`AI test failed: ${a.status}`);return a.json()}async aiModels(s){const a=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`Model list failed: ${a.status}`);return a.json()}async getMcpHealth(){const s=await this.fetch("/mcp/health");if(!s.ok)throw new Error(`MCP server unreachable: ${s.status}`);return s.json()}async getAgentContact(){const s=await this.fetch("/mcp/agent-contact");if(!s.ok)throw new Error(`Failed to fetch agent contact: ${s.status}`);return s.json()}async getMcpIntegrations(){const s=await this.fetch("/mcp/integrations");if(!s.ok)throw new Error(`Failed to fetch integrations: ${s.status}`);return s.json()}async getOAuthHealth(s){try{const a=await this.fetch(`/auth/oauth/${encodeURIComponent(s)}/health`);return a.ok?await a.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const s=await this.fetch("/mcp/integrations/manifests");if(!s.ok)throw new Error(`Failed to fetch manifests: ${s.status}`);return s.json()}async getLabelManifests(){const{manifests:s,builtins:a}=await this.getIntegrationManifests();return[...s??[],...a??[]]}async discoverScopeField(s,a){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/discover/${encodeURIComponent(a)}`);if(!o.ok){const l=await o.json().catch(()=>({error:`Discovery failed: ${o.status}`}));throw new Error(He(l,`Discovery failed: ${o.status}`))}return o.json()}async activateIntegration(s){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}/activate`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed"}));throw new Error(He(o,`Failed: ${a.status}`))}return a.json()}async removeMcpIntegration(s){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}`,{method:"DELETE"});if(!a.ok)throw new Error(`Failed to remove integration: ${a.status}`)}async setReadPolicy(s,a){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/read-policy`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAgeDays:a})});if(!o.ok){const l=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(He(l,`HTTP ${o.status}`))}}async getTeamProfileConfig(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`);if(o.status===404||!o.ok)return null;const l=await o.json();return(l==null?void 0:l.config)??null}async setTeamProfileConfig(s,a,o){const l=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(o)});if(!l.ok){const u=await l.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(He(u,`setTeamProfileConfig failed: ${l.status}`))}}async encryptIntent(s,a){const o=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:s,recipients:a})});if(!o.ok){const l=await o.json().catch(()=>({error:"Encryption failed"}));throw new Error(He(l,`encryptIntent failed: ${o.status}`))}return o.json()}async getToolDisplay(){const s=await this.fetch("/tool-display");if(!s.ok)return{};const a=await s.json();return(a==null?void 0:a.tools)??{}}async getApproversPubkeys(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}/approvers/pubkeys`);return o.ok?xx(await o.json()):[]}async deleteTeamProfileConfig(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`,{method:"DELETE"});if(!o.ok){const l=await o.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(He(l,`deleteTeamProfileConfig failed: ${o.status}`))}}async getIdentityDisclosure(){const s=await this.fetch("/api/users/me/identity-disclosure");if(!s.ok)throw new Error(`Failed to read identity setting: ${s.status}`);return s.json()}async setIdentityDisclosure(s){const a=await this.fetch("/api/users/me/identity-disclosure",{method:"PUT",body:JSON.stringify({always:s})});if(!a.ok)throw new Error(`Failed to save identity setting: ${a.status}`);return a.json()}async getProposals(s,a="pending"){const o=a==="all"?"&status=all":"",l=await this.fetch(`/api/proposals?domain=${encodeURIComponent(s)}${o}`);if(!l.ok)throw new Error(`Failed to fetch proposals: ${l.status}`);return(await l.json()).proposals??[]}async getMyProposals(s,a="pending"){const o=await Promise.all(px(s).map(l=>this.getProposals(l,a)));return gx(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(He(x,`Failed: ${y.status}`))}return y.json()}async getProposal(s){const a=await this.fetch(`/api/proposals/${encodeURIComponent(s)}`);if(!a.ok){const l=await a.json().catch(()=>({error:"Failed"}));throw new Error(He(l,`getProposal failed: ${a.status}`))}const o=await a.json();return o.proposal??o}async getProposalsForApprover(){const s=await this.fetch("/api/proposals?approver=me");if(!s.ok)throw new Error(`Failed to fetch approver proposals: ${s.status}`);return(await s.json()).proposals??[]}async approveProposal(s,a,o){const l={};a&&(l.content_hash=a),o&&(l.shown_hash=o);const u=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/approve`,{method:"POST",body:Object.keys(l).length>0?JSON.stringify(l):void 0});if(!u.ok){const f=await u.json().catch(()=>({error:"Failed"}));throw new Error(He(f,`approveProposal failed: ${u.status}`))}return u.json()}async rejectProposal(s,a,o,l){let u;if(typeof a=="string")u={reason:a};else{const{noteEncrypted: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(He(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(He(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(He(l,`decryptIntent failed: ${a.status}`))}return(await a.json()).intent}async decryptProposalContent(s){const a=await this.fetch("/api/decrypt-proposal-content",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(He(o,`decryptProposalContent failed: ${a.status}`))}return a.json()}async encryptProposalNote(s,a){const o=await this.fetch("/api/encrypt-proposal-note",{method:"POST",body:JSON.stringify({note:s,recipientUserIds:a})});if(!o.ok){const l=await o.json().catch(()=>({error:"Encryption failed"}));throw new Error(He(l,`encryptProposalNote failed: ${o.status}`))}return o.json()}async storeApprovedIntent(s,a){const o=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:s,intent:a})});if(!o.ok){const l=await o.json().catch(()=>({error:"Failed"}));throw new Error(He(l,`storeApprovedIntent failed: ${o.status}`))}}async listTeamAuthorizations(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/mandates`);if(!a.ok)throw new Error(`Failed to fetch team authorizations: ${a.status}`);return((await a.json()).mandates??[]).map(l=>{var 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(He(o,`Push gate content failed: ${a.status}`))}}async getAgentContext(){const s=await this.fetch("/agent-brief/context");if(!s.ok)throw new Error(`Failed to fetch agent context: ${s.status}`);return(await s.json()).content}async saveAgentContext(s){const a=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:s})});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(He(o,`Save failed: ${a.status}`))}}async aiChat(s){const a=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI chat failed"}));return{success:!1,error:He(o,`Chat failed: ${a.status}`)}}return a.json()}async getAIPrompts(){const s=await this.fetch("/ai-prompts");if(!s.ok)throw new Error(`Failed to load AI prompts: ${s.status}`);return s.json()}async setAIPrompt(s,a){const o=await this.fetch(`/ai-prompts/${s}`,{method:"PUT",body:JSON.stringify({value:a})});if(!o.ok){const l=await o.json().catch(()=>({error:"Save failed"}));throw new Error(He(l,`Save failed: ${o.status}`))}}}const z=new wx,dh=m.createContext(null);function jx({children:t}){const[s,a]=m.useState(null),[o,l]=m.useState("personal"),[u,f]=m.useState(null),[g,p]=m.useState(""),[v,y]=m.useState(null),[x,j]=m.useState(null),[k,b]=m.useState(null),[S,N]=m.useState(!1),[E,T]=m.useState(""),P=m.useRef(!1),A=m.useRef(null),D=m.useCallback(async()=>{if(P.current)try{const Z=await z.getMyTeam();if(b(Z.pendingRequest),Z.group&&Z.membership){const{group:F,membership:ne}=Z;y(F),j(ne),l("team"),f(F);const he=A.current??ne.domains[0]??"owner";p(he)}else y(null),j(null),l("personal")}catch{}},[]);m.useEffect(()=>{const Z=()=>{document.visibilityState==="visible"&&D()};return document.addEventListener("visibilitychange",Z),()=>document.removeEventListener("visibilitychange",Z)},[D]),m.useEffect(()=>{fetch("/health").then(Z=>Z.json()).then(Z=>{var F;((F=Z.session)==null?void 0:F.lockedReason)==="as-url-changed"&&T(`Authority Server changed to ${Z.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const O=m.useCallback(async(Z,F={})=>{N(!0),T("");try{z.setApiKey(Z),P.current=!0;const ne=await z.login(Z,F);a(ne),A.current=ne.id;const he=await z.getGroups(),Q=he.find(ve=>ve.isPersonal)??he[0]??null;f(Q),p("owner"),await D()}catch(ne){throw z.clearApiKey(),P.current=!1,T(ne instanceof Error?ne.message:"Login failed"),ne}finally{N(!1)}},[D]),K=m.useCallback(async()=>{await z.logout(),z.clearApiKey(),P.current=!1,A.current=null,a(null),f(null),p(""),y(null),j(null),b(null),l("personal"),T("")},[]),L=m.useCallback(Z=>{z.clearApiKey(),P.current=!1,A.current=null,a(null),f(null),p(""),y(null),j(null),b(null),l("personal"),T(Z??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),W=m.useCallback(()=>T(""),[]),te=m.useCallback((Z,F)=>{f(Z),p(F)},[]);return n.jsx(dh.Provider,{value:{user:s,mode:o,group:u,domain:g,groupId:(u==null?void 0:u.id)??null,activeTeam:v,activeMembership:x,pendingRequest:k,isLoading:S,error:E,login:O,logout:K,clearError:W,handleSessionLocked:L,activeGroup:u,activeDomain:g,groups:u?[u]:[],setActiveContext:te,refreshGroups:D},children:t})}function xt(){const t=m.useContext(dh);if(!t)throw new Error("useAuth must be used within AuthProvider");return t}const Sx={"integration-changed":!0,"attestation-changed":!0,"proposal-added":!0,"proposal-resolved":!0,"team-membership-changed":!0,"action-approval-needed":!0,"action-resolved":!0,"proposal-approved":!0,"proposal-rejected":!0,"session-locked":!0,"execution-failed":!0,"denial-recorded":!0,"ticket-recorded":!0,"report-written":!0},bx=Object.keys(Sx),fh=m.createContext(null);function kx({children:t}){const{user:s}=xt(),a=m.useRef(null),[o,l]=m.useState(!1),u=m.useRef(new Map),f=m.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 m.useEffect(()=>{if(!s){a.current&&(a.current.close(),a.current=null,l(!1));return}if(a.current)return;const g=z.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 bx)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 k of j)try{k(x)}catch(b){console.error(`[EventSource] handler for "${v}" threw:`,b)}});return()=>{p.close(),a.current=null,l(!1)}},[s]),n.jsx(fh.Provider,{value:{connected:o,addListener:f},children:t})}function Fe(t,s){const a=m.useContext(fh);if(!a)return;const{addListener:o}=a;m.useEffect(()=>o(t,s),[t,s,o])}const aa="suveren-theme",Wf="hap-theme";function Ci(t){return t!=="system"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const s=localStorage.getItem(Wf);s!==null&&localStorage.getItem(aa)===null&&localStorage.setItem(aa,s),s!==null&&localStorage.removeItem(Wf)})();function mh(){const[t,s]=m.useState(()=>{const u=localStorage.getItem(aa);return u==="light"||u==="dark"?u:"system"}),[a,o]=m.useState(()=>Ci(t));m.useEffect(()=>{const u=document.documentElement,f=Ci(t);u.setAttribute("data-theme",f),t==="system"?localStorage.removeItem(aa):localStorage.setItem(aa,t),o(Ci(t))},[t]),m.useEffect(()=>{if(t!=="system")return;const u=window.matchMedia("(prefers-color-scheme: dark)"),f=()=>o(Ci("system"));return u.addEventListener("change",f),()=>u.removeEventListener("change",f)},[t]);const l=m.useCallback(()=>{s(u=>u==="system"?"light":u==="light"?"dark":"system")},[]);return{theme:t,effectiveTheme:a,toggle:l}}const Nx=300*1e3,Cx=2e3;function $c(){const[t,s]=m.useState(!1),[a,o]=m.useState("docker"),[l,u]=m.useState(""),[f,g]=m.useState(null),[p,v]=m.useState(!1),[y,x]=m.useState(!1),[j,k]=m.useState(!1),b=m.useRef(null);return m.useEffect(()=>{let S=!1;const N=(P=!1)=>{fetch(P?"/health?refresh=1":"/health").then(A=>A.json()).then(A=>{S||(A.installMethod&&o(A.installMethod),typeof A.latestVersion<"u"&&g(A.latestVersion),A.updateAvailable&&s(!0),A.version&&(u(A.version),b.current===null?b.current=A.version:A.version!==b.current&&A.version!=="dev"&&v(!0)))}).catch(()=>{})};N(!0);const E=setInterval(()=>N(!1),j?Cx:Nx),T=()=>{document.visibilityState==="visible"&&N(!1)};return document.addEventListener("visibilitychange",T),window.addEventListener("focus",T),()=>{S=!0,clearInterval(E),document.removeEventListener("visibilitychange",T),window.removeEventListener("focus",T)}},[j]),{updateAvailable:t&&!y,installMethod:a,version:l,latestVersion:f,serverRestarted:p,startFastPolling:()=>k(!0),dismiss:()=>x(!0)}}function Ex(t){return!t||typeof t!="object"?{managed:!1}:{managed:Array.isArray(t.policyLocked)&&t.policyLocked.includes("team")}}function Tx(){const[t,s]=m.useState({managed:!1});return m.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(Ex(o))}).catch(()=>{}),()=>{a=!0}},[]),t}function Ix({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 Ax(t){return t?t==="dev"?"dev":/^[0-9a-f]{40}$/i.test(t)?t.slice(0,7):t:""}const Hf={system:"◑",light:"☀",dark:"☾"};function _c({onMenuToggle:t}){const{user:s,logout:a,mode:o,activeTeam:l}=xt(),{theme:u,toggle:f}=mh(),{version:g,updateAvailable:p,latestVersion:v}=$c(),{managed:y}=Tx(),x=Ax(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(Ix,{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:Hf[u]}),n.jsx("button",{className:"nav-logout",onClick:a,children:"Logout"})]}):n.jsx("button",{className:"theme-toggle",onClick:f,title:`Theme: ${u}`,children:Hf[u]})}),s&&t&&n.jsx("button",{className:"mobile-menu-btn",onClick:t,"aria-label":"Menu",children:"☰"})]})})}function Lc(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 hh(t){return t==="expired"||t==="revoked"}function ph(t,s){var a;return!!((a=s==null?void 0:s.archivedSet)!=null&&a.has(t.authorization_id))&&hh(Lc(t,s))}function zi(t,s){return ph(t,s)?"archived":Lc(t,s)}function gh(t,s){const a={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const o of t)a[zi(o,s)].push(o);return a}function Rx(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 Ft(t,s,a){const o=m.useRef(t);o.current=t,m.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 zc(){const[t,s]=m.useState(!1);return m.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 Px(t,s){const a=t.simulation;return a?(((s==null?void 0:s[a.field])??"").trim().toLowerCase()||a.default.trim().toLowerCase())==="simulation":!1}function la(t){return!!(t!=null&&t.simulation)}const yh=m.createContext(null),$x=3e4,_x=5e3,Lx=3e5;function zx(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 Fx({children:t}){const[s,a]=m.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),o=m.useRef(null),l=m.useCallback(async()=>{let y=!1;const[x,j]=await Promise.all([z.getIntegrationManifests().catch(()=>(y=!0,{manifests:[]})),z.getMcpHealth().catch(()=>null)]);a(b=>({...b,manifests:x.manifests,integrations:(j==null?void 0:j.integrations)??b.integrations,activeSessions:(j==null?void 0:j.activeSessions)??b.activeSessions,mcpServerUp:!!j,manifestsError:y,fetchCount:b.fetchCount+1}));const k=x.manifests.filter(b=>b.oauth);if(k.length>0){const b=await Promise.all(k.map(async S=>[S.id,await z.getOAuthHealth(S.id)]));a(S=>({...S,authHealth:Object.fromEntries(b)}))}},[]),u=s.fetchCount>0&&s.manifests.some(y=>{const x=s.integrations.find(j=>j.id===y.id);return x&&!x.running&&!x.paused});Fe("integration-changed",l),Ft(l,u?_x:Lx);const f=m.useMemo(()=>{const y=new Map(s.integrations.map(k=>[k.id,k])),x=Date.now();u&&o.current===null?o.current=x:u||(o.current=null);const j=o.current!==null&&x-o.current<$x;return s.manifests.map(k=>{const b=y.get(k.id),S=zx(b,s.fetchCount,j),N=s.authHealth[k.id];return{id:k.id,manifest:k,integration:b,state:S,authStatus:N==null?void 0:N.status,authAccount:N==null?void 0:N.account,authError:N==null?void 0:N.error}})},[s,u]),g=zc(),p=m.useMemo(()=>f.filter(y=>!(g&&!la(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(yh.Provider,{value:v,children:t})}function Fc(){const t=m.useContext(yh);if(!t)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return t}const Mx={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},Mc=t=>Mx[t]??t,Ox={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 Bx(t){return(t&&Ox[t])??{chip:"Blocked",sev:"info"}}function Dx(t){const s=Mc(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 vh(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 Ux=5,Wx=1440*60*1e3,Hx=7;function Vx(t,s){const a=s-Hx*Wx;return{recent:t.filter(o=>o.ts>=a),all:t}}function Gx(){const[t,s]=m.useState(null),[a,o]=m.useState(!1),[l,u]=m.useState(null),f=m.useCallback(()=>{z.getDenials({limit:200}).then(({records:x})=>{s(x),o(!1)}).catch(()=>o(!0)),z.getLastSeenBlockedAt().then(u).catch(()=>u(0))},[]);if(m.useEffect(()=>{f()},[f]),Ft(f,12e4),Fe("denial-recorded",f),m.useEffect(()=>(window.addEventListener("suveren:blocked-seen-changed",f),()=>window.removeEventListener("suveren:blocked-seen-changed",f)),[f]),a||t===null||l===null)return null;const{all:g}=Vx(t,Date.now()),p=g.filter(x=>x.ts>l);if(p.length===0)return null;const v=p.slice(0,Ux),y=(x,j)=>{const k=Bx(x.reason);return n.jsxs("div",{className:"rb-row",children:[n.jsx("span",{className:`rb-dot ${k.sev==="act"?"act":k.sev==="info"?"info":""}`,"aria-hidden":"true"}),n.jsxs("div",{className:"rb-body",children:[n.jsx("div",{className:"rb-line",children:Dx(x)}),n.jsxs("div",{className:"rb-meta",children:[n.jsx("span",{className:`rb-chip ${k.sev==="act"?"act":k.sev==="warn"?"warn":""}`,children:k.chip}),n.jsx("span",{className:"rb-via",children:Mc(x.integrationId)})]}),k.fixTo&&n.jsx(ht,{className:"rb-fix",to:k.fixTo,children:"Set a read window →"})]}),n.jsx("div",{className:"rb-when",children:vh(x.ts,Date.now())})]},`${x.ts}-${j}`)};return n.jsxs("section",{className:"card recent-blocks","aria-label":"Recent blocks",style:{marginTop:"1.5rem"},children:[n.jsxs("div",{className:"card-header",children:[n.jsx("h2",{className:"card-title",children:"Recent blocks"}),n.jsx("span",{className:"rb-count",children:p.length})]}),n.jsx("p",{className:"rb-sub",children:"New since you last looked. Limits you set that stopped your agent — the gateway doing its job."}),n.jsx("div",{className:"rb-rows",children:v.map(y)}),n.jsxs(ht,{className:"col-btn",to:"/blocked",children:["View all ",g.length," blocks from the last 30 days ›"]})]})}function eo(t){return t.kind??"read"}function Kx(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 qx={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"},Yx={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 Vf(t){return t===void 0?"":typeof t=="number"?t.toLocaleString():t}function Jx(t,s){const a=eo(t),o=Vf(t.value),l=Vf(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 xh(t,s){if(t.mandateId){const a=s==null?void 0:s[t.mandateId];if(a)return a}return t.mandateTitle}function Qx(t,s){const a=xh(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 Xx(t,s){const a=eo(t),o=Mc(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}`},...Qx(t,s),{text:` · ${l}${u}`}]}function Zx(t,s,a){const o=eo(t),l=Kx(s,t.field);return{title:qx[o],sentence:Jx(t,l),sourceLine:Xx(t,a),whatYouCanDo:Yx[o]}}function e0(t,s){const a=new Date(s);return a.setHours(0,0,0,0),t.filter(o=>o.ts>=a.getTime()).length}function t0(t,s){return t.filter(a=>a.ts>s).length}const n0=1440*60*1e3;function r0(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-n0?`Yesterday · ${a}`:`${new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})} · ${a}`}function wh(t,s){return!!t&&t.savedAt*1e3>s}function s0(t){const s=/<h[1-3][^>]*>([\s\S]*?)<\/h[1-3]>/i.exec(t),a=s?s[1].replace(/<[^>]+>/g,"").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/\s+/g," ").trim():"";return a?a.length>80?`${a.slice(0,79)}…`:a:"Report"}function a0(t){var s,a;return{verified:((a=(s=t.proof)==null?void 0:s.verifiedValues)==null?void 0:a.length)??0,unchecked:(t.elements??[]).filter(o=>o.status==="unverifiable").length}}const Gf=(t,s)=>new Date(t*1e3).toLocaleString(s,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),Kf=(t,s)=>new Date(t*1e3).toLocaleString(s,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"});function Fi(t,s){const a=t==null?void 0:t.window;return a?{text:`Covers ${Gf(a.start,s)} → ${Gf(a.end,s)} (${a.days} day${a.days===1?"":"s"})`,title:`From ${Kf(a.start,s)} to ${Kf(a.end,s)}. Tickets up to 2 minutes after the end count, for small clock differences.`}:{text:"Period not recorded"}}function jh(t,s,a){const o=new Date(t*1e3),l=o.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"}),u=Math.floor((s-t*1e3)/864e5);if(new Date(s).toDateString()===o.toDateString())return`today ${l}`;const g=`${o.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`;return u>=2?`${g} (${u} days ago)`:g}const i0=[{to:"/",icon:"□",label:"Dashboard",group:"top"},{to:"/approvals",icon:"▷",iconClass:"nav-ic-approval",label:"Approvals",statusKey:"proposals",group:"core"},{to:"/mandates",icon:"☰",iconClass:"nav-ic-mandate",label:"Mandates",statusKey:"authorizations",group:"core",quietCount:!0},{to:"/tickets",icon:"▣",iconClass:"nav-ic-ticket",label:"Tickets",group:"core"},{to:"/reports",icon:"▥",label:"Reports",statusKey:"report",newLabel:!0,group:"core"},{to:"/blocked",icon:"⊘",iconClass:"nav-ic-blocked",label:"Blocked",statusKey:"blocked",group:"core"},{to:"/team",icon:"◉",label:"Team",teamOnly:!0,group:"setup"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief",group:"setup"},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations",group:"setup"},{to:"/settings",icon:"⚙",label:"Settings",statusKey:"assistant",group:"setup"}];function o0(){const{activeDomain:t}=xt(),[s,a]=m.useState({}),o=m.useCallback(async()=>{try{const[l,u,f,g,p,v,y,x,j,k]=await Promise.all([z.getCredential("ai-config").catch(()=>null),z.getMyAttestations().catch(()=>null),z.getMyProposals(t).catch(()=>null),z.getProposalsForApprover().catch(()=>null),z.getAgentContext().catch(()=>""),z.getArchivedMandates().catch(()=>[]),z.getDenials({limit:200}).catch(()=>null),z.getLastSeenBlockedAt().catch(()=>0),z.getReport().catch(()=>null),z.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]),b={};if(l&&!l.configured&&(b.assistant=1),u){const T=gh(u,{archivedSet:new Set(v)}).expired.length;T>0&&(b.authorizations=T)}const S=(f==null?void 0:f.length)??0,N=(g==null?void 0:g.length)??0,E=S+N;if(E>0&&(b.proposals=E),(!p||!p.trim())&&(b.brief=1),y){const T=t0(y.records,x);T>0&&(b.blocked=T)}wh(j==null?void 0:j.report,k)&&(b.report=1),a(b)}catch{}},[t]);return Fe("attestation-changed",o),Fe("proposal-added",o),Fe("proposal-resolved",o),Fe("proposal-approved",o),Fe("proposal-rejected",o),Fe("team-membership-changed",o),Fe("denial-recorded",o),Fe("report-written",o),m.useEffect(()=>(window.addEventListener("suveren:archived-changed",o),()=>window.removeEventListener("suveren:archived-changed",o)),[o]),m.useEffect(()=>(window.addEventListener("suveren:blocked-seen-changed",o),window.addEventListener("suveren:report-seen-changed",o),()=>{window.removeEventListener("suveren:blocked-seen-changed",o),window.removeEventListener("suveren:report-seen-changed",o)}),[o]),Ft(o,3e5,t),s}const l0={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},c0={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 u0(){const{mode:t,activeTeam:s}=xt(),a=o0(),{attentionCount:o}=Fc(),l={...a};o>0&&(l.integrations=o);const u=i0.filter(y=>!y.teamOnly||t==="team"),f=m.useRef(null),[g,p]=m.useState(null),v=Qt();return m.useEffect(()=>{if(f.current===null){f.current=t;return}f.current!==t&&(t==="team"&&s?p(`You are now acting in team context — ${s.name}`):t==="personal"&&p("You have left the team — back to personal context"),f.current=t)},[t,s]),m.useEffect(()=>{p(null)},[v.pathname]),n.jsxs("div",{className:"sidebar",children:[["top","core","setup"].map(y=>{const x=u.filter(j=>(j.group??"setup")===y);return x.length===0?null:n.jsxs("div",{className:`sidebar-${y}`,children:[y==="setup"&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sidebar-divider"}),n.jsx("div",{className:"sidebar-group-label",children:"Setup"})]}),n.jsx("ul",{className:"sidebar-nav",children:x.map(j=>{const k=j.statusKey?l[j.statusKey]:0;return n.jsx("li",{children:n.jsxs(Pc,{to:j.to,end:j.to==="/",className:({isActive:b})=>`sidebar-item${b?" active":""}`,children:[n.jsx("span",{className:"icon",children:j.iconClass?n.jsx("span",{className:`nav-ic ${j.iconClass}`,"aria-hidden":"true"}):j.icon}),j.label,k?j.newLabel?n.jsx("span",{className:"nav-new","data-testid":`nav-new-${j.statusKey}`,children:"New"}):n.jsx("span",{style:l0,className:j.quietCount?"nav-count-quiet":void 0,title:j.quietCount?"Expired mandates":void 0,children:k}):null]})},j.to)})})]},y)}),g&&n.jsx("div",{style:c0,role:"status","aria-live":"polite",children:g})]})}const Ql="suveren:updatedTo";function d0(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 f0="Updates for this gateway come from your company's IT — no action needed here.";function m0(t){return t==="managed"?"update-banner is-managed":"update-banner"}const h0="Download the new installer and run it. Your settings and mandates stay.";function p0(t){const s="https://github.com/suverenai/suveren-gateway/releases";return t?`${s}/tag/v${t}`:`${s}/latest`}function g0(){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 Sh(){const{updateAvailable:t,installMethod:s,version:a,latestVersion:o,serverRestarted:l,startFastPolling:u,dismiss:f}=$c(),[g,p]=m.useState(!1),[v,y]=m.useState(!1),[x,j]=m.useState(()=>{try{const P=sessionStorage.getItem(Ql);if(P)return sessionStorage.removeItem(Ql),P}catch{}return null}),k=d0(s),b=m.useRef(null),S=P=>{try{sessionStorage.setItem(Ql,P||o||"✓")}catch{}window.location.reload()};m.useEffect(()=>{if(!x)return;const P=setTimeout(()=>j(null),6e3);return()=>clearTimeout(P)},[x]),m.useEffect(()=>{if(!g||!l)return;const P=()=>g0()?!1:(S(a),!0);if(P())return;const A=setInterval(P,1500);return()=>clearInterval(A)},[g,l,a]),m.useEffect(()=>(document.body.classList.toggle("is-updating",g),()=>document.body.classList.remove("is-updating")),[g]);const N=t&&!g&&!x||!!x&&!g;m.useEffect(()=>{if(!N){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const P=()=>{var O;const D=((O=b.current)==null?void 0:O.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${D}px`)};P();const A=new ResizeObserver(P);return b.current&&A.observe(b.current),()=>{A.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[N]);const E=()=>{p(!0),u()},T=async()=>{if(k)try{await navigator.clipboard.writeText(k),y(!0),setTimeout(()=>y(!1),1800)}catch{}};return n.jsxs(n.Fragment,{children:[x&&!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:m0(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:p0(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:f0}),s==="msi"&&n.jsx("p",{className:"update-banner-hint",children:h0})]}),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:k}),n.jsx("button",{className:"btn btn-sm btn-primary",onClick:T,children:v?"Copied":"Copy"})]}),n.jsxs("div",{className:"update-status",children:[n.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),n.jsxs("div",{className:"update-overlay-actions",children:[n.jsx("button",{className:"btn btn-primary",onClick:()=>S(a),children:"Reload now"}),n.jsx("button",{className:"btn btn-secondary",onClick:()=>p(!1),children:"Cancel"})]})]})})]})}function bh(){const t=zc(),s=m.useRef(null);return m.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 y0={system:"◑",light:"☀",dark:"☾"},v0=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Approvals"},{to:"/mandates",icon:"☰",label:"Mandates"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/blocked",icon:"⊘",label:"Blocked"},{to:"/team",icon:"◉",label:"Team"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"Settings"}];function x0({open:t,onClose:s}){const{user:a,activeGroup:o,activeDomain:l,logout:u}=xt(),{theme:f,toggle:g}=mh(),p=Qt();return m.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:v0.map(v=>n.jsxs(Pc,{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:y0[f]}),"Theme: ",f]}),n.jsx("button",{className:"mobile-menu-action",onClick:()=>{u(),s()},children:"Logout"})]})]})]}):null}function kh(t){return t.status==="pending"}function w0(t,s){return t.filter(kh).length+s.length}const br=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],j0=500;function Nh(){const{user:t,domain:s}=xt(),[a,o]=m.useState(0),l=m.useRef(null),u=m.useCallback(async()=>{if(!t){o(0);return}try{const[g,p]=await Promise.all([z.getMyProposals(s).catch(()=>[]),z.getProposalsForApprover().catch(()=>[])]);o(w0(g,p))}catch{o(0)}},[t,s]),f=m.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{u()},j0)},[u]);return m.useEffect(()=>(u(),()=>{l.current&&clearTimeout(l.current)}),[u]),Fe(br[0],f),Fe(br[1],f),Fe(br[2],f),Fe(br[3],f),Fe(br[4],f),Fe(br[5],f),Fe(br[6],f),a}const qf="Suveren",S0="/favicon.svg",b0="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",Ei={x1:74.54,y1:22.74,x2:94.46,y2:34.24},k0=14,N0="#f59e0b";function C0(t){const s=Oc(t);return s>0?`(${s}) ${qf}`:qf}function Oc(t){return Number.isFinite(t)&&t>0?Math.floor(t):0}function E0(){const t=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
52
+ <path class="m" d="${b0}"/>
53
+ <line class="m" x1="${Ei.x1}" y1="${Ei.y1}" x2="${Ei.x2}" y2="${Ei.y2}"/>
54
+ <circle cx="103" cy="103" r="25" fill="${N0}"/>
55
+ <style>.m{stroke:#111111;stroke-width:${k0};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 T0(){return document.querySelector('link[rel="icon"]')}function Ch(t){const s=Oc(t);document.title=C0(s),Eh(s);const a=T0();if(!a)return;const o=s>0?E0():S0;a.getAttribute("href")!==o&&a.setAttribute("href",o)}function I0(){Ch(0)}function Eh(t,s=globalThis.navigator){var l;if(!s||typeof s.setAppBadge!="function")return;const a=Oc(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 A0(){const t=Nh();return m.useEffect(()=>{Ch(t)},[t]),m.useEffect(()=>I0,[]),null}const Th="suveren:dockBadgePrompt";function R0(){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(Th))return!1}catch{}return!0}function P0(){const[t,s]=m.useState(!1),a=Nh();if(m.useEffect(()=>{s(R0())},[]),!t)return null;const o=()=>{try{localStorage.setItem(Th,"1")}catch{}s(!1)},l=async()=>{try{await Notification.requestPermission()==="granted"&&Eh(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 $0(){const[t,s]=m.useState(!1);return n.jsxs(Fx,{children:[n.jsx(A0,{}),n.jsx(_c,{onMenuToggle:()=>s(!t)}),n.jsx(Sh,{}),n.jsx(bh,{}),n.jsx(u0,{}),n.jsx(x0,{open:t,onClose:()=>s(!1)}),n.jsx("div",{className:"main-content",children:n.jsxs("div",{className:"page-inner",children:[n.jsx(P0,{}),n.jsx(Pv,{})]})})]})}function Ih({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 Bc(){return typeof navigator<"u"&&navigator.webdriver===!0}const Dc="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function _0(){const[t,s]=m.useState(""),{login:a,isLoading:o,error:l,clearError:u}=xt(),[f,g]=m.useState(null),p=Bc(),v=async()=>{if(!(!t.trim()||p)){u();try{await a(t)}catch(j){if(j instanceof ch){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(_c,{}),n.jsx(Sh,{}),n.jsx(bh,{}),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(Ih,{what:"sign-in"}),p&&n.jsx("div",{className:"error-message",children:Dc}),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,k)=>n.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:k<2?"0.5rem":0},children:[n.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[k+1,"."]}),j]},k))})]})]})})]}),f&&n.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wipe-warning-title",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-main) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:x,children:n.jsxs("div",{className:"card",onClick:j=>j.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[n.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["This gateway already holds data for another account. Signing in with this API key will ",n.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),n.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[n.jsxs("li",{children:[f.credentialCount," stored service credential",f.credentialCount===1?"":"s",f.credentialIds.length>0&&n.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",f.credentialIds.slice(0,5).join(", "),f.credentialIds.length>5?`, +${f.credentialIds.length-5} more`:"",")"]})]}),n.jsxs("li",{children:[f.serviceCount," configured integration",f.serviceCount===1?"":"s"]}),n.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),n.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Mandates and tickets on the Authority Server are NOT affected — only this gateway's local state is wiped."}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:"If this isn't what you wanted, cancel and sign back in with the original API key, or use a different gateway instance for this account."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:x,disabled:o,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:y,disabled:o,children:o?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function L0(t,s){return!s&&t!=null}function z0(t,s){return t==="join-waiting"&&s==="team"}function F0(t,s,a,o){return a!=null||t!=="join-waiting"||s==="team"?null:o}function M0(t){return`${t} personal mandate${t===1?"":"s"}`}function O0({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 B0(){const{mode:t,pendingRequest:s,refreshGroups:a}=xt(),o=Sn(),[l,u]=m.useState("choose"),[f,g]=m.useState(""),[p,v]=m.useState(""),[y,x]=m.useState(null),[j,k]=m.useState(null),[b,S]=m.useState(""),[N,E]=m.useState(""),[T,P]=m.useState(!1),A=m.useRef(!1);m.useEffect(()=>{L0(s,A.current)&&(A.current=!0,u("join-waiting"))},[s]),m.useEffect(()=>{z0(l,t)&&o("/")},[l,t,o]);const D=m.useRef(null);m.useEffect(()=>{if(s){D.current=s.groupName;return}const F=F0(l,t,s,D.current);F&&(S(F),u("join-declined"),D.current=null)},[s,l,t]),m.useEffect(()=>{if(l!=="join-waiting")return;const F=setInterval(()=>{a()},5e3);return()=>clearInterval(F)},[l,a]);const O=m.useCallback(()=>{u("choose"),E(""),x(null),k(null),g(""),v("")},[]),K=async()=>{if(f.trim()){P(!0),E("");try{const F=await z.getJoinPreview(f.trim());x(F),u("join-preview")}catch(F){E(F instanceof Error?F.message:"Invalid or expired invite code")}finally{P(!1)}}},L=async()=>{P(!0),E("");try{await z.requestToJoinGroup(f.trim()),await a(),u("join-waiting")}catch(F){E(F instanceof Error?F.message:"Failed to join group")}finally{P(!1)}},W=async()=>{P(!0),E("");try{await z.withdrawJoinRequest(),await a(),O()}catch(F){E(F instanceof Error?F.message:"Failed to withdraw request")}finally{P(!1)}},te=async()=>{u("create"),E(""),P(!0);try{const F=await z.getCreatePreview();k(F)}catch(F){E(F instanceof Error?F.message:"Failed to load preview")}finally{P(!1)}},Z=async()=>{if(p.trim()){P(!0),E("");try{await z.createGroup(p.trim()),await a(),o("/")}catch(F){E(F instanceof Error?F.message:"Failed to create group")}finally{P(!1)}}};return n.jsxs(n.Fragment,{children:[n.jsx(_c,{}),n.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:n.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[N&&n.jsx("div",{className:"error-message",children:N}),l==="choose"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join or create a team"}),n.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6},children:"An account is Personal or in one team — never both. Joining or creating a team moves your account: your personal mandates end (kept in your history)."})]}),n.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[n.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing team"}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),n.jsxs("div",{className:"invite-input-row",children:[n.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:f,onChange:F=>g(F.target.value),onKeyDown:F=>F.key==="Enter"&&K(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:T}),n.jsx("button",{className:"btn btn-primary",onClick:K,disabled:T||!f.trim(),children:T?"Checking…":"Continue"})]})]}),n.jsxs("div",{className:"card",children:[n.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new team"}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members."}),n.jsx("button",{className:"btn btn-secondary",onClick:te,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(O0,{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:L,disabled:T,children:T?"Asking…":"Ask to join"}),n.jsx("button",{className:"btn btn-ghost",onClick:O,disabled:T,children:"Cancel"})]})]}),l==="join-waiting"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request sent to team ",(s==null?void 0:s.groupName)??""]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Waiting for the team admin to confirm. Until then your account stays Personal and your mandates keep working."}),n.jsx("button",{className:"btn btn-secondary",onClick:W,disabled:T,children:T?"Withdrawing…":"Withdraw request"})]}),l==="join-declined"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request to ",b," ended"]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"The team admin declined your request, or it was withdrawn. Your account stays Personal."}),n.jsx("button",{className:"btn btn-primary",onClick:O,disabled:T,children:"Back"})]}),l==="create"&&n.jsxs("div",{className:"card",children:[n.jsx("h3",{style:{marginBottom:"0.75rem"},children:"Create a team"}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:"Team name"}),n.jsx("input",{className:"form-input",placeholder:"e.g., Acme Corp",value:p,onChange:F=>v(F.target.value),onKeyDown:F=>F.key==="Enter"&&Z(),disabled:T,autoFocus:!0})]}),j&&n.jsxs("div",{className:"alert alert-info",style:{color:"white"},children:["Your account moves to the new team. Your ",M0(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:Z,disabled:T||!p.trim(),children:T?"Creating…":"Create team and move my account"}),n.jsx("button",{className:"btn btn-ghost",onClick:O,disabled:T,children:"Cancel"})]})]})]})})]})}const Yf={"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`}},Jf=["claude-code","claude-desktop","chatgpt-codex","other"];function cc({mcpEndpoint:t}){const[s,a]=m.useState(Jf[0]),[o,l]=m.useState(!1),u=m.useCallback(async g=>{try{await navigator.clipboard.writeText(g),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},[]),f=Yf[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:Jf.map(g=>n.jsx("button",{className:`mcp-tab${s===g?" active":""}`,onClick:()=>a(g),children:Yf[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 uc="suveren-setup-ai-skipped",dc="suveren-setup-agent-done",fc="suveren-setup-dismissed",D0={"hap-setup-ai-skipped":uc,"hap-setup-agent-done":dc,"hap-setup-dismissed":fc};function U0(){for(const[t,s]of Object.entries(D0)){const a=localStorage.getItem(t);a!==null&&localStorage.getItem(s)===null&&localStorage.setItem(s,a),a!==null&&localStorage.removeItem(t)}}U0();function W0({aiConfigured:t,hasRunningIntegration:s,hasActiveAuth:a,hasAgentConnected:o,mcpEndpoint:l}){const[u,f]=m.useState(()=>localStorage.getItem(uc)==="true"),[g,p]=m.useState(()=>localStorage.getItem(dc)==="true"),[v,y]=m.useState(()=>localStorage.getItem(fc)==="true"),[x,j]=m.useState(null),k=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status: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=k.filter(A=>A.status==="done"||A.status==="skipped").length,S=b===k.length,N=m.useCallback(()=>{localStorage.setItem(uc,"true"),f(!0)},[]),E=m.useCallback(()=>{localStorage.setItem(dc,"true"),p(!0),j(null)},[]),T=m.useCallback(()=>{localStorage.setItem(fc,"true"),y(!0)},[]);if(v||S)return null;const P=k.findIndex(A=>A.status==="pending");return n.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[n.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),n.jsx("button",{onClick:T,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:k.map((A,D)=>{const O=D===P,K=A.status==="done"||A.status==="skipped"?"●":"○",L=A.status==="done"?"var(--text-primary)":A.status==="skipped"?"var(--text-tertiary)":O?"var(--accent)":"var(--text-tertiary)";return n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:O?"0.75rem":"0.25rem 0",borderRadius:O?"0.5rem":void 0,background:O?"var(--accent-subtle)":void 0},children:[n.jsx("span",{style:{color:L,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:K}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[A.to&&A.status==="pending"?n.jsx(ht,{to:A.to,style:{fontSize:"0.9rem",fontWeight:O?600:500,color:O?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:A.label}):A.status==="pending"&&D===3?n.jsx("button",{onClick:()=>j(x===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:O?600:500,color:O?"var(--accent)":"var(--text-primary)"},children:A.label}):n.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:A.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:A.label}),A.optional&&A.status==="pending"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),A.status==="skipped"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),A.detail&&A.status==="pending"&&O&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:A.detail})]}),A.optional&&A.status==="pending"&&n.jsx("button",{onClick:N,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),A.to&&A.status==="pending"&&n.jsx(ht,{to:A.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),D===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(cc,{mcpEndpoint:l}),n.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:E,children:"Done"})]})]},D)})}),n.jsxs("div",{style:{marginTop:"1.25rem"},children:[n.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:n.jsx("div",{style:{height:"100%",width:`${b/k.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),n.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[b," of ",k.length," complete"]})]})]})}function Ah(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 H0="/mandates?new=1&profile=delegation";function Qf({text:t}){const[s,a]=m.useState(!1),o=m.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 Xl({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 V0({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]=m.useState(null),y=Ah(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 ",vh(Date.parse(t.lastSeenAt),Date.now()).toLowerCase()]}):n.jsx(Xl,{todo:y.step1.status==="todo",onOpen:()=>v(0),children:"Connect your AI"})]}),y.step1.status==="open"&&n.jsx("div",{className:"flow-step-body",children:y.step1.variant==="managed"?n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Your IT sets up the connection. Open your AI — if Suveren isn't there, contact your IT."}),n.jsxs("details",{className:"int-details",children:[n.jsx("summary",{children:"For your IT"}),n.jsx("div",{style:{marginTop:"0.75rem"},children:n.jsx(cc,{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(Qf,{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(cc,{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(ht,{to:"/mandates",children:"review or revoke under Mandates"})]}):n.jsx(Xl,{todo:y.step2.status==="todo",onOpen:()=>v(1),children:"Give the Delegation mandate"})]}),y.step2.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.jsx("p",{children:"Delegation lets your AI propose the rest of its own setup — new mandates and its working instructions. It can only propose; nothing changes until you approve it."}),n.jsxs("ul",{className:"bound-list",children:[n.jsx("li",{children:"Read the setup guides"}),n.jsx("li",{children:"Propose new mandates — each waits for your approval"}),n.jsx("li",{children:"Propose an updated agent brief — also waits for your approval"})]}),y.step2.simulationOn?n.jsxs(n.Fragment,{children:[n.jsx(ht,{to:H0,className:"btn btn-primary",children:"Give the Delegation mandate →"}),n.jsx("p",{className:"cta-helper",children:"You set the daily limit in the next step."}),y.step2.variant==="managed"&&n.jsx("p",{className:"managed-note",children:"In a company team you may need approver rights — ask your IT if the button is refused."})]}):n.jsx("p",{className:"managed-note",style:{marginTop:0},children:y.step2.variant==="managed"?"Delegation works in simulation mode only. Ask your IT to turn on simulation mode.":n.jsxs(n.Fragment,{children:["Delegation works in simulation mode only. Turn it on with ",n.jsx("code",{children:"suveren-gateway simulation on"})," and restart."]})})]})]}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step3.status==="open"?"open":"todo"}`,children:"3"}),n.jsx(Xl,{todo:y.step3.status==="todo",onOpen:()=>v(2),children:"Ask your AI: “How do I start with Suveren?”"})]}),y.step3.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.875rem"},children:n.jsxs("div",{className:"quote-box",children:[n.jsx("span",{className:"quote-text",children:"“How do I start with Suveren?”"}),n.jsx(Qf,{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(ht,{to:"/approvals",children:"Approvals"}),"."]})]})]})]})}function G0(){const[t,s]=m.useState(null);return m.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 K0(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 Rh(){const[t,s]=m.useState({simulation:null,locked:!1});return m.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(K0(o))}).catch(()=>{}),()=>{a=!0}},[]),t}function q0(t){return!t||typeof t!="object"?!1:Array.isArray(t.policyLocked)&&t.policyLocked.length>0}function Y0(){const[t,s]=m.useState(!1);return m.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(f=>f.json()).then(f=>{a||s(q0(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}const Xf=new Map;function Ph(t){let s=Xf.get(t);return s||(s=(async()=>{try{let a=t;if(!t.includes("@")){const o=await z.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 z.getProfile(a)}catch{return null}})(),Xf.set(t,s)),s}function hs(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let o=!0;return t&&Ph(t).then(l=>{o&&a(l)}),()=>{o=!1}},[t]),s}const Zf=40;function Mt(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;return s?s.slice(0,Zf):(u.charAt(0).toUpperCase()+u.slice(1)).slice(0,Zf)}function An(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 Pr(t,s){const a=An(t),o=Ir(t),l=Mt(t,s==null?void 0:s.name);return{icon:o,name:l,testSetup:a==="delegation"}}function to(t){return t.startsWith("setup__")}const J0={customers:"customers",email:"email",charge:"payments",sales:"sales",calendar:"calendar",records:"records",publish:"publishing",deploy:"deployments",purchase:"purchasing",reporting:"reports",delegation:"setup"};function Ir(t){return J0[An(t)]??"unknown"}function em(t){const s=t.indexOf("@");return s>=0?t.slice(s+1):""}function Bn(t,s){const a=An(t),o=s.filter(l=>An(l.id)===a).sort((l,u)=>em(u.id).localeCompare(em(l.id),void 0,{numeric:!0}))[0];return Mt(t,o==null?void 0:o.name)}function Q0(t,s){const a=t==null?void 0:t.trim();return a?a.toLowerCase()!==s.trim().toLowerCase():!1}function $h(t){return t&&t.trim()?t.trim():null}function _h(t,s){return s===null||An(t)===s}let Zl=null;function X0(){return Zl||(Zl=z.listProfiles().catch(()=>[])),Zl}function $r(){const[t,s]=m.useState([]);return m.useEffect(()=>{let a=!0;return X0().then(o=>{a&&s(o)}),()=>{a=!1}},[]),t}function Z0(t){const s=$r();return Bn(t,s)}function no(t){return!t||t==="count"?"":t==="minutes"?"min":t==="hours"?"hr":t==="days"?"days":t==="percent"?"%":t.startsWith("currency:")?t.slice(9):t}const Lh=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview","_source"]);function Jt(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 lr(t){const s=t.indexOf("__");return s<0?{integrationId:"",toolName:t}:{integrationId:t.slice(0,s),toolName:t.slice(s+2)}}function ew(t){const{integrationId:s,toolName:a}=lr(t);return s?`${s} · ${a}`:a}function ps(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 tw(t){return Array.isArray(t)?"list":t&&typeof t=="object"?"object":typeof t=="string"&&(t.includes(`
66
+ `)||t.length>120)?"markdown":"text"}function nw(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)||Lh.has(p))continue;const v=t[p],y=a[p]??{},x=y.kind??tw(v),j={key:p,label:y.label??Jt(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 zh(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 rw(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=no(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)??Jt(g),value:y?`${x} ${y}`:x,hint:v==null?void 0:v.description,unknown:s?!v:void 0})}return f}function Fh(t){const s=t.indexOf("__");return s<0?{integrationId:"",toolName:t}:{integrationId:t.slice(0,s),toolName:t.slice(s+2)}}function ro(t,s){var p,v,y;const{integrationId:a,toolName:o}=Fh(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=Mt(t.profileId),g=(y=t.executionContext)==null?void 0:y.action_type;return typeof g=="string"&&g?`${f} · ${g}`:`${f} · ${o}`}function sw(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 aw(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 tm(t){return t.appliesTo}function iw(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,k])=>{if(!(j in s))return!1;const b=k.boundType;if(!b||b.kind!=="cumulative_sum"&&b.kind!=="cumulative_count"||b.window!==o)return!1;const S=tm(k);return!S||!u||S.includes(u)}),p=(u?f.find(([,j])=>{var k;return(k=tm(j))==null?void 0:k.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 Mh(t,s,a,o){var g;const l=(g=t.cumulativeState)==null?void 0:g[o];if(!l)return null;const u=iw(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 ow(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=Mh(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 lw(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=no(g.unit),k=g.displayName??Jt(v),b=S=>j?`${S.toLocaleString()} ${j}`:S.toLocaleString();l.push({key:f,label:k,ok:y<=x,valueText:b(y),limitText:b(x)})}return l}function Mi(t){return typeof t.proposalId=="string"&&t.proposalId.length>0}function cw(t){const s=Mt(t),a=t.split("@")[1];return a?`${s}@${a}`:s}const uw=["automatic","approved","all"];function dw(t){return t==="automatic"||t==="approved"?t:"all"}function mc(t,s){return s==="all"?!0:s==="approved"?Mi(t):!Mi(t)}function Ar(t,s){return Bn(t,s)}function ha(t,s){return ps(Fh(t).integrationId,s)}function fw(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 Oh(t,s){const a=fw(t*1e3,s);return a==="just now"?"waiting just now":`waiting ${a}`}const mw=24*3600;function Bh(t,s,a){const o=t-Math.floor(s/1e3);return o<=0||o>mw?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 Dh(t){return t.replace(/-/g,"").slice(0,8)}function hw(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 Uc(t,s){return hw(t*1e3,s)}function Oi(t,s){return t.timestamp*1e3>s}function pw(t,s){var l;const a=new Map;for(const u of t){if(Mi(u))continue;const f=ro(u,s.manifests),p=`${u.authorizationId??u.profileId}|${u.action}`;let v=a.get(p);v||(v={key:p,area:Ar(u.profileId,s.catalog),system:ha(u.action,s.manifests),profileId:u.profileId,mandateTitle:u.authorizationId?(l=s.titles)==null?void 0:l[u.authorizationId]:void 0,label:f,count:0,newCount:0,latestSec:0,tickets:[]},a.set(p,v)),v.count+=1,Oi(u,s.lastSeenMs)&&(v.newCount+=1),v.latestSec=Math.max(v.latestSec,u.timestamp),v.tickets.push(u)}const o=[...a.values()];for(const u of o)u.tickets.sort((f,g)=>g.timestamp-f.timestamp);return o.sort((u,f)=>+(f.newCount>0)-+(u.newCount>0)||f.latestSec-u.latestSec)}function gw(t,s){var l,u,f,g,p;const a=new Map;for(const v of t){if(!v.authorizationId||!Uc(v.timestamp,s.nowMs))continue;const y=a.get(v.authorizationId);(!y||v.timestamp>y.timestamp||v.timestamp===y.timestamp&&(((u=(l=v.cumulativeState)==null?void 0:l.daily)==null?void 0:u.count)??0)>(((g=(f=y.cumulativeState)==null?void 0:f.daily)==null?void 0:g.count)??0))&&a.set(v.authorizationId,v)}const o=[];for(const[v,y]of a){const x=Mh(y,s.boundsOf(v)??y.limits,s.profileOf(y.profileId),"daily"),j={authorizationId:v,area:Ar(y.profileId,s.catalog),system:ha(y.action,s.manifests),profileId:y.profileId,mandateTitle:(p=s.titles)==null?void 0:p[v]};x&&"limit"in x?o.push({...j,used:x.used,limit:x.limit,ratio:x.limit>0?x.used/x.limit:0}):o.push({...j,used:x?x.count:1,ratio:0})}return o.sort((v,y)=>y.ratio-v.ratio||v.area.localeCompare(y.area))}function nm(t){return t.ratio>=.8}function Bi(t,s,a){const o=new Date(t*1e3),l=o.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"});return Uc(t,s)?`today ${l}`:`${o.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`}const yw={customers:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),n.jsx("path",{d:"M3 19c0-3.3 2.7-5.5 6-5.5s6 2.2 6 5.5"}),n.jsx("circle",{cx:"17",cy:"9",r:"2.4"}),n.jsx("path",{d:"M15.5 13.8c3 .1 5.5 2 5.5 5"})]}),email:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"1.5"}),n.jsx("path",{d:"m3.5 6 8.5 7 8.5-7"})]}),payments:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"1.5"}),n.jsx("path",{d:"M3 10h18M7 15h4"})]}),sales:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h9l4 4v14H6z"}),n.jsx("path",{d:"M15 3v4h4M9 12h7M9 16h5"})]}),calendar:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"5",width:"17",height:"15",rx:"1.5"}),n.jsx("path",{d:"M3.5 10h17M8 3v4M16 3v4"})]}),records:n.jsx("path",{d:"M3 7h7l2 2h9v10H3z"}),publishing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 10v4l11 4V6z"}),n.jsx("path",{d:"M15 9.5c2 .3 3 1.3 3 2.5s-1 2.2-3 2.5M7 14.5 8.5 19h2.5l-1.3-4"})]}),deployments:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12 3v12M7 8l5-5 5 5"}),n.jsx("path",{d:"M4 15v5h16v-5"})]}),purchasing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3 4h2.5l2.2 11h10.6L20.5 7H6.4"}),n.jsx("circle",{cx:"9",cy:"19",r:"1.4"}),n.jsx("circle",{cx:"17",cy:"19",r:"1.4"})]}),reports:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 20V4M4 20h16"}),n.jsx("path",{d:"M8 16v-4M12 16V8M16 16v-6"})]}),setup:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 7h10M18 7h2M4 17h4M12 17h8"}),n.jsx("circle",{cx:"16",cy:"7",r:"2"}),n.jsx("circle",{cx:"10",cy:"17",r:"2"})]}),unknown:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"9.2"}),n.jsx("path",{d:"M9.6 9.6a2.5 2.5 0 1 1 3.6 2.3c-.9.5-1.4 1.1-1.4 2.2"}),n.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"17.05"})]})};function pa({icon:t,className:s}){return n.jsx("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:yw[t]})}function os({profileId:t,area:s,system:a,time:o,trailing:l,leading:u}){return n.jsxs("div",{className:"obj-line",children:[u,n.jsx(pa,{icon:Ir(t)}),n.jsx("b",{children:s}),a&&n.jsxs("span",{children:["· via ",a]}),o&&n.jsxs("span",{children:["· ",o]}),l&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"obj-line-sp"}),l]})]})}function ca({title:t,area:s}){return Q0(t,s)?n.jsxs("div",{className:"obj-mandate-line","data-testid":"mandate-line",children:["Mandate: ",t]}):null}async function rm(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 vw(t){return t.normalize("NFC").replace(/\r\n?/g,`
67
+ `).split(`
68
+ `).map(l=>l.replace(/[ \t]+$/,"")).join(`
69
+ `).replace(/\n+$/,"")}function hc(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":hc(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)+":"+hc(l))}return"{"+a.join(",")+"}"}async function Uh(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 rm(hc(s))}`}if(typeof s!="string")throw new Error('content_binding kind="text" expects a string, got an object');return`sha256:${await rm(vw(s))}`}async function Wh(t){if(t.toolArgs)return t.toolArgs;if(!t.content)return null;try{const{plaintext:s}=await z.decryptProposalContent(t.content),a=JSON.parse(s);return typeof a!="object"||a===null||Array.isArray(a)?null:a}catch{return null}}function xw(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 Hh(t){return!t.loading&&t.readable}function Vh(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 ia(t){const s=await Wh(t);if(s)return Uh("jcs",s)}function ww(t){var o;const[s,a]=m.useState((t==null?void 0:t.note)??null);return m.useEffect(()=>{let l=!0;if(t!=null&&t.note){a(t.note);return}if(!(t!=null&&t.noteEncrypted)){a(null);return}return a(null),z.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 jw={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function so(t){var o;const[s,a]=m.useState(jw);return m.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 Wh(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 sm=140,am=60,Sw=/\{([^{}]+)\}/g;function Gh(t,s){var u,f;const{integrationId:a,toolName:o}=lr(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 Kh(t,s){let a=t;for(const o of s.split(".")){if(a===null||typeof a!="object")return;a=a[o]}return a}function im(t){return t==null?!1:typeof t=="string"?t.trim().length>0:Array.isArray(t)?t.length>0:!0}function bw(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>am?`${l.slice(0,am-1).trimEnd()}…`:l}function om(t,s,a,o){let l=!1;const u=t.replace(Sw,(f,g)=>{const[p,v]=g.split("|").map(x=>x.trim()),y=p.split(",").map(x=>Kh(s,x.trim())).find(im);return im(y)?bw(y,v,a,o):(l=!0,"")});return l?null:u}function qh(t,s,a={}){const o=Kh(s,a.currencyField??"currency"),l=typeof o=="string"?o:void 0,u=t.replace(/\[([^[\]]*)\]/g,(p,v)=>om(v,s,l,a.locale)??""),f=om(u,s,l,a.locale);if(f===null)return null;const g=f.replace(/\s+/g," ").trim();return g.length>sm?`${g.slice(0,sm-1).trimEnd()}…`:g}function Yh(t,s,a,o){var f;const l=Jt(lr(t).toolName),u=Gh(t,a);return!(u!=null&&u.summary)||!s?l:qh(u.summary,s,{currencyField:(f=u.display)==null?void 0:f.currencyField,locale:o})??l}function kw(t,s,a,o){var u;const l=Gh(t,a);return!(l!=null&&l.summary)||!s?null:qh(l.summary,s,{currencyField:(u=l.display)==null?void 0:u.currencyField,locale:o})}function Jh({proposal:t,manifests:s}){const a=so(t);return n.jsx(n.Fragment,{children:Yh(t.tool,a.toolArgs,s)})}function ec({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"})}const as=5;function Nw({auths:t,activeCount:s,waiting:a,waitingReady:o}){const[l,u]=m.useState(null),[f,g]=m.useState(null),[p,v]=m.useState([]),[y,x]=m.useState({}),[j,k]=m.useState({}),b=m.useCallback(()=>{z.getMyReceiptsPage({limit:200}).then(L=>u(L.receipts)).catch(()=>u(L=>L??[])),z.getLastSeenTicketsAt().then(g).catch(()=>g(Number.POSITIVE_INFINITY))},[]);Ft(b,3e5),Fe("ticket-recorded",b),m.useEffect(()=>{z.getLabelManifests().then(v).catch(()=>{}),z.getLocalAuthorizations().then(({authorizations:L})=>x(L)).catch(()=>{})},[]);const S=$r(),N=m.useMemo(()=>{const L={};for(const W of t)W.authorization_id&&W.title&&(L[W.authorization_id]=W.title);return L},[t]),E=Date.now(),T=m.useMemo(()=>{const L=Date.now();return(l??[]).filter(W=>Uc(W.timestamp,L))},[l]);m.useEffect(()=>{const L=[...new Set(T.map(W=>W.profileId))].filter(W=>!(W in j));L.length!==0&&Promise.all(L.map(W=>Ph(W).then(te=>[W,te]).catch(()=>[W,null]))).then(W=>k(te=>({...te,...Object.fromEntries(W)})))},[T,j]);const P=m.useMemo(()=>pw(T,{catalog:S,manifests:p,titles:N,lastSeenMs:f??Number.POSITIVE_INFINITY}),[T,S,p,N,f]),A=T.filter(L=>mc(L,"approved")).length,D=m.useMemo(()=>gw(T,{nowMs:Date.now(),catalog:S,manifests:p,titles:N,boundsOf:L=>{var W;return(W=y[L])==null?void 0:W.bounds},profileOf:L=>j[L]}),[T,S,p,N,y,j]),O=P.filter(L=>L.newCount>0).length,K=[...a].sort((L,W)=>L.createdAt-W.createdAt);return n.jsxs("div",{className:"core-cols","data-testid":"core-cols",children:[n.jsxs("section",{"aria-label":"Waiting for you","data-testid":"col-waiting",children:[n.jsxs("div",{className:"core-col-h is-main",children:[n.jsx("h2",{children:"Waiting for you"}),a.length>0&&n.jsx("span",{className:"pill-count",children:a.length})]}),o?K.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing waits for your decision."}):K.slice(0,as).map(L=>{const W=Bh(L.expiresAt,E);return n.jsxs(ht,{to:`/approvals?open=${encodeURIComponent(L.id)}`,className:"appr-item appr-item-link","data-testid":"dash-approval",children:[n.jsxs("div",{className:"appr-item-main",children:[n.jsx(os,{profileId:L.profileId,area:Ar(L.profileId,S),system:ha(L.tool,p),time:Oh(L.createdAt,E)}),n.jsx("div",{className:"appr-item-sum",children:n.jsx(Jh,{proposal:L,manifests:p})}),n.jsx(ca,{title:L.authorizationId?N[L.authorizationId]:void 0,area:Ar(L.profileId,S)}),W&&n.jsx("div",{className:"obj-due",children:W})]}),n.jsx("span",{className:"appr-item-chev","aria-hidden":"true",children:"›"})]},L.id)}):n.jsx(ec,{variant:"line"}),K.length>0&&n.jsx(ht,{to:"/approvals",className:"col-btn",children:"All approvals ›"})]}),n.jsxs("section",{"aria-label":"Done automatically","data-testid":"col-automatic",children:[n.jsxs("div",{className:"core-col-h",children:[n.jsx("h2",{children:"Done automatically"}),O>0&&n.jsxs("span",{className:"meta",children:[P.reduce((L,W)=>L+W.newCount,0)," new"]})]}),l===null?n.jsx(ec,{variant:"line"}):P.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing was done automatically today."}):P.slice(0,as).map(L=>n.jsxs("details",{className:`auto-grp${L.newCount>0?"":" is-seen"}`,"data-testid":"auto-group",children:[n.jsxs("summary",{children:[n.jsx("span",{className:`seen-dot${L.newCount>0?" is-new":""}`,"aria-label":L.newCount>0?"new since your last visit":"seen"}),n.jsxs("span",{className:"auto-grp-txt",children:[n.jsx(os,{profileId:L.profileId,area:L.area,system:L.system}),n.jsxs("b",{children:[L.count," × ",L.label]}),n.jsx(ca,{title:L.mandateTitle,area:L.area}),n.jsxs("span",{className:"meta",children:[L.newCount>0?`${L.newCount} new`:"seen"," · latest ",Bi(L.latestSec,E)]})]})]}),n.jsxs("div",{className:"auto-grp-list",children:[L.tickets.slice(0,as).map(W=>n.jsxs("div",{className:"auto-grp-row",children:[n.jsx("span",{className:`seen-dot${Oi(W,f??Number.POSITIVE_INFINITY)?" is-new":""}`}),ro(W,p),n.jsxs("span",{className:"t",children:[Bi(W.timestamp,E)," · ",Dh(W.id)]})]},W.id)),L.tickets.length>as&&n.jsxs("div",{className:"auto-grp-row meta",children:["+ ",L.tickets.length-as," more in Tickets"]})]})]},L.key)),P.length>0&&n.jsx(ht,{to:"/tickets?filter=automatic",className:"col-btn","data-testid":"btn-automatic-tickets",children:"Automatic tickets ›"}),A>0&&n.jsxs("div",{className:"core-quiet-line",children:[A," approved today — ",n.jsx(ht,{to:"/tickets?filter=approved",children:"see approved tickets"})]})]}),n.jsxs("section",{"aria-label":"Mandates at work today","data-testid":"col-mandates",children:[n.jsx("div",{className:"core-col-h",children:n.jsx("h2",{children:"Mandates at work today"})}),l===null?n.jsx(ec,{variant:"line"}):D.length===0?n.jsx("p",{className:"core-col-empty",children:"No mandate has acted today."}):D.slice(0,as).map(L=>n.jsxs("div",{className:"mandate-obj","data-testid":"mandate-at-work",children:[n.jsx(os,{profileId:L.profileId,area:L.area,system:L.system}),L.mandateTitle&&L.mandateTitle.trim().toLowerCase()!==L.area.trim().toLowerCase()&&n.jsx("div",{className:"mandate-obj-title",children:L.mandateTitle}),n.jsx("div",{className:`usage${nm(L)?" is-near":""}`,children:L.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(L.ratio*100))}%`}})}),n.jsxs("span",{children:[nm(L)?n.jsxs("b",{children:[L.used," of ",L.limit]}):`${L.used} of ${L.limit}`," today"]})]}):n.jsxs("span",{children:[L.used," ",L.used===1?"action":"actions"," today"]})})]},L.authorizationId)),l!==null&&s>D.length&&n.jsxs("div",{className:"meta",style:{marginTop:"var(--space-2)",fontSize:"var(--text-caption)"},children:[s-D.length," more mandate",s-D.length===1?"":"s"," in force — no actions today"]}),D.length>0&&n.jsx(ht,{to:"/mandates",className:"col-btn",children:"All mandates ›"})]})]})}function Cw(){const[t,s]=m.useState(null),[a,o]=m.useState(Number.POSITIVE_INFINITY),l=m.useCallback(()=>{Promise.all([z.getReport().then(g=>g.report).catch(()=>null),z.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]).then(([g,p])=>{s(g),o(p)})},[]);if(Ft(l,3e5),Fe("report-written",l),!t||!wh(t,a))return null;const{verified:u,unchecked:f}=a0(t);return n.jsxs("div",{className:"report-line","data-testid":"report-line",children:[n.jsx("span",{className:"nav-new",style:{marginLeft:0},children:"New"}),n.jsxs("span",{className:"report-line-text",children:[n.jsx("b",{children:s0(t.renderedHtml)})," — ",n.jsx("span",{title:Fi(t.coverage).title,children:Fi(t.coverage).text})," · written ",jh(t.savedAt,Date.now()),f===0?n.jsxs(n.Fragment,{children:[" · all ",u," value",u===1?"":"s"," verified"]}):n.jsxs(n.Fragment,{children:[" · ",u," value",u===1?"":"s"," verified · ",n.jsxs("b",{children:["✕ ",f," could not be checked"]})]})]}),n.jsx(ht,{to:"/reports",className:"col-btn",children:"Open report ›"})]})}function Ew(){const[t,s]=m.useState([]);return Ft(async()=>{try{const{skipped:o}=await z.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 Tw(t,s){return s&&!la(t.manifest)}function Iw(t,s=!1){var o;const a=[];for(const l of t)Tw(l,s)||(l.state==="error"?a.push({label:"Integration error",detail:(o=l.integration)!=null&&o.error?`${l.manifest.name}: ${l.integration.error}`:`${l.manifest.name} is not running`,to:"/integrations",color:"var(--text-primary)"}):l.state==="not-running"&&(la(l.manifest)?a.push({label:`${l.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--text-primary)"}):a.push({label:"Integration stopped",detail:`${l.manifest.name} is not running`,to:"/integrations",color:"var(--text-primary)"})));return a}function Aw(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 Rw=1800;function Zs(t){return t.replace(/@.*$/,"").split("/").pop()??t}function Pw(){const{domain:t}=xt(),[s,a]=m.useState([]),[o,l]=m.useState([]),[u,f]=m.useState([]),[g,p]=m.useState(!0),[v,y]=m.useState(!1),[x,j]=m.useState([]),[k,b]=m.useState(!1),[S,N]=m.useState(!1),[E,T]=m.useState(null),[P,A]=m.useState(!1),{entries:D,activeSessions:O,loading:K}=Fc(),L=G0(),W=!K,{simulation:te}=Rh(),Z=te===!0,F=Y0(),ne=m.useCallback(()=>{z.getMyAttestations().then(oe=>{a(oe),y(!0)}).catch(()=>y(!0)),z.getArchivedMandates().then(j).catch(()=>j([])),z.getMyProposals(t).then(oe=>{l(oe),b(!0)}).catch(()=>b(!0)),z.getProposalsForApprover().then(oe=>f(oe)).catch(()=>f([])),z.getCredential("ai-config").then(oe=>{p(oe.configured),N(!0)}).catch(()=>N(!0)),z.getAgentContact().then(oe=>{T(oe.contact),A(!0)}).catch(()=>A(!0))},[t]);Fe("attestation-changed",ne),Fe("proposal-added",ne),Fe("proposal-resolved",ne),Fe("proposal-approved",ne),Fe("proposal-rejected",ne),Fe("execution-failed",ne),Ft(ne,3e5,t);const he=v&&k&&S&&W&&P&&te!==null,Q=gh(s,{archivedSet:new Set(x)}),ve=Q.active,we=Q.expired,ee=ve.some(oe=>Zs(oe.profile_id)==="delegation"),X=ve.filter(oe=>Zs(oe.profile_id)!=="delegation").length,q=o.filter(oe=>Zs(oe.profileId)==="delegation").length,I=Ah({hasContact:E!==null,hasDelegationMandate:ee,otherMandateCount:X,delegationProposalCount:q,managed:F,simulationOn:Z}),$=Z&&I.visible,ie=ve.filter(oe=>oe.remaining_seconds!==null&&oe.remaining_seconds<=Rw),fe=o.filter(kh),B=D.filter(oe=>oe.state==="running"),re=D.filter(oe=>oe.state==="starting"),ce=Aw(D),pe=[...fe,...u.filter(oe=>!fe.some(Ge=>Ge.id===oe.id))],ye=[];for(const oe of ie){const Ge=Math.ceil((oe.remaining_seconds??0)/60);ye.push({label:"Expiring soon",detail:`${oe.title??Zs(oe.profile_id)} — ${Ge} min remaining`,to:"/mandates",color:"var(--text-primary)"})}for(const oe of we)ye.push({label:"Expired",detail:oe.title??Zs(oe.profile_id),to:"/mandates",color:"var(--text-primary)"});ye.push(...Iw(D,Z));for(const oe of re)ye.push({label:"Integration starting",detail:`${oe.manifest.name} is coming up…`,to:"/integrations",color:"var(--text-primary)"});for(const oe of D)oe.authStatus==="failed"&&oe.state!=="not-running"&&oe.state!=="error"&&oe.state!=="paused"&&ye.push({label:"Reconnect needed",detail:`${oe.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--text-primary)"});return g||ye.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"})}),he&&L&&($?n.jsx(V0,{contact:E,hasDelegationMandate:ee,otherMandateCount:X,delegationProposalCount:q,managed:F,simulationOn:Z,mcpEndpoint:L}):!Z&&n.jsx(W0,{aiConfigured:g,hasRunningIntegration:B.length>0,hasActiveAuth:ve.length>0,hasAgentConnected:O>0,mcpEndpoint:L})),!$&&n.jsxs(n.Fragment,{children:[n.jsx(Nw,{auths:s,activeCount:ve.length,waiting:pe,waitingReady:k}),n.jsx(Cw,{}),ye.length>0&&n.jsxs("section",{className:"card attention attention-quiet","aria-label":"Setup — needs attention",children:[n.jsxs("div",{className:"card-header",children:[n.jsx("h2",{className:"card-title",children:"Setup — needs attention"}),n.jsx("span",{className:"rb-count",children:ye.length})]}),n.jsx("div",{className:"attention-rows",children:ye.map((oe,Ge)=>n.jsxs(ht,{to:oe.to,className:"attention-row",children:[n.jsx("span",{className:"attention-dot",style:{background:oe.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:oe.label}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:oe.detail})]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},Ge))})]})]}),ce&&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:[ce.count," real system",ce.count===1?"":"s"," ",ce.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",ce.namesText,"."]})]}),n.jsx(Ew,{}),n.jsx(Gx,{})]})}const $w=["Scope & Limits","Intent","Sign"];function Qh({currentStep:t,onStepClick:s}){const a=Sn();return n.jsxs("div",{className:"wizard-progress",children:[n.jsx("ol",{className:"wizard-steps",children:$w.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 _w({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:"})," ",Mt(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 Lw({integrationId:t,field:s,value:a,onChange:o,disabled:l,onLabels:u}){const[f,g]=m.useState(null),[p,v]=m.useState(null),[y,x]=m.useState(!0);m.useEffect(()=>{let b=!1;return z.discoverScopeField(t,s).then(S=>{var N;b||(g(S.options),x(!1),(N=S.options)!=null&&N.length&&(u==null||u(Object.fromEntries(S.options.map(E=>[E.value,E.label])))))}).catch(S=>{b||(v(S instanceof Error?S.message:String(S)),x(!1))}),()=>{b=!0}},[t,s]);const j=new Set(a.split(",").map(b=>b.trim()).filter(Boolean)),k=b=>{const S=new Set(j);S.has(b)?S.delete(b):S.add(b),o(Array.from(S).join(","))};return y?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",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??{},N=typeof S.access=="string"?S.access:void 0,E=N==="reader",T=S.primary===!0;return n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:E?"var(--text-tertiary)":"var(--text-primary)",cursor:l||E?"not-allowed":"pointer"},title:E?"Read-only — you can authorize list/read but not writes":void 0,children:[n.jsx("input",{type:"checkbox",checked:j.has(String(b.value)),onChange:()=>k(String(b.value)),disabled:l||E}),n.jsx("span",{children:b.label||b.value}),T&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),N&&n.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",N]})]},b.value)})})}function Wc(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 lm(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):Wc(t)===1?"1":""}function pc(t){const s=t.maximum;return typeof s=="number"&&Number.isFinite(s)?s:void 0}function cm(t,s){const a=Wc(t),o=pc(t),l=s===""?a:Math.max(a,Number(s));return o!==void 0?Math.min(o,l):l}function zw(t,s){var o;const a=(o=t.capKinds)==null?void 0:o[s];return a||(t.approvers.length>0?"approval":"hard")}function Hc(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":zw(t,a)}function Xh(t,s,a){const o=t.indexOf(s),l=t.indexOf(a);return o===-1||l===-1?!1:l<o}function Di(t,s){var a;return((a=t.caps)==null?void 0:a[s])!==void 0}function Fw(t,s,a){const o=Object.entries(s.caps??{}).filter(([u])=>Hc(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 Mw(t){return t.replace(/@.*$/,"").split("/").pop()??t}function Vc(t,s){return s.displayName?s.displayName:t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function Ow(t){return t.type==="string"&&(t.format==="email"||t.format==="domain")}function Bw(t){var a;const s=t;return!!(s.enum&&((a=s.constraint)!=null&&a.enforceable.includes("subset")))}function um(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 Dw(t){return t?t==="minutes"?15:t==="percent"?5:t.startsWith("currency:")?10:1:1}function Uw(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 Ww(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 Hw({id:t,value:s,onChange:a,disabled:o,placeholder:l,unit:u,min:f=0,max:g}){const p=Dw(u),v=Uw(u).filter(S=>g===void 0||S.value<=g),y=no(u),x=Ww(s,u),j=s===""?null:Number(s),k=()=>{const S=s===""?0:Number(s),N=S%p,E=N===0?S+p:S+(p-N);a(String(g!==void 0?Math.min(g,E):E))},b=()=>{const S=s===""?0:Number(s);if(S<=f)return;const N=S%p,E=N===0?S-p:S-N;a(String(Math.max(f,E)))};return n.jsxs("div",{className:"bounded-input",children:[n.jsxs("div",{className:"bounded-input-field",children:[n.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:b,disabled:o||s===""||Number(s)<=f,"aria-label":"Decrease",children:"−"}),n.jsx("input",{id:t,className:"stepper-input",type:"number",min:f,max:g,step:p,value:s,placeholder:l??String(f),onChange:S=>{const N=S.target.value;a(g!==void 0&&N!==""&&Number(N)>g?String(g):N)},onFocus:S=>S.target.select(),disabled:o}),n.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:k,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 dm({htmlFor:t,label:s,description:a}){const[o,l]=m.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 Vw({id:t,value:s,onChange:a,disabled:o,format:l,placeholder:u}){const[f,g]=m.useState(""),[p,v]=m.useState(!1),y=m.useRef(null),x=s?s.split(",").map(E=>E.trim()).filter(Boolean):[],j=E=>{const T=E.trim();if(!T)return;if(!um(T,l)){v(!0);return}v(!1);const P=x.includes(T)?x:[...x,T];a(P.join(",")),g("")},k=E=>{const T=x.filter((P,A)=>A!==E);a(T.join(","))},b=E=>{E.key==="Enter"||E.key===","||E.key==="Tab"?f.trim()&&(E.preventDefault(),j(f)):E.key==="Backspace"&&!f&&x.length>0&&k(x.length-1)},S=E=>{const T=E.clipboardData.getData("text");if(T.includes(",")){E.preventDefault();const A=T.split(",").map(O=>O.trim()).filter(Boolean).filter(O=>um(O,l)),D=[...new Set([...x,...A])];a(D.join(",")),g(""),v(!1)}},N=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(),k(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??N:""})]})}function Gw({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 fm({fieldKey:t,fieldDef:s,value:a,onChange:o,prefix:l,readOnly:u,twoColumn:f,discoveryIntegrationId:g,onLabels:p,capMax:v,enumAllowedFrom:y}){const x=Vc(t,s),j=`${l}-field-${t}`,k=n.jsx(n.Fragment,{children:Bw(s)?n.jsx(Gw,{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(Hw,{id:j,value:a,onChange:b=>o(t,b),disabled:u,unit:s.unit,min:Wc(s),max:v!==void 0?Math.min(v,pc(s)??v):pc(s)}):Ow(s)?n.jsx(Vw,{id:j,value:a,onChange:b=>o(t,b),disabled:u,format:s.format}):g?n.jsx(Lw,{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(dm,{htmlFor:j,label:x,description:s.description})}),n.jsx("div",{className:"bounds-field-input",children:k})]},`${l}-${t}`):n.jsxs("div",{className:"form-group",children:[n.jsx(dm,{htmlFor:j,label:x,description:s.description}),k]},`${l}-${t}`)}function Kw(t,s,a,o){if(!o||!Di(o,t))return null;const l=o.caps[t],u=Hc(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"?Xh(g.values??[],l,a):!1}return{kind:u,cap:l,violating:f}}function mm(t,s,a,o){if(!o||!Di(o,t))return a;const l=Hc(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!==""&&Xh(g,u,a)?u:a}return a}function qw(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 Yw(t,s){return no(s.unit)||Vc(t,s).toLowerCase()}function Zh(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 Jw(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 — ",Vc(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=Yw(t,s),p=Zh(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 Qw({profile:t,onConfirm:s,onCancel:a,readOnly:o,initialBounds:l,initialContext:u,initialFrame:f,profileConfig:g,approverNames:p,adminName:v}){var fe;const y=t.boundsSchema,x=t.scopeSchema,j=B=>!!g&&Di(g,B),k=y?Object.entries(y.fields).filter(([B,re])=>!(B==="profile"||B==="path"||re.enforced===!1||re.enforcedBy==="gatekeeper"&&!j(B))):[],b=y?Object.entries(y.fields).filter(([B,re])=>re.enforcedBy==="gatekeeper"&&!j(B)).filter(([,B])=>B.enforced!==!1).map(([B,re])=>re.displayName??B):[],S=x&&x.keyOrder.length>0?Object.entries(x.fields):[],N=l??f??{},E=u??{},T={};for(const[B,re]of k)T[B]=mm(B,re,lm(re,N[B]),g);const P={};for(const[B]of S)P[B]=E[B]!==void 0?String(E[B]):"";const[A,D]=m.useState(T),[O,K]=m.useState(P),[L,W]=m.useState({}),te=m.useRef(new Set);m.useEffect(()=>{D(B=>{let re=!1;const ce={...B};for(const[pe,ye]of k){if(te.current.has(pe))continue;const oe=B[pe]!==void 0?B[pe]:lm(ye,N[pe]),Ge=mm(pe,ye,oe,g);ce[pe]!==Ge&&(ce[pe]=Ge,re=!0)}return re?ce:B})},[g]);const[Z,F]=m.useState(null);m.useEffect(()=>{const B=Mw(t.id);z.getIntegrationManifests().then(({manifests:re})=>{const ce=re.find(pe=>pe.profile===B&&pe.contextDiscovery&&Object.keys(pe.contextDiscovery).length>0);F(ce??null)}).catch(()=>F(null))},[t.id]);const ne={};for(const[B,re]of k)ne[B]=Kw(B,re,A[B]??"",g);const he=Object.entries(ne).filter(([,B])=>(B==null?void 0:B.kind)==="hard"&&B.violating).map(([B])=>B),Q=!!g&&(((fe=g.approvers)==null?void 0:fe.length)??0)>0&&k.every(([B])=>!Di(g,B)),ve=(B,re)=>{te.current.add(B),D(ce=>({...ce,[B]:re}))},we=(B,re)=>{K(ce=>({...ce,[B]:re}))},ee=()=>{const B={profile:t.id};for(const[ce,pe]of k)pe.type==="number"?B[ce]=cm(pe,A[ce]):B[ce]=A[ce];const re={};for(const[ce,pe]of S)pe.type==="number"?re[ce]=O[ce]===""?0:Number(O[ce]):re[ce]=O[ce];return[B,re]},X=()=>{const[B,re]=ee();s(B,re,L)},q=()=>{var pe;const B={...A};for(const ye of he){const oe=(pe=ne[ye])==null?void 0:pe.cap;oe!==void 0&&(B[ye]=String(oe))}D(B);const re={profile:t.id};for(const[ye,oe]of k)oe.type==="number"?re[ye]=cm(oe,B[ye]??""):re[ye]=B[ye]??"";const ce={};for(const[ye,oe]of S)oe.type==="number"?ce[ye]=O[ye]===""?0:Number(O[ye]):ce[ye]=O[ye];s(re,ce,L)},I=()=>{if(!Q)return null;const B=Zh(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: ",B]}),n.jsxs("div",{children:["No caps are set on this profile, so ",B," 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(he.length===0)return null;const B=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 ",B," to add an approver path above the cap."]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:q,children:"Save below cap"}),a&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:a,children:"Cancel"})]})]})},ie=he.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(([B,re])=>{var pe;const ce=!!((pe=Z==null?void 0:Z.contextDiscovery)!=null&&pe[B]);return n.jsx(fm,{fieldKey:B,fieldDef:re,value:O[B],onChange:we,prefix:"context",readOnly:o,discoveryIntegrationId:ce?Z.id:void 0,onLabels:(ye,oe)=>W(Ge=>({...Ge,[ye]:oe}))},`context-${B}`)})]}),k.length>0&&n.jsxs("div",{className:"bounds-section",children:[n.jsxs("div",{className:"bounds-section-header",children:[n.jsx("span",{className:"bounds-section-icon",children:"🔒"}),n.jsxs("div",{children:[n.jsx("div",{className:"bounds-section-title",children:"Limits"}),n.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Authority Server"})]})]}),n.jsx("div",{className:"bounds-fields-grid",children:k.map(([B,re])=>{const ce=ne[B];return n.jsxs("div",{style:{display:"contents"},children:[n.jsx(fm,{fieldKey:B,fieldDef:re,value:A[B],onChange:ve,prefix:"bounds",readOnly:o,twoColumn:!0,capMax:(ce==null?void 0:ce.kind)==="hard"&&typeof ce.cap=="number"?ce.cap:void 0,enumAllowedFrom:(ce==null?void 0:ce.kind)==="hard"?qw(re,ce.cap):void 0}),ce&&n.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:Jw(B,re,ce,g,p)})]},`bounds-${B}`)})}),I(),$(),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(ht,{to:"/integrations",children:"Integrations"}),"."]})]}),n.jsx("button",{className:"btn btn-primary",onClick:X,disabled:ie,style:{marginTop:"0.5rem"},children:o?"Next: Gates":"Next: Problem Statement"})]})}function Xw(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 Zw(t){return t.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const ej="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 Ui({target:t,currentText:s,onApply:a,greeting:o,placeholder:l,title:u}){const[f,g]=m.useState([{role:"assistant",content:o??ej}]),[p,v]=m.useState(""),[y,x]=m.useState(!1),[j,k]=m.useState(null),b=m.useRef(null),S=m.useRef(null);m.useEffect(()=>{const T=b.current;if(!T)return;const P=f[f.length-1],A=S.current;!y&&(P==null?void 0:P.role)==="assistant"&&f.length>1&&A?T.scrollTop=A.offsetTop:T.scrollTop=T.scrollHeight},[f,y]);const N=async()=>{const T=p.trim();if(!T||y)return;const P=[...f,{role:"user",content:T}];g(P),v(""),k(null),x(!0);try{const A=await z.aiChat({target:t,currentText:s,messages:P.filter((D,O)=>!(O===0&&D.role==="assistant"))});A.success&&A.reply?g(D=>[...D,{role:"assistant",content:A.reply}]):k(A.error??"AI returned no reply")}catch(A){k(A instanceof Error?A.message:"Chat failed")}finally{x(!1)}},E=T=>{T.key==="Enter"&&!T.shiftKey&&!T.nativeEvent.isComposing&&(T.preventDefault(),N())};return n.jsxs("div",{className:"intent-chat",children:[n.jsx("h3",{className:"card-title",children:u??"AI Assistant"}),n.jsxs("div",{ref:b,className:"chat-messages",children:[f.map((T,P)=>{const A=T.role==="assistant"?Xw(T.content):null,D=A?Zw(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:[D&&n.jsx("div",{className:"chat-msg-prose",children:D}),A!==null&&n.jsxs(n.Fragment,{children:[n.jsx("pre",{className:"chat-fenced-block",children:A}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>a(A),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:N,disabled:y||!p.trim(),"aria-label":"Send",children:"↑"})]}),n.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function ep({open:t,onClose:s,children:a,ariaLabel:o}){const l=m.useRef(null),u=m.useRef(null);return m.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]),hx.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 tj(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nj(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(k=>k.trim().toLowerCase()).includes(v))})},f=["\\[\\d+\\]",...o.map(tj)],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 hm=`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 rj(t,s,a,o){return nj(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 sj(){var be;const t=Sn(),[s]=ms(),a=Number(s.get("step"))||2,[o,l]=m.useState(null),[u,f]=m.useState(null),[g,p]=m.useState(a),[v,y]=m.useState(null),[x,j]=m.useState(null),[k,b]=m.useState({}),[S,N]=m.useState(hm),[E,T]=m.useState(!1),[P,A]=m.useState(null),[D,O]=m.useState(!0),[K,L]=m.useState(null),[W,te]=m.useState([]),[Z,F]=m.useState(void 0),[ne,he]=m.useState(!1),[Q,ve]=m.useState(null),[we,ee]=m.useState(null),[X,q]=m.useState(null),[I,$]=m.useState([]),[ie,fe]=m.useState(null);m.useEffect(()=>{var Be;const Y=sessionStorage.getItem("agentAuth");if(!Y){t("/mandates?new=1");return}const $e=JSON.parse(Y);l($e),$e.intentHint&&N($e.intentHint),z.getCredential("ai-config").then(ze=>A(ze.configured)).catch(()=>A(!1));const _e=sessionStorage.getItem("agentGate");if(_e){const ze=JSON.parse(_e);ze.bounds&&y(ze.bounds),ze.context&&j(ze.context),(Be=ze.gateContent)!=null&&Be.intent&&N(ze.gateContent.intent)}z.getProfile($e.profileId).then(ze=>f(ze)).catch(()=>t("/mandates?new=1")).finally(()=>O(!1)),$e.groupId&&Promise.all([z.getTeamProfileConfig($e.groupId,$e.profileId).catch(()=>null),z.getGroupById($e.groupId).catch(()=>null),z.listUsers().catch(()=>[])]).then(([ze,it,tt])=>{if(L(ze),ze){const Qe=new Map;for(const Me of tt){const me=Me.name&&Me.email?`${Me.name} (${Me.email})`:Me.name||Me.email||Me.id;Qe.set(Me.id,me)}const Ye=(it==null?void 0:it.members)??[];for(const Me of Ye){const me=Me.userId??Me.id;me&&(Me.name&&Me.email?Qe.set(me,`${Me.name} (${Me.email})`):Me.name&&Qe.set(me,Me.name))}const jt=(ze.approvers??[]).map(Me=>Qe.get(Me)??Me);te(jt);const pt=Ye.find(Me=>Me.role==="admin");if(pt){const Me=pt.userId??pt.id;Me&&F(Qe.get(Me)??pt.name)}}})},[t]);const B=v?Object.entries(v).filter(([Y])=>Y!=="profile"&&Y!=="path").map(([Y,$e])=>`${Y} = ${$e}`).join(", "):"",re=(Y,$e,_e)=>{y(Y),j($e),_e&&b(_e),p(3)},ce=S.trim()!==hm.trim()&&S.trim()!=="",pe=Y=>{ce&&!confirm("Replace your current intent with the AI draft?")||N(Y)},ye=()=>{const Y=u==null?void 0:u.ttl,$e={intent:S},_e=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({..._e,bounds:v,context:x,contextLabels:k,gateContent:$e,ttlConfig:Y})),t("/mandates/new/sign")},oe=async()=>{if(o){he(!0),ve(null),ee(null),q(null),$([]),fe(null);try{const Y=await z.aiIntentReview({profileId:o.profileId,newIntent:S,context:x??void 0});$(Y.grants??[]),Y.success?Y.review?ve(Y.review):ee(Y.note??"No other mandates on this profile to compare against."):q(Y.error??"Check failed.")}catch(Y){q(Y instanceof Error?Y.message:"Check failed.")}finally{he(!1)}}},Ge=Y=>{N(Y),(Q||we||X)&&(ve(null),ee(null),q(null),$([]),fe(null))};return D||!o||!u?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):n.jsxs(n.Fragment,{children:[n.jsx(Qh,{currentStep:g,onStepClick:Y=>{Y>=2&&p(Y)}}),n.jsx(_w,{profileId:o.profileId,bounds:B||void 0,groupName:o.groupName,domain:o.domain}),g===2&&n.jsx("div",{className:"card",children:n.jsx(Qw,{profile:u,onConfirm:re,onCancel:()=>t("/mandates?new=1"),initialBounds:v||void 0,initialContext:x||void 0,profileConfig:K,approverNames:W,adminName:Z})}),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(Ui,{target:{kind:"intent",profileId:o.profileId,bounds:B||void 0},currentText:S,onApply:pe})}),n.jsxs("div",{className:"card intent-pane document",children:[n.jsx("h3",{className:"card-title",children:"What should your agent know?"}),n.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),n.jsx("textarea",{className:"intent-textarea",value:S,onChange:Y=>Ge(Y.target.value)}),n.jsxs("div",{className:"char-counter",children:[S.length," / 2000"]})]}),P===!1&&n.jsxs("p",{className:"intent-ai-hint",children:[n.jsx(ht,{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:oe,disabled:ne||!ce,children:ne?"Checking…":"Check against my other grants"}),X&&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:X})]}),we&&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:we})]}),Q&&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:rj(Q,I,fe,Mt(o.profileId))}),n.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),n.jsxs("div",{className:"intent-footer",children:[n.jsx("button",{className:"btn btn-ghost",onClick:()=>p(2),children:"Back"}),n.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:ye,disabled:!ce,children:"Continue to Review"})]}),(((be=K==null?void 0:K.approvers)==null?void 0:be.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 ",W.length>0?W.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",W.length>0?W.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(ep,{open:E,onClose:()=>T(!1),ariaLabel:"Intent assistant",children:n.jsx(Ui,{target:{kind:"intent",profileId:o.profileId,bounds:B||void 0},currentText:S,onApply:Y=>{pe(Y),T(!1)}})})]}),ie&&n.jsx("div",{className:"modal-backdrop",onClick:Y=>Y.target===Y.currentTarget&&fe(null),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:ie.length>1?`Existing mandates (${ie.length})`:"Existing mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>fe(null),children:"×"})]}),n.jsx("div",{className:"modal-body",children:ie.map((Y,$e)=>{var _e;return n.jsxs("div",{style:{marginBottom:$e<ie.length-1?"1rem":0,paddingBottom:$e<ie.length-1?"1rem":0,borderBottom:$e<ie.length-1?"1px solid var(--border)":"none"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),n.jsx("div",{style:{marginBottom:"0.75rem"},children:Y.scope}),n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),n.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((_e=Y.intent)==null?void 0:_e.trim())||"(no intent recorded)"}),Object.entries(Y.bounds).filter(([Be])=>Be!=="profile"&&Be!=="path").length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(Y.bounds).filter(([Be])=>Be!=="profile"&&Be!=="path").map(([Be,ze])=>`${Be}: ${ze}`).join(" · ")})]})]},$e)})})]})})]})]})}function aj(t){return t.normalize("NFC").replace(/\r\n?/g,`
74
+ `).split(`
75
+ `).map(l=>l.replace(/[ \t]+$/,"")).join(`
76
+ `).replace(/\n+$/,"")}async function Gc(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 ij extends Error{constructor(a,o,l){super(l);Js(this,"code");Js(this,"field");this.name="CanonicalValueError",this.code=a,this.field=o}}function oj(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 tp(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 ij(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}=${oj(f)}`)}return o.join(`
78
+ `)}async function $i(t,s){const a=s.boundsSchema;if(!a)throw new Error("Profile has no boundsSchema");const o=tp(t,a.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await Gc(o)}`}async function np(t,s){const a=s.scopeSchema?tp(t,s.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await Gc(a)}`}function gc(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":gc(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)+":"+gc(l))}return"{"+a.join(",")+"}"}async function rp(t){return`sha256:${await Gc(gc(t))}`}async function Wi(t){const s=new TextEncoder().encode(aj(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 sp(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 lj(t){const s=t.commitment_modes;return s===void 0?["review","automatic"]:Array.isArray(s)?["review","automatic"].filter(a=>s.includes(a)):[]}function cj(t){return t==="per-action"?"review":"automatic"}function pm(t){return t?lj(t).map(s=>s==="review"?"per-action":"immediate"):["per-action","immediate"]}function uj(t,s){return s.includes(t)?t:s[0]??null}function gm(t){return t==null?new Set:new Set(String(t).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean))}function dj(t,s){for(const a of t)if(s.has(a))return!0;return!1}function fj(t,s,a){for(const o of t){const l=gm(s[o]),u=gm(a[o]);if(!(l.size===0||u.size===0)&&!dj(l,u))return!1}return!0}function mj(t){return t.length>24?`${t.slice(0,10)}…`:t}function ap(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} (${mj(u)})`:u}).join(", ")}function ip(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 Hi=500,hj=["Lower the discount","Other recipient","Shorter","Different wording"];function Kc(t){const s=t.trim();return s.length===0?{valid:!1,error:"Describe what should change."}:s.length>Hi?{valid:!1,error:`At most ${Hi} characters (currently ${s.length}).`}:{valid:!0,trimmed:s}}function pj(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function op(t,s){return t.toLowerCase().includes(s.toLowerCase())}function gj(t,s){const a=t.trim();if(a.length===0)return s;if(!op(a,s))return`${a}. ${s}`;const o=new RegExp(`\\.?\\s*${pj(s)}\\.?`,"i");return a.replace(o,"").replace(/\s{2,}/g," ").replace(/^\.\s*/,"").trim()}function lp(){return{outcome:"rejected"}}function yj(t){const s=Kc(t);if(!s.valid)throw new Error(s.error);return{outcome:"change_needed",note:s.trimmed}}function ym(){return{outcome:"replaced"}}function vj(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 xj={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function wj(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:xj[o],who:a.userId===s?"You":a.userId,at:a.at,note:l}}function jj(t){return t.refusal?{kind:"REFUSED",at:t.refusal.at,message:t.refusal.message}:null}function Sj(){var Oe,G;const t=Sn(),{user:s,mode:a,domain:o}=xt(),[l,u]=m.useState(null),[f,g]=m.useState(null),[p,v]=m.useState(null),[y,x]=m.useState("per-action"),[j,k]=m.useState(1800),[b,S]=m.useState(86400),[N,E]=m.useState(""),[T,P]=m.useState("hours"),[A,D]=m.useState(""),[O,K]=m.useState(!0),[L,W]=m.useState(!1);m.useEffect(()=>{z.getIdentityDisclosure().then(J=>W(J.always)).catch(()=>{})},[]);const[te,Z]=m.useState(!1),[F,ne]=m.useState(""),[he,Q]=m.useState(null),[ve,we]=m.useState([]),[ee,X]=m.useState(!1),[q,I]=m.useState([]),[$,ie]=m.useState(0);m.useEffect(()=>{var Ot;const J=sessionStorage.getItem("agentAuth"),ge=sessionStorage.getItem("agentGate");if(!J||!ge){t("/mandates?new=1");return}const Ue=JSON.parse(J),We=JSON.parse(ge),nt={bounds:We.bounds??{},context:We.context??{},contextLabels:We.contextLabels??void 0,gateContent:We.gateContent};u(Ue),g(nt),We.ttlConfig&&(k(We.ttlConfig.default??1800),S(We.ttlConfig.max??86400)),We.templateMode==="automatic"?x("immediate"):We.templateMode==="review"&&x("per-action");const Wt=((Ot=We.ttlConfig)==null?void 0:Ot.max)??86400;if(typeof We.templateTtl=="number"&&We.templateTtl>0){const Ze=Math.min(We.templateTtl,Wt);k(Ze),[3600,86400,604800,2592e3,31536e3].includes(Ze)||(Ze%86400===0?(E(String(Ze/86400)),P("days")):(E(String(Math.max(1,Math.round(Ze/3600)))),P("hours")))}z.getProfile(Ue.profileId).then(Ze=>{var H;if(v(Ze),!A){const xe=Ze.name??((H=Ue.profileId.split("/").pop())==null?void 0:H.replace(/@.*$/,""))??"",Te=[];if(nt.context&&Ze.scopeSchema)for(const gt of Ze.scopeSchema.keyOrder){const Ke=nt.context[gt];if(Ke!==void 0&&Ke!==""){const Nt=String(Ke).split(",").map(St=>St.trim()).filter(Boolean);Te.push(Nt.join(", "))}}const rt=Te.length>0?`${xe}: ${Te.join(" · ")}`:xe;D(rt)}}).catch(()=>{}),Ue.isPersonal?X(!0):Promise.all([z.getTeamProfileConfig(Ue.groupId,Ue.profileId).catch(()=>null),z.getGroupById(Ue.groupId).catch(()=>null),z.listUsers().catch(()=>[])]).then(([Ze,H,xe])=>{if(Q(Ze),Ze){const Te=new Map;for(const Ke of xe){const Nt=Ke.name&&Ke.email?`${Ke.name} (${Ke.email})`:Ke.name||Ke.email||Ke.id;Te.set(Ke.id,Nt)}const rt=(H==null?void 0:H.members)??[];for(const Ke of rt){const Nt=Ke.userId??Ke.id;Nt&&(Ke.name&&Ke.email?Te.set(Nt,`${Ke.name} (${Ke.email})`):Ke.name&&Te.set(Nt,Ke.name))}const gt=(Ze.approvers??[]).map(Ke=>Te.get(Ke)??Ke);we(gt)}}).finally(()=>{X(!0)})},[t]),m.useEffect(()=>{if(!(l!=null&&l.profileId))return;const J=l.profileId,ge=sessionStorage.getItem("agentEditReplaces");z.getEnrichedAuthorizations().then(Ue=>{const We=Ue.filter(nt=>nt.profileId===J&&nt.authorizationId!==ge).map(nt=>({authorizationId:nt.authorizationId,bounds:nt.bounds,context:nt.context??{},intent:nt.intent}));I(We)}).catch(()=>I([]))},[l==null?void 0:l.profileId]),m.useEffect(()=>{if(!p)return;const J=uj(y,pm(p));J&&J!==y&&x(J)},[p,y]),m.useEffect(()=>{if(!f||!p||q.length===0){ie(0);return}let J=!1;return(async()=>{const ge=await $i(f.bounds,p),Ue=await Promise.all(q.map(We=>$i(We.bounds,p).catch(()=>null)));J||ie(Ue.filter(We=>We===ge).length)})().catch(()=>{J||ie(0)}),()=>{J=!0}},[f,p,q]);const fe=async()=>{if(!(!l||!f||!p||!s)){if(!l.groupId){ne("No active group; cannot create mandate.");return}Z(!0),ne("");try{const J=o||l.domain||"owner",ge=await $i(f.bounds,p),Ue=await np(f.context,p),[We,nt]=await Promise.all([Wi(f.gateContent.intent),Wi(JSON.stringify({profile:l.profileId,domain:J,group:l.groupId}))]);let Wt,Ot,Ze,H;if(l.isTeam){const St=await z.getApproversPubkeys(l.groupId,l.profileId);if(St.length>0){const Xt=await z.encryptIntent(f.gateContent.intent,St);Wt=Xt.intentCiphertext,Ot=Xt.encryptedKeys,Ze=Xt.approversFrozen,H=Xt.intentDisclosureHash}}const xe=`authz_${crypto.randomUUID()}`,Te=sessionStorage.getItem("agentEditReplaces")||void 0,rt=sessionStorage.getItem("agentReplacesProposal")||void 0,gt=await rp(p),Ke=await z.attest({authorization_id:xe,replaces:Te,profile_id:l.profileId,profile_hash:gt,supported_versions:["0.7"],bounds:f.bounds,bounds_hash:ge,scope_hash:Ue,domain:J,did:s.did,mandate_owners:[{did:s.did}],gate_content_hashes:{intent:We},execution_context_hash:nt,group_id:l.groupId,ttl:j,commitment_mode:cj(y),title:A.trim(),intent_ciphertext:Wt,encrypted_keys:Ot,approvers_frozen:Ze,intent_disclosure_hash:H,disclose_identity:O});try{await z.pushGateContent(sp(Ke,{boundsHash:ge,contextHash:Ue,context:f.context,contextLabels:f.contextLabels,gateContent:f.gateContent}))}catch(St){try{await z.revokeAttestation(xe,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${St instanceof Error?St.message:"Unknown error"})`)}if(Te)try{await z.revokeAttestation(Te,`Replaced by ${xe} (edit)`),z.resyncGates().catch(()=>{})}catch{}let Nt="";if(rt)try{const St=await z.getProposal(rt);if(St.status==="pending"){const Xt=vj(St,(s==null?void 0:s.id)??"");Xt?Xt.route==="approver"?await z.rejectProposal(rt,ym()):await z.resolveProposal(rt,"reject",Xt.domain,ym()):Nt="you are not one of the people who may decide it"}}catch(St){Nt=St instanceof Error?St.message:"unknown error"}if(sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),sessionStorage.removeItem("agentReplacesProposal"),Nt){ne(`Your mandate is signed and active. The AI's proposal could not be withdrawn (${Nt}) — reject it under Approvals.`);return}t(`/mandates?highlight=${encodeURIComponent(xe)}`)}catch(J){ne(J instanceof Error?J.message:"Signing the mandate failed")}finally{Z(!1)}}};if(!l||!f)return n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const B=Object.entries(f.bounds).filter(([J])=>J!=="profile"&&J!=="path"),re=Object.entries(f.context),pe=((he==null?void 0:he.caps)!=null?Object.keys(he.caps):[]).length!==0,ye=ve.length>0?ve.join(", "):((he==null?void 0:he.approvers)??[]).join(", "),oe=pe?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${ye}, regardless of your mode.`:"No caps set — they won't gate any action, but your intent is encrypted and shared with them as an accountability record.",Ge=pe?`Over-cap actions will be reviewed by you and ${ye}. Within-cap actions run per the mode you chose above.`:`Approvers ${ye} can read your intent but won't gate any action — no caps configured on this profile.`,be=!!((Oe=he==null?void 0:he.approvers)!=null&&Oe.length),Y=ip({isPersonal:l.isPersonal,configLoaded:ee,grantors:he?uh(he):void 0,userId:s==null?void 0:s.id,profileName:Mt(l.profileId),teamName:l.groupName}),$e=!Y.can,_e=pm(p),Be=_e.length===0,ze=j>b,it={flex:1,padding:"0.75rem",border:y==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius-md)",background:y==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},tt={flex:1,padding:"0.75rem",border:y==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius-md)",background:y==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Qe=((G=p==null?void 0:p.scopeSchema)==null?void 0:G.keyOrder)??[],Ye=q.filter(J=>fj(Qe,f.context,J.context)),jt=Ye.length>0,pt=Mt(l.profileId),Me=J=>{const ge=Object.values(J).map(Ue=>String(Ue).trim()).filter(Boolean);return ge.length>0?ge.join(", "):"all (unscoped)"},me=Ye.map(J=>Me(J.context)).join("; "),Ie=`This grant's scope overlaps an existing grant on ${pt} (scoped to: ${me}). The agent may act under either. Per-action limits take the more permissive value, and daily limits add together — two grants of 10/day allow 20/day. Approval is not weakened: if either grant requires review, review still applies. Confirm this is intended before authorizing.`;return n.jsxs(n.Fragment,{children:[n.jsx(Qh,{currentStep:4,onStepClick:J=>{J<=3&&t(`/mandates/new/intent?step=${J}`)}}),n.jsxs("div",{className:"card",children:[n.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),l.upgradedFromProfileId&&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 ",Mt(l.profileId)," ",p.version," — the current version of this profile."]})]}),F&&n.jsx("div",{className:"error-message",children:F}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Title"]}),n.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${Mt(l.profileId)}: daily operations`,value:A,onChange:J=>D(J.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),n.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this mandate on your dashboard."})]}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[_e.includes("per-action")&&n.jsxs("button",{onClick:()=>x("per-action"),style:tt,children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),_e.includes("immediate")&&n.jsxs("button",{onClick:()=>x("immediate"),style:it,children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]}),_e.length===1&&n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:_e[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),Be&&n.jsx("div",{className:"msg-error",style:{fontSize:"0.75rem",marginTop:"0.25rem"},children:"This profile allows no commitment mode, so no mandate can be signed under it. Its publisher must fix the profile."})]}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Duration"]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center"},children:[[{label:"1 hour",seconds:3600},{label:"24 hours",seconds:86400},{label:"7 days",seconds:604800},{label:"30 days",seconds:2592e3},{label:"1 year",seconds:31536e3}].filter(J=>J.seconds<=b).map(J=>n.jsx("button",{onClick:()=>{k(J.seconds),E("")},style:{padding:"0.5rem 0.85rem",border:j===J.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:j===J.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:J.label},J.seconds)),n.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[n.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:N,onChange:J=>{E(J.target.value);const ge=parseInt(J.target.value,10);if(ge>0){const Ue=T==="days"?ge*86400:ge*3600;k(Math.min(Ue,b))}}}),n.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:T,onChange:J=>{P(J.target.value);const ge=parseInt(N,10);if(ge>0){const Ue=J.target.value==="days"?ge*86400:ge*3600;k(Math.min(Ue,b))}},children:[n.jsx("option",{value:"hours",children:"hours"}),n.jsx("option",{value:"days",children:"days"})]})]}),ze&&n.jsxs("span",{className:"msg-error",style:{fontSize:"0.75rem"},children:["Maximum: ",b>=86400?`${Math.floor(b/86400)} days`:`${Math.floor(b/3600)} hours`]})]})]}),n.jsx("div",{className:"field-editable",children:n.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[n.jsx("input",{type:"checkbox",checked:L||O,disabled:L,onChange:J=>K(J.target.checked),style:{marginTop:"0.15rem"}}),n.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this mandate",n.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.15rem"},children:['Adds "verified by Suveren" with your name to outgoing content. Takes effect only if your identity is verified; otherwise actions stay pseudonymous.',L&&" 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})]}),(!!B.length||!!re.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:[re.map(([J,ge])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:J}),n.jsx("dd",{children:ap(J,ge,f.contextLabels)})]},J)),B.map(([J,ge])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:J}),n.jsx("dd",{children:String(ge)})]},J))]})]}),n.jsxs("div",{className:"info-block",children:[n.jsx("div",{className:"info-head",children:n.jsx("span",{className:"info-title",children:"Authority"})}),n.jsxs("dl",{className:"info-kv",children:[n.jsx("dt",{children:"Profile"}),n.jsxs("dd",{children:[Mt(l.profileId),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:l.profileId})]}),!l.isPersonal&&l.groupName&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Team"}),n.jsx("dd",{children:l.groupName})]}),!l.isPersonal&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Approvers"}),n.jsx("dd",{children:ee?Y.can?n.jsxs(n.Fragment,{children:[ye,n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:oe})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"msg-error",children:Y.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${l.groupName??"this team"}`:"You cannot give this mandate"}),Y.code==="OWNER_NOT_APPROVER"&&n.jsx("div",{children:ye}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[Y.reason," ",Y.fix]})]}):n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),$>0?n.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px dashed var(--border-strong)",borderLeft:"3px dashed var(--text-primary)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[n.jsx("span",{"aria-hidden":"true",style:{fontWeight:700},children:"!"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),n.jsxs("div",{children:[$===1?`An active grant on ${pt} already has exactly these limits.`:`${$} active grants on ${pt} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",n.jsx("strong",{children:"Extend"})," on the Mandates page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,jt?n.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px dashed var(--border-strong)",borderLeft:"3px dashed var(--text-primary)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[n.jsx("span",{"aria-hidden":"true",style:{fontWeight:700},children:"!"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,marginBottom:"0.2rem"},children:"Overlapping scope"}),n.jsx("div",{children:Ie})]})]}):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:fe,disabled:te||!A.trim()||$e||Be,children:te?"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:be?"block":"none"},children:Ge})]})]})}const bj={card:"💳",mail:"✉️"};function cp(t){return bj[t]??"🔧"}function kj(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 Nj=[0,7,30,90,365,3650];function Ti(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 Cj(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 tc({manifest:t,integration:s,state:a,onStatusChange:o,onSuccess:l}){var Me;const[u,f]=m.useState({}),[g,p]=m.useState(!1),[v,y]=m.useState(!1),[x,j]=m.useState({}),[k,b]=m.useState({}),[S,N]=m.useState(void 0),[E,T]=m.useState(!1),[P,A]=m.useState(null),[D,O]=m.useState(!1),[K,L]=m.useState(!1),[W,te]=m.useState(!1),[Z,F]=m.useState(!1),[ne,he]=m.useState({}),[Q,ve]=m.useState(null),[we,ee]=m.useState(!1),[X,q]=m.useState(null),[I,$]=m.useState(!1);m.useEffect(()=>{let me=!1;return z.getCredential(t.id).then(Ie=>{var Oe;if(!(me||!Ie.configured)){if(p(!0),y(!0),Ie.fields){const G={};for(const J of t.credentials.fields)Ie.fields[J.key]!=null&&(G[J.key]=Ie.fields[J.key]);j(G)}if(b(Ie.secrets??{}),N(Ie.updatedAt),t.oauth){const G=((Oe=Ie.fieldNames)==null?void 0:Oe.includes(t.oauth.tokenStorage))??!1;T(G),G&&z.getOAuthHealth(t.id).then(J=>{me||A(J)})}}}).catch(()=>{}),()=>{me=!0}},[t.id,t.oauth]);const ie=kj(t.toolGating),fe=s?s.readAgeDays??null:void 0,B=we&&Q?Q.value:fe,re=async me=>{ve({value:me}),ee(!0),q(null);try{await z.setReadPolicy(t.id,me),l(me===null?`${t.name} read window now follows your mandate`:`${t.name} read window set to ${Ti(me).toLowerCase()}`),o()}catch(Ie){q(Ie instanceof Error?Ie.message:"Could not save")}finally{ee(!1),ve(null)}},ce=!!t.oauth||t.credentials.fields.some(me=>!me.optional),pe=t.oauth?E:g,ye=!ce||pe,oe=a==="starting"?"starting":ye?s!=null&&s.running?"running":!g&&t.credentials.fields.length>0?"unconfigured":"ready":t.oauth&&g&&!E?"needs-oauth":"unconfigured",Ge=async()=>{if(t.credentials.fields.some(Ie=>{var Oe;return(Oe=u[Ie.key])==null?void 0:Oe.trim()})){O(!0);try{await z.setCredential(t.id,u),p(!0),f({}),t.oauth?l(`${t.name} credentials saved!`):(l(`${t.name} credentials saved — starting integration...`),await Be())}catch{l(`Failed to save ${t.name} credentials`)}finally{O(!1)}}},be=()=>{const me={};for(const Ie of t.credentials.fields){const Oe=u[Ie.key];Ie.type==="password"?Oe!=null&&Oe.trim()&&(me[Ie.key]=Oe):Oe!=null&&Oe!==(x[Ie.key]??"")&&(me[Ie.key]=Oe)}return me},Y=Object.keys(be()).length>0,$e=async()=>{const me=be();if(Object.keys(me).length!==0){O(!0);try{await z.setCredential(t.id,me),f({}),p(!0),t.oauth?l(`${t.name} credentials saved — now click Connect.`):(F(!1),l(`${t.name} credentials updated — restarting...`),await Be())}catch{l(`Failed to update ${t.name} credentials`)}finally{O(!1)}}},_e=()=>{window.open(`/auth/oauth/${t.id}/start`,"_blank","width=600,height=700");const me=setInterval(async()=>{var Ie;try{const Oe=await z.getCredential(t.id);Oe.configured&&t.oauth&&((Ie=Oe.fieldNames)!=null&&Ie.includes(t.oauth.tokenStorage))&&(T(!0),F(!1),A(null),clearInterval(me),l(`${t.name} connected — starting integration...`),z.getOAuthHealth(t.id).then(A).catch(()=>{}),await Be())}catch{}},2e3);setTimeout(()=>clearInterval(me),12e4)},Be=async()=>{te(!0);try{const me=await z.activateIntegration(t.id);me.warning?l(me.warning):l(`${t.name} integration started with ${me.tools.length} tools`),o()}catch(me){l(`Failed to start ${t.name}: ${me instanceof Error?me.message:"Unknown error"}`)}finally{te(!1)}},ze=async()=>{try{await z.removeMcpIntegration(t.id),l(`${t.name} integration removed`),o()}catch{l(`Failed to remove ${t.name}`)}},it=cp(t.icon),tt=Cj(s),Qe=oe==="running"?{c:"int-chip-ok",t:"Running"}:oe==="starting"?{c:"int-chip-idle",t:"Starting"}:tt.chip,Ye=t.oauth&&E&&(P==null?void 0:P.status)==="failed",jt=ce?Ye?{c:"int-chip-bad",t:"Auth failed"}:pe?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},pt=me=>me.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${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:it}),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:[oe!=="unconfigured"&&oe!=="needs-oauth"&&n.jsxs("span",{className:`int-chip ${Qe.c}`,children:[n.jsx("span",{className:"int-dot"}),Qe.t]}),n.jsxs("span",{className:`int-chip ${jt.c}`,children:[n.jsx("span",{className:"int-dot"}),jt.t]}),Px(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"})}),Ye&&!Z&&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:_e,children:["Reconnect ",t.name]}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{f({...x}),F(!0)},children:"Edit credentials"})]})]}),n.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[n.jsx("summary",{children:"Details"}),n.jsxs("div",{className:"int-meta",children:[n.jsx("span",{className:"int-k",children:"What"}),n.jsx("span",{children: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:((Me=t.oauth.scopes)==null?void 0:Me.join(", "))||"—"})]}),s&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Tools"}),n.jsxs("span",{children:[s.toolCount," gated"]})]})]})]}),t.setupGuide&&t.setupGuide.length>0&&(oe!=="running"||Ye)&&n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n.jsxs("button",{onClick:()=>L(!K),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[n.jsx("span",{style:{transition:"transform 0.2s",transform:K?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",t.name]}),K&&n.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:t.setupGuide.map((me,Ie)=>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:Ie+1}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:me.title}),n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[pt(me.description),me.link&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("a",{href:me.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},Ie))})]}),oe==="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…"]}),Z&&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(me=>{var Ie;return n.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[n.jsx("label",{className:"form-label",children:me.label}),me.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:ne[me.key]?"text":"password",name:`${t.id}-${me.key}-credential`,autoComplete:"new-password",placeholder:(Ie=k[me.key])!=null&&Ie.preview?`Unchanged — ends in ${k[me.key].preview}`:v?"Unchanged — paste a new value to replace":me.placeholder,value:u[me.key]||"",onChange:Oe=>f(G=>({...G,[me.key]:Oe.target.value}))}),n.jsx("button",{className:"cred-toggle",onClick:()=>he(Oe=>({...Oe,[me.key]:!Oe[me.key]})),children:ne[me.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${t.id}-${me.key}-credential`,autoComplete:"off",placeholder:me.placeholder,value:u[me.key]||"",onChange:Oe=>f(G=>({...G,[me.key]:Oe.target.value}))})]},me.key)}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:$e,disabled:D||!Y,children:D?"Saving…":"Save"}),!Y&&!D&&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:_e,children:["Connect ",t.name]}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{F(!1),f({})},children:"Cancel"})]})]}),!Z&&oe==="running"&&s&&n.jsxs(n.Fragment,{children:[(Object.keys(x).length>0||Object.keys(k).length>0)&&n.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:t.credentials.fields.map(me=>{const Ie=me.type==="password",Oe=k[me.key];return!Ie&&x[me.key]==null||Ie&&Oe==null?null:n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[n.jsx("span",{style:{color:"var(--text-muted)"},children:me.label}),n.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[Ie?Oe.preview??"set":x[me.key],Ie&&S&&n.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(S).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},me.key)})}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[n.jsx(ht,{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}),F(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),n.jsx("span",{style:{flex:1}}),n.jsx("button",{className:"btn btn-sm btn-outline-strong",onClick:ze,title:"Stops the subprocess and removes the integration from the registry. It will NOT auto-start on next gateway restart. Re-enable with Install.",children:"Disable"})]}),ie&&B!==void 0&&!I&&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:B===null?"window from your mandate":Ti(B).toLowerCase()}),we&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),X&&n.jsx("span",{className:"msg-error",style:{fontSize:"0.78rem"},children:X})]}),n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>$(!0),children:"Edit"})]})}),ie&&B!==void 0&&I&&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:[Nj.map(me=>{const Ie=B===me;return n.jsx("button",{className:`btn btn-sm ${Ie?"btn-primary":"btn-secondary"}`,"aria-pressed":Ie,disabled:we,onClick:()=>re(me),children:Ti(me)},me)}),n.jsx("button",{className:`btn btn-sm ${B===null?"btn-primary":"btn-ghost"}`,"aria-pressed":B===null,disabled:we,onClick:()=>re(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:Ti(null)})]}),n.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:X?n.jsx("span",{className:"msg-error",children:X}):we?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):B===null?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):B===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 ",B," days is blocked, whoever it is from."]})})]}),n.jsx("div",{style:{display:"none"},children:n.jsx(ht,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),oe==="unconfigured"&&(()=>{const me=t.credentials.fields.every(G=>G.optional),Ie=t.credentials.fields.some(G=>!G.optional),Oe=t.credentials.fields.some(G=>{var J;return(J=u[G.key])==null?void 0:J.trim()});return n.jsxs(n.Fragment,{children:[v&&n.jsxs("div",{className:"alert",style:{fontSize:"0.8rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.75rem",marginBottom:"0.75rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{style:{color:"var(--text-primary)"},children:"Credentials on file."})," ","Existing values are encrypted in the vault and not shown. Enter new values below to replace them, or"," ",n.jsx("button",{onClick:()=>{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(G=>n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{className:"form-label",children:G.label}),G.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:ne[G.key]?"text":"password",name:`${t.id}-${G.key}-credential`,autoComplete:"new-password",placeholder:G.placeholder,value:u[G.key]||"",onChange:J=>f(ge=>({...ge,[G.key]:J.target.value}))}),n.jsx("button",{className:"cred-toggle",onClick:()=>he(J=>({...J,[G.key]:!J[G.key]})),children:ne[G.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${t.id}-${G.key}-credential`,autoComplete:"off",placeholder:G.placeholder,value:u[G.key]||"",onChange:J=>f(ge=>({...ge,[G.key]:J.target.value}))})]},G.key)),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[Oe&&n.jsx("button",{className:"btn btn-primary",onClick:Ge,disabled:D||Ie&&!t.credentials.fields.filter(G=>!G.optional).every(G=>{var J;return(J=u[G.key])==null?void 0:J.trim()}),children:D?"Saving...":"Save & Encrypt"}),me&&!Oe&&n.jsx("button",{className:"btn btn-primary",onClick:Be,disabled:W,children:W?"Starting...":`Activate ${t.name}`})]})]})})(),oe==="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:_e,children:["Connect ",t.name," Account"]}),n.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Change Credentials"})]})]}),oe==="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:Be,disabled:W,children:W?"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"})]})]}),oe==="ready"&&s&&!s.running&&(tt.showStart?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[n.jsx("span",{className:"service-status-dot"}),"Not running"]}),s.error&&n.jsx("div",{className:"msg-error",style:{fontSize:"0.8rem",marginBottom:"0.75rem"},children:s.error}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:Be,disabled:W,children:W?"Starting...":"Start"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:ze,children:"Disable"})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"service-status",style:{marginBottom:"0.5rem",color:"var(--text-muted)"},children:[n.jsx("span",{className:"service-status-dot",style:{background:"var(--text-muted)"}}),"Paused"]}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.75rem"},children:"Real systems are off while simulation mode is on."}),n.jsx("div",{style:{display:"flex",gap:"0.5rem"},children:n.jsx("button",{className:"btn btn-outline-strong",onClick:ze,children:"Disable"})})]}))]})}function vm(t,s){const a=new Map;for(const o of t){const l=o.manifest.profile;let u=a.get(l);u||(u={shortId:l,icon:Ir(l),name:Bn(l,s),entries:[]},a.set(l,u)),u.entries.push(o)}return[...a.values()].sort((o,l)=>o.name.localeCompare(l.name))}function Ej(t,s){if(!s)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:t};const a=t.filter(f=>la(f.manifest)),o=t.filter(f=>!la(f.manifest)),l=o.filter(f=>f.state==="error"),u=o.filter(f=>f.state!=="error");return{grouped:!0,testSystems:a,realErrors:l,pausedReal:u,ungrouped:[]}}function xm({group:t,children:s}){return n.jsxs("div",{className:"area-group","data-testid":"integration-area","data-area":t.shortId,children:[n.jsxs("div",{className:"area-group-h",children:[n.jsx(pa,{icon:t.icon}),n.jsx("b",{children:t.name})]}),s]})}function Tj({entry:t}){return n.jsxs("div",{className:"int-paused-row",children:[n.jsx("span",{"aria-hidden":"true",children:cp(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 Ij(){const{loading:t,mcpServerUp:s,manifestsError:a,entries:o,refresh:l}=Fc(),u=zc(),[f,g]=m.useState(""),p=$r(),v=m.useCallback(x=>{g(x),setTimeout(()=>g(""),5e3)},[]),y=Ej(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."})]}):y.grouped?n.jsxs(n.Fragment,{children:[y.testSystems.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Test systems"}),vm(y.testSystems,p).map(x=>n.jsx(xm,{group:x,children:x.entries.map(j=>n.jsx(tc,{manifest:j.manifest,integration:j.integration,state:j.state,onStatusChange:l,onSuccess:v},j.id))},x.shortId))]}),(y.realErrors.length>0||y.pausedReal.length>0)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Real systems"}),y.realErrors.map(x=>n.jsx(tc,{manifest:x.manifest,integration:x.integration,state:x.state,onStatusChange:l,onSuccess:v},x.id)),y.pausedReal.length>0&&n.jsxs("details",{className:"int-paused-group",open:!0,children:[n.jsxs("summary",{children:["Paused while simulation mode is on (",y.pausedReal.length,")"]}),n.jsxs("p",{className:"int-paused-group-note",children:["Nothing is lost — mandates, credentials and data stay. They start again when simulation mode is switched off (",n.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),y.pausedReal.map(x=>n.jsx(Tj,{entry:x},x.id))]})]}),o.length===0&&n.jsx(wm,{manifestsError:a})]}):n.jsxs(n.Fragment,{children:[vm(o,p).map(x=>n.jsx(xm,{group:x,children:x.entries.map(j=>n.jsx(tc,{manifest:j.manifest,integration:j.integration,state:j.state,onStatusChange:l,onSuccess:v},j.id))},x.shortId)),o.length===0&&n.jsx(wm,{manifestsError:a})]})]})}function wm({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 Aj(){var F,ne,he;const{activeTeam:t,activeMembership:s,refreshGroups:a,user:o}=xt(),l=Sn(),[u,f]=m.useState(null),[g,p]=m.useState(!1),[v,y]=m.useState(""),[x,j]=m.useState(""),[k,b]=m.useState(!1),[S,N]=m.useState(""),[E,T]=m.useState("");m.useEffect(()=>{fetch("/health").then(Q=>Q.json()).then(Q=>{typeof Q.spUrl=="string"&&T(Q.spUrl)}).catch(()=>{})},[]),m.useEffect(()=>{if(!t){f(null);return}z.getGroupById(t.id).then(Q=>{const ve=Q.group??Q,we=Q.members??[],ee=Q.isAdmin??!1,X=we.map(q=>{const I=q.userId||q.id||"",$=q.role||(ee&&I===ve.createdBy?"admin":"member");return{id:I,name:q.name||I.slice(0,8)||"Member",email:q.email||"",domains:q.domains||[],role:$,isAdmin:$==="admin"||ee&&I===ve.createdBy}});f({id:ve.id,name:ve.name,members:X})}).catch(()=>f(null))},[t==null?void 0:t.id]);const P=(u==null?void 0:u.members.filter(Q=>Q.isAdmin))??[],A=(t==null?void 0:t.isAdmin)===!0&&P.length<=1&&P.some(Q=>Q.id===(o==null?void 0:o.id)),D=(t==null?void 0:t.name)??"",O=S.trim()===D&&!g,K=()=>{N(""),b(!0)},L=()=>{b(!1),N("")},W=async()=>{if(!(!t||!O)){p(!0),y("");try{await z.leaveTeam(t.id),await a(),j("You have left the team."),f(null),L()}catch(Q){y(Q instanceof Error?Q.message:"Failed to leave team")}finally{p(!1)}}},te=t&&E?`${E}/dashboard/groups/${t.id}`:void 0,Z=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:[((F=u==null?void 0:u.members)==null?void 0:F.length)??0," ",(((ne=u==null?void 0:u.members)==null?void 0:ne.length)??0)===1?"member":"members",t.isAdmin&&" · You are admin"]})]}),n.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(he=u==null?void 0:u.members)==null?void 0:he.map(Q=>n.jsxs("div",{className:"member-row",children:[n.jsx("div",{className:"member-avatar",children:Q.name.split(" ").map(ve=>ve[0]).join("").slice(0,2).toUpperCase()}),n.jsxs("div",{className:"member-info",children:[n.jsx("div",{className:"member-name",children:Q.name}),n.jsx("div",{className:"member-email",children:Q.email})]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Q.role})]},Q.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:[te&&n.jsx("a",{className:"btn btn-secondary btn-sm",href:te,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server →"}),n.jsx("span",{title:A?"You are the only admin. Transfer admin to another member in your Authority Server dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:n.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:K,disabled:g||A,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"}),Z&&n.jsx("a",{className:"btn btn-ghost btn-sm",href:Z,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server →"})]})]}),k&&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:L,children:n.jsxs("div",{className:"card",onClick:Q=>Q.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 ",D,"?"]}),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:D})," to confirm:"]}),n.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:S,onChange:Q=>N(Q.target.value),placeholder:D,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:L,disabled:g,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:W,disabled:!O,children:g?"Leaving...":"Leave team"})]})]})})]})}function qc({areas:t,selected:s,onSelect:a,totalCount:o}){return t.length<2?null:n.jsxs("div",{className:"ftabs",role:"tablist","aria-label":"Which area","data-testid":"area-filter",children:[n.jsxs("button",{type:"button",role:"tab",className:"ftab","aria-selected":s===null,onClick:()=>a(null),children:["All ",n.jsx("span",{className:"n",children:o})]}),t.map(l=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`area-filter-${l.shortId}`,"aria-selected":s===l.shortId,onClick:()=>a(s===l.shortId?null:l.shortId),children:[n.jsx(pa,{icon:l.icon})," ",l.name," ",n.jsx("span",{className:"n",children:l.count})]},l.shortId))]})}const ua=t=>t.replace(/@.*$/,"").split("/").pop()??t,jm=t=>t.split("@")[1]??"";function Rj(t,s){const a=new Map;for(const o of t){const l=ua(o.id);if(!s.has(l))continue;const u=a.get(l);(!u||jm(o.id).localeCompare(jm(u.id),void 0,{numeric:!0})>0)&&a.set(l,o)}return a}function Pj(t,s,a,o){var g;const l=new Set([...s.filter(p=>p.profile).map(p=>p.profile),...o.map(p=>ua(p.profile))]),u=Rj(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(ua(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 $j(t,s,a){if(s)return t.find(o=>ua(o.profile.id)===ua(s)&&o.ready&&a(o))}function up({icon:t,className:s}){return n.jsx(pa,{icon:t,className:s})}function _j({onDismiss:t,preselectProfileId:s}){const a=Sn(),{group:o,groupId:l,domain:u,user:f}=xt(),[g,p]=m.useState([]),[v,y]=m.useState([]),[x,j]=m.useState([]),[k,b]=m.useState([]),[S,N]=m.useState(!0),[E,T]=m.useState({});m.useEffect(()=>{Promise.all([z.listProfiles().catch(()=>[]),z.getIntegrationManifests().then(W=>W.manifests??[]).catch(()=>[]),z.getMcpHealth().catch(()=>null)]).then(async([W,te,Z])=>{if(p(W),y(te),j((Z==null?void 0:Z.integrations)??[]),b((Z==null?void 0:Z.builtins)??[]),l){const F=await Promise.all(W.map(he=>z.getTeamProfileConfig(l,he.id).catch(()=>null))),ne={};W.forEach((he,Q)=>{const ve=F[Q];ve&&(ne[he.id]=ve)}),T(ne)}}).finally(()=>N(!1))},[l]);const P=Pj(g,v,x,k),A=W=>{const te=E[W.id];return ip({isPersonal:!!(o!=null&&o.isPersonal),configLoaded:!S,grantors:te?uh(te):void 0,userId:f==null?void 0:f.id,profileName:Mt(W.id),teamName:o==null?void 0:o.name})},D=W=>W in E,O=(W,te)=>{if(!l){console.error("No active group when creating authorization");return}const Z=D(W);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:W,groupId:l,groupName:(o==null?void 0:o.name)??null,domain:u,isTeam:Z,isPersonal:!!(o!=null&&o.isPersonal),...te?{intentHint:te}:{}})),sessionStorage.removeItem("agentGate"),t==null||t(),a("/mandates/new/intent")},K=(W,te)=>{l&&O(W,te)},L=m.useRef(!1);return m.useEffect(()=>{if(S||!s||L.current)return;const W=$j(P,s,te=>A(te.profile).can);W&&(L.current=!0,K(W.profile.id,W.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(ht,{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(W=>{const te=W.profile,Z=D(te.id),F=A(te),ne=!W.ready||!F.can,{icon:he}=Pr(te.id,{name:te.name});return n.jsxs("div",{className:"card",style:ne?{opacity:.7}:void 0,children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[n.jsxs("h3",{className:"card-title profile-chip",style:{margin:0},children:[n.jsx(up,{icon:he,className:"profile-chip-icon"}),W.name]}),Z?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:W.description}),F.can?W.ready?n.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>K(te.id,W.intentHint),children:"Give a mandate"}):W.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:W.unavailableReason})]}):n.jsxs(ht,{to:`/integrations?setup=${W.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>t==null?void 0:t(),children:["Set up ",W.name]}):n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:[F.reason," ",n.jsx("span",{style:{color:"var(--text-tertiary)"},children:F.fix})]})]})]},W.key)})})]})}const Lj={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function zj({status:t,label:s}){return n.jsx("span",{className:`status-badge status-${t}`,children:s||Lj[t]})}function Fj({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 kr=86400,sa=3600,Ii=60,Mj=30*kr;function Oj(t){if(t<=0)return"Expired";if(t>90*kr){const s=Math.floor(t/Mj);return`${s} ${s===1?"month":"months"} remaining`}if(t>7*kr){const s=Math.floor(t/kr);return`${s} ${s===1?"day":"days"} remaining`}if(t>=2*kr){const s=Math.floor(t/kr),a=Math.floor(t%kr/sa);return`${s} ${s===1?"day":"days"} ${a}h remaining`}if(t>=2*sa){const s=Math.floor(t/sa),a=Math.floor(t%sa/Ii);return`${s}h ${String(a).padStart(2,"0")}m remaining`}if(t>=Ii){const s=Math.floor(t/Ii),a=Math.floor(t%Ii);return`${s}m ${String(a).padStart(2,"0")}s remaining`}return`${Math.floor(t)}s remaining`}function Bj({expiresAt:t}){const[s,a]=m.useState(()=>t-Date.now()/1e3),o=s<2*sa;m.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:Oj(s)})}function cs({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 Dj(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 Uj=[{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 Wj({item:t,onClose:s,onSuccess:a}){var P;const{user:o,activeDomain:l,groupId:u}=xt(),[f,g]=m.useState(null);m.useEffect(()=>{let A=!1;return z.getProfile(t.profile_id).then(D=>{var O;A||g(((O=D==null?void 0:D.ttl)==null?void 0:O.max)??null)}).catch(()=>{}),()=>{A=!0}},[t.profile_id]);const p=t.remaining_seconds??0,v=Uj.filter(A=>A.seconds>p&&(f===null||A.seconds<=f)),y=((P=v[0])==null?void 0:P.seconds)??2592e3,[x,j]=m.useState(y);m.useEffect(()=>{var A;if(f!==null&&x>f){const D=(A=v[v.length-1])==null?void 0:A.seconds;D&&j(D)}},[f]);const[k,b]=m.useState(!1),[S,N]=m.useState(""),E=Object.entries(t.frame).filter(([A])=>A!=="profile"&&A!=="path"),T=async()=>{var A;if(o){b(!0),N("");try{const D=t.authorization_id,O=await z.getGateContent(D);if(!O)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const K=await z.getProfile(t.profile_id),L=t.frame,W=O.context??{},te=t.attested_domains[0]||l||"owner",Z=await $i(L,K),F=await np(W,K),[ne,he]=await Promise.all([Wi(O.gateContent.intent),Wi(JSON.stringify({profile:t.profile_id,path:t.path,domain:te}))]);if(!u)throw new Error("No active group; cannot extend mandate.");const Q=(((A=t.deferred_commitment_domains)==null?void 0:A.length)??0)>0?"review":"automatic",ve=await rp(K),we=await z.attest({authorization_id:t.authorization_id,renew:!0,profile_id:t.profile_id,profile_hash:ve,supported_versions:["0.7"],bounds:L,bounds_hash:Z,scope_hash:F,domain:te,did:o.did,mandate_owners:[{did:o.did}],gate_content_hashes:{intent:ne},execution_context_hash:he,group_id:u,commitment_mode:Q,ttl:x});await z.pushGateContent(sp(we,{boundsHash:Z,contextHash:F,context:W,path:t.path,gateContent:O.gateContent})),a()}catch(D){N(D instanceof Error?D.message:"Extension failed")}finally{b(!1)}}};return n.jsx("div",{className:"modal-backdrop",onClick:A=>A.target===A.currentTarget&&s(),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:"Extend mandate"}),n.jsx("button",{className:"modal-close",onClick:s,children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[Mt(t.profile_id)," / ",t.path]}),E.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:E.map(([A,D])=>`${A}=${D}`).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 ",Dj(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(A=>n.jsx("button",{className:`btn ${x===A.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>j(A.seconds),style:{minWidth:"3.5rem"},children:A.label},A.seconds))})]}),n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, scope, and gate content will be re-signed with a new TTL (measured from now)."}),S&&n.jsx("div",{className:"error-message",children:S})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-secondary",onClick:s,disabled:k,children:"Cancel"}),n.jsx("button",{className:"btn btn-primary",onClick:T,disabled:k,children:k?"Extending...":"Extend"})]})]})})}function Sm(t){return t.replace(/@.*$/,"").split("/").pop()??t}function bm(t){return t.split("@")[1]??""}function Hj(t,s){return bm(t).localeCompare(bm(s),void 0,{numeric:!0})>0}function dp(t,s){const a=Sm(t);let o;for(const l of s)Sm(l.id)===a&&(!o||Hj(l.id,o.id))&&(o=l);return o}function fp(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 mp(t,s){return fp(t,s.boundsSchema)}function hp(t,s){return fp(t,s.scopeSchema)}function Vj(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=zi(o,s),f=zi(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 Gj({item:t,newerProfile:s,area:a,revokedSet:o,expandedHash:l,gateCache:u,gateLoading:f,copiedHash:g,revokingHash:p,copyingHash:v,profileConfigCache:y,mode:x,ownerLabel:j,isAdmin:k,onExpand:b,onCopyHash:S,onCopy:N,onRevoke:E,onExtend:T,archivedSet:P,archivingHash:A,onArchive:D,highlightHash:O,needsReapprovalSet:K}){var Ge;const L=Lc(t,{revokedSet:o}),W=L==="active"&&((K==null?void 0:K.has(t.authorization_id))??!1),te=ph(t,{revokedSet:o,archivedSet:P}),Z=!j&&!!D&&hh(L),F=l===t.authorization_id,ne=u[t.authorization_id],he=L==="active"||L==="pending"||L==="expired",Q=Object.entries(t.frame).filter(([be])=>be!=="profile"&&be!=="path"),ve=y.get(t.profile_id)??null,we=(((Ge=ve==null?void 0:ve.approvers)==null?void 0:Ge.length)??0)>0,ee=new Map;if(ve!=null&&ve.caps&&x==="team")for(const[be,Y]of Q){const $e=ve.caps[be];typeof $e=="number"&&Number(Y)>$e&&ee.set(be,{authorized:Number(Y),cap:$e})}const X=ee.size>0,q=t.approvers_frozen??[],I=(ve==null?void 0:ve.approvers)??[],$=x==="team"&&q.length>0&&I.length>0&&(q.length!==I.length||q.some(be=>!I.includes(be))||I.some(be=>!q.includes(be))),ie=Array.from(ee.entries()).map(([be,Y])=>`${be}: ${Y.authorized} (cap ${Y.cap})`).join(", "),fe=Array.from(ee.entries()).map(([be,Y])=>`${be}: ${Y.authorized} → ${Y.cap}`).join(", "),B=X?we?ee.size===1?`Above team cap: ${ie} — actions require approval`:`Above team cap (${ee.size}): ${ie} — actions require approval`:ee.size===1?`Reduced by hard cap: ${fe}`:`Reduced by hard cap (${ee.size}): ${fe}`:"",re=X?we?"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,ce=Pr(t.profile_id),pe=ce.name,ye=s?n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem",padding:"0.4rem 0.6rem",border:"1px solid var(--border)",borderRadius:6},children:[n.jsxs("strong",{style:{color:"var(--text-secondary)"},children:[pe,"@",s.version," available"]}),s.whatsNew?n.jsxs(n.Fragment,{children:[" — ",s.whatsNew]}):null,n.jsx("br",{}),n.jsxs("span",{children:["This mandate stays on ",t.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,oe=O!=null&&t.authorization_id===O;return n.jsx("div",{className:`card mandate-card${oe?" card-highlight":""}`,style:{marginBottom:0},children:n.jsxs("div",{className:"id-body",children:[t.created_at&&n.jsxs("div",{className:"obj-line",children:["since ",new Date(t.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})]}),ye,j&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",n.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:j})]}),n.jsxs("div",{className:"auth-card-header",children:[n.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:t.title||pe}),n.jsx(zj,{status:L}),W&&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"}),ce.testSetup&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),L==="active"&&t.earliest_expiry&&n.jsx(Bj,{expiresAt:new Date(t.earliest_expiry).getTime()/1e3}),L==="expired"&&(()=>{const be=Rx(t,L);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(Fj,{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:re,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"transparent",color:"var(--text-primary)",border:we?"1px dashed var(--text-primary)":"2px solid var(--text-primary)",fontWeight:600,cursor:"help"},children:B}),$&&n.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.65rem",padding:"0.15rem 0.5rem",borderRadius:"0.25rem",background:"transparent",color:"var(--text-primary)",fontWeight:600,border:"1px dashed var(--text-primary)",cursor:"pointer",lineHeight:1.4},onClick:()=>N(t),disabled:v===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:v===t.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),Q.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:Q.map(([be,Y],$e)=>{const _e=ee.get(be);return n.jsxs("span",{children:[$e>0&&" · ",_e?we?n.jsxs("span",{title:`Team cap on ${be} is ${_e.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${_e.authorized}.`,children:[n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[be,"=",String(Y)]}),n.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",_e.cap]})]}):n.jsxs("span",{title:`Team cap on ${be} is ${_e.cap} with no approvers configured (hard cap). Authorized for ${_e.authorized}; effective ${_e.cap}.`,children:[n.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[be,"=",String(Y)]}),n.jsxs("span",{style:{marginLeft:"0.25rem",fontWeight:700},children:["→"," ",_e.cap]})]}):n.jsxs("span",{children:[be,"=",String(Y)]})]},be)})}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[Z&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>D(t.authorization_id,!te),disabled:A===t.authorization_id,title:te?"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:A===t.authorization_id?te?"Unarchiving…":"Archiving…":te?"↩ Unarchive":"⊟ Archive"}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>b(t),children:F?"▲ Hide Details":"▼ Details"})]}),F&&n.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[Q.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:Q.map(([be,Y])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:be}),n.jsx("dd",{children:String(Y)})]},be))})]}),(ne==null?void 0:ne.context)&&Object.keys(ne.context).length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Scope"}),n.jsx("dl",{className:"review-grid",children:Object.entries(ne.context).map(([be,Y])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:be}),n.jsx("dd",{title:String(Y),children:ap(be,Y,ne.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"}),f===t.authorization_id?n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):ne?n.jsx("div",{className:"gate-content-block",children:n.jsx("div",{className:"gate-content-item",children:n.jsx("div",{className:"gate-content-text",children:ne.gateContent.intent})})}):n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"1rem"},children:["Created: ",new Date(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:()=>S(t.authorization_id),children:g===t.authorization_id?"copied":"copy"})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!j&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>N(t),disabled:v===t.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:v===t.authorization_id?"Copying…":"⧉ Copy"}),!j&&(L==="active"||L==="pending")&&n.jsx("button",{className:W?"btn btn-primary btn-sm":"btn btn-secondary btn-sm",onClick:()=>N(t,{asEdit:!0}),disabled:v===t.authorization_id,title:W?"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:W?"⚠ Re-approve":"✎ Edit"}),!j&&he&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>T(t),children:"↻ Extend"}),j&&k&&L!=="revoked"?n.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>E(t.authorization_id,j,pe),disabled:p===t.authorization_id,children:p===t.authorization_id?"Revoking…":"Revoke"}):!j&&(L==="active"||L==="pending")?n.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>E(t.authorization_id),disabled:p===t.authorization_id,children:p===t.authorization_id?"Revoking…":"Revoke"}):null]})]})]})},t.authorization_id)}function Kj(){const[t,s]=m.useState([]),[a,o]=m.useState(!0),[l,u]=m.useState([]),[f,g]=m.useState(!1),[p,v]=m.useState(new Map),[y,x]=m.useState("mine"),[j,k]=m.useState("active"),[b,S]=m.useState(null),[N,E]=m.useState(null),[T,P]=ms(),[A,D]=m.useState(()=>T.get("new")==="1"),[O]=m.useState(()=>T.get("profile")),[K,L]=m.useState(()=>T.get("highlight")),[W,te]=m.useState(null),[Z,F]=m.useState({}),[ne,he]=m.useState(null),[Q,ve]=m.useState(null),[we,ee]=m.useState(null),[X,q]=m.useState(new Set),[I,$]=m.useState(null),[ie,fe]=m.useState(new Set),[B,re]=m.useState(null),[ce,pe]=m.useState(null),[ye,oe]=m.useState(new Set),Ge=Sn(),{group:be,groupId:Y,domain:$e,mode:_e,activeTeam:Be}=xt(),ze=(Be==null?void 0:Be.isAdmin)===!0,[it,tt]=m.useState(()=>new Map),[Qe,Ye]=m.useState([]);m.useEffect(()=>{z.getLabelManifests().then(Ye).catch(()=>{})},[]);const jt=m.useCallback(()=>{o(!0),z.getMyAttestations().then(s).catch(()=>{}).finally(()=>o(!1))},[]),pt=m.useCallback(()=>{z.getArchivedMandates().then(ue=>fe(new Set(ue))).catch(()=>{})},[]);m.useEffect(()=>{pt()},[pt]);const Me=m.useCallback(()=>{z.getEnrichedAuthorizations().then(ue=>oe(new Set(ue.filter(Ce=>Ce.needsReapproval).map(Ce=>Ce.authorizationId)))).catch(()=>{})},[]);m.useEffect(()=>{Me()},[Me]);const me=async(ue,Ce)=>{re(ue);try{const Ae=await z.setMandateArchived(ue,Ce);fe(new Set(Ae)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(Ae){alert(Ae instanceof Error?Ae.message:"Failed to update archive")}finally{re(null)}},Ie=m.useCallback(()=>{Y&&(g(!0),z.listTeamAuthorizations(Y).then(u).catch(()=>{}).finally(()=>g(!1)))},[Y]);Fe("attestation-changed",()=>{jt(),ze&&Y&&Ie(),Me()}),m.useEffect(()=>{if(!K)return;T.get("highlight")&&(T.delete("highlight"),P(T,{replace:!0}));const ue=window.setTimeout(()=>L(null),3e3);return()=>window.clearTimeout(ue)},[]),Ft(jt,3e5),m.useEffect(()=>{y==="team"&&ze&&Y&&l.length===0&&!f&&Ie()},[y,ze,Y,l.length,f,Ie]),m.useEffect(()=>{let ue=!1;return z.listProfiles().then(Ce=>{if(ue)return;const Ae=Ct=>Ct.replace(/@.*$/,"").split("/").pop()??Ct,Ve=Ct=>Ct.split("@")[1]??"",Xe=new Map;for(const Ct of Ce){const Pt=Ae(Ct.id),_r=Xe.get(Pt);(!_r||Ve(Ct.id).localeCompare(Ve(_r.id),void 0,{numeric:!0})>0)&&Xe.set(Pt,Ct)}v(Xe)}).catch(()=>{}),()=>{ue=!0}},[]);const Oe=m.useCallback(ue=>{const Ce=Pt=>Pt.replace(/@.*$/,"").split("/").pop()??Pt,Ae=Pt=>Pt.split("@")[1]??"",Ve=p.get(Ce(ue));if(!Ve)return;const Xe=Ae(ue),Ct=Ae(Ve.id);if(!(!Xe||!Ct))return Ct.localeCompare(Xe,void 0,{numeric:!0})>0?Ve:void 0},[p]),G=m.useCallback(ue=>Bn(ue,[...p.values()]),[p]);m.useEffect(()=>{if(_e!=="team"||!Y)return;const ue=y==="mine"?t:l;if(ue.length===0)return;const Ce=[...new Set(ue.map(Ae=>Ae.profile_id))].filter(Ae=>!it.has(Ae));if(Ce.length!==0){tt(Ae=>{const Ve=new Map(Ae);for(const Xe of Ce)Ve.set(Xe,null);return Ve});for(const Ae of Ce)z.getTeamProfileConfig(Y,Ae).then(Ve=>{tt(Xe=>new Map(Xe).set(Ae,Ve))}).catch(()=>{})}},[t,l,y,Y,_e,it]);const J=async ue=>{if(W===ue.authorization_id){te(null);return}te(ue.authorization_id);const Ce=ue.authorization_id;if(!(Ce in Z)){he(ue.authorization_id);try{const Ae=await z.getGateContent(Ce);F(Ve=>({...Ve,[Ce]:Ae}))}catch{F(Ae=>({...Ae,[Ce]:null}))}finally{he(null)}}},ge=ue=>{navigator.clipboard.writeText(ue).then(()=>{ee(ue),setTimeout(()=>ee(null),2e3)})},Ue=async(ue,Ce)=>{var Ae;if(!Y){alert("No active group; cannot copy mandate.");return}pe(ue.authorization_id);try{const Ve=ue.authorization_id;let Xe=Z[Ve]??null;Ve in Z||(Xe=await z.getGateContent(Ve),F(kn=>({...kn,[Ve]:Xe})));const Ct=Object.fromEntries(Object.entries(ue.frame).filter(([kn])=>kn!=="profile"&&kn!=="path")),Pt=(Xe==null?void 0:Xe.context)??{},_r=((Ae=Xe==null?void 0:Xe.gateContent)==null?void 0:Ae.intent)??"",cr=ue.deferred_commitment_domains.length>0?"review":"automatic",Lr=ue.attested_domains[0]||$e||"owner",Un=Date.parse(ue.created_at),ur=ue.earliest_expiry?Date.parse(ue.earliest_expiry):NaN,io=Number.isFinite(Un)&&Number.isFinite(ur)&&ur>Un?Math.round((ur-Un)/1e3):void 0;let ga=ue.profile_id,ya=Ct,bn=Pt,gs;const va=await z.listProfiles(),zr=dp(ue.profile_id,va);if(zr&&zr.id!==ue.profile_id){const kn=await z.getProfile(zr.id);ga=zr.id,ya=mp(Ct,kn),bn=hp(Pt,kn),gs=ue.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:ga,groupId:Y,groupName:(be==null?void 0:be.name)??null,domain:Lr,isPersonal:!!(be!=null&&be.isPersonal),upgradedFromProfileId:gs})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:ya,context:bn,gateContent:{intent:_r},templateMode:cr,templateTtl:io})),Ce!=null&&Ce.asEdit?sessionStorage.setItem("agentEditReplaces",ue.authorization_id):sessionStorage.removeItem("agentEditReplaces"),Ge("/mandates/new/intent")}catch(Ve){alert(Ve instanceof Error?Ve.message:"Failed to copy mandate")}finally{pe(null)}},We=async(ue,Ce,Ae)=>{const Ve=Ce&&Ae?`Revoke ${Ce}'s ${Ae} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(Ve)){$(ue);try{await z.revokeAttestation(ue),q(Xe=>new Set(Xe).add(ue)),z.resyncGates().catch(()=>{}),Ce&&Y&&Ie()}catch(Xe){alert(Xe instanceof Error?Xe.message:"Failed to revoke mandate")}finally{$(null)}}},nt=y==="mine"?t:l,Wt=y==="mine"?a:f,Ot=y==="mine"?{revokedSet:X,archivedSet:ie}:{revokedSet:X},Ze=ue=>zi(ue,Ot),H={active:0,pending:0,expired:0,revoked:0,archived:0};for(const ue of nt)H[Ze(ue)]+=1;const xe=y==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],Te=(()=>{const ue=new Map;for(const Ce of nt){if(Ze(Ce)!==j)continue;const Ae=An(Ce.profile_id),Ve=ue.get(Ae);Ve?Ve.count+=1:ue.set(Ae,{shortId:Ae,icon:Ir(Ce.profile_id),name:G(Ce.profile_id),count:1})}return[...ue.values()].sort((Ce,Ae)=>Ce.name.localeCompare(Ae.name))})(),rt=Te.reduce((ue,Ce)=>ue+Ce.count,0),gt=Vj(nt.filter(ue=>{if(Ze(ue)!==j||b!==null&&An(ue.profile_id)!==b)return!1;if(N!==null){const Ce=ue.deferred_commitment_domains.length>0;if(N==="review"&&!Ce||N==="auto"&&Ce)return!1}return!0}),Ot,K),Ke=m.useMemo(()=>{const ue=new Map;for(const Ce of gt){const Ae=An(Ce.profile_id);let Ve=ue.get(Ae);Ve||(Ve={shortId:Ae,icon:Ir(Ce.profile_id),name:G(Ce.profile_id),items:[]},ue.set(Ae,Ve)),Ve.items.push(Ce)}return[...ue.values()].sort((Ce,Ae)=>Ae.items.length-Ce.items.length||Ce.name.localeCompare(Ae.name))},[gt,G]),Nt=m.useCallback(ue=>[...new Set(Qe.filter(Ce=>Ce.profile===ue).map(Ce=>Ce.name))],[Qe]),St={revokedSet:X,expandedHash:W,gateCache:Z,gateLoading:ne,copiedHash:we,revokingHash:I,copyingHash:ce,profileConfigCache:it,mode:_e,activeDomain:$e,group:be,groupId:Y,onExpand:J,onCopyHash:ge,onCopy:Ue,onRevoke:We,onExtend:ve,highlightHash:K},Xt={...St,archivedSet:ie,archivingHash:B,onArchive:me,needsReapprovalSet:ye};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:()=>D(!0),children:"+ New mandate"})]}),A&&n.jsx("div",{className:"modal-backdrop",onClick:()=>{D(!1),(T.get("new")||T.get("profile"))&&(T.delete("new"),T.delete("profile"),P(T,{replace:!0}))},children:n.jsxs("div",{className:"modal",onClick:ue=>ue.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:()=>{D(!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(_j,{onDismiss:()=>D(!1),preselectProfileId:O})]})]})}),ze&&n.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[n.jsx("button",{className:`nav-tab${y==="mine"?" active":""}`,onClick:()=>{x("mine"),k("active"),S(null),E(null),te(null)},children:"Mine"}),n.jsx("button",{className:`nav-tab${y==="team"?" active":""}`,onClick:()=>{x("team"),k("active"),S(null),E(null),te(null)},children:"Team"})]}),n.jsx("div",{className:"nav-tabs",children:xe.map(ue=>n.jsxs("button",{className:`nav-tab${j===ue?" active":""}`,onClick:()=>{k(ue),S(null),E(null)},children:[ue.charAt(0).toUpperCase()+ue.slice(1)," (",H[ue],")"]},ue))}),rt>0&&n.jsxs("div",{className:"mandate-filters",children:[n.jsx(qc,{areas:Te,selected:b,onSelect:S,totalCount:rt}),n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which mode",children:["auto","review"].map(ue=>{const Ce=N===ue;return n.jsx("button",{type:"button",role:"tab",className:"ftab","data-testid":`mode-filter-${ue}`,"aria-selected":Ce,onClick:()=>E(Ce?null:ue),children:ue==="auto"?"Automatic":"Review"},ue)})})]}),Wt&&nt.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):gt.length===0?n.jsx(cs,{icon:"☰",title:"No mandates",text:j==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${j} mandates found.`}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:Ke.map(ue=>n.jsxs("section",{"data-testid":"mandate-area","data-area":ue.shortId,children:[n.jsxs("div",{className:"area-group-h",children:[n.jsx(pa,{icon:ue.icon}),n.jsx("b",{children:ue.name}),n.jsxs("span",{className:"meta",children:[ue.items.length," mandate",ue.items.length===1?"":"s",Nt(ue.shortId).length>0&&n.jsxs(n.Fragment,{children:[" · via ",Nt(ue.shortId).join(", ")]})]})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:ue.items.map(Ce=>{const Ae=y==="team"?Ce:null,Ve=Ae!=null&&Ae.owner?Ae.owner.name??Ae.owner.email??Ae.owner.userId:void 0;return n.jsx(Gj,{item:Ce,newerProfile:Oe(Ce.profile_id),area:ue.name,ownerLabel:Ve,isAdmin:ze,...y==="mine"?Xt:St},Ce.authorization_id)})})]},ue.shortId))}),Q&&n.jsx(Wj,{item:Q,onClose:()=>ve(null),onSuccess:()=>{ve(null),jt()}})]})}const km=new Map;function qj(t){let s=km.get(t);return s||(s=z.getProposal(t).catch(()=>null),km.set(t,s)),s}function Yj({proposal:t,tool:s,manifests:a,label:o}){const l=so(t);return n.jsx(n.Fragment,{children:kw(s,l.toolArgs,a)??o})}function Jj({proposalId:t,tool:s,manifests:a,label:o}){const[l,u]=m.useState(null);return m.useEffect(()=>{let f=!0;return u(null),t&&qj(t).then(g=>{f&&u(g)}),()=>{f=!1}},[t]),l?n.jsx(Yj,{proposal:l,tool:s,manifests:a,label:o}):n.jsx(n.Fragment,{children:o})}function dn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Ut(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 Qj(t){return t==null?!1:typeof t=="string"||Array.isArray(t)?t.length>0:!0}function Er(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)??Jt(l),g=dn(u)?Er(u,(v=s==null?void 0:s[l])==null?void 0:v.properties,a):Ut(u,a);return`${f}: ${g}`}).join(" · ")}function Xj(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)??Jt(u)}}),l=t.map(u=>({cells:a.map(f=>{var y,x;const g=u[f],p=dn(g)?Er(g,(y=s==null?void 0:s[f])==null?void 0:y.properties,!1):Ut(g),v=dn(g)?Er(g,(x=s==null?void 0:s[f])==null?void 0:x.properties,!0):Ut(g,!0);return v===p?{value:p,sealed:!1}:{value:p,valueTitle:v,sealed:!1}})}));return{columns:o,rows:l}}function Zj(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 eS(t,s){var l;if(Array.isArray(t)){if(t.length===0)return{value:"—"};if(t.every(y=>!dn(y)&&!Array.isArray(y))){if(t.every(j=>typeof j=="string"))return{lines:t};const y=t.map(j=>Ut(j)).join(", "),x=t.map(j=>Ut(j,!0)).join(", ");return x===y?{value:y}:{value:y,valueTitle:x}}const u=(l=s==null?void 0:s.items)==null?void 0:l.properties,f=t.map(y=>dn(y)?Er(y,u,!1):Ut(y)),g=t.map(y=>dn(y)?Er(y,u,!0):Ut(y,!0)),p=f.map((y,x)=>y===g[x]?void 0:g[x]),v=t.every(dn)?Xj(t,u):void 0;return{lines:f,...p.some(y=>y!==void 0)?{lineTitles:p}:{},...v?{table:v}:{}}}if(dn(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=>!dn(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)??Jt(y),k=Ut(x),b=Ut(x,!0);return b===k?{key:y,label:j,value:k}:{key:y,label:j,value:k,valueTitle:b}})};const g=Er(t,u,!1),p=Er(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:Zj(t)};const a=Ut(t),o=Ut(t,!0);return o===a?{value:a}:{value:a,valueTitle:o}}function tS(t){let s;try{s=JSON.parse(t)}catch{return null}return dn(s)?s:null}function Rr(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?tS(t.text):null;return a?{obj:a}:null}function Vi(t){const s=Rr(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)??Jt(g),y={key:g,label:v,...eS(a[g],p)};p!=null&&p.description&&(y.description=p.description),f.push(y)}return f}function Gi(t,s){const a=Rr(t);if(a){const l=Vi(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=>Qj(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 Nm(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 Ai(t){return{kind:t.length>0?"structured":"empty",fields:t,moreFields:[],totalFields:t.length}}function nS(t,s,a){const o=Rr(t),l=Rr(s);if(!o&&!l){const j=(t==null?void 0:t.text)??"",k=(s==null?void 0:s.text)??"";return j===k?{approved:Ai([]),current:Ai([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:j},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:k},unchanged:!1}}const u=new Map(Vi(t).map(j=>[j.key,j])),f=new Map(Vi(s).map(j=>[j.key,j])),p=[...new Set([...u.keys(),...f.keys()])].filter(j=>j===(a==null?void 0:a.excludeKey)?!1:Nm(u.get(j))!==Nm(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:Ai(y),current:Ai(x),unchanged:p.length===0}}function rS(t){const s=t==null?void 0:t.structured;if(Array.isArray(s)&&s.every(dn))return s;if(t!=null&&t.text){let a;try{a=JSON.parse(t.text)}catch{return null}if(Array.isArray(a)&&a.every(dn))return a}return null}function ao(t){const s=Ut(t),a=Ut(t,!0);return a===s?{value:s}:{value:s,valueTitle:a}}function pp(t){return!t||t.status!=="ok"?[]:Vi(t.body)}function gp(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 yp(t,s,a){var p;const o=pp(t);if(o.length===0)return{rawId:Ut(s),context:[],unresolved:gp(t)};const l=t&&t.status==="ok"?(p=Rr(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=oa(a==null?void 0:a.displayHints,y,v.label);if(!da((b=a==null?void 0:a.displayHints)==null?void 0:b.money,y)&&!da((S=a==null?void 0:a.displayHints)==null?void 0:S.percent,y))return x===v.label?v:{...v,label:x};const{value:j,valueTitle:k}=Ki(l==null?void 0:l[v.key],a==null?void 0:a.displayHints,y,a==null?void 0:a.currency);return{...v,label:x,value:j,valueTitle:k}});return{name:u==null?void 0:u.value,rawId:Ut(s),context:g}}const sS=new Set(["id","name","title","label"]);function da(t,s){return!!(t!=null&&t.includes(s))}function oa(t,s,a){var o;return((o=t==null?void 0:t.labels)==null?void 0:o[s])??a}function aS(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}`:""}`}:ao(t)}function iS(t){return typeof t!="number"&&typeof t!="string"?ao(t):{value:`${t} %`}}function Ki(t,s,a,o){return da(s==null?void 0:s.money,a)?aS(t,o):da(s==null?void 0:s.percent,a)?iS(t):ao(t)}function vp(t,s){return da(t==null?void 0:t.hidden,s)}function oS(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 lS(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=>!vp(a,`${l}[].${S}`)),x=new Map;if(u)for(const S of v)for(const N of pp(S))x.has(N.key)||x.set(N.key,N.label);const j=u?[...x.keys()].filter(S=>!sS.has(S)):[],k=[];u&&k.push({key:`__attach:${u}`,label:oa(a,`${l}[].${u}`,Jt(t.sourceArg??u))});for(const S of y)k.push({key:`bound:${S}`,label:oa(a,`${l}[].${S}`,Jt(S))});for(const S of j)k.push({key:`attached:${S}`,label:oa(a,`${l}[].${u}.${S}`,x.get(S)??Jt(S))});const b=p.map((S,N)=>{var A;const E=v[N],T=[];if(u){const D=yp(E,t.sourceArg?S[t.sourceArg]:void 0),O=D.name?`${D.name} (${D.rawId})`:D.unresolved?`${D.rawId} — ${D.unresolved}`:D.rawId;T.push({value:O,sealed:!1})}for(const D of y){const{value:O,valueTitle:K}=Ki(S[D],a,`${l}[].${D}`,o);T.push({value:O,valueTitle:K,sealed:!0})}const P=E&&E.status==="ok"?(A=Rr(E.body))==null?void 0:A.obj:void 0;for(const D of j){const O=P==null?void 0:P[D],{value:K,valueTitle:L}=O!==void 0?Ki(O,a,`${l}[].${u}.${D}`,o):{value:"—",valueTitle:void 0};T.push({value:K,valueTitle:L,sealed:!1})}return{cells:T}});return{columns:k,rows:b,...t.overflow?{overflowNote:`${t.overflow.total-t.overflow.shown} more not shown`}:{}}}function cS(t){return`${Jt(t)} — from the system`}function uS(t){const s=cS(t.tool),a=t.result;if(!a||a.status!=="ok")return{heading:s,note:gp(a)};const o=rS(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:Jt(g)})),f=o.map(g=>({cells:l.map(p=>({...ao(g[p]),sealed:!1}))}));return{heading:s,table:{columns:u,rows:f}}}return{heading:s,body:Gi(a.body,{fields:t.fields})}}function dS(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=oS(a,t,x=>{var k,b;const j=(k=o.get(x))==null?void 0:k.result;return j&&j.status==="ok"?(b=Rr(j.body))==null?void 0:b.obj:void 0}),p=(a==null?void 0:a.order)??[],v=[...new Set([...p,...Object.keys(t)])],y=[];for(const x of v){if(!(x in t)||Lh.has(x)||vp(a,x))continue;const j=oa(a,x,Jt(x)),k=l.get(x);if(k){const E=Array.isArray(t[x])?t[x]:[];y.push({kind:"table",key:x,label:j,table:lS(k,E,a,g)});continue}const b=o.get(x);if(b){const E=yp(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:N}=Ki(t[x],a,x,g);y.push({kind:"scalar",key:x,label:j,value:S,valueTitle:N})}return{rows:y,sections:u.map(uS)}}function fS(t){return t.offDevice?"off-device":t.boundContent===void 0?"none":t.hasHashToCheck?t.hashVerified===!0?"verified":"mismatch":"unchecked"}function mS(t,s){return t===void 0?{kind:"empty",fields:[],moreFields:[],totalFields:0}:typeof t=="string"?Gi({text:t}):Gi({structured:t},{fields:s})}function hS(t,s){return t?Object.entries(t).filter(([,a])=>a!=null&&a!=="").map(([a,o])=>({key:a,label:zh(a,s).label,value:String(o)})):[]}function qi({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 Cm({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 pS({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(m.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(qi,{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 yc({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(Cm,{row:s}),n.jsx(qi,{table:s.table})]},s.key):n.jsxs(m.Fragment,{children:[n.jsx(Cm,{row:s}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:n.jsx(pS,{row:s})})]},s.key))})}function _i({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(yc,{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(yc,{rows:t.moreFields})]})]})}function xp({receipt:t,profile:s}){var j;const[a,o]=m.useState(void 0),[l,u]=m.useState(null),f=!!(t.contentHash&&t.contentBinding);if(m.useEffect(()=>{let k=!0;return o(void 0),u(null),(async()=>{let b;try{b=await z.getArchivedReceipt(t.id)}catch{k&&o(null);return}let S=null;const N=b==null?void 0:b.entry.boundContent;if(N!==void 0&&f)try{S=await Uh(t.contentBinding.kind,N)===t.contentHash}catch{S=!1}k&&(u(S),o(b))})(),()=>{k=!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=fS({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 k=hS(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"}),k.length>0?n.jsx("dl",{className:"ticket-done-fields",children:k.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=mS(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(_i,{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 Em=500;function vc(t){return t.length>Em?`${t.slice(0,Em)}…`:t}function Tm(t){return t.length?t[0].toUpperCase()+t.slice(1):t}function gS(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function wp(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 — ${vc(t.message)}`:"Preview not available."};case"not_found":return{heading:"Not found in your system",note:t.message?`Not found in your system — ${vc(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 ${gS(t.readAt)}.`,creation:dS(a??{},t.reads,t.display)};const o=Gi(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=nS(t.body,u.currentBody,{fields:t.fields,excludeKey:u.field});l.stale={heading:`A newer ${u.field} exists (${u.current})`,approvedLabel:`${Tm(u.field)} ${u.approved}`,currentLabel:`${Tm(u.field)} ${u.current}`,...f.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:f.approved,currentRendered:f.current}}}return l}}}function yS(t,s){if(t.state!=="failed")return null;const a=t.detail?vc(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 vS(t){return t!==null&&t!=="loading"&&t!=="ok"&&t!=="stale"}function xS({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 wS({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(m.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(xS,{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(qi,{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(qi,{table:s.table}),s.body&&n.jsx(yc,{rows:s.body.fields}),s.note&&n.jsx("p",{className:"preview-note",children:s.note})]},a))]})}function jp({resp:t,systemName:s,toolArgs:a,sealed:o}){const l=wp(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(wS,{view:l.creation}),l.rendered&&n.jsx(_i,{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(_i,{rendered:l.stale.approvedRendered})}),n.jsx("dt",{children:l.stale.currentLabel}),n.jsx("dd",{children:n.jsx(_i,{rendered:l.stale.currentRendered})})]})]})]})}function jS({proposalId:t,systemName:s,toolArgs:a,sealed:o,onTone:l,onData:u}){const[f,g]=m.useState(null),[p,v]=m.useState(!1);return m.useEffect(()=>{let y=!0;return g(null),v(!1),z.getProposalPreview(t).then(x=>{y&&g(x)}).catch(()=>{y&&v(!0)}),()=>{y=!1}},[t]),m.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=wp(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(jp,{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 nc=6;function Yi(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 SS(t){if(!t)return{first:""};const s=t.split(`
85
+ `);return s.length<=nc?{first:t}:{first:s.slice(0,nc).join(`
86
+ `),more:s.slice(nc).join(`
87
+ `)}}const bS="Linked by the AI",kS="linked automatically — this action already carried a reference to it";function NS(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}=SS(t.body),o=[t.connector,t.kind,t.author?`from ${t.author}`:void 0,Yi(t.at)].filter(l=>!!l);return{state:"ok",implicit:t.implicit,tag:bS,...t.implicit?{implicitNote:kS}:{},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:Yi(l.at)}))}}const ea="Read by the gateway — same customer, not matched to this request";function CS(t){const s=t.matchedKeyType==="email_domain"?"matched by email domain":"matched by email";return`Latest entries for ${t.matchedKeyValue} (${s})`}function ES(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?Yi(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:Yi(t.at),title:t.title,body:t.body,attribution:o,aiWritten:s}}function TS(t){if(t.status==="no_customer_link")return{state:"no_customer_link",label:ea,note:"No customer link — nothing to match history against.",matchNotes:[],items:[]};if(t.status==="no_match")return{state:"no_match",label:ea,note:"No match — no connector here matches on this customer's available identity key.",matchNotes:[],items:[]};if(t.status==="unreachable")return{state:"unreachable",label:ea,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})=>ES(l)),a=t.matches.map(CS),o=t.unreachableConnectorIds.length>0?`${t.unreachableConnectorIds.join(", ")} not reachable — showing what could be read.`:void 0;return s.length===0?{state:"empty",label:ea,note:"Nothing in the last few days.",matchNotes:a,items:[],unreachableNote:o}:{state:"ok",label:ea,note:"",matchNotes:a,items:s,unreachableNote:o}}function Sp({resp:t}){const s=NS(t.request),a=TS(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 IS({proposalId:t,onData:s}){const[a,o]=m.useState(null),[l,u]=m.useState(!1);return m.useEffect(()=>{let f=!0;return o(null),u(!1),z.getProposalRequestContext(t).then(g=>{f&&o(g)}).catch(()=>{f&&u(!0)}),()=>{f=!1}},[t]),m.useEffect(()=>{s==null||s(l?null:a)},[a,l,s]),l||!a?null:n.jsx(Sp,{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 RS(t){return t.offDevice?"off-device":t.recordedHash?t.localHash===t.recordedHash?"verified":"mismatch":"unchecked"}function PS(t){if(!(t<=0))return`${t} other approver${t===1?"":"s"} recorded their own.`}function $S(t){return new Date(t).toLocaleString([],{hour:"2-digit",minute:"2-digit"})}function bp({proposalId:t,tool:s,manifests:a}){const{user:o,domain:l}=xt(),[u,f]=m.useState(null),[g,p]=m.useState(null),[v,y]=m.useState(!1);if(m.useEffect(()=>{let P=!0;return f(null),p(null),y(!1),Promise.all([z.getShownSnapshot(t),z.getProposal(t)]).then(([A,D])=>{P&&(f(A),p(D))}).catch(()=>{P&&y(!0)}),()=>{P=!1}},[t]),v||!u||!g)return null;const x=u.status==="off_device",{entry:j,otherCount:k}=AS(g.shownHashes,(o==null?void 0:o.id)??"",l),b=RS({offDevice:x,recordedHash:j==null?void 0:j.hash,localHash:u.status==="ok"?u.shownHash:void 0}),S=PS(k);if(x)return n.jsxs("div",{className:"ticket-box ticket-shown-off-device","data-testid":"au10-shown","data-shown-status":"off-device",children:[n.jsx("h4",{children:"What you saw"}),n.jsx("p",{className:"ticket-done-note",children:"Only on the approving gateway — this device has no local copy."})]});const{snapshot:N}=u,{integrationId:E}=lr(s),T=ps(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 ",$S(N.readAt),")",b==="verified"&&n.jsx("span",{className:"src-tag src-tag-sealed",children:"verified"}),b==="mismatch"&&n.jsx("span",{className:"src-tag src-tag-danger",children:"does not match what was approved"})]}),n.jsx(jp,{resp:N.preview,systemName:T,toolArgs:N.toolArgs,sealed:N.sealed}),n.jsx(Sp,{resp:N.requestContext}),b==="verified"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-ok",children:"✓ Matches the fingerprint recorded with your approval."}),b==="mismatch"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-bad",children:"⚠ This copy differs from the fingerprint recorded with your approval."}),b==="unchecked"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-neutral",children:"This device's copy of what was shown, kept locally — the Authority Server does not record a fingerprint for you to check it against."}),S&&n.jsx("p",{className:"ticket-done-note ticket-done-note-neutral","data-testid":"au10-shown-others",children:S})]})}function ta({label: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 _S({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 te;const j=hs(t.profileId),k=sw(t,j),b=aw(a==null?void 0:a.context,j),S=ow(t,(a==null?void 0:a.bounds)??t.limits,j),N=a==null?void 0:a.intent,E=Pr(t.profileId).testSetup||to(t.action),[T,P]=m.useState(!1),[A,D]=m.useState(x),O=Date.now(),K=$r(),L=Ar(t.profileId,K),W=l==="valid"||l==="valid-legacy";return n.jsxs("div",{className:`ticket-obj ticket-obj-card${y?" is-new":""}${A?" 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":A,onClick:()=>D(Z=>!Z),children:[n.jsx(os,{profileId:t.profileId,area:L,system:ha(t.action,s),time:Bi(t.timestamp,O),leading:y?n.jsx("span",{className:"seen-dot is-new","aria-label":"new since your last visit"}):void 0}),n.jsxs("div",{className:"receipt-head",children:[n.jsx("span",{className:"receipt-what","data-testid":"ticket-headline",children:n.jsx(Jj,{proposalId:t.proposalId,tool:t.action,manifests:s,label:ro(t,s)})}),n.jsx("span",{className:"receipt-tag",children:Mi(t)?"approved":"automatic"}),t.contentHash&&n.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(te=t.contentBinding)!=null&&te.fields?`Sealed in the ticket: ${t.contentBinding.fields.join(", ")} — exactly this content was sent`:"Sealed in the ticket — exactly this content was sent",children:"content sealed"}),E&&n.jsx("span",{className:"sim-mark",children:"Test setup"})]}),n.jsx(ca,{title:u,area:L}),k&&n.jsx("div",{className:"receipt-scope",children:k})]}),A&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"receipt-when",children:p(t.timestamp)}),n.jsx(xp,{receipt:t,profile:j}),t.proposalId&&n.jsx(bp,{proposalId:t.proposalId,tool:t.action,manifests:s}),n.jsxs("dl",{className:"receipt-rows",children:[n.jsxs(ta,{label:"mandate",children:[n.jsx("strong",{children:u||cw(t.profileId)})," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),f&&n.jsx(ta,{label:"owner",children:f}),b&&n.jsxs(ta,{label:"allowed",children:[b," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),S&&n.jsxs(ta,{label:"used",children:[n.jsx("span",{className:"receipt-num",children:S})," ",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),n.jsx(ta,{label:"intent",children:N?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:`intent-text${T?"":" intent-clamped"}`,children:N}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>P(!T),children:T?"Show less":"Show full intent"})," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}):n.jsx("span",{className:"receipt-absent",children:o?"local store unreachable — sign in to the gateway to read it":"not on this device — the Authority Server stores only its hash"})})]}),n.jsxs("div",{className:"receipt-foot",children:[l==="valid"&&n.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued — no Authority Server involved.",children:"✓ Verified on this device"}),l==="valid-legacy"&&n.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued. This ticket was issued before protocol 0.7 and is checked with that version's format.",children:"✓ Verified on this device · issued before protocol 0.7"}),l==="invalid"&&n.jsx("span",{className:"receipt-tamper",title:"The stored ticket does not match what was signed.",children:"⚠ Signature check FAILED"}),n.jsx("button",{type:"button",className:"receipt-evidence-link",onClick:v,children:"Complete ticket"}),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(([Z,F])=>`${Z}=${F}`).join(" · ")]}),(a==null?void 0:a.boundsHash)&&n.jsxs("div",{children:["bounds hash · ",a.boundsHash]}),(a==null?void 0:a.contextHash)&&n.jsxs("div",{children:["scope hash · ",a.contextHash]}),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:Dh(t.id)}),n.jsx("span",{className:"ticket-obj-time",children:Bi(t.timestamp,O)}),W&&n.jsx("span",{className:"ticket-obj-sig",title:"Signature checked on this device",children:"✓ verified"})]})]})}function LS({receipt:t,onClose:s}){const[a,o]=m.useState(null),[l,u]=m.useState(null),[f,g]=m.useState(null),[p,v]=m.useState(!0),[y,x]=m.useState(!1);m.useEffect(()=>{let N=!1;return v(!0),z.getArchivedReceipt(t.id).then(E=>{N||(o(E),u(E?"local":"authority-server"),g((E==null?void 0:E.signature)??null))}).catch(()=>{N||u("authority-server")}).finally(()=>{N||v(!1)}),()=>{N=!0}},[t.id]);const j=a?a.entry:{receipt:t},k=JSON.stringify(j,null,2);function b(){const N=URL.createObjectURL(new Blob([k],{type:"application/json"})),E=document.createElement("a");E.href=N,E.download=`suveren-ticket-${t.id.slice(0,8)}.json`,E.click(),URL.revokeObjectURL(N)}async function S(){try{await navigator.clipboard.writeText(k),x(!0),setTimeout(()=>x(!1),2e3)}catch{x(!1)}}return n.jsx("div",{className:"modal-backdrop",onClick:N=>N.target===N.currentTarget&&s(),children:n.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:"Complete ticket"}),n.jsx("button",{className:"modal-close",onClick:s,"aria-label":"Close",children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[f==="valid"&&n.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued."}),f==="valid-legacy"&&n.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued. Issued before protocol 0.7 — checked with that version's format."}),f==="invalid"&&n.jsx("p",{className:"receipt-tamper",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"⚠ Signature check FAILED — the stored ticket does not match what was signed."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children: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:k})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:b,children:"Download"}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:S,children:y?"Copied":"Copy"})]})]})})}function zS(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 MS(t,s,a){const o=s.trim().toLowerCase();return o?[...a,t.id,t.action,t.profileId,JSON.stringify(t.executionContext??{})].some(u=>typeof u=="string"&&u.toLowerCase().includes(o)):!0}function Im(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 OS(){const{activeTeam:t,groupId:s}=xt(),a=(t==null?void 0:t.isAdmin)===!0,[o,l]=m.useState("mine"),[u,f]=ms(),g=dw(u.get("filter")),p=H=>{const xe=new URLSearchParams(u);H==="all"?xe.delete("filter"):xe.set("filter",H),f(xe,{replace:!0})},v=$h(u.get("area")),y=H=>{const xe=new URLSearchParams(u);H===null?xe.delete("area"):xe.set("area",H),f(xe,{replace:!0})},x=$r(),[j,k]=m.useState(null),b=m.useRef(!1),[S,N]=m.useState([]),[E,T]=m.useState([]),[P,A]=m.useState(""),[D,O]=m.useState(!0),[K,L]=m.useState({}),[W,te]=m.useState(new Set),[Z,F]=m.useState(""),[ne,he]=m.useState(new Set),[Q,ve]=m.useState("all"),[we,ee]=m.useState(!1),[X,q]=m.useState(!1),[I,$]=m.useState(null),[ie,fe]=m.useState({}),[B,re]=m.useState(!1),[ce,pe]=m.useState({}),[ye,oe]=m.useState({}),[Ge,be]=m.useState(null),[Y,$e]=m.useState(null),[_e,Be]=m.useState(!1),[ze,it]=m.useState(!1),tt=m.useRef(""),Qe=m.useCallback(H=>o==="team"&&a&&s?z.listTeamReceiptsPage(s,{before:H,limit:200}):z.getMyReceiptsPage({before:H,limit:200}),[o,a,s]),Ye=m.useCallback(()=>{const H=o==="team"?`team:${s}`:"mine",xe=tt.current!==H;tt.current=H,O(!0),it(!1),Qe().then(Te=>{N(rt=>xe?Te.receipts:Im(rt,Te.receipts)),$e(rt=>xe?Te.nextBefore:rt??Te.nextBefore)}).catch(()=>{xe&&N([]),it(!0)}).finally(()=>O(!1))},[Qe,o,s]),jt=m.useCallback(()=>{!Y||_e||(Be(!0),it(!1),Qe(Y).then(H=>{N(xe=>Im(xe,H.receipts)),$e(H.nextBefore)}).catch(()=>it(!0)).finally(()=>Be(!1)))},[Y,_e,Qe]);Ft(Ye,12e4);const pt=m.useCallback(()=>{Ye(),j!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||z.markTicketsSeen(Date.now()).catch(()=>{}))},[Ye,j]);Fe("ticket-recorded",pt),m.useEffect(()=>{D||b.current||(b.current=!0,z.getLastSeenTicketsAt().then(H=>(k(H),z.markTicketsSeen(Date.now()))).catch(()=>k(Number.POSITIVE_INFINITY)))},[D]),m.useEffect(()=>{z.getLabelManifests().then(T).catch(()=>{}),fetch("/health").then(H=>H.json()).then(H=>{typeof H.spUrl=="string"&&A(H.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),m.useEffect(()=>{z.getLocalAuthorizations().then(({authorizations:H,signatures:xe})=>{fe(H),pe(xe),re(!1)}).catch(()=>{fe({}),pe({}),re(!0)}),z.getMyAttestations().then(H=>{const xe={};for(const Te of H)Te.authorization_id&&Te.title&&(xe[Te.authorization_id]=Te.title);oe(xe)}).catch(()=>{})},[]),m.useEffect(()=>{o!=="team"||Object.keys(K).length>0||z.listUsers().then(H=>{const xe={};for(const Te of H)xe[Te.id]={name:Te.name,email:Te.email};L(xe)}).catch(()=>{})},[o,K]);const Me=m.useMemo(()=>{const H=new Set;for(const xe of S)H.add(xe.action);return[...H].sort()},[S]),me=m.useMemo(()=>{if(o!=="team")return[];const H=new Set;for(const xe of S)xe.userId&&H.add(xe.userId);return[...H].map(xe=>{var Te;return{id:xe,label:(Te=K[xe])!=null&&Te.name?`${K[xe].name} (${K[xe].email})`:xe}}).sort((xe,Te)=>xe.label.localeCompare(Te.label))},[o,S,K]),Ie=m.useMemo(()=>S.filter(H=>!(!MS(H,Z,[Bn(H.profileId,x),ro(H,E),ps(lr(H.action).integrationId,E),H.authorizationId?ye[H.authorizationId]:null])||ne.size>0&&!ne.has(H.action)||W.size>0&&H.userId&&!W.has(H.userId)||!FS(H,Q))),[S,Z,x,E,ye,ne,W,Q]),Oe=m.useMemo(()=>{const H={automatic:0,approved:0,all:0};for(const xe of Ie)H.all+=1,H[mc(xe,"approved")?"approved":"automatic"]+=1;return H},[Ie]),G=m.useMemo(()=>Ie.filter(H=>mc(H,g)),[Ie,g]),J=m.useMemo(()=>{const H=new Map;for(const xe of G){const Te=An(xe.profileId),rt=H.get(Te);rt?rt.count+=1:H.set(Te,{shortId:Te,icon:Ir(xe.profileId),name:Bn(xe.profileId,x),count:1})}return[...H.values()].sort((xe,Te)=>xe.name.localeCompare(Te.name))},[G,x]),ge=m.useMemo(()=>G.filter(H=>_h(H.profileId,v)),[G,v]),Ue=m.useMemo(()=>j===null?0:ge.filter(H=>Oi(H,j)).length,[ge,j]),We=ne.size>0||W.size>0||Q!=="all";function nt(H){he(xe=>{const Te=new Set(xe);return Te.has(H)?Te.delete(H):Te.add(H),Te})}function Wt(H){te(xe=>{const Te=new Set(xe);return Te.has(H)?Te.delete(H):Te.add(H),Te})}function Ot(){he(new Set),te(new Set),ve("all"),F("")}async function Ze(){q(!0),$(null);try{const{bundle:H,filename:xe}=await z.fetchEvidenceBundle(),Te=URL.createObjectURL(new Blob([JSON.stringify(H,null,2)],{type:"application/json"})),rt=document.createElement("a");rt.href=Te,rt.download=xe,rt.click(),URL.revokeObjectURL(Te);const gt=H.sources??{};gt.authorityServer?gt.local||$(`Downloaded Authority Server history only — ${gt.localError??"local archive unavailable."}`):$(`Downloaded local evidence only — ${gt.asError??"Authority Server export unavailable."}`)}catch(H){$(`Export failed: ${H instanceof Error?H.message:String(H)}`)}finally{q(!1)}}return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Tickets"}),n.jsxs("p",{className:"page-subtitle",children:["Execution history for agent actions.",Ue>0&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("b",{"data-testid":"tickets-new-count",children:[Ue," new since your last visit"]})]})]})]}),n.jsx("button",{className:"btn btn-secondary",onClick:Ze,disabled:X,children:X?"Preparing…":"Download evidence"})]}),I&&n.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:I}),a&&n.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(H=>n.jsx("button",{onClick:()=>l(H),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:o===H?"2px solid var(--accent)":"2px solid transparent",color:o===H?"var(--text-primary)":"var(--text-tertiary)",fontWeight:o===H?600:500},children:H==="mine"?"Mine":"Team"},H))}),n.jsxs("div",{className:"tickets-toolbar",children:[n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which tickets",children:uw.map(H=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`tickets-filter-${H}`,"aria-selected":g===H,onClick:()=>p(H),children:[H==="automatic"?"Automatic":H==="approved"?"Approved":"All",n.jsx("span",{className:"n",children:Oe[H]})]},H))}),n.jsxs("div",{className:"search-filter-bar",children:[n.jsxs("div",{className:"search-input-wrap",children:[n.jsx("span",{className:"search-icon",children:"⌕"}),n.jsx("input",{type:"text",className:"form-input search-input","data-testid":"tickets-search",placeholder:"Search tickets","aria-label":"Search tickets",value:Z,onChange:H=>F(H.target.value)}),Z&&n.jsx("button",{className:"search-clear",onClick:()=>F(""),children:"×"})]}),n.jsxs("button",{className:`btn btn-sm btn-secondary${we?" active":""}`,onClick:()=>ee(!we),children:["Filters",We?` (${ne.size+(Q!=="all"?1:0)})`:""]})]})]}),g==="automatic"&&n.jsx("p",{className:"page-subtitle",style:{marginTop:"-0.25rem"},children:'Automatic — no person approved these. Approved tickets are under "Approved".'}),n.jsx(qc,{areas:J,selected:v,onSelect:y,totalCount:G.length}),we&&n.jsxs("div",{className:"filter-panel",children:[Me.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Action"}),n.jsx("div",{className:"filter-chips",children:Me.map(H=>n.jsx("button",{className:`filter-chip${ne.has(H)?" selected":""}`,onClick:()=>nt(H),children:H},H))})]}),o==="team"&&me.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Owner"}),n.jsx("div",{className:"filter-chips",children:me.map(H=>n.jsx("button",{className:`filter-chip${W.has(H.id)?" selected":""}`,onClick:()=>Wt(H.id),children:H.label},H.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(([H,xe])=>n.jsx("button",{className:`filter-chip${Q===H?" selected":""}`,onClick:()=>ve(H),children:xe},H))})]})]}),We&&n.jsxs("div",{className:"active-filters",children:[[...ne].map(H=>n.jsxs("span",{className:"active-chip",onClick:()=>nt(H),children:[H," ",n.jsx("span",{className:"chip-remove",children:"×"})]},H)),[...W].map(H=>{const xe=K[H],Te=xe?xe.name:H;return n.jsxs("span",{className:"active-chip",onClick:()=>Wt(H),children:[Te," ",n.jsx("span",{className:"chip-remove",children:"×"})]},H)}),Q!=="all"&&n.jsxs("span",{className:"active-chip",onClick:()=>ve("all"),children:[Q==="1d"?"Today":Q==="7d"?"7 days":"30 days"," ",n.jsx("span",{className:"chip-remove",children:"×"})]}),n.jsx("button",{className:"clear-filters",onClick:Ot,children:"Clear all"})]}),ze&&n.jsx("div",{className:"card note-stopped",style:{marginBottom:"0.75rem"},children:n.jsx("span",{className:"msg-error",style:{fontSize:"0.85rem"},children:"Couldn’t load tickets — your session may have expired. Try signing out and back in."})}),D&&S.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ge.length===0?n.jsx(cs,{icon:"⌕",title:S.length===0?"No tickets in the last 30 days":"No matching tickets",text:S.length===0?"Tickets appear here after an agent uses an authorized tool. Older tickets can be loaded below.":"Try adjusting your search or filters."}):n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:ge.length===S.length?`${S.length} ticket${S.length!==1?"s":""}`:`${ge.length} of ${S.length} tickets`}),n.jsx("div",{className:"timeline",children:ge.map(H=>{const xe=H.userId?K[H.userId]:void 0;return n.jsx("div",{className:"timeline-event",children:n.jsx(_S,{receipt:H,manifests:E,localAuth:H.authorizationId?ie[H.authorizationId]:void 0,localUnavailable:B,signature:ce[H.id],grantTitle:H.authorizationId?ye[H.authorizationId]:null,ownerLabel:o==="team"&&H.userId?xe?`${xe.name} (${xe.email})`:H.userId:null,spUrl:P,formatDate:zS,onOpenComplete:()=>be(H),isNew:j!==null&&Oi(H,j),defaultOpen:ge.length===1})},H.id)})})]}),Ge&&n.jsx(LS,{receipt:Ge,onClose:()=>be(null)}),Y&&n.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:jt,disabled:_e,children:_e?"Loading…":"Load older"})})]})}function BS(){const[t,s]=m.useState(null),[a,o]=m.useState({}),[l,u]=m.useState(!1),f=$r(),[g,p]=ms(),v=$h(g.get("area")),y=m.useCallback(O=>{const K=new URLSearchParams(g);O===null?K.delete("area"):K.set("area",O),p(K,{replace:!0})},[g,p]),[x,j]=m.useState({}),k=m.useCallback(()=>{z.getMyAttestations().then(O=>{const K={};for(const L of O)L.title&&(K[L.authorization_id]=L.title);j(K)}).catch(()=>{})},[]);m.useEffect(()=>{k()},[k]),Ft(k,3e5);const[b,S]=m.useState(null),N=m.useRef(!1),E=m.useCallback(()=>{z.getDenials({limit:200}).then(({records:O})=>{s(O),u(!1)}).catch(()=>u(!0))},[]);m.useEffect(()=>{E()},[E]),Ft(E,6e4),m.useEffect(()=>{if(!t)return;const O=[...new Set(t.map(K=>K.profile).filter(K=>!!K))].filter(K=>!(K in a));O.length!==0&&Promise.all(O.map(K=>z.getProfile(K).catch(()=>null))).then(K=>{o(L=>{const W={...L};return O.forEach((te,Z)=>{K[Z]&&(W[te]=K[Z])}),W})})},[t,a]),m.useEffect(()=>{!t||N.current||(N.current=!0,z.getLastSeenBlockedAt().then(O=>(S(O),z.markBlockedSeen(Date.now()))).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[t]);const T=m.useCallback(()=>{E(),k(),b!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||z.markBlockedSeen(Date.now()).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[E,k,b]);Fe("denial-recorded",T);const P=m.useMemo(()=>{const O=new Map;for(const K of t??[]){const L=K.profile??K.integrationId,W=An(L),te=O.get(W);te?te.count+=1:O.set(W,{shortId:W,icon:Ir(L),name:Bn(L,f),count:1})}return[...O.values()].sort((K,L)=>K.name.localeCompare(L.name))},[t,f]);if(l)return n.jsx(cs,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(t===null)return null;const A=e0(t,Date.now()),D=t.filter(O=>_h(O.profile??O.integrationId,v));return n.jsxs("div",{className:"blocked-page",children:[n.jsxs("div",{className:"page-header blocked-header",children:[n.jsx("h1",{className:"page-title",children:"Blocked actions"}),n.jsxs("span",{className:"blocked-today",children:[A," today · nothing ran"]})]}),t.length===0?n.jsx(cs,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):n.jsxs(n.Fragment,{children:[n.jsx(qc,{areas:P,selected:v,onSelect:y,totalCount:t.length}),n.jsx("div",{className:"blocked-list",children:D.map((O,K)=>{const L=Zx(O,O.profile?a[O.profile]:void 0,x),W=b!==null&&O.ts>b,te=O.profile??O.integrationId;return n.jsx("div",{className:"card blocked-item blocked-card","data-seen":W?"false":"true",children:n.jsxs("div",{className:"id-body",children:[n.jsx(os,{profileId:te,area:Bn(te,f),system:O.integrationId?ps(O.integrationId,void 0):void 0,time:r0(O.ts,Date.now()),trailing:W?n.jsx("span",{className:"new-pill",children:"New"}):void 0}),n.jsxs("div",{className:"blocked-row-head",children:[n.jsx("span",{className:`blocked-dot blocked-dot-${eo(O)}`,"aria-hidden":"true"}),n.jsx("span",{className:"blocked-title",children:L.title})]}),n.jsx(ca,{title:xh(O,x),area:Bn(te,f)}),n.jsx("div",{className:"blocked-sentence",children:L.sentence}),n.jsx("div",{className:"blocked-source",children:L.sourceLine.map((Z,F)=>Z.dim?n.jsx("span",{className:"mandate-id",children:Z.text},F):n.jsx("span",{children:Z.text},F))}),n.jsxs("details",{children:[n.jsx("summary",{children:"What you can do"}),n.jsx("div",{className:"blocked-advice",children:L.whatYouCanDo})]})]})},`${O.ts}-${K}`)})})]})]})}const DS={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function US(){const[t,s]=m.useState(null),[a,o]=m.useState(!1),[l,u]=m.useState(null),f=m.useCallback(async()=>{try{s(await z.getAutostart())}catch(v){u(v instanceof Error?v.message:"Could not read autostart state")}},[]);m.useEffect(()=>{f()},[f]);const g=m.useCallback(async()=>{if(!(!(t!=null&&t.supported)||a)){o(!0),u(null);try{await z.setAutostart(!t.installed)}catch(v){u(v instanceof Error?v.message:"Failed")}finally{try{s(await z.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=DS[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 WS(){const[t,s]=m.useState(null),[a,o]=m.useState(!1),[l,u]=m.useState(null),f=m.useCallback(async()=>{try{const p=await z.getGatewaySettings();s(p.desktopNotifications),u(null)}catch(p){u(p instanceof Error?p.message:"Could not read notification setting")}},[]);m.useEffect(()=>{f()},[f]);const g=m.useCallback(async()=>{if(!(t===null||a)){o(!0),u(null);try{const p=await z.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 Am={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function HS(){const[t,s]=m.useState(null),[a,o]=m.useState(!1),[l,u]=m.useState(null),f=m.useCallback(async()=>{try{s(await z.getIdentityDisclosure()),u(null)}catch(y){u(y instanceof Error?y.message:"Could not read the setting")}},[]);m.useEffect(()=>{f()},[f]);const g=m.useCallback(async()=>{if(!(!t||a)){o(!0),u(null);try{s(await z.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"?`${Am.as_vouched} ${t.verifier}`:Am[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 VS={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 GS(){const{version:t,latestVersion:s,updateAvailable:a,installMethod:o}=$c();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:[VS[o]??"Update checking is unavailable",o==="dev"&&n.jsx(n.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function xc({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 Rm(t){return t===!0}function KS(){const[t,s]=m.useState(null),[a,o]=m.useState(null);m.useEffect(()=>{let f=!1;return z.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=Rm(t==null?void 0:t.asUrlLockedByPolicy),u=Rm(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(xc,{})]}),!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(xc,{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 qS(){const{simulation:t,locked:s}=Rh();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(xc,{})]}),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 YS={ollama:{provider:"ollama",endpoint:"http://localhost:11434",models:["gemma4:e4b","gemma4:e2b","gemma4:26b","gemma4:31b","llama3.2","llama3.1","mistral","qwen2.5"]},openrouter:{provider:"openai-compatible",endpoint:"https://openrouter.ai/api/v1",models:["google/gemma-4-31b-it","qwen/qwen3.6-plus:free","stepfun/step-3.5-flash:free","google/gemini-2.5-flash","openai/gpt-4o-mini","anthropic/claude-haiku-4"]},openai:{provider:"openai-compatible",endpoint:"https://api.openai.com/v1",models:["gpt-4o-mini","gpt-4o","o3-mini"]},groq:{provider:"openai-compatible",endpoint:"https://api.groq.com/openai/v1",models:["llama-3.1-8b-instant","llama-3.3-70b-versatile","gemma2-9b-it"]},together:{provider:"openai-compatible",endpoint:"https://api.together.xyz/v1",models:["meta-llama/Llama-3-8b-chat-hf","meta-llama/Llama-3-70b-chat-hf"]}},na=["AI Assistant","Authority Server","This computer","Security","Version"],ra={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function JS(){const[t,s]=m.useState(""),[a,o]=m.useState("openrouter"),[l,u]=m.useState("openai-compatible"),[f,g]=m.useState("https://openrouter.ai/api/v1"),[p,v]=m.useState("google/gemma-4-31b-it"),[y,x]=m.useState(""),[j,k]=m.useState(!1),[b,S]=m.useState(!1),[N,E]=m.useState(!1),[T,P]=m.useState(null),[A,D]=m.useState([]),[O,K]=m.useState(!1),[L,W]=m.useState(null),[te,Z]=m.useState(""),F=m.useCallback(X=>{s(X),setTimeout(()=>s(""),3e3)},[]),ne=m.useCallback(async(X,q,I)=>{K(!0),W(null);try{const $=await z.aiModels({provider:X,endpoint:q,...I?{apiKey:I}:{}});$.ok&&$.models.length>0?(D($.models),W(`${$.models.length} models available`)):(D([]),W($.message||"No models returned — using defaults"))}catch($){D([]),W($ instanceof Error?$.message:"Failed to load models")}finally{K(!1)}},[]),he=m.useCallback(async()=>{try{const X=await z.getCredential("ai-config");if(k(X.configured),X.configured&&X.fields){const q=X.fields.provider||"openai-compatible",I=X.fields.endpoint||"";X.fields.provider&&u(q),X.fields.endpoint&&g(I),X.fields.model&&v(X.fields.model),I.includes("openai.com")?o("openai"):I.includes("groq.com")?o("groq"):I.includes("together.xyz")?o("together"):I.includes("openrouter.ai")?o("openrouter"):o("ollama"),I&&ne(q,I)}}catch{}},[ne]);m.useEffect(()=>{he()},[he]);const Q=X=>{o(X),D([]),W(null),Z("");const q=YS[X];q&&(u(q.provider),g(q.endpoint),v(""),ne(q.provider,q.endpoint,y||void 0))},ve=()=>ne(l,f,y||void 0),we=async()=>{S(!0);try{await z.setCredential("ai-config",{provider:l,endpoint:f,model:p,...y?{apiKey:y}:{}}),k(!0),F("AI configuration saved!")}catch{F("Failed to save AI config")}finally{S(!1)}},ee=async()=>{E(!0),P(null);try{const X=await z.aiTest({provider:l,endpoint:f,model:p,...y?{apiKey:y}:{}});P(X.ok?`OK: ${X.message}`:`Failed: ${X.message}`)}catch(X){P(`Error: ${X instanceof Error?X.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:ra,children:na[0]}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Advisory AI to help you think through intent when giving mandates."}),n.jsxs("div",{className:"card",children:[n.jsx("h3",{className:"card-title",children:"Configuration"}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Connect a trusted AI model that has access to your intent — problem, objective, and tradeoffs — to help you think through mandates. Keys are encrypted in your vault."}),j&&n.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[n.jsx("span",{className:"status-banner-icon",children:"✓"}),n.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{className:"form-label",children:"Provider Preset"}),n.jsxs("select",{className:"form-input",value:a,onChange:X=>Q(X.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:X=>x(X.target.value),onBlur:()=>{y.trim()&&ne(l,f,y.trim())},placeholder:j?"••••••••••••••••":"sk-... (not needed for Ollama)"}),n.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:"Each provider uses its own key — paste it and the model list loads automatically."})]}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsx("label",{className:"form-label",children:"Model"}),n.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.75rem",padding:"0.125rem 0.5rem"},onClick:ve,disabled:O,title:"Re-fetch the model list from the provider",children:O?"Loading…":"↻ Refresh"})]}),A.length===0?n.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:O?"Loading models…":l==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const X=A,q=X.includes(p),I=X.length>12,$=te.trim().toLowerCase();let ie=$?X.filter(fe=>fe.toLowerCase().includes($)):X;return q&&!ie.includes(p)&&(ie=[p,...ie]),n.jsxs(n.Fragment,{children:[I&&n.jsx("input",{className:"form-input",value:te,onChange:fe=>Z(fe.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),n.jsxs("select",{className:"form-input",value:q?p:"__unset__",onChange:fe=>v(fe.target.value==="__unset__"?"":fe.target.value),children:[n.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),ie.map(fe=>n.jsx("option",{value:fe,children:fe},fe)),$&&ie.length===0&&n.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",te,"”"]})]})]})})(),L&&n.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:L})]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[n.jsx("button",{className:"btn btn-primary",onClick:we,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:ee,disabled:N,children:N?"Testing...":"Test Connection"})]}),T&&n.jsx("div",{className:`alert ${T.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:T})]}),n.jsx(QS,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:ra,children:na[1]}),n.jsx(KS,{}),n.jsx(HS,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:ra,children:na[2]}),n.jsx(US,{}),n.jsx(WS,{}),n.jsx(qS,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:ra,children:na[3]}),n.jsx("div",{className:"card",style:{padding:"1.5rem"},children:n.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),n.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[n.jsx("li",{children:"Every tool call verified against your mandate bounds"}),n.jsx("li",{children:"Credentials never exposed to agents through MCP"}),n.jsx("li",{children:"Every action produces a signed ticket"})]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),n.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[n.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),n.jsx("li",{children:"For best security, run agents in sandboxed environments"}),n.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})})]}),n.jsxs("section",{children:[n.jsx("h2",{style:ra,children:na[4]}),n.jsx(GS,{})]})]})}function QS(){const[t,s]=m.useState(null),[a,o]=m.useState({intent:"",context:""}),[l,u]=m.useState(null),[f,g]=m.useState(null),[p,v]=m.useState(null),[y,x]=m.useState(!1),j=m.useCallback(async()=>{if(!y)try{const S=await z.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]),k=async S=>{if(t){u(S),g(null);try{const N=a[S],E=N.trim()===t[S].default.trim()?"":N;await z.setAIPrompt(S,E);const T=await z.getAIPrompts();s(T),o({intent:T.intent.current,context:T.context.current}),v(S),setTimeout(()=>v(null),2e3)}catch(N){g(N instanceof Error?N.message:"Save failed")}finally{u(null)}}},b=async S=>{if(confirm(`Revert ${S} prompt to the built-in default?`)){u(S),g(null);try{await z.setAIPrompt(S,"");const N=await z.getAIPrompts();s(N),o({intent:N.intent.current,context:N.context.current})}catch(N){g(N instanceof Error?N.message:"Revert failed")}finally{u(null)}}};return n.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:S=>{S.currentTarget.open&&j()},children:[n.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",margin:"0.75rem 0 1rem 0",lineHeight:1.55},children:"These are the system prompts the AI assistant sees when helping you write Intent (per-mandate) or Context (your standing-orders brief). Edit with care — changes apply on the next chat turn."}),f&&n.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:f}),!y&&!f&&n.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),t&&n.jsxs(n.Fragment,{children:[n.jsx(Pm,{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(N=>({...N,intent:S})),onSave:()=>k("intent"),onRevert:()=>b("intent"),saving:l==="intent",justSaved:p==="intent"}),n.jsx(Pm,{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(N=>({...N,context:S})),onSave:()=>k("context"),onRevert:()=>b("context"),saving:l==="context",justSaved:p==="context"})]})]})}function Pm({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 XS(t){return t.proposalId?"review":"automatic"}function $m(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=XS(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 ZS=["https://","http://"];function kp(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)?[]:ZS.some(l=>o.toLowerCase().startsWith(l))?[{label:a.label,href:o,description:a.description}]:[]}):[]}function Np(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 eb=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function tb(t,s){return typeof s!="string"?!1:/^data:image\//i.test(s)?!0:eb.test(t)?/^https?:\/\//.test(s):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(s)}function Nr(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 _m({row:t,which:s}){const a=hs(t.profileRef),o=rw(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(m.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 nb({row:t}){const s=hs(t.profileRef),a=(s==null?void 0:s.id)??t.profileRef??"";return n.jsxs(n.Fragment,{children:[(s==null?void 0:s.name)??Mt(a),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:a})]})}function rb({row:t,altText:s}){switch(t.kind){case"profile":return n.jsx(nb,{row:t});case"profile-limits":return n.jsx(_m,{row:t,which:"limits"});case"profile-scope":return n.jsx(_m,{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:Nr(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:Nr(a)},o))}):n.jsx(n.Fragment,{children:Nr(t.value)});case"money":return n.jsxs(n.Fragment,{children:[Nr(t.value),t.currency?` ${t.currency}`:""]});case"object":return n.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Nr(t.value)});default:return tb(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:Nr(t.value)})}}function wc({args:t,display:s,heading:a="Details",requestRefArg:o}){const l=nw(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(m.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:f.hint,children:f.key===o?"Replying to":f.label}),n.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:f.key===o?n.jsx("span",{"data-testid":"request-ref",title:Nr(f.value),children:"the message shown under Request"}):n.jsx(rb,{row:f,altText:u})})]},f.key))})]})}function Yc({profileId:t,declared:s}){const{icon:a}=Pr(t,s),o=Z0(t);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"id-rail",children:[n.jsx(up,{icon:a,className:"id-rail-icon"}),n.jsx("span",{className:"id-rail-name",children:o})]}),n.jsx("div",{className:"id-sep"})]})}function sb({proposalId:t,systemName:s}){const[a,o]=m.useState(null);if(m.useEffect(()=>{let u=!0;return o(null),z.getProposalOutcome(t).then(f=>{u&&o(f)}).catch(()=>{}),()=>{u=!1}},[t]),!a)return null;const l=yS(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 rc=null;function ab(){return rc||(rc=z.getEnrichedAuthorizations().then(t=>new Map(t.map(s=>[s.authorizationId,s.bounds]))).catch(()=>new Map)),rc}function ib(t){const[s,a]=m.useState(void 0);return m.useEffect(()=>{let o=!0;if(t)return ab().then(l=>{o&&a(l.get(t))}),()=>{o=!1}},[t]),s}function ob(t,s){const[a,o]=m.useState(null),[l,u]=m.useState(!1),[f,g]=m.useState(null);return m.useEffect(()=>{let p=!0;return o(null),g(null),u(!0),(async()=>{var v;try{try{const j=await z.getGateContent(t);if((v=j==null?void 0:j.gateContent)!=null&&v.intent){p&&o(j.gateContent.intent);return}}catch{}const y=await z.getAttestationIntent(t);if(!y){p&&g("Intent not available or you are not an authorized approver.");return}const x=await z.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 Lm(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 lb(t){const s=Lm(t.limits),a=Lm(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 Cp(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=>Cp(s)).join(", ");try{return JSON.stringify(t,null,2)}catch{return String(t)}}const cb="setup__create_mandate";function Ep({proposal:t,currentUserId:s,proposalLinks:a,toolDisplay:o,manifests:l,onContentState:u,onShownSnapshot:f,nameOf:g}){var pe,ye,oe,Ge,be;const[p,v]=m.useState(!1),[y,x]=m.useState(!1),[j,k]=m.useState(null),b=Sn(),{group:S,groupId:N,domain:E}=xt(),T=Object.entries(t.executionContext),P=hs(t.profileId),A=ib(t.authorizationId),D=lw(t.executionContext,A,P),O=ew(t.tool),{integrationId:K}=lr(t.tool),L=ps(K,l),{intent:W,loading:te,error:Z}=ob(t.authorizationId,s),F=so(t),ne=F.toolArgs!==null;m.useEffect(()=>{u==null||u({loading:F.loading,readable:ne})},[F.loading,ne]);const he=xw(t),Q=F.toolArgs?kp(a,F.toolArgs):[],ve=async()=>{if(!N){k("No active workspace; cannot open the mandate screen.");return}x(!0),k(null);try{if(!F.toolArgs){k("This content is not readable on this device yet.");return}const Y=F.toolArgs,$e=typeof Y.profile=="string"?Y.profile:"",_e=await z.listProfiles(),Be=dp($e,_e);if(!Be){k(`Unknown profile "${$e}".`);return}const ze=await z.getProfile(Be.id),it=lb(Y),tt=mp(it.bounds,ze),Qe=hp(it.context,ze);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Be.id,groupId:N,groupName:(S==null?void 0:S.name)??null,domain:E,isPersonal:!!(S!=null&&S.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...it,bounds:tt,context:Qe})),sessionStorage.setItem("agentReplacesProposal",t.id),b("/mandates/new/intent")}catch(Y){k(Y instanceof Error?Y.message:"Could not open the mandate screen.")}finally{x(!1)}},[we,ee]=m.useState(null),X=vS(we),[q,I]=m.useState(null),[$,ie]=m.useState(null);m.useEffect(()=>{if(!q||!$){f==null||f(null);return}const Y=q.status==="ok"?q.readAt:Date.now();f==null||f({readAt:Y,preview:q,requestContext:$,...F.toolArgs?{toolArgs:F.toolArgs}:{},sealed:F.sealed})},[q,$,F.toolArgs,F.sealed,f]);const{toolName:fe}=lr(t.tool),B=(be=(Ge=(oe=(ye=(pe=l==null?void 0:l.find(Y=>Y.id===K))==null?void 0:pe.toolGating)==null?void 0:ye.overrides)==null?void 0:oe[fe])==null?void 0:Ge.sourceFromArg)==null?void 0:be.arg,re=F.toolArgs?n.jsx(wc,{args:F.toolArgs,display:o,heading:"",requestRefArg:B}):null,ce=F.toolArgs?n.jsxs(n.Fragment,{children:[n.jsx(wc,{args:F.toolArgs,display:o,heading:"",requestRefArg:B}),T.length>0&&n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:T.map(([Y,$e],_e)=>{const{label:Be,hint:ze}=zh(Y,P);return n.jsxs("span",{children:[_e>0&&" · ",n.jsxs("span",{title:ze,children:[Be,"=",Cp($e)]})]},Y)})})]}):null;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"approval-summary","data-testid":"approval-summary",children:Yh(t.tool,F.toolArgs,l)}),n.jsx("div",{className:"approval-headline",children:O}),F.sealed&&F.undecryptable&&n.jsxs("div",{className:"preview-box","data-testid":"proposal-undecryptable",style:{marginBottom:"0.5rem"},children:[n.jsx("strong",{children:"Encrypted for another device."}),n.jsx("p",{style:{margin:"0.35rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"This device was added after the proposal was made, and no device of yours has shared it yet. It is shared automatically once a device that can read it comes online — or open it there."})]}),F.sealed&&F.loading&&n.jsx("div",{className:"preview-box","data-testid":"proposal-decrypting",style:{marginBottom:"0.5rem"},children:"Decrypting…"}),X&&ne&&n.jsxs("div",{className:"preview-box preview-box-ok","data-testid":"bound-values-open",style:{marginBottom:"0.5rem"},children:[n.jsxs("h4",{children:["What will be sent",F.sealed?n.jsx(n.Fragment,{children:n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})}):n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),re]}),he.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: ",he.map(Y=>(g==null?void 0:g(Y))??Y).join(", ")," — shared automatically once they sign in on a device."]}),ne&&n.jsx(jS,{proposalId:t.id,systemName:L,toolArgs:F.toolArgs,sealed:F.sealed,onTone:ee,onData:I}),ne&&n.jsx(IS,{proposalId:t.id,onData:ie}),ne&&n.jsxs("details",{className:"creation-legend-fold",children:[n.jsx("summary",{"aria-label":"What the marks mean",children:"?"}),n.jsxs("p",{className:"creation-legend","data-testid":"au10-legend",children:[n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot creation-legend-dot-sealed"}),"sealed — approved and executed exactly so"]}),n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot creation-legend-dot-system"}),"from the system — read by the gateway, not by the AI"]}),n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot au10-dot-ai"}),"the AI's own claim or text — not checked"]}),F.sealed&&n.jsx("span",{children:"Decrypted on this device — suveren.ai stores only an unreadable copy and its fingerprint."})]})]}),D.length>0&&n.jsxs("div",{className:"limit-checks",children:[n.jsx("h4",{children:"Within your limits"}),n.jsx("ul",{className:"limit-check-list",children:D.map(Y=>n.jsxs("li",{className:Y.ok?"ok":"bad",children:[n.jsx("span",{className:"limit-check-icon",children:Y.ok?"✓":"✗"}),n.jsxs("span",{children:[Y.label," ",Y.valueText," — your limit ",Y.limitText]})]},Y.key))})]}),n.jsxs("div",{className:"mandate-intent",children:[n.jsxs("dl",{children:[n.jsx("dt",{children:"Mandate"}),n.jsx("dd",{children:n.jsx("strong",{children:(P==null?void 0:P.name)??Mt(t.profileId)})})]}),n.jsxs("dl",{children:[n.jsx("dt",{children:"Intent"}),n.jsx("dd",{children:Z?n.jsx("p",{className:"msg-error",style:{fontSize:"0.8rem",margin:0},children:Z}):W!==null?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:`intent-text${p?"":" intent-clamped"}`,children:W}),n.jsx("button",{className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>v(!p),children:p?"Show less":"Show full intent"})]}):te?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"Loading intent…"}):n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this mandate."})})]})]}),ne&&Q.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:Q.map(Y=>n.jsxs("a",{href:Y.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:Y.description??Y.href,children:[Y.label," ↗"]},Y.label))}),!X&&ne&&n.jsxs("details",{className:"proposal-args-fold",style:{marginBottom:"0.75rem"},children:[n.jsx("summary",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",cursor:"pointer"},children:"Details (exactly what is bound)"}),n.jsx("div",{style:{marginTop:"0.5rem"},children:ce})]}),ne&&t.tool===cb&&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:ve,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 Tp({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:hj.map(f=>n.jsx("button",{type:"button",className:`filter-chip${op(t,f)?" selected":""}`,onClick:()=>s(gj(t,f)),disabled:l,children:f},f))}),n.jsx("textarea",{"data-testid":"change-note",className:"form-input",value:t,maxLength:Hi,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," / ",Hi]}),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 ub={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired",refused:"Refused"},db={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired",refused:"status-revoked"},zm={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced",REFUSED:"status-revoked"};function sc(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 fb(t){return t.split("__").pop()??t}function mb(t){const s=t.toLowerCase();return s.includes("delete")||s.includes("refund")||s.includes("cancel")||s.includes("revoke")}function Ip(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=>Ip(s)).join(", ");try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Fm({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,k=fb(j),b=mb(j),{integrationId:S}=lr(j),N=ps(S,g),[E,T]=m.useState(!1),[P,A]=m.useState(""),[D,O]=m.useState(""),K=m.useRef(null),L=async()=>{const B=K.current;if(!(!B||!y))try{const{shownHash:re}=await z.saveShownSnapshot(t.proposal.id,B);return re}catch{return}},W=async()=>{const B=Kc(P);if(!B.valid){O(B.error);return}O("");const re=await L();o==null||o(t.id,B.trimmed,re)},te=y&&x==="rejected"?wj(t.proposal,p??""):null,Z=y&&x==="refused"?jj(t.proposal):null,F=ww(y?t.proposal.rejectedBy??t.proposal.approverRejectedBy??null:null),ne=hs(t.profileId),he=so(y?t.proposal:{toolArgs:void 0,content:void 0}),Q=y?he.toolArgs:null,ve=y?t.proposal.executionContext:t.receipt.executionContext,we=y?null:t.receipt.cumulativeState,[ee,X]=m.useState(!0),[q,I]=m.useState(!1),$=y&&he.toolArgs?kp(u,he.toolArgs):[],ie=Object.entries(ve??{}),fe=Pr(t.profileId).testSetup||to(j);return n.jsxs("div",{className:v?"card card-in-row":"card id-card",children:[!v&&n.jsx(Yc,{profileId:t.profileId}),n.jsxs("div",{className:"id-body",children:[v?fe?n.jsx("div",{style:{marginBottom:"0.5rem"},children:n.jsx("span",{className:"sim-mark",children:"Test setup"})}):null:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[n.jsx("code",{style:{fontSize:"0.85rem"},children:k}),fe&&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 B=Np(t.proposal.expiresAt,Date.now());return n.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",fontWeight:B.urgent?600:400,whiteSpace:"nowrap"},children:B.label})})(),n.jsx("span",{"data-testid":te||Z?"outcome-kind":void 0,className:`status-badge ${te?zm[te.kind]:Z?zm.REFUSED:db[x]}`,children:te?te.kind:Z?Z.kind:ub[x]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:sc(t.sortTimestamp)})]})]}),y&&t.proposal.status==="executed"&&n.jsx(sb,{proposalId:t.proposal.id,systemName:N}),te&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By ",te.who,", ",sc(te.at)]}),(F??te.note)&&n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[te.kind==="CHANGE NEEDED"?"Change: ":"Note: ",F??te.note]})]}),Z&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By the Authority Server, ",sc(Z.at)]}),n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:["Reason: ",Z.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(Q==null?void 0:Q._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:Q._imagePreview,alt:typeof(Q==null?void 0:Q.altText)=="string"?Q.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),y&&x==="pending"?n.jsx(Ep,{proposal:t.proposal,currentUserId:p??"",proposalLinks:u,toolDisplay:f,manifests:g,onContentState:({loading:B,readable:re})=>{I(B),X(re)},onShownSnapshot:B=>{K.current=B}}):n.jsxs(n.Fragment,{children:[$.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:$.map(B=>n.jsxs("a",{href:B.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:B.description??B.href,children:[B.label," ↗"]},B.label))}),y?n.jsxs(n.Fragment,{children:[Q&&n.jsx(wc,{args:Q,display:f}),ie.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:ie.map(([B,re])=>`${B}=${Ip(re)}`).join(" · ")})]}):n.jsxs(n.Fragment,{children:[n.jsx(xp,{receipt:t.receipt,profile:ne}),t.receipt.proposalId&&n.jsx(bp,{proposalId:t.receipt.proposalId,tool:t.receipt.action,manifests:g})]})]}),we&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",we.daily.count," action",we.daily.count===1?"":"s",we.daily.amount>0?`, ${we.daily.amount}`:""," · ","this month: ",we.monthly.count,we.monthly.amount>0?`, ${we.monthly.amount}`:""]}),y&&x==="pending"&&Hh({loading:q,readable:ee})&&(E?n.jsx(Tp,{note:P,onNoteChange:A,onSend:W,onCancel:()=>{T(!1),A(""),O("")},sending:!!l,error:D}):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 L()),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 L()),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 hb(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 pb(t,s){return t.map(a=>s.get(a)??a)}function Ap(t){var k;const{groupId:s}=xt(),a=hs(t.profileId),[o,l]=m.useState(null),[u,f]=m.useState(new Map),[g,p]=m.useState(!0);m.useEffect(()=>{let b=!0;if(!s){p(!1);return}return p(!0),Promise.all([z.getTeamProfileConfig(s,t.profileId).catch(()=>null),z.getGroupById(s).catch(()=>null),z.listUsers().catch(()=>[])]).then(([S,N,E])=>{b&&(l(S),f(hb(E,(N==null?void 0:N.members)??[])))}).finally(()=>{b&&p(!1)}),()=>{b=!1}},[s,t.profileId]);const v=vx(o??{}),y=pb(t.pendingApprovers??[],u),x=b=>u.get(b)??b,j=o&&((k=a==null?void 0:a.boundsSchema)!=null&&k.fields)?Fw(t.executionContext,o,a.boundsSchema.fields):null;return{loading:g,profileConfig:o,requiredApprovals:v,approverNames:y,nameOf:x,aboveCapReason:j}}function Rp(t,s){return!!t.createdBy&&!!s&&t.createdBy===s}function Pp(t){return(t.pendingApprovers??[]).filter(s=>s!==t.createdBy)}function gb(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 yb({proposal:t,currentUserId:s,onAction:a,onMessage:o,proposalLinks:l,toolDisplay:u,manifests:f,inRow:g=!1}){const[p,v]=m.useState(!1),[y,x]=m.useState(!1),[j,k]=m.useState(!1),[b,S]=m.useState(""),[N,E]=m.useState(""),[T,P]=m.useState(!1),[A,D]=m.useState(!1),[O,K]=m.useState(!0),L=m.useRef(null),W=async()=>{const $=L.current;if($)try{const{shownHash:ie}=await z.saveShownSnapshot(t.id,$);return ie}catch{return}},te=Pr(t.profileId).testSetup||to(t.tool),Z=Pp(t),F=t.approvedBy??{},ne=Object.keys(F).length,he=s in F,Q=Ap(t),ve=Rp(t,s),we=$=>{const ie=$ instanceof Error?$.message:"Approval failed";return ie.includes("APPROVER_IS_PROPOSER")?"You can't approve your own action. Ask another approver.":ie.includes("APPROVAL_IMPOSSIBLE")?"This action cannot be approved — there is no one else eligible to approve it. Ask a team admin to add another approver.":ie},ee=async()=>{if(Bc()){o(Dc);return}v(!0),o("");try{const $=await ia(t),ie=await W(),fe=await z.approveProposal(t.id,$,ie);try{const pe=await z.getAttestationIntent(t.authorizationId);if(pe){const ye=await z.decryptIntent({intentCiphertext:pe.intentCiphertext,encryptedKey:pe.encryptedKey,approverId:s});await z.storeApprovedIntent(t.authorizationId,ye)}}catch{}const{requiredApprovals:B,approvedCount:re}=fe,ce=B!==void 0&&re!==void 0?B-re:void 0;o(ce===void 0?"Approved.":ce>0?`Approved. ${ce} more approval${ce===1?"":"s"} still needed.`:"Approved — the required number of approvals is met; the action is ready to execute."),a()}catch($){o(we($))}finally{v(!1)}},X=async()=>{x(!0),o("");try{const $=await ia(t),ie=await W();await z.rejectProposal(t.id,lp(),$,ie),o("Action rejected."),a()}catch($){o($ instanceof Error?$.message:"Rejection failed")}finally{x(!1)}},q=async()=>{const $=Kc(b);if(!$.valid){E($.error);return}E(""),P(!0),o("");try{const{noteEncrypted:ie}=await z.encryptProposalNote($.trimmed,Vh(t,s)),fe=await ia(t),B=await W();await z.rejectProposal(t.id,{outcome:"change_needed",noteEncrypted:ie},fe,B),o("Sent back for a change."),a()}catch(ie){o(ie instanceof Error?ie.message:"Failed to send back")}finally{P(!1)}},I=p||y||T;return n.jsxs("div",{className:g?"card card-in-row":"card id-card",children:[!g&&n.jsx(Yc,{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:[te&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),n.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const $=Np(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:gb(t.createdAt)})]})]}),n.jsxs("div",{className:"approver-progress",style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Needs ",Q.requiredApprovals," approval",Q.requiredApprovals===1?"":"s"," from:"," ",Z.map(($,ie)=>n.jsxs("span",{className:`who${$ in F?" done":""}`,style:{marginLeft:ie===0?"0.25rem":"0.5rem",fontWeight:$ in F?600:void 0},children:[$ in F?"✓ ":"",Q.nameOf($),$===s?" (you)":"",ie<Z.length-1?",":""]},$)),Q.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",ne," of ",Q.requiredApprovals,")"]})]}),Q.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:[Q.aboveCapReason.fieldLabel,Q.aboveCapReason.value!==void 0?` ${Q.aboveCapReason.value}`:""," (limit ",String(Q.aboveCapReason.cap),")."," ",t.createdBy?`Requested by ${Q.nameOf(t.createdBy)}.`:""]})]}),n.jsx(Ep,{proposal:t,currentUserId:s,proposalLinks:l,toolDisplay:u,manifests:f,nameOf:Q.nameOf,onContentState:({loading:$,readable:ie})=>{D($),K(ie)},onShownSnapshot:$=>{L.current=$}}),!he&&Hh({loading:A,readable:O})&&(j?n.jsx(Tp,{note:b,onNoteChange:S,onSend:q,onCancel:()=>{k(!1),S(""),E("")},sending:T,error:N}):n.jsxs(n.Fragment,{children:[!ve&&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:[ve?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:ee,disabled:I,children:p?"Approving...":"Approve"}),n.jsxs("button",{"data-testid":"btn-change-needed",className:"btn btn-outline-strong",onClick:()=>k(!0),disabled:I,children:[n.jsx("span",{"aria-hidden":"true",children:"↩"})," Change needed"]}),n.jsxs("button",{"data-testid":"btn-reject",className:"btn btn-outline-strong",onClick:X,disabled:I,children:[n.jsx("span",{"aria-hidden":"true",children:"✕"})," ",y?"Rejecting...":"Reject"]})]})]})),he&&n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:["You approved this action.",Q.requiredApprovals>1&&ne<Q.requiredApprovals?` Waiting on ${Q.requiredApprovals-ne} more approval(s).`:""]}),!g&&n.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",t.id]})]})]})}function Mm({proposal:t,manifests:s,titles:a,open:o,onToggle:l,who:u,children:f}){const g=Date.now(),p=Bh(t.expiresAt,g),v=$r(),y=m.useRef(null);return m.useEffect(()=>{var x;o&&((x=y.current)==null||x.scrollIntoView({block:"nearest"}))},[o]),n.jsxs("div",{ref:y,className:`appr-item${o?" is-open":""}`,"data-testid":"approval-row","data-proposal-id":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(os,{profileId:t.profileId,area:Ar(t.profileId,v),system:ha(t.tool,s),time:Oh(t.createdAt,g)}),n.jsx("div",{className:"appr-item-sum","data-testid":"approval-row-summary",children:n.jsx(Jh,{proposal:t,manifests:s})}),n.jsx(ca,{title:t.authorizationId?a[t.authorizationId]:void 0,area:Ar(t.profileId,v)}),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 vb(){const{domain:t,user:s}=xt(),a=(s==null?void 0:s.id)??"",[o,l]=m.useState("awaiting-me"),[u,f]=m.useState([]),[g,p]=m.useState([]),[v,y]=m.useState({}),[x,j]=m.useState(!0),[k,b]=m.useState(""),S=m.useCallback(async()=>{try{const G=await z.getProposalsForApprover();f(G)}catch{}finally{j(!1)}},[]);Fe("proposal-added",S),Fe("proposal-approved",S),Fe("proposal-rejected",S),Fe("proposal-resolved",S),Ft(S,3e4);const[N,E]=m.useState([]),T=m.useCallback(async()=>{try{const G=await z.getMyProposals(t);E(G)}catch{}},[t]);Fe("proposal-added",T),Fe("proposal-approved",T),Fe("proposal-rejected",T),Fe("proposal-resolved",T),Fe("execution-failed",T),Ft(T,3e4,t);const P=m.useMemo(()=>N.filter(G=>{var J;return G.status==="pending"&&(((J=G.pendingApprovers)==null?void 0:J.length)??0)===0}),[N]),A=m.useMemo(()=>$m(P,[],{status:"pending"}),[P]),[D,O]=m.useState([]),K=m.useCallback(async()=>{if(a)try{const J=(await z.getMyProposals(t)).filter(ge=>ge.status==="pending"&&ge.pendingApprovers&&ge.pendingApprovers.includes(a)&&ge.approvedBy&&a in ge.approvedBy);O(J)}catch{}},[a,t]);Fe("proposal-approved",K),Fe("proposal-rejected",K),Ft(K,3e4,`${a}:${t}`);const[L,W]=m.useState([]),te=m.useCallback(async()=>{try{const G=await z.getProposalsCreatedByMe();if(G!==null){W(G);return}W(await z.getMyPendingProposals())}catch{}},[]);Fe("proposal-added",te),Fe("proposal-approved",te),Fe("proposal-rejected",te),Ft(te,3e4),m.useEffect(()=>{z.getLabelManifests().then(p).catch(()=>{}),z.getToolDisplay().then(y).catch(()=>{})},[]);const Z=G=>{var J;return(J=g.find(ge=>ge.id===G.split("__")[0]))==null?void 0:J.proposalLinks};m.useEffect(()=>{S(),T(),K(),te()},[]);const[F,ne]=m.useState([]),[he,Q]=m.useState([]),[ve,we]=m.useState(!0),[ee,X]=m.useState(null),[q,I]=m.useState(""),[$,ie]=m.useState("pending"),[fe,B]=m.useState(null),[re,ce]=m.useState(!1),pe=m.useCallback(async()=>{try{const{proposals:G,receipts:J}=await z.getThread({domain:t,status:$,sinceDays:7});ne(G),Q(J)}catch{}finally{we(!1)}},[t,$]);Ft(pe,3e4,`${t}:${$}`);const ye=async(G,J,ge,Ue)=>{if(J==="commit"&&Bc()){I(Dc);return}X(G),I("");try{const We=F.find(H=>H.id===G)??N.find(H=>H.id===G),nt=yx(We,t),Wt=We?await ia(We):void 0;let Ot=ge??{};if((ge==null?void 0:ge.outcome)==="change_needed"&&ge.note){const H=We?Vh(We,a):[a],{noteEncrypted:xe}=await z.encryptProposalNote(ge.note,H);Ot={outcome:"change_needed",noteEncrypted:xe}}const Ze=await z.resolveProposal(G,J,nt,{...Ot,contentHash:Wt,shownHash:Ue});I(J==="commit"?`Action approved. Status: ${Ze.status}`:(ge==null?void 0:ge.outcome)==="change_needed"?"Sent back for a change.":"Action rejected."),await Promise.all([pe(),T()])}catch(We){I(We instanceof Error?We.message:"Failed")}finally{X(null)}},oe=(G,J)=>ye(G,"commit",void 0,J),Ge=(G,J)=>ye(G,"reject",lp(),J),be=(G,J,ge)=>ye(G,"reject",yj(J),ge),Y=m.useMemo(()=>{const G=new Set;for(const J of F)G.add(J.profileId);for(const J of he)G.add(J.profileId);return Array.from(G).sort()},[F,he]),$e=m.useMemo(()=>$m(F,he,{status:$,profile:fe??void 0,includeAutonomous:re}),[F,he,$,fe,re]),_e=m.useCallback(()=>{S(),K()},[S,K]),Be=m.useMemo(()=>{const G=new Set,J=[];for(const ge of[...D,...L])G.has(ge.id)||(G.add(ge.id),J.push(ge));return J.sort((ge,Ue)=>Ue.createdAt-ge.createdAt)},[D,L]),ze=u.length+A.length,[it]=ms(),[tt,Qe]=m.useState(()=>it.get("open")),Ye=m.useMemo(()=>[...A.map(G=>G.kind==="proposal"?G.proposal.id:G.id),...u.map(G=>G.id)],[A,u]),jt=m.useRef([]),pt=m.useRef(null);m.useEffect(()=>{const G=jt.current;if(jt.current=Ye,Ye.length===1&&tt===null&&pt.current!==Ye[0]){pt.current=Ye[0],Qe(Ye[0]);return}if(tt&&!Ye.includes(tt)&&G.includes(tt)){const J=G.indexOf(tt),ge=G.slice(J+1).find(Ue=>Ye.includes(Ue))??Ye[0]??null;Qe(ge)}},[Ye,tt]);const Me=G=>Qe(J=>J===G?null:G),[me,Ie]=m.useState({});m.useEffect(()=>{z.getMyAttestations().then(G=>{const J={};for(const ge of G)ge.authorization_id&&ge.title&&(J[ge.authorization_id]=ge.title);Ie(J)}).catch(()=>{})},[]);const Oe=Be.length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Approvals"}),n.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."}),n.jsx(Ih,{what:"approve"})]}),n.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[n.jsxs("button",{className:`nav-tab${o==="awaiting-me"?" active":""}`,onClick:()=>l("awaiting-me"),children:["Awaiting me ",ze>0&&n.jsx("span",{className:"pill-count",style:{marginLeft:"0.4rem"},children:ze})]}),n.jsxs("button",{className:`nav-tab${o==="awaiting-others"?" active":""}`,onClick:()=>l("awaiting-others"),children:["Awaiting others ",Oe>0&&n.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--border)",color:"var(--text-secondary)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:Oe})]}),n.jsx("button",{className:`nav-tab${o==="all"?" active":""}`,onClick:()=>{l("all"),pe()},children:"All"})]}),o==="awaiting-me"&&n.jsx(n.Fragment,{children:x&&ze===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ze===0?n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[n.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):n.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[(k||q)&&n.jsx("div",{className:"alert alert-success",children:k||q}),A.map(G=>{const J=n.jsx(Fm,{proposalLinks:G.kind==="proposal"?Z(G.proposal.tool):void 0,toolDisplay:G.kind==="proposal"?v[G.proposal.tool]:void 0,manifests:g,currentUserId:a,item:G,onApprove:oe,onReject:Ge,onChangeNeeded:be,resolving:ee===G.id,inRow:G.kind==="proposal"},G.id);if(G.kind!=="proposal")return J;const ge=G.proposal.id;return n.jsx(Mm,{proposal:G.proposal,manifests:g,titles:me,open:tt===ge,onToggle:()=>Me(ge),children:J},ge)}),u.map(G=>n.jsx(Mm,{proposal:G,manifests:g,titles:me,open:tt===G.id,onToggle:()=>Me(G.id),who:"Team approval — other people are involved",children:n.jsx(yb,{inRow:!0,proposal:G,currentUserId:a,onAction:_e,onMessage:b,proposalLinks:Z(G.tool),toolDisplay:v[G.tool],manifests:g},G.id)},G.id))]})}),o==="awaiting-others"&&n.jsx(n.Fragment,{children:Be.length===0?n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[n.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:Be.map(G=>n.jsx(wb,{proposal:G,currentUserId:a,onCancel:async()=>{try{await z.rejectProposal(G.id,{reason:"cancelled by creator"}),K(),T()}catch(J){alert(J instanceof Error?J.message:"Cancel failed")}},onWithdraw:async()=>{const J=await ia(G);await z.withdrawProposal(G.id,void 0,J),te(),K()}},G.id))})}),o==="all"&&n.jsxs(n.Fragment,{children:[q&&n.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:q}),n.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[n.jsx("button",{className:`filter-chip ${$==="pending"?"selected":""}`,onClick:()=>ie("pending"),children:"Pending"}),n.jsx("button",{className:`filter-chip ${$==="all"?"selected":""}`,onClick:()=>ie("all"),children:"All"}),Y.length>0&&n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),Y.map(G=>n.jsx("button",{className:`filter-chip ${fe===G?"selected":""}`,onClick:()=>B(fe===G?null:G),children:Mt(G)},G)),$==="all"&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),n.jsxs("button",{className:`filter-chip ${re?"selected":""}`,onClick:()=>ce(!re),title:"Include actions executed without human review (automatic commitment mode)",children:[re?"✓ ":"","Autonomous actions"]})]})]}),ve&&$e.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):$e.length===0?n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[n.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:$==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:$==="pending"?"Your agents are operating within their mandates. Switch to All to see recent activity.":"When an agent calls a gated tool, activity will appear here."})]}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:$e.map(G=>n.jsx(Fm,{proposalLinks:G.kind==="proposal"?Z(G.proposal.tool):void 0,toolDisplay:G.kind==="proposal"?v[G.proposal.tool]:void 0,manifests:g,currentUserId:a,item:G,onApprove:oe,onReject:Ge,onChangeNeeded:be,resolving:ee===G.id},G.id))})]})]})}function xb(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 wb({proposal:t,currentUserId:s,onCancel:a,onWithdraw:o}){const[l,u]=m.useState(!1),[f,g]=m.useState(!1),[p,v]=m.useState(""),y=Ap(t),x=Rp(t,s),j=Pp(t),k=t.approvedBy??{},b=Object.keys(k).length,S=j.length>0,N=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=Pr(t.profileId).testSetup||to(t.tool);return n.jsxs("div",{className:"card id-card",children:[n.jsx(Yc,{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:xb(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,A)=>n.jsxs("span",{className:`who${P in k?" done":""}`,style:{marginLeft:A===0?"0.25rem":"0.5rem",fontWeight:P in k?600:void 0},children:[P in k?"✓ ":"",y.nameOf(P),P===s?" (you)":"",A<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:N,disabled:l,children:l?"Cancelling...":"Cancel"})})]})]})}const jb=`# 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 Sb(){const[t,s]=m.useState(""),[a,o]=m.useState(""),[l,u]=m.useState(!0),[f,g]=m.useState(!1),[p,v]=m.useState(null),[y,x]=m.useState(!1),j=t!==a,k=new Blob([t]).size,b=16*1024;m.useEffect(()=>{if(!j)return;const T=A=>{A.preventDefault(),A.returnValue=""},P=A=>{var K,L;if(A.defaultPrevented||A.button!==0||A.metaKey||A.ctrlKey||A.shiftKey||A.altKey)return;const D=(L=(K=A.target)==null?void 0:K.closest)==null?void 0:L.call(K,"a");if(!D||!D.href)return;let O;try{O=new URL(D.href)}catch{return}O.origin===window.location.origin&&O.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(A.preventDefault(),A.stopPropagation()))};return window.addEventListener("beforeunload",T),document.addEventListener("click",P,!0),()=>{window.removeEventListener("beforeunload",T),document.removeEventListener("click",P,!0)}},[j]),m.useEffect(()=>{let T=!1;return z.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 z.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)}},N=()=>{s(a),v(null)},E=()=>{t.trim()&&!confirm("Replace current context with the starter template?")||s(jb)};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(Ui,{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:k>b?"msg-error":void 0,style:{fontSize:"0.75rem",color:k>b?void 0:"var(--text-muted)"},children:[k.toLocaleString()," / ",b.toLocaleString()," bytes"]})]}),n.jsx("textarea",{className:"form-textarea",value: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:N,disabled:f||!j,children:"Revert"}),n.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:S,disabled:f||!j||k>b||l,children:f?"Saving…":"Save"})]})]}),n.jsx("button",{type:"button",className:"floating-help",onClick:()=>x(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),n.jsx(ep,{open:y,onClose:()=>x(!1),ariaLabel:"Brief assistant",children:n.jsx(Ui,{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 bb(t){const s=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(t);return s&&s[1].replace(/<[^>]+>/g,"").trim()||"Report"}function kb(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 Nb(t){return new Date(t*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Cb(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 Eb(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 Tb(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 Om(t,s="none in this report"){return t>0?{kind:"ok",text:`${t} ✓`}:{kind:"neutral",text:s}}function Ib(t){return/Labels?$/.test(t)||t==="limits"||t==="fields"}function Ab(t,s){const a=s[t];return a==null||a===""||Ib(t)?null:typeof a=="object"?JSON.stringify(a):String(a)}function Rb(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 Pb(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 $b="allow-popups allow-popups-to-escape-sandbox",_b="AI analysis — not verified",Lb="Green = verified by the gateway — raw signed fields only",zb="Grey dashed = the AI's own analysis, not verified",Fb="= translation by the AI, not verified",Mb="Übersetzung anzeigen / show translation";function Bm(t){var a;const s=((a=t.formatNotice)==null?void 0:a.blocksNotShown)??0;return s<=0?null:`${s} ${s===1?"block was":"blocks were"} not shown — not in the allowed form (the AI's own text belongs in an AI block). Ask the AI to write the report again.`}function Ob(t){return(t.elements??[]).length===0&&t.renderedHtml.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<[^>]+>/g,"").replace(/&nbsp;/g," ").trim()===""}function Bb(t,s){return s&&t.renderedHtmlGloss?t.renderedHtmlGloss:t.renderedHtml}function Db(t,s,a){const o=new URLSearchParams(t);return o.set("element",s),a?o.set("ticket",a):o.delete("ticket"),o}const Ub={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function Wb(t){return t.filter(s=>s.status==="unverifiable").map(s=>({elementId:s.id,text:`${Ub[s.kind]??"Element"}: ${s.reason??"could not be checked"}`}))}function Hb(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 Vb(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 Jc={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},Gb={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function Kb(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 qb(t,s){const a=Gb[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:{...Jc,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 ac(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:Jc,children:Kb(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))}),qb(t,s.data??{})]})]}):null}function Yb({report:t,elementId:s,ticketParam:a,onClose:o,onSelectTicket:l}){var x;const u=t.elements.find(j=>j.id===s),f=Pb(u,a),g=f?t.ticketDetails[f]:void 0,p=Hb(u),v=(x=t.proof.verifiedValues.find(j=>j.elementId===s))==null?void 0:x.summary,y=m.useRef(null);return m.useEffect(()=>{const j=y.current;if(!j||typeof j.getBoundingClientRect!="function")return;const k=j.getBoundingClientRect().top;(k<0||k>window.innerHeight-80)&&j.scrollIntoView({block:"start",behavior:"smooth"})},[s,a]),n.jsxs("div",{className:"card reports-detail",ref:y,children:[n.jsxs("div",{className:"card-header",children:[n.jsx("div",{className:"card-title",children:"Details"}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:o,children:"Close"})]}),v&&n.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:v}),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:Jc,children:Object.keys(u.data??{}).map(j=>{const k=Ab(j,u.data??{});return k===null?null:n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:j}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:k})]},j)})})),g&&n.jsxs(n.Fragment,{children:[ac("Ticket",g.ticket),ac("Mandate",g.mandate),ac("Approval",g.approval)]}),f&&!g&&n.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",f,"."]})]})}async function Jb(t){const{html:s,filename:a}=await t.exportReport();t.download(s,a),await t.refresh()}function Dm({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 Qb({report:t,open:s,selectedId:a,onOpenElement:o,detail:l}){const{proof:u,coverage:f}=t,g=Wb(t.elements),p=Rb(f),v=Eb(f),y=Tb(f),x=Om(u.signaturesValid),j=Om(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(k=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${a===k.elementId?" reports-row-selected":""}`,onClick:()=>o(k.elementId),children:[n.jsx("span",{children:k.text}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},k.elementId))]}),n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:"Coverage"}),v.kind==="error"?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"reports-error",role:"alert",children:v.text}),n.jsx(Dm,{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(Dm,{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(k=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button${a===k.elementId?" reports-row-selected":""}`,onClick:()=>o(k.elementId),title:"Show details",children:[n.jsx("span",{children:k.summary}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},k.elementId))]})]})}function Xb(){const[t,s]=m.useState(null),[a,o]=m.useState(!0),[l,u]=m.useState(null),[f,g]=m.useState(!1),[p,v]=m.useState(!1),[y,x]=m.useState(null),[j,k]=m.useState(!1),[b,S]=m.useState(!1),[N,E]=ms(),T=m.useCallback(()=>z.getReport().then(({report:F})=>s(F)).catch(F=>u(F instanceof Error?F.message:String(F))),[]),P=m.useCallback(()=>{o(!0),u(null),T().finally(()=>o(!1))},[T]);m.useEffect(()=>{P()},[P]),m.useEffect(()=>{t&&z.markReportSeen(Date.now()).then(()=>window.dispatchEvent(new Event("suveren:report-seen-changed"))).catch(()=>{})},[t==null?void 0:t.savedAt]);const A=m.useCallback(()=>{g(!0),z.recheckReport().then(({report:F})=>s(F)).catch(F=>u(F instanceof Error?F.message:String(F))).finally(()=>g(!1))},[]),D=m.useCallback(async()=>{v(!0),x(null);try{await Jb({exportReport:()=>z.exportReportWithProof(),download:(F,ne)=>{const he=URL.createObjectURL(new Blob([F],{type:"text/html"})),Q=document.createElement("a");Q.href=he,Q.download=ne,Q.click(),URL.revokeObjectURL(he)},refresh:T})}catch(F){x(F instanceof Error?F.message:String(F))}finally{v(!1)}},[T]),O=N.get("element"),K=N.get("ticket"),L=m.useCallback((F,ne)=>{E(Db(N,F,ne))},[N,E]),W=m.useCallback(()=>{const F=new URLSearchParams(N);F.delete("element"),F.delete("ticket"),E(F,{replace:!0})},[N,E]);if(a)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(l)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(cs,{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(cs,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const te=bb(t.renderedHtml),Z=kb(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:te}),n.jsxs("p",{className:"reports-period","data-testid":"report-period",title:Fi(t.coverage).title,children:[n.jsx("b",{children:Fi(t.coverage).text})," · written ",jh(t.savedAt,Date.now())]}),n.jsxs("p",{className:"page-subtitle",children:[Z?`written by the AI under mandate ${Z} · `:"","checked ",Nb(t.checkedAt)]})]}),n.jsxs("div",{className:"reports-bar-actions",children:[n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:A,disabled:f,children:f?"Checking…":"Check again"}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:D,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:Cb(t.proof,t.coverage)}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>k(F=>!F),children:j?"hide":"details"})]}),n.jsxs("div",{className:"reports-grid",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"reports-legend",role:"note",children:[n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-v"}),Lb]}),n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-a"}),zb," (“",_b,"”)"]}),t.renderedHtmlGloss&&n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",Fb]})]}),Bm(t)&&n.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:Bm(t)}),t.renderedHtmlGloss&&n.jsxs("label",{className:"reports-gloss-switch",children:[n.jsx("input",{type:"checkbox",role:"switch",checked:b,onChange:F=>S(F.target.checked)}),n.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:n.jsx("span",{className:"reports-gloss-thumb"})}),n.jsx("span",{children:Mb})]}),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."}),Ob(t)?n.jsxs("div",{className:"note-stopped","data-testid":"report-empty",style:{padding:"var(--space-4)"},children:[n.jsx("span",{className:"msg-error",children:"Nothing in this report can be shown."})," ","Ask the AI to write it again — its own text inside an AI block, the checked values as gateway elements."]}):n.jsx("iframe",{title:"Report",sandbox:$b,srcDoc:Vb(Bb(t,b)),className:"reports-iframe"})]}),n.jsx(Qb,{report:t,open:j||!!O,selectedId:O,onOpenElement:F=>L(F),detail:O?n.jsx(Yb,{report:t,elementId:O,ticketParam:K,onClose:W,onSelectTicket:F=>L(O,F)}):void 0})]})]})})}function is({to:t}){const{search:s,hash:a}=Qt();return n.jsx(On,{to:`${t}${s}${a}`,replace:!0})}function Zb({children:t}){const{user:s,mode:a,domain:o}=xt();return s?a==="team"&&!o?n.jsx(On,{to:"/onboarding",replace:!0}):n.jsx(n.Fragment,{children:t}):n.jsx(On,{to:"/login",replace:!0})}function ek(){const{user:t,handleSessionLocked:s,refreshGroups:a}=xt();return Fe("session-locked",o=>{const l=o==null?void 0:o.message;s(l)}),Fe("team-membership-changed",()=>{a()}),n.jsxs(_v,{children:[n.jsx(at,{path:"/login",element:t?n.jsx(On,{to:"/",replace:!0}):n.jsx(_0,{})}),n.jsx(at,{path:"/onboarding",element:t?n.jsx(B0,{}):n.jsx(On,{to:"/login",replace:!0})}),n.jsxs(at,{element:n.jsx(Zb,{children:n.jsx($0,{})}),children:[n.jsx(at,{path:"/",element:n.jsx(Pw,{})}),n.jsx(at,{path:"/mandates",element:n.jsx(Kj,{})}),n.jsx(at,{path:"/mandates/new/intent",element:n.jsx(sj,{})}),n.jsx(at,{path:"/mandates/new/sign",element:n.jsx(Sj,{})}),n.jsx(at,{path:"/integrations",element:n.jsx(Ij,{})}),n.jsx(at,{path:"/team",element:n.jsx(Aj,{})}),n.jsx(at,{path:"/tickets",element:n.jsx(OS,{})}),n.jsx(at,{path:"/blocked",element:n.jsx(BS,{})}),n.jsx(at,{path:"/approvals",element:n.jsx(vb,{})}),n.jsx(at,{path:"/reports",element:n.jsx(Xb,{})}),n.jsx(at,{path:"/agent/new",element:n.jsx(On,{to:"/mandates?new=1",replace:!0})}),n.jsx(at,{path:"/agent/gate",element:n.jsx(is,{to:"/mandates/new/intent"})}),n.jsx(at,{path:"/agent/review",element:n.jsx(is,{to:"/mandates/new/sign"})}),n.jsx(at,{path:"/authorizations",element:n.jsx(is,{to:"/mandates"})}),n.jsx(at,{path:"/groups",element:n.jsx(is,{to:"/team"})}),n.jsx(at,{path:"/audit",element:n.jsx(is,{to:"/tickets"})}),n.jsx(at,{path:"/proposals",element:n.jsx(is,{to:"/approvals"})}),n.jsx(at,{path:"/agent-brief",element:n.jsx(Sb,{})}),n.jsx(at,{path:"/settings",element:n.jsx(JS,{})}),n.jsx(at,{path:"/settings/services",element:n.jsx(On,{to:"/settings",replace:!0})}),n.jsx(at,{path:"/deploy",element:n.jsx(On,{to:"/integrations",replace:!0})})]}),n.jsx(at,{path:"*",element:n.jsx(On,{to:"/",replace:!0})})]})}function tk(){return n.jsx(ax,{children:n.jsx(jx,{children:n.jsx(kx,{children:n.jsx(ek,{})})})})}Ry.createRoot(document.getElementById("root")).render(n.jsx(m.StrictMode,{children:n.jsx(tk,{})}));