@suveren/gateway 0.8.4 → 0.8.6

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.
Files changed (97) hide show
  1. package/dist/control-plane/index.mjs +170 -83
  2. package/dist/mcp-server/http.mjs +75 -0
  3. package/dist/ui/assets/index-BJqF5rmx.css +1 -0
  4. package/dist/ui/assets/index-DWpjjPIf.js +110 -0
  5. package/dist/ui/index.html +2 -2
  6. package/node_modules/@types/node/README.md +2 -2
  7. package/node_modules/@types/node/buffer.d.ts +1 -0
  8. package/node_modules/@types/node/child_process.d.ts +1 -1
  9. package/node_modules/@types/node/crypto.d.ts +20 -8
  10. package/node_modules/@types/node/diagnostics_channel.d.ts +4 -4
  11. package/node_modules/@types/node/ffi.d.ts +14 -0
  12. package/node_modules/@types/node/http.d.ts +1 -1
  13. package/node_modules/@types/node/http2.d.ts +3 -2
  14. package/node_modules/@types/node/net.d.ts +16 -4
  15. package/node_modules/@types/node/package.json +3 -18
  16. package/node_modules/@types/node/perf_hooks.d.ts +31 -19
  17. package/node_modules/@types/node/process.d.ts +1 -0
  18. package/node_modules/@types/node/quic.d.ts +45 -5
  19. package/node_modules/@types/node/stream/iter.d.ts +9 -12
  20. package/node_modules/@types/node/stream/web.d.ts +20 -0
  21. package/node_modules/@types/node/test/reporters.d.ts +1 -0
  22. package/node_modules/@types/node/test.d.ts +72 -0
  23. package/node_modules/@types/node/tls.d.ts +40 -25
  24. package/node_modules/@types/node/vfs.d.ts +7 -6
  25. package/node_modules/@types/node/vm.d.ts +2 -1
  26. package/node_modules/@types/node/web-globals/streams.d.ts +4 -0
  27. package/node_modules/@types/node/worker_threads.d.ts +4 -1
  28. package/node_modules/@types/node/zlib.d.ts +17 -0
  29. package/node_modules/body-parser/HISTORY.md +156 -145
  30. package/node_modules/body-parser/package.json +2 -2
  31. package/node_modules/express/History.md +583 -576
  32. package/node_modules/express/lib/request.js +2 -2
  33. package/node_modules/express/package.json +3 -3
  34. package/node_modules/fast-uri/index.js +10 -6
  35. package/node_modules/fast-uri/package.json +1 -1
  36. package/node_modules/fast-uri/test/security-normalization.test.js +38 -0
  37. package/node_modules/hono/README.md +1 -1
  38. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +5 -4
  39. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +5 -4
  40. package/node_modules/hono/dist/cjs/context.js +1 -1
  41. package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +1 -1
  42. package/node_modules/hono/dist/cjs/jsx/dom/render.js +44 -8
  43. package/node_modules/hono/dist/cjs/middleware/language/language.js +4 -1
  44. package/node_modules/hono/dist/cjs/request.js +4 -1
  45. package/node_modules/hono/dist/cjs/utils/accept.js +4 -7
  46. package/node_modules/hono/dist/context.js +1 -1
  47. package/node_modules/hono/dist/helper/accepts/accepts.js +1 -1
  48. package/node_modules/hono/dist/jsx/dom/render.js +44 -8
  49. package/node_modules/hono/dist/middleware/language/language.js +4 -1
  50. package/node_modules/hono/dist/request.js +4 -1
  51. package/node_modules/hono/dist/types/helper/proxy/index.d.ts +1 -1
  52. package/node_modules/hono/dist/types/helper/route/index.d.ts +2 -2
  53. package/node_modules/hono/dist/types/middleware/combine/index.d.ts +3 -1
  54. package/node_modules/hono/dist/types/utils/types.d.ts +1 -1
  55. package/node_modules/hono/dist/utils/accept.js +4 -7
  56. package/node_modules/hono/package.json +1 -1
  57. package/node_modules/ip-address/README.md +114 -114
  58. package/node_modules/ip-address/dist/common.d.ts +5 -0
  59. package/node_modules/ip-address/dist/common.js +12 -0
  60. package/node_modules/ip-address/dist/common.js.map +1 -1
  61. package/node_modules/ip-address/dist/ipv4.d.ts +10 -3
  62. package/node_modules/ip-address/dist/ipv4.js +20 -5
  63. package/node_modules/ip-address/dist/ipv4.js.map +1 -1
  64. package/node_modules/ip-address/dist/ipv6.d.ts +5 -1
  65. package/node_modules/ip-address/dist/ipv6.js +18 -3
  66. package/node_modules/ip-address/dist/ipv6.js.map +1 -1
  67. package/node_modules/ip-address/package.json +1 -1
  68. package/node_modules/proxy-addr/HISTORY.md +60 -54
  69. package/node_modules/proxy-addr/README.md +1 -1
  70. package/node_modules/proxy-addr/index.js +32 -0
  71. package/node_modules/proxy-addr/package.json +8 -4
  72. package/node_modules/qs/.github/THREAT_MODEL.md +3 -3
  73. package/node_modules/qs/CHANGELOG.md +15 -0
  74. package/node_modules/qs/README.md +19 -1
  75. package/node_modules/qs/dist/qs.js +21 -21
  76. package/node_modules/qs/eslint.config.mjs +1 -1
  77. package/node_modules/qs/lib/parse.js +3 -4
  78. package/node_modules/qs/lib/stringify.js +23 -8
  79. package/node_modules/qs/lib/utils.js +10 -3
  80. package/node_modules/qs/package.json +4 -4
  81. package/node_modules/qs/test/parse.js +192 -3
  82. package/node_modules/qs/test/stringify.js +317 -0
  83. package/node_modules/qs/test/utils.js +12 -0
  84. package/node_modules/undici-types/client.d.ts +8 -3
  85. package/node_modules/undici-types/connector.d.ts +1 -0
  86. package/node_modules/undici-types/cookies.d.ts +1 -1
  87. package/node_modules/undici-types/dispatcher.d.ts +3 -3
  88. package/node_modules/undici-types/errors.d.ts +10 -0
  89. package/node_modules/undici-types/fetch.d.ts +5 -1
  90. package/node_modules/undici-types/handlers.d.ts +2 -0
  91. package/node_modules/undici-types/interceptors.d.ts +1 -1
  92. package/node_modules/undici-types/mock-interceptor.d.ts +5 -1
  93. package/node_modules/undici-types/package.json +1 -1
  94. package/node_modules/undici-types/proxy-agent.d.ts +7 -0
  95. package/package.json +1 -1
  96. package/dist/ui/assets/index-BYVb_0oG.css +0 -1
  97. package/dist/ui/assets/index-Z0OQ-dd1.js +0 -110
@@ -0,0 +1,110 @@
1
+ var xp=Object.defineProperty;var wp=(e,t,n)=>t in e?xp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var wr=(e,t,n)=>wp(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();var hu={exports:{}},Pa={},mu={exports:{}},ie={};/**
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 us=Symbol.for("react.element"),Sp=Symbol.for("react.portal"),jp=Symbol.for("react.fragment"),kp=Symbol.for("react.strict_mode"),bp=Symbol.for("react.profiler"),Cp=Symbol.for("react.provider"),Np=Symbol.for("react.context"),Ep=Symbol.for("react.forward_ref"),Tp=Symbol.for("react.suspense"),zp=Symbol.for("react.memo"),Rp=Symbol.for("react.lazy"),Fl=Symbol.iterator;function Pp(e){return e===null||typeof e!="object"?null:(e=Fl&&e[Fl]||e["@@iterator"],typeof e=="function"?e:null)}var gu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},vu=Object.assign,yu={};function hr(e,t,n){this.props=e,this.context=t,this.refs=yu,this.updater=n||gu}hr.prototype.isReactComponent={};hr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=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,e,t,"setState")};hr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function xu(){}xu.prototype=hr.prototype;function Ii(e,t,n){this.props=e,this.context=t,this.refs=yu,this.updater=n||gu}var _i=Ii.prototype=new xu;_i.constructor=Ii;vu(_i,hr.prototype);_i.isPureReactComponent=!0;var Ol=Array.isArray,wu=Object.prototype.hasOwnProperty,Ai={current:null},Su={key:!0,ref:!0,__self:!0,__source:!0};function ju(e,t,n){var r,s={},o=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(o=""+t.key),t)wu.call(t,r)&&!Su.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1<l){for(var c=Array(l),d=0;d<l;d++)c[d]=arguments[d+2];s.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)s[r]===void 0&&(s[r]=l[r]);return{$$typeof:us,type:e,key:o,ref:i,props:s,_owner:Ai.current}}function Ip(e,t){return{$$typeof:us,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function $i(e){return typeof e=="object"&&e!==null&&e.$$typeof===us}function _p(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Bl=/\/+/g;function qa(e,t){return typeof e=="object"&&e!==null&&e.key!=null?_p(""+e.key):t.toString(36)}function Ds(e,t,n,r,s){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var i=!1;if(e===null)i=!0;else switch(o){case"string":case"number":i=!0;break;case"object":switch(e.$$typeof){case us:case Sp:i=!0}}if(i)return i=e,s=s(i),e=r===""?"."+qa(i,0):r,Ol(s)?(n="",e!=null&&(n=e.replace(Bl,"$&/")+"/"),Ds(s,t,n,"",function(d){return d})):s!=null&&($i(s)&&(s=Ip(s,n+(!s.key||i&&i.key===s.key?"":(""+s.key).replace(Bl,"$&/")+"/")+e)),t.push(s)),1;if(i=0,r=r===""?".":r+":",Ol(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+qa(o,l);i+=Ds(o,t,n,c,s)}else if(c=Pp(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+qa(o,l++),i+=Ds(o,t,n,c,s);else if(o==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return i}function xs(e,t,n){if(e==null)return e;var r=[],s=0;return Ds(e,r,"","",function(o){return t.call(n,o,s++)}),r}function Ap(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var qe={current:null},Us={transition:null},$p={ReactCurrentDispatcher:qe,ReactCurrentBatchConfig:Us,ReactCurrentOwner:Ai};function ku(){throw Error("act(...) is not supported in production builds of React.")}ie.Children={map:xs,forEach:function(e,t,n){xs(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return xs(e,function(){t++}),t},toArray:function(e){return xs(e,function(t){return t})||[]},only:function(e){if(!$i(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ie.Component=hr;ie.Fragment=jp;ie.Profiler=bp;ie.PureComponent=Ii;ie.StrictMode=kp;ie.Suspense=Tp;ie.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=$p;ie.act=ku;ie.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=vu({},e.props),s=e.key,o=e.ref,i=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,i=Ai.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)wu.call(t,c)&&!Su.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var d=0;d<c;d++)l[d]=arguments[d+2];r.children=l}return{$$typeof:us,type:e.type,key:s,ref:o,props:r,_owner:i}};ie.createContext=function(e){return e={$$typeof:Np,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Cp,_context:e},e.Consumer=e};ie.createElement=ju;ie.createFactory=function(e){var t=ju.bind(null,e);return t.type=e,t};ie.createRef=function(){return{current:null}};ie.forwardRef=function(e){return{$$typeof:Ep,render:e}};ie.isValidElement=$i;ie.lazy=function(e){return{$$typeof:Rp,_payload:{_status:-1,_result:e},_init:Ap}};ie.memo=function(e,t){return{$$typeof:zp,type:e,compare:t===void 0?null:t}};ie.startTransition=function(e){var t=Us.transition;Us.transition={};try{e()}finally{Us.transition=t}};ie.unstable_act=ku;ie.useCallback=function(e,t){return qe.current.useCallback(e,t)};ie.useContext=function(e){return qe.current.useContext(e)};ie.useDebugValue=function(){};ie.useDeferredValue=function(e){return qe.current.useDeferredValue(e)};ie.useEffect=function(e,t){return qe.current.useEffect(e,t)};ie.useId=function(){return qe.current.useId()};ie.useImperativeHandle=function(e,t,n){return qe.current.useImperativeHandle(e,t,n)};ie.useInsertionEffect=function(e,t){return qe.current.useInsertionEffect(e,t)};ie.useLayoutEffect=function(e,t){return qe.current.useLayoutEffect(e,t)};ie.useMemo=function(e,t){return qe.current.useMemo(e,t)};ie.useReducer=function(e,t,n){return qe.current.useReducer(e,t,n)};ie.useRef=function(e){return qe.current.useRef(e)};ie.useState=function(e){return qe.current.useState(e)};ie.useSyncExternalStore=function(e,t,n){return qe.current.useSyncExternalStore(e,t,n)};ie.useTransition=function(){return qe.current.useTransition()};ie.version="18.3.1";mu.exports=ie;var u=mu.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 Lp=u,Mp=Symbol.for("react.element"),Fp=Symbol.for("react.fragment"),Op=Object.prototype.hasOwnProperty,Bp=Lp.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Dp={key:!0,ref:!0,__self:!0,__source:!0};function bu(e,t,n){var r,s={},o=null,i=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(i=t.ref);for(r in t)Op.call(t,r)&&!Dp.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:Mp,type:e,key:o,ref:i,props:s,_owner:Bp.current}}Pa.Fragment=Fp;Pa.jsx=bu;Pa.jsxs=bu;hu.exports=Pa;var a=hu.exports,Cu={exports:{}},ht={},Nu={exports:{}},Eu={};/**
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
+ */(function(e){function t($,A){var W=$.length;$.push(A);e:for(;0<W;){var R=W-1>>>1,B=$[R];if(0<s(B,A))$[R]=A,$[W]=B,W=R;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var A=$[0],W=$.pop();if(W!==A){$[0]=W;e:for(var R=0,B=$.length,Q=B>>>1;R<Q;){var q=2*(R+1)-1,re=$[q],ce=q+1,pe=$[ce];if(0>s(re,W))ce<B&&0>s(pe,re)?($[R]=pe,$[ce]=W,R=ce):($[R]=re,$[q]=W,R=q);else if(ce<B&&0>s(pe,W))$[R]=pe,$[ce]=W,R=ce;else break e}}return A}function s($,A){var W=$.sortIndex-A.sortIndex;return W!==0?W:$.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,l=i.now();e.unstable_now=function(){return i.now()-l}}var c=[],d=[],f=1,h=null,p=3,w=!1,y=!1,x=!1,j=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,m=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v($){for(var A=n(d);A!==null;){if(A.callback===null)r(d);else if(A.startTime<=$)r(d),A.sortIndex=A.expirationTime,t(c,A);else break;A=n(d)}}function S($){if(x=!1,v($),!y)if(n(c)!==null)y=!0,ee(b);else{var A=n(d);A!==null&&F(S,A.startTime-$)}}function b($,A){y=!1,x&&(x=!1,g(T),T=-1),w=!0;var W=p;try{for(v(A),h=n(c);h!==null&&(!(h.expirationTime>A)||$&&!D());){var R=h.callback;if(typeof R=="function"){h.callback=null,p=h.priorityLevel;var B=R(h.expirationTime<=A);A=e.unstable_now(),typeof B=="function"?h.callback=B:h===n(c)&&r(c),v(A)}else r(c);h=n(c)}if(h!==null)var Q=!0;else{var q=n(d);q!==null&&F(S,q.startTime-A),Q=!1}return Q}finally{h=null,p=W,w=!1}}var N=!1,C=null,T=-1,E=5,L=-1;function D(){return!(e.unstable_now()-L<E)}function G(){if(C!==null){var $=e.unstable_now();L=$;var A=!0;try{A=C(!0,$)}finally{A?J():(N=!1,C=null)}}else N=!1}var J;if(typeof m=="function")J=function(){m(G)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,P=U.port2;U.port1.onmessage=G,J=function(){P.postMessage(null)}}else J=function(){j(G,0)};function ee($){C=$,N||(N=!0,J())}function F($,A){T=j(function(){$(e.unstable_now())},A)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function($){$.callback=null},e.unstable_continueExecution=function(){y||w||(y=!0,ee(b))},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function($){switch(p){case 1:case 2:case 3:var A=3;break;default:A=p}var W=p;p=A;try{return $()}finally{p=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function($,A){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var W=p;p=$;try{return A()}finally{p=W}},e.unstable_scheduleCallback=function($,A,W){var R=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?R+W:R):W=R,$){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=W+B,$={id:f++,callback:A,priorityLevel:$,startTime:W,expirationTime:B,sortIndex:-1},W>R?($.sortIndex=W,t(d,$),n(c)===null&&$===n(d)&&(x?(g(T),T=-1):x=!0,F(S,W-R))):($.sortIndex=B,t(c,$),y||w||(y=!0,ee(b))),$},e.unstable_shouldYield=D,e.unstable_wrapCallback=function($){var A=p;return function(){var W=p;p=A;try{return $.apply(this,arguments)}finally{p=W}}}})(Eu);Nu.exports=Eu;var Up=Nu.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 Wp=u,pt=Up;function O(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var Tu=new Set,Gr={};function Bn(e,t){ir(e,t),ir(e+"Capture",t)}function ir(e,t){for(Gr[e]=t,e=0;e<t.length;e++)Tu.add(t[e])}var Yt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Io=Object.prototype.hasOwnProperty,Hp=/^[: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]*$/,Dl={},Ul={};function Vp(e){return Io.call(Ul,e)?!0:Io.call(Dl,e)?!1:Hp.test(e)?Ul[e]=!0:(Dl[e]=!0,!1)}function Gp(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Kp(e,t,n,r){if(t===null||typeof t>"u"||Gp(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ze(e,t,n,r,s,o,i){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=i}var Ue={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ue[e]=new Ze(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ue[t]=new Ze(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ue[e]=new Ze(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ue[e]=new Ze(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){Ue[e]=new Ze(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ue[e]=new Ze(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ue[e]=new Ze(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ue[e]=new Ze(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ue[e]=new Ze(e,5,!1,e.toLowerCase(),null,!1,!1)});var Li=/[\-:]([a-z])/g;function Mi(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Li,Mi);Ue[t]=new Ze(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Li,Mi);Ue[t]=new Ze(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Li,Mi);Ue[t]=new Ze(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ue[e]=new Ze(e,1,!1,e.toLowerCase(),null,!1,!1)});Ue.xlinkHref=new Ze("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ue[e]=new Ze(e,1,!1,e.toLowerCase(),null,!0,!0)});function Fi(e,t,n,r){var s=Ue.hasOwnProperty(t)?Ue[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(Kp(t,n,s,r)&&(n=null),r||s===null?Vp(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):s.mustUseProperty?e[s.propertyName]=n===null?s.type===3?!1:"":n:(t=s.attributeName,r=s.attributeNamespace,n===null?e.removeAttribute(t):(s=s.type,n=s===3||s===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var Zt=Wp.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,ws=Symbol.for("react.element"),Wn=Symbol.for("react.portal"),Hn=Symbol.for("react.fragment"),Oi=Symbol.for("react.strict_mode"),_o=Symbol.for("react.profiler"),zu=Symbol.for("react.provider"),Ru=Symbol.for("react.context"),Bi=Symbol.for("react.forward_ref"),Ao=Symbol.for("react.suspense"),$o=Symbol.for("react.suspense_list"),Di=Symbol.for("react.memo"),nn=Symbol.for("react.lazy"),Pu=Symbol.for("react.offscreen"),Wl=Symbol.iterator;function Sr(e){return e===null||typeof e!="object"?null:(e=Wl&&e[Wl]||e["@@iterator"],typeof e=="function"?e:null)}var Ne=Object.assign,Za;function Pr(e){if(Za===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Za=t&&t[1]||""}return`
34
+ `+Za+e}var eo=!1;function to(e,t){if(!e||eo)return"";eo=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(d){var r=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){r=d}e.call(t.prototype)}else{try{throw Error()}catch(d){r=d}e()}}catch(d){if(d&&r&&typeof d.stack=="string"){for(var s=d.stack.split(`
35
+ `),o=r.stack.split(`
36
+ `),i=s.length-1,l=o.length-1;1<=i&&0<=l&&s[i]!==o[l];)l--;for(;1<=i&&0<=l;i--,l--)if(s[i]!==o[l]){if(i!==1||l!==1)do if(i--,l--,0>l||s[i]!==o[l]){var c=`
37
+ `+s[i].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=i&&0<=l);break}}}finally{eo=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Pr(e):""}function Yp(e){switch(e.tag){case 5:return Pr(e.type);case 16:return Pr("Lazy");case 13:return Pr("Suspense");case 19:return Pr("SuspenseList");case 0:case 2:case 15:return e=to(e.type,!1),e;case 11:return e=to(e.type.render,!1),e;case 1:return e=to(e.type,!0),e;default:return""}}function Lo(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 Hn:return"Fragment";case Wn:return"Portal";case _o:return"Profiler";case Oi:return"StrictMode";case Ao:return"Suspense";case $o:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ru:return(e.displayName||"Context")+".Consumer";case zu:return(e._context.displayName||"Context")+".Provider";case Bi:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Di:return t=e.displayName||null,t!==null?t:Lo(e.type)||"Memo";case nn:t=e._payload,e=e._init;try{return Lo(e(t))}catch{}}return null}function Qp(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Lo(t);case 8:return t===Oi?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function yn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Iu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Jp(e){var t=Iu(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(i){r=""+i,o.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ss(e){e._valueTracker||(e._valueTracker=Jp(e))}function _u(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Iu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function ra(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 Mo(e,t){var n=t.checked;return Ne({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Hl(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=yn(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Au(e,t){t=t.checked,t!=null&&Fi(e,"checked",t,!1)}function Fo(e,t){Au(e,t);var n=yn(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Oo(e,t.type,n):t.hasOwnProperty("defaultValue")&&Oo(e,t.type,yn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Vl(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Oo(e,t,n){(t!=="number"||ra(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Ir=Array.isArray;function tr(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s<n.length;s++)t["$"+n[s]]=!0;for(n=0;n<e.length;n++)s=t.hasOwnProperty("$"+e[n].value),e[n].selected!==s&&(e[n].selected=s),s&&r&&(e[n].defaultSelected=!0)}else{for(n=""+yn(n),t=null,s=0;s<e.length;s++){if(e[s].value===n){e[s].selected=!0,r&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function Bo(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(O(91));return Ne({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Gl(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(O(92));if(Ir(n)){if(1<n.length)throw Error(O(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:yn(n)}}function $u(e,t){var n=yn(t.value),r=yn(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function Kl(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Lu(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 Do(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Lu(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var js,Mu=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,s){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,s)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(js=js||document.createElement("div"),js.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=js.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Kr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Lr={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},Xp=["Webkit","ms","Moz","O"];Object.keys(Lr).forEach(function(e){Xp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Lr[t]=Lr[e]})});function Fu(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Lr.hasOwnProperty(e)&&Lr[e]?(""+t).trim():t+"px"}function Ou(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=Fu(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var qp=Ne({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 Uo(e,t){if(t){if(qp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(O(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(O(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(O(61))}if(t.style!=null&&typeof t.style!="object")throw Error(O(62))}}function Wo(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ho=null;function Ui(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Vo=null,nr=null,rr=null;function Yl(e){if(e=ps(e)){if(typeof Vo!="function")throw Error(O(280));var t=e.stateNode;t&&(t=La(t),Vo(e.stateNode,e.type,t))}}function Bu(e){nr?rr?rr.push(e):rr=[e]:nr=e}function Du(){if(nr){var e=nr,t=rr;if(rr=nr=null,Yl(e),t)for(e=0;e<t.length;e++)Yl(t[e])}}function Uu(e,t){return e(t)}function Wu(){}var no=!1;function Hu(e,t,n){if(no)return e(t,n);no=!0;try{return Uu(e,t,n)}finally{no=!1,(nr!==null||rr!==null)&&(Wu(),Du())}}function Yr(e,t){var n=e.stateNode;if(n===null)return null;var r=La(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(O(231,t,typeof n));return n}var Go=!1;if(Yt)try{var jr={};Object.defineProperty(jr,"passive",{get:function(){Go=!0}}),window.addEventListener("test",jr,jr),window.removeEventListener("test",jr,jr)}catch{Go=!1}function Zp(e,t,n,r,s,o,i,l,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(f){this.onError(f)}}var Mr=!1,sa=null,aa=!1,Ko=null,eh={onError:function(e){Mr=!0,sa=e}};function th(e,t,n,r,s,o,i,l,c){Mr=!1,sa=null,Zp.apply(eh,arguments)}function nh(e,t,n,r,s,o,i,l,c){if(th.apply(this,arguments),Mr){if(Mr){var d=sa;Mr=!1,sa=null}else throw Error(O(198));aa||(aa=!0,Ko=d)}}function Dn(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function Vu(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Ql(e){if(Dn(e)!==e)throw Error(O(188))}function rh(e){var t=e.alternate;if(!t){if(t=Dn(e),t===null)throw Error(O(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(s===null)break;var o=s.alternate;if(o===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===o.child){for(o=s.child;o;){if(o===n)return Ql(s),e;if(o===r)return Ql(s),t;o=o.sibling}throw Error(O(188))}if(n.return!==r.return)n=s,r=o;else{for(var i=!1,l=s.child;l;){if(l===n){i=!0,n=s,r=o;break}if(l===r){i=!0,r=s,n=o;break}l=l.sibling}if(!i){for(l=o.child;l;){if(l===n){i=!0,n=o,r=s;break}if(l===r){i=!0,r=o,n=s;break}l=l.sibling}if(!i)throw Error(O(189))}}if(n.alternate!==r)throw Error(O(190))}if(n.tag!==3)throw Error(O(188));return n.stateNode.current===n?e:t}function Gu(e){return e=rh(e),e!==null?Ku(e):null}function Ku(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Ku(e);if(t!==null)return t;e=e.sibling}return null}var Yu=pt.unstable_scheduleCallback,Jl=pt.unstable_cancelCallback,sh=pt.unstable_shouldYield,ah=pt.unstable_requestPaint,Te=pt.unstable_now,oh=pt.unstable_getCurrentPriorityLevel,Wi=pt.unstable_ImmediatePriority,Qu=pt.unstable_UserBlockingPriority,oa=pt.unstable_NormalPriority,ih=pt.unstable_LowPriority,Ju=pt.unstable_IdlePriority,Ia=null,Ot=null;function lh(e){if(Ot&&typeof Ot.onCommitFiberRoot=="function")try{Ot.onCommitFiberRoot(Ia,e,void 0,(e.current.flags&128)===128)}catch{}}var Pt=Math.clz32?Math.clz32:dh,ch=Math.log,uh=Math.LN2;function dh(e){return e>>>=0,e===0?32:31-(ch(e)/uh|0)|0}var ks=64,bs=4194304;function _r(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 ia(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,o=e.pingedLanes,i=n&268435455;if(i!==0){var l=i&~s;l!==0?r=_r(l):(o&=i,o!==0&&(r=_r(o)))}else i=n&~s,i!==0?r=_r(i):o!==0&&(r=_r(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,o=t&-t,s>=o||s===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Pt(t),s=1<<n,r|=e[n],t&=~s;return r}function fh(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ph(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes;0<o;){var i=31-Pt(o),l=1<<i,c=s[i];c===-1?(!(l&n)||l&r)&&(s[i]=fh(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function Yo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Xu(){var e=ks;return ks<<=1,!(ks&4194240)&&(ks=64),e}function ro(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function ds(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Pt(t),e[t]=n}function hh(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var s=31-Pt(n),o=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~o}}function Hi(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Pt(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var he=0;function qu(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Zu,Vi,ed,td,nd,Qo=!1,Cs=[],un=null,dn=null,fn=null,Qr=new Map,Jr=new Map,an=[],mh="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 Xl(e,t){switch(e){case"focusin":case"focusout":un=null;break;case"dragenter":case"dragleave":dn=null;break;case"mouseover":case"mouseout":fn=null;break;case"pointerover":case"pointerout":Qr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Jr.delete(t.pointerId)}}function kr(e,t,n,r,s,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[s]},t!==null&&(t=ps(t),t!==null&&Vi(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function gh(e,t,n,r,s){switch(t){case"focusin":return un=kr(un,e,t,n,r,s),!0;case"dragenter":return dn=kr(dn,e,t,n,r,s),!0;case"mouseover":return fn=kr(fn,e,t,n,r,s),!0;case"pointerover":var o=s.pointerId;return Qr.set(o,kr(Qr.get(o)||null,e,t,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,Jr.set(o,kr(Jr.get(o)||null,e,t,n,r,s)),!0}return!1}function rd(e){var t=zn(e.target);if(t!==null){var n=Dn(t);if(n!==null){if(t=n.tag,t===13){if(t=Vu(n),t!==null){e.blockedOn=t,nd(e.priority,function(){ed(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ws(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Jo(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Ho=r,n.target.dispatchEvent(r),Ho=null}else return t=ps(n),t!==null&&Vi(t),e.blockedOn=n,!1;t.shift()}return!0}function ql(e,t,n){Ws(e)&&n.delete(t)}function vh(){Qo=!1,un!==null&&Ws(un)&&(un=null),dn!==null&&Ws(dn)&&(dn=null),fn!==null&&Ws(fn)&&(fn=null),Qr.forEach(ql),Jr.forEach(ql)}function br(e,t){e.blockedOn===t&&(e.blockedOn=null,Qo||(Qo=!0,pt.unstable_scheduleCallback(pt.unstable_NormalPriority,vh)))}function Xr(e){function t(s){return br(s,e)}if(0<Cs.length){br(Cs[0],e);for(var n=1;n<Cs.length;n++){var r=Cs[n];r.blockedOn===e&&(r.blockedOn=null)}}for(un!==null&&br(un,e),dn!==null&&br(dn,e),fn!==null&&br(fn,e),Qr.forEach(t),Jr.forEach(t),n=0;n<an.length;n++)r=an[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<an.length&&(n=an[0],n.blockedOn===null);)rd(n),n.blockedOn===null&&an.shift()}var sr=Zt.ReactCurrentBatchConfig,la=!0;function yh(e,t,n,r){var s=he,o=sr.transition;sr.transition=null;try{he=1,Gi(e,t,n,r)}finally{he=s,sr.transition=o}}function xh(e,t,n,r){var s=he,o=sr.transition;sr.transition=null;try{he=4,Gi(e,t,n,r)}finally{he=s,sr.transition=o}}function Gi(e,t,n,r){if(la){var s=Jo(e,t,n,r);if(s===null)ho(e,t,r,ca,n),Xl(e,r);else if(gh(s,e,t,n,r))r.stopPropagation();else if(Xl(e,r),t&4&&-1<mh.indexOf(e)){for(;s!==null;){var o=ps(s);if(o!==null&&Zu(o),o=Jo(e,t,n,r),o===null&&ho(e,t,r,ca,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else ho(e,t,r,null,n)}}var ca=null;function Jo(e,t,n,r){if(ca=null,e=Ui(r),e=zn(e),e!==null)if(t=Dn(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Vu(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return ca=e,null}function sd(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(oh()){case Wi:return 1;case Qu:return 4;case oa:case ih:return 16;case Ju:return 536870912;default:return 16}default:return 16}}var ln=null,Ki=null,Hs=null;function ad(){if(Hs)return Hs;var e,t=Ki,n=t.length,r,s="value"in ln?ln.value:ln.textContent,o=s.length;for(e=0;e<n&&t[e]===s[e];e++);var i=n-e;for(r=1;r<=i&&t[n-r]===s[o-r];r++);return Hs=s.slice(e,1<r?1-r:void 0)}function Vs(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Ns(){return!0}function Zl(){return!1}function mt(e){function t(n,r,s,o,i){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=o,this.target=i,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(o):o[l]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?Ns:Zl,this.isPropagationStopped=Zl,this}return Ne(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Ns)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Ns)},persist:function(){},isPersistent:Ns}),t}var mr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Yi=mt(mr),fs=Ne({},mr,{view:0,detail:0}),wh=mt(fs),so,ao,Cr,_a=Ne({},fs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Qi,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!==Cr&&(Cr&&e.type==="mousemove"?(so=e.screenX-Cr.screenX,ao=e.screenY-Cr.screenY):ao=so=0,Cr=e),so)},movementY:function(e){return"movementY"in e?e.movementY:ao}}),ec=mt(_a),Sh=Ne({},_a,{dataTransfer:0}),jh=mt(Sh),kh=Ne({},fs,{relatedTarget:0}),oo=mt(kh),bh=Ne({},mr,{animationName:0,elapsedTime:0,pseudoElement:0}),Ch=mt(bh),Nh=Ne({},mr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Eh=mt(Nh),Th=Ne({},mr,{data:0}),tc=mt(Th),zh={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Rh={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"},Ph={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ih(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Ph[e])?!!t[e]:!1}function Qi(){return Ih}var _h=Ne({},fs,{key:function(e){if(e.key){var t=zh[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Vs(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Rh[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Qi,charCode:function(e){return e.type==="keypress"?Vs(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Vs(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Ah=mt(_h),$h=Ne({},_a,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),nc=mt($h),Lh=Ne({},fs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Qi}),Mh=mt(Lh),Fh=Ne({},mr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Oh=mt(Fh),Bh=Ne({},_a,{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}),Dh=mt(Bh),Uh=[9,13,27,32],Ji=Yt&&"CompositionEvent"in window,Fr=null;Yt&&"documentMode"in document&&(Fr=document.documentMode);var Wh=Yt&&"TextEvent"in window&&!Fr,od=Yt&&(!Ji||Fr&&8<Fr&&11>=Fr),rc=" ",sc=!1;function id(e,t){switch(e){case"keyup":return Uh.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ld(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Vn=!1;function Hh(e,t){switch(e){case"compositionend":return ld(t);case"keypress":return t.which!==32?null:(sc=!0,rc);case"textInput":return e=t.data,e===rc&&sc?null:e;default:return null}}function Vh(e,t){if(Vn)return e==="compositionend"||!Ji&&id(e,t)?(e=ad(),Hs=Ki=ln=null,Vn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return od&&t.locale!=="ko"?null:t.data;default:return null}}var Gh={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 ac(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Gh[e.type]:t==="textarea"}function cd(e,t,n,r){Bu(r),t=ua(t,"onChange"),0<t.length&&(n=new Yi("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Or=null,qr=null;function Kh(e){wd(e,0)}function Aa(e){var t=Yn(e);if(_u(t))return e}function Yh(e,t){if(e==="change")return t}var ud=!1;if(Yt){var io;if(Yt){var lo="oninput"in document;if(!lo){var oc=document.createElement("div");oc.setAttribute("oninput","return;"),lo=typeof oc.oninput=="function"}io=lo}else io=!1;ud=io&&(!document.documentMode||9<document.documentMode)}function ic(){Or&&(Or.detachEvent("onpropertychange",dd),qr=Or=null)}function dd(e){if(e.propertyName==="value"&&Aa(qr)){var t=[];cd(t,qr,e,Ui(e)),Hu(Kh,t)}}function Qh(e,t,n){e==="focusin"?(ic(),Or=t,qr=n,Or.attachEvent("onpropertychange",dd)):e==="focusout"&&ic()}function Jh(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Aa(qr)}function Xh(e,t){if(e==="click")return Aa(t)}function qh(e,t){if(e==="input"||e==="change")return Aa(t)}function Zh(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var _t=typeof Object.is=="function"?Object.is:Zh;function Zr(e,t){if(_t(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var s=n[r];if(!Io.call(t,s)||!_t(e[s],t[s]))return!1}return!0}function lc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function cc(e,t){var n=lc(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=lc(n)}}function fd(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?fd(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function pd(){for(var e=window,t=ra();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=ra(e.document)}return t}function Xi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function em(e){var t=pd(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&fd(n.ownerDocument.documentElement,n)){if(r!==null&&Xi(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,o=Math.min(r.start,s);r=r.end===void 0?o:Math.min(r.end,s),!e.extend&&o>r&&(s=r,r=o,o=s),s=cc(n,o);var i=cc(n,r);s&&i&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var tm=Yt&&"documentMode"in document&&11>=document.documentMode,Gn=null,Xo=null,Br=null,qo=!1;function uc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;qo||Gn==null||Gn!==ra(r)||(r=Gn,"selectionStart"in r&&Xi(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Br&&Zr(Br,r)||(Br=r,r=ua(Xo,"onSelect"),0<r.length&&(t=new Yi("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Gn)))}function Es(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Kn={animationend:Es("Animation","AnimationEnd"),animationiteration:Es("Animation","AnimationIteration"),animationstart:Es("Animation","AnimationStart"),transitionend:Es("Transition","TransitionEnd")},co={},hd={};Yt&&(hd=document.createElement("div").style,"AnimationEvent"in window||(delete Kn.animationend.animation,delete Kn.animationiteration.animation,delete Kn.animationstart.animation),"TransitionEvent"in window||delete Kn.transitionend.transition);function $a(e){if(co[e])return co[e];if(!Kn[e])return e;var t=Kn[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in hd)return co[e]=t[n];return e}var md=$a("animationend"),gd=$a("animationiteration"),vd=$a("animationstart"),yd=$a("transitionend"),xd=new Map,dc="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 wn(e,t){xd.set(e,t),Bn(t,[e])}for(var uo=0;uo<dc.length;uo++){var fo=dc[uo],nm=fo.toLowerCase(),rm=fo[0].toUpperCase()+fo.slice(1);wn(nm,"on"+rm)}wn(md,"onAnimationEnd");wn(gd,"onAnimationIteration");wn(vd,"onAnimationStart");wn("dblclick","onDoubleClick");wn("focusin","onFocus");wn("focusout","onBlur");wn(yd,"onTransitionEnd");ir("onMouseEnter",["mouseout","mouseover"]);ir("onMouseLeave",["mouseout","mouseover"]);ir("onPointerEnter",["pointerout","pointerover"]);ir("onPointerLeave",["pointerout","pointerover"]);Bn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Bn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Bn("onBeforeInput",["compositionend","keypress","textInput","paste"]);Bn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Bn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Bn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ar="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(" "),sm=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ar));function fc(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,nh(r,t,void 0,e),e.currentTarget=null}function wd(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],s=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var i=r.length-1;0<=i;i--){var l=r[i],c=l.instance,d=l.currentTarget;if(l=l.listener,c!==o&&s.isPropagationStopped())break e;fc(s,l,d),o=c}else for(i=0;i<r.length;i++){if(l=r[i],c=l.instance,d=l.currentTarget,l=l.listener,c!==o&&s.isPropagationStopped())break e;fc(s,l,d),o=c}}}if(aa)throw e=Ko,aa=!1,Ko=null,e}function we(e,t){var n=t[ri];n===void 0&&(n=t[ri]=new Set);var r=e+"__bubble";n.has(r)||(Sd(t,e,2,!1),n.add(r))}function po(e,t,n){var r=0;t&&(r|=4),Sd(n,e,r,t)}var Ts="_reactListening"+Math.random().toString(36).slice(2);function es(e){if(!e[Ts]){e[Ts]=!0,Tu.forEach(function(n){n!=="selectionchange"&&(sm.has(n)||po(n,!1,e),po(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ts]||(t[Ts]=!0,po("selectionchange",!1,t))}}function Sd(e,t,n,r){switch(sd(t)){case 1:var s=yh;break;case 4:s=xh;break;default:s=Gi}n=s.bind(null,t,n,e),s=void 0,!Go||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),r?s!==void 0?e.addEventListener(t,n,{capture:!0,passive:s}):e.addEventListener(t,n,!0):s!==void 0?e.addEventListener(t,n,{passive:s}):e.addEventListener(t,n,!1)}function ho(e,t,n,r,s){var o=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var i=r.tag;if(i===3||i===4){var l=r.stateNode.containerInfo;if(l===s||l.nodeType===8&&l.parentNode===s)break;if(i===4)for(i=r.return;i!==null;){var c=i.tag;if((c===3||c===4)&&(c=i.stateNode.containerInfo,c===s||c.nodeType===8&&c.parentNode===s))return;i=i.return}for(;l!==null;){if(i=zn(l),i===null)return;if(c=i.tag,c===5||c===6){r=o=i;continue e}l=l.parentNode}}r=r.return}Hu(function(){var d=o,f=Ui(n),h=[];e:{var p=xd.get(e);if(p!==void 0){var w=Yi,y=e;switch(e){case"keypress":if(Vs(n)===0)break e;case"keydown":case"keyup":w=Ah;break;case"focusin":y="focus",w=oo;break;case"focusout":y="blur",w=oo;break;case"beforeblur":case"afterblur":w=oo;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":w=ec;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":w=jh;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":w=Mh;break;case md:case gd:case vd:w=Ch;break;case yd:w=Oh;break;case"scroll":w=wh;break;case"wheel":w=Dh;break;case"copy":case"cut":case"paste":w=Eh;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":w=nc}var x=(t&4)!==0,j=!x&&e==="scroll",g=x?p!==null?p+"Capture":null:p;x=[];for(var m=d,v;m!==null;){v=m;var S=v.stateNode;if(v.tag===5&&S!==null&&(v=S,g!==null&&(S=Yr(m,g),S!=null&&x.push(ts(m,S,v)))),j)break;m=m.return}0<x.length&&(p=new w(p,y,null,n,f),h.push({event:p,listeners:x}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",w=e==="mouseout"||e==="pointerout",p&&n!==Ho&&(y=n.relatedTarget||n.fromElement)&&(zn(y)||y[Qt]))break e;if((w||p)&&(p=f.window===f?f:(p=f.ownerDocument)?p.defaultView||p.parentWindow:window,w?(y=n.relatedTarget||n.toElement,w=d,y=y?zn(y):null,y!==null&&(j=Dn(y),y!==j||y.tag!==5&&y.tag!==6)&&(y=null)):(w=null,y=d),w!==y)){if(x=ec,S="onMouseLeave",g="onMouseEnter",m="mouse",(e==="pointerout"||e==="pointerover")&&(x=nc,S="onPointerLeave",g="onPointerEnter",m="pointer"),j=w==null?p:Yn(w),v=y==null?p:Yn(y),p=new x(S,m+"leave",w,n,f),p.target=j,p.relatedTarget=v,S=null,zn(f)===d&&(x=new x(g,m+"enter",y,n,f),x.target=v,x.relatedTarget=j,S=x),j=S,w&&y)t:{for(x=w,g=y,m=0,v=x;v;v=Un(v))m++;for(v=0,S=g;S;S=Un(S))v++;for(;0<m-v;)x=Un(x),m--;for(;0<v-m;)g=Un(g),v--;for(;m--;){if(x===g||g!==null&&x===g.alternate)break t;x=Un(x),g=Un(g)}x=null}else x=null;w!==null&&pc(h,p,w,x,!1),y!==null&&j!==null&&pc(h,j,y,x,!0)}}e:{if(p=d?Yn(d):window,w=p.nodeName&&p.nodeName.toLowerCase(),w==="select"||w==="input"&&p.type==="file")var b=Yh;else if(ac(p))if(ud)b=qh;else{b=Jh;var N=Qh}else(w=p.nodeName)&&w.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(b=Xh);if(b&&(b=b(e,d))){cd(h,b,n,f);break e}N&&N(e,p,d),e==="focusout"&&(N=p._wrapperState)&&N.controlled&&p.type==="number"&&Oo(p,"number",p.value)}switch(N=d?Yn(d):window,e){case"focusin":(ac(N)||N.contentEditable==="true")&&(Gn=N,Xo=d,Br=null);break;case"focusout":Br=Xo=Gn=null;break;case"mousedown":qo=!0;break;case"contextmenu":case"mouseup":case"dragend":qo=!1,uc(h,n,f);break;case"selectionchange":if(tm)break;case"keydown":case"keyup":uc(h,n,f)}var C;if(Ji)e:{switch(e){case"compositionstart":var T="onCompositionStart";break e;case"compositionend":T="onCompositionEnd";break e;case"compositionupdate":T="onCompositionUpdate";break e}T=void 0}else Vn?id(e,n)&&(T="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(T="onCompositionStart");T&&(od&&n.locale!=="ko"&&(Vn||T!=="onCompositionStart"?T==="onCompositionEnd"&&Vn&&(C=ad()):(ln=f,Ki="value"in ln?ln.value:ln.textContent,Vn=!0)),N=ua(d,T),0<N.length&&(T=new tc(T,e,null,n,f),h.push({event:T,listeners:N}),C?T.data=C:(C=ld(n),C!==null&&(T.data=C)))),(C=Wh?Hh(e,n):Vh(e,n))&&(d=ua(d,"onBeforeInput"),0<d.length&&(f=new tc("onBeforeInput","beforeinput",null,n,f),h.push({event:f,listeners:d}),f.data=C))}wd(h,t)})}function ts(e,t,n){return{instance:e,listener:t,currentTarget:n}}function ua(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=Yr(e,n),o!=null&&r.unshift(ts(e,o,s)),o=Yr(e,t),o!=null&&r.push(ts(e,o,s))),e=e.return}return r}function Un(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function pc(e,t,n,r,s){for(var o=t._reactName,i=[];n!==null&&n!==r;){var l=n,c=l.alternate,d=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&d!==null&&(l=d,s?(c=Yr(n,o),c!=null&&i.unshift(ts(n,c,l))):s||(c=Yr(n,o),c!=null&&i.push(ts(n,c,l)))),n=n.return}i.length!==0&&e.push({event:t,listeners:i})}var am=/\r\n?/g,om=/\u0000|\uFFFD/g;function hc(e){return(typeof e=="string"?e:""+e).replace(am,`
38
+ `).replace(om,"")}function zs(e,t,n){if(t=hc(t),hc(e)!==t&&n)throw Error(O(425))}function da(){}var Zo=null,ei=null;function ti(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var ni=typeof setTimeout=="function"?setTimeout:void 0,im=typeof clearTimeout=="function"?clearTimeout:void 0,mc=typeof Promise=="function"?Promise:void 0,lm=typeof queueMicrotask=="function"?queueMicrotask:typeof mc<"u"?function(e){return mc.resolve(null).then(e).catch(cm)}:ni;function cm(e){setTimeout(function(){throw e})}function mo(e,t){var n=t,r=0;do{var s=n.nextSibling;if(e.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(r===0){e.removeChild(s),Xr(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);Xr(t)}function pn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function gc(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var gr=Math.random().toString(36).slice(2),Mt="__reactFiber$"+gr,ns="__reactProps$"+gr,Qt="__reactContainer$"+gr,ri="__reactEvents$"+gr,um="__reactListeners$"+gr,dm="__reactHandles$"+gr;function zn(e){var t=e[Mt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Qt]||n[Mt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=gc(e);e!==null;){if(n=e[Mt])return n;e=gc(e)}return t}e=n,n=e.parentNode}return null}function ps(e){return e=e[Mt]||e[Qt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Yn(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(O(33))}function La(e){return e[ns]||null}var si=[],Qn=-1;function Sn(e){return{current:e}}function Se(e){0>Qn||(e.current=si[Qn],si[Qn]=null,Qn--)}function xe(e,t){Qn++,si[Qn]=e.current,e.current=t}var xn={},Ge=Sn(xn),st=Sn(!1),$n=xn;function lr(e,t){var n=e.type.contextTypes;if(!n)return xn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},o;for(o in n)s[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function at(e){return e=e.childContextTypes,e!=null}function fa(){Se(st),Se(Ge)}function vc(e,t,n){if(Ge.current!==xn)throw Error(O(168));xe(Ge,t),xe(st,n)}function jd(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(O(108,Qp(e)||"Unknown",s));return Ne({},n,r)}function pa(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xn,$n=Ge.current,xe(Ge,e),xe(st,st.current),!0}function yc(e,t,n){var r=e.stateNode;if(!r)throw Error(O(169));n?(e=jd(e,t,$n),r.__reactInternalMemoizedMergedChildContext=e,Se(st),Se(Ge),xe(Ge,e)):Se(st),xe(st,n)}var Ht=null,Ma=!1,go=!1;function kd(e){Ht===null?Ht=[e]:Ht.push(e)}function fm(e){Ma=!0,kd(e)}function jn(){if(!go&&Ht!==null){go=!0;var e=0,t=he;try{var n=Ht;for(he=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Ht=null,Ma=!1}catch(s){throw Ht!==null&&(Ht=Ht.slice(e+1)),Yu(Wi,jn),s}finally{he=t,go=!1}}return null}var Jn=[],Xn=0,ha=null,ma=0,xt=[],wt=0,Ln=null,Vt=1,Gt="";function Nn(e,t){Jn[Xn++]=ma,Jn[Xn++]=ha,ha=e,ma=t}function bd(e,t,n){xt[wt++]=Vt,xt[wt++]=Gt,xt[wt++]=Ln,Ln=e;var r=Vt;e=Gt;var s=32-Pt(r)-1;r&=~(1<<s),n+=1;var o=32-Pt(t)+s;if(30<o){var i=s-s%5;o=(r&(1<<i)-1).toString(32),r>>=i,s-=i,Vt=1<<32-Pt(t)+s|n<<s|r,Gt=o+e}else Vt=1<<o|n<<s|r,Gt=e}function qi(e){e.return!==null&&(Nn(e,1),bd(e,1,0))}function Zi(e){for(;e===ha;)ha=Jn[--Xn],Jn[Xn]=null,ma=Jn[--Xn],Jn[Xn]=null;for(;e===Ln;)Ln=xt[--wt],xt[wt]=null,Gt=xt[--wt],xt[wt]=null,Vt=xt[--wt],xt[wt]=null}var ft=null,dt=null,je=!1,Rt=null;function Cd(e,t){var n=St(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function xc(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,ft=e,dt=pn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ft=e,dt=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Ln!==null?{id:Vt,overflow:Gt}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=St(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ft=e,dt=null,!0):!1;default:return!1}}function ai(e){return(e.mode&1)!==0&&(e.flags&128)===0}function oi(e){if(je){var t=dt;if(t){var n=t;if(!xc(e,t)){if(ai(e))throw Error(O(418));t=pn(n.nextSibling);var r=ft;t&&xc(e,t)?Cd(r,n):(e.flags=e.flags&-4097|2,je=!1,ft=e)}}else{if(ai(e))throw Error(O(418));e.flags=e.flags&-4097|2,je=!1,ft=e}}}function wc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ft=e}function Rs(e){if(e!==ft)return!1;if(!je)return wc(e),je=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!ti(e.type,e.memoizedProps)),t&&(t=dt)){if(ai(e))throw Nd(),Error(O(418));for(;t;)Cd(e,t),t=pn(t.nextSibling)}if(wc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){dt=pn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}dt=null}}else dt=ft?pn(e.stateNode.nextSibling):null;return!0}function Nd(){for(var e=dt;e;)e=pn(e.nextSibling)}function cr(){dt=ft=null,je=!1}function el(e){Rt===null?Rt=[e]:Rt.push(e)}var pm=Zt.ReactCurrentBatchConfig;function Nr(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(O(309));var r=n.stateNode}if(!r)throw Error(O(147,e));var s=r,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(i){var l=s.refs;i===null?delete l[o]:l[o]=i},t._stringRef=o,t)}if(typeof e!="string")throw Error(O(284));if(!n._owner)throw Error(O(290,e))}return e}function Ps(e,t){throw e=Object.prototype.toString.call(t),Error(O(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Sc(e){var t=e._init;return t(e._payload)}function Ed(e){function t(g,m){if(e){var v=g.deletions;v===null?(g.deletions=[m],g.flags|=16):v.push(m)}}function n(g,m){if(!e)return null;for(;m!==null;)t(g,m),m=m.sibling;return null}function r(g,m){for(g=new Map;m!==null;)m.key!==null?g.set(m.key,m):g.set(m.index,m),m=m.sibling;return g}function s(g,m){return g=vn(g,m),g.index=0,g.sibling=null,g}function o(g,m,v){return g.index=v,e?(v=g.alternate,v!==null?(v=v.index,v<m?(g.flags|=2,m):v):(g.flags|=2,m)):(g.flags|=1048576,m)}function i(g){return e&&g.alternate===null&&(g.flags|=2),g}function l(g,m,v,S){return m===null||m.tag!==6?(m=ko(v,g.mode,S),m.return=g,m):(m=s(m,v),m.return=g,m)}function c(g,m,v,S){var b=v.type;return b===Hn?f(g,m,v.props.children,S,v.key):m!==null&&(m.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===nn&&Sc(b)===m.type)?(S=s(m,v.props),S.ref=Nr(g,m,v),S.return=g,S):(S=qs(v.type,v.key,v.props,null,g.mode,S),S.ref=Nr(g,m,v),S.return=g,S)}function d(g,m,v,S){return m===null||m.tag!==4||m.stateNode.containerInfo!==v.containerInfo||m.stateNode.implementation!==v.implementation?(m=bo(v,g.mode,S),m.return=g,m):(m=s(m,v.children||[]),m.return=g,m)}function f(g,m,v,S,b){return m===null||m.tag!==7?(m=An(v,g.mode,S,b),m.return=g,m):(m=s(m,v),m.return=g,m)}function h(g,m,v){if(typeof m=="string"&&m!==""||typeof m=="number")return m=ko(""+m,g.mode,v),m.return=g,m;if(typeof m=="object"&&m!==null){switch(m.$$typeof){case ws:return v=qs(m.type,m.key,m.props,null,g.mode,v),v.ref=Nr(g,null,m),v.return=g,v;case Wn:return m=bo(m,g.mode,v),m.return=g,m;case nn:var S=m._init;return h(g,S(m._payload),v)}if(Ir(m)||Sr(m))return m=An(m,g.mode,v,null),m.return=g,m;Ps(g,m)}return null}function p(g,m,v,S){var b=m!==null?m.key:null;if(typeof v=="string"&&v!==""||typeof v=="number")return b!==null?null:l(g,m,""+v,S);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case ws:return v.key===b?c(g,m,v,S):null;case Wn:return v.key===b?d(g,m,v,S):null;case nn:return b=v._init,p(g,m,b(v._payload),S)}if(Ir(v)||Sr(v))return b!==null?null:f(g,m,v,S,null);Ps(g,v)}return null}function w(g,m,v,S,b){if(typeof S=="string"&&S!==""||typeof S=="number")return g=g.get(v)||null,l(m,g,""+S,b);if(typeof S=="object"&&S!==null){switch(S.$$typeof){case ws:return g=g.get(S.key===null?v:S.key)||null,c(m,g,S,b);case Wn:return g=g.get(S.key===null?v:S.key)||null,d(m,g,S,b);case nn:var N=S._init;return w(g,m,v,N(S._payload),b)}if(Ir(S)||Sr(S))return g=g.get(v)||null,f(m,g,S,b,null);Ps(m,S)}return null}function y(g,m,v,S){for(var b=null,N=null,C=m,T=m=0,E=null;C!==null&&T<v.length;T++){C.index>T?(E=C,C=null):E=C.sibling;var L=p(g,C,v[T],S);if(L===null){C===null&&(C=E);break}e&&C&&L.alternate===null&&t(g,C),m=o(L,m,T),N===null?b=L:N.sibling=L,N=L,C=E}if(T===v.length)return n(g,C),je&&Nn(g,T),b;if(C===null){for(;T<v.length;T++)C=h(g,v[T],S),C!==null&&(m=o(C,m,T),N===null?b=C:N.sibling=C,N=C);return je&&Nn(g,T),b}for(C=r(g,C);T<v.length;T++)E=w(C,g,T,v[T],S),E!==null&&(e&&E.alternate!==null&&C.delete(E.key===null?T:E.key),m=o(E,m,T),N===null?b=E:N.sibling=E,N=E);return e&&C.forEach(function(D){return t(g,D)}),je&&Nn(g,T),b}function x(g,m,v,S){var b=Sr(v);if(typeof b!="function")throw Error(O(150));if(v=b.call(v),v==null)throw Error(O(151));for(var N=b=null,C=m,T=m=0,E=null,L=v.next();C!==null&&!L.done;T++,L=v.next()){C.index>T?(E=C,C=null):E=C.sibling;var D=p(g,C,L.value,S);if(D===null){C===null&&(C=E);break}e&&C&&D.alternate===null&&t(g,C),m=o(D,m,T),N===null?b=D:N.sibling=D,N=D,C=E}if(L.done)return n(g,C),je&&Nn(g,T),b;if(C===null){for(;!L.done;T++,L=v.next())L=h(g,L.value,S),L!==null&&(m=o(L,m,T),N===null?b=L:N.sibling=L,N=L);return je&&Nn(g,T),b}for(C=r(g,C);!L.done;T++,L=v.next())L=w(C,g,T,L.value,S),L!==null&&(e&&L.alternate!==null&&C.delete(L.key===null?T:L.key),m=o(L,m,T),N===null?b=L:N.sibling=L,N=L);return e&&C.forEach(function(G){return t(g,G)}),je&&Nn(g,T),b}function j(g,m,v,S){if(typeof v=="object"&&v!==null&&v.type===Hn&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case ws:e:{for(var b=v.key,N=m;N!==null;){if(N.key===b){if(b=v.type,b===Hn){if(N.tag===7){n(g,N.sibling),m=s(N,v.props.children),m.return=g,g=m;break e}}else if(N.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===nn&&Sc(b)===N.type){n(g,N.sibling),m=s(N,v.props),m.ref=Nr(g,N,v),m.return=g,g=m;break e}n(g,N);break}else t(g,N);N=N.sibling}v.type===Hn?(m=An(v.props.children,g.mode,S,v.key),m.return=g,g=m):(S=qs(v.type,v.key,v.props,null,g.mode,S),S.ref=Nr(g,m,v),S.return=g,g=S)}return i(g);case Wn:e:{for(N=v.key;m!==null;){if(m.key===N)if(m.tag===4&&m.stateNode.containerInfo===v.containerInfo&&m.stateNode.implementation===v.implementation){n(g,m.sibling),m=s(m,v.children||[]),m.return=g,g=m;break e}else{n(g,m);break}else t(g,m);m=m.sibling}m=bo(v,g.mode,S),m.return=g,g=m}return i(g);case nn:return N=v._init,j(g,m,N(v._payload),S)}if(Ir(v))return y(g,m,v,S);if(Sr(v))return x(g,m,v,S);Ps(g,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,m!==null&&m.tag===6?(n(g,m.sibling),m=s(m,v),m.return=g,g=m):(n(g,m),m=ko(v,g.mode,S),m.return=g,g=m),i(g)):n(g,m)}return j}var ur=Ed(!0),Td=Ed(!1),ga=Sn(null),va=null,qn=null,tl=null;function nl(){tl=qn=va=null}function rl(e){var t=ga.current;Se(ga),e._currentValue=t}function ii(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function ar(e,t){va=e,tl=qn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(rt=!0),e.firstContext=null)}function kt(e){var t=e._currentValue;if(tl!==e)if(e={context:e,memoizedValue:t,next:null},qn===null){if(va===null)throw Error(O(308));qn=e,va.dependencies={lanes:0,firstContext:e}}else qn=qn.next=e;return t}var Rn=null;function sl(e){Rn===null?Rn=[e]:Rn.push(e)}function zd(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,sl(t)):(n.next=s.next,s.next=n),t.interleaved=n,Jt(e,r)}function Jt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var rn=!1;function al(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Rd(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Kt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function hn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ue&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Jt(e,n)}return s=r.interleaved,s===null?(t.next=t,sl(r)):(t.next=s.next,s.next=t),r.interleaved=t,Jt(e,n)}function Gs(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Hi(e,n)}}function jc(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?s=o=i:o=o.next=i,n=n.next}while(n!==null);o===null?s=o=t:o=o.next=t}else s=o=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ya(e,t,n,r){var s=e.updateQueue;rn=!1;var o=s.firstBaseUpdate,i=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,d=c.next;c.next=null,i===null?o=d:i.next=d,i=c;var f=e.alternate;f!==null&&(f=f.updateQueue,l=f.lastBaseUpdate,l!==i&&(l===null?f.firstBaseUpdate=d:l.next=d,f.lastBaseUpdate=c))}if(o!==null){var h=s.baseState;i=0,f=d=c=null,l=o;do{var p=l.lane,w=l.eventTime;if((r&p)===p){f!==null&&(f=f.next={eventTime:w,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var y=e,x=l;switch(p=t,w=n,x.tag){case 1:if(y=x.payload,typeof y=="function"){h=y.call(w,h,p);break e}h=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=x.payload,p=typeof y=="function"?y.call(w,h,p):y,p==null)break e;h=Ne({},h,p);break e;case 2:rn=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else w={eventTime:w,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},f===null?(d=f=w,c=h):f=f.next=w,i|=p;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;p=l,l=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(f===null&&(c=h),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=f,t=s.shared.interleaved,t!==null){s=t;do i|=s.lane,s=s.next;while(s!==t)}else o===null&&(s.shared.lanes=0);Fn|=i,e.lanes=i,e.memoizedState=h}}function kc(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error(O(191,s));s.call(r)}}}var hs={},Bt=Sn(hs),rs=Sn(hs),ss=Sn(hs);function Pn(e){if(e===hs)throw Error(O(174));return e}function ol(e,t){switch(xe(ss,t),xe(rs,e),xe(Bt,hs),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Do(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Do(t,e)}Se(Bt),xe(Bt,t)}function dr(){Se(Bt),Se(rs),Se(ss)}function Pd(e){Pn(ss.current);var t=Pn(Bt.current),n=Do(t,e.type);t!==n&&(xe(rs,e),xe(Bt,n))}function il(e){rs.current===e&&(Se(Bt),Se(rs))}var be=Sn(0);function xa(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var vo=[];function ll(){for(var e=0;e<vo.length;e++)vo[e]._workInProgressVersionPrimary=null;vo.length=0}var Ks=Zt.ReactCurrentDispatcher,yo=Zt.ReactCurrentBatchConfig,Mn=0,Ce=null,_e=null,Me=null,wa=!1,Dr=!1,as=0,hm=0;function We(){throw Error(O(321))}function cl(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!_t(e[n],t[n]))return!1;return!0}function ul(e,t,n,r,s,o){if(Mn=o,Ce=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Ks.current=e===null||e.memoizedState===null?ym:xm,e=n(r,s),Dr){o=0;do{if(Dr=!1,as=0,25<=o)throw Error(O(301));o+=1,Me=_e=null,t.updateQueue=null,Ks.current=wm,e=n(r,s)}while(Dr)}if(Ks.current=Sa,t=_e!==null&&_e.next!==null,Mn=0,Me=_e=Ce=null,wa=!1,t)throw Error(O(300));return e}function dl(){var e=as!==0;return as=0,e}function Lt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Me===null?Ce.memoizedState=Me=e:Me=Me.next=e,Me}function bt(){if(_e===null){var e=Ce.alternate;e=e!==null?e.memoizedState:null}else e=_e.next;var t=Me===null?Ce.memoizedState:Me.next;if(t!==null)Me=t,_e=e;else{if(e===null)throw Error(O(310));_e=e,e={memoizedState:_e.memoizedState,baseState:_e.baseState,baseQueue:_e.baseQueue,queue:_e.queue,next:null},Me===null?Ce.memoizedState=Me=e:Me=Me.next=e}return Me}function os(e,t){return typeof t=="function"?t(e):t}function xo(e){var t=bt(),n=t.queue;if(n===null)throw Error(O(311));n.lastRenderedReducer=e;var r=_e,s=r.baseQueue,o=n.pending;if(o!==null){if(s!==null){var i=s.next;s.next=o.next,o.next=i}r.baseQueue=s=o,n.pending=null}if(s!==null){o=s.next,r=r.baseState;var l=i=null,c=null,d=o;do{var f=d.lane;if((Mn&f)===f)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),r=d.hasEagerState?d.eagerState:e(r,d.action);else{var h={lane:f,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=h,i=r):c=c.next=h,Ce.lanes|=f,Fn|=f}d=d.next}while(d!==null&&d!==o);c===null?i=r:c.next=l,_t(r,t.memoizedState)||(rt=!0),t.memoizedState=r,t.baseState=i,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do o=s.lane,Ce.lanes|=o,Fn|=o,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function wo(e){var t=bt(),n=t.queue;if(n===null)throw Error(O(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,o=t.memoizedState;if(s!==null){n.pending=null;var i=s=s.next;do o=e(o,i.action),i=i.next;while(i!==s);_t(o,t.memoizedState)||(rt=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Id(){}function _d(e,t){var n=Ce,r=bt(),s=t(),o=!_t(r.memoizedState,s);if(o&&(r.memoizedState=s,rt=!0),r=r.queue,fl(Ld.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||Me!==null&&Me.memoizedState.tag&1){if(n.flags|=2048,is(9,$d.bind(null,n,r,s,t),void 0,null),Fe===null)throw Error(O(349));Mn&30||Ad(n,t,s)}return s}function Ad(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ce.updateQueue,t===null?(t={lastEffect:null,stores:null},Ce.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function $d(e,t,n,r){t.value=n,t.getSnapshot=r,Md(t)&&Fd(e)}function Ld(e,t,n){return n(function(){Md(t)&&Fd(e)})}function Md(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!_t(e,n)}catch{return!0}}function Fd(e){var t=Jt(e,1);t!==null&&It(t,e,1,-1)}function bc(e){var t=Lt();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:os,lastRenderedState:e},t.queue=e,e=e.dispatch=vm.bind(null,Ce,e),[t.memoizedState,e]}function is(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Ce.updateQueue,t===null?(t={lastEffect:null,stores:null},Ce.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function Od(){return bt().memoizedState}function Ys(e,t,n,r){var s=Lt();Ce.flags|=e,s.memoizedState=is(1|t,n,void 0,r===void 0?null:r)}function Fa(e,t,n,r){var s=bt();r=r===void 0?null:r;var o=void 0;if(_e!==null){var i=_e.memoizedState;if(o=i.destroy,r!==null&&cl(r,i.deps)){s.memoizedState=is(t,n,o,r);return}}Ce.flags|=e,s.memoizedState=is(1|t,n,o,r)}function Cc(e,t){return Ys(8390656,8,e,t)}function fl(e,t){return Fa(2048,8,e,t)}function Bd(e,t){return Fa(4,2,e,t)}function Dd(e,t){return Fa(4,4,e,t)}function Ud(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Wd(e,t,n){return n=n!=null?n.concat([e]):null,Fa(4,4,Ud.bind(null,t,e),n)}function pl(){}function Hd(e,t){var n=bt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&cl(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Vd(e,t){var n=bt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&cl(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Gd(e,t,n){return Mn&21?(_t(n,t)||(n=Xu(),Ce.lanes|=n,Fn|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,rt=!0),e.memoizedState=n)}function mm(e,t){var n=he;he=n!==0&&4>n?n:4,e(!0);var r=yo.transition;yo.transition={};try{e(!1),t()}finally{he=n,yo.transition=r}}function Kd(){return bt().memoizedState}function gm(e,t,n){var r=gn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Yd(e))Qd(t,n);else if(n=zd(e,t,n,r),n!==null){var s=Xe();It(n,e,r,s),Jd(n,t,r)}}function vm(e,t,n){var r=gn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Yd(e))Qd(t,s);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var i=t.lastRenderedState,l=o(i,n);if(s.hasEagerState=!0,s.eagerState=l,_t(l,i)){var c=t.interleaved;c===null?(s.next=s,sl(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=zd(e,t,s,r),n!==null&&(s=Xe(),It(n,e,r,s),Jd(n,t,r))}}function Yd(e){var t=e.alternate;return e===Ce||t!==null&&t===Ce}function Qd(e,t){Dr=wa=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Jd(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Hi(e,n)}}var Sa={readContext:kt,useCallback:We,useContext:We,useEffect:We,useImperativeHandle:We,useInsertionEffect:We,useLayoutEffect:We,useMemo:We,useReducer:We,useRef:We,useState:We,useDebugValue:We,useDeferredValue:We,useTransition:We,useMutableSource:We,useSyncExternalStore:We,useId:We,unstable_isNewReconciler:!1},ym={readContext:kt,useCallback:function(e,t){return Lt().memoizedState=[e,t===void 0?null:t],e},useContext:kt,useEffect:Cc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ys(4194308,4,Ud.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ys(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ys(4,2,e,t)},useMemo:function(e,t){var n=Lt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Lt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=gm.bind(null,Ce,e),[r.memoizedState,e]},useRef:function(e){var t=Lt();return e={current:e},t.memoizedState=e},useState:bc,useDebugValue:pl,useDeferredValue:function(e){return Lt().memoizedState=e},useTransition:function(){var e=bc(!1),t=e[0];return e=mm.bind(null,e[1]),Lt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Ce,s=Lt();if(je){if(n===void 0)throw Error(O(407));n=n()}else{if(n=t(),Fe===null)throw Error(O(349));Mn&30||Ad(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,Cc(Ld.bind(null,r,o,e),[e]),r.flags|=2048,is(9,$d.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Lt(),t=Fe.identifierPrefix;if(je){var n=Gt,r=Vt;n=(r&~(1<<32-Pt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=as++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=hm++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},xm={readContext:kt,useCallback:Hd,useContext:kt,useEffect:fl,useImperativeHandle:Wd,useInsertionEffect:Bd,useLayoutEffect:Dd,useMemo:Vd,useReducer:xo,useRef:Od,useState:function(){return xo(os)},useDebugValue:pl,useDeferredValue:function(e){var t=bt();return Gd(t,_e.memoizedState,e)},useTransition:function(){var e=xo(os)[0],t=bt().memoizedState;return[e,t]},useMutableSource:Id,useSyncExternalStore:_d,useId:Kd,unstable_isNewReconciler:!1},wm={readContext:kt,useCallback:Hd,useContext:kt,useEffect:fl,useImperativeHandle:Wd,useInsertionEffect:Bd,useLayoutEffect:Dd,useMemo:Vd,useReducer:wo,useRef:Od,useState:function(){return wo(os)},useDebugValue:pl,useDeferredValue:function(e){var t=bt();return _e===null?t.memoizedState=e:Gd(t,_e.memoizedState,e)},useTransition:function(){var e=wo(os)[0],t=bt().memoizedState;return[e,t]},useMutableSource:Id,useSyncExternalStore:_d,useId:Kd,unstable_isNewReconciler:!1};function Tt(e,t){if(e&&e.defaultProps){t=Ne({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function li(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Ne({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Oa={isMounted:function(e){return(e=e._reactInternals)?Dn(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Xe(),s=gn(e),o=Kt(r,s);o.payload=t,n!=null&&(o.callback=n),t=hn(e,o,s),t!==null&&(It(t,e,s,r),Gs(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Xe(),s=gn(e),o=Kt(r,s);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=hn(e,o,s),t!==null&&(It(t,e,s,r),Gs(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Xe(),r=gn(e),s=Kt(n,r);s.tag=2,t!=null&&(s.callback=t),t=hn(e,s,r),t!==null&&(It(t,e,r,n),Gs(t,e,r))}};function Nc(e,t,n,r,s,o,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,i):t.prototype&&t.prototype.isPureReactComponent?!Zr(n,r)||!Zr(s,o):!0}function Xd(e,t,n){var r=!1,s=xn,o=t.contextType;return typeof o=="object"&&o!==null?o=kt(o):(s=at(t)?$n:Ge.current,r=t.contextTypes,o=(r=r!=null)?lr(e,s):xn),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Oa,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function Ec(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Oa.enqueueReplaceState(t,t.state,null)}function ci(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},al(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=kt(o):(o=at(t)?$n:Ge.current,s.context=lr(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(li(e,t,o,n),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&Oa.enqueueReplaceState(s,s.state,null),ya(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function fr(e,t){try{var n="",r=t;do n+=Yp(r),r=r.return;while(r);var s=n}catch(o){s=`
39
+ Error generating stack: `+o.message+`
40
+ `+o.stack}return{value:e,source:t,stack:s,digest:null}}function So(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function ui(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Sm=typeof WeakMap=="function"?WeakMap:Map;function qd(e,t,n){n=Kt(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){ka||(ka=!0,wi=r),ui(e,t)},n}function Zd(e,t,n){n=Kt(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var s=t.value;n.payload=function(){return r(s)},n.callback=function(){ui(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){ui(e,t),typeof r!="function"&&(mn===null?mn=new Set([this]):mn.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function Tc(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Sm;var s=new Set;r.set(t,s)}else s=r.get(t),s===void 0&&(s=new Set,r.set(t,s));s.has(n)||(s.add(n),e=$m.bind(null,e,t,n),t.then(e,e))}function zc(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function Rc(e,t,n,r,s){return e.mode&1?(e.flags|=65536,e.lanes=s,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Kt(-1,1),t.tag=2,hn(n,t,1))),n.lanes|=1),e)}var jm=Zt.ReactCurrentOwner,rt=!1;function Qe(e,t,n,r){t.child=e===null?Td(t,null,n,r):ur(t,e.child,n,r)}function Pc(e,t,n,r,s){n=n.render;var o=t.ref;return ar(t,s),r=ul(e,t,n,r,o,s),n=dl(),e!==null&&!rt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,Xt(e,t,s)):(je&&n&&qi(t),t.flags|=1,Qe(e,t,r,s),t.child)}function Ic(e,t,n,r,s){if(e===null){var o=n.type;return typeof o=="function"&&!Sl(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,ef(e,t,o,r,s)):(e=qs(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&s)){var i=o.memoizedProps;if(n=n.compare,n=n!==null?n:Zr,n(i,r)&&e.ref===t.ref)return Xt(e,t,s)}return t.flags|=1,e=vn(o,r),e.ref=t.ref,e.return=t,t.child=e}function ef(e,t,n,r,s){if(e!==null){var o=e.memoizedProps;if(Zr(o,r)&&e.ref===t.ref)if(rt=!1,t.pendingProps=r=o,(e.lanes&s)!==0)e.flags&131072&&(rt=!0);else return t.lanes=e.lanes,Xt(e,t,s)}return di(e,t,n,r,s)}function tf(e,t,n){var r=t.pendingProps,s=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},xe(er,ut),ut|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,xe(er,ut),ut|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,xe(er,ut),ut|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,xe(er,ut),ut|=r;return Qe(e,t,s,n),t.child}function nf(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function di(e,t,n,r,s){var o=at(n)?$n:Ge.current;return o=lr(t,o),ar(t,s),n=ul(e,t,n,r,o,s),r=dl(),e!==null&&!rt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,Xt(e,t,s)):(je&&r&&qi(t),t.flags|=1,Qe(e,t,n,s),t.child)}function _c(e,t,n,r,s){if(at(n)){var o=!0;pa(t)}else o=!1;if(ar(t,s),t.stateNode===null)Qs(e,t),Xd(t,n,r),ci(t,n,r,s),r=!0;else if(e===null){var i=t.stateNode,l=t.memoizedProps;i.props=l;var c=i.context,d=n.contextType;typeof d=="object"&&d!==null?d=kt(d):(d=at(n)?$n:Ge.current,d=lr(t,d));var f=n.getDerivedStateFromProps,h=typeof f=="function"||typeof i.getSnapshotBeforeUpdate=="function";h||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==r||c!==d)&&Ec(t,i,r,d),rn=!1;var p=t.memoizedState;i.state=p,ya(t,r,i,s),c=t.memoizedState,l!==r||p!==c||st.current||rn?(typeof f=="function"&&(li(t,n,f,r),c=t.memoizedState),(l=rn||Nc(t,n,l,r,p,c,d))?(h||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(t.flags|=4194308)):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),i.props=r,i.state=c,i.context=d,r=l):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,Rd(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:Tt(t.type,l),i.props=d,h=t.pendingProps,p=i.context,c=n.contextType,typeof c=="object"&&c!==null?c=kt(c):(c=at(n)?$n:Ge.current,c=lr(t,c));var w=n.getDerivedStateFromProps;(f=typeof w=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==h||p!==c)&&Ec(t,i,r,c),rn=!1,p=t.memoizedState,i.state=p,ya(t,r,i,s);var y=t.memoizedState;l!==h||p!==y||st.current||rn?(typeof w=="function"&&(li(t,n,w,r),y=t.memoizedState),(d=rn||Nc(t,n,d,r,p,y,c)||!1)?(f||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,y,c),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,y,c)),typeof i.componentDidUpdate=="function"&&(t.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof i.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=y),i.props=r,i.state=y,i.context=c,r=d):(typeof i.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return fi(e,t,n,r,o,s)}function fi(e,t,n,r,s,o){nf(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return s&&yc(t,n,!1),Xt(e,t,o);r=t.stateNode,jm.current=t;var l=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=ur(t,e.child,null,o),t.child=ur(t,null,l,o)):Qe(e,t,l,o),t.memoizedState=r.state,s&&yc(t,n,!0),t.child}function rf(e){var t=e.stateNode;t.pendingContext?vc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&vc(e,t.context,!1),ol(e,t.containerInfo)}function Ac(e,t,n,r,s){return cr(),el(s),t.flags|=256,Qe(e,t,n,r),t.child}var pi={dehydrated:null,treeContext:null,retryLane:0};function hi(e){return{baseLanes:e,cachePool:null,transitions:null}}function sf(e,t,n){var r=t.pendingProps,s=be.current,o=!1,i=(t.flags&128)!==0,l;if((l=i)||(l=e!==null&&e.memoizedState===null?!1:(s&2)!==0),l?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),xe(be,s&1),e===null)return oi(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(i=r.children,e=r.fallback,o?(r=t.mode,o=t.child,i={mode:"hidden",children:i},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=i):o=Ua(i,r,0,null),e=An(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=hi(n),t.memoizedState=pi,e):hl(t,i));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return km(e,t,i,r,l,s,n);if(o){o=r.fallback,i=t.mode,s=e.child,l=s.sibling;var c={mode:"hidden",children:r.children};return!(i&1)&&t.child!==s?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=vn(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?o=vn(l,o):(o=An(o,i,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,i=e.child.memoizedState,i=i===null?hi(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},o.memoizedState=i,o.childLanes=e.childLanes&~n,t.memoizedState=pi,r}return o=e.child,e=o.sibling,r=vn(o,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function hl(e,t){return t=Ua({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Is(e,t,n,r){return r!==null&&el(r),ur(t,e.child,null,n),e=hl(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function km(e,t,n,r,s,o,i){if(n)return t.flags&256?(t.flags&=-257,r=So(Error(O(422))),Is(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,s=t.mode,r=Ua({mode:"visible",children:r.children},s,0,null),o=An(o,s,i,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&ur(t,e.child,null,i),t.child.memoizedState=hi(i),t.memoizedState=pi,o);if(!(t.mode&1))return Is(e,t,i,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(O(419)),r=So(o,r,void 0),Is(e,t,i,r)}if(l=(i&e.childLanes)!==0,rt||l){if(r=Fe,r!==null){switch(i&-i){case 4:s=2;break;case 16:s=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:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(r.suspendedLanes|i)?0:s,s!==0&&s!==o.retryLane&&(o.retryLane=s,Jt(e,s),It(r,e,s,-1))}return wl(),r=So(Error(O(421))),Is(e,t,i,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=Lm.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,dt=pn(s.nextSibling),ft=t,je=!0,Rt=null,e!==null&&(xt[wt++]=Vt,xt[wt++]=Gt,xt[wt++]=Ln,Vt=e.id,Gt=e.overflow,Ln=t),t=hl(t,r.children),t.flags|=4096,t)}function $c(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ii(e.return,t,n)}function jo(e,t,n,r,s){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=s)}function af(e,t,n){var r=t.pendingProps,s=r.revealOrder,o=r.tail;if(Qe(e,t,r.children,n),r=be.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&$c(e,n,t);else if(e.tag===19)$c(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(xe(be,r),!(t.mode&1))t.memoizedState=null;else switch(s){case"forwards":for(n=t.child,s=null;n!==null;)e=n.alternate,e!==null&&xa(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),jo(t,!1,s,n,o);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&xa(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}jo(t,!0,n,null,o);break;case"together":jo(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Qs(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Xt(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Fn|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(O(153));if(t.child!==null){for(e=t.child,n=vn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=vn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function bm(e,t,n){switch(t.tag){case 3:rf(t),cr();break;case 5:Pd(t);break;case 1:at(t.type)&&pa(t);break;case 4:ol(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;xe(ga,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(xe(be,be.current&1),t.flags|=128,null):n&t.child.childLanes?sf(e,t,n):(xe(be,be.current&1),e=Xt(e,t,n),e!==null?e.sibling:null);xe(be,be.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return af(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),xe(be,be.current),r)break;return null;case 22:case 23:return t.lanes=0,tf(e,t,n)}return Xt(e,t,n)}var of,mi,lf,cf;of=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};mi=function(){};lf=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Pn(Bt.current);var o=null;switch(n){case"input":s=Mo(e,s),r=Mo(e,r),o=[];break;case"select":s=Ne({},s,{value:void 0}),r=Ne({},r,{value:void 0}),o=[];break;case"textarea":s=Bo(e,s),r=Bo(e,r),o=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=da)}Uo(n,r);var i;n=null;for(d in s)if(!r.hasOwnProperty(d)&&s.hasOwnProperty(d)&&s[d]!=null)if(d==="style"){var l=s[d];for(i in l)l.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(Gr.hasOwnProperty(d)?o||(o=[]):(o=o||[]).push(d,null));for(d in r){var c=r[d];if(l=s!=null?s[d]:void 0,r.hasOwnProperty(d)&&c!==l&&(c!=null||l!=null))if(d==="style")if(l){for(i in l)!l.hasOwnProperty(i)||c&&c.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in c)c.hasOwnProperty(i)&&l[i]!==c[i]&&(n||(n={}),n[i]=c[i])}else n||(o||(o=[]),o.push(d,n)),n=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(o=o||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(o=o||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(Gr.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&we("scroll",e),o||l===c||(o=[])):(o=o||[]).push(d,c))}n&&(o=o||[]).push("style",n);var d=o;(t.updateQueue=d)&&(t.flags|=4)}};cf=function(e,t,n,r){n!==r&&(t.flags|=4)};function Er(e,t){if(!je)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function He(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Cm(e,t,n){var r=t.pendingProps;switch(Zi(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return He(t),null;case 1:return at(t.type)&&fa(),He(t),null;case 3:return r=t.stateNode,dr(),Se(st),Se(Ge),ll(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Rs(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Rt!==null&&(ki(Rt),Rt=null))),mi(e,t),He(t),null;case 5:il(t);var s=Pn(ss.current);if(n=t.type,e!==null&&t.stateNode!=null)lf(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(O(166));return He(t),null}if(e=Pn(Bt.current),Rs(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[Mt]=t,r[ns]=o,e=(t.mode&1)!==0,n){case"dialog":we("cancel",r),we("close",r);break;case"iframe":case"object":case"embed":we("load",r);break;case"video":case"audio":for(s=0;s<Ar.length;s++)we(Ar[s],r);break;case"source":we("error",r);break;case"img":case"image":case"link":we("error",r),we("load",r);break;case"details":we("toggle",r);break;case"input":Hl(r,o),we("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},we("invalid",r);break;case"textarea":Gl(r,o),we("invalid",r)}Uo(n,o),s=null;for(var i in o)if(o.hasOwnProperty(i)){var l=o[i];i==="children"?typeof l=="string"?r.textContent!==l&&(o.suppressHydrationWarning!==!0&&zs(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&zs(r.textContent,l,e),s=["children",""+l]):Gr.hasOwnProperty(i)&&l!=null&&i==="onScroll"&&we("scroll",r)}switch(n){case"input":Ss(r),Vl(r,o,!0);break;case"textarea":Ss(r),Kl(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=da)}r=s,t.updateQueue=r,r!==null&&(t.flags|=4)}else{i=s.nodeType===9?s:s.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Lu(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[Mt]=t,e[ns]=r,of(e,t,!1,!1),t.stateNode=e;e:{switch(i=Wo(n,r),n){case"dialog":we("cancel",e),we("close",e),s=r;break;case"iframe":case"object":case"embed":we("load",e),s=r;break;case"video":case"audio":for(s=0;s<Ar.length;s++)we(Ar[s],e);s=r;break;case"source":we("error",e),s=r;break;case"img":case"image":case"link":we("error",e),we("load",e),s=r;break;case"details":we("toggle",e),s=r;break;case"input":Hl(e,r),s=Mo(e,r),we("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=Ne({},r,{value:void 0}),we("invalid",e);break;case"textarea":Gl(e,r),s=Bo(e,r),we("invalid",e);break;default:s=r}Uo(n,s),l=s;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?Ou(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&Mu(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Kr(e,c):typeof c=="number"&&Kr(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Gr.hasOwnProperty(o)?c!=null&&o==="onScroll"&&we("scroll",e):c!=null&&Fi(e,o,c,i))}switch(n){case"input":Ss(e),Vl(e,r,!1);break;case"textarea":Ss(e),Kl(e);break;case"option":r.value!=null&&e.setAttribute("value",""+yn(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?tr(e,!!r.multiple,o,!1):r.defaultValue!=null&&tr(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=da)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return He(t),null;case 6:if(e&&t.stateNode!=null)cf(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(O(166));if(n=Pn(ss.current),Pn(Bt.current),Rs(t)){if(r=t.stateNode,n=t.memoizedProps,r[Mt]=t,(o=r.nodeValue!==n)&&(e=ft,e!==null))switch(e.tag){case 3:zs(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&zs(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Mt]=t,t.stateNode=r}return He(t),null;case 13:if(Se(be),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(je&&dt!==null&&t.mode&1&&!(t.flags&128))Nd(),cr(),t.flags|=98560,o=!1;else if(o=Rs(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(O(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(O(317));o[Mt]=t}else cr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;He(t),o=!1}else Rt!==null&&(ki(Rt),Rt=null),o=!0;if(!o)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||be.current&1?Ae===0&&(Ae=3):wl())),t.updateQueue!==null&&(t.flags|=4),He(t),null);case 4:return dr(),mi(e,t),e===null&&es(t.stateNode.containerInfo),He(t),null;case 10:return rl(t.type._context),He(t),null;case 17:return at(t.type)&&fa(),He(t),null;case 19:if(Se(be),o=t.memoizedState,o===null)return He(t),null;if(r=(t.flags&128)!==0,i=o.rendering,i===null)if(r)Er(o,!1);else{if(Ae!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=xa(e),i!==null){for(t.flags|=128,Er(o,!1),r=i.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)o=n,e=r,o.flags&=14680066,i=o.alternate,i===null?(o.childLanes=0,o.lanes=e,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=i.childLanes,o.lanes=i.lanes,o.child=i.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=i.memoizedProps,o.memoizedState=i.memoizedState,o.updateQueue=i.updateQueue,o.type=i.type,e=i.dependencies,o.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return xe(be,be.current&1|2),t.child}e=e.sibling}o.tail!==null&&Te()>pr&&(t.flags|=128,r=!0,Er(o,!1),t.lanes=4194304)}else{if(!r)if(e=xa(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Er(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!je)return He(t),null}else 2*Te()-o.renderingStartTime>pr&&n!==1073741824&&(t.flags|=128,r=!0,Er(o,!1),t.lanes=4194304);o.isBackwards?(i.sibling=t.child,t.child=i):(n=o.last,n!==null?n.sibling=i:t.child=i,o.last=i)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=Te(),t.sibling=null,n=be.current,xe(be,r?n&1|2:n&1),t):(He(t),null);case 22:case 23:return xl(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ut&1073741824&&(He(t),t.subtreeFlags&6&&(t.flags|=8192)):He(t),null;case 24:return null;case 25:return null}throw Error(O(156,t.tag))}function Nm(e,t){switch(Zi(t),t.tag){case 1:return at(t.type)&&fa(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return dr(),Se(st),Se(Ge),ll(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return il(t),null;case 13:if(Se(be),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(O(340));cr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Se(be),null;case 4:return dr(),null;case 10:return rl(t.type._context),null;case 22:case 23:return xl(),null;case 24:return null;default:return null}}var _s=!1,Ve=!1,Em=typeof WeakSet=="function"?WeakSet:Set,Y=null;function Zn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ee(e,t,r)}else n.current=null}function gi(e,t,n){try{n()}catch(r){Ee(e,t,r)}}var Lc=!1;function Tm(e,t){if(Zo=la,e=pd(),Xi(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,l=-1,c=-1,d=0,f=0,h=e,p=null;t:for(;;){for(var w;h!==n||s!==0&&h.nodeType!==3||(l=i+s),h!==o||r!==0&&h.nodeType!==3||(c=i+r),h.nodeType===3&&(i+=h.nodeValue.length),(w=h.firstChild)!==null;)p=h,h=w;for(;;){if(h===e)break t;if(p===n&&++d===s&&(l=i),p===o&&++f===r&&(c=i),(w=h.nextSibling)!==null)break;h=p,p=h.parentNode}h=w}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(ei={focusedElem:e,selectionRange:n},la=!1,Y=t;Y!==null;)if(t=Y,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Y=e;else for(;Y!==null;){t=Y;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var x=y.memoizedProps,j=y.memoizedState,g=t.stateNode,m=g.getSnapshotBeforeUpdate(t.elementType===t.type?x:Tt(t.type,x),j);g.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(O(163))}}catch(S){Ee(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,Y=e;break}Y=t.return}return y=Lc,Lc=!1,y}function Ur(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var o=s.destroy;s.destroy=void 0,o!==void 0&&gi(t,n,o)}s=s.next}while(s!==r)}}function Ba(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function vi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function uf(e){var t=e.alternate;t!==null&&(e.alternate=null,uf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Mt],delete t[ns],delete t[ri],delete t[um],delete t[dm])),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 df(e){return e.tag===5||e.tag===3||e.tag===4}function Mc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||df(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 yi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=da));else if(r!==4&&(e=e.child,e!==null))for(yi(e,t,n),e=e.sibling;e!==null;)yi(e,t,n),e=e.sibling}function xi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(xi(e,t,n),e=e.sibling;e!==null;)xi(e,t,n),e=e.sibling}var Be=null,zt=!1;function tn(e,t,n){for(n=n.child;n!==null;)ff(e,t,n),n=n.sibling}function ff(e,t,n){if(Ot&&typeof Ot.onCommitFiberUnmount=="function")try{Ot.onCommitFiberUnmount(Ia,n)}catch{}switch(n.tag){case 5:Ve||Zn(n,t);case 6:var r=Be,s=zt;Be=null,tn(e,t,n),Be=r,zt=s,Be!==null&&(zt?(e=Be,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Be.removeChild(n.stateNode));break;case 18:Be!==null&&(zt?(e=Be,n=n.stateNode,e.nodeType===8?mo(e.parentNode,n):e.nodeType===1&&mo(e,n),Xr(e)):mo(Be,n.stateNode));break;case 4:r=Be,s=zt,Be=n.stateNode.containerInfo,zt=!0,tn(e,t,n),Be=r,zt=s;break;case 0:case 11:case 14:case 15:if(!Ve&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var o=s,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&gi(n,t,i),s=s.next}while(s!==r)}tn(e,t,n);break;case 1:if(!Ve&&(Zn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Ee(n,t,l)}tn(e,t,n);break;case 21:tn(e,t,n);break;case 22:n.mode&1?(Ve=(r=Ve)||n.memoizedState!==null,tn(e,t,n),Ve=r):tn(e,t,n);break;default:tn(e,t,n)}}function Fc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Em),t.forEach(function(r){var s=Mm.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Et(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var o=e,i=t,l=i;e:for(;l!==null;){switch(l.tag){case 5:Be=l.stateNode,zt=!1;break e;case 3:Be=l.stateNode.containerInfo,zt=!0;break e;case 4:Be=l.stateNode.containerInfo,zt=!0;break e}l=l.return}if(Be===null)throw Error(O(160));ff(o,i,s),Be=null,zt=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(d){Ee(s,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)pf(t,e),t=t.sibling}function pf(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Et(t,e),$t(e),r&4){try{Ur(3,e,e.return),Ba(3,e)}catch(x){Ee(e,e.return,x)}try{Ur(5,e,e.return)}catch(x){Ee(e,e.return,x)}}break;case 1:Et(t,e),$t(e),r&512&&n!==null&&Zn(n,n.return);break;case 5:if(Et(t,e),$t(e),r&512&&n!==null&&Zn(n,n.return),e.flags&32){var s=e.stateNode;try{Kr(s,"")}catch(x){Ee(e,e.return,x)}}if(r&4&&(s=e.stateNode,s!=null)){var o=e.memoizedProps,i=n!==null?n.memoizedProps:o,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&o.type==="radio"&&o.name!=null&&Au(s,o),Wo(l,i);var d=Wo(l,o);for(i=0;i<c.length;i+=2){var f=c[i],h=c[i+1];f==="style"?Ou(s,h):f==="dangerouslySetInnerHTML"?Mu(s,h):f==="children"?Kr(s,h):Fi(s,f,h,d)}switch(l){case"input":Fo(s,o);break;case"textarea":$u(s,o);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var w=o.value;w!=null?tr(s,!!o.multiple,w,!1):p!==!!o.multiple&&(o.defaultValue!=null?tr(s,!!o.multiple,o.defaultValue,!0):tr(s,!!o.multiple,o.multiple?[]:"",!1))}s[ns]=o}catch(x){Ee(e,e.return,x)}}break;case 6:if(Et(t,e),$t(e),r&4){if(e.stateNode===null)throw Error(O(162));s=e.stateNode,o=e.memoizedProps;try{s.nodeValue=o}catch(x){Ee(e,e.return,x)}}break;case 3:if(Et(t,e),$t(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Xr(t.containerInfo)}catch(x){Ee(e,e.return,x)}break;case 4:Et(t,e),$t(e);break;case 13:Et(t,e),$t(e),s=e.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(vl=Te())),r&4&&Fc(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Ve=(d=Ve)||f,Et(t,e),Ve=d):Et(t,e),$t(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(Y=e,f=e.child;f!==null;){for(h=Y=f;Y!==null;){switch(p=Y,w=p.child,p.tag){case 0:case 11:case 14:case 15:Ur(4,p,p.return);break;case 1:Zn(p,p.return);var y=p.stateNode;if(typeof y.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,y.props=t.memoizedProps,y.state=t.memoizedState,y.componentWillUnmount()}catch(x){Ee(r,n,x)}}break;case 5:Zn(p,p.return);break;case 22:if(p.memoizedState!==null){Bc(h);continue}}w!==null?(w.return=p,Y=w):Bc(h)}f=f.sibling}e:for(f=null,h=e;;){if(h.tag===5){if(f===null){f=h;try{s=h.stateNode,d?(o=s.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(l=h.stateNode,c=h.memoizedProps.style,i=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=Fu("display",i))}catch(x){Ee(e,e.return,x)}}}else if(h.tag===6){if(f===null)try{h.stateNode.nodeValue=d?"":h.memoizedProps}catch(x){Ee(e,e.return,x)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===e)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===e)break e;for(;h.sibling===null;){if(h.return===null||h.return===e)break e;f===h&&(f=null),h=h.return}f===h&&(f=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:Et(t,e),$t(e),r&4&&Fc(e);break;case 21:break;default:Et(t,e),$t(e)}}function $t(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(df(n)){var r=n;break e}n=n.return}throw Error(O(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Kr(s,""),r.flags&=-33);var o=Mc(e);xi(e,o,s);break;case 3:case 4:var i=r.stateNode.containerInfo,l=Mc(e);yi(e,l,i);break;default:throw Error(O(161))}}catch(c){Ee(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function zm(e,t,n){Y=e,hf(e)}function hf(e,t,n){for(var r=(e.mode&1)!==0;Y!==null;){var s=Y,o=s.child;if(s.tag===22&&r){var i=s.memoizedState!==null||_s;if(!i){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Ve;l=_s;var d=Ve;if(_s=i,(Ve=c)&&!d)for(Y=s;Y!==null;)i=Y,c=i.child,i.tag===22&&i.memoizedState!==null?Dc(s):c!==null?(c.return=i,Y=c):Dc(s);for(;o!==null;)Y=o,hf(o),o=o.sibling;Y=s,_s=l,Ve=d}Oc(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,Y=o):Oc(e)}}function Oc(e){for(;Y!==null;){var t=Y;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Ve||Ba(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Ve)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Tt(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&kc(t,o,r);break;case 3:var i=t.updateQueue;if(i!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}kc(t,i,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var d=t.alternate;if(d!==null){var f=d.memoizedState;if(f!==null){var h=f.dehydrated;h!==null&&Xr(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(O(163))}Ve||t.flags&512&&vi(t)}catch(p){Ee(t,t.return,p)}}if(t===e){Y=null;break}if(n=t.sibling,n!==null){n.return=t.return,Y=n;break}Y=t.return}}function Bc(e){for(;Y!==null;){var t=Y;if(t===e){Y=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Y=n;break}Y=t.return}}function Dc(e){for(;Y!==null;){var t=Y;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Ba(4,t)}catch(c){Ee(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){Ee(t,s,c)}}var o=t.return;try{vi(t)}catch(c){Ee(t,o,c)}break;case 5:var i=t.return;try{vi(t)}catch(c){Ee(t,i,c)}}}catch(c){Ee(t,t.return,c)}if(t===e){Y=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Y=l;break}Y=t.return}}var Rm=Math.ceil,ja=Zt.ReactCurrentDispatcher,ml=Zt.ReactCurrentOwner,jt=Zt.ReactCurrentBatchConfig,ue=0,Fe=null,Re=null,De=0,ut=0,er=Sn(0),Ae=0,ls=null,Fn=0,Da=0,gl=0,Wr=null,nt=null,vl=0,pr=1/0,Wt=null,ka=!1,wi=null,mn=null,As=!1,cn=null,ba=0,Hr=0,Si=null,Js=-1,Xs=0;function Xe(){return ue&6?Te():Js!==-1?Js:Js=Te()}function gn(e){return e.mode&1?ue&2&&De!==0?De&-De:pm.transition!==null?(Xs===0&&(Xs=Xu()),Xs):(e=he,e!==0||(e=window.event,e=e===void 0?16:sd(e.type)),e):1}function It(e,t,n,r){if(50<Hr)throw Hr=0,Si=null,Error(O(185));ds(e,n,r),(!(ue&2)||e!==Fe)&&(e===Fe&&(!(ue&2)&&(Da|=n),Ae===4&&on(e,De)),ot(e,r),n===1&&ue===0&&!(t.mode&1)&&(pr=Te()+500,Ma&&jn()))}function ot(e,t){var n=e.callbackNode;ph(e,t);var r=ia(e,e===Fe?De:0);if(r===0)n!==null&&Jl(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Jl(n),t===1)e.tag===0?fm(Uc.bind(null,e)):kd(Uc.bind(null,e)),lm(function(){!(ue&6)&&jn()}),n=null;else{switch(qu(r)){case 1:n=Wi;break;case 4:n=Qu;break;case 16:n=oa;break;case 536870912:n=Ju;break;default:n=oa}n=jf(n,mf.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function mf(e,t){if(Js=-1,Xs=0,ue&6)throw Error(O(327));var n=e.callbackNode;if(or()&&e.callbackNode!==n)return null;var r=ia(e,e===Fe?De:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Ca(e,r);else{t=r;var s=ue;ue|=2;var o=vf();(Fe!==e||De!==t)&&(Wt=null,pr=Te()+500,_n(e,t));do try{_m();break}catch(l){gf(e,l)}while(!0);nl(),ja.current=o,ue=s,Re!==null?t=0:(Fe=null,De=0,t=Ae)}if(t!==0){if(t===2&&(s=Yo(e),s!==0&&(r=s,t=ji(e,s))),t===1)throw n=ls,_n(e,0),on(e,r),ot(e,Te()),n;if(t===6)on(e,r);else{if(s=e.current.alternate,!(r&30)&&!Pm(s)&&(t=Ca(e,r),t===2&&(o=Yo(e),o!==0&&(r=o,t=ji(e,o))),t===1))throw n=ls,_n(e,0),on(e,r),ot(e,Te()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(O(345));case 2:En(e,nt,Wt);break;case 3:if(on(e,r),(r&130023424)===r&&(t=vl+500-Te(),10<t)){if(ia(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Xe(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=ni(En.bind(null,e,nt,Wt),t);break}En(e,nt,Wt);break;case 4:if(on(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var i=31-Pt(r);o=1<<i,i=t[i],i>s&&(s=i),r&=~o}if(r=s,r=Te()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Rm(r/1960))-r,10<r){e.timeoutHandle=ni(En.bind(null,e,nt,Wt),r);break}En(e,nt,Wt);break;case 5:En(e,nt,Wt);break;default:throw Error(O(329))}}}return ot(e,Te()),e.callbackNode===n?mf.bind(null,e):null}function ji(e,t){var n=Wr;return e.current.memoizedState.isDehydrated&&(_n(e,t).flags|=256),e=Ca(e,t),e!==2&&(t=nt,nt=n,t!==null&&ki(t)),e}function ki(e){nt===null?nt=e:nt.push.apply(nt,e)}function Pm(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var s=n[r],o=s.getSnapshot;s=s.value;try{if(!_t(o(),s))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function on(e,t){for(t&=~gl,t&=~Da,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Pt(t),r=1<<n;e[n]=-1,t&=~r}}function Uc(e){if(ue&6)throw Error(O(327));or();var t=ia(e,0);if(!(t&1))return ot(e,Te()),null;var n=Ca(e,t);if(e.tag!==0&&n===2){var r=Yo(e);r!==0&&(t=r,n=ji(e,r))}if(n===1)throw n=ls,_n(e,0),on(e,t),ot(e,Te()),n;if(n===6)throw Error(O(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,En(e,nt,Wt),ot(e,Te()),null}function yl(e,t){var n=ue;ue|=1;try{return e(t)}finally{ue=n,ue===0&&(pr=Te()+500,Ma&&jn())}}function On(e){cn!==null&&cn.tag===0&&!(ue&6)&&or();var t=ue;ue|=1;var n=jt.transition,r=he;try{if(jt.transition=null,he=1,e)return e()}finally{he=r,jt.transition=n,ue=t,!(ue&6)&&jn()}}function xl(){ut=er.current,Se(er)}function _n(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,im(n)),Re!==null)for(n=Re.return;n!==null;){var r=n;switch(Zi(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&fa();break;case 3:dr(),Se(st),Se(Ge),ll();break;case 5:il(r);break;case 4:dr();break;case 13:Se(be);break;case 19:Se(be);break;case 10:rl(r.type._context);break;case 22:case 23:xl()}n=n.return}if(Fe=e,Re=e=vn(e.current,null),De=ut=t,Ae=0,ls=null,gl=Da=Fn=0,nt=Wr=null,Rn!==null){for(t=0;t<Rn.length;t++)if(n=Rn[t],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,o=n.pending;if(o!==null){var i=o.next;o.next=s,r.next=i}n.pending=r}Rn=null}return e}function gf(e,t){do{var n=Re;try{if(nl(),Ks.current=Sa,wa){for(var r=Ce.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}wa=!1}if(Mn=0,Me=_e=Ce=null,Dr=!1,as=0,ml.current=null,n===null||n.return===null){Ae=1,ls=t,Re=null;break}e:{var o=e,i=n.return,l=n,c=t;if(t=De,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,f=l,h=f.tag;if(!(f.mode&1)&&(h===0||h===11||h===15)){var p=f.alternate;p?(f.updateQueue=p.updateQueue,f.memoizedState=p.memoizedState,f.lanes=p.lanes):(f.updateQueue=null,f.memoizedState=null)}var w=zc(i);if(w!==null){w.flags&=-257,Rc(w,i,l,o,t),w.mode&1&&Tc(o,d,t),t=w,c=d;var y=t.updateQueue;if(y===null){var x=new Set;x.add(c),t.updateQueue=x}else y.add(c);break e}else{if(!(t&1)){Tc(o,d,t),wl();break e}c=Error(O(426))}}else if(je&&l.mode&1){var j=zc(i);if(j!==null){!(j.flags&65536)&&(j.flags|=256),Rc(j,i,l,o,t),el(fr(c,l));break e}}o=c=fr(c,l),Ae!==4&&(Ae=2),Wr===null?Wr=[o]:Wr.push(o),o=i;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var g=qd(o,c,t);jc(o,g);break e;case 1:l=c;var m=o.type,v=o.stateNode;if(!(o.flags&128)&&(typeof m.getDerivedStateFromError=="function"||v!==null&&typeof v.componentDidCatch=="function"&&(mn===null||!mn.has(v)))){o.flags|=65536,t&=-t,o.lanes|=t;var S=Zd(o,l,t);jc(o,S);break e}}o=o.return}while(o!==null)}xf(n)}catch(b){t=b,Re===n&&n!==null&&(Re=n=n.return);continue}break}while(!0)}function vf(){var e=ja.current;return ja.current=Sa,e===null?Sa:e}function wl(){(Ae===0||Ae===3||Ae===2)&&(Ae=4),Fe===null||!(Fn&268435455)&&!(Da&268435455)||on(Fe,De)}function Ca(e,t){var n=ue;ue|=2;var r=vf();(Fe!==e||De!==t)&&(Wt=null,_n(e,t));do try{Im();break}catch(s){gf(e,s)}while(!0);if(nl(),ue=n,ja.current=r,Re!==null)throw Error(O(261));return Fe=null,De=0,Ae}function Im(){for(;Re!==null;)yf(Re)}function _m(){for(;Re!==null&&!sh();)yf(Re)}function yf(e){var t=Sf(e.alternate,e,ut);e.memoizedProps=e.pendingProps,t===null?xf(e):Re=t,ml.current=null}function xf(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=Nm(n,t),n!==null){n.flags&=32767,Re=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Ae=6,Re=null;return}}else if(n=Cm(n,t,ut),n!==null){Re=n;return}if(t=t.sibling,t!==null){Re=t;return}Re=t=e}while(t!==null);Ae===0&&(Ae=5)}function En(e,t,n){var r=he,s=jt.transition;try{jt.transition=null,he=1,Am(e,t,n,r)}finally{jt.transition=s,he=r}return null}function Am(e,t,n,r){do or();while(cn!==null);if(ue&6)throw Error(O(327));n=e.finishedWork;var s=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(O(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(hh(e,o),e===Fe&&(Re=Fe=null,De=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||As||(As=!0,jf(oa,function(){return or(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=jt.transition,jt.transition=null;var i=he;he=1;var l=ue;ue|=4,ml.current=null,Tm(e,n),pf(n,e),em(ei),la=!!Zo,ei=Zo=null,e.current=n,zm(n),ah(),ue=l,he=i,jt.transition=o}else e.current=n;if(As&&(As=!1,cn=e,ba=s),o=e.pendingLanes,o===0&&(mn=null),lh(n.stateNode),ot(e,Te()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)s=t[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(ka)throw ka=!1,e=wi,wi=null,e;return ba&1&&e.tag!==0&&or(),o=e.pendingLanes,o&1?e===Si?Hr++:(Hr=0,Si=e):Hr=0,jn(),null}function or(){if(cn!==null){var e=qu(ba),t=jt.transition,n=he;try{if(jt.transition=null,he=16>e?16:e,cn===null)var r=!1;else{if(e=cn,cn=null,ba=0,ue&6)throw Error(O(331));var s=ue;for(ue|=4,Y=e.current;Y!==null;){var o=Y,i=o.child;if(Y.flags&16){var l=o.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(Y=d;Y!==null;){var f=Y;switch(f.tag){case 0:case 11:case 15:Ur(8,f,o)}var h=f.child;if(h!==null)h.return=f,Y=h;else for(;Y!==null;){f=Y;var p=f.sibling,w=f.return;if(uf(f),f===d){Y=null;break}if(p!==null){p.return=w,Y=p;break}Y=w}}}var y=o.alternate;if(y!==null){var x=y.child;if(x!==null){y.child=null;do{var j=x.sibling;x.sibling=null,x=j}while(x!==null)}}Y=o}}if(o.subtreeFlags&2064&&i!==null)i.return=o,Y=i;else e:for(;Y!==null;){if(o=Y,o.flags&2048)switch(o.tag){case 0:case 11:case 15:Ur(9,o,o.return)}var g=o.sibling;if(g!==null){g.return=o.return,Y=g;break e}Y=o.return}}var m=e.current;for(Y=m;Y!==null;){i=Y;var v=i.child;if(i.subtreeFlags&2064&&v!==null)v.return=i,Y=v;else e:for(i=m;Y!==null;){if(l=Y,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Ba(9,l)}}catch(b){Ee(l,l.return,b)}if(l===i){Y=null;break e}var S=l.sibling;if(S!==null){S.return=l.return,Y=S;break e}Y=l.return}}if(ue=s,jn(),Ot&&typeof Ot.onPostCommitFiberRoot=="function")try{Ot.onPostCommitFiberRoot(Ia,e)}catch{}r=!0}return r}finally{he=n,jt.transition=t}}return!1}function Wc(e,t,n){t=fr(n,t),t=qd(e,t,1),e=hn(e,t,1),t=Xe(),e!==null&&(ds(e,1,t),ot(e,t))}function Ee(e,t,n){if(e.tag===3)Wc(e,e,n);else for(;t!==null;){if(t.tag===3){Wc(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(mn===null||!mn.has(r))){e=fr(n,e),e=Zd(t,e,1),t=hn(t,e,1),e=Xe(),t!==null&&(ds(t,1,e),ot(t,e));break}}t=t.return}}function $m(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Xe(),e.pingedLanes|=e.suspendedLanes&n,Fe===e&&(De&n)===n&&(Ae===4||Ae===3&&(De&130023424)===De&&500>Te()-vl?_n(e,0):gl|=n),ot(e,t)}function wf(e,t){t===0&&(e.mode&1?(t=bs,bs<<=1,!(bs&130023424)&&(bs=4194304)):t=1);var n=Xe();e=Jt(e,t),e!==null&&(ds(e,t,n),ot(e,n))}function Lm(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),wf(e,n)}function Mm(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(O(314))}r!==null&&r.delete(t),wf(e,n)}var Sf;Sf=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||st.current)rt=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return rt=!1,bm(e,t,n);rt=!!(e.flags&131072)}else rt=!1,je&&t.flags&1048576&&bd(t,ma,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Qs(e,t),e=t.pendingProps;var s=lr(t,Ge.current);ar(t,n),s=ul(null,t,r,e,s,n);var o=dl();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,at(r)?(o=!0,pa(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,al(t),s.updater=Oa,t.stateNode=s,s._reactInternals=t,ci(t,r,e,n),t=fi(null,t,r,!0,o,n)):(t.tag=0,je&&o&&qi(t),Qe(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Qs(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=Om(r),e=Tt(r,e),s){case 0:t=di(null,t,r,e,n);break e;case 1:t=_c(null,t,r,e,n);break e;case 11:t=Pc(null,t,r,e,n);break e;case 14:t=Ic(null,t,r,Tt(r.type,e),n);break e}throw Error(O(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Tt(r,s),di(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Tt(r,s),_c(e,t,r,s,n);case 3:e:{if(rf(t),e===null)throw Error(O(387));r=t.pendingProps,o=t.memoizedState,s=o.element,Rd(e,t),ya(t,r,null,n);var i=t.memoizedState;if(r=i.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){s=fr(Error(O(423)),t),t=Ac(e,t,r,n,s);break e}else if(r!==s){s=fr(Error(O(424)),t),t=Ac(e,t,r,n,s);break e}else for(dt=pn(t.stateNode.containerInfo.firstChild),ft=t,je=!0,Rt=null,n=Td(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(cr(),r===s){t=Xt(e,t,n);break e}Qe(e,t,r,n)}t=t.child}return t;case 5:return Pd(t),e===null&&oi(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,i=s.children,ti(r,s)?i=null:o!==null&&ti(r,o)&&(t.flags|=32),nf(e,t),Qe(e,t,i,n),t.child;case 6:return e===null&&oi(t),null;case 13:return sf(e,t,n);case 4:return ol(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ur(t,null,r,n):Qe(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Tt(r,s),Pc(e,t,r,s,n);case 7:return Qe(e,t,t.pendingProps,n),t.child;case 8:return Qe(e,t,t.pendingProps.children,n),t.child;case 12:return Qe(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,o=t.memoizedProps,i=s.value,xe(ga,r._currentValue),r._currentValue=i,o!==null)if(_t(o.value,i)){if(o.children===s.children&&!st.current){t=Xt(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var l=o.dependencies;if(l!==null){i=o.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(o.tag===1){c=Kt(-1,n&-n),c.tag=2;var d=o.updateQueue;if(d!==null){d=d.shared;var f=d.pending;f===null?c.next=c:(c.next=f.next,f.next=c),d.pending=c}}o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),ii(o.return,n,t),l.lanes|=n;break}c=c.next}}else if(o.tag===10)i=o.type===t.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(O(341));i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),ii(i,n,t),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===t){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}Qe(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,ar(t,n),s=kt(s),r=r(s),t.flags|=1,Qe(e,t,r,n),t.child;case 14:return r=t.type,s=Tt(r,t.pendingProps),s=Tt(r.type,s),Ic(e,t,r,s,n);case 15:return ef(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Tt(r,s),Qs(e,t),t.tag=1,at(r)?(e=!0,pa(t)):e=!1,ar(t,n),Xd(t,r,s),ci(t,r,s,n),fi(null,t,r,!0,e,n);case 19:return af(e,t,n);case 22:return tf(e,t,n)}throw Error(O(156,t.tag))};function jf(e,t){return Yu(e,t)}function Fm(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function St(e,t,n,r){return new Fm(e,t,n,r)}function Sl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Om(e){if(typeof e=="function")return Sl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Bi)return 11;if(e===Di)return 14}return 2}function vn(e,t){var n=e.alternate;return n===null?(n=St(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function qs(e,t,n,r,s,o){var i=2;if(r=e,typeof e=="function")Sl(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Hn:return An(n.children,s,o,t);case Oi:i=8,s|=8;break;case _o:return e=St(12,n,t,s|2),e.elementType=_o,e.lanes=o,e;case Ao:return e=St(13,n,t,s),e.elementType=Ao,e.lanes=o,e;case $o:return e=St(19,n,t,s),e.elementType=$o,e.lanes=o,e;case Pu:return Ua(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case zu:i=10;break e;case Ru:i=9;break e;case Bi:i=11;break e;case Di:i=14;break e;case nn:i=16,r=null;break e}throw Error(O(130,e==null?e:typeof e,""))}return t=St(i,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function An(e,t,n,r){return e=St(7,e,r,t),e.lanes=n,e}function Ua(e,t,n,r){return e=St(22,e,r,t),e.elementType=Pu,e.lanes=n,e.stateNode={isHidden:!1},e}function ko(e,t,n){return e=St(6,e,null,t),e.lanes=n,e}function bo(e,t,n){return t=St(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Bm(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ro(0),this.expirationTimes=ro(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ro(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function jl(e,t,n,r,s,o,i,l,c){return e=new Bm(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=St(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},al(o),e}function Dm(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Wn,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function kf(e){if(!e)return xn;e=e._reactInternals;e:{if(Dn(e)!==e||e.tag!==1)throw Error(O(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(at(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(O(171))}if(e.tag===1){var n=e.type;if(at(n))return jd(e,n,t)}return t}function bf(e,t,n,r,s,o,i,l,c){return e=jl(n,r,!0,e,s,o,i,l,c),e.context=kf(null),n=e.current,r=Xe(),s=gn(n),o=Kt(r,s),o.callback=t??null,hn(n,o,s),e.current.lanes=s,ds(e,s,r),ot(e,r),e}function Wa(e,t,n,r){var s=t.current,o=Xe(),i=gn(s);return n=kf(n),t.context===null?t.context=n:t.pendingContext=n,t=Kt(o,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=hn(s,t,i),e!==null&&(It(e,s,i,o),Gs(e,s,i)),i}function Na(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 Hc(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function kl(e,t){Hc(e,t),(e=e.alternate)&&Hc(e,t)}function Um(){return null}var Cf=typeof reportError=="function"?reportError:function(e){console.error(e)};function bl(e){this._internalRoot=e}Ha.prototype.render=bl.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(O(409));Wa(e,t,null,null)};Ha.prototype.unmount=bl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;On(function(){Wa(null,e,null,null)}),t[Qt]=null}};function Ha(e){this._internalRoot=e}Ha.prototype.unstable_scheduleHydration=function(e){if(e){var t=td();e={blockedOn:null,target:e,priority:t};for(var n=0;n<an.length&&t!==0&&t<an[n].priority;n++);an.splice(n,0,e),n===0&&rd(e)}};function Cl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Va(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Vc(){}function Wm(e,t,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var d=Na(i);o.call(d)}}var i=bf(t,r,e,0,null,!1,!1,"",Vc);return e._reactRootContainer=i,e[Qt]=i.current,es(e.nodeType===8?e.parentNode:e),On(),i}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var d=Na(c);l.call(d)}}var c=jl(e,0,!1,null,null,!1,!1,"",Vc);return e._reactRootContainer=c,e[Qt]=c.current,es(e.nodeType===8?e.parentNode:e),On(function(){Wa(t,c,n,r)}),c}function Ga(e,t,n,r,s){var o=n._reactRootContainer;if(o){var i=o;if(typeof s=="function"){var l=s;s=function(){var c=Na(i);l.call(c)}}Wa(t,i,e,s)}else i=Wm(n,t,e,s,r);return Na(i)}Zu=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=_r(t.pendingLanes);n!==0&&(Hi(t,n|1),ot(t,Te()),!(ue&6)&&(pr=Te()+500,jn()))}break;case 13:On(function(){var r=Jt(e,1);if(r!==null){var s=Xe();It(r,e,1,s)}}),kl(e,1)}};Vi=function(e){if(e.tag===13){var t=Jt(e,134217728);if(t!==null){var n=Xe();It(t,e,134217728,n)}kl(e,134217728)}};ed=function(e){if(e.tag===13){var t=gn(e),n=Jt(e,t);if(n!==null){var r=Xe();It(n,e,t,r)}kl(e,t)}};td=function(){return he};nd=function(e,t){var n=he;try{return he=e,t()}finally{he=n}};Vo=function(e,t,n){switch(t){case"input":if(Fo(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var s=La(r);if(!s)throw Error(O(90));_u(r),Fo(r,s)}}}break;case"textarea":$u(e,n);break;case"select":t=n.value,t!=null&&tr(e,!!n.multiple,t,!1)}};Uu=yl;Wu=On;var Hm={usingClientEntryPoint:!1,Events:[ps,Yn,La,Bu,Du,yl]},Tr={findFiberByHostInstance:zn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Vm={bundleType:Tr.bundleType,version:Tr.version,rendererPackageName:Tr.rendererPackageName,rendererConfig:Tr.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Zt.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Gu(e),e===null?null:e.stateNode},findFiberByHostInstance:Tr.findFiberByHostInstance||Um,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 $s=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!$s.isDisabled&&$s.supportsFiber)try{Ia=$s.inject(Vm),Ot=$s}catch{}}ht.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Hm;ht.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Cl(t))throw Error(O(200));return Dm(e,t,null,n)};ht.createRoot=function(e,t){if(!Cl(e))throw Error(O(299));var n=!1,r="",s=Cf;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=jl(e,1,!1,null,null,n,!1,r,s),e[Qt]=t.current,es(e.nodeType===8?e.parentNode:e),new bl(t)};ht.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(O(188)):(e=Object.keys(e).join(","),Error(O(268,e)));return e=Gu(t),e=e===null?null:e.stateNode,e};ht.flushSync=function(e){return On(e)};ht.hydrate=function(e,t,n){if(!Va(t))throw Error(O(200));return Ga(null,e,t,!0,n)};ht.hydrateRoot=function(e,t,n){if(!Cl(e))throw Error(O(405));var r=n!=null&&n.hydratedSources||null,s=!1,o="",i=Cf;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(i=n.onRecoverableError)),t=bf(t,null,e,1,n??null,s,!1,o,i),e[Qt]=t.current,es(e),r)for(e=0;e<r.length;e++)n=r[e],s=n._getVersion,s=s(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,s]:t.mutableSourceEagerHydrationData.push(n,s);return new Ha(t)};ht.render=function(e,t,n){if(!Va(t))throw Error(O(200));return Ga(null,e,t,!1,n)};ht.unmountComponentAtNode=function(e){if(!Va(e))throw Error(O(40));return e._reactRootContainer?(On(function(){Ga(null,null,e,!1,function(){e._reactRootContainer=null,e[Qt]=null})}),!0):!1};ht.unstable_batchedUpdates=yl;ht.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Va(n))throw Error(O(200));if(e==null||e._reactInternals===void 0)throw Error(O(38));return Ga(e,t,n,!1,r)};ht.version="18.3.1-next-f1338f8080-20240426";function Nf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Nf)}catch(e){console.error(e)}}Nf(),Cu.exports=ht;var Ef=Cu.exports,Tf,Gc=Ef;Tf=Gc.createRoot,Gc.hydrateRoot;/**
41
+ * react-router v7.13.1
42
+ *
43
+ * Copyright (c) Remix Software Inc.
44
+ *
45
+ * This source code is licensed under the MIT license found in the
46
+ * LICENSE.md file in the root directory of this source tree.
47
+ *
48
+ * @license MIT
49
+ */var Kc="popstate";function Yc(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Gm(e={}){function t(r,s){var d;let o=(d=s.state)==null?void 0:d.masked,{pathname:i,search:l,hash:c}=o||r.location;return bi("",{pathname:i,search:l,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default",o?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,s){return typeof s=="string"?s:cs(s)}return Ym(t,n,null,e)}function ke(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ct(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Km(){return Math.random().toString(36).substring(2,10)}function Qc(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function bi(e,t,n=null,r,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?vr(t):t,state:n,key:t&&t.key||r||Km(),unstable_mask:s}}function cs({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function vr(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Ym(e,t,n,r={}){let{window:s=document.defaultView,v5Compat:o=!1}=r,i=s.history,l="POP",c=null,d=f();d==null&&(d=0,i.replaceState({...i.state,idx:d},""));function f(){return(i.state||{idx:null}).idx}function h(){l="POP";let j=f(),g=j==null?null:j-d;d=j,c&&c({action:l,location:x.location,delta:g})}function p(j,g){l="PUSH";let m=Yc(j)?j:bi(x.location,j,g);d=f()+1;let v=Qc(m,d),S=x.createHref(m.unstable_mask||m);try{i.pushState(v,"",S)}catch(b){if(b instanceof DOMException&&b.name==="DataCloneError")throw b;s.location.assign(S)}o&&c&&c({action:l,location:x.location,delta:1})}function w(j,g){l="REPLACE";let m=Yc(j)?j:bi(x.location,j,g);d=f();let v=Qc(m,d),S=x.createHref(m.unstable_mask||m);i.replaceState(v,"",S),o&&c&&c({action:l,location:x.location,delta:0})}function y(j){return Qm(j)}let x={get action(){return l},get location(){return e(s,i)},listen(j){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(Kc,h),c=j,()=>{s.removeEventListener(Kc,h),c=null}},createHref(j){return t(s,j)},createURL:y,encodeLocation(j){let g=y(j);return{pathname:g.pathname,search:g.search,hash:g.hash}},push:p,replace:w,go(j){return i.go(j)}};return x}function Qm(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ke(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:cs(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function zf(e,t,n="/"){return Jm(e,t,n,!1)}function Jm(e,t,n,r){let s=typeof t=="string"?vr(t):t,o=qt(s.pathname||"/",n);if(o==null)return null;let i=Rf(e);Xm(i);let l=null;for(let c=0;l==null&&c<i.length;++c){let d=lg(o);l=og(i[c],d,r)}return l}function Rf(e,t=[],n=[],r="",s=!1){let o=(i,l,c=s,d)=>{let f={relativePath:d===void 0?i.path||"":d,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(r)&&c)return;ke(f.relativePath.startsWith(r),`Absolute route path "${f.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),f.relativePath=f.relativePath.slice(r.length)}let h=Dt([r,f.relativePath]),p=n.concat(f);i.children&&i.children.length>0&&(ke(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),Rf(i.children,t,p,h,c)),!(i.path==null&&!i.index)&&t.push({path:h,score:sg(h,i.index),routesMeta:p})};return e.forEach((i,l)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))o(i,l);else for(let d of Pf(i.path))o(i,l,!0,d)}),t}function Pf(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),o=n.replace(/\?$/,"");if(r.length===0)return s?[o,""]:[o];let i=Pf(r.join("/")),l=[];return l.push(...i.map(c=>c===""?o:[o,c].join("/"))),s&&l.push(...i),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function Xm(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:ag(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var qm=/^:[\w-]+$/,Zm=3,eg=2,tg=1,ng=10,rg=-2,Jc=e=>e==="*";function sg(e,t){let n=e.split("/"),r=n.length;return n.some(Jc)&&(r+=rg),t&&(r+=eg),n.filter(s=>!Jc(s)).reduce((s,o)=>s+(qm.test(o)?Zm:o===""?tg:ng),r)}function ag(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function og(e,t,n=!1){let{routesMeta:r}=e,s={},o="/",i=[];for(let l=0;l<r.length;++l){let c=r[l],d=l===r.length-1,f=o==="/"?t:t.slice(o.length)||"/",h=Ea({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},f),p=c.route;if(!h&&d&&n&&!r[r.length-1].route.index&&(h=Ea({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!h)return null;Object.assign(s,h.params),i.push({params:s,pathname:Dt([o,h.pathname]),pathnameBase:fg(Dt([o,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(o=Dt([o,h.pathnameBase]))}return i}function Ea(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ig(e.path,e.caseSensitive,e.end),s=t.match(n);if(!s)return null;let o=s[0],i=o.replace(/(.)\/+$/,"$1"),l=s.slice(1);return{params:r.reduce((d,{paramName:f,isOptional:h},p)=>{if(f==="*"){let y=l[p]||"";i=o.slice(0,o.length-y.length).replace(/(.)\/+$/,"$1")}const w=l[p];return h&&!w?d[f]=void 0:d[f]=(w||"").replace(/%2F/g,"/"),d},{}),pathname:o,pathnameBase:i,pattern:e}}function ig(e,t=!1,n=!0){Ct(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c,d,f)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let h=f.charAt(d+i.length);return h&&h!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function lg(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ct(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function qt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var cg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function ug(e,t="/"){let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?vr(e):e,o;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?o=Xc(n.substring(1),"/"):o=Xc(n,t)):o=t,{pathname:o,search:pg(r),hash:hg(s)}}function Xc(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function Co(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function dg(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Nl(e){let t=dg(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Ka(e,t,n,r=!1){let s;typeof e=="string"?s=vr(e):(s={...e},ke(!s.pathname||!s.pathname.includes("?"),Co("?","pathname","search",s)),ke(!s.pathname||!s.pathname.includes("#"),Co("#","pathname","hash",s)),ke(!s.search||!s.search.includes("#"),Co("#","search","hash",s)));let o=e===""||s.pathname==="",i=o?"/":s.pathname,l;if(i==null)l=n;else{let h=t.length-1;if(!r&&i.startsWith("..")){let p=i.split("/");for(;p[0]==="..";)p.shift(),h-=1;s.pathname=p.join("/")}l=h>=0?t[h]:"/"}let c=ug(s,l),d=i&&i!=="/"&&i.endsWith("/"),f=(o||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var Dt=e=>e.join("/").replace(/\/\/+/g,"/"),fg=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),pg=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,hg=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,mg=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function gg(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function vg(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var If=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function _f(e,t){let n=e;if(typeof n!="string"||!cg.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,s=!1;if(If)try{let o=new URL(window.location.href),i=n.startsWith("//")?new URL(o.protocol+n):new URL(n),l=qt(i.pathname,t);i.origin===o.origin&&l!=null?n=l+i.search+i.hash:s=!0}catch{Ct(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:s,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Af=["POST","PUT","PATCH","DELETE"];new Set(Af);var yg=["GET",...Af];new Set(yg);var yr=u.createContext(null);yr.displayName="DataRouter";var Ya=u.createContext(null);Ya.displayName="DataRouterState";var xg=u.createContext(!1),$f=u.createContext({isTransitioning:!1});$f.displayName="ViewTransition";var wg=u.createContext(new Map);wg.displayName="Fetchers";var Sg=u.createContext(null);Sg.displayName="Await";var gt=u.createContext(null);gt.displayName="Navigation";var ms=u.createContext(null);ms.displayName="Location";var At=u.createContext({outlet:null,matches:[],isDataRoute:!1});At.displayName="Route";var El=u.createContext(null);El.displayName="RouteError";var Lf="REACT_ROUTER_ERROR",jg="REDIRECT",kg="ROUTE_ERROR_RESPONSE";function bg(e){if(e.startsWith(`${Lf}:${jg}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function Cg(e){if(e.startsWith(`${Lf}:${kg}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new mg(t.status,t.statusText,t.data)}catch{}}function Ng(e,{relative:t}={}){ke(xr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=u.useContext(gt),{hash:s,pathname:o,search:i}=gs(e,{relative:t}),l=o;return n!=="/"&&(l=o==="/"?n:Dt([n,o])),r.createHref({pathname:l,search:i,hash:s})}function xr(){return u.useContext(ms)!=null}function Nt(){return ke(xr(),"useLocation() may be used only in the context of a <Router> component."),u.useContext(ms).location}var Mf="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ff(e){u.useContext(gt).static||u.useLayoutEffect(e)}function en(){let{isDataRoute:e}=u.useContext(At);return e?Dg():Eg()}function Eg(){ke(xr(),"useNavigate() may be used only in the context of a <Router> component.");let e=u.useContext(yr),{basename:t,navigator:n}=u.useContext(gt),{matches:r}=u.useContext(At),{pathname:s}=Nt(),o=JSON.stringify(Nl(r)),i=u.useRef(!1);return Ff(()=>{i.current=!0}),u.useCallback((c,d={})=>{if(Ct(i.current,Mf),!i.current)return;if(typeof c=="number"){n.go(c);return}let f=Ka(c,JSON.parse(o),s,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Dt([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,o,s,e])}var Tg=u.createContext(null);function zg(e){let t=u.useContext(At).outlet;return u.useMemo(()=>t&&u.createElement(Tg.Provider,{value:e},t),[t,e])}function gs(e,{relative:t}={}){let{matches:n}=u.useContext(At),{pathname:r}=Nt(),s=JSON.stringify(Nl(n));return u.useMemo(()=>Ka(e,JSON.parse(s),r,t==="path"),[e,s,r,t])}function Rg(e,t){return Of(e,t)}function Of(e,t,n){var j;ke(xr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=u.useContext(gt),{matches:s}=u.useContext(At),o=s[s.length-1],i=o?o.params:{},l=o?o.pathname:"/",c=o?o.pathnameBase:"/",d=o&&o.route;{let g=d&&d.path||"";Df(l,!d||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${g}">) 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="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let f=Nt(),h;if(t){let g=typeof t=="string"?vr(t):t;ke(c==="/"||((j=g.pathname)==null?void 0:j.startsWith(c)),`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 "${c}" but pathname "${g.pathname}" was given in the \`location\` prop.`),h=g}else h=f;let p=h.pathname||"/",w=p;if(c!=="/"){let g=c.replace(/^\//,"").split("/");w="/"+p.replace(/^\//,"").split("/").slice(g.length).join("/")}let y=zf(e,{pathname:w});Ct(d||y!=null,`No routes matched location "${h.pathname}${h.search}${h.hash}" `),Ct(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${h.pathname}${h.search}${h.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 x=$g(y&&y.map(g=>Object.assign({},g,{params:Object.assign({},i,g.params),pathname:Dt([c,r.encodeLocation?r.encodeLocation(g.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?c:Dt([c,r.encodeLocation?r.encodeLocation(g.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),s,n);return t&&x?u.createElement(ms.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...h},navigationType:"POP"}},x):x}function Pg(){let e=Bg(),t=gg(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:r},o={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=u.createElement(u.Fragment,null,u.createElement("p",null,"💿 Hey developer 👋"),u.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",u.createElement("code",{style:o},"ErrorBoundary")," or"," ",u.createElement("code",{style:o},"errorElement")," prop on your route.")),u.createElement(u.Fragment,null,u.createElement("h2",null,"Unexpected Application Error!"),u.createElement("h3",{style:{fontStyle:"italic"}},t),n?u.createElement("pre",{style:s},n):null,i)}var Ig=u.createElement(Pg,null),Bf=class extends u.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=Cg(e.digest);n&&(e=n)}let t=e!==void 0?u.createElement(At.Provider,{value:this.props.routeContext},u.createElement(El.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?u.createElement(_g,{error:e},t):t}};Bf.contextType=xg;var No=new WeakMap;function _g({children:e,error:t}){let{basename:n}=u.useContext(gt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=bg(t.digest);if(r){let s=No.get(t);if(s)throw s;let o=_f(r.location,n);if(If&&!No.get(t))if(o.isExternal||r.reloadDocument)window.location.href=o.absoluteURL||o.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(o.to,{replace:r.replace}));throw No.set(t,i),i}return u.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o.absoluteURL||o.to}`})}}return e}function Ag({routeContext:e,match:t,children:n}){let r=u.useContext(yr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),u.createElement(At.Provider,{value:e},n)}function $g(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let s=e,o=r==null?void 0:r.errors;if(o!=null){let f=s.findIndex(h=>h.route.id&&(o==null?void 0:o[h.route.id])!==void 0);ke(f>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),s=s.slice(0,Math.min(s.length,f+1))}let i=!1,l=-1;if(n&&r){i=r.renderFallback;for(let f=0;f<s.length;f++){let h=s[f];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(l=f),h.route.id){let{loaderData:p,errors:w}=r,y=h.route.loader&&!p.hasOwnProperty(h.route.id)&&(!w||w[h.route.id]===void 0);if(h.route.lazy||y){n.isStatic&&(i=!0),l>=0?s=s.slice(0,l+1):s=[s[0]];break}}}}let c=n==null?void 0:n.onError,d=r&&c?(f,h)=>{var p,w;c(f,{location:r.location,params:((w=(p=r.matches)==null?void 0:p[0])==null?void 0:w.params)??{},unstable_pattern:vg(r.matches),errorInfo:h})}:void 0;return s.reduceRight((f,h,p)=>{let w,y=!1,x=null,j=null;r&&(w=o&&h.route.id?o[h.route.id]:void 0,x=h.route.errorElement||Ig,i&&(l<0&&p===0?(Df("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),y=!0,j=null):l===p&&(y=!0,j=h.route.hydrateFallbackElement||null)));let g=t.concat(s.slice(0,p+1)),m=()=>{let v;return w?v=x:y?v=j:h.route.Component?v=u.createElement(h.route.Component,null):h.route.element?v=h.route.element:v=f,u.createElement(Ag,{match:h,routeContext:{outlet:f,matches:g,isDataRoute:r!=null},children:v})};return r&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?u.createElement(Bf,{location:r.location,revalidation:r.revalidation,component:x,error:w,children:m(),routeContext:{outlet:null,matches:g,isDataRoute:!0},onError:d}):m()},null)}function Tl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Lg(e){let t=u.useContext(yr);return ke(t,Tl(e)),t}function Mg(e){let t=u.useContext(Ya);return ke(t,Tl(e)),t}function Fg(e){let t=u.useContext(At);return ke(t,Tl(e)),t}function zl(e){let t=Fg(e),n=t.matches[t.matches.length-1];return ke(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Og(){return zl("useRouteId")}function Bg(){var r;let e=u.useContext(El),t=Mg("useRouteError"),n=zl("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function Dg(){let{router:e}=Lg("useNavigate"),t=zl("useNavigate"),n=u.useRef(!1);return Ff(()=>{n.current=!0}),u.useCallback(async(s,o={})=>{Ct(n.current,Mf),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...o}))},[e,t])}var qc={};function Df(e,t,n){!t&&!qc[e]&&(qc[e]=!0,Ct(!1,n))}u.memo(Ug);function Ug({routes:e,future:t,state:n,isStatic:r,onError:s}){return Of(e,void 0,{state:n,isStatic:r,onError:s})}function sn({to:e,replace:t,state:n,relative:r}){ke(xr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=u.useContext(gt);Ct(!s,"<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:o}=u.useContext(At),{pathname:i}=Nt(),l=en(),c=Ka(e,Nl(o),i,r==="path"),d=JSON.stringify(c);return u.useEffect(()=>{l(JSON.parse(d),{replace:t,state:n,relative:r})},[l,d,r,t,n]),null}function Wg(e){return zg(e.context)}function Le(e){ke(!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 Hg({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:s,static:o=!1,unstable_useTransitions:i}){ke(!xr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=u.useMemo(()=>({basename:l,navigator:s,static:o,unstable_useTransitions:i,future:{}}),[l,s,o,i]);typeof n=="string"&&(n=vr(n));let{pathname:d="/",search:f="",hash:h="",state:p=null,key:w="default",unstable_mask:y}=n,x=u.useMemo(()=>{let j=qt(d,l);return j==null?null:{location:{pathname:j,search:f,hash:h,state:p,key:w,unstable_mask:y},navigationType:r}},[l,d,f,h,p,w,r,y]);return Ct(x!=null,`<Router basename="${l}"> is not able to match the URL "${d}${f}${h}" because it does not start with the basename, so the <Router> won't render anything.`),x==null?null:u.createElement(gt.Provider,{value:c},u.createElement(ms.Provider,{children:t,value:x}))}function Vg({children:e,location:t}){return Rg(Ci(e),t)}function Ci(e,t=[]){let n=[];return u.Children.forEach(e,(r,s)=>{if(!u.isValidElement(r))return;let o=[...t,s];if(r.type===u.Fragment){n.push.apply(n,Ci(r.props.children,o));return}ke(r.type===Le,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ke(!r.props.index||!r.props.children,"An index route cannot have child routes.");let i={id:r.props.id||o.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=Ci(r.props.children,o)),n.push(i)}),n}var Zs="get",ea="application/x-www-form-urlencoded";function Qa(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Gg(e){return Qa(e)&&e.tagName.toLowerCase()==="button"}function Kg(e){return Qa(e)&&e.tagName.toLowerCase()==="form"}function Yg(e){return Qa(e)&&e.tagName.toLowerCase()==="input"}function Qg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Jg(e,t){return e.button===0&&(!t||t==="_self")&&!Qg(e)}function Ni(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(s=>[n,s]):[[n,r]])},[]))}function Xg(e,t){let n=Ni(e);return t&&t.forEach((r,s)=>{n.has(s)||t.getAll(s).forEach(o=>{n.append(s,o)})}),n}var Ls=null;function qg(){if(Ls===null)try{new FormData(document.createElement("form"),0),Ls=!1}catch{Ls=!0}return Ls}var Zg=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Eo(e){return e!=null&&!Zg.has(e)?(Ct(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ea}"`),null):e}function ev(e,t){let n,r,s,o,i;if(Kg(e)){let l=e.getAttribute("action");r=l?qt(l,t):null,n=e.getAttribute("method")||Zs,s=Eo(e.getAttribute("enctype"))||ea,o=new FormData(e)}else if(Gg(e)||Yg(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(r=c?qt(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Zs,s=Eo(e.getAttribute("formenctype"))||Eo(l.getAttribute("enctype"))||ea,o=new FormData(l,e),!qg()){let{name:d,type:f,value:h}=e;if(f==="image"){let p=d?`${d}.`:"";o.append(`${p}x`,"0"),o.append(`${p}y`,"0")}else d&&o.append(d,h)}}else{if(Qa(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Zs,r=null,s=ea,i=e}return o&&s==="text/plain"&&(i=o,o=void 0),{action:r,method:n.toLowerCase(),encType:s,formData:o,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Rl(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function tv(e,t,n,r){let s=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?s.pathname.endsWith("/")?s.pathname=`${s.pathname}_.${r}`:s.pathname=`${s.pathname}.${r}`:s.pathname==="/"?s.pathname=`_root.${r}`:t&&qt(s.pathname,t)==="/"?s.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:s.pathname=`${s.pathname.replace(/\/$/,"")}.${r}`,s}async function nv(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function rv(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function sv(e,t,n){let r=await Promise.all(e.map(async s=>{let o=t.routes[s.route.id];if(o){let i=await nv(o,n);return i.links?i.links():[]}return[]}));return lv(r.flat(1).filter(rv).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function Zc(e,t,n,r,s,o){let i=(c,d)=>n[d]?c.route.id!==n[d].route.id:!0,l=(c,d)=>{var f;return n[d].pathname!==c.pathname||((f=n[d].route.path)==null?void 0:f.endsWith("*"))&&n[d].params["*"]!==c.params["*"]};return o==="assets"?t.filter((c,d)=>i(c,d)||l(c,d)):o==="data"?t.filter((c,d)=>{var h;let f=r.routes[c.route.id];if(!f||!f.hasLoader)return!1;if(i(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let p=c.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:((h=n[0])==null?void 0:h.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof p=="boolean")return p}return!0}):[]}function av(e,t,{includeHydrateFallback:n}={}){return ov(e.map(r=>{let s=t.routes[r.route.id];if(!s)return[];let o=[s.module];return s.clientActionModule&&(o=o.concat(s.clientActionModule)),s.clientLoaderModule&&(o=o.concat(s.clientLoaderModule)),n&&s.hydrateFallbackModule&&(o=o.concat(s.hydrateFallbackModule)),s.imports&&(o=o.concat(s.imports)),o}).flat(1))}function ov(e){return[...new Set(e)]}function iv(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function lv(e,t){let n=new Set;return new Set(t),e.reduce((r,s)=>{let o=JSON.stringify(iv(s));return n.has(o)||(n.add(o),r.push({key:o,link:s})),r},[])}function Uf(){let e=u.useContext(yr);return Rl(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function cv(){let e=u.useContext(Ya);return Rl(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Pl=u.createContext(void 0);Pl.displayName="FrameworkContext";function Wf(){let e=u.useContext(Pl);return Rl(e,"You must render this element inside a <HydratedRouter> element"),e}function uv(e,t){let n=u.useContext(Pl),[r,s]=u.useState(!1),[o,i]=u.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:f,onTouchStart:h}=t,p=u.useRef(null);u.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let x=g=>{g.forEach(m=>{i(m.isIntersecting)})},j=new IntersectionObserver(x,{threshold:.5});return p.current&&j.observe(p.current),()=>{j.disconnect()}}},[e]),u.useEffect(()=>{if(r){let x=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(x)}}},[r]);let w=()=>{s(!0)},y=()=>{s(!1),i(!1)};return n?e!=="intent"?[o,p,{}]:[o,p,{onFocus:zr(l,w),onBlur:zr(c,y),onMouseEnter:zr(d,w),onMouseLeave:zr(f,y),onTouchStart:zr(h,w)}]:[!1,p,{}]}function zr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function dv({page:e,...t}){let{router:n}=Uf(),r=u.useMemo(()=>zf(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?u.createElement(pv,{page:e,matches:r,...t}):null}function fv(e){let{manifest:t,routeModules:n}=Wf(),[r,s]=u.useState([]);return u.useEffect(()=>{let o=!1;return sv(e,t,n).then(i=>{o||s(i)}),()=>{o=!0}},[e,t,n]),r}function pv({page:e,matches:t,...n}){let r=Nt(),{future:s,manifest:o,routeModules:i}=Wf(),{basename:l}=Uf(),{loaderData:c,matches:d}=cv(),f=u.useMemo(()=>Zc(e,t,d,o,r,"data"),[e,t,d,o,r]),h=u.useMemo(()=>Zc(e,t,d,o,r,"assets"),[e,t,d,o,r]),p=u.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let x=new Set,j=!1;if(t.forEach(m=>{var S;let v=o.routes[m.route.id];!v||!v.hasLoader||(!f.some(b=>b.route.id===m.route.id)&&m.route.id in c&&((S=i[m.route.id])!=null&&S.shouldRevalidate)||v.hasClientLoader?j=!0:x.add(m.route.id))}),x.size===0)return[];let g=tv(e,l,s.unstable_trailingSlashAwareDataRequests,"data");return j&&x.size>0&&g.searchParams.set("_routes",t.filter(m=>x.has(m.route.id)).map(m=>m.route.id).join(",")),[g.pathname+g.search]},[l,s.unstable_trailingSlashAwareDataRequests,c,r,o,f,t,e,i]),w=u.useMemo(()=>av(h,o),[h,o]),y=fv(h);return u.createElement(u.Fragment,null,p.map(x=>u.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),w.map(x=>u.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),y.map(({key:x,link:j})=>u.createElement("link",{key:x,nonce:n.nonce,...j,crossOrigin:j.crossOrigin??n.crossOrigin})))}function hv(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var mv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{mv&&(window.__reactRouterVersion="7.13.1")}catch{}function gv({basename:e,children:t,unstable_useTransitions:n,window:r}){let s=u.useRef();s.current==null&&(s.current=Gm({window:r,v5Compat:!0}));let o=s.current,[i,l]=u.useState({action:o.action,location:o.location}),c=u.useCallback(d=>{n===!1?l(d):u.startTransition(()=>l(d))},[n]);return u.useLayoutEffect(()=>o.listen(c),[o,c]),u.createElement(Hg,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:o,unstable_useTransitions:n})}var Hf=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Je=u.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:s,reloadDocument:o,replace:i,unstable_mask:l,state:c,target:d,to:f,preventScrollReset:h,viewTransition:p,unstable_defaultShouldRevalidate:w,...y},x){let{basename:j,navigator:g,unstable_useTransitions:m}=u.useContext(gt),v=typeof f=="string"&&Hf.test(f),S=_f(f,j);f=S.to;let b=Ng(f,{relative:s}),N=Nt(),C=null;if(l){let P=Ka(l,[],N.unstable_mask?N.unstable_mask.pathname:"/",!0);j!=="/"&&(P.pathname=P.pathname==="/"?j:Dt([j,P.pathname])),C=g.createHref(P)}let[T,E,L]=uv(r,y),D=xv(f,{replace:i,unstable_mask:l,state:c,target:d,preventScrollReset:h,relative:s,viewTransition:p,unstable_defaultShouldRevalidate:w,unstable_useTransitions:m});function G(P){t&&t(P),P.defaultPrevented||D(P)}let J=!(S.isExternal||o),U=u.createElement("a",{...y,...L,href:(J?C:void 0)||S.absoluteURL||b,onClick:J?G:t,ref:hv(x,E),target:d,"data-discover":!v&&n==="render"?"true":void 0});return T&&!v?u.createElement(u.Fragment,null,U,u.createElement(dv,{page:b})):U});Je.displayName="Link";var Il=u.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:s=!1,style:o,to:i,viewTransition:l,children:c,...d},f){let h=gs(i,{relative:d.relative}),p=Nt(),w=u.useContext(Ya),{navigator:y,basename:x}=u.useContext(gt),j=w!=null&&bv(h)&&l===!0,g=y.encodeLocation?y.encodeLocation(h).pathname:h.pathname,m=p.pathname,v=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;n||(m=m.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&x&&(v=qt(v,x)||v);const S=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let b=m===g||!s&&m.startsWith(g)&&m.charAt(S)==="/",N=v!=null&&(v===g||!s&&v.startsWith(g)&&v.charAt(g.length)==="/"),C={isActive:b,isPending:N,isTransitioning:j},T=b?t:void 0,E;typeof r=="function"?E=r(C):E=[r,b?"active":null,N?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let L=typeof o=="function"?o(C):o;return u.createElement(Je,{...d,"aria-current":T,className:E,ref:f,style:L,to:i,viewTransition:l},typeof c=="function"?c(C):c)});Il.displayName="NavLink";var vv=u.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:s,state:o,method:i=Zs,action:l,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:h,unstable_defaultShouldRevalidate:p,...w},y)=>{let{unstable_useTransitions:x}=u.useContext(gt),j=jv(),g=kv(l,{relative:d}),m=i.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&Hf.test(l),S=b=>{if(c&&c(b),b.defaultPrevented)return;b.preventDefault();let N=b.nativeEvent.submitter,C=(N==null?void 0:N.getAttribute("formmethod"))||i,T=()=>j(N||b.currentTarget,{fetcherKey:t,method:C,navigate:n,replace:s,state:o,relative:d,preventScrollReset:f,viewTransition:h,unstable_defaultShouldRevalidate:p});x&&n!==!1?u.startTransition(()=>T()):T()};return u.createElement("form",{ref:y,method:m,action:g,onSubmit:r?c:S,...w,"data-discover":!v&&e==="render"?"true":void 0})});vv.displayName="Form";function yv(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Vf(e){let t=u.useContext(yr);return ke(t,yv(e)),t}function xv(e,{target:t,replace:n,unstable_mask:r,state:s,preventScrollReset:o,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c,unstable_useTransitions:d}={}){let f=en(),h=Nt(),p=gs(e,{relative:i});return u.useCallback(w=>{if(Jg(w,t)){w.preventDefault();let y=n!==void 0?n:cs(h)===cs(p),x=()=>f(e,{replace:y,unstable_mask:r,state:s,preventScrollReset:o,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c});d?u.startTransition(()=>x()):x()}},[h,f,p,n,r,s,t,e,o,i,l,c,d])}function Gf(e){Ct(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 t=u.useRef(Ni(e)),n=u.useRef(!1),r=Nt(),s=u.useMemo(()=>Xg(r.search,n.current?null:t.current),[r.search]),o=en(),i=u.useCallback((l,c)=>{const d=Ni(typeof l=="function"?l(new URLSearchParams(s)):l);n.current=!0,o("?"+d,c)},[o,s]);return[s,i]}var wv=0,Sv=()=>`__${String(++wv)}__`;function jv(){let{router:e}=Vf("useSubmit"),{basename:t}=u.useContext(gt),n=Og(),r=e.fetch,s=e.navigate;return u.useCallback(async(o,i={})=>{let{action:l,method:c,encType:d,formData:f,body:h}=ev(o,t);if(i.navigate===!1){let p=i.fetcherKey||Sv();await r(p,n,i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:h,formMethod:i.method||c,formEncType:i.encType||d,flushSync:i.flushSync})}else await s(i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:h,formMethod:i.method||c,formEncType:i.encType||d,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[r,s,t,n])}function kv(e,{relative:t}={}){let{basename:n}=u.useContext(gt),r=u.useContext(At);ke(r,"useFormAction must be used inside a RouteContext");let[s]=r.matches.slice(-1),o={...gs(e||".",{relative:t})},i=Nt();if(e==null){o.search=i.search;let l=new URLSearchParams(o.search),c=l.getAll("index");if(c.some(f=>f==="")){l.delete("index"),c.filter(h=>h).forEach(h=>l.append("index",h));let f=l.toString();o.search=f?`?${f}`:""}}return(!e||e===".")&&s.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(o.pathname=o.pathname==="/"?n:Dt([n,o.pathname])),cs(o)}function bv(e,{relative:t}={}){let n=u.useContext($f);ke(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Vf("useViewTransitionState"),s=gs(e,{relative:t});if(!n.isTransitioning)return!1;let o=qt(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=qt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Ea(s.pathname,i)!=null||Ea(s.pathname,o)!=null}class Kf extends Error{constructor(n){super("different_account");wr(this,"summary");this.name="DifferentAccountError",this.summary=n}}class Cv{constructor(){wr(this,"apiKey",null)}setApiKey(t){this.apiKey=t}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(t,n){return globalThis.fetch(t,{...n,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...n==null?void 0:n.headers}})}async login(t,n={}){const r=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":t,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:n.confirmWipe===!0})});if(r.status===409){const o=await r.json().catch(()=>({}));if(o!=null&&o.wouldWipe)throw new Kf(o.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!r.ok){const o=await r.json().catch(()=>({error:"Invalid API key"}));throw new Error(o.error||`Login failed: ${r.status}`)}return(await r.json()).user}async logout(){await this.fetch("/auth/logout",{method:"POST"})}async getGroups(){const t=await this.fetch("/api/groups");if(!t.ok)throw new Error(`Failed to fetch groups: ${t.status}`);const n=await t.json();return n.groups??n}async listProfiles(){const t=await this.fetch("/api/profiles");if(!t.ok)throw new Error(`Failed to fetch profiles: ${t.status}`);return(await t.json()).profiles}async getProfile(t){const n=await this.fetch(`/api/profiles/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch profile: ${n.status}`);return n.json()}async attest(t){const n=await this.fetch("/api/as/attest",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||`Attest failed: ${n.status}`)}return n.json()}async getPending(t){const n=await this.fetch(`/api/attestations/pending?domain=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch pending: ${n.status}`);const r=await n.json();return r.pending??r}async getMyAttestations(t){const n=t?`?status=${encodeURIComponent(t)}`:"",r=await this.fetch(`/api/attestations/mine${n}`);if(!r.ok)throw new Error(`Failed to fetch attestations: ${r.status}`);return((await r.json()).attestations??[]).map(o=>{var i,l;return{authorization_id:o.authorization_id,profile_id:o.profileId,path:o.path,title:o.title??null,sp_status:o.status??null,frame:o.bounds??o.frame??{},required_domains:o.requiredDomains??[],attested_domains:o.attestedDomains??[],missing_domains:(o.requiredDomains??[]).filter(c=>!(o.attestedDomains??[]).includes(c)),deferred_commitment_domains:o.deferredCommitmentDomains??[],approvers_frozen:o.approversFrozen??[],above_cap:o.aboveCap??!1,created_at:o.createdAt?new Date(o.createdAt*1e3).toISOString():"",earliest_expiry:(i=o.attestations)!=null&&i.length?new Date(Math.min(...o.attestations.map(c=>c.expiresAt))*1e3).toISOString():null,remaining_seconds:(l=o.attestations)!=null&&l.length?Math.max(0,Math.min(...o.attestations.map(c=>c.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getDenials(t){const n=new URLSearchParams;t!=null&&t.since&&n.set("since",String(t.since)),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString()?`?${n.toString()}`:"",s=await this.fetch(`/denials${r}`);if(!s.ok)throw new Error(`Failed to fetch denials: ${s.status}`);return s.json()}async getMyReceipts(t){const n=new URLSearchParams;t!=null&&t.date&&n.set("date",t.date),t!=null&&t.profile&&n.set("profile",t.profile),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString(),s=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!s.ok)throw new Error(`Failed to fetch receipts: ${s.status}`);return(await s.json()).receipts??[]}async fetchEvidenceBundle(){var s;const t=await this.fetch("/api/evidence-export"),n=await t.json();if(!t.ok)throw new Error(n.error??`Export failed (${t.status})`);const r=((s=/filename="([^"]+)"/.exec(t.headers.get("content-disposition")??""))==null?void 0:s[1])??"suveren-evidence.json";return{bundle:n,filename:r}}async getLocalAuthorizations(){const t=await this.fetch("/api/evidence/authorizations");if(!t.ok)throw new Error(`Local evidence unavailable (${t.status})`);const n=await t.json();return{authorizations:n.authorizations??{},signatures:n.signatures??{}}}async getArchivedReceipt(t){const n=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(t)}`);if(n.status===404)return null;if(!n.ok)throw new Error(`Local evidence unavailable (${n.status})`);return await n.json()}async revokeAttestation(t,n){const r=await this.fetch(`/api/authorizations/${encodeURIComponent(t)}/revoke`,{method:"POST",body:JSON.stringify({reason:n??"Revoked by user"})});if(!r.ok){const s=await r.json().catch(()=>({error:"Failed to revoke"}));throw new Error(s.error||`Revoke failed: ${r.status}`)}}async getAttestations(t){const n=await this.fetch(`/api/attestations?authorization_id=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch attestations: ${n.status}`);return n.json()}async getGroupById(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch group: ${n.status}`);return n.json()}async createGroup(t){const n=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:t})});if(!n.ok){const o=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(o.error||`Create group failed: ${n.status}`)}const r=await n.json(),s=r.group||r;return{id:s.id,name:s.name,myDomains:s.myDomains||[],isAdmin:!0}}async joinGroup(t){const n=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:t})});if(!n.ok){const o=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(o.error||`Join group failed: ${n.status}`)}const r=await n.json(),s=r.group||r;return{id:s.id,name:s.name,myDomains:s.myDomains||[],isAdmin:s.isAdmin||!1}}async inviteToGroup(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/invite`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||`Invite failed: ${n.status}`)}return n.json()}async getMyTeam(){const t=await this.fetch("/api/groups/me");if(!t.ok)return null;const n=await t.json();return n.group?{group:n.group,membership:n.membership}:null}async listUsers(){const t=await this.fetch("/api/users");return t.ok?(await t.json()).users??[]:[]}async setPubkey(t){const n=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:t})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(r.error||`setPubkey failed: ${n.status}`)}}async getPubkey(t){const n=await this.fetch(`/api/users/${encodeURIComponent(t)}/pubkey`);return n.status===404||!n.ok?null:(await n.json()).pubkey??null}async leaveTeam(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/leave`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to leave team"}));throw new Error(r.error||`Leave failed: ${n.status}`)}}async getVaultStatus(){const t=await this.fetch("/vault/status");if(!t.ok)throw new Error(`Failed to fetch vault status: ${t.status}`);return t.json()}async getGatewaySettings(){const t=await this.fetch("/api/gateway-settings");if(!t.ok)throw new Error(`Failed to load settings: ${t.status}`);return t.json()}async setGatewaySettings(t){const n=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`Failed to save settings: ${n.status}`);return n.json()}async getArchivedMandates(){const t=await this.fetch("/api/archived-mandates");if(!t.ok)throw new Error(`Failed to load archived mandates: ${t.status}`);return(await t.json()).archived}async setMandateArchived(t,n){const r=await this.fetch(`/api/archived-mandates/${encodeURIComponent(t)}`,{method:n?"PUT":"DELETE"});if(!r.ok)throw new Error(`Failed to ${n?"archive":"unarchive"} mandate: ${r.status}`);return(await r.json()).archived}async getCredential(t){const n=await this.fetch(`/vault/credentials/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to check credential: ${n.status}`);return n.json()}async setCredential(t,n){const r=await this.fetch(`/vault/credentials/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)});if(!r.ok)throw new Error(`Failed to save credential: ${r.status}`)}async testCredential(t){const n=await this.fetch(`/vault/test/${encodeURIComponent(t)}`,{method:"POST"});if(!n.ok)throw new Error(`Test failed: ${n.status}`);return n.json()}async aiAssist(t){const n=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI request failed"}))).error,disclaimer:"AI surfaces reality. You supply intent."}}async aiIntentReview(t){const n=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI request failed"}))).error}}async aiTest(t){const n=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(t??{})});if(!n.ok)throw new Error(`AI test failed: ${n.status}`);return n.json()}async aiModels(t){const n=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(t??{})});if(!n.ok)throw new Error(`Model list failed: ${n.status}`);return n.json()}async getMcpHealth(){const t=await this.fetch("/mcp/health");if(!t.ok)throw new Error(`MCP server unreachable: ${t.status}`);return t.json()}async getMcpIntegrations(){const t=await this.fetch("/mcp/integrations");if(!t.ok)throw new Error(`Failed to fetch integrations: ${t.status}`);return t.json()}async getOAuthHealth(t){try{const n=await this.fetch(`/auth/oauth/${encodeURIComponent(t)}/health`);return n.ok?await n.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const t=await this.fetch("/mcp/integrations/manifests");if(!t.ok)throw new Error(`Failed to fetch manifests: ${t.status}`);return t.json()}async discoverScopeField(t,n){const r=await this.fetch(`/integrations/${encodeURIComponent(t)}/discover/${encodeURIComponent(n)}`);if(!r.ok){const s=await r.json().catch(()=>({error:`Discovery failed: ${r.status}`}));throw new Error(s.error)}return r.json()}async activateIntegration(t){const n=await this.fetch(`/mcp/integrations/${encodeURIComponent(t)}/activate`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed"}));throw new Error(r.error||`Failed: ${n.status}`)}return n.json()}async removeMcpIntegration(t){const n=await this.fetch(`/mcp/integrations/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`Failed to remove integration: ${n.status}`)}async setReadPolicy(t,n){const r=await this.fetch(`/integrations/${encodeURIComponent(t)}/read-policy`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAgeDays:n})});if(!r.ok){const s=await r.json().catch(()=>({error:`HTTP ${r.status}`}));throw new Error(s.error)}}async getTeamProfileConfig(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`);if(r.status===404||!r.ok)return null;const s=await r.json();return(s==null?void 0:s.config)??null}async setTeamProfileConfig(t,n,r){const s=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify(r)});if(!s.ok){const o=await s.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(o.error||`setTeamProfileConfig failed: ${s.status}`)}}async encryptIntent(t,n){const r=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:t,recipients:n})});if(!r.ok){const s=await r.json().catch(()=>({error:"Encryption failed"}));throw new Error(s.error||`encryptIntent failed: ${r.status}`)}return r.json()}async getApproversPubkeys(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}/approvers/pubkeys`);return r.ok?(await r.json()).approvers??[]:[]}async deleteTeamProfileConfig(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"DELETE"});if(!r.ok){const s=await r.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(s.error||`deleteTeamProfileConfig failed: ${r.status}`)}}async getProposals(t){const n=await this.fetch(`/api/proposals?domain=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch proposals: ${n.status}`);return(await n.json()).proposals??[]}async resolveProposal(t,n,r){const s=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/resolve`,{method:"POST",body:JSON.stringify({action:n,domain:r})});if(!s.ok){const o=await s.json().catch(()=>({error:"Failed"}));throw new Error(o.error||`Failed: ${s.status}`)}return s.json()}async getProposalsForApprover(){const t=await this.fetch("/api/proposals?approver=me");if(!t.ok)throw new Error(`Failed to fetch approver proposals: ${t.status}`);return(await t.json()).proposals??[]}async approveProposal(t){const n=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/approve`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed"}));throw new Error(r.error||`approveProposal failed: ${n.status}`)}return n.json()}async rejectProposal(t,n){const r=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/reject`,{method:"POST",body:JSON.stringify({reason:n})});if(!r.ok){const s=await r.json().catch(()=>({error:"Failed"}));throw new Error(s.error||`rejectProposal failed: ${r.status}`)}return r.json()}async getAttestationIntent(t){const n=await this.fetch(`/api/authorizations/${encodeURIComponent(t)}/intent`);return n.status===404||n.status===403||!n.ok?null:n.json()}async decryptIntent(t){const n=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const s=await n.json().catch(()=>({error:"Decryption failed"}));throw new Error(s.error||`decryptIntent failed: ${n.status}`)}return(await n.json()).intent}async storeApprovedIntent(t,n){const r=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:t,intent:n})});if(!r.ok){const s=await r.json().catch(()=>({error:"Failed"}));throw new Error(s.error||`storeApprovedIntent failed: ${r.status}`)}}async listTeamAuthorizations(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/attestations`);if(!n.ok)throw new Error(`Failed to fetch team authorizations: ${n.status}`);return((await n.json()).items??[]).map(s=>{var l,c;const o=s.owner??{userId:""};return{authorization_id:s.authorization_id??s.authorizationId,profile_id:s.profileId??s.profile_id,path:s.path??"",title:s.title??null,sp_status:s.status??s.sp_status??null,frame:s.bounds??s.frame??{},required_domains:s.requiredDomains??s.required_domains??[],attested_domains:s.attestedDomains??s.attested_domains??[],missing_domains:(s.requiredDomains??s.required_domains??[]).filter(d=>!(s.attestedDomains??s.attested_domains??[]).includes(d)),deferred_commitment_domains:s.deferredCommitmentDomains??s.deferred_commitment_domains??[],approvers_frozen:s.approversFrozen??s.approvers_frozen??[],above_cap:s.aboveCap??s.above_cap??!1,created_at:s.createdAt?new Date(s.createdAt*1e3).toISOString():s.created_at??"",earliest_expiry:(l=s.attestations)!=null&&l.length?new Date(Math.min(...s.attestations.map(d=>d.expiresAt))*1e3).toISOString():null,remaining_seconds:(c=s.attestations)!=null&&c.length?Math.max(0,Math.min(...s.attestations.map(d=>d.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:o}})}async listTeamReceipts(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts`);if(!n.ok)throw new Error(`Failed to fetch team receipts: ${n.status}`);return(await n.json()).receipts??[]}async getMyReceiptsPage(t){const n=new URLSearchParams;t!=null&&t.before&&n.set("before",t.before),t!=null&&t.profile&&n.set("profile",t.profile),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString(),s=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!s.ok)throw new Error(`Failed to fetch receipts: ${s.status}`);const o=await s.json();return{receipts:o.receipts??[],nextBefore:o.nextBefore??null}}async listTeamReceiptsPage(t,n){const r=new URLSearchParams;n!=null&&n.before&&r.set("before",n.before),n!=null&&n.profile&&r.set("profile",n.profile),n!=null&&n.limit&&r.set("limit",String(n.limit));const s=r.toString(),o=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts${s?"?"+s:""}`);if(!o.ok)throw new Error(`Failed to fetch team receipts: ${o.status}`);const i=await o.json();return{receipts:i.receipts??[],nextBefore:i.nextBefore??null}}async getThread(t){const n=t.sinceDays??7,r=t.status??"pending",s=t.domain||"owner",o=await this.getProposals(s);let i=[];if(r==="all"){const l=[],c=new Date;for(let f=0;f<n;f++){const h=new Date(c);h.setUTCDate(c.getUTCDate()-f),l.push(h.toISOString().slice(0,10))}i=(await Promise.all(l.map(f=>this.getMyReceipts({date:f,profile:t.profile})))).flat()}return{proposals:o,receipts:i}}async getAutostart(){const t=await this.fetch("/autostart");if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}async setAutostart(t){const n=await this.fetch("/autostart",{method:t?"POST":"DELETE"});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.message||`HTTP ${n.status}`)}}async getGateContent(t){const n=await this.fetch(`/gate-content?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch gate content: ${n.status}`);return(await n.json()).entry??null}async resyncGates(){const t=await this.fetch("/resync-gates",{method:"POST"});if(!t.ok)throw new Error(`Failed to resync gates: ${t.status}`)}async getEnrichedAuthorizations(){const t=await this.fetch("/active-authorizations");if(!t.ok)throw new Error(`Failed to fetch authorizations: ${t.status}`);return(await t.json()).authorizations??[]}async pushGateContent(t){const n=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(r.error||`Push gate content failed: ${n.status}`)}}async getAgentContext(){const t=await this.fetch("/agent-brief/context");if(!t.ok)throw new Error(`Failed to fetch agent context: ${t.status}`);return(await t.json()).content}async saveAgentContext(t){const n=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:t})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(r.error||`Save failed: ${n.status}`)}}async aiChat(t){const n=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI chat failed"}))).error||`Chat failed: ${n.status}`}}async getAIPrompts(){const t=await this.fetch("/ai-prompts");if(!t.ok)throw new Error(`Failed to load AI prompts: ${t.status}`);return t.json()}async setAIPrompt(t,n){const r=await this.fetch(`/ai-prompts/${t}`,{method:"PUT",body:JSON.stringify({value:n})});if(!r.ok){const s=await r.json().catch(()=>({error:"Save failed"}));throw new Error(s.error||`Save failed: ${r.status}`)}}}const z=new Cv,Yf=u.createContext(null);function Nv({children:e}){const[t,n]=u.useState(null),[r,s]=u.useState("personal"),[o,i]=u.useState(null),[l,c]=u.useState(""),[d,f]=u.useState(null),[h,p]=u.useState(null),[w,y]=u.useState(!1),[x,j]=u.useState(""),g=u.useRef(!1),m=u.useRef(null),v=u.useCallback(async()=>{if(g.current)try{const T=await z.getMyTeam();if(T){const{group:E,membership:L}=T;f(E),p(L),s("team"),i(E);const D=m.current??L.domains[0]??"owner";c(D)}else f(null),p(null),s("personal")}catch{}},[]);u.useEffect(()=>{const T=()=>{document.visibilityState==="visible"&&v()};return document.addEventListener("visibilitychange",T),()=>document.removeEventListener("visibilitychange",T)},[v]);const S=u.useCallback(async(T,E={})=>{y(!0),j("");try{z.setApiKey(T),g.current=!0;const L=await z.login(T,E);n(L),m.current=L.id;const D=await z.getGroups(),G=D.find(J=>J.isPersonal)??D[0]??null;i(G),c("owner"),await v()}catch(L){throw z.clearApiKey(),g.current=!1,j(L instanceof Error?L.message:"Login failed"),L}finally{y(!1)}},[v]),b=u.useCallback(async()=>{await z.logout(),z.clearApiKey(),g.current=!1,m.current=null,n(null),i(null),c(""),f(null),p(null),s("personal"),j("")},[]),N=u.useCallback(()=>j(""),[]),C=u.useCallback((T,E)=>{i(T),c(E)},[]);return a.jsx(Yf.Provider,{value:{user:t,mode:r,group:o,domain:l,groupId:(o==null?void 0:o.id)??null,activeTeam:d,activeMembership:h,isLoading:w,error:x,login:S,logout:b,clearError:N,activeGroup:o,activeDomain:l,groups:o?[o]:[],setActiveContext:C,refreshGroups:v},children:e})}function Oe(){const e=u.useContext(Yf);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const Qf=u.createContext(null);function Ev({children:e}){const{user:t}=Oe(),n=u.useRef(null),[r,s]=u.useState(!1),o=u.useRef(new Map),i=u.useCallback((l,c)=>{const d=o.current;return d.has(l)||d.set(l,new Set),d.get(l).add(c),()=>{var f;(f=d.get(l))==null||f.delete(c)}},[]);return u.useEffect(()=>{if(!t){n.current&&(n.current.close(),n.current=null,s(!1));return}if(n.current)return;const l=z.getApiKey();if(!l)return;const c=new EventSource(`/events?key=${encodeURIComponent(l)}`);n.current=c,c.onopen=()=>s(!0),c.onerror=()=>s(!1);const d=["integration-changed","attestation-changed","proposal-added","proposal-resolved","team-membership-changed","action-approval-needed","action-resolved","proposal-approved","proposal-rejected"];for(const f of d)c.addEventListener(f,h=>{let p;try{p=JSON.parse(h.data)}catch{p=null}const w=o.current.get(f);if(w)for(const y of w)try{y(p)}catch(x){console.error(`[EventSource] handler for "${f}" threw:`,x)}});return()=>{c.close(),n.current=null,s(!1)}},[t]),a.jsx(Qf.Provider,{value:{connected:r,addListener:i},children:e})}function fe(e,t){const n=u.useContext(Qf);if(!n)return;const{addListener:r}=n;u.useEffect(()=>r(e,t),[e,t,r])}const Vr="suveren-theme",eu="hap-theme";function Ms(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const t=localStorage.getItem(eu);t!==null&&localStorage.getItem(Vr)===null&&localStorage.setItem(Vr,t),t!==null&&localStorage.removeItem(eu)})();function Jf(){const[e,t]=u.useState(()=>{const o=localStorage.getItem(Vr);return o==="light"||o==="dark"?o:"system"}),[n,r]=u.useState(()=>Ms(e));u.useEffect(()=>{const o=document.documentElement,i=Ms(e);o.setAttribute("data-theme",i),e==="system"?localStorage.removeItem(Vr):localStorage.setItem(Vr,e),r(Ms(e))},[e]),u.useEffect(()=>{if(e!=="system")return;const o=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>r(Ms("system"));return o.addEventListener("change",i),()=>o.removeEventListener("change",i)},[e]);const s=u.useCallback(()=>{t(o=>o==="system"?"light":o==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:n,toggle:s}}const Tv=5*60*1e3,zv=2e3;function _l(){const[e,t]=u.useState(!1),[n,r]=u.useState("docker"),[s,o]=u.useState(""),[i,l]=u.useState(null),[c,d]=u.useState(!1),[f,h]=u.useState(!1),[p,w]=u.useState(!1),y=u.useRef(null);return u.useEffect(()=>{let x=!1;const j=(v=!1)=>{fetch(v?"/health?refresh=1":"/health").then(S=>S.json()).then(S=>{x||(S.installMethod&&r(S.installMethod),typeof S.latestVersion<"u"&&l(S.latestVersion),S.updateAvailable&&t(!0),S.version&&(o(S.version),y.current===null?y.current=S.version:S.version!==y.current&&S.version!=="dev"&&d(!0)))}).catch(()=>{})};j(!0);const g=setInterval(()=>j(!1),p?zv:Tv),m=()=>{document.visibilityState==="visible"&&j(!1)};return document.addEventListener("visibilitychange",m),window.addEventListener("focus",m),()=>{x=!0,clearInterval(g),document.removeEventListener("visibilitychange",m),window.removeEventListener("focus",m)}},[p]),{updateAvailable:e&&!f,installMethod:n,version:s,latestVersion:i,serverRestarted:c,startFastPolling:()=>w(!0),dismiss:()=>h(!0)}}function Rv({size:e=20}){return a.jsxs("svg",{width:e,height:e,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[a.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),a.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function Pv(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const tu={system:"◑",light:"☀",dark:"☾"};function Al({onMenuToggle:e}){const{user:t,logout:n}=Oe(),{theme:r,toggle:s}=Jf(),{version:o,updateAvailable:i,latestVersion:l}=_l(),c=Pv(o);return a.jsx("nav",{className:"top-nav",children:a.jsxs("div",{className:"top-nav-inner",children:[a.jsxs("div",{className:"logo-group",children:[a.jsx(Rv,{size:20}),a.jsx("span",{className:"logo",children:"Suveren"}),a.jsx("span",{className:"version-badge",children:"Local Gateway"}),c&&a.jsxs("span",{className:"gw-version",title:i&&l?`Running v${c} — v${l} is available`:"Running gateway version","data-stale":i?"true":void 0,children:["v",c,i&&l?` → ${l}`:""]})]}),a.jsx("div",{className:"nav-spacer"}),a.jsx("div",{className:"nav-actions nav-actions-desktop",children:t?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"user-chip",children:a.jsx("strong",{children:t.name})}),a.jsx("button",{className:"theme-toggle",onClick:s,title:`Theme: ${r}`,children:tu[r]}),a.jsx("button",{className:"nav-logout",onClick:n,children:"Logout"})]}):a.jsx("button",{className:"theme-toggle",onClick:s,title:`Theme: ${r}`,children:tu[r]})}),t&&e&&a.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function $l(e,t){var n;if((n=t==null?void 0:t.revokedSet)!=null&&n.has(e.authorization_id))return"revoked";switch(e.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return e.remaining_seconds===null||e.remaining_seconds<=0?"expired":e.missing_domains.length>0?"pending":"active"}function Xf(e){return e==="expired"||e==="revoked"}function qf(e,t){var n;return!!((n=t==null?void 0:t.archivedSet)!=null&&n.has(e.authorization_id))&&Xf($l(e,t))}function Ta(e,t){return qf(e,t)?"archived":$l(e,t)}function Zf(e,t){const n={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const r of e)n[Ta(r,t)].push(r);return n}function Iv(e,t){return t==="expired"?e.earliest_expiry?{iso:e.earliest_expiry,meaning:"expired"}:null:e.created_at?{iso:e.created_at,meaning:"created"}:null}function Ft(e,t,n){const r=u.useRef(e);r.current=e,u.useEffect(()=>{let s=null;const o=()=>typeof document>"u"?!0:document.visibilityState==="visible",i=()=>{o()&&r.current()},l=()=>{s===null&&(s=setInterval(i,t))},c=()=>{s!==null&&(clearInterval(s),s=null)},d=()=>{o()?(r.current(),l()):c()};return o()&&(r.current(),l()),document.addEventListener("visibilitychange",d),()=>{c(),document.removeEventListener("visibilitychange",d)}},[t,n])}const ep=u.createContext(null),_v=3e4,Av=5e3,$v=3e5;function Lv(e,t,n){return t===0?"loading":e!=null&&e.running?"running":e!=null&&e.error?"error":e&&n?"starting":"not-running"}function Mv({children:e}){const[t,n]=u.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),r=u.useRef(null),s=u.useCallback(async()=>{let d=!1;const[f,h]=await Promise.all([z.getIntegrationManifests().catch(()=>(d=!0,{manifests:[]})),z.getMcpHealth().catch(()=>null)]);n(w=>({...w,manifests:f.manifests,integrations:(h==null?void 0:h.integrations)??w.integrations,activeSessions:(h==null?void 0:h.activeSessions)??w.activeSessions,mcpServerUp:!!h,manifestsError:d,fetchCount:w.fetchCount+1}));const p=f.manifests.filter(w=>w.oauth);if(p.length>0){const w=await Promise.all(p.map(async y=>[y.id,await z.getOAuthHealth(y.id)]));n(y=>({...y,authHealth:Object.fromEntries(w)}))}},[]),o=t.fetchCount>0&&t.manifests.some(d=>{const f=t.integrations.find(h=>h.id===d.id);return f&&!f.running});fe("integration-changed",s),Ft(s,o?Av:$v);const i=u.useMemo(()=>{const d=new Map(t.integrations.map(p=>[p.id,p])),f=Date.now();o&&r.current===null?r.current=f:o||(r.current=null);const h=r.current!==null&&f-r.current<_v;return t.manifests.map(p=>{const w=d.get(p.id),y=Lv(w,t.fetchCount,h),x=t.authHealth[p.id];return{id:p.id,manifest:p,integration:w,state:y,authStatus:x==null?void 0:x.status,authAccount:x==null?void 0:x.account,authError:x==null?void 0:x.error}})},[t,o]),l=u.useMemo(()=>i.filter(d=>d.state==="not-running"||d.state==="error"||d.authStatus==="failed").length,[i]),c={loading:t.fetchCount===0,mcpServerUp:t.mcpServerUp,manifestsError:t.manifestsError,entries:i,attentionCount:l,activeSessions:t.activeSessions,refresh:s};return a.jsx(ep.Provider,{value:c,children:e})}function Ll(){const e=u.useContext(ep);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const Fv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/proposals",icon:"▷",label:"Pending Approvals",statusKey:"proposals"},{to:"/authorizations",icon:"☰",label:"Mandates",statusKey:"authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief"},{to:"/audit",icon:"▣",label:"Tickets"},{to:"/groups",icon:"◉",label:"Team",teamOnly:!0},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations"},{to:"/settings",icon:"⚙",label:"AI Assistant",statusKey:"assistant"}];function Ov(){const{activeDomain:e}=Oe(),[t,n]=u.useState({}),r=u.useCallback(async()=>{try{const[s,o,i,l,c,d]=await Promise.all([z.getCredential("ai-config").catch(()=>null),z.getMyAttestations().catch(()=>null),z.getProposals(e||"owner").catch(()=>null),z.getProposalsForApprover().catch(()=>null),z.getAgentContext().catch(()=>""),z.getArchivedMandates().catch(()=>[])]),f={};if(s&&!s.configured&&(f.assistant=1),o){const y=Zf(o,{archivedSet:new Set(d)}).expired.length;y>0&&(f.authorizations=y)}const h=(i==null?void 0:i.length)??0,p=(l==null?void 0:l.length)??0,w=h+p;w>0&&(f.proposals=w),(!c||!c.trim())&&(f.brief=1),n(f)}catch{}},[e]);return fe("attestation-changed",r),fe("proposal-added",r),fe("proposal-resolved",r),fe("proposal-approved",r),fe("proposal-rejected",r),fe("team-membership-changed",r),u.useEffect(()=>(window.addEventListener("suveren:archived-changed",r),()=>window.removeEventListener("suveren:archived-changed",r)),[r]),Ft(r,3e5,e),t}const Bv={marginLeft:"auto",minWidth:"1.25rem",height:"1.25rem",padding:"0 0.375rem",borderRadius:"0.625rem",background:"var(--warning)",color:"var(--bg-elevated)",fontSize:"0.7rem",fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},Dv={position:"fixed",bottom:"1.5rem",left:"50%",transform:"translateX(-50%)",background:"var(--bg-elevated, #1e1e2e)",color:"var(--text-primary, #e2e8f0)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.625rem 1rem",fontSize:"0.85rem",boxShadow:"0 4px 16px rgba(0,0,0,0.3)",zIndex:9999,whiteSpace:"nowrap",pointerEvents:"none"};function Uv(){const{mode:e,group:t,domain:n,activeTeam:r}=Oe(),s=Ov(),{attentionCount:o}=Ll(),i={...s};o>0&&(i.integrations=o);const l=Fv.filter(p=>!p.teamOnly||e==="team"),c=u.useRef(null),[d,f]=u.useState(null),h=Nt();return u.useEffect(()=>{if(c.current===null){c.current=e;return}c.current!==e&&(e==="team"&&r?f(`You are now acting in team context — ${r.name}`):e==="personal"&&f("You have left the team — back to personal context"),c.current=e)},[e,r]),u.useEffect(()=>{f(null)},[h.pathname]),a.jsxs("div",{className:"sidebar",children:[a.jsx("ul",{className:"sidebar-nav",children:l.map(p=>{const w=p.statusKey?i[p.statusKey]:0;return a.jsx("li",{children:a.jsxs(Il,{to:p.to,end:p.to==="/",className:({isActive:y})=>`sidebar-item${y?" active":""}`,children:[a.jsx("span",{className:"icon",children:p.icon}),p.label,w?a.jsx("span",{style:Bv,children:w}):null]})},p.to)})}),a.jsxs("div",{className:"sidebar-context",children:[a.jsx("div",{className:"ctx-label",children:"Active context"}),a.jsx("div",{className:"ctx-value",children:e==="personal"?"personal":t?`${t.name} / ${n}`:n})]}),d&&a.jsx("div",{style:Dv,role:"status","aria-live":"polite",children:d})]})}const To="suveren:updatedTo";function Wv(e){return e==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":e==="dev"?"git pull && pnpm install":"docker rm -f suveren-gateway 2>/dev/null; docker ps -q --filter publish=7400 --filter publish=7430 | xargs -r docker rm -f; docker pull ghcr.io/suverenai/suveren-gateway:latest && docker run -d --name suveren-gateway -p 7400:3000 -p 7430:3030 -v $HOME/.suveren:/app/data ghcr.io/suverenai/suveren-gateway"}function Hv(){const e=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const n of e)if(!n.closest(".update-overlay"))return!0;const t=document.activeElement;if(t&&(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable)){const n=t.value;if(n&&n.trim())return!0}return!1}function tp(){const{updateAvailable:e,installMethod:t,version:n,latestVersion:r,serverRestarted:s,startFastPolling:o,dismiss:i}=_l(),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[h,p]=u.useState(()=>{try{const v=sessionStorage.getItem(To);if(v)return sessionStorage.removeItem(To),v}catch{}return null}),w=Wv(t),y=u.useRef(null),x=v=>{try{sessionStorage.setItem(To,v||r||"✓")}catch{}window.location.reload()};u.useEffect(()=>{if(!h)return;const v=setTimeout(()=>p(null),6e3);return()=>clearTimeout(v)},[h]),u.useEffect(()=>{if(!l||!s)return;const v=()=>Hv()?!1:(x(n),!0);if(v())return;const S=setInterval(v,1500);return()=>clearInterval(S)},[l,s,n]),u.useEffect(()=>(document.body.classList.toggle("is-updating",l),()=>document.body.classList.remove("is-updating")),[l]);const j=e&&!l&&!h||!!h&&!l;u.useEffect(()=>{if(!j){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const v=()=>{var N;const b=((N=y.current)==null?void 0:N.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${b}px`)};v();const S=new ResizeObserver(v);return y.current&&S.observe(y.current),()=>{S.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[j]);const g=()=>{c(!0),o()},m=async()=>{try{await navigator.clipboard.writeText(w),f(!0),setTimeout(()=>f(!1),1800)}catch{}};return a.jsxs(a.Fragment,{children:[h&&!l&&a.jsx("div",{ref:y,className:"update-banner is-live",role:"status","aria-live":"polite",children:a.jsxs("div",{className:"update-banner-row",children:[a.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",h&&h!=="✓"?` — ${h} is live`:" — now live","."]}),a.jsx("button",{className:"update-banner-x",onClick:()=>p(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!l&&!h&&a.jsx("div",{ref:y,className:"update-banner",role:"status","aria-live":"polite",children:a.jsxs("div",{className:"update-banner-row",children:[a.jsx("span",{className:"update-banner-text",children:"Update available."}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.jsx("button",{className:"btn btn-sm btn-secondary",onClick:g,children:"Update"}),a.jsx("button",{className:"update-banner-x",onClick:i,"aria-label":"Dismiss",children:"×"})]})]})}),l&&a.jsx("div",{className:"update-overlay",children:a.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[a.jsx("div",{className:"update-spinner"}),a.jsxs("h2",{children:["Finishing the update","…"]}),a.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",a.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),a.jsxs("div",{className:"update-cmd-row",children:[a.jsx("code",{className:"update-cmd",children:w}),a.jsx("button",{className:"btn btn-sm btn-primary",onClick:m,children:d?"Copied":"Copy"})]}),a.jsxs("div",{className:"update-status",children:[a.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),a.jsxs("div",{className:"update-overlay-actions",children:[a.jsx("button",{className:"btn btn-primary",onClick:()=>x(n),children:"Reload now"}),a.jsx("button",{className:"btn btn-secondary",onClick:()=>c(!1),children:"Cancel"})]})]})})]})}const Vv={system:"◑",light:"☀",dark:"☾"},Gv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/proposals",icon:"▷",label:"Pending Approvals"},{to:"/authorizations",icon:"☰",label:"Mandates"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/audit",icon:"▣",label:"Tickets"},{to:"/groups",icon:"◉",label:"Team"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"AI Assistant"}];function Kv({open:e,onClose:t}){const{user:n,activeGroup:r,activeDomain:s,logout:o}=Oe(),{theme:i,toggle:l}=Jf(),c=Nt();return u.useEffect(()=>{t()},[c.pathname]),e?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mobile-menu-backdrop",onClick:t}),a.jsxs("div",{className:"mobile-menu-panel",children:[n&&a.jsxs("div",{className:"mobile-menu-header",children:[a.jsx("strong",{children:n.name}),a.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:r?`${r.name} / ${s}`:s||"personal"})]}),a.jsx("nav",{className:"mobile-menu-nav",children:Gv.map(d=>a.jsxs(Il,{to:d.to,end:d.to==="/",className:({isActive:f})=>`mobile-menu-item${f?" active":""}`,onClick:t,children:[a.jsx("span",{className:"icon",children:d.icon}),d.label]},d.to))}),a.jsxs("div",{className:"mobile-menu-footer",children:[a.jsxs("button",{className:"mobile-menu-action",onClick:()=>{l()},children:[a.jsx("span",{className:"icon",children:Vv[i]}),"Theme: ",i]}),a.jsx("button",{className:"mobile-menu-action",onClick:()=>{o(),t()},children:"Logout"})]})]})]}):null}function np(e){return e.status==="pending"}function Yv(e,t){return e.filter(np).length+t.length}const Cn=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],Qv=500;function Jv(){const{user:e,domain:t}=Oe(),[n,r]=u.useState(0),s=u.useRef(null),o=u.useCallback(async()=>{if(!e){r(0);return}try{const[l,c]=await Promise.all([z.getProposals(t||"owner").catch(()=>[]),z.getProposalsForApprover().catch(()=>[])]);r(Yv(l,c))}catch{r(0)}},[e,t]),i=u.useCallback(()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o()},Qv)},[o]);return u.useEffect(()=>(o(),()=>{s.current&&clearTimeout(s.current)}),[o]),fe(Cn[0],i),fe(Cn[1],i),fe(Cn[2],i),fe(Cn[3],i),fe(Cn[4],i),fe(Cn[5],i),fe(Cn[6],i),n}const nu="Suveren",Xv="/favicon.svg",qv="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",Fs={x1:74.54,y1:22.74,x2:94.46,y2:34.24},Zv=14,ey="#f59e0b";function ty(e){const t=rp(e);return t>0?`(${t}) ${nu}`:nu}function rp(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function ny(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
52
+ <path class="m" d="${qv}"/>
53
+ <line class="m" x1="${Fs.x1}" y1="${Fs.y1}" x2="${Fs.x2}" y2="${Fs.y2}"/>
54
+ <circle cx="103" cy="103" r="25" fill="${ey}"/>
55
+ <style>.m{stroke:#111111;stroke-width:${Zv};fill:none;stroke-linecap:round}@media (prefers-color-scheme:dark){.m{stroke:#ffffff;stroke-width:13.3}}</style>
56
+ </svg>`;return`data:image/svg+xml,${encodeURIComponent(e)}`}function ry(){return document.querySelector('link[rel="icon"]')}function sp(e){const t=rp(e);document.title=ty(t);const n=ry();if(!n)return;const r=t>0?ny():Xv;n.getAttribute("href")!==r&&n.setAttribute("href",r)}function sy(){sp(0)}function ay(){const e=Jv();return u.useEffect(()=>{sp(e)},[e]),u.useEffect(()=>sy,[]),null}function oy(){const[e,t]=u.useState(!1);return a.jsxs(Mv,{children:[a.jsx(ay,{}),a.jsx(Al,{onMenuToggle:()=>t(!e)}),a.jsx(tp,{}),a.jsx(Uv,{}),a.jsx(Kv,{open:e,onClose:()=>t(!1)}),a.jsx("div",{className:"main-content",children:a.jsx("div",{className:"page-inner",children:a.jsx(Wg,{})})})]})}function iy(){const[e,t]=u.useState(""),{login:n,isLoading:r,error:s,clearError:o}=Oe(),[i,l]=u.useState(null),c=async()=>{if(e.trim()){o();try{await n(e)}catch(h){if(h instanceof Kf){l(h.summary);return}}}},d=async()=>{l(null),o();try{await n(e,{confirmWipe:!0})}catch{}},f=()=>{l(null)};return a.jsxs(a.Fragment,{children:[a.jsx(Al,{}),a.jsx(tp,{}),a.jsxs("div",{className:"login-split",children:[a.jsx("div",{className:"login-split-left",children:a.jsxs("div",{style:{maxWidth:"28rem"},children:[a.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."}),a.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 receipts."})]})}),a.jsx("div",{className:"login-split-right",children:a.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[a.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[a.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),a.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage authorizations."})]}),s&&a.jsx("div",{className:"error-message",children:s}),a.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[a.jsx("label",{className:"form-label",children:"API Key"}),a.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:e,onChange:h=>t(h.target.value),onKeyDown:h=>h.key==="Enter"&&c(),disabled:r,style:{padding:"0.75rem"}}),a.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),a.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:c,disabled:r,style:{marginBottom:"2rem"},children:r?"Signing in...":"Sign In"}),a.jsx("div",{className:"login-divider",children:"New here?"}),a.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[a.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",a.jsx("br",{}),"then come back to sign in."]}),a.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"})]}),a.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[a.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),a.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[a.jsxs(a.Fragment,{children:["Create an account at ",a.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 authorizing agents"].map((h,p)=>a.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:p<2?"0.5rem":0},children:[a.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[p+1,"."]}),h]},p))})]})]})})]}),i&&a.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wipe-warning-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:f,children:a.jsxs("div",{className:"card",onClick:h=>h.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[a.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),a.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 ",a.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),a.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[a.jsxs("li",{children:[i.credentialCount," stored service credential",i.credentialCount===1?"":"s",i.credentialIds.length>0&&a.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",i.credentialIds.slice(0,5).join(", "),i.credentialIds.length>5?`, +${i.credentialIds.length-5} more`:"",")"]})]}),a.jsxs("li",{children:[i.serviceCount," configured integration",i.serviceCount===1?"":"s"]}),a.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),a.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),a.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Authorizations and receipts on the Service Provider are NOT affected — only this gateway's local state is wiped."}),a.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."}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[a.jsx("button",{className:"btn btn-ghost",onClick:f,disabled:r,children:"Cancel"}),a.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:d,disabled:r,children:r?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function ly(){const{setActiveContext:e}=Oe(),t=en(),[n,r]=u.useState(""),[s,o]=u.useState(""),[i,l]=u.useState(""),[c,d]=u.useState(!1),f=async()=>{if(n.trim()){d(!0),l("");try{const p=await z.joinGroup(n.trim());e(p,p.myDomains[0]||""),t("/")}catch(p){l(p instanceof Error?p.message:"Failed to join group")}finally{d(!1)}}},h=async()=>{if(s.trim()){d(!0),l("");try{const p=await z.createGroup(s.trim());e(p,p.myDomains[0]||""),t("/")}catch(p){l(p instanceof Error?p.message:"Failed to create group")}finally{d(!1)}}};return a.jsxs(a.Fragment,{children:[a.jsx(Al,{}),a.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:a.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[a.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[a.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join Your Team"}),a.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6},children:"Join an existing team or create a new one to share authority across domains."})]}),i&&a.jsx("div",{className:"error-message",children:i}),a.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[a.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing group"}),a.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),a.jsxs("div",{className:"invite-input-row",children:[a.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:n,onChange:p=>r(p.target.value),onKeyDown:p=>p.key==="Enter"&&f(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:c}),a.jsx("button",{className:"btn btn-primary",onClick:f,disabled:c,children:"Join"})]})]}),a.jsxs("div",{className:"card",children:[a.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new group"}),a.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members. Assign domains after creation."}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("input",{className:"form-input",placeholder:"Group name (e.g., Acme Corp)",value:s,onChange:p=>o(p.target.value),onKeyDown:p=>p.key==="Enter"&&h(),style:{flex:1},disabled:c}),a.jsx("button",{className:"btn btn-secondary",onClick:h,disabled:c,children:"Create"})]})]})]})})]})}const Ei="suveren-setup-ai-skipped",Ti="suveren-setup-agent-done",zi="suveren-setup-dismissed",cy={"hap-setup-ai-skipped":Ei,"hap-setup-agent-done":Ti,"hap-setup-dismissed":zi};function uy(){for(const[e,t]of Object.entries(cy)){const n=localStorage.getItem(e);n!==null&&localStorage.getItem(t)===null&&localStorage.setItem(t,n),n!==null&&localStorage.removeItem(e)}}uy();const zo={"claude-code":{label:"Claude Code",snippet:e=>JSON.stringify({mcpServers:{"suveren-gateway":{url:`${e}/sse`}}},null,2)},"claude-desktop":{label:"Claude Desktop",snippet:e=>`Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
57
+
58
+ ${JSON.stringify({mcpServers:{"suveren-gateway":{url:`${e}/sse`}}},null,2)}`},other:{label:"Other",snippet:e=>`Streamable HTTP: POST ${e}/mcp
59
+ SSE transport: GET ${e}/sse
60
+ Health check: GET ${e}/health`}};function dy({aiConfigured:e,hasRunningIntegration:t,hasActiveAuth:n,hasAgentConnected:r,mcpEndpoint:s}){const[o,i]=u.useState(()=>localStorage.getItem(Ei)==="true"),[l,c]=u.useState(()=>localStorage.getItem(Ti)==="true"),[d,f]=u.useState(()=>localStorage.getItem(zi)==="true"),[h,p]=u.useState(null),[w,y]=u.useState("claude-code"),[x,j]=u.useState(!1),g=[{label:"AI Assistant",detail:"A trusted AI helps you think through authorizations — surfacing risks and asking the right questions.",to:"/settings",status:e?"done":o?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:t?"done":"pending"},{label:"Authorize your agent",to:"/agent/new",status:n?"done":"pending"},{label:"Connect your agent",status:r||l?"done":"pending"}],m=g.filter(E=>E.status==="done"||E.status==="skipped").length,v=m===g.length,S=u.useCallback(()=>{localStorage.setItem(Ei,"true"),i(!0)},[]),b=u.useCallback(()=>{localStorage.setItem(Ti,"true"),c(!0),p(null)},[]),N=u.useCallback(()=>{localStorage.setItem(zi,"true"),f(!0)},[]),C=u.useCallback(async E=>{try{await navigator.clipboard.writeText(E),j(!0),setTimeout(()=>j(!1),2e3)}catch{}},[]);if(d||v)return null;const T=g.findIndex(E=>E.status==="pending");return a.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[a.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),a.jsx("button",{onClick:N,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:"×"})]}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:g.map((E,L)=>{const D=L===T,G=E.status==="done"||E.status==="skipped"?"●":"○",J=E.status==="done"?"var(--success)":E.status==="skipped"?"var(--text-tertiary)":D?"var(--accent)":"var(--text-tertiary)";return a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:D?"0.75rem":"0.25rem 0",borderRadius:D?"0.5rem":void 0,background:D?"var(--accent-subtle)":void 0},children:[a.jsx("span",{style:{color:J,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:G}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[E.to&&E.status==="pending"?a.jsx(Je,{to:E.to,style:{fontSize:"0.9rem",fontWeight:D?600:500,color:D?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:E.label}):E.status==="pending"&&L===3?a.jsx("button",{onClick:()=>p(h===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:D?600:500,color:D?"var(--accent)":"var(--text-primary)"},children:E.label}):a.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:E.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:E.label}),E.optional&&E.status==="pending"&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),E.status==="skipped"&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),E.detail&&E.status==="pending"&&D&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:E.detail})]}),E.optional&&E.status==="pending"&&a.jsx("button",{onClick:S,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),E.to&&E.status==="pending"&&a.jsx(Je,{to:E.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),L===3&&h===3&&a.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[a.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.75rem",color:"var(--text-primary)"},children:"MCP Endpoint"}),a.jsx("div",{style:{fontFamily:"monospace",fontSize:"0.85rem",padding:"0.5rem 0.75rem",background:"var(--bg-elevated)",border:"1px solid var(--border)",borderRadius:"0.375rem",marginBottom:"1rem",wordBreak:"break-all"},children:s}),a.jsx("div",{style:{display:"flex",gap:"0.25rem",marginBottom:"0.75rem"},children:Object.entries(zo).map(([U,P])=>a.jsx("button",{onClick:()=>y(U),style:{padding:"0.375rem 0.75rem",fontSize:"0.75rem",fontWeight:w===U?600:400,background:w===U?"var(--accent-subtle)":"transparent",color:w===U?"var(--accent)":"var(--text-secondary)",border:`1px solid ${w===U?"var(--accent)":"var(--border)"}`,borderRadius:"0.375rem",cursor:"pointer"},children:P.label},U))}),a.jsx("pre",{style:{fontFamily:"monospace",fontSize:"0.78rem",lineHeight:1.6,padding:"0.75rem",background:"var(--bg-elevated)",border:"1px solid var(--border)",borderRadius:"0.375rem",overflow:"auto",whiteSpace:"pre-wrap",margin:0,marginBottom:"0.75rem"},children:zo[w].snippet(s)}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>C(zo[w].snippet(s)),children:x?"Copied":"Copy"}),a.jsx("button",{className:"btn btn-primary btn-sm",onClick:b,children:"Done"})]})]})]},L)})}),a.jsxs("div",{style:{marginTop:"1.25rem"},children:[a.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:a.jsx("div",{style:{height:"100%",width:`${m/g.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),a.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[m," of ",g.length," complete"]})]})]})}function In({variant:e="base",style:t,className:n,...r}){const s=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return a.jsx("span",{className:`${s}${n?` ${n}`:""}`,style:t,role:"status","aria-busy":"true","aria-label":r["aria-label"]??"Loading"})}function Ro(){return a.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[a.jsx(In,{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",flexShrink:0}}),a.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.35rem"},children:[a.jsx(In,{variant:"line",style:{width:"35%"}}),a.jsx(In,{variant:"line-sm",style:{width:"65%"}})]})]})}const fy={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},ap=e=>fy[e]??e,py={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:"/authorizations"},ungoverned:{chip:"Unconfigured",sev:"act"},query_unsafe:{chip:"Unsafe search",sev:"info"}};function hy(e){return py[e]??{chip:"Blocked",sev:"info"}}function my(e){const t=ap(e.integrationId);switch(e.reason){case"resource":return e.integrationId==="calendar"?a.jsxs(a.Fragment,{children:["Tried to read your ",a.jsx("b",{children:e.target??"restricted"})," calendar"]}):a.jsxs(a.Fragment,{children:["Tried to read a restricted location in ",t]});case"spam":return a.jsxs(a.Fragment,{children:["Tried to open a message in ",a.jsx("b",{children:"spam or trash"})]});case"age":return a.jsxs(a.Fragment,{children:["Tried to read ",t," older than your read window"]});case"unset_age":return a.jsxs(a.Fragment,{children:["Your ",t," has ",a.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return a.jsxs(a.Fragment,{children:["Read access isn't granted on your ",t," authorization"]});case"ungoverned":return a.jsxs(a.Fragment,{children:["A ",t," tool isn't configured for safe reading"]});case"query_unsafe":return a.jsx(a.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return a.jsx(a.Fragment,{children:e.detail})}}function gy(e,t){const n=Math.max(0,(t-e)/1e3);if(n<60)return"Just now";if(n<3600)return`${Math.floor(n/60)} min ago`;if(n<86400)return`${Math.floor(n/3600)} hr ago`;const r=Math.floor(n/86400);return r===1?"Yesterday":`${r} days ago`}const ru=5,vy=24*60*60*1e3,ta=7;function yy(e,t){const n=t-ta*vy;return{recent:e.filter(r=>r.ts>=n),all:e}}function xy(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[s,o]=u.useState(!1),i=u.useCallback(()=>{z.getDenials({limit:200}).then(({records:p})=>{t(p),o(!1)}).catch(()=>o(!0))},[]);if(u.useEffect(()=>{i()},[i]),Ft(i,12e4),s||e===null)return null;const{recent:l,all:c}=yy(e,Date.now()),d=n?c:l.slice(0,ru),f=c.length-l.length,h=(p,w)=>{const y=hy(p.reason);return a.jsxs("div",{className:"rb-row",children:[a.jsx("span",{className:`rb-dot ${y.sev==="act"?"act":y.sev==="info"?"info":""}`,"aria-hidden":"true"}),a.jsxs("div",{className:"rb-body",children:[a.jsx("div",{className:"rb-line",children:my(p)}),a.jsxs("div",{className:"rb-meta",children:[a.jsx("span",{className:`rb-chip ${y.sev==="act"?"act":y.sev==="warn"?"warn":""}`,children:y.chip}),a.jsx("span",{className:"rb-via",children:ap(p.integrationId)})]}),y.fixTo&&a.jsx(Je,{className:"rb-fix",to:y.fixTo,children:"Set a read window →"})]}),a.jsx("div",{className:"rb-when",children:gy(p.ts,Date.now())})]},`${p.ts}-${w}`)};return a.jsxs("section",{className:"card recent-blocks","aria-label":"Recent blocks",style:{marginTop:"1.5rem"},children:[a.jsxs("div",{className:"card-header",children:[a.jsx("h2",{className:"card-title",children:"Recent blocks"}),(n?c.length:l.length)>0&&a.jsx("span",{className:"rb-count",children:n?c.length:l.length})]}),d.length===0?a.jsxs("div",{className:"rb-empty",children:[a.jsx("span",{className:"rb-mark","aria-hidden":"true",children:a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M20 6 9 17l-5-5"})})}),a.jsxs("h3",{children:["Nothing blocked in the last ",ta," days"]}),a.jsx("p",{children:"Your agent has stayed within every limit you set."}),f>0&&a.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!0),children:["Show the last 30 days (",f,")"]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("p",{className:"rb-sub",children:[n?"Last 30 days. ":`Last ${ta} days. `,"Limits you set that stopped your agent. Seeing them here means the gateway is doing its job."]}),a.jsx("div",{className:"rb-rows",children:d.map(h)}),!n&&c.length>d.length&&a.jsx("div",{className:"rb-foot",children:a.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!0),children:["View all ",c.length," blocks from the last 30 days"]})}),n&&c.length>Math.min(l.length,ru)&&a.jsx("div",{className:"rb-foot",children:a.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!1),children:["Show only the last ",ta," days"]})})]})]})}const wy=30*60;function Po(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Sy(){var ee;const{domain:e}=Oe(),[t,n]=u.useState([]),[r,s]=u.useState([]),[o,i]=u.useState([]),[l,c]=u.useState(!0),[d,f]=u.useState(!1),[h,p]=u.useState([]),[w,y]=u.useState(!1),[x,j]=u.useState(!1),{entries:g,activeSessions:m,loading:v}=Ll(),S=!v,b=u.useCallback(()=>{z.getMyAttestations().then(F=>{n(F),f(!0)}).catch(()=>f(!0)),z.getArchivedMandates().then(p).catch(()=>p([])),z.getProposals(e||"owner").then(F=>{s(F),y(!0)}).catch(()=>y(!0)),z.getProposalsForApprover().then(F=>i(F)).catch(()=>i([])),z.getCredential("ai-config").then(F=>{c(F.configured),j(!0)}).catch(()=>j(!0))},[e]);fe("attestation-changed",b),fe("proposal-added",b),fe("proposal-resolved",b),fe("proposal-approved",b),fe("proposal-rejected",b),Ft(b,3e5,e);const N=d&&w&&x&&S,C=Zf(t,{archivedSet:new Set(h)}),T=C.active,E=C.expired,L=T.filter(F=>F.remaining_seconds!==null&&F.remaining_seconds<=wy),D=r.filter(np),G=g.filter(F=>F.state==="running"),J=g.filter(F=>F.state==="starting"),U=g.filter(F=>F.state==="not-running"||F.state==="error"),P=[];for(const F of o)P.push({label:"Approval needed",detail:`${F.tool} — above-cap action under ${Po(F.profileId)}`,to:"/proposals",color:"var(--warning)"});for(const F of D)P.push({label:"Approval pending",detail:`${F.tool} awaiting your approval`,to:"/proposals",color:"var(--warning)"});for(const F of L){const $=Math.ceil((F.remaining_seconds??0)/60);P.push({label:"Expiring soon",detail:`${F.title??Po(F.profile_id)} — ${$} min remaining`,to:"/authorizations",color:"var(--warning)"})}for(const F of E)P.push({label:"Expired",detail:F.title??Po(F.profile_id),to:"/authorizations",color:"var(--danger)"});for(const F of U)P.push({label:F.state==="error"?"Integration error":"Integration stopped",detail:F.state==="error"&&((ee=F.integration)!=null&&ee.error)?`${F.manifest.name}: ${F.integration.error}`:`${F.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"});for(const F of J)P.push({label:"Integration starting",detail:`${F.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const F of g)F.authStatus==="failed"&&F.state!=="not-running"&&F.state!=="error"&&P.push({label:"Reconnect needed",detail:`${F.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return l||P.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"page-header",children:a.jsx("h1",{className:"page-title",children:"Dashboard"})}),N&&a.jsx(dy,{aiConfigured:l,hasRunningIntegration:G.length>0,hasActiveAuth:T.length>0,hasAgentConnected:m>0,mcpEndpoint:`http://localhost:${window.location.port==="3400"?"3430":"7430"}`}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(8rem, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[a.jsx(Je,{to:"/authorizations",style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[d?a.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:T.length>0?"var(--success)":"var(--text-tertiary)"},children:T.length}):a.jsx(In,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),a.jsx(Je,{to:"/proposals",style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[w?a.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:D.length>0?"var(--warning)":"var(--text-tertiary)"},children:D.length}):a.jsx(In,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),a.jsx(Je,{to:"/authorizations",style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[d?a.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:E.length>0?"var(--danger)":"var(--text-tertiary)"},children:E.length}):a.jsx(In,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),a.jsx(Je,{to:"/integrations",style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[S?a.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:G.length>0?"var(--success)":"var(--text-tertiary)"},children:G.length}):a.jsx(In,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),a.jsxs("section",{className:"card attention","aria-label":"Needs your attention",children:[a.jsxs("div",{className:"card-header",children:[a.jsx("h2",{className:"card-title",children:"Needs your attention"}),P.length>0&&a.jsx("span",{className:"rb-count",children:P.length})]}),P.length>0?a.jsx("div",{className:"attention-rows",children:P.map((F,$)=>a.jsxs(Je,{to:F.to,className:"attention-row",children:[a.jsx("span",{className:"attention-dot",style:{background:F.color},"aria-hidden":"true"}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:F.label}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:F.detail})]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},$))}):N?a.jsxs("div",{className:"all-clear",children:[a.jsx("span",{className:"rb-mark","aria-hidden":"true",children:a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M20 6 9 17l-5-5"})})}),a.jsx("h3",{children:"All clear"}),a.jsx("p",{children:"Nothing needs your attention."})]}):a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[a.jsx(Ro,{}),a.jsx(Ro,{}),a.jsx(Ro,{})]})]}),a.jsx(xy,{})]})}const jy=["Scope & Limits","Intent","Authorize"];function op({currentStep:e,onStepClick:t}){const n=en();return a.jsxs("div",{className:"wizard-progress",children:[a.jsx("ol",{className:"wizard-steps",children:jy.map((r,s)=>{const o=s+2,i=o<e,l=o===e,c=o-1<e,d=i&&!!t;return a.jsxs("li",{className:`wizard-step${c?" reached":""}`,"aria-current":l?"step":void 0,children:[a.jsx("button",{type:"button",className:`step-circle${i?" completed":""}${l?" current":""}`,onClick:d?()=>t(o):void 0,disabled:!d,"aria-label":`${r}${i?" (done)":l?" (current)":""}`,children:i?"✓":s+1}),a.jsx("span",{className:`step-label-text${l?" current":i?" completed":""}`,children:r})]},o)})}),a.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>n("/agent/new"),children:"Cancel"})]})}const ky=40;function $e(e,t){const n=e.lastIndexOf("/"),r=n>=0?e.slice(n+1):e,s=r.indexOf("@"),o=s>=0?r.slice(0,s):r;return(o.charAt(0).toUpperCase()+o.slice(1)).slice(0,ky)}function by({profileId:e,bounds:t,groupName:n,domain:r,onSwitch:s}){return a.jsxs("div",{className:"context-strip",children:[n&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"context-strip-label",children:"Team:"}),a.jsxs("span",{children:[a.jsx("strong",{children:n}),r?` / ${r}`:""]})]}),e&&a.jsxs("span",{children:[a.jsx("strong",{children:"Profile:"})," ",$e(e)]}),t&&a.jsxs("span",{children:[a.jsx("strong",{children:"Bounds:"})," ",t]}),s&&a.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:s,children:"Switch"})]})}function Cy({integrationId:e,field:t,value:n,onChange:r,disabled:s,onLabels:o}){const[i,l]=u.useState(null),[c,d]=u.useState(null),[f,h]=u.useState(!0);u.useEffect(()=>{let y=!1;return z.discoverScopeField(e,t).then(x=>{var j;y||(l(x.options),h(!1),(j=x.options)!=null&&j.length&&(o==null||o(Object.fromEntries(x.options.map(g=>[g.value,g.label])))))}).catch(x=>{y||(d(x instanceof Error?x.message:String(x)),h(!1))}),()=>{y=!0}},[e,t]);const p=new Set(n.split(",").map(y=>y.trim()).filter(Boolean)),w=y=>{const x=new Set(p);x.has(y)?x.delete(y):x.add(y),r(Array.from(x).join(","))};return f?a.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):c||!i?a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--warning)",marginBottom:"0.5rem"},children:["Couldn't fetch options (",c??"no response","). Enter values manually, separated by commas."]}),a.jsx("input",{className:"form-input",type:"text",value:n,onChange:y=>r(y.target.value),disabled:s})]}):i.length===0?a.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",e," for this field."]}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:i.map(y=>{const x=y.extras??{},j=typeof x.access=="string"?x.access:void 0,g=j==="reader",m=x.primary===!0;return a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:g?"var(--text-tertiary)":"var(--text-primary)",cursor:s||g?"not-allowed":"pointer"},title:g?"Read-only — you can authorize list/read but not writes":void 0,children:[a.jsx("input",{type:"checkbox",checked:p.has(String(y.value)),onChange:()=>w(String(y.value)),disabled:s||g}),a.jsx("span",{children:y.label||y.value}),m&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),j&&a.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",j]})]},y.value)})})}function Ml(e){if(e.type!=="number")return 0;const t=e.boundType,n=e.unit;return(t==null?void 0:t.kind)==="per_transaction"&&n==="count"?1:0}function Ny(e,t){return t!==void 0?String(t):Ml(e)===1?"1":""}function su(e,t){const n=Ml(e);return t===""?n:Math.max(n,Number(t))}function Ey(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Ty(e,t){return t.displayName?t.displayName:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function zy(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function Ry(e){var t;return!!(e.enum&&((t=e.constraint)!=null&&t.enforceable.includes("subset")))}function au(e,t){const n=e.trim();return n?t==="email"?n.includes("@")&&n.indexOf(".",n.indexOf("@"))>-1:t==="domain"?n.includes(".")&&!n.includes("@"):!0:!1}function Py(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}function Iy(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function _y(e){return e?e==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:e==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:e==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:e==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:e.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function Ay(e,t){if(!e||!t)return"";const n=Number(e);if(!Number.isFinite(n)||n<=0)return"";if(t==="minutes"&&n>=60){const r=Math.floor(n/60),s=n%60;return s===0?`${r} hour${r!==1?"s":""}`:`${r}h ${s}m`}if(t==="hours"&&n>=24&&n%24===0){const r=n/24;return`${r} day${r!==1?"s":""}`}if(t==="days"){if(n>=30&&n%30===0)return`${n/30} month${n/30!==1?"s":""}`;if(n>=7&&n%7===0)return`${n/7} week${n/7!==1?"s":""}`}return""}function $y({id:e,value:t,onChange:n,disabled:r,placeholder:s,unit:o,min:i=0}){const l=Iy(o),c=_y(o),d=Py(o),f=Ay(t,o),h=t===""?null:Number(t),p=()=>{const y=t===""?0:Number(t),x=y%l,j=x===0?y+l:y+(l-x);n(String(j))},w=()=>{const y=t===""?0:Number(t);if(y<=i)return;const x=y%l,j=x===0?y-l:y-x;n(String(Math.max(i,j)))};return a.jsxs("div",{className:"bounded-input",children:[a.jsxs("div",{className:"bounded-input-field",children:[a.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:w,disabled:r||t===""||Number(t)<=i,"aria-label":"Decrease",children:"−"}),a.jsx("input",{id:e,className:"stepper-input",type:"number",min:i,step:l,value:t,placeholder:s??String(i),onChange:y=>n(y.target.value),onFocus:y=>y.target.select(),disabled:r}),a.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:p,disabled:r,"aria-label":"Increase",children:"+"}),d&&a.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:d})]}),c.length>0&&!r&&a.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:c.map(y=>a.jsx("button",{type:"button",className:`preset-chip${h===y.value?" preset-chip-selected":""}`,onClick:()=>n(String(y.value)),children:y.label},y.value))}),f&&a.jsxs("div",{className:"bounded-input-echo",children:["≈ ",f]})]})}function ou({htmlFor:e,label:t,description:n}){const[r,s]=u.useState(!1);return a.jsxs("div",{className:"field-label-with-tip",children:[a.jsx("label",{className:"form-label",htmlFor:e,children:t}),n&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${t}" mean?`,"aria-expanded":r,onClick:()=>s(o=>!o),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),onBlur:()=>s(!1),children:"i"}),r&&a.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:n})]})]})}function Ly({id:e,value:t,onChange:n,disabled:r,format:s,placeholder:o}){const[i,l]=u.useState(""),[c,d]=u.useState(!1),f=u.useRef(null),h=t?t.split(",").map(g=>g.trim()).filter(Boolean):[],p=g=>{const m=g.trim();if(!m)return;if(!au(m,s)){d(!0);return}d(!1);const v=h.includes(m)?h:[...h,m];n(v.join(",")),l("")},w=g=>{const m=h.filter((v,S)=>S!==g);n(m.join(","))},y=g=>{g.key==="Enter"||g.key===","||g.key==="Tab"?i.trim()&&(g.preventDefault(),p(i)):g.key==="Backspace"&&!i&&h.length>0&&w(h.length-1)},x=g=>{const m=g.clipboardData.getData("text");if(m.includes(",")){g.preventDefault();const S=m.split(",").map(N=>N.trim()).filter(Boolean).filter(N=>au(N,s)),b=[...new Set([...h,...S])];n(b.join(",")),l(""),d(!1)}},j=s==="email"?"Type email and press Enter...":"Type domain and press Enter...";return a.jsxs("div",{className:`tag-input${c?" tag-input-invalid":""}`,onClick:()=>{var g;return(g=f.current)==null?void 0:g.focus()},children:[h.map((g,m)=>a.jsxs("span",{className:"tag-pill",children:[g,!r&&a.jsx("button",{type:"button",className:"tag-remove",onClick:v=>{v.stopPropagation(),w(m)},"aria-label":`Remove ${g}`,children:"×"})]},g)),!r&&a.jsx("input",{ref:f,id:e,className:"tag-input-field",type:"text",value:i,onChange:g=>{l(g.target.value),d(!1)},onKeyDown:y,onPaste:x,onBlur:()=>{i.trim()&&p(i)},placeholder:h.length===0?o??j:""})]})}function My({id:e,options:t,value:n,onChange:r,disabled:s}){const o=n?n.split(",").map(l=>l.trim()).filter(Boolean):[],i=l=>{const c=o.includes(l)?o.filter(d=>d!==l):[...o,l];r(c.join(","))};return a.jsx("div",{className:"checkbox-group",id:e,children:t.map(l=>a.jsxs("label",{className:`checkbox-pill${o.includes(l)?" checkbox-pill-selected":""}`,children:[a.jsx("input",{type:"checkbox",checked:o.includes(l),onChange:()=>i(l),disabled:s}),a.jsx("span",{children:l})]},l))})}function iu({fieldKey:e,fieldDef:t,value:n,onChange:r,prefix:s,readOnly:o,twoColumn:i,discoveryIntegrationId:l,onLabels:c}){const d=Ty(e,t),f=`${s}-field-${e}`,h=a.jsx(a.Fragment,{children:Ry(t)?a.jsx(My,{id:f,options:t.enum,value:n,onChange:p=>r(e,p),disabled:o}):(()=>{const p=t.boundType;return(p==null?void 0:p.kind)==="enum"&&Array.isArray(p.values)})()?a.jsxs("select",{id:f,className:"form-select",value:n,onChange:p=>r(e,p.target.value),disabled:o,children:[a.jsx("option",{value:"",children:"Select..."}),t.boundType.values.map(p=>a.jsx("option",{value:p,children:p},p))]}):"enum"in t&&t.enum?a.jsxs("select",{id:f,className:"form-select",value:n,onChange:p=>r(e,p.target.value),disabled:o,children:[a.jsx("option",{value:"",children:"Select..."}),t.enum.map(p=>a.jsx("option",{value:p,children:p},p))]}):t.type==="number"?a.jsx($y,{id:f,value:n,onChange:p=>r(e,p),disabled:o,unit:t.unit,min:Ml(t)}):zy(t)?a.jsx(Ly,{id:f,value:n,onChange:p=>r(e,p),disabled:o,format:t.format}):l?a.jsx(Cy,{integrationId:l,field:e,value:n,onChange:p=>r(e,p),disabled:o,onLabels:p=>c==null?void 0:c(e,p)}):a.jsx("input",{id:f,className:"form-input",type:"text",value:n,onChange:p=>r(e,p.target.value),disabled:o})});return i?a.jsxs("div",{className:"bounds-field-row",children:[a.jsx("div",{className:"bounds-field-label",children:a.jsx(ou,{htmlFor:f,label:d,description:t.description})}),a.jsx("div",{className:"bounds-field-input",children:h})]},`${s}-${e}`):a.jsxs("div",{className:"form-group",children:[a.jsx(ou,{htmlFor:f,label:d,description:t.description}),h]},`${s}-${e}`)}function Fy(e,t){if(!t)return"no-config";const n=t.caps,r=Array.isArray(t.approvers)&&t.approvers.length>0;if(!(n&&Object.keys(n).length>0))return r?"approvers-dormant":"no-config";let o=!1;for(const[i,l]of Object.entries(n)){const c=e[i];if(c===""||c===void 0)continue;const d=Number(c);if(!isNaN(d)&&d>l){o=!0;break}}return o?r?"above-approvers":"hard-ceiling":"within-cap"}function Oy(e,t){const n=new Set;if(!t)return n;for(const[r,s]of Object.entries(t)){const o=e[r];if(o===""||o===void 0)continue;const i=Number(o);!isNaN(i)&&i>s&&n.add(r)}return n}function By({profile:e,onConfirm:t,onCancel:n,readOnly:r,initialBounds:s,initialContext:o,initialFrame:i,profileConfig:l,approverNames:c,adminName:d}){const f=e.boundsSchema??e.frameSchema,h=e.contextSchema,p=f?Object.entries(f.fields).filter(([R,B])=>!(R==="profile"||R==="path"||B.enforced===!1||B.enforcedBy==="gatekeeper")):[],w=f?Object.entries(f.fields).filter(([,R])=>R.enforcedBy==="gatekeeper").filter(([,R])=>R.enforced!==!1).map(([R,B])=>B.displayName??R):[],y=h&&h.keyOrder.length>0?Object.entries(h.fields):[],x=s??i??{},j=o??{},g={};for(const[R,B]of p)g[R]=Ny(B,x[R]);const m={};for(const[R]of y)m[R]=j[R]!==void 0?String(j[R]):"";const[v,S]=u.useState(g),[b,N]=u.useState(m),[C,T]=u.useState({}),[E,L]=u.useState(null);u.useEffect(()=>{const R=Ey(e.id);z.getIntegrationManifests().then(({manifests:B})=>{const Q=B.find(q=>q.profile===R&&q.contextDiscovery&&Object.keys(q.contextDiscovery).length>0);L(Q??null)}).catch(()=>L(null))},[e.id]);const D=Fy(v,l),G=Oy(v,l==null?void 0:l.caps),J=(R,B)=>{S(Q=>({...Q,[R]:B}))},U=(R,B)=>{N(Q=>({...Q,[R]:B}))},P=()=>{const R={profile:e.id};for(const[Q,q]of p)q.type==="number"?R[Q]=su(q,v[Q]):R[Q]=v[Q];const B={};for(const[Q,q]of y)q.type==="number"?B[Q]=b[Q]===""?0:Number(b[Q]):B[Q]=b[Q];return[R,B]},ee=()=>{const[R,B]=P();t(R,B,C)},F=()=>{const R=(l==null?void 0:l.caps)??{},B={...v};for(const re of G)R[re]!==void 0&&(B[re]=String(R[re]));S(B);const Q={profile:e.id};for(const[re,ce]of p)ce.type==="number"?Q[re]=su(ce,B[re]??""):Q[re]=B[re]??"";const q={};for(const[re,ce]of y)ce.type==="number"?q[re]=b[re]===""?0:Number(b[re]):q[re]=b[re];t(Q,q,C)},$=R=>{const B=l==null?void 0:l.caps;if(!B||B[R]===void 0)return null;const Q=B[R],q=G.has(R);return D==="hard-ceiling"&&q?a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",Q," — exceeds team ceiling"]}):D==="above-approvers"&&q?a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",Q," — above cap"]}):a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",Q," ok"]})},A=()=>{var R;if(D==="no-config")return null;if(D==="approvers-dormant"){const B=c&&c.length>0?c.join(", "):"the configured approvers";return a.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:[a.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",B]}),a.jsxs("div",{children:["No caps are set on this profile, so ",B," won't gate any action under this authority. 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(D==="within-cap")return a.jsx("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--border)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:a.jsx("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:"Within all team caps — your responsibility."})});if(D==="above-approvers"){const B=c&&c.length>0?c.join(", "):"the required approvers";return a.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--warning)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[a.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.25rem"},children:"Above team cap."}),a.jsxs("div",{children:[a.jsx("strong",{children:"Over-cap actions"})," will require approval from you and ",B,". Within-cap actions run per the mode you choose."]})]})}if(D==="hard-ceiling"){const B=Array.from(G)[0],Q=B?(R=l==null?void 0:l.caps)==null?void 0:R[B]:void 0,q=d??"the team admin";return a.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--danger)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[a.jsx("div",{style:{fontWeight:600,color:"var(--danger)",marginBottom:"0.25rem"},children:"Hard team ceiling."}),a.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Team policy caps this at ",Q??"the configured limit",". Lower your bound or ask ",q," to add an approver path above the cap."]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:F,children:"Save below cap"}),n&&a.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:n,children:"Cancel"})]})]})}return null},W=D==="hard-ceiling";return a.jsxs("div",{children:[y.length>0&&a.jsxs("div",{className:"context-section",children:[a.jsxs("div",{className:"bounds-section-header",children:[a.jsx("span",{className:"bounds-section-icon",children:"🛡"}),a.jsxs("div",{children:[a.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),a.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the SP"})]})]}),y.map(([R,B])=>{var q;const Q=!!((q=E==null?void 0:E.contextDiscovery)!=null&&q[R]);return a.jsx(iu,{fieldKey:R,fieldDef:B,value:b[R],onChange:U,prefix:"context",readOnly:r,discoveryIntegrationId:Q?E.id:void 0,onLabels:(re,ce)=>T(pe=>({...pe,[re]:ce}))},`context-${R}`)})]}),p.length>0&&a.jsxs("div",{className:"bounds-section",children:[a.jsxs("div",{className:"bounds-section-header",children:[a.jsx("span",{className:"bounds-section-icon",children:"🔒"}),a.jsxs("div",{children:[a.jsx("div",{className:"bounds-section-title",children:"Limits"}),a.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Authority Server"})]})]}),a.jsx("div",{className:"bounds-fields-grid",children:p.map(([R,B])=>{var Q;return a.jsxs("div",{style:{display:"contents"},children:[a.jsx(iu,{fieldKey:R,fieldDef:B,value:v[R],onChange:J,prefix:"bounds",readOnly:r,twoColumn:!0}),D!=="no-config"&&((Q=l==null?void 0:l.caps)==null?void 0:Q[R])!==void 0&&a.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:$(R)})]},`bounds-${R}`)})}),A(),w.length>0&&a.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[w.join(", ")," ",w.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"," ",a.jsx(Je,{to:"/integrations",children:"Integrations"}),"."]})]}),a.jsx("button",{className:"btn btn-primary",onClick:ee,disabled:W,style:{marginTop:"0.5rem"},children:r?"Next: Gates":"Next: Problem Statement"})]})}function Dy(e){var n;const t=e.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((n=t==null?void 0:t[1])==null?void 0:n.trim())??null}function Uy(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const Wy="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 za({target:e,currentText:t,onApply:n,greeting:r,placeholder:s,title:o}){const[i,l]=u.useState([{role:"assistant",content:r??Wy}]),[c,d]=u.useState(""),[f,h]=u.useState(!1),[p,w]=u.useState(null),y=u.useRef(null),x=u.useRef(null);u.useEffect(()=>{const m=y.current;if(!m)return;const v=i[i.length-1],S=x.current;!f&&(v==null?void 0:v.role)==="assistant"&&i.length>1&&S?m.scrollTop=S.offsetTop:m.scrollTop=m.scrollHeight},[i,f]);const j=async()=>{const m=c.trim();if(!m||f)return;const v=[...i,{role:"user",content:m}];l(v),d(""),w(null),h(!0);try{const S=await z.aiChat({target:e,currentText:t,messages:v.filter((b,N)=>!(N===0&&b.role==="assistant"))});S.success&&S.reply?l(b=>[...b,{role:"assistant",content:S.reply}]):w(S.error??"AI returned no reply")}catch(S){w(S instanceof Error?S.message:"Chat failed")}finally{h(!1)}},g=m=>{m.key==="Enter"&&!m.shiftKey&&!m.nativeEvent.isComposing&&(m.preventDefault(),j())};return a.jsxs("div",{className:"intent-chat",children:[a.jsx("h3",{className:"card-title",children:o??"AI Assistant"}),a.jsxs("div",{ref:y,className:"chat-messages",children:[i.map((m,v)=>{const S=m.role==="assistant"?Dy(m.content):null,b=S?Uy(m.content):m.content;return a.jsx("div",{className:`chat-msg ${m.role}`,ref:v===i.length-1?x:void 0,children:a.jsxs("div",{className:"chat-msg-body",children:[b&&a.jsx("div",{className:"chat-msg-prose",children:b}),S!==null&&a.jsxs(a.Fragment,{children:[a.jsx("pre",{className:"chat-fenced-block",children:S}),a.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>n(S),children:"Apply this draft"})]})]})},v)}),f&&a.jsx("div",{className:"chat-msg assistant",children:a.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),p&&a.jsx("div",{className:"error-message",children:p}),a.jsxs("div",{className:"chat-composer",children:[a.jsxs("div",{className:"chat-composer-pill",children:[a.jsx("textarea",{className:"chat-input",value:c,onChange:m=>d(m.target.value),onKeyDown:g,placeholder:s??"Ask for help articulating the intent…",rows:1,disabled:f}),a.jsx("button",{type:"button",className:"chat-send-btn",onClick:j,disabled:f||!c.trim(),"aria-label":"Send",children:"↑"})]}),a.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function ip({open:e,onClose:t,children:n,ariaLabel:r}){const s=u.useRef(null),o=u.useRef(null);return u.useEffect(()=>{var l;if(!e)return;o.current=document.activeElement,document.body.style.overflow="hidden";const i=c=>{c.key==="Escape"&&t()};return document.addEventListener("keydown",i),(l=s.current)==null||l.focus(),()=>{document.removeEventListener("keydown",i),document.body.style.overflow="",o.current instanceof HTMLElement&&o.current.focus()}},[e,t]),Ef.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("div",{className:`bottom-sheet-backdrop${e?" is-open":""}`,onClick:t,"aria-hidden":"true"}),a.jsxs("aside",{ref:s,className:`bottom-sheet${e?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":r,tabIndex:-1,children:[a.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),a.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:t,"aria-label":"Close",children:"×"}),n]})]}),document.body)}function Hy(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Vy(e,t,n){if(t.length===0)return[{text:e,label:e,matched:null}];const r=[],s=new Set;for(const c of t)if(!(!c.scope||c.scope==="all (unscoped)"))for(const d of[c.scope,...c.scope.split(",").map(f=>f.trim())]){const f=d.toLowerCase();d&&!s.has(f)&&(s.add(f),r.push(d))}r.sort((c,d)=>d.length-c.length);const o=c=>{const d=c.toLowerCase();return t.filter(f=>{var h,p;return((h=f.scope)==null?void 0:h.toLowerCase())===d||((p=f.scope)==null?void 0:p.split(",").map(w=>w.trim().toLowerCase()).includes(d))})},i=["\\[\\d+\\]",...r.map(Hy)],l=new RegExp(`(${i.join("|")})`,"gi");return e.split(l).filter(c=>c!=="").map(c=>{const d=/^\[(\d+)\]$/.exec(c);if(d){const f=t[Number(d[1])-1];if(f){const h=f.scope&&f.scope!=="all (unscoped)"?f.scope:"all recipients",p=n?`${n}: ${h}`:h;return{text:c,label:p,matched:[f]}}}else if(r.some(f=>f.toLowerCase()===c.toLowerCase())){const f=o(c);if(f.length>0)return{text:c,label:c,matched:f}}return{text:c,label:c,matched:null}})}const lu=`Why — What's the situation? Why does this need to happen?
61
+
62
+ Goal — What should the agent try to achieve?
63
+
64
+ Watch out — What should the agent avoid or be careful about?`;function Gy(e,t,n,r){return Vy(e,t,r).map((s,o)=>{if(!s.matched)return a.jsx("span",{children:s.text},o);const i=s.matched;return a.jsx("button",{type:"button",onClick:()=>n(i),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:s.label},o)})}function Ky(){var se;const e=en(),[t]=Gf(),n=Number(t.get("step"))||2,[r,s]=u.useState(null),[o,i]=u.useState(null),[l,c]=u.useState(n),[d,f]=u.useState(null),[h,p]=u.useState(null),[w,y]=u.useState({}),[x,j]=u.useState(lu),[g,m]=u.useState(!1),[v,S]=u.useState(!0),[b,N]=u.useState(null),[C,T]=u.useState([]),[E,L]=u.useState(void 0),[D,G]=u.useState(!1),[J,U]=u.useState(null),[P,ee]=u.useState(null),[F,$]=u.useState(null),[A,W]=u.useState([]),[R,B]=u.useState(null);u.useEffect(()=>{var ge;const I=sessionStorage.getItem("agentAuth");if(!I){e("/agent/new");return}const X=JSON.parse(I);s(X);const ae=sessionStorage.getItem("agentGate");if(ae){const me=JSON.parse(ae);me.bounds&&f(me.bounds),me.context&&p(me.context),(ge=me.gateContent)!=null&&ge.intent&&j(me.gateContent.intent)}z.getProfile(X.profileId).then(me=>i(me)).catch(()=>e("/agent/new")).finally(()=>S(!1)),X.groupId&&Promise.all([z.getTeamProfileConfig(X.groupId,X.profileId).catch(()=>null),z.getGroupById(X.groupId).catch(()=>null),z.listUsers().catch(()=>[])]).then(([me,Pe,it])=>{if(N(me),me){const Ie=new Map;for(const le of it){const Ye=le.name&&le.email?`${le.name} (${le.email})`:le.name||le.email||le.id;Ie.set(le.id,Ye)}const vt=(Pe==null?void 0:Pe.members)??[];for(const le of vt){const Ye=le.userId??le.id;Ye&&(le.name&&le.email?Ie.set(Ye,`${le.name} (${le.email})`):le.name&&Ie.set(Ye,le.name))}const Ke=(me.approvers??[]).map(le=>Ie.get(le)??le);T(Ke);const et=vt.find(le=>le.role==="admin");if(et){const le=et.userId??et.id;le&&L(Ie.get(le)??et.name)}}})},[e]);const Q=d?Object.entries(d).filter(([I])=>I!=="profile"&&I!=="path").map(([I,X])=>`${I} = ${X}`).join(", "):"",q=(I,X,ae)=>{f(I),p(X),ae&&y(ae),c(3)},re=x.trim()!==lu.trim()&&x.trim()!=="",ce=I=>{re&&!confirm("Replace your current intent with the AI draft?")||j(I)},pe=()=>{const I=o==null?void 0:o.ttl,X={intent:x},ae=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...ae,bounds:d,context:h,contextLabels:w,gateContent:X,ttlConfig:I})),e("/agent/review")},te=async()=>{if(r){G(!0),U(null),ee(null),$(null),W([]),B(null);try{const I=await z.aiIntentReview({profileId:r.profileId,newIntent:x,context:h??void 0});W(I.grants??[]),I.success?I.review?U(I.review):ee(I.note??"No other authorizations on this profile to compare against."):$(I.error??"Check failed.")}catch(I){$(I instanceof Error?I.message:"Check failed.")}finally{G(!1)}}},oe=I=>{j(I),(J||P||F)&&(U(null),ee(null),$(null),W([]),B(null))};return v||!r||!o?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):a.jsxs(a.Fragment,{children:[a.jsx(op,{currentStep:l,onStepClick:I=>{I>=2&&c(I)}}),a.jsx(by,{profileId:r.profileId,bounds:Q||void 0,groupName:r.groupName,domain:r.domain}),l===2&&a.jsx("div",{className:"card",children:a.jsx(By,{profile:o,onConfirm:q,onCancel:()=>e("/agent/new"),initialBounds:d||void 0,initialContext:h||void 0,profileConfig:b,approverNames:C,adminName:E})}),l===3&&a.jsxs("div",{className:"intent-layout",children:[a.jsx("div",{className:"card intent-pane chat tool",children:a.jsx(za,{target:{kind:"intent",profileId:r.profileId,bounds:Q||void 0},currentText:x,onApply:ce})}),a.jsxs("div",{className:"card intent-pane document",children:[a.jsx("h3",{className:"card-title",children:"What should your agent know?"}),a.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[a.jsxs("div",{className:"field-label",children:[a.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),a.jsx("textarea",{className:"intent-textarea",value:x,onChange:I=>oe(I.target.value)}),a.jsxs("div",{className:"char-counter",children:[x.length," / 2000"]})]}),a.jsxs("div",{style:{marginTop:"0.5rem"},children:[a.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:te,disabled:D||!re,children:D?"Checking…":"Check against my other grants"}),F&&a.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeftColor:"var(--danger)"},children:[a.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),a.jsx("div",{className:"hint-body",children:F})]}),P&&a.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[a.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),a.jsx("div",{className:"hint-body",children:P})]}),J&&a.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[a.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),a.jsxs("div",{className:"hint-body",children:[a.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),a.jsx("div",{style:{whiteSpace:"pre-wrap"},children:Gy(J,A,B,$e(r.profileId))}),a.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),a.jsxs("div",{className:"intent-footer",children:[a.jsx("button",{className:"btn btn-ghost",onClick:()=>c(2),children:"Back"}),a.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:pe,disabled:!re,children:"Continue to Review"})]}),(((se=b==null?void 0:b.approvers)==null?void 0:se.length)??0)>0&&a.jsxs("div",{className:"hint-box",role:"note",children:[a.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),a.jsxs("div",{className:"hint-body",children:[a.jsxs("div",{className:"hint-head",children:["Visible to ",C.length>0?C.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",C.length>0?C.join(", "):"this profile's required approvers",". Only they can decrypt it — your Service Provider cannot. Each approver stores a copy as their accountability record."]})]})]}),a.jsx("button",{type:"button",className:"floating-help",onClick:()=>m(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),a.jsx(ip,{open:g,onClose:()=>m(!1),ariaLabel:"Intent assistant",children:a.jsx(za,{target:{kind:"intent",profileId:r.profileId,bounds:Q||void 0},currentText:x,onApply:I=>{ce(I),m(!1)}})}),R&&a.jsx("div",{className:"modal-backdrop",onClick:I=>I.target===I.currentTarget&&B(null),children:a.jsxs("div",{className:"modal",children:[a.jsxs("div",{className:"modal-header",children:[a.jsx("h3",{className:"modal-title",children:R.length>1?`Existing authorizations (${R.length})`:"Existing authorization"}),a.jsx("button",{className:"modal-close",onClick:()=>B(null),children:"×"})]}),a.jsx("div",{className:"modal-body",children:R.map((I,X)=>{var ae;return a.jsxs("div",{style:{marginBottom:X<R.length-1?"1rem":0,paddingBottom:X<R.length-1?"1rem":0,borderBottom:X<R.length-1?"1px solid var(--border)":"none"},children:[a.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),a.jsx("div",{style:{marginBottom:"0.75rem"},children:I.scope}),a.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),a.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((ae=I.intent)==null?void 0:ae.trim())||"(no intent recorded)"}),Object.entries(I.bounds).filter(([ge])=>ge!=="profile"&&ge!=="path").length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),a.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(I.bounds).filter(([ge])=>ge!=="profile"&&ge!=="path").map(([ge,me])=>`${ge}: ${me}`).join(" · ")})]})]},X)})})]})})]})]})}function Yy(e){return e.normalize("NFC").replace(/\r\n?/g,`
65
+ `).split(`
66
+ `).map(s=>s.replace(/[ \t]+$/,"")).join(`
67
+ `).replace(/\n+$/,"")}async function lp(e){const n=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(o=>o.toString(16).padStart(2,"0")).join("")}class Qy extends Error{constructor(n,r,s){super(s);wr(this,"code");wr(this,"field");this.name="CanonicalValueError",this.code=n,this.field=r}}function Jy(e){const t=new TextEncoder().encode(e);let n="";for(const r of t)r===61||r===37||r<32||r>126?n+="%"+r.toString(16).toUpperCase().padStart(2,"0"):n+=String.fromCharCode(r);return n}function cp(e,t,n){const r=[];for(const s of t){const o=e[s];if(o==null)continue;const i=String(o);if(i.includes(`
68
+ `)||i.includes("\r"))throw new Qy(n,s,`Value for "${s}" contains a raw newline or carriage return. Refusing: a hash over stripped or normalized input would not represent what was authorized.`);r.push(`${s}=${Jy(i)}`)}return r.join(`
69
+ `)}async function na(e,t){const n=t.boundsSchema??t.frameSchema;if(!n)throw new Error("Profile has no boundsSchema or frameSchema");const r=cp(e,n.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await lp(r)}`}async function up(e,t){const n=t.contextSchema?cp(e,t.contextSchema.keyOrder,"CONTEXT_INVALID_VALUE"):"";return`sha256:${await lp(n)}`}async function Ra(e){const t=new TextEncoder().encode(Yy(e)),n=await crypto.subtle.digest("SHA-256",t);return`sha256:${Array.from(new Uint8Array(n)).map(o=>o.toString(16).padStart(2,"0")).join("")}`}function dp(e,t){if(!e.authorization_id)throw new Error("Attest result lacks authorization_id — the Authority Server predates per-ceremony identity. Update the Authority Server (lockstep deploy).");return{authorizationId:e.authorization_id,boundsHash:e.bounds_hash??t.boundsHash,contextHash:t.contextHash,context:t.context,...t.contextLabels&&Object.keys(t.contextLabels).length>0?{contextLabels:t.contextLabels}:{},gateContent:t.gateContent,...t.path?{path:t.path}:{}}}function cu(e){return e==null?new Set:new Set(String(e).split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}function Xy(e,t){for(const n of e)if(t.has(n))return!0;return!1}function qy(e,t,n){for(const r of e){const s=cu(t[r]),o=cu(n[r]);if(!(s.size===0||o.size===0)&&!Xy(s,o))return!1}return!0}function Zy(e){return e.length>24?`${e.slice(0,10)}…`:e}function fp(e,t,n){const r=n==null?void 0:n[e];return String(t).split(",").map(o=>o.trim()).filter(Boolean).map(o=>{const i=r==null?void 0:r[o];return i?`${i} (${Zy(o)})`:o}).join(", ")}function ex(e,t,n){return e.isPersonal?!1:t&&((n==null?void 0:n.length)??0)===0}function tx(){var le,Ye,V;const e=en(),{user:t,mode:n,domain:r}=Oe(),[s,o]=u.useState(null),[i,l]=u.useState(null),[c,d]=u.useState(null),[f,h]=u.useState("per-action"),[p,w]=u.useState(1800),[y,x]=u.useState(86400),[j,g]=u.useState(""),[m,v]=u.useState("hours"),[S,b]=u.useState(""),[N,C]=u.useState(!0),[T,E]=u.useState(!1),[L,D]=u.useState(""),[G,J]=u.useState(null),[U,P]=u.useState([]),[ee,F]=u.useState(!1),[$,A]=u.useState([]),[W,R]=u.useState(0);u.useEffect(()=>{var bn;const k=sessionStorage.getItem("agentAuth"),_=sessionStorage.getItem("agentGate");if(!k||!_){e("/agent/new");return}const M=JSON.parse(k),ne=JSON.parse(_),ve={bounds:ne.bounds??{},context:ne.context??{},contextLabels:ne.contextLabels??void 0,gateContent:ne.gateContent};o(M),l(ve),ne.ttlConfig&&(w(ne.ttlConfig.default??1800),x(ne.ttlConfig.max??86400)),ne.templateMode==="automatic"?h("immediate"):ne.templateMode==="review"&&h("per-action");const kn=((bn=ne.ttlConfig)==null?void 0:bn.max)??86400;if(typeof ne.templateTtl=="number"&&ne.templateTtl>0){const ze=Math.min(ne.templateTtl,kn);w(ze),[3600,86400,604800,2592e3,31536e3].includes(ze)||(ze%86400===0?(g(String(ze/86400)),v("days")):(g(String(Math.max(1,Math.round(ze/3600)))),v("hours")))}z.getProfile(M.profileId).then(ze=>{var lt;if(d(ze),!S){const yt=ze.name??((lt=M.profileId.split("/").pop())==null?void 0:lt.replace(/@.*$/,""))??"",tt=[];if(ve.context&&ze.contextSchema)for(const Z of ze.contextSchema.keyOrder){const K=ve.context[Z];if(K!==void 0&&K!==""){const de=String(K).split(",").map(ye=>ye.trim()).filter(Boolean);tt.push(de.join(", "))}}const H=tt.length>0?`${yt}: ${tt.join(" · ")}`:yt;b(H)}}).catch(()=>{}),M.isPersonal?F(!0):Promise.all([z.getTeamProfileConfig(M.groupId,M.profileId).catch(()=>null),z.getGroupById(M.groupId).catch(()=>null),z.listUsers().catch(()=>[])]).then(([ze,lt,yt])=>{if(J(ze),ze){const tt=new Map;for(const K of yt){const de=K.name&&K.email?`${K.name} (${K.email})`:K.name||K.email||K.id;tt.set(K.id,de)}const H=(lt==null?void 0:lt.members)??[];for(const K of H){const de=K.userId??K.id;de&&(K.name&&K.email?tt.set(de,`${K.name} (${K.email})`):K.name&&tt.set(de,K.name))}const Z=(ze.approvers??[]).map(K=>tt.get(K)??K);P(Z)}}).finally(()=>{F(!0)})},[e]),u.useEffect(()=>{if(!(s!=null&&s.profileId))return;const k=s.profileId,_=sessionStorage.getItem("agentEditReplaces");z.getEnrichedAuthorizations().then(M=>{const ne=M.filter(ve=>ve.profileId===k&&ve.authorizationId!==_).map(ve=>({authorizationId:ve.authorizationId,bounds:ve.bounds,context:ve.context??{},intent:ve.intent}));A(ne)}).catch(()=>A([]))},[s==null?void 0:s.profileId]),u.useEffect(()=>{if(!i||!c||$.length===0){R(0);return}let k=!1;return(async()=>{const _=await na(i.bounds,c),M=await Promise.all($.map(ne=>na(ne.bounds,c).catch(()=>null)));k||R(M.filter(ne=>ne===_).length)})().catch(()=>{k||R(0)}),()=>{k=!0}},[i,c,$]);const B=async()=>{if(!(!s||!i||!c||!t)){if(!s.groupId){D("No active group; cannot create authorization.");return}E(!0),D("");try{const k=r||s.domain||"owner",_=await na(i.bounds,c),M=await up(i.context,c),[ne,ve]=await Promise.all([Ra(i.gateContent.intent),Ra(JSON.stringify({profile:s.profileId,domain:k,group:s.groupId}))]);let kn,bn,ze,lt;if(s.isTeam){const Z=await z.getApproversPubkeys(s.groupId,s.profileId);if(Z.length>0){const K=await z.encryptIntent(i.gateContent.intent,Z);kn=K.intentCiphertext,bn=K.encryptedKeys,ze=K.approversFrozen,lt=K.intentDisclosureHash}}const yt=`authz_${crypto.randomUUID()}`,tt=sessionStorage.getItem("agentEditReplaces")||void 0,H=await z.attest({authorization_id:yt,replaces:tt,profile_id:s.profileId,bounds:i.bounds,bounds_hash:_,context_hash:M,domain:k,did:t.did,gate_content_hashes:{intent:ne},execution_context_hash:ve,group_id:s.groupId,ttl:p,commitment_mode:f==="per-action"?"review":"automatic",title:S.trim(),intent_ciphertext:kn,encrypted_keys:bn,approvers_frozen:ze,intent_disclosure_hash:lt,disclose_identity:N});try{await z.pushGateContent(dp(H,{boundsHash:_,contextHash:M,context:i.context,contextLabels:i.contextLabels,gateContent:i.gateContent}))}catch(Z){try{await z.revokeAttestation(yt,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Authorization signed but gate content delivery failed. The attestation was revoked. Please try again. (${Z instanceof Error?Z.message:"Unknown error"})`)}if(tt)try{await z.revokeAttestation(tt,`Replaced by ${yt} (edit)`),z.resyncGates().catch(()=>{})}catch{}sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),e(`/authorizations?highlight=${encodeURIComponent(yt)}`)}catch(k){D(k instanceof Error?k.message:"Attestation failed")}finally{E(!1)}}};if(!s||!i)return a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const Q=Object.entries(i.bounds).filter(([k])=>k!=="profile"&&k!=="path"),q=Object.entries(i.context),ce=((G==null?void 0:G.caps)!=null?Object.keys(G.caps):[]).length!==0,pe=U.length>0?U.join(", "):((G==null?void 0:G.approvers)??[]).join(", "),te=ce?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${pe}, 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.",oe=ce?`Over-cap actions will be reviewed by you and ${pe}. Within-cap actions run per the mode you chose above.`:`Approvers ${pe} can read your intent but won't gate any action — no caps configured on this profile.`,se=!!((le=G==null?void 0:G.approvers)!=null&&le.length),I=ex(s,ee,G==null?void 0:G.approvers),X=p>y,ae={flex:1,padding:"0.75rem",border:f==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:f==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},ge={flex:1,padding:"0.75rem",border:f==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:f==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},me=((Ye=c==null?void 0:c.contextSchema)==null?void 0:Ye.keyOrder)??[],Pe=$.filter(k=>qy(me,i.context,k.context)),it=Pe.length>0,Ie=$e(s.profileId),vt=k=>{const _=Object.values(k).map(M=>String(M).trim()).filter(Boolean);return _.length>0?_.join(", "):"all (unscoped)"},Ke=Pe.map(k=>vt(k.context)).join("; "),et=`This grant's scope overlaps an existing grant on ${Ie} (scoped to: ${Ke}). 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 a.jsxs(a.Fragment,{children:[a.jsx(op,{currentStep:4,onStepClick:k=>{k<=3&&e(`/agent/gate?step=${k}`)}}),a.jsxs("div",{className:"card",children:[a.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),a.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your authorization details before signing."}),L&&a.jsx("div",{className:"error-message",children:L}),a.jsxs("div",{className:"field-editable",children:[a.jsxs("div",{className:"field-label",children:[a.jsx("span",{className:"pen",children:"✎"})," Title"]}),a.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${$e(s.profileId)}: daily operations`,value:S,onChange:k=>b(k.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),a.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this authorization on your dashboard."})]}),a.jsxs("div",{className:"field-editable",children:[a.jsxs("div",{className:"field-label",children:[a.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),a.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[a.jsxs("button",{onClick:()=>h("per-action"),style:ge,children:[a.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),a.jsxs("button",{onClick:()=>h("immediate"),style:ae,children:[a.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]})]}),a.jsxs("div",{className:"field-editable",children:[a.jsxs("div",{className:"field-label",children:[a.jsx("span",{className:"pen",children:"✎"})," Duration"]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center"},children:[[{label:"1 hour",seconds:3600},{label:"24 hours",seconds:86400},{label:"7 days",seconds:604800},{label:"30 days",seconds:2592e3},{label:"1 year",seconds:31536e3}].filter(k=>k.seconds<=y).map(k=>a.jsx("button",{onClick:()=>{w(k.seconds),g("")},style:{padding:"0.5rem 0.85rem",border:p===k.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:p===k.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:k.label},k.seconds)),a.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[a.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:j,onChange:k=>{g(k.target.value);const _=parseInt(k.target.value,10);if(_>0){const M=m==="days"?_*86400:_*3600;w(Math.min(M,y))}}}),a.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:m,onChange:k=>{v(k.target.value);const _=parseInt(j,10);if(_>0){const M=k.target.value==="days"?_*86400:_*3600;w(Math.min(M,y))}},children:[a.jsx("option",{value:"hours",children:"hours"}),a.jsx("option",{value:"days",children:"days"})]})]}),X&&a.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",y>=86400?`${Math.floor(y/86400)} days`:`${Math.floor(y/3600)} hours`]})]})]}),a.jsx("div",{className:"field-editable",children:a.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:N,onChange:k=>C(k.target.checked),style:{marginTop:"0.15rem"}}),a.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this authority",a.jsx("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.'})]})]})}),a.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),a.jsxs("div",{className:"info-block",children:[a.jsxs("div",{className:"info-head",children:[a.jsx("span",{className:"info-title",children:"Intent"}),a.jsx("button",{className:"info-edit",onClick:()=>e("/agent/gate?step=3"),children:"edit in step 3"})]}),a.jsx("div",{style:{whiteSpace:"pre-wrap"},children:i.gateContent.intent})]}),(!!Q.length||!!q.length)&&a.jsxs("div",{className:"info-block",children:[a.jsxs("div",{className:"info-head",children:[a.jsx("span",{className:"info-title",children:"Scope & Limits"}),a.jsx("button",{className:"info-edit",onClick:()=>e("/agent/gate?step=2"),children:"edit in step 2"})]}),a.jsxs("dl",{className:"info-kv",children:[q.map(([k,_])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:k}),a.jsx("dd",{children:fp(k,_,i.contextLabels)})]},k)),Q.map(([k,_])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:k}),a.jsx("dd",{children:String(_)})]},k))]})]}),a.jsxs("div",{className:"info-block",children:[a.jsx("div",{className:"info-head",children:a.jsx("span",{className:"info-title",children:"Authority"})}),a.jsxs("dl",{className:"info-kv",children:[a.jsx("dt",{children:"Profile"}),a.jsxs("dd",{children:[$e(s.profileId),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:s.profileId})]}),!s.isPersonal&&s.groupName&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Team"}),a.jsx("dd",{children:s.groupName})]}),!s.isPersonal&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Approvers"}),a.jsx("dd",{children:ee?(((V=G==null?void 0:G.approvers)==null?void 0:V.length)??0)===0?a.jsxs(a.Fragment,{children:[a.jsxs("span",{style:{color:"var(--danger)",fontWeight:600},children:["Not enabled for ",s.groupName??"this team"]}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:"A team admin must name at least one approver for this profile on the Authority Server (team → Profiles) before anyone can grant under it. Personal use is unaffected."})]}):a.jsxs(a.Fragment,{children:[pe,a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:te})]}):a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),W>0?a.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[a.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),a.jsxs("div",{children:[W===1?`An active grant on ${Ie} already has exactly these limits.`:`${W} active grants on ${Ie} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",a.jsx("strong",{children:"Extend"})," on the Authorizations page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,it?a.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[a.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Overlapping scope"}),a.jsx("div",{children:et})]})]}):null,a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("button",{className:"btn btn-ghost",onClick:()=>e("/agent/gate"),children:"Back"}),a.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:B,disabled:T||!S.trim()||I,children:T?"Signing...":f==="immediate"?"Authorize":"Authorize (Review Mode)"})]}),a.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:se?"block":"none"},children:oe})]})]})}const nx={card:"💳",mail:"✉️"};function rx(e){const t=e==null?void 0:e.overrides;return!t||typeof t!="object"?!1:Object.values(t).some(n=>{var r;return typeof((r=n==null?void 0:n.read)==null?void 0:r.ageField)=="string"})}const sx=[0,7,30,90,365,3650];function Os(e){return e===null?"From your authorization":e===0?"Read nothing":e===1?"1 day back":e===365?"1 year back":e%365===0?`${e/365} years back`:`${e} days back`}function ax({manifest:e,integration:t,state:n,onStatusChange:r,onSuccess:s}){var Ye;const[o,i]=u.useState({}),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[h,p]=u.useState({}),[w,y]=u.useState({}),[x,j]=u.useState(void 0),[g,m]=u.useState(!1),[v,S]=u.useState(null),[b,N]=u.useState(!1),[C,T]=u.useState(!1),[E,L]=u.useState(!1),[D,G]=u.useState(!1),[J,U]=u.useState({}),[P,ee]=u.useState(null),[F,$]=u.useState(!1),[A,W]=u.useState(null),[R,B]=u.useState(!1);u.useEffect(()=>{let V=!1;return z.getCredential(e.id).then(k=>{var _;if(!(V||!k.configured)){if(c(!0),f(!0),k.fields){const M={};for(const ne of e.credentials.fields)k.fields[ne.key]!=null&&(M[ne.key]=k.fields[ne.key]);p(M)}if(y(k.secrets??{}),j(k.updatedAt),e.oauth){const M=((_=k.fieldNames)==null?void 0:_.includes(e.oauth.tokenStorage))??!1;m(M),M&&z.getOAuthHealth(e.id).then(ne=>{V||S(ne)})}}}).catch(()=>{}),()=>{V=!0}},[e.id,e.oauth]);const Q=rx(e.toolGating),q=t?t.readAgeDays??null:void 0,re=F&&P?P.value:q,ce=async V=>{ee({value:V}),$(!0),W(null);try{await z.setReadPolicy(e.id,V),s(V===null?`${e.name} read window now follows your authorization`:`${e.name} read window set to ${Os(V).toLowerCase()}`),r()}catch(k){W(k instanceof Error?k.message:"Could not save")}finally{$(!1),ee(null)}},pe=!!e.oauth||e.credentials.fields.some(V=>!V.optional),te=e.oauth?g:l,oe=!pe||te,se=n==="starting"?"starting":oe?t!=null&&t.running?"running":!l&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&l&&!g?"needs-oauth":"unconfigured",I=async()=>{if(e.credentials.fields.some(k=>{var _;return(_=o[k.key])==null?void 0:_.trim()})){N(!0);try{await z.setCredential(e.id,o),c(!0),i({}),e.oauth?s(`${e.name} credentials saved!`):(s(`${e.name} credentials saved — starting integration...`),await Pe())}catch{s(`Failed to save ${e.name} credentials`)}finally{N(!1)}}},X=()=>{const V={};for(const k of e.credentials.fields){const _=o[k.key];k.type==="password"?_!=null&&_.trim()&&(V[k.key]=_):_!=null&&_!==(h[k.key]??"")&&(V[k.key]=_)}return V},ae=Object.keys(X()).length>0,ge=async()=>{const V=X();if(Object.keys(V).length!==0){N(!0);try{await z.setCredential(e.id,V),i({}),c(!0),e.oauth?s(`${e.name} credentials saved — now click Connect.`):(G(!1),s(`${e.name} credentials updated — restarting...`),await Pe())}catch{s(`Failed to update ${e.name} credentials`)}finally{N(!1)}}},me=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const V=setInterval(async()=>{var k;try{const _=await z.getCredential(e.id);_.configured&&e.oauth&&((k=_.fieldNames)!=null&&k.includes(e.oauth.tokenStorage))&&(m(!0),G(!1),S(null),clearInterval(V),s(`${e.name} connected — starting integration...`),z.getOAuthHealth(e.id).then(S).catch(()=>{}),await Pe())}catch{}},2e3);setTimeout(()=>clearInterval(V),12e4)},Pe=async()=>{L(!0);try{const V=await z.activateIntegration(e.id);V.warning?s(V.warning):s(`${e.name} integration started with ${V.tools.length} tools`),r()}catch(V){s(`Failed to start ${e.name}: ${V instanceof Error?V.message:"Unknown error"}`)}finally{L(!1)}},it=async()=>{try{await z.removeMcpIntegration(e.id),s(`${e.name} integration removed`),r()}catch{s(`Failed to remove ${e.name}`)}},Ie=nx[e.icon]??"🔧",vt=se==="running"?{c:"int-chip-ok",t:"Running"}:se==="starting"?{c:"int-chip-idle",t:"Starting"}:t&&!t.running&&t.error?{c:"int-chip-bad",t:"Crashed"}:{c:"int-chip-idle",t:"Stopped"},Ke=e.oauth&&g&&(v==null?void 0:v.status)==="failed",et=pe?Ke?{c:"int-chip-bad",t:"Auth failed"}:te?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},le=V=>V.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${e.id}/callback`);return a.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[a.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:Ie}),a.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:e.name}),a.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[se!=="unconfigured"&&se!=="needs-oauth"&&a.jsxs("span",{className:`int-chip ${vt.c}`,children:[a.jsx("span",{className:"int-dot"}),vt.t]}),a.jsxs("span",{className:`int-chip ${et.c}`,children:[a.jsx("span",{className:"int-dot"}),et.t]})]})]}),e.oauth&&g&&a.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:v!=null&&v.account?a.jsxs(a.Fragment,{children:["Connected as ",a.jsx("b",{children:v.account})]}):a.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),Ke&&!D&&a.jsxs("div",{style:{marginTop:"0.7rem",border:"1px solid var(--danger)",borderRadius:"10px",padding:"0.8rem 0.95rem",background:"color-mix(in srgb, var(--danger) 5%, var(--bg-elevated))"},children:[a.jsxs("div",{style:{fontSize:"0.86rem",fontWeight:700},children:[e.name," stopped accepting the stored credentials"]}),a.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0.3rem 0 0",lineHeight:1.55},children:[(v==null?void 0:v.error)==="invalid_grant"?a.jsxs(a.Fragment,{children:["The refresh token was revoked (",a.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):v!=null&&v.error?a.jsxs(a.Fragment,{children:["The provider reported ",a.jsx("code",{children:v.error}),"."]}):a.jsx(a.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",e.name," actions are ",a.jsx("b",{children:"blocked"}),", not failing silently."]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.6rem"},children:[a.jsxs("button",{className:"btn btn-primary btn-sm",onClick:me,children:["Reconnect ",e.name]}),a.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{i({...h}),G(!0)},children:"Edit credentials"})]})]}),a.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[a.jsx("summary",{children:"Details"}),a.jsxs("div",{className:"int-meta",children:[a.jsx("span",{className:"int-k",children:"What"}),a.jsx("span",{children:e.description}),e.profile&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"int-k",children:"Profile"}),a.jsx("span",{children:e.profile})]}),e.oauth&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"int-k",children:"Scopes"}),a.jsx("span",{children:((Ye=e.oauth.scopes)==null?void 0:Ye.join(", "))||"—"})]}),t&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"int-k",children:"Tools"}),a.jsxs("span",{children:[t.toolCount," gated"]})]})]})]}),e.setupGuide&&e.setupGuide.length>0&&(se!=="running"||Ke)&&a.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a.jsxs("button",{onClick:()=>T(!C),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[a.jsx("span",{style:{transition:"transform 0.2s",transform:C?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),C&&a.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((V,k)=>a.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[a.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:k+1}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:V.title}),a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[le(V.description),V.link&&a.jsxs(a.Fragment,{children:[" ",a.jsxs("a",{href:V.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},k))})]}),se==="starting"&&a.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[a.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),D&&a.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[a.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),d&&a.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.6rem"},children:["Leaving a secret blank keeps the stored one — editing other fields can never silently wipe it.",e.oauth?" Save, then Connect to re-link the account.":""]}),e.credentials.fields.map(V=>{var k;return a.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[a.jsx("label",{className:"form-label",children:V.label}),V.type==="password"?a.jsxs("div",{className:"cred-field",children:[a.jsx("input",{className:"form-input",type:J[V.key]?"text":"password",name:`${e.id}-${V.key}-credential`,autoComplete:"new-password",placeholder:(k=w[V.key])!=null&&k.preview?`Unchanged — ends in ${w[V.key].preview}`:d?"Unchanged — paste a new value to replace":V.placeholder,value:o[V.key]||"",onChange:_=>i(M=>({...M,[V.key]:_.target.value}))}),a.jsx("button",{className:"cred-toggle",onClick:()=>U(_=>({..._,[V.key]:!_[V.key]})),children:J[V.key]?"hide":"show"})]}):a.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${V.key}-credential`,autoComplete:"off",placeholder:V.placeholder,value:o[V.key]||"",onChange:_=>i(M=>({...M,[V.key]:_.target.value}))})]},V.key)}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[a.jsx("button",{className:"btn btn-primary btn-sm",onClick:ge,disabled:b||!ae,children:b?"Saving…":"Save"}),!ae&&!b&&a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),e.oauth&&a.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:me,children:["Connect ",e.name]}),a.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{G(!1),i({})},children:"Cancel"})]})]}),!D&&se==="running"&&t&&a.jsxs(a.Fragment,{children:[(Object.keys(h).length>0||Object.keys(w).length>0)&&a.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:e.credentials.fields.map(V=>{const k=V.type==="password",_=w[V.key];return!k&&h[V.key]==null||k&&_==null?null:a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[a.jsx("span",{style:{color:"var(--text-muted)"},children:V.label}),a.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[k?_.preview??"set":h[V.key],k&&x&&a.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(x).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},V.key)})}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[a.jsx(Je,{to:"/agent/new",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Authorize agent"}),(e.credentials.fields.length>0||e.oauth)&&a.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{i({...h}),G(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),a.jsx("span",{style:{flex:1}}),a.jsx("button",{className:"btn btn-sm btn-ghost",style:{color:"var(--danger)"},onClick:it,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"})]}),Q&&re!==void 0&&!R&&a.jsx("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"0.5rem",minWidth:0},children:[a.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"Reads"}),a.jsx("span",{style:{fontSize:"0.82rem",color:"var(--text-muted)"},children:re===null?"window from your authorization":Os(re).toLowerCase()}),F&&a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),A&&a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:A})]}),a.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>B(!0),children:"Edit"})]})}),Q&&re!==void 0&&R&&a.jsxs("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem",marginBottom:"0.35rem"},children:[a.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"How far back may your agent read?"}),a.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>B(!1),children:"Done"})]}),a.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-tertiary)",margin:"0 0 0.55rem"},children:"Applies immediately — no Save, no new authorization."}),a.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[sx.map(V=>{const k=re===V;return a.jsx("button",{className:`btn btn-sm ${k?"btn-primary":"btn-secondary"}`,"aria-pressed":k,disabled:F,onClick:()=>ce(V),children:Os(V)},V)}),a.jsx("button",{className:`btn btn-sm ${re===null?"btn-primary":"btn-ghost"}`,"aria-pressed":re===null,disabled:F,onClick:()=>ce(null),title:"Clear the local setting and use the read window from your signed authorization instead.",children:Os(null)})]}),a.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:A?a.jsx("span",{style:{color:"var(--danger)"},children:A}):F?a.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):re===null?a.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your authorization. If none is set there, reads are blocked."}):re===0?a.jsx("span",{style:{color:"var(--text-muted)"},children:"Your agent cannot read any mail."}):a.jsxs("span",{style:{color:"var(--text-muted)"},children:["Anything older than ",re," days is blocked, whoever it is from."]})})]}),a.jsx("div",{style:{display:"none"},children:a.jsx(Je,{to:"/agent/new",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Authorize your agent"})})]}),se==="unconfigured"&&(()=>{const V=e.credentials.fields.every(M=>M.optional),k=e.credentials.fields.some(M=>!M.optional),_=e.credentials.fields.some(M=>{var ne;return(ne=o[M.key])==null?void 0:ne.trim()});return a.jsxs(a.Fragment,{children:[d&&a.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:[a.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"," ",a.jsx("button",{onClick:()=>{c(!0),e.oauth&&m(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),e.oauth&&!d&&a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Step 1 of 2 — enter credentials, then connect your account."}),e.setupHint&&!d&&a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:e.setupHint}),e.credentials.fields.map(M=>a.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[a.jsx("label",{className:"form-label",children:M.label}),M.type==="password"?a.jsxs("div",{className:"cred-field",children:[a.jsx("input",{className:"form-input",type:J[M.key]?"text":"password",name:`${e.id}-${M.key}-credential`,autoComplete:"new-password",placeholder:M.placeholder,value:o[M.key]||"",onChange:ne=>i(ve=>({...ve,[M.key]:ne.target.value}))}),a.jsx("button",{className:"cred-toggle",onClick:()=>U(ne=>({...ne,[M.key]:!ne[M.key]})),children:J[M.key]?"hide":"show"})]}):a.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${M.key}-credential`,autoComplete:"off",placeholder:M.placeholder,value:o[M.key]||"",onChange:ne=>i(ve=>({...ve,[M.key]:ne.target.value}))})]},M.key)),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[_&&a.jsx("button",{className:"btn btn-primary",onClick:I,disabled:b||k&&!e.credentials.fields.filter(M=>!M.optional).every(M=>{var ne;return(ne=o[M.key])==null?void 0:ne.trim()}),children:b?"Saving...":"Save & Encrypt"}),V&&!_&&a.jsx("button",{className:"btn btn-primary",onClick:Pe,disabled:E,children:E?"Starting...":`Activate ${e.name}`})]})]})})(),se==="needs-oauth"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",e.name," account to authorize access."]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[a.jsxs("button",{className:"btn btn-primary",onClick:me,children:["Connect ",e.name," Account"]}),a.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Change Credentials"})]})]}),se==="ready"&&!t&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.75rem"},children:["✓"," ",e.oauth?`${e.name} account connected`:"Credentials configured"]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[a.jsx("button",{className:"btn btn-primary",onClick:Pe,disabled:E,children:E?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&a.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Update Credentials"}),e.oauth&&a.jsx("button",{className:"btn btn-ghost",onClick:()=>{c(!1),m(!1)},children:"Change Credentials"})]})]}),se==="ready"&&t&&!t.running&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[a.jsx("span",{className:"service-status-dot"}),"Not running"]}),t.error&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--danger)",marginBottom:"0.75rem"},children:t.error}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("button",{className:"btn btn-primary",onClick:Pe,disabled:E,children:E?"Starting...":"Start"}),a.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:it,children:"Disable"})]})]})]})}function ox(){const{loading:e,mcpServerUp:t,manifestsError:n,entries:r,refresh:s}=Ll(),[o,i]=u.useState(""),l=u.useCallback(c=>{i(c),setTimeout(()=>i(""),5e3)},[]);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"page-header",children:[a.jsx("h1",{className:"page-title",children:"Integrations"}),a.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),o&&a.jsx("div",{className:"alert alert-success",children:o}),e?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):t===!1?a.jsxs("div",{className:"status-banner status-banner-error",children:[a.jsx("span",{className:"status-banner-icon",children:"!"}),a.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):a.jsxs(a.Fragment,{children:[r.map(c=>a.jsx(ax,{manifest:c.manifest,integration:c.integration,state:c.state,onStatusChange:s,onSuccess:l},c.id)),r.length===0&&(n?a.jsxs("div",{className:"status-banner status-banner-error",children:[a.jsx("span",{className:"status-banner-icon",children:"!"}),a.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"," ",a.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):a.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."}))]})]})}function ix(){var D,G,J;const{activeTeam:e,activeMembership:t,refreshGroups:n,user:r}=Oe(),[s,o]=u.useState(null),[i,l]=u.useState(!1),[c,d]=u.useState(""),[f,h]=u.useState(""),[p,w]=u.useState(!1),[y,x]=u.useState(""),[j,g]=u.useState("");u.useEffect(()=>{fetch("/health").then(U=>U.json()).then(U=>{typeof U.spUrl=="string"&&g(U.spUrl)}).catch(()=>{})},[]),u.useEffect(()=>{if(!e){o(null);return}z.getGroupById(e.id).then(U=>{const P=U.group??U,ee=U.members??[],F=U.isAdmin??!1,$=ee.map(A=>{const W=A.userId||A.id||"",R=A.role||(F&&W===P.createdBy?"admin":"member");return{id:W,name:A.name||W.slice(0,8)||"Member",email:A.email||"",domains:A.domains||[],role:R,isAdmin:R==="admin"||F&&W===P.createdBy}});o({id:P.id,name:P.name,members:$})}).catch(()=>o(null))},[e==null?void 0:e.id]);const m=(s==null?void 0:s.members.filter(U=>U.isAdmin))??[],v=(e==null?void 0:e.isAdmin)===!0&&m.length<=1&&m.some(U=>U.id===(r==null?void 0:r.id)),S=(e==null?void 0:e.name)??"",b=y.trim()===S&&!i,N=()=>{x(""),w(!0)},C=()=>{w(!1),x("")},T=async()=>{if(!(!e||!b)){l(!0),d("");try{await z.leaveTeam(e.id),await n(),h("You have left the team."),o(null),C()}catch(U){d(U instanceof Error?U.message:"Failed to leave team")}finally{l(!1)}}},E=e&&j?`${j}/dashboard/groups/${e.id}`:void 0,L=j?`${j}/dashboard/groups`:void 0;return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"page-header",children:a.jsxs("div",{children:[a.jsx("h1",{className:"page-title",children:"Team"}),a.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Service Provider dashboard."})]})}),c&&a.jsx("div",{className:"error-message",children:c}),f&&a.jsx("div",{className:"alert alert-success",children:f}),e?a.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[a.jsxs("div",{className:"card-header",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"card-title",children:e.name}),a.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((D=s==null?void 0:s.members)==null?void 0:D.length)??0," ",(((G=s==null?void 0:s.members)==null?void 0:G.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),a.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(J=s==null?void 0:s.members)==null?void 0:J.map(U=>a.jsxs("div",{className:"member-row",children:[a.jsx("div",{className:"member-avatar",children:U.name.split(" ").map(P=>P[0]).join("").slice(0,2).toUpperCase()}),a.jsxs("div",{className:"member-info",children:[a.jsx("div",{className:"member-name",children:U.name}),a.jsx("div",{className:"member-email",children:U.email})]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:U.role})]},U.id)),a.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[E&&a.jsx("a",{className:"btn btn-secondary btn-sm",href:E,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Service Provider →"}),a.jsx("span",{title:v?"You are the only admin. Transfer admin to another member in your Service Provider dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:a.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:N,disabled:i||v,children:"Leave team"})})]})]}):a.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[a.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),a.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",maxWidth:480,marginLeft:"auto",marginRight:"auto"},children:"Every authorization you create here is in your personal context. You can join an existing team or create a new one in your Service Provider dashboard."}),L&&a.jsx("a",{className:"btn btn-primary btn-sm",href:L,target:"_blank",rel:"noopener noreferrer",children:"Open Service Provider dashboard →"})]}),p&&e&&a.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"leave-team-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:C,children:a.jsxs("div",{className:"card",onClick:U=>U.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[a.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",S,"?"]}),a.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),a.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[a.jsx("li",{children:"Revoke all authorizations you created in this team's context"}),a.jsx("li",{children:"Reject any pending action proposals you authored"}),a.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),a.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",a.jsx("strong",{children:"personal"})," authorizations are not affected."]}),a.jsxs("div",{className:"form-group",children:[a.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",a.jsx("code",{children:S})," to confirm:"]}),a.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:y,onChange:U=>x(U.target.value),placeholder:S,disabled:i,autoFocus:!0})]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[a.jsx("button",{className:"btn btn-ghost",onClick:C,disabled:i,children:"Cancel"}),a.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:T,disabled:!b,children:i?"Leaving...":"Leave team"})]})]})})]})}function lx({onDismiss:e}){const t=en(),{group:n,groupId:r,domain:s}=Oe(),[o,i]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState([]),[h,p]=u.useState(!0),[w,y]=u.useState({});u.useEffect(()=>{Promise.all([z.listProfiles().catch(()=>[]),z.getIntegrationManifests().then(C=>C.manifests??[]).catch(()=>[]),z.getMcpHealth().then(C=>C.integrations??[]).catch(()=>[])]).then(async([C,T,E])=>{if(i(C),c(T),f(E),r){const L=await Promise.all(C.map(G=>z.getTeamProfileConfig(r,G.id).catch(()=>null))),D={};C.forEach((G,J)=>{const U=L[J];U&&(D[G.id]=U)}),y(D)}}).finally(()=>p(!1))},[r]);const x=new Map;for(const C of l)C.profile&&x.set(C.profile,C);const j=C=>C.replace(/@.*$/,"").split("/").pop()??C,g=C=>C.split("@")[1]??"",m=new Map;for(const C of o){const T=j(C.id);if(!x.has(T))continue;const E=m.get(T);(!E||g(C.id).localeCompare(g(E.id),void 0,{numeric:!0})>0)&&m.set(T,C)}const v=l.map(C=>{const T=C.profile?m.get(C.profile):void 0;return T?{manifest:C,profile:T,integration:d.find(E=>E.id===C.id)}:null}).filter(C=>C!==null),S=C=>C in w,b=C=>{if(!r){console.error("No active group when creating authorization");return}const T=S(C);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:C,groupId:r,groupName:(n==null?void 0:n.name)??null,domain:s,isTeam:T,isPersonal:!!(n!=null&&n.isPersonal)})),sessionStorage.removeItem("agentGate"),e==null||e(),t("/agent/gate")},N=C=>{r&&b(C)};return a.jsxs(a.Fragment,{children:[a.jsx("style",{children:`
70
+ .profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
71
+ .profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
72
+ @media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
73
+ @media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
74
+ `}),h?a.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):v.length===0?a.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[a.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),a.jsx(Je,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>e==null?void 0:e(),children:"Go to Integrations"})]}):a.jsx("div",{className:"profile-grid",children:v.map(({manifest:C,profile:T,integration:E})=>{const L=S(T.id),D=(E==null?void 0:E.running)===!0;return a.jsxs("div",{className:"card",style:D?void 0:{opacity:.7},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[a.jsx("h3",{className:"card-title",style:{margin:0},children:C.name}),L?a.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"}):a.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"})]}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:C.description||T.description}),D?a.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>N(T.id),children:"Authorize"}):a.jsxs(Je,{to:`/integrations?setup=${(C==null?void 0:C.id)??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",(C==null?void 0:C.name)??"integration"]})]},C.id)})})]})}const cx={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function ux({status:e,label:t}){return a.jsx("span",{className:`status-badge status-${e}`,children:t||cx[e]})}function dx({domain:e,attested:t}){const n=t===!0?"domain-attested":t===!1?"domain-missing":"";return a.jsx("span",{className:`domain-badge ${n}`,style:{fontSize:"0.75rem"},children:e})}const Tn=86400,$r=3600,Bs=60,fx=30*Tn;function px(e){if(e<=0)return"Expired";if(e>90*Tn){const t=Math.floor(e/fx);return`${t} ${t===1?"month":"months"} remaining`}if(e>7*Tn){const t=Math.floor(e/Tn);return`${t} ${t===1?"day":"days"} remaining`}if(e>=2*Tn){const t=Math.floor(e/Tn),n=Math.floor(e%Tn/$r);return`${t} ${t===1?"day":"days"} ${n}h remaining`}if(e>=2*$r){const t=Math.floor(e/$r),n=Math.floor(e%$r/Bs);return`${t}h ${String(n).padStart(2,"0")}m remaining`}if(e>=Bs){const t=Math.floor(e/Bs),n=Math.floor(e%Bs);return`${t}m ${String(n).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function hx({expiresAt:e}){const[t,n]=u.useState(()=>e-Date.now()/1e3),r=t<2*$r;u.useEffect(()=>{const o=setInterval(()=>n(e-Date.now()/1e3),r?1e3:6e4);return()=>clearInterval(o)},[e,r]);const s=t<300;return a.jsx("span",{className:`ttl-badge ${s?"ttl-warn":"ttl-ok"}`,children:px(t)})}function pp({icon:e,title:t,text:n,children:r}){return a.jsxs("div",{className:"empty-state",children:[e&&a.jsx("div",{className:"empty-state-icon",children:e}),a.jsx("div",{className:"empty-state-title",children:t}),n&&a.jsx("div",{className:"empty-state-text",children:n}),r]})}function mx(e){const t=Math.floor(e/86400);if(t>=1)return`${t} day${t===1?"":"s"}`;const n=Math.floor(e/3600);if(n>=1)return`${n} hour${n===1?"":"s"}`;const r=Math.ceil(e/60);return`${r} minute${r===1?"":"s"}`}const gx=[{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 vx({item:e,onClose:t,onSuccess:n}){var v;const{user:r,activeDomain:s,groupId:o}=Oe(),[i,l]=u.useState(null);u.useEffect(()=>{let S=!1;return z.getProfile(e.profile_id).then(b=>{var N;S||l(((N=b==null?void 0:b.ttl)==null?void 0:N.max)??null)}).catch(()=>{}),()=>{S=!0}},[e.profile_id]);const c=e.remaining_seconds??0,d=gx.filter(S=>S.seconds>c&&(i===null||S.seconds<=i)),f=((v=d[0])==null?void 0:v.seconds)??2592e3,[h,p]=u.useState(f);u.useEffect(()=>{var S;if(i!==null&&h>i){const b=(S=d[d.length-1])==null?void 0:S.seconds;b&&p(b)}},[i]);const[w,y]=u.useState(!1),[x,j]=u.useState(""),g=Object.entries(e.frame).filter(([S])=>S!=="profile"&&S!=="path"),m=async()=>{var S;if(r){y(!0),j("");try{const b=e.authorization_id,N=await z.getGateContent(b);if(!N)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const C=await z.getProfile(e.profile_id),T=e.frame,E=N.context??{},L=e.attested_domains[0]||s||"owner",D=await na(T,C),G=await up(E,C),[J,U]=await Promise.all([Ra(N.gateContent.intent),Ra(JSON.stringify({profile:e.profile_id,path:e.path,domain:L}))]);if(!o)throw new Error("No active group; cannot extend authorization.");const P=(((S=e.deferred_commitment_domains)==null?void 0:S.length)??0)>0?"review":"automatic",ee=await z.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,bounds:T,bounds_hash:D,context_hash:G,domain:L,did:r.did,gate_content_hashes:{intent:J},execution_context_hash:U,group_id:o,commitment_mode:P,ttl:h});await z.pushGateContent(dp(ee,{boundsHash:D,contextHash:G,context:E,path:e.path,gateContent:N.gateContent})),n()}catch(b){j(b instanceof Error?b.message:"Extension failed")}finally{y(!1)}}};return a.jsx("div",{className:"modal-backdrop",onClick:S=>S.target===S.currentTarget&&t(),children:a.jsxs("div",{className:"modal",children:[a.jsxs("div",{className:"modal-header",children:[a.jsx("h3",{className:"modal-title",children:"Extend Authorization"}),a.jsx("button",{className:"modal-close",onClick:t,children:"×"})]}),a.jsxs("div",{className:"modal-body",children:[a.jsxs("div",{style:{marginBottom:"1rem"},children:[a.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[$e(e.profile_id)," / ",e.path]}),g.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:g.map(([S,b])=>`${S}=${b}`).join(" · ")})]}),a.jsxs("div",{style:{marginBottom:"1rem"},children:[a.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),c>0&&a.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",mx(c),". Only longer durations are shown."]}),a.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:d.length===0?a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This authorization is already on the longest available duration. Nothing to extend."}):d.map(S=>a.jsx("button",{className:`btn ${h===S.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>p(S.seconds),style:{minWidth:"3.5rem"},children:S.label},S.seconds))})]}),a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, context, and gate content will be re-attested with a new TTL (measured from now)."}),x&&a.jsx("div",{className:"error-message",children:x})]}),a.jsxs("div",{className:"modal-footer",children:[a.jsx("button",{className:"btn btn-secondary",onClick:t,disabled:w,children:"Cancel"}),a.jsx("button",{className:"btn btn-primary",onClick:m,disabled:w,children:w?"Extending...":"Extend"})]})]})})}function yx(e,t,n){return[...e].sort((r,s)=>{if(n){if(r.authorization_id===n&&s.authorization_id!==n)return-1;if(s.authorization_id===n&&r.authorization_id!==n)return 1}const o=Ta(r,t),i=Ta(s,t),l={active:0,pending:1,expired:2,revoked:3,archived:4};return l[o]!==l[i]?l[o]-l[i]:new Date(s.created_at).getTime()-new Date(r.created_at).getTime()})}function xx({item:e,newerProfile:t,revokedSet:n,expandedHash:r,gateCache:s,gateLoading:o,copiedHash:i,revokingHash:l,copyingHash:c,profileConfigCache:d,mode:f,ownerLabel:h,isAdmin:p,onExpand:w,onCopyHash:y,onCopy:x,onRevoke:j,onExtend:g,archivedSet:m,archivingHash:v,onArchive:S,highlightHash:b}){var pe;const N=$l(e,{revokedSet:n}),C=qf(e,{revokedSet:n,archivedSet:m}),T=!h&&!!S&&Xf(N),E=r===e.authorization_id,L=s[e.authorization_id],D=N==="active"||N==="pending"||N==="expired",G=Object.entries(e.frame).filter(([te])=>te!=="profile"&&te!=="path"),J=d.get(e.profile_id)??null,U=(((pe=J==null?void 0:J.approvers)==null?void 0:pe.length)??0)>0,P=new Map;if(J!=null&&J.caps&&f==="team")for(const[te,oe]of G){const se=J.caps[te];se!==void 0&&Number(oe)>se&&P.set(te,{authorized:Number(oe),cap:se})}const ee=P.size>0,F=e.approvers_frozen??[],$=(J==null?void 0:J.approvers)??[],A=f==="team"&&F.length>0&&$.length>0&&(F.length!==$.length||F.some(te=>!$.includes(te))||$.some(te=>!F.includes(te))),W=Array.from(P.entries()).map(([te,oe])=>`${te}: ${oe.authorized} (cap ${oe.cap})`).join(", "),R=Array.from(P.entries()).map(([te,oe])=>`${te}: ${oe.authorized} → ${oe.cap}`).join(", "),B=ee?U?P.size===1?`Above team cap: ${W} — actions require approval`:`Above team cap (${P.size}): ${W} — actions require approval`:P.size===1?`Reduced by hard cap: ${R}`:`Reduced by hard cap (${P.size}): ${R}`:"",Q=ee?U?"Above-cap actions under this authority 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 authorization to reissue within the cap.":void 0,q=$e(e.profile_id),re=t?a.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:[a.jsxs("strong",{style:{color:"var(--text-secondary)"},children:[q,"@",t.version," available"]}),t.whatsNew?a.jsxs(a.Fragment,{children:[" — ",t.whatsNew]}):null,a.jsx("br",{}),a.jsxs("span",{children:["This authority stays on ",e.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,ce=b!=null&&e.authorization_id===b;return a.jsxs("div",{className:`card${ce?" card-highlight":""}`,style:{marginBottom:0},children:[re,h&&a.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",a.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:h})]}),a.jsxs("div",{className:"auth-card-header",children:[a.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:q}),e.title&&a.jsx("span",{style:{fontWeight:500,fontSize:"0.85rem",color:"var(--text-secondary)"},children:e.title}),a.jsx(ux,{status:N}),N==="active"&&e.earliest_expiry&&a.jsx(hx,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),N==="expired"&&(()=>{const te=Iv(e,N);return te?a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(te.iso).toLocaleString()}`,children:new Date(te.iso).toLocaleDateString(void 0,{month:"short",day:"numeric"})}):null})()]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[e.required_domains.map(te=>a.jsx(dx,{domain:te,attested:e.attested_domains.includes(te)},te)),e.deferred_commitment_domains.length>0&&a.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"}),ee&&a.jsx("span",{title:Q,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:U?"var(--accent-subtle)":"var(--danger-subtle)",color:U?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:B}),A&&a.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.65rem",padding:"0.15rem 0.5rem",borderRadius:"0.25rem",background:"var(--warning-subtle, rgba(234,179,8,0.12))",color:"var(--warning, #ca8a04)",fontWeight:600,border:"1px solid var(--warning-border, rgba(234,179,8,0.3))",cursor:"pointer",lineHeight:1.4},onClick:()=>x(e),disabled:c===e.authorization_id,title:"The approver list for this profile has changed since this authority was created. Copy to reissue with the current approvers.",children:c===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),G.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:G.map(([te,oe],se)=>{const I=P.get(te);return a.jsxs("span",{children:[se>0&&" · ",I?U?a.jsxs("span",{title:`Team cap on ${te} is ${I.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${I.authorized}.`,children:[a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[te,"=",String(oe)]}),a.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",I.cap]})]}):a.jsxs("span",{title:`Team cap on ${te} is ${I.cap} with no approvers configured (hard cap). Authorized for ${I.authorized}; effective ${I.cap}.`,children:[a.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[te,"=",String(oe)]}),a.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",I.cap]})]}):a.jsxs("span",{children:[te,"=",String(oe)]})]},te)})}),a.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[T&&a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>S(e.authorization_id,!C),disabled:v===e.authorization_id,title:C?"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:v===e.authorization_id?C?"Unarchiving…":"Archiving…":C?"↩ Unarchive":"⊟ Archive"}),a.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>w(e),children:E?"▲ Hide Details":"▼ Details"})]}),E&&a.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[G.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Bounds"}),a.jsx("dl",{className:"review-grid",children:G.map(([te,oe])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:te}),a.jsx("dd",{children:String(oe)})]},te))})]}),(L==null?void 0:L.context)&&Object.keys(L.context).length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Context"}),a.jsx("dl",{className:"review-grid",children:Object.entries(L.context).map(([te,oe])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:te}),a.jsx("dd",{title:String(oe),children:fp(te,oe,L.contextLabels)})]},te))})]}),a.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Intent"}),o===e.authorization_id?a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):L?a.jsx("div",{className:"gate-content-block",children:a.jsx("div",{className:"gate-content-item",children:a.jsx("div",{className:"gate-content-text",children:L.gateContent.intent})})}):a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),a.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"1rem"},children:["Created: ",new Date(e.created_at).toLocaleString(),e.earliest_expiry&&` · Expires: ${new Date(e.earliest_expiry).toLocaleString()}`]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:e.authorization_id}),a.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>y(e.authorization_id),children:i===e.authorization_id?"copied":"copy"})]}),a.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!h&&a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>x(e),disabled:c===e.authorization_id,title:"Start a new authorization pre-filled with these bounds, context, and intent",children:c===e.authorization_id?"Copying…":"⧉ Copy"}),!h&&(N==="active"||N==="pending")&&a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>x(e,{asEdit:!0}),disabled:c===e.authorization_id,title:"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new authorization revokes this one",children:"✎ Edit"}),!h&&D&&a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>g(e),children:"↻ Extend"}),h&&p&&N!=="revoked"?a.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>j(e.authorization_id,h,q),disabled:l===e.authorization_id,children:l===e.authorization_id?"Revoking…":"Revoke"}):!h&&(N==="active"||N==="pending")?a.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>j(e.authorization_id),disabled:l===e.authorization_id,children:l===e.authorization_id?"Revoking…":"Revoke"}):null]})]})]},e.authorization_id)}function wx(){const[e,t]=u.useState([]),[n,r]=u.useState(!0),[s,o]=u.useState([]),[i,l]=u.useState(!1),[c,d]=u.useState(new Map),[f,h]=u.useState("mine"),[p,w]=u.useState("active"),[y,x]=u.useState(null),[j,g]=u.useState(null),[m,v]=Gf(),[S,b]=u.useState(()=>m.get("new")==="1"),[N,C]=u.useState(()=>m.get("highlight")),[T,E]=u.useState(null),[L,D]=u.useState({}),[G,J]=u.useState(null),[U,P]=u.useState(null),[ee,F]=u.useState(null),[$,A]=u.useState(new Set),[W,R]=u.useState(null),[B,Q]=u.useState(new Set),[q,re]=u.useState(null),[ce,pe]=u.useState(null),te=en(),{group:oe,groupId:se,domain:I,mode:X,activeTeam:ae}=Oe(),ge=(ae==null?void 0:ae.isAdmin)===!0,[me,Pe]=u.useState(()=>new Map),it=u.useCallback(()=>{r(!0),z.getMyAttestations().then(t).catch(()=>{}).finally(()=>r(!1))},[]),Ie=u.useCallback(()=>{z.getArchivedMandates().then(H=>Q(new Set(H))).catch(()=>{})},[]);u.useEffect(()=>{Ie()},[Ie]);const vt=async(H,Z)=>{re(H);try{const K=await z.setMandateArchived(H,Z);Q(new Set(K)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(K){alert(K instanceof Error?K.message:"Failed to update archive")}finally{re(null)}},Ke=u.useCallback(()=>{se&&(l(!0),z.listTeamAuthorizations(se).then(o).catch(()=>{}).finally(()=>l(!1)))},[se]);fe("attestation-changed",()=>{it(),ge&&se&&Ke()}),u.useEffect(()=>{if(!N)return;m.get("highlight")&&(m.delete("highlight"),v(m,{replace:!0}));const H=window.setTimeout(()=>C(null),3e3);return()=>window.clearTimeout(H)},[]),Ft(it,3e5),u.useEffect(()=>{f==="team"&&ge&&se&&s.length===0&&!i&&Ke()},[f,ge,se,s.length,i,Ke]),u.useEffect(()=>{let H=!1;return z.listProfiles().then(Z=>{if(H)return;const K=ct=>ct.replace(/@.*$/,"").split("/").pop()??ct,de=ct=>ct.split("@")[1]??"",ye=new Map;for(const ct of Z){const Ut=K(ct.id),vs=ye.get(Ut);(!vs||de(ct.id).localeCompare(de(vs.id),void 0,{numeric:!0})>0)&&ye.set(Ut,ct)}d(ye)}).catch(()=>{}),()=>{H=!0}},[]);const et=u.useCallback(H=>{const Z=Ut=>Ut.replace(/@.*$/,"").split("/").pop()??Ut,K=Ut=>Ut.split("@")[1]??"",de=c.get(Z(H));if(!de)return;const ye=K(H),ct=K(de.id);if(!(!ye||!ct))return ct.localeCompare(ye,void 0,{numeric:!0})>0?de:void 0},[c]);u.useEffect(()=>{if(X!=="team"||!se)return;const H=f==="mine"?e:s;if(H.length===0)return;const Z=[...new Set(H.map(K=>K.profile_id))].filter(K=>!me.has(K));if(Z.length!==0){Pe(K=>{const de=new Map(K);for(const ye of Z)de.set(ye,null);return de});for(const K of Z)z.getTeamProfileConfig(se,K).then(de=>{Pe(ye=>new Map(ye).set(K,de))}).catch(()=>{})}},[e,s,f,se,X,me]);const le=async H=>{if(T===H.authorization_id){E(null);return}E(H.authorization_id);const Z=H.authorization_id;if(!(Z in L)){J(H.authorization_id);try{const K=await z.getGateContent(Z);D(de=>({...de,[Z]:K}))}catch{D(K=>({...K,[Z]:null}))}finally{J(null)}}},Ye=H=>{navigator.clipboard.writeText(H).then(()=>{F(H),setTimeout(()=>F(null),2e3)})},V=async(H,Z)=>{var K;if(!se){alert("No active group; cannot copy authorization.");return}pe(H.authorization_id);try{const de=H.authorization_id;let ye=L[de]??null;de in L||(ye=await z.getGateContent(de),D(ys=>({...ys,[de]:ye})));const ct=Object.fromEntries(Object.entries(H.frame).filter(([ys])=>ys!=="profile"&&ys!=="path")),Ut=(ye==null?void 0:ye.context)??{},vs=((K=ye==null?void 0:ye.gateContent)==null?void 0:K.intent)??"",gp=H.deferred_commitment_domains.length>0?"review":"automatic",vp=H.attested_domains[0]||I||"owner",Ja=Date.parse(H.created_at),Xa=H.earliest_expiry?Date.parse(H.earliest_expiry):NaN,yp=Number.isFinite(Ja)&&Number.isFinite(Xa)&&Xa>Ja?Math.round((Xa-Ja)/1e3):void 0;sessionStorage.setItem("agentAuth",JSON.stringify({profileId:H.profile_id,groupId:se,groupName:(oe==null?void 0:oe.name)??null,domain:vp,isPersonal:!!(oe!=null&&oe.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:ct,context:Ut,gateContent:{intent:vs},templateMode:gp,templateTtl:yp})),Z!=null&&Z.asEdit?sessionStorage.setItem("agentEditReplaces",H.authorization_id):sessionStorage.removeItem("agentEditReplaces"),te("/agent/gate")}catch(de){alert(de instanceof Error?de.message:"Failed to copy authorization")}finally{pe(null)}},k=async(H,Z,K)=>{const de=Z&&K?`Revoke ${Z}'s ${K} authorization? This cannot be undone.`:"Revoke this authorization? The agent will no longer be able to execute actions under this attestation.";if(confirm(de)){R(H);try{await z.revokeAttestation(H),A(ye=>new Set(ye).add(H)),z.resyncGates().catch(()=>{}),Z&&se&&Ke()}catch(ye){alert(ye instanceof Error?ye.message:"Failed to revoke authorization")}finally{R(null)}}},_=f==="mine"?e:s,M=f==="mine"?n:i,ne=f==="mine"?{revokedSet:$,archivedSet:B}:{revokedSet:$},ve=H=>Ta(H,ne),kn={active:0,pending:0,expired:0,revoked:0,archived:0};for(const H of _)kn[ve(H)]+=1;const bn=f==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],ze=(()=>{const H=new Map;for(const Z of _){if(ve(Z)!==p)continue;const K=H.get(Z.profile_id)??{count:0,review:!1};K.count+=1,Z.deferred_commitment_domains.length>0&&(K.review=!0),H.set(Z.profile_id,K)}return Array.from(H.entries()).map(([Z,K])=>({profileId:Z,...K})).sort((Z,K)=>$e(Z.profileId).localeCompare($e(K.profileId)))})(),lt=yx(_.filter(H=>{if(ve(H)!==p||y!==null&&H.profile_id!==y)return!1;if(j!==null){const Z=H.deferred_commitment_domains.length>0;if(j==="review"&&!Z||j==="auto"&&Z)return!1}return!0}),ne,N),yt={revokedSet:$,expandedHash:T,gateCache:L,gateLoading:G,copiedHash:ee,revokingHash:W,copyingHash:ce,profileConfigCache:me,mode:X,activeDomain:I,group:oe,groupId:se,onExpand:le,onCopyHash:Ye,onCopy:V,onRevoke:k,onExtend:P,highlightHash:N},tt={...yt,archivedSet:B,archivingHash:q,onArchive:vt};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[a.jsxs("div",{children:[a.jsx("h1",{className:"page-title",children:"Mandates"}),a.jsx("p",{className:"page-subtitle",children:"Active, pending, expired, and archived agent authorizations."})]}),a.jsx("button",{className:"btn btn-primary",onClick:()=>b(!0),children:"+ New authorization"})]}),S&&a.jsx("div",{className:"modal-backdrop",onClick:()=>{b(!1),m.get("new")&&(m.delete("new"),v(m,{replace:!0}))},children:a.jsxs("div",{className:"modal",onClick:H=>H.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[a.jsxs("div",{className:"modal-header",children:[a.jsx("h2",{className:"modal-title",children:"New authorization"}),a.jsx("button",{className:"modal-close",onClick:()=>{b(!1),m.get("new")&&(m.delete("new"),v(m,{replace:!0}))},children:"×"})]}),a.jsxs("div",{className:"modal-body",children:[a.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."}),a.jsx(lx,{onDismiss:()=>b(!1)})]})]})}),ge&&a.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[a.jsx("button",{className:`nav-tab${f==="mine"?" active":""}`,onClick:()=>{h("mine"),w("active"),x(null),g(null),E(null)},children:"Mine"}),a.jsx("button",{className:`nav-tab${f==="team"?" active":""}`,onClick:()=>{h("team"),w("active"),x(null),g(null),E(null)},children:"Team"})]}),a.jsx("div",{className:"nav-tabs",children:bn.map(H=>a.jsxs("button",{className:`nav-tab${p===H?" active":""}`,onClick:()=>{w(H),x(null),g(null)},children:[H.charAt(0).toUpperCase()+H.slice(1)," (",kn[H],")"]},H))}),ze.length>0&&a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[ze.map(H=>{const Z=y===H.profileId;return a.jsx("button",{className:`btn btn-sm ${Z?"btn-primary":"btn-secondary"}`,onClick:()=>x(Z?null:H.profileId),children:$e(H.profileId)},H.profileId)}),a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(H=>{const Z=j===H;return a.jsx("button",{className:`btn btn-sm ${Z?"btn-primary":"btn-secondary"}`,onClick:()=>g(Z?null:H),children:H==="auto"?"Auto":"Review"},H)})]}),M&&_.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):lt.length===0?a.jsx(pp,{icon:"☰",title:"No authorizations",text:p==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${p} authorizations found.`}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:lt.map(H=>{const Z=f==="team"?H:null,K=Z!=null&&Z.owner?Z.owner.name??Z.owner.email??Z.owner.userId:void 0;return a.jsx(xx,{item:H,newerProfile:et(H.profile_id),ownerLabel:K,isAdmin:ge,...f==="mine"?tt:yt},H.authorization_id)})}),U&&a.jsx(vx,{item:U,onClose:()=>P(null),onSuccess:()=>{P(null),it()}})]})}function Sx(e){const t=e.indexOf("__");return t<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,t),toolName:e.slice(t+2)}}function jx(e,t){var c,d,f;const{integrationId:n,toolName:r}=Sx(e.action),s=t.find(h=>h.id===n),o=(d=(c=s==null?void 0:s.toolGating)==null?void 0:c.overrides)==null?void 0:d[r];if(o!=null&&o.actionLabel)return o.actionLabel;const i=$e(e.profileId),l=(f=e.executionContext)==null?void 0:f.action_type;return typeof l=="string"&&l?`${i} · ${l}`:`${i} · ${r}`}function kx(e){const t=[];for(const[n,r]of Object.entries(e.executionContext??{})){if(!n.startsWith("allowed_"))continue;const s=String(r??"").trim();s&&t.push(s.split(",").map(o=>o.trim()).filter(Boolean).join(", "))}return t.join(" · ")}function bx(e){if(!e)return"";const t=[];for(const[n,r]of Object.entries(e)){if(n==="action_type")continue;const s=String(r??"").trim();if(!s)continue;const o=n.replace(/^allowed_/,"").replace(/_/g," ");t.push(`${o} ${s.split(",").map(i=>i.trim()).filter(Boolean).join(", ")}`)}return t.join(" · ")}function Cx(e,t){var o,i;const n=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],r=e.actionType??(typeof((o=e.executionContext)==null?void 0:o.action_type)=="string"?e.executionContext.action_type:void 0),s=[];for(const{window:l,label:c}of n){const d=(i=e.cumulativeState)==null?void 0:i[l];if(!d)continue;const f=`_${l}_max`,h=Object.keys(t??{}).filter(j=>j.endsWith(f)),p=(r&&h.find(j=>j.startsWith(`${r}_`)))??(h.length===1?h[0]:void 0),y=(p?/^(amount|spend)_/.test(p):!1)?d.amount:d.count,x=p?Number(t==null?void 0:t[p]):NaN;p&&Number.isFinite(x)?s.push(`${y} of ${x} ${c}`):s.push(`${d.count} ${d.count===1?"call":"calls"} ${c}`)}return s.join(" · ")}function Nx(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function Ex(e){const t=$e(e),n=e.split("@")[1];return n?`${t}@${n}`:t}function Rr({label:e,children:t}){return a.jsxs(a.Fragment,{children:[a.jsx("dt",{className:"receipt-row-label",children:e}),a.jsx("dd",{className:"receipt-row-value",children:t})]})}function Tx({receipt:e,manifests:t,localAuth:n,localUnavailable:r,signature:s,grantTitle:o,ownerLabel:i,spUrl:l,formatDate:c,onOpenComplete:d}){var y;const f=kx(e),h=bx(n==null?void 0:n.context),p=Cx(e,(n==null?void 0:n.bounds)??e.limits),w=n==null?void 0:n.intent;return a.jsxs("div",{className:"card",style:{marginBottom:0},children:[a.jsxs("div",{className:"receipt-head",children:[a.jsx("span",{className:"receipt-what",children:jx(e,t)}),a.jsx("span",{className:"receipt-tag",children:Nx(e)?"review":"automatic"}),e.contentHash&&a.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(y=e.contentBinding)!=null&&y.fields?`The receipt binds: ${e.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),a.jsx("span",{className:"auth-card-time",children:c(e.timestamp)})]}),f&&a.jsx("div",{className:"receipt-scope",children:f}),a.jsxs("dl",{className:"receipt-rows",children:[a.jsx(Rr,{label:"authorization",children:a.jsx("strong",{children:o||Ex(e.profileId)})}),i&&a.jsx(Rr,{label:"owner",children:i}),h&&a.jsx(Rr,{label:"allowed",children:h}),p&&a.jsx(Rr,{label:"used",children:a.jsx("span",{className:"receipt-num",children:p})}),a.jsx(Rr,{label:"intent",children:w?a.jsx("span",{className:"receipt-intent",children:w}):a.jsx("span",{className:"receipt-absent",children:r?"local store unreachable — sign in to the gateway to read it":"not on this device — the Authority Server stores only its hash"})})]}),a.jsxs("div",{className:"receipt-foot",children:[s==="valid"&&a.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the receipt was issued — no Authority Server involved.",children:"✓ Verified on this device"}),s==="invalid"&&a.jsx("span",{className:"receipt-tamper",title:"The stored receipt does not match what was signed.",children:"⚠ Signature check FAILED"}),a.jsx("button",{type:"button",className:"receipt-evidence-link",onClick:d,children:"Complete receipt"}),l&&a.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",a.jsx("a",{className:"receipt-link",href:`${l}/r/${e.id}`,target:"_blank",rel:"noreferrer",children:"public link ↗"})]})]}),a.jsxs("details",{className:"receipt-more",children:[a.jsx("summary",{children:"Raw"}),a.jsxs("div",{className:"receipt-kv",children:[a.jsxs("div",{children:["receipt · ",e.id]}),a.jsxs("div",{children:["action · ",e.action]}),a.jsxs("div",{children:["profile · ",e.profileId]}),e.authorizationId&&a.jsxs("div",{children:["authorization · ",e.authorizationId]}),Object.keys(e.executionContext??{}).length>0&&a.jsxs("div",{children:["context ·"," ",Object.entries(e.executionContext).map(([x,j])=>`${x}=${j}`).join(" · ")]}),(n==null?void 0:n.boundsHash)&&a.jsxs("div",{children:["bounds hash · ",n.boundsHash]}),(n==null?void 0:n.contextHash)&&a.jsxs("div",{children:["context hash · ",n.contextHash]}),e.contentHash&&a.jsxs("div",{children:["content · ",e.contentHash]}),e.proposalId&&a.jsxs("div",{children:["proposal · ",e.proposalId]}),a.jsxs("div",{children:["signature · ",e.signature]})]})]})]})}function zx({receipt:e,onClose:t}){const[n,r]=u.useState(null),[s,o]=u.useState(null),[i,l]=u.useState(null),[c,d]=u.useState(!0),[f,h]=u.useState(!1);u.useEffect(()=>{let j=!1;return d(!0),z.getArchivedReceipt(e.id).then(g=>{j||(r(g),o(g?"local":"authority-server"),l((g==null?void 0:g.signature)??null))}).catch(()=>{j||o("authority-server")}).finally(()=>{j||d(!1)}),()=>{j=!0}},[e.id]);const p=n?n.entry:{receipt:e},w=JSON.stringify(p,null,2);function y(){const j=URL.createObjectURL(new Blob([w],{type:"application/json"})),g=document.createElement("a");g.href=j,g.download=`suveren-receipt-${e.id.slice(0,8)}.json`,g.click(),URL.revokeObjectURL(j)}async function x(){try{await navigator.clipboard.writeText(w),h(!0),setTimeout(()=>h(!1),2e3)}catch{h(!1)}}return a.jsx("div",{className:"modal-backdrop",onClick:j=>j.target===j.currentTarget&&t(),children:a.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[a.jsxs("div",{className:"modal-header",children:[a.jsx("h3",{className:"modal-title",children:"Complete receipt"}),a.jsx("button",{className:"modal-close",onClick:t,"aria-label":"Close",children:"×"})]}),a.jsxs("div",{className:"modal-body",children:[i==="valid"&&a.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 receipt was issued."}),i==="invalid"&&a.jsx("p",{className:"receipt-tamper",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"⚠ Signature check FAILED — the stored receipt does not match what was signed."}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children:c?"Loading…":s==="local"?"Held on this device — the signed receipt, the attestation 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 receipt (it predates local archiving, or ran on another device). Shown from the Authority Server — complete and signed, but it needs the server to retrieve."}),a.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:w})]}),a.jsxs("div",{className:"modal-footer",children:[a.jsx("button",{className:"btn btn-primary btn-sm",onClick:y,children:"Download"}),a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:x,children:f?"Copied":"Copy"})]})]})})}function Rx(e){return new Date(e*1e3).toLocaleString()}function Px(e,t){if(t==="all")return!0;const n=t==="1d"?1:t==="7d"?7:30,r=Math.floor(Date.now()/1e3)-n*86400;return e.timestamp>=r}function Ix(e,t){if(!t)return!0;const n=t.toLowerCase();return e.profileId.toLowerCase().includes(n)||$e(e.profileId).toLowerCase().includes(n)||e.path.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)||e.attestationHash.toLowerCase().includes(n)||e.id.toLowerCase().includes(n)||JSON.stringify(e.executionContext).toLowerCase().includes(n)}function uu(e,t){const n=new Map(e.map(r=>[r.id,r]));for(const r of t)n.set(r.id,r);return[...n.values()].sort((r,s)=>s.timestamp-r.timestamp)}function _x(){const{activeTeam:e,groupId:t}=Oe(),n=(e==null?void 0:e.isAdmin)===!0,[r,s]=u.useState("mine"),[o,i]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState(""),[h,p]=u.useState(!0),[w,y]=u.useState({}),[x,j]=u.useState(new Set),[g,m]=u.useState(""),[v,S]=u.useState(new Set),[b,N]=u.useState(new Set),[C,T]=u.useState("all"),[E,L]=u.useState(!1),[D,G]=u.useState(!1),[J,U]=u.useState(null),[P,ee]=u.useState({}),[F,$]=u.useState(!1),[A,W]=u.useState({}),[R,B]=u.useState({}),[Q,q]=u.useState(null),[re,ce]=u.useState(null),[pe,te]=u.useState(!1),[oe,se]=u.useState(!1),I=u.useRef(""),X=u.useCallback(k=>r==="team"&&n&&t?z.listTeamReceiptsPage(t,{before:k,limit:200}):z.getMyReceiptsPage({before:k,limit:200}),[r,n,t]),ae=u.useCallback(()=>{const k=r==="team"?`team:${t}`:"mine",_=I.current!==k;I.current=k,p(!0),se(!1),X().then(M=>{i(ne=>_?M.receipts:uu(ne,M.receipts)),ce(ne=>_?M.nextBefore:ne??M.nextBefore)}).catch(()=>{_&&i([]),se(!0)}).finally(()=>p(!1))},[X,r,t]),ge=u.useCallback(()=>{!re||pe||(te(!0),se(!1),X(re).then(k=>{i(_=>uu(_,k.receipts)),ce(k.nextBefore)}).catch(()=>se(!0)).finally(()=>te(!1)))},[re,pe,X]);Ft(ae,12e4),u.useEffect(()=>{z.getIntegrationManifests().then(({manifests:k})=>c(k)).catch(()=>{}),fetch("/health").then(k=>k.json()).then(k=>{typeof k.spUrl=="string"&&f(k.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),u.useEffect(()=>{z.getLocalAuthorizations().then(({authorizations:k,signatures:_})=>{ee(k),W(_),$(!1)}).catch(()=>{ee({}),W({}),$(!0)}),z.getMyAttestations().then(k=>{const _={};for(const M of k)M.authorization_id&&M.title&&(_[M.authorization_id]=M.title);B(_)}).catch(()=>{})},[]),u.useEffect(()=>{r!=="team"||Object.keys(w).length>0||z.listUsers().then(k=>{const _={};for(const M of k)_[M.id]={name:M.name,email:M.email};y(_)}).catch(()=>{})},[r,w]);const me=u.useMemo(()=>{const k=new Set;for(const _ of o)k.add($e(_.profileId));return[...k].sort()},[o]),Pe=u.useMemo(()=>{const k=new Set;for(const _ of o)k.add(_.action);return[...k].sort()},[o]),it=u.useMemo(()=>{if(r!=="team")return[];const k=new Set;for(const _ of o)_.userId&&k.add(_.userId);return[...k].map(_=>{var M;return{id:_,label:(M=w[_])!=null&&M.name?`${w[_].name} (${w[_].email})`:_}}).sort((_,M)=>_.label.localeCompare(M.label))},[r,o,w]),Ie=u.useMemo(()=>o.filter(k=>!(!Ix(k,g)||v.size>0&&!v.has($e(k.profileId))||b.size>0&&!b.has(k.action)||x.size>0&&k.userId&&!x.has(k.userId)||!Px(k,C))),[o,g,v,b,x,C]),vt=v.size>0||b.size>0||x.size>0||C!=="all";function Ke(k){S(_=>{const M=new Set(_);return M.has(k)?M.delete(k):M.add(k),M})}function et(k){N(_=>{const M=new Set(_);return M.has(k)?M.delete(k):M.add(k),M})}function le(k){j(_=>{const M=new Set(_);return M.has(k)?M.delete(k):M.add(k),M})}function Ye(){S(new Set),N(new Set),j(new Set),T("all"),m("")}async function V(){G(!0),U(null);try{const{bundle:k,filename:_}=await z.fetchEvidenceBundle(),M=URL.createObjectURL(new Blob([JSON.stringify(k,null,2)],{type:"application/json"})),ne=document.createElement("a");ne.href=M,ne.download=_,ne.click(),URL.revokeObjectURL(M);const ve=k.sources??{};ve.authorityServer?ve.local||U(`Downloaded Authority Server history only — ${ve.localError??"local archive unavailable."}`):U(`Downloaded local evidence only — ${ve.asError??"Authority Server export unavailable."}`)}catch(k){U(`Export failed: ${k instanceof Error?k.message:String(k)}`)}finally{G(!1)}}return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[a.jsxs("div",{children:[a.jsx("h1",{className:"page-title",children:"Tickets"}),a.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),a.jsx("button",{className:"btn btn-secondary",onClick:V,disabled:D,children:D?"Preparing…":"Download evidence"})]}),J&&a.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:J}),n&&a.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(k=>a.jsx("button",{onClick:()=>s(k),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:r===k?"2px solid var(--accent)":"2px solid transparent",color:r===k?"var(--text-primary)":"var(--text-tertiary)",fontWeight:r===k?600:500},children:k==="mine"?"Mine":"Team"},k))}),a.jsxs("div",{className:"search-filter-bar",children:[a.jsxs("div",{className:"search-input-wrap",children:[a.jsx("span",{className:"search-icon",children:"⌕"}),a.jsx("input",{type:"text",className:"form-input search-input",placeholder:"Search by profile, action, path, or hash\\u2026",value:g,onChange:k=>m(k.target.value)}),g&&a.jsx("button",{className:"search-clear",onClick:()=>m(""),children:"×"})]}),a.jsxs("button",{className:`btn btn-sm btn-secondary${E?" active":""}`,onClick:()=>L(!E),children:["Filters",vt?` (${v.size+b.size+(C!=="all"?1:0)})`:""]})]}),E&&a.jsxs("div",{className:"filter-panel",children:[me.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Profile"}),a.jsx("div",{className:"filter-chips",children:me.map(k=>a.jsx("button",{className:`filter-chip${v.has(k)?" selected":""}`,onClick:()=>Ke(k),children:k},k))})]}),Pe.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Action"}),a.jsx("div",{className:"filter-chips",children:Pe.map(k=>a.jsx("button",{className:`filter-chip${b.has(k)?" selected":""}`,onClick:()=>et(k),children:k},k))})]}),r==="team"&&it.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Owner"}),a.jsx("div",{className:"filter-chips",children:it.map(k=>a.jsx("button",{className:`filter-chip${x.has(k.id)?" selected":""}`,onClick:()=>le(k.id),children:k.label},k.id))})]}),a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Time range"}),a.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([k,_])=>a.jsx("button",{className:`filter-chip${C===k?" selected":""}`,onClick:()=>T(k),children:_},k))})]})]}),vt&&a.jsxs("div",{className:"active-filters",children:[[...v].map(k=>a.jsxs("span",{className:"active-chip",onClick:()=>Ke(k),children:[k," ",a.jsx("span",{className:"chip-remove",children:"×"})]},k)),[...b].map(k=>a.jsxs("span",{className:"active-chip",onClick:()=>et(k),children:[k," ",a.jsx("span",{className:"chip-remove",children:"×"})]},k)),[...x].map(k=>{const _=w[k],M=_?_.name:k;return a.jsxs("span",{className:"active-chip",onClick:()=>le(k),children:[M," ",a.jsx("span",{className:"chip-remove",children:"×"})]},k)}),C!=="all"&&a.jsxs("span",{className:"active-chip",onClick:()=>T("all"),children:[C==="1d"?"Today":C==="7d"?"7 days":"30 days"," ",a.jsx("span",{className:"chip-remove",children:"×"})]}),a.jsx("button",{className:"clear-filters",onClick:Ye,children:"Clear all"})]}),oe&&a.jsx("div",{className:"card",style:{borderColor:"var(--danger, #c0392b)",marginBottom:"0.75rem"},children:a.jsx("span",{style:{color:"var(--danger, #c0392b)",fontSize:"0.85rem"},children:"Couldn’t load receipts — your session may have expired. Try signing out and back in."})}),h&&o.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Ie.length===0?a.jsx(pp,{icon:"⌕",title:o.length===0?"No receipts in the last 30 days":"No matching receipts",text:o.length===0?"Execution receipts appear here after an agent uses an authorized tool. Older receipts can be loaded below.":"Try adjusting your search or filters."}):a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:Ie.length===o.length?`${o.length} receipt${o.length!==1?"s":""}`:`${Ie.length} of ${o.length} receipts`}),a.jsx("div",{className:"timeline",children:Ie.map(k=>{const _=k.userId?w[k.userId]:void 0;return a.jsx("div",{className:"timeline-event",children:a.jsx(Tx,{receipt:k,manifests:l,localAuth:k.authorizationId?P[k.authorizationId]:void 0,localUnavailable:F,signature:A[k.id],grantTitle:k.authorizationId?R[k.authorizationId]:null,ownerLabel:r==="team"&&k.userId?_?`${_.name} (${_.email})`:k.userId:null,spUrl:d,formatDate:Rx,onOpenComplete:()=>q(k)})},k.id)})})]}),Q&&a.jsx(zx,{receipt:Q,onClose:()=>q(null)}),re&&a.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:ge,disabled:pe,children:pe?"Loading…":"Load older"})})]})}const Ax={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function $x(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[s,o]=u.useState(null),i=u.useCallback(async()=>{try{t(await z.getAutostart())}catch(d){o(d instanceof Error?d.message:"Could not read autostart state")}},[]);u.useEffect(()=>{i()},[i]);const l=u.useCallback(async()=>{if(!(!(e!=null&&e.supported)||n)){r(!0),o(null);try{await z.setAutostart(!e.installed)}catch(d){o(d instanceof Error?d.message:"Failed")}finally{try{t(await z.getAutostart()),o(null)}catch(d){o(d instanceof Error?d.message:"Could not re-read state")}r(!1)}}},[e,n,i]);if(!e)return a.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[a.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),a.jsx("p",{role:s?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:s?`Could not read autostart state: ${s}`:"Checking…"})]});const c=Ax[e.platform]??"a login service";return a.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[a.jsxs("div",{children:[a.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),a.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:e.supported?a.jsxs(a.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",c," — no admin rights needed."]}):e.reason})]}),e.supported&&a.jsx("button",{type:"button",onClick:()=>void l(),disabled:n,"aria-pressed":e.installed,className:e.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:n?"Working…":e.installed?"Turn off":"Turn on"})]}),e.supported&&a.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",a.jsx("strong",{children:e.installed?"On — starts from your next login":"Off"})]}),e.supported&&a.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 ",a.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]}),s&&a.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger, #c00)"},children:s})]})}function Lx(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[s,o]=u.useState(null),i=u.useCallback(async()=>{try{const c=await z.getGatewaySettings();t(c.desktopNotifications),o(null)}catch(c){o(c instanceof Error?c.message:"Could not read notification setting")}},[]);u.useEffect(()=>{i()},[i]);const l=u.useCallback(async()=>{if(!(e===null||n)){r(!0),o(null);try{const c=await z.setGatewaySettings({desktopNotifications:!e});t(c.desktopNotifications)}catch(c){o(c instanceof Error?c.message:"Failed to save"),await i()}finally{r(!1)}}},[e,n,i]);return e===null?a.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[a.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),a.jsx("p",{role:s?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:s?`Could not read the setting: ${s}`:"Checking…"})]}):a.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[a.jsxs("div",{children:[a.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),a.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."})]}),a.jsx("button",{type:"button",onClick:()=>void l(),disabled:n,"aria-pressed":e,className:e?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:n?"Saving…":e?"Turn off":"Turn on"})]}),s&&a.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:s})]})}const Mx={npm:"Checking npm for new releases",docker:"Checking the container registry for new images",dev:"Git checkout — comparing against origin/main, not npm releases"};function Fx(){const{version:e,latestVersion:t,updateAvailable:n,installMethod:r}=_l();return e?a.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[a.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Version"}),a.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:["Running ",a.jsx("strong",{children:e}),n&&t?a.jsxs(a.Fragment,{children:[" — ",a.jsx("strong",{children:t})," is available"]}):null]}),a.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:[Mx[r]??"Update checking is unavailable",r==="dev"&&a.jsx(a.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}const Ox={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"]}};function Bx(){const[e,t]=u.useState(""),[n,r]=u.useState("openrouter"),[s,o]=u.useState("openai-compatible"),[i,l]=u.useState("https://openrouter.ai/api/v1"),[c,d]=u.useState("google/gemma-4-31b-it"),[f,h]=u.useState(""),[p,w]=u.useState(!1),[y,x]=u.useState(!1),[j,g]=u.useState(!1),[m,v]=u.useState(null),[S,b]=u.useState([]),[N,C]=u.useState(!1),[T,E]=u.useState(null),[L,D]=u.useState(""),G=u.useCallback(A=>{t(A),setTimeout(()=>t(""),3e3)},[]),J=u.useCallback(async(A,W,R)=>{C(!0),E(null);try{const B=await z.aiModels({provider:A,endpoint:W,...R?{apiKey:R}:{}});B.ok&&B.models.length>0?(b(B.models),E(`${B.models.length} models available`)):(b([]),E(B.message||"No models returned — using defaults"))}catch(B){b([]),E(B instanceof Error?B.message:"Failed to load models")}finally{C(!1)}},[]),U=u.useCallback(async()=>{try{const A=await z.getCredential("ai-config");if(w(A.configured),A.configured&&A.fields){const W=A.fields.provider||"openai-compatible",R=A.fields.endpoint||"";A.fields.provider&&o(W),A.fields.endpoint&&l(R),A.fields.model&&d(A.fields.model),R.includes("openai.com")?r("openai"):R.includes("groq.com")?r("groq"):R.includes("together.xyz")?r("together"):R.includes("openrouter.ai")?r("openrouter"):r("ollama"),R&&J(W,R)}}catch{}},[J]);u.useEffect(()=>{U()},[U]);const P=A=>{r(A),b([]),E(null),D("");const W=Ox[A];W&&(o(W.provider),l(W.endpoint),d(""),J(W.provider,W.endpoint,f||void 0))},ee=()=>J(s,i,f||void 0),F=async()=>{x(!0);try{await z.setCredential("ai-config",{provider:s,endpoint:i,model:c,...f?{apiKey:f}:{}}),w(!0),G("AI configuration saved!")}catch{G("Failed to save AI config")}finally{x(!1)}},$=async()=>{g(!0),v(null);try{const A=await z.aiTest({provider:s,endpoint:i,model:c,...f?{apiKey:f}:{}});v(A.ok?`OK: ${A.message}`:`Failed: ${A.message}`)}catch(A){v(`Error: ${A instanceof Error?A.message:"Unknown"}`)}finally{g(!1)}};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"page-header",children:[a.jsx("h1",{className:"page-title",children:"AI Assistant"}),a.jsx("p",{className:"page-subtitle",children:"Advisory AI to help you think through intent when authorizing agents."})]}),e&&a.jsx("div",{className:"alert alert-success",children:e}),a.jsxs("div",{className:"card",children:[a.jsx("h3",{className:"card-title",children:"Configuration"}),a.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 authorizations. Keys are encrypted in your vault."}),p&&a.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[a.jsx("span",{className:"status-banner-icon",children:"✓"}),a.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),a.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[a.jsx("label",{className:"form-label",children:"Provider Preset"}),a.jsxs("select",{className:"form-input",value:n,onChange:A=>P(A.target.value),children:[a.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),a.jsx("option",{value:"ollama",children:"Ollama (local)"}),a.jsx("option",{value:"openai",children:"OpenAI"}),a.jsx("option",{value:"groq",children:"Groq"}),a.jsx("option",{value:"together",children:"Together"})]})]}),a.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[a.jsxs("label",{className:"form-label",children:["API Key ",s==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),a.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:f,onChange:A=>h(A.target.value),onBlur:()=>{f.trim()&&J(s,i,f.trim())},placeholder:p?"••••••••••••••••":"sk-... (not needed for Ollama)"}),a.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."})]}),a.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a.jsx("label",{className:"form-label",children:"Model"}),a.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.75rem",padding:"0.125rem 0.5rem"},onClick:ee,disabled:N,title:"Re-fetch the model list from the provider",children:N?"Loading…":"↻ Refresh"})]}),S.length===0?a.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:N?"Loading models…":s==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const A=S,W=A.includes(c),R=A.length>12,B=L.trim().toLowerCase();let Q=B?A.filter(q=>q.toLowerCase().includes(B)):A;return W&&!Q.includes(c)&&(Q=[c,...Q]),a.jsxs(a.Fragment,{children:[R&&a.jsx("input",{className:"form-input",value:L,onChange:q=>D(q.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),a.jsxs("select",{className:"form-input",value:W?c:"__unset__",onChange:q=>d(q.target.value==="__unset__"?"":q.target.value),children:[a.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),Q.map(q=>a.jsx("option",{value:q,children:q},q)),B&&Q.length===0&&a.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",L,"”"]})]})]})})(),T&&a.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:T})]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.jsx("button",{className:"btn btn-primary",onClick:F,disabled:y||!c.trim(),title:c.trim()?void 0:"Select a model first",children:y?"Saving...":"Save & Encrypt"}),p&&a.jsx("button",{className:"btn btn-ghost",onClick:$,disabled:j,children:j?"Testing...":"Test Connection"})]}),m&&a.jsx("div",{className:`alert ${m.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:m})]}),a.jsx(Dx,{}),a.jsx($x,{}),a.jsx(Lx,{}),a.jsx(Fx,{}),a.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[a.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,marginBottom:"1rem"},children:"Security"}),a.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[a.jsxs("div",{style:{marginBottom:"1rem"},children:[a.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),a.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[a.jsx("li",{children:"Every tool call verified against your authorization bounds"}),a.jsx("li",{children:"Credentials never exposed to agents through MCP"}),a.jsx("li",{children:"Every action produces a signed receipt"})]})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),a.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[a.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),a.jsx("li",{children:"For best security, run agents in sandboxed environments"}),a.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})]})]})}function Dx(){const[e,t]=u.useState(null),[n,r]=u.useState({intent:"",context:""}),[s,o]=u.useState(null),[i,l]=u.useState(null),[c,d]=u.useState(null),[f,h]=u.useState(!1),p=u.useCallback(async()=>{if(!f)try{const x=await z.getAIPrompts();t(x),r({intent:x.intent.current,context:x.context.current}),h(!0)}catch(x){l(x instanceof Error?x.message:"Failed to load prompts")}},[f]),w=async x=>{if(e){o(x),l(null);try{const j=n[x],g=j.trim()===e[x].default.trim()?"":j;await z.setAIPrompt(x,g);const m=await z.getAIPrompts();t(m),r({intent:m.intent.current,context:m.context.current}),d(x),setTimeout(()=>d(null),2e3)}catch(j){l(j instanceof Error?j.message:"Save failed")}finally{o(null)}}},y=async x=>{if(confirm(`Revert ${x} prompt to the built-in default?`)){o(x),l(null);try{await z.setAIPrompt(x,"");const j=await z.getAIPrompts();t(j),r({intent:j.intent.current,context:j.context.current})}catch(j){l(j instanceof Error?j.message:"Revert failed")}finally{o(null)}}};return a.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:x=>{x.currentTarget.open&&p()},children:[a.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),a.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-authorization) or Context (your standing-orders brief). Edit with care — changes apply on the next chat turn."}),i&&a.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:i}),!f&&!i&&a.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),e&&a.jsxs(a.Fragment,{children:[a.jsx(du,{kind:"intent",label:"Intent — per-authorization",description:"Used on the Intent gate when creating a new authorization.",state:e.intent,draft:n.intent,onChange:x=>r(j=>({...j,intent:x})),onSave:()=>w("intent"),onRevert:()=>y("intent"),saving:s==="intent",justSaved:c==="intent"}),a.jsx(du,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:e.context,draft:n.context,onChange:x=>r(j=>({...j,context:x})),onSave:()=>w("context"),onRevert:()=>y("context"),saving:s==="context",justSaved:c==="context"})]})]})}function du({kind:e,label:t,description:n,state:r,draft:s,onChange:o,onSave:i,onRevert:l,saving:c,justSaved:d}){const f=s!==r.current;return a.jsxs("section",{style:{marginBottom:"1.5rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:t}),a.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:n})]}),r.overridden&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),a.jsx("textarea",{className:"form-textarea",value:s,onChange:h=>o(h.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":`${t} system prompt`}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[a.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:i,disabled:c||!f,children:c?"Saving…":"Save"}),r.overridden&&a.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:l,disabled:c,title:"Discard the override and use the built-in default",children:"Revert to default"}),d&&a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--success)"},children:"Saved"}),f&&!c&&!d&&a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),a.jsxs("details",{style:{marginTop:"0.5rem"},children:[a.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),a.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:r.default})]}),a.jsx("span",{style:{display:"none"},children:e})]})}function Ux(e){return e.proposalId?"review":"automatic"}function fu(e,t,n={}){const r=n.status??"pending",s=n.includeAutonomous??!1,o=[];for(const i of e)r==="pending"&&i.status!=="pending"||n.profile&&i.profileId!==n.profile||o.push({kind:"proposal",id:i.id,sortTimestamp:i.createdAt,commitmentMode:"review",profileId:i.profileId,proposal:i});if(r==="all")for(const i of t){const l=Ux(i);!s&&l==="automatic"||n.profile&&i.profileId!==n.profile||o.push({kind:"receipt",id:i.id,sortTimestamp:i.timestamp,commitmentMode:l,profileId:i.profileId,receipt:i})}return o.sort((i,l)=>l.sortTimestamp-i.sortTimestamp),typeof n.limit=="number"&&n.limit>0?o.slice(0,n.limit):o}const Wx=["https://","http://"];function hp(e,t){return e!=null&&e.length?e.flatMap(n=>{const r=n.template.replace(/\{(\w+)\}/g,(s,o)=>{const i=t[o];return typeof i=="string"||typeof i=="number"?String(i):"\0"});return r.includes("\0")||/\{|\}/.test(r)?[]:Wx.some(s=>r.toLowerCase().startsWith(s))?[{label:n.label,href:r,description:n.description}]:[]}):[]}function Hx({profileId:e}){return a.jsx("span",{className:"profile-badge",children:$e(e)})}function mp(e,t){const n=e-Math.floor(t/1e3);if(n<=0)return{label:"expired",urgent:!1,expired:!0};const r=Math.floor(n/86400),s=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);let i;return r>0?i=`expires in ${r}d ${s}h`:s>0?i=`expires in ${s}h ${o}m`:i=`expires in ${Math.max(1,o)}m`,{label:i,urgent:n<2*3600,expired:!1}}const Vx={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},Gx={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"};function Kx(e){const t=Date.now()-e*1e3,n=t/36e5;return n<48?n<1?`${Math.max(1,Math.round(t/6e4))}m ago`:`${Math.round(n)}h ago`:new Date(e*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Yx(e){return e.split("__").pop()??e}function Qx(e){const t=e.toLowerCase();return t.includes("delete")||t.includes("refund")||t.includes("cancel")||t.includes("revoke")}const Jx=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]),Xx=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function qx(e,t){return typeof t!="string"?!1:/^data:image\//i.test(t)?!0:Xx.test(e)?/^https?:\/\//.test(t):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(t)}function Ri(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(t=>Ri(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function pu({item:e,onApprove:t,onReject:n,resolving:r,proposalLinks:s}){const o=e.kind==="proposal",i=o?e.proposal.status:"executed",l=o?e.proposal.tool:e.receipt.action,c=Yx(l),d=Qx(l),f=o?e.proposal.toolArgs:null,h=o?e.proposal.executionContext:e.receipt.executionContext,p=o?null:e.receipt.cumulativeState,w=o?hp(s,e.proposal.toolArgs):[],y=f?Object.entries(f).filter(([j])=>!Jx.has(j)):[],x=Object.entries(h??{});return a.jsxs("div",{className:"card",children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[a.jsx(Hx,{profileId:e.profileId}),a.jsx("code",{style:{fontSize:"0.85rem"},children:c}),e.commitmentMode==="automatic"&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),a.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[o&&i==="pending"&&(()=>{const j=mp(e.proposal.expiresAt,Date.now());return a.jsx("span",{style:{fontSize:"0.72rem",color:j.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:j.urgent?600:400,whiteSpace:"nowrap"},children:j.label})})(),a.jsx("span",{className:`status-badge ${Gx[i]}`,children:Vx[i]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Kx(e.sortTimestamp)})]})]}),d&&a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.4rem",fontSize:"0.8rem",color:"var(--warning)",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.4rem 0.6rem",marginBottom:"0.75rem"},children:[a.jsx("span",{children:"⚠"}),a.jsx("span",{children:"Irreversible action"})]}),o&&typeof(f==null?void 0:f._imagePreview)=="string"&&a.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),a.jsx("img",{src:f._imagePreview,alt:typeof(f==null?void 0:f.altText)=="string"?f.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),w.length>0&&a.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:w.map(j=>a.jsxs("a",{href:j.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:j.description??j.href,children:[j.label," ↗"]},j.label))}),o&&y.length>0&&a.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Arguments"}),a.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.2rem 0.75rem",fontSize:"0.85rem",margin:0},children:y.map(([j,g])=>a.jsxs(u.Fragment,{children:[a.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:j}),a.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:qx(j,g)?a.jsx("img",{src:g,alt:typeof(f==null?void 0:f.altText)=="string"?f.altText:j,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"},onError:m=>{const v=m.currentTarget,S=v.parentElement;if(!S)return;v.style.display="none";const b=document.createElement("span");b.textContent=g,b.style.color="var(--text-tertiary)",S.appendChild(b)}}):Ri(g)})]},j))})]}),x.length>0&&a.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:x.map(([j,g])=>`${j}=${Ri(g)}`).join(" · ")}),p&&a.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",p.daily.count," action",p.daily.count===1?"":"s",p.daily.amount>0?`, ${p.daily.amount}`:""," · ","this month: ",p.monthly.count,p.monthly.amount>0?`, ${p.monthly.amount}`:""]}),o&&i==="pending"&&a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("button",{className:"btn btn-primary",onClick:()=>t==null?void 0:t(e.id),disabled:r,children:r?"Approving…":"Approve"}),a.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:()=>n==null?void 0:n(e.id),disabled:r,children:"Reject"})]}),a.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[o?"Proposal":"Receipt",": ",e.id]})]})}const Zx=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function Pi(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(t=>Pi(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function e0(e){const t=Date.now()-e*1e3,n=Math.floor(t/6e4);if(n<60)return`${Math.max(1,n)}m ago`;const r=Math.floor(t/36e5);return r<48?`${r}h ago`:`${Math.floor(r/24)}d ago`}function t0({proposal:e,currentUserId:t,onAction:n,onMessage:r,proposalLinks:s}){const[o,i]=u.useState(!1),[l,c]=u.useState(!1),[d,f]=u.useState(null),[h,p]=u.useState(!1),[w,y]=u.useState(null),[x,j]=u.useState(!1),g=e.tool.split("__").pop()??e.tool,m=Object.entries(e.toolArgs).filter(([P])=>!Zx.has(P)),v=Object.entries(e.executionContext),S=hp(s,e.toolArgs),b=e.pendingApprovers??[],N=e.approvedBy??{},C=Object.keys(N).length,T=b.filter(P=>!(P in N)).length,E=t in N,L=async()=>{if(d===null){p(!0),y(null);try{const P=await z.getAttestationIntent(e.authorizationId);if(!P){y("Intent not available or you are not an authorized approver.");return}const ee=await z.decryptIntent({intentCiphertext:P.intentCiphertext,encryptedKey:P.encryptedKey,approverId:t});f(ee)}catch(P){y(P instanceof Error?P.message:"Failed to decrypt intent")}finally{p(!1)}}},D=async()=>{x?j(!1):(j(!0),await L())},G=async()=>{i(!0),r("");try{await z.approveProposal(e.id);try{if(d===null){const P=await z.getAttestationIntent(e.authorizationId);if(P){const ee=await z.decryptIntent({intentCiphertext:P.intentCiphertext,encryptedKey:P.encryptedKey,approverId:t});f(ee),await z.storeApprovedIntent(e.authorizationId,ee)}}else await z.storeApprovedIntent(e.authorizationId,d)}catch{}r(`Approved. ${T-1>0?`${T-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),n()}catch(P){r(P instanceof Error?P.message:"Approval failed")}finally{i(!1)}},J=async()=>{const P=prompt("Rejection reason (optional):");if(P!==null){c(!0),r("");try{await z.rejectProposal(e.id,P||void 0),r("Action rejected."),n()}catch(ee){r(ee instanceof Error?ee.message:"Rejection failed")}finally{c(!1)}}},U=o||l;return a.jsxs("div",{className:"card",children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[a.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:$e(e.profileId)}),a.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),a.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const P=mp(e.expiresAt,Date.now());return a.jsx("span",{style:{fontSize:"0.72rem",color:P.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:P.urgent?600:400,whiteSpace:"nowrap"},children:P.label})})(),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:e0(e.createdAt)})]})]}),a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[C," of ",b.length," approver",b.length===1?"":"s"," signed off",b.map(P=>{const ee=P in N;return a.jsxs("span",{style:{marginLeft:"0.5rem",color:ee?"var(--success, green)":"var(--text-tertiary)"},children:[ee?"✓":"○"," ",P===t?"You":P]},P)})]}),a.jsxs("div",{style:{marginBottom:"0.5rem"},children:[a.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Proposed action"}),a.jsx("code",{style:{fontSize:"0.85rem"},children:g})]}),S.length>0&&a.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:S.map(P=>a.jsxs("a",{href:P.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:P.description??P.href,children:[P.label," ↗"]},P.label))}),m.length>0&&a.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Arguments"}),a.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.2rem 0.75rem",fontSize:"0.85rem",margin:0},children:m.map(([P,ee])=>a.jsxs(u.Fragment,{children:[a.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:P}),a.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:Pi(ee)})]},P))})]}),v.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:v.map(([P,ee])=>`${P}=${Pi(ee)}`).join(" · ")}),a.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a.jsxs("button",{className:"btn btn-ghost btn-sm",style:{padding:"0.2rem 0",fontSize:"0.75rem"},onClick:D,disabled:h,children:[x?"▲ Hide intent":"▼ Show intent",h&&" (decrypting...)"]}),x&&a.jsx("div",{style:{marginTop:"0.5rem",padding:"0.75rem",background:"var(--bg-main)",borderRadius:"0.375rem",border:"1px solid var(--border)"},children:w?a.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:w}):d!==null?a.jsx("p",{style:{fontSize:"0.85rem",margin:0,whiteSpace:"pre-wrap",color:"var(--text-primary)"},children:d}):a.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this authority."})})]}),!E&&a.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[a.jsx("button",{className:"btn btn-primary",onClick:G,disabled:U,children:o?"Approving...":"Approve"}),a.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:J,disabled:U,children:l?"Rejecting...":"Reject"})]}),E&&a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"You approved this action. Waiting on other approvers."}),a.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",e.id]})]})}function n0(){const{domain:e,user:t}=Oe(),n=(t==null?void 0:t.id)??"",[r,s]=u.useState("awaiting-me"),[o,i]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState(!0),[h,p]=u.useState(""),w=u.useCallback(async()=>{try{const I=await z.getProposalsForApprover();i(I)}catch{}finally{f(!1)}},[]);fe("proposal-added",w),fe("proposal-approved",w),fe("proposal-rejected",w),fe("proposal-resolved",w),Ft(w,3e4);const[y,x]=u.useState([]),j=u.useCallback(async()=>{try{const I=await z.getProposals(e||"owner");x(I)}catch{}},[e]);fe("proposal-added",j),fe("proposal-approved",j),fe("proposal-rejected",j),fe("proposal-resolved",j),Ft(j,3e4,e);const g=u.useMemo(()=>y.filter(I=>{var X;return I.status==="pending"&&(((X=I.pendingApprovers)==null?void 0:X.length)??0)===0}),[y]),m=u.useMemo(()=>fu(g,[],{status:"pending"}),[g]),[v,S]=u.useState([]),b=u.useCallback(async()=>{if(n)try{const X=(await z.getProposals(e||"owner")).filter(ae=>ae.status==="pending"&&ae.pendingApprovers&&ae.pendingApprovers.includes(n)&&ae.approvedBy&&n in ae.approvedBy);S(X)}catch{}},[n,e]);fe("proposal-approved",b),fe("proposal-rejected",b),Ft(b,3e4,`${n}:${e}`),u.useEffect(()=>{z.getIntegrationManifests().then(I=>c(I.manifests??[])).catch(()=>{})},[]);const N=I=>{var X;return(X=l.find(ae=>ae.id===I.split("__")[0]))==null?void 0:X.proposalLinks};u.useEffect(()=>{w(),j(),b()},[]);const[C,T]=u.useState([]),[E,L]=u.useState([]),[D,G]=u.useState(!0),[J,U]=u.useState(null),[P,ee]=u.useState(""),[F,$]=u.useState("pending"),[A,W]=u.useState(null),[R,B]=u.useState(!1),Q=u.useCallback(async()=>{try{const{proposals:I,receipts:X}=await z.getThread({domain:e,status:F,sinceDays:7});T(I),L(X)}catch{}finally{G(!1)}},[e,F]);Ft(Q,3e4,`${e}:${F}`);const q=async(I,X)=>{U(I),ee("");try{const ae=e||"owner",ge=await z.resolveProposal(I,X,ae);ee(X==="commit"?`Action approved. Status: ${ge.status}`:"Action rejected."),await Promise.all([Q(),j()])}catch(ae){ee(ae instanceof Error?ae.message:"Failed")}finally{U(null)}},re=u.useMemo(()=>{const I=new Set;for(const X of C)I.add(X.profileId);for(const X of E)I.add(X.profileId);return Array.from(I).sort()},[C,E]),ce=u.useMemo(()=>fu(C,E,{status:F,profile:A??void 0,includeAutonomous:R}),[C,E,F,A,R]),pe=u.useCallback(()=>{w(),b()},[w,b]),te=u.useMemo(()=>{const I=new Set,X=[];for(const ae of v)I.has(ae.id)||(I.add(ae.id),X.push(ae));return X.sort((ae,ge)=>ge.createdAt-ae.createdAt)},[v]),oe=o.length+m.length,se=te.length;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"page-header",children:[a.jsx("h1",{className:"page-title",children:"Pending Approvals"}),a.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."})]}),a.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[a.jsxs("button",{className:`nav-tab${r==="awaiting-me"?" active":""}`,onClick:()=>s("awaiting-me"),children:["Awaiting me ",oe>0&&a.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--warning)",color:"var(--bg-elevated)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:oe})]}),a.jsxs("button",{className:`nav-tab${r==="awaiting-others"?" active":""}`,onClick:()=>s("awaiting-others"),children:["Awaiting others ",se>0&&a.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:se})]}),a.jsx("button",{className:`nav-tab${r==="all"?" active":""}`,onClick:()=>{s("all"),Q()},children:"All"})]}),r==="awaiting-me"&&a.jsx(a.Fragment,{children:d&&oe===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):oe===0?a.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[a.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(h||P)&&a.jsx("div",{className:"alert alert-success",children:h||P}),m.map(I=>a.jsx(pu,{proposalLinks:I.kind==="proposal"?N(I.proposal.tool):void 0,item:I,onApprove:X=>q(X,"commit"),onReject:X=>q(X,"reject"),resolving:J===I.id},I.id)),o.map(I=>a.jsx(t0,{proposal:I,currentUserId:n,onAction:pe,onMessage:p,proposalLinks:N(I.tool)},I.id))]})}),r==="awaiting-others"&&a.jsx(a.Fragment,{children:te.length===0?a.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[a.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:te.map(I=>a.jsx(s0,{proposal:I,currentUserId:n,onCancel:async()=>{try{await z.rejectProposal(I.id,"cancelled by creator"),b(),j()}catch(X){alert(X instanceof Error?X.message:"Cancel failed")}}},I.id))})}),r==="all"&&a.jsxs(a.Fragment,{children:[P&&a.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:P}),a.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[a.jsx("button",{className:`filter-chip ${F==="pending"?"selected":""}`,onClick:()=>$("pending"),children:"Pending"}),a.jsx("button",{className:`filter-chip ${F==="all"?"selected":""}`,onClick:()=>$("all"),children:"All"}),re.length>0&&a.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),re.map(I=>a.jsx("button",{className:`filter-chip ${A===I?"selected":""}`,onClick:()=>W(A===I?null:I),children:$e(I)},I)),F==="all"&&a.jsxs(a.Fragment,{children:[a.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),a.jsxs("button",{className:`filter-chip ${R?"selected":""}`,onClick:()=>B(!R),title:"Include actions executed without human review (automatic commitment mode)",children:[R?"✓ ":"","Autonomous actions"]})]})]}),D&&ce.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ce.length===0?a.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[a.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:F==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:F==="pending"?"Your agents are operating within their authorizations. Switch to All to see recent activity.":"When an agent calls a gated tool, activity will appear here."})]}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:ce.map(I=>a.jsx(pu,{proposalLinks:I.kind==="proposal"?N(I.proposal.tool):void 0,item:I,onApprove:X=>q(X,"commit"),onReject:X=>q(X,"reject"),resolving:J===I.id},I.id))})]})]})}function r0(e){const t=Date.now()-e*1e3,n=Math.floor(t/6e4);if(n<60)return`${Math.max(1,n)}m ago`;const r=Math.floor(t/36e5);return r<48?`${r}h ago`:`${Math.floor(r/24)}d ago`}function s0({proposal:e,currentUserId:t,onCancel:n}){var d;const[r,s]=u.useState(!1),o=Object.keys(e.approvedBy??{}),i=(e.pendingApprovers??[]).filter(f=>!(f in(e.approvedBy??{}))),l=(((d=e.pendingApprovers)==null?void 0:d.length)??0)>0,c=async()=>{if(confirm("Cancel this action? All approvers will be notified.")){s(!0);try{await n()}finally{s(!1)}}};return a.jsxs("div",{className:"card",children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[a.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:$e(e.profileId)}),l&&a.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),a.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:r0(e.createdAt)})]}),a.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:a.jsx("code",{children:e.tool.split("__").pop()??e.tool})}),l&&a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[o.map(f=>a.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:f===t?"You approved":`${f} approved`},f)),i.map(f=>a.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",f===t?"you":f]},f))]}),a.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:a.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--danger)"},onClick:c,disabled:r,children:r?"Cancelling...":"Cancel"})})]})}const a0=`# Agent Brief
75
+
76
+ You act on my behalf through Suveren — the gateway that gates every
77
+ privileged tool call you make. Suveren implements the bounded-authority
78
+ model from the open Human Agency Protocol (HAP): each authorization
79
+ describes an area of authority, a set of numeric limits, and a scope.
80
+ Operate inside those bounds or the Gatekeeper will reject your action.
81
+
82
+ ## Before you act in a domain
83
+
84
+ 1. Call \`list-authorizations(domain: "<domain>")\` to load the full
85
+ intent, scope, and usage for that area. The session brief shows only
86
+ a one-line summary per authority — the Intent paragraph lives behind
87
+ that call, and often contains soft rules you MUST honor (e.g. "never
88
+ publish on weekends", "only reply in English").
89
+ 2. If the action would exceed a bound or fall outside the scope, stop
90
+ and explain what would be blocked instead of trying.
91
+ 3. If you're not sure whether an action is covered, ask me first.
92
+
93
+ ## How to handle reviews
94
+
95
+ Authorizations in review mode require my approval before the action
96
+ executes. When you propose an action:
97
+ - Include everything I need to judge it (title, recipients, amounts,
98
+ dates, attendees) in the tool arguments.
99
+ - Don't batch unrelated proposals — one proposal per decision.
100
+
101
+ ## Standing orders
102
+
103
+ (Add your own here. Examples:)
104
+
105
+ - Every morning, summarize today's calendar and flag conflicts.
106
+ - On Fridays, give me a weekly review: what's done, what slipped, what's
107
+ next.
108
+ - Never email anyone outside the company without asking first.
109
+ - When drafting posts, prefer plain language over marketing copy.
110
+ `;function o0(){const[e,t]=u.useState(""),[n,r]=u.useState(""),[s,o]=u.useState(!0),[i,l]=u.useState(!1),[c,d]=u.useState(null),[f,h]=u.useState(!1),p=e!==n,w=new Blob([e]).size,y=16*1024;u.useEffect(()=>{if(!p)return;const m=S=>{S.preventDefault(),S.returnValue=""},v=S=>{var C,T;if(S.defaultPrevented||S.button!==0||S.metaKey||S.ctrlKey||S.shiftKey||S.altKey)return;const b=(T=(C=S.target)==null?void 0:C.closest)==null?void 0:T.call(C,"a");if(!b||!b.href)return;let N;try{N=new URL(b.href)}catch{return}N.origin===window.location.origin&&N.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(S.preventDefault(),S.stopPropagation()))};return window.addEventListener("beforeunload",m),document.addEventListener("click",v,!0),()=>{window.removeEventListener("beforeunload",m),document.removeEventListener("click",v,!0)}},[p]),u.useEffect(()=>{let m=!1;return z.getAgentContext().then(v=>{m||(t(v),r(v))}).catch(v=>{m||d({kind:"error",text:v instanceof Error?v.message:"Failed to load context"})}).finally(()=>{m||o(!1)}),()=>{m=!0}},[]);const x=async()=>{l(!0),d(null);try{await z.saveAgentContext(e),r(e),d({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(m){d({kind:"error",text:m instanceof Error?m.message:"Save failed"})}finally{l(!1)}},j=()=>{t(n),d(null)},g=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||t(a0)};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"page-header",children:[a.jsx("h1",{className:"page-title",children:"Agent Brief"}),a.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!e.trim()&&!s&&a.jsx("button",{className:"btn btn-primary btn-sm",onClick:g,disabled:i,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),c&&a.jsx("div",{className:c.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:c.text}),a.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[a.jsx("div",{className:"card intent-pane chat",children:a.jsx(za,{target:{kind:"context"},currentText:e,onApply:m=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||t(m)},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…"})}),a.jsxs("div",{className:"card intent-pane document",children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[a.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),a.jsxs("span",{style:{fontSize:"0.75rem",color:w>y?"var(--danger)":"var(--text-muted)"},children:[w.toLocaleString()," / ",y.toLocaleString()," bytes"]})]}),a.jsx("textarea",{className:"form-textarea",value:e,onChange:m=>t(m.target.value),placeholder:s?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:s,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),a.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[a.jsx("button",{className:"btn btn-ghost",onClick:j,disabled:i||!p,children:"Revert"}),a.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:x,disabled:i||!p||w>y||s,children:i?"Saving…":"Save"})]})]}),a.jsx("button",{type:"button",className:"floating-help",onClick:()=>h(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),a.jsx(ip,{open:f,onClose:()=>h(!1),ariaLabel:"Brief assistant",children:a.jsx(za,{target:{kind:"context"},currentText:e,onApply:m=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(t(m),h(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function i0({children:e}){const{user:t,mode:n,domain:r}=Oe();return t?n==="team"&&!r?a.jsx(sn,{to:"/onboarding",replace:!0}):a.jsx(a.Fragment,{children:e}):a.jsx(sn,{to:"/login",replace:!0})}function l0(){const{user:e}=Oe();return a.jsxs(Vg,{children:[a.jsx(Le,{path:"/login",element:e?a.jsx(sn,{to:"/",replace:!0}):a.jsx(iy,{})}),a.jsx(Le,{path:"/onboarding",element:e?a.jsx(ly,{}):a.jsx(sn,{to:"/login",replace:!0})}),a.jsxs(Le,{element:a.jsx(i0,{children:a.jsx(oy,{})}),children:[a.jsx(Le,{path:"/",element:a.jsx(Sy,{})}),a.jsx(Le,{path:"/agent/new",element:a.jsx(sn,{to:"/authorizations?new=1",replace:!0})}),a.jsx(Le,{path:"/agent/gate",element:a.jsx(Ky,{})}),a.jsx(Le,{path:"/agent/review",element:a.jsx(tx,{})}),a.jsx(Le,{path:"/integrations",element:a.jsx(ox,{})}),a.jsx(Le,{path:"/groups",element:a.jsx(ix,{})}),a.jsx(Le,{path:"/authorizations",element:a.jsx(wx,{})}),a.jsx(Le,{path:"/audit",element:a.jsx(_x,{})}),a.jsx(Le,{path:"/proposals",element:a.jsx(n0,{})}),a.jsx(Le,{path:"/agent-brief",element:a.jsx(o0,{})}),a.jsx(Le,{path:"/settings",element:a.jsx(Bx,{})}),a.jsx(Le,{path:"/settings/services",element:a.jsx(sn,{to:"/settings",replace:!0})}),a.jsx(Le,{path:"/deploy",element:a.jsx(sn,{to:"/integrations",replace:!0})})]}),a.jsx(Le,{path:"*",element:a.jsx(sn,{to:"/",replace:!0})})]})}function c0(){return a.jsx(gv,{children:a.jsx(Nv,{children:a.jsx(Ev,{children:a.jsx(l0,{})})})})}Tf(document.getElementById("root")).render(a.jsx(u.StrictMode,{children:a.jsx(c0,{})}));