@suveren/gateway 0.7.6 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/content/integrations/mollie.json +103 -28
  2. package/dist/mcp-server/http.mjs +228 -118
  3. package/dist/ui/assets/{index-CsrM6RQr.js → index-BFnSVa9N.js} +22 -22
  4. package/dist/ui/index.html +1 -1
  5. package/node_modules/@hap/core/dist/index.d.mts +29 -6
  6. package/node_modules/@hap/core/dist/index.d.ts +29 -6
  7. package/node_modules/@hap/core/dist/index.js +54 -8
  8. package/node_modules/@hap/core/dist/index.mjs +53 -8
  9. package/node_modules/@hap/core/package.json +2 -1
  10. package/node_modules/@hap/core/src/frame.ts +115 -14
  11. package/node_modules/@hap/core/src/gatekeeper.ts +26 -0
  12. package/node_modules/@hap/core/src/types.ts +7 -1
  13. package/node_modules/@types/node/README.md +1 -1
  14. package/node_modules/@types/node/buffer.buffer.d.ts +5 -0
  15. package/node_modules/@types/node/crypto.d.ts +0 -2
  16. package/node_modules/@types/node/dgram.d.ts +119 -4
  17. package/node_modules/@types/node/ffi.d.ts +1 -1
  18. package/node_modules/@types/node/fs/promises.d.ts +61 -65
  19. package/node_modules/@types/node/fs.d.ts +86 -76
  20. package/node_modules/@types/node/http.d.ts +1 -1
  21. package/node_modules/@types/node/http2.d.ts +2 -2
  22. package/node_modules/@types/node/index.d.ts +1 -0
  23. package/node_modules/@types/node/inspector.d.ts +2 -1
  24. package/node_modules/@types/node/net.d.ts +108 -16
  25. package/node_modules/@types/node/package.json +2 -2
  26. package/node_modules/@types/node/quic.d.ts +37 -11
  27. package/node_modules/@types/node/stream/iter.d.ts +4 -4
  28. package/node_modules/@types/node/tls.d.ts +24 -0
  29. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +5 -0
  30. package/node_modules/@types/node/ts5.6/index.d.ts +1 -0
  31. package/node_modules/@types/node/ts5.7/index.d.ts +1 -0
  32. package/node_modules/@types/node/tty.d.ts +4 -3
  33. package/node_modules/@types/node/vfs.d.ts +210 -0
  34. package/node_modules/@types/node/vm.d.ts +1 -1
  35. package/node_modules/express-rate-limit/dist/index.cjs +6 -3
  36. package/node_modules/express-rate-limit/dist/index.d.cts +11 -0
  37. package/node_modules/express-rate-limit/dist/index.d.mts +11 -0
  38. package/node_modules/express-rate-limit/dist/index.d.ts +11 -0
  39. package/node_modules/express-rate-limit/dist/index.mjs +6 -3
  40. package/node_modules/express-rate-limit/{license.md → license} +7 -6
  41. package/node_modules/express-rate-limit/package.json +5 -5
  42. package/node_modules/express-rate-limit/readme.md +1 -0
  43. package/node_modules/fast-uri/index.js +20 -5
  44. package/node_modules/fast-uri/lib/utils.js +8 -1
  45. package/node_modules/fast-uri/package.json +1 -1
  46. package/node_modules/fast-uri/test/component-safe-serialization.test.js +58 -0
  47. package/node_modules/fast-uri/test/ipv6-validation.test.js +34 -0
  48. package/node_modules/ip-address/README.md +92 -82
  49. package/node_modules/ip-address/dist/common.d.ts +20 -0
  50. package/node_modules/ip-address/dist/common.js +36 -0
  51. package/node_modules/ip-address/dist/common.js.map +1 -1
  52. package/node_modules/ip-address/dist/ipv4.d.ts +50 -0
  53. package/node_modules/ip-address/dist/ipv4.js +75 -0
  54. package/node_modules/ip-address/dist/ipv4.js.map +1 -1
  55. package/node_modules/ip-address/dist/ipv6.d.ts +79 -10
  56. package/node_modules/ip-address/dist/ipv6.js +120 -30
  57. package/node_modules/ip-address/dist/ipv6.js.map +1 -1
  58. package/node_modules/ip-address/dist/v4/constants.d.ts +12 -0
  59. package/node_modules/ip-address/dist/v4/constants.js +40 -1
  60. package/node_modules/ip-address/dist/v4/constants.js.map +1 -1
  61. package/node_modules/ip-address/dist/v6/constants.d.ts +14 -0
  62. package/node_modules/ip-address/dist/v6/constants.js +47 -1
  63. package/node_modules/ip-address/dist/v6/constants.js.map +1 -1
  64. package/node_modules/ip-address/package.json +1 -1
  65. package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +7 -16
  66. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +6 -17
  67. package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +7 -16
  68. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +11 -34
  69. package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +7 -16
  70. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +15 -35
  71. package/node_modules/jose/dist/types/jwk/embedded.d.ts +3 -8
  72. package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +5 -5
  73. package/node_modules/jose/dist/types/jwks/local.d.ts +6 -10
  74. package/node_modules/jose/dist/types/jwks/remote.d.ts +13 -24
  75. package/node_modules/jose/dist/types/jws/compact/sign.d.ts +5 -10
  76. package/node_modules/jose/dist/types/jws/compact/verify.d.ts +9 -18
  77. package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +7 -16
  78. package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +9 -18
  79. package/node_modules/jose/dist/types/jws/general/sign.d.ts +11 -21
  80. package/node_modules/jose/dist/types/jws/general/verify.d.ts +9 -18
  81. package/node_modules/jose/dist/types/jwt/decrypt.d.ts +10 -20
  82. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +6 -13
  83. package/node_modules/jose/dist/types/jwt/sign.d.ts +5 -6
  84. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +9 -14
  85. package/node_modules/jose/dist/types/jwt/verify.d.ts +9 -19
  86. package/node_modules/jose/dist/types/key/export.d.ts +4 -4
  87. package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +6 -8
  88. package/node_modules/jose/dist/types/key/generate_secret.d.ts +4 -11
  89. package/node_modules/jose/dist/types/key/import.d.ts +10 -17
  90. package/node_modules/jose/dist/types/types.d.ts +44 -84
  91. package/node_modules/jose/dist/types/util/base64url.d.ts +2 -2
  92. package/node_modules/jose/dist/types/util/decode_jwt.d.ts +3 -10
  93. package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +4 -4
  94. package/node_modules/jose/dist/types/util/errors.d.ts +26 -53
  95. package/node_modules/jose/dist/webapi/index.js +70 -32
  96. package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +7 -8
  97. package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +42 -48
  98. package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +14 -14
  99. package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +53 -64
  100. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +38 -49
  101. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +121 -169
  102. package/node_modules/jose/dist/webapi/jwk/embedded.js +30 -32
  103. package/node_modules/jose/dist/webapi/jwk/thumbprint.js +54 -70
  104. package/node_modules/jose/dist/webapi/jwks/local.js +47 -64
  105. package/node_modules/jose/dist/webapi/jwks/remote.js +88 -136
  106. package/node_modules/jose/dist/webapi/jws/compact/sign.js +21 -21
  107. package/node_modules/jose/dist/webapi/jws/compact/verify.js +7 -8
  108. package/node_modules/jose/dist/webapi/jws/flattened/sign.js +29 -31
  109. package/node_modules/jose/dist/webapi/jws/flattened/verify.js +21 -24
  110. package/node_modules/jose/dist/webapi/jws/general/sign.js +61 -72
  111. package/node_modules/jose/dist/webapi/jws/general/verify.js +45 -69
  112. package/node_modules/jose/dist/webapi/jwt/decrypt.js +13 -20
  113. package/node_modules/jose/dist/webapi/jwt/encrypt.js +57 -70
  114. package/node_modules/jose/dist/webapi/jwt/sign.js +17 -16
  115. package/node_modules/jose/dist/webapi/jwt/unsecured.js +32 -40
  116. package/node_modules/jose/dist/webapi/jwt/verify.js +12 -14
  117. package/node_modules/jose/dist/webapi/key/export.js +32 -37
  118. package/node_modules/jose/dist/webapi/key/generate_key_pair.js +40 -48
  119. package/node_modules/jose/dist/webapi/key/generate_secret.js +35 -40
  120. package/node_modules/jose/dist/webapi/key/import.js +52 -56
  121. package/node_modules/jose/dist/webapi/lib/asn1.js +130 -169
  122. package/node_modules/jose/dist/webapi/lib/base64.js +18 -20
  123. package/node_modules/jose/dist/webapi/lib/buffer_utils.js +34 -38
  124. package/node_modules/jose/dist/webapi/lib/content_encryption.js +79 -115
  125. package/node_modules/jose/dist/webapi/lib/crypto_key.js +24 -25
  126. package/node_modules/jose/dist/webapi/lib/deflate.js +45 -47
  127. package/node_modules/jose/dist/webapi/lib/helpers.js +40 -37
  128. package/node_modules/jose/dist/webapi/lib/invalid_key_input.js +10 -24
  129. package/node_modules/jose/dist/webapi/lib/is_key_like.js +17 -15
  130. package/node_modules/jose/dist/webapi/lib/jwe_algorithms.js +106 -93
  131. package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +207 -230
  132. package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +104 -138
  133. package/node_modules/jose/dist/webapi/lib/jwk_metadata.js +17 -18
  134. package/node_modules/jose/dist/webapi/lib/jwk_to_key.js +9 -16
  135. package/node_modules/jose/dist/webapi/lib/jws_algorithms.js +62 -61
  136. package/node_modules/jose/dist/webapi/lib/jws_sign.js +50 -75
  137. package/node_modules/jose/dist/webapi/lib/jws_verify.js +80 -125
  138. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +123 -209
  139. package/node_modules/jose/dist/webapi/lib/key.js +84 -136
  140. package/node_modules/jose/dist/webapi/lib/key_algorithm.js +13 -8
  141. package/node_modules/jose/dist/webapi/lib/key_descriptor.js +8 -6
  142. package/node_modules/jose/dist/webapi/lib/key_management.js +200 -231
  143. package/node_modules/jose/dist/webapi/lib/key_options.js +7 -5
  144. package/node_modules/jose/dist/webapi/lib/options.js +55 -68
  145. package/node_modules/jose/dist/webapi/lib/signing.js +18 -22
  146. package/node_modules/jose/dist/webapi/lib/type_checks.js +26 -29
  147. package/node_modules/jose/dist/webapi/util/base64url.js +26 -35
  148. package/node_modules/jose/dist/webapi/util/decode_jwt.js +32 -31
  149. package/node_modules/jose/dist/webapi/util/decode_protected_header.js +18 -23
  150. package/node_modules/jose/dist/webapi/util/errors.js +94 -84
  151. package/node_modules/jose/package.json +17 -81
  152. package/package.json +2 -2
  153. package/profiles/calendar/0.5.profile.json +190 -0
  154. package/profiles/charge/0.5.profile.json +210 -0
  155. package/profiles/customers/0.7.profile.json +157 -0
  156. package/profiles/deploy/0.9.profile.json +176 -0
  157. package/profiles/email/0.6.profile.json +208 -0
  158. package/profiles/index.json +9 -1
  159. package/profiles/publish/0.5.profile.json +186 -0
  160. package/profiles/purchase/0.5.profile.json +231 -0
  161. package/profiles/records/0.5.profile.json +117 -0
@@ -1,4 +1,4 @@
1
- var tp=Object.defineProperty;var np=(e,t,n)=>t in e?tp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Wa=(e,t,n)=>np(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 ru={exports:{}},ba={},su={exports:{}},re={};/**
1
+ var np=Object.defineProperty;var rp=(e,t,n)=>t in e?np(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var vr=(e,t,n)=>rp(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 nu={exports:{}},Ca={},ru={exports:{}},re={};/**
2
2
  * @license React
3
3
  * react.production.min.js
4
4
  *
@@ -6,7 +6,7 @@ var tp=Object.defineProperty;var np=(e,t,n)=>t in e?tp(e,t,{enumerable:!0,config
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var is=Symbol.for("react.element"),rp=Symbol.for("react.portal"),sp=Symbol.for("react.fragment"),ap=Symbol.for("react.strict_mode"),op=Symbol.for("react.profiler"),ip=Symbol.for("react.provider"),lp=Symbol.for("react.context"),cp=Symbol.for("react.forward_ref"),up=Symbol.for("react.suspense"),dp=Symbol.for("react.memo"),fp=Symbol.for("react.lazy"),zl=Symbol.iterator;function pp(e){return e===null||typeof e!="object"?null:(e=zl&&e[zl]||e["@@iterator"],typeof e=="function"?e:null)}var au={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ou=Object.assign,iu={};function fr(e,t,n){this.props=e,this.context=t,this.refs=iu,this.updater=n||au}fr.prototype.isReactComponent={};fr.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")};fr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function lu(){}lu.prototype=fr.prototype;function Ci(e,t,n){this.props=e,this.context=t,this.refs=iu,this.updater=n||au}var Ni=Ci.prototype=new lu;Ni.constructor=Ci;ou(Ni,fr.prototype);Ni.isPureReactComponent=!0;var Il=Array.isArray,cu=Object.prototype.hasOwnProperty,Ei={current:null},uu={key:!0,ref:!0,__self:!0,__source:!0};function du(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)cu.call(t,r)&&!uu.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:is,type:e,key:o,ref:i,props:s,_owner:Ei.current}}function mp(e,t){return{$$typeof:is,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Ti(e){return typeof e=="object"&&e!==null&&e.$$typeof===is}function hp(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Rl=/\/+/g;function Ha(e,t){return typeof e=="object"&&e!==null&&e.key!=null?hp(""+e.key):t.toString(36)}function Ls(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 is:case rp:i=!0}}if(i)return i=e,s=s(i),e=r===""?"."+Ha(i,0):r,Il(s)?(n="",e!=null&&(n=e.replace(Rl,"$&/")+"/"),Ls(s,t,n,"",function(d){return d})):s!=null&&(Ti(s)&&(s=mp(s,n+(!s.key||i&&i.key===s.key?"":(""+s.key).replace(Rl,"$&/")+"/")+e)),t.push(s)),1;if(i=0,r=r===""?".":r+":",Il(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+Ha(o,l);i+=Ls(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+Ha(o,l++),i+=Ls(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 ms(e,t,n){if(e==null)return e;var r=[],s=0;return Ls(e,r,"","",function(o){return t.call(n,o,s++)}),r}function gp(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 Xe={current:null},Ms={transition:null},yp={ReactCurrentDispatcher:Xe,ReactCurrentBatchConfig:Ms,ReactCurrentOwner:Ei};function fu(){throw Error("act(...) is not supported in production builds of React.")}re.Children={map:ms,forEach:function(e,t,n){ms(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ms(e,function(){t++}),t},toArray:function(e){return ms(e,function(t){return t})||[]},only:function(e){if(!Ti(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};re.Component=fr;re.Fragment=sp;re.Profiler=op;re.PureComponent=Ci;re.StrictMode=ap;re.Suspense=up;re.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=yp;re.act=fu;re.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=ou({},e.props),s=e.key,o=e.ref,i=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,i=Ei.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)cu.call(t,c)&&!uu.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:is,type:e.type,key:s,ref:o,props:r,_owner:i}};re.createContext=function(e){return e={$$typeof:lp,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:ip,_context:e},e.Consumer=e};re.createElement=du;re.createFactory=function(e){var t=du.bind(null,e);return t.type=e,t};re.createRef=function(){return{current:null}};re.forwardRef=function(e){return{$$typeof:cp,render:e}};re.isValidElement=Ti;re.lazy=function(e){return{$$typeof:fp,_payload:{_status:-1,_result:e},_init:gp}};re.memo=function(e,t){return{$$typeof:dp,type:e,compare:t===void 0?null:t}};re.startTransition=function(e){var t=Ms.transition;Ms.transition={};try{e()}finally{Ms.transition=t}};re.unstable_act=fu;re.useCallback=function(e,t){return Xe.current.useCallback(e,t)};re.useContext=function(e){return Xe.current.useContext(e)};re.useDebugValue=function(){};re.useDeferredValue=function(e){return Xe.current.useDeferredValue(e)};re.useEffect=function(e,t){return Xe.current.useEffect(e,t)};re.useId=function(){return Xe.current.useId()};re.useImperativeHandle=function(e,t,n){return Xe.current.useImperativeHandle(e,t,n)};re.useInsertionEffect=function(e,t){return Xe.current.useInsertionEffect(e,t)};re.useLayoutEffect=function(e,t){return Xe.current.useLayoutEffect(e,t)};re.useMemo=function(e,t){return Xe.current.useMemo(e,t)};re.useReducer=function(e,t,n){return Xe.current.useReducer(e,t,n)};re.useRef=function(e){return Xe.current.useRef(e)};re.useState=function(e){return Xe.current.useState(e)};re.useSyncExternalStore=function(e,t,n){return Xe.current.useSyncExternalStore(e,t,n)};re.useTransition=function(){return Xe.current.useTransition()};re.version="18.3.1";su.exports=re;var u=su.exports;/**
9
+ */var ls=Symbol.for("react.element"),sp=Symbol.for("react.portal"),ap=Symbol.for("react.fragment"),op=Symbol.for("react.strict_mode"),ip=Symbol.for("react.profiler"),lp=Symbol.for("react.provider"),cp=Symbol.for("react.context"),up=Symbol.for("react.forward_ref"),dp=Symbol.for("react.suspense"),fp=Symbol.for("react.memo"),pp=Symbol.for("react.lazy"),Tl=Symbol.iterator;function mp(e){return e===null||typeof e!="object"?null:(e=Tl&&e[Tl]||e["@@iterator"],typeof e=="function"?e:null)}var su={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},au=Object.assign,ou={};function fr(e,t,n){this.props=e,this.context=t,this.refs=ou,this.updater=n||su}fr.prototype.isReactComponent={};fr.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")};fr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function iu(){}iu.prototype=fr.prototype;function bi(e,t,n){this.props=e,this.context=t,this.refs=ou,this.updater=n||su}var Ci=bi.prototype=new iu;Ci.constructor=bi;au(Ci,fr.prototype);Ci.isPureReactComponent=!0;var zl=Array.isArray,lu=Object.prototype.hasOwnProperty,Ni={current:null},cu={key:!0,ref:!0,__self:!0,__source:!0};function uu(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)lu.call(t,r)&&!cu.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:ls,type:e,key:o,ref:i,props:s,_owner:Ni.current}}function hp(e,t){return{$$typeof:ls,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Ei(e){return typeof e=="object"&&e!==null&&e.$$typeof===ls}function gp(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Il=/\/+/g;function Ha(e,t){return typeof e=="object"&&e!==null&&e.key!=null?gp(""+e.key):t.toString(36)}function Ms(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 ls:case sp:i=!0}}if(i)return i=e,s=s(i),e=r===""?"."+Ha(i,0):r,zl(s)?(n="",e!=null&&(n=e.replace(Il,"$&/")+"/"),Ms(s,t,n,"",function(d){return d})):s!=null&&(Ei(s)&&(s=hp(s,n+(!s.key||i&&i.key===s.key?"":(""+s.key).replace(Il,"$&/")+"/")+e)),t.push(s)),1;if(i=0,r=r===""?".":r+":",zl(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+Ha(o,l);i+=Ms(o,t,n,c,s)}else if(c=mp(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+Ha(o,l++),i+=Ms(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 hs(e,t,n){if(e==null)return e;var r=[],s=0;return Ms(e,r,"","",function(o){return t.call(n,o,s++)}),r}function yp(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 Xe={current:null},Fs={transition:null},vp={ReactCurrentDispatcher:Xe,ReactCurrentBatchConfig:Fs,ReactCurrentOwner:Ni};function du(){throw Error("act(...) is not supported in production builds of React.")}re.Children={map:hs,forEach:function(e,t,n){hs(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return hs(e,function(){t++}),t},toArray:function(e){return hs(e,function(t){return t})||[]},only:function(e){if(!Ei(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};re.Component=fr;re.Fragment=ap;re.Profiler=ip;re.PureComponent=bi;re.StrictMode=op;re.Suspense=dp;re.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=vp;re.act=du;re.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=au({},e.props),s=e.key,o=e.ref,i=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,i=Ni.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)lu.call(t,c)&&!cu.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:ls,type:e.type,key:s,ref:o,props:r,_owner:i}};re.createContext=function(e){return e={$$typeof:cp,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:lp,_context:e},e.Consumer=e};re.createElement=uu;re.createFactory=function(e){var t=uu.bind(null,e);return t.type=e,t};re.createRef=function(){return{current:null}};re.forwardRef=function(e){return{$$typeof:up,render:e}};re.isValidElement=Ei;re.lazy=function(e){return{$$typeof:pp,_payload:{_status:-1,_result:e},_init:yp}};re.memo=function(e,t){return{$$typeof:fp,type:e,compare:t===void 0?null:t}};re.startTransition=function(e){var t=Fs.transition;Fs.transition={};try{e()}finally{Fs.transition=t}};re.unstable_act=du;re.useCallback=function(e,t){return Xe.current.useCallback(e,t)};re.useContext=function(e){return Xe.current.useContext(e)};re.useDebugValue=function(){};re.useDeferredValue=function(e){return Xe.current.useDeferredValue(e)};re.useEffect=function(e,t){return Xe.current.useEffect(e,t)};re.useId=function(){return Xe.current.useId()};re.useImperativeHandle=function(e,t,n){return Xe.current.useImperativeHandle(e,t,n)};re.useInsertionEffect=function(e,t){return Xe.current.useInsertionEffect(e,t)};re.useLayoutEffect=function(e,t){return Xe.current.useLayoutEffect(e,t)};re.useMemo=function(e,t){return Xe.current.useMemo(e,t)};re.useReducer=function(e,t,n){return Xe.current.useReducer(e,t,n)};re.useRef=function(e){return Xe.current.useRef(e)};re.useState=function(e){return Xe.current.useState(e)};re.useSyncExternalStore=function(e,t,n){return Xe.current.useSyncExternalStore(e,t,n)};re.useTransition=function(){return Xe.current.useTransition()};re.version="18.3.1";ru.exports=re;var u=ru.exports;/**
10
10
  * @license React
11
11
  * react-jsx-runtime.production.min.js
12
12
  *
@@ -14,7 +14,7 @@ var tp=Object.defineProperty;var np=(e,t,n)=>t in e?tp(e,t,{enumerable:!0,config
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var vp=u,xp=Symbol.for("react.element"),wp=Symbol.for("react.fragment"),Sp=Object.prototype.hasOwnProperty,jp=vp.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,kp={key:!0,ref:!0,__self:!0,__source:!0};function pu(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)Sp.call(t,r)&&!kp.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:xp,type:e,key:o,ref:i,props:s,_owner:jp.current}}ba.Fragment=wp;ba.jsx=pu;ba.jsxs=pu;ru.exports=ba;var a=ru.exports,mu={exports:{}},ft={},hu={exports:{}},gu={};/**
17
+ */var xp=u,wp=Symbol.for("react.element"),Sp=Symbol.for("react.fragment"),jp=Object.prototype.hasOwnProperty,kp=xp.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,bp={key:!0,ref:!0,__self:!0,__source:!0};function fu(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)jp.call(t,r)&&!bp.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:wp,type:e,key:o,ref:i,props:s,_owner:kp.current}}Ca.Fragment=Sp;Ca.jsx=fu;Ca.jsxs=fu;nu.exports=Ca;var a=nu.exports,pu={exports:{}},ft={},mu={exports:{}},hu={};/**
18
18
  * @license React
19
19
  * scheduler.production.min.js
20
20
  *
@@ -22,7 +22,7 @@ var tp=Object.defineProperty;var np=(e,t,n)=>t in e?tp(e,t,{enumerable:!0,config
22
22
  *
23
23
  * This source code is licensed under the MIT license found in the
24
24
  * LICENSE file in the root directory of this source tree.
25
- */(function(e){function t(F,L){var H=F.length;F.push(L);e:for(;0<H;){var A=H-1>>>1,U=F[A];if(0<s(U,L))F[A]=L,F[H]=U,H=A;else break e}}function n(F){return F.length===0?null:F[0]}function r(F){if(F.length===0)return null;var L=F[0],H=F.pop();if(H!==L){F[0]=H;e:for(var A=0,U=F.length,O=U>>>1;A<O;){var G=2*(A+1)-1,X=F[G],Z=G+1,de=F[Z];if(0>s(X,H))Z<U&&0>s(de,X)?(F[A]=de,F[Z]=H,A=Z):(F[A]=X,F[G]=H,A=G);else if(Z<U&&0>s(de,H))F[A]=de,F[Z]=H,A=Z;else break e}}return L}function s(F,L){var H=F.sortIndex-L.sortIndex;return H!==0?H:F.id-L.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,m=null,p=3,x=!1,w=!1,v=!1,j=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(F){for(var L=n(d);L!==null;){if(L.callback===null)r(d);else if(L.startTime<=F)r(d),L.sortIndex=L.expirationTime,t(c,L);else break;L=n(d)}}function S(F){if(v=!1,y(F),!w)if(n(c)!==null)w=!0,q(k);else{var L=n(d);L!==null&&ee(S,L.startTime-F)}}function k(F,L){w=!1,v&&(v=!1,h(_),_=-1),x=!0;var H=p;try{for(y(L),m=n(c);m!==null&&(!(m.expirationTime>L)||F&&!D());){var A=m.callback;if(typeof A=="function"){m.callback=null,p=m.priorityLevel;var U=A(m.expirationTime<=L);L=e.unstable_now(),typeof U=="function"?m.callback=U:m===n(c)&&r(c),y(L)}else r(c);m=n(c)}if(m!==null)var O=!0;else{var G=n(d);G!==null&&ee(S,G.startTime-L),O=!1}return O}finally{m=null,p=H,x=!1}}var I=!1,R=null,_=-1,C=5,z=-1;function D(){return!(e.unstable_now()-z<C)}function Y(){if(R!==null){var F=e.unstable_now();z=F;var L=!0;try{L=R(!0,F)}finally{L?K():(I=!1,R=null)}}else I=!1}var K;if(typeof g=="function")K=function(){g(Y)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,T=W.port2;W.port1.onmessage=Y,K=function(){T.postMessage(null)}}else K=function(){j(Y,0)};function q(F){R=F,I||(I=!0,K())}function ee(F,L){_=j(function(){F(e.unstable_now())},L)}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(F){F.callback=null},e.unstable_continueExecution=function(){w||x||(w=!0,q(k))},e.unstable_forceFrameRate=function(F){0>F||125<F?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):C=0<F?Math.floor(1e3/F):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(F){switch(p){case 1:case 2:case 3:var L=3;break;default:L=p}var H=p;p=L;try{return F()}finally{p=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(F,L){switch(F){case 1:case 2:case 3:case 4:case 5:break;default:F=3}var H=p;p=F;try{return L()}finally{p=H}},e.unstable_scheduleCallback=function(F,L,H){var A=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?A+H:A):H=A,F){case 1:var U=-1;break;case 2:U=250;break;case 5:U=1073741823;break;case 4:U=1e4;break;default:U=5e3}return U=H+U,F={id:f++,callback:L,priorityLevel:F,startTime:H,expirationTime:U,sortIndex:-1},H>A?(F.sortIndex=H,t(d,F),n(c)===null&&F===n(d)&&(v?(h(_),_=-1):v=!0,ee(S,H-A))):(F.sortIndex=U,t(c,F),w||x||(w=!0,q(k))),F},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(F){var L=p;return function(){var H=p;p=L;try{return F.apply(this,arguments)}finally{p=H}}}})(gu);hu.exports=gu;var bp=hu.exports;/**
25
+ */(function(e){function t(F,L){var H=F.length;F.push(L);e:for(;0<H;){var A=H-1>>>1,U=F[A];if(0<s(U,L))F[A]=L,F[H]=U,H=A;else break e}}function n(F){return F.length===0?null:F[0]}function r(F){if(F.length===0)return null;var L=F[0],H=F.pop();if(H!==L){F[0]=H;e:for(var A=0,U=F.length,O=U>>>1;A<O;){var G=2*(A+1)-1,X=F[G],Z=G+1,de=F[Z];if(0>s(X,H))Z<U&&0>s(de,X)?(F[A]=de,F[Z]=H,A=Z):(F[A]=X,F[G]=H,A=G);else if(Z<U&&0>s(de,H))F[A]=de,F[Z]=H,A=Z;else break e}}return L}function s(F,L){var H=F.sortIndex-L.sortIndex;return H!==0?H:F.id-L.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,m=null,p=3,x=!1,w=!1,v=!1,j=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(F){for(var L=n(d);L!==null;){if(L.callback===null)r(d);else if(L.startTime<=F)r(d),L.sortIndex=L.expirationTime,t(c,L);else break;L=n(d)}}function S(F){if(v=!1,y(F),!w)if(n(c)!==null)w=!0,q(k);else{var L=n(d);L!==null&&ee(S,L.startTime-F)}}function k(F,L){w=!1,v&&(v=!1,h(_),_=-1),x=!0;var H=p;try{for(y(L),m=n(c);m!==null&&(!(m.expirationTime>L)||F&&!D());){var A=m.callback;if(typeof A=="function"){m.callback=null,p=m.priorityLevel;var U=A(m.expirationTime<=L);L=e.unstable_now(),typeof U=="function"?m.callback=U:m===n(c)&&r(c),y(L)}else r(c);m=n(c)}if(m!==null)var O=!0;else{var G=n(d);G!==null&&ee(S,G.startTime-L),O=!1}return O}finally{m=null,p=H,x=!1}}var I=!1,R=null,_=-1,C=5,z=-1;function D(){return!(e.unstable_now()-z<C)}function Y(){if(R!==null){var F=e.unstable_now();z=F;var L=!0;try{L=R(!0,F)}finally{L?K():(I=!1,R=null)}}else I=!1}var K;if(typeof g=="function")K=function(){g(Y)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,T=W.port2;W.port1.onmessage=Y,K=function(){T.postMessage(null)}}else K=function(){j(Y,0)};function q(F){R=F,I||(I=!0,K())}function ee(F,L){_=j(function(){F(e.unstable_now())},L)}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(F){F.callback=null},e.unstable_continueExecution=function(){w||x||(w=!0,q(k))},e.unstable_forceFrameRate=function(F){0>F||125<F?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):C=0<F?Math.floor(1e3/F):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(F){switch(p){case 1:case 2:case 3:var L=3;break;default:L=p}var H=p;p=L;try{return F()}finally{p=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(F,L){switch(F){case 1:case 2:case 3:case 4:case 5:break;default:F=3}var H=p;p=F;try{return L()}finally{p=H}},e.unstable_scheduleCallback=function(F,L,H){var A=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?A+H:A):H=A,F){case 1:var U=-1;break;case 2:U=250;break;case 5:U=1073741823;break;case 4:U=1e4;break;default:U=5e3}return U=H+U,F={id:f++,callback:L,priorityLevel:F,startTime:H,expirationTime:U,sortIndex:-1},H>A?(F.sortIndex=H,t(d,F),n(c)===null&&F===n(d)&&(v?(h(_),_=-1):v=!0,ee(S,H-A))):(F.sortIndex=U,t(c,F),w||x||(w=!0,q(k))),F},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(F){var L=p;return function(){var H=p;p=L;try{return F.apply(this,arguments)}finally{p=H}}}})(hu);mu.exports=hu;var Cp=mu.exports;/**
26
26
  * @license React
27
27
  * react-dom.production.min.js
28
28
  *
@@ -30,14 +30,14 @@ var tp=Object.defineProperty;var np=(e,t,n)=>t in e?tp(e,t,{enumerable:!0,config
30
30
  *
31
31
  * This source code is licensed under the MIT license found in the
32
32
  * LICENSE file in the root directory of this source tree.
33
- */var Cp=u,dt=bp;function B(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 yu=new Set,Wr={};function Mn(e,t){ar(e,t),ar(e+"Capture",t)}function ar(e,t){for(Wr[e]=t,e=0;e<t.length;e++)yu.add(t[e])}var Gt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),bo=Object.prototype.hasOwnProperty,Np=/^[: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]*$/,Pl={},_l={};function Ep(e){return bo.call(_l,e)?!0:bo.call(Pl,e)?!1:Np.test(e)?_l[e]=!0:(Pl[e]=!0,!1)}function Tp(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 zp(e,t,n,r){if(t===null||typeof t>"u"||Tp(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 qe(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 Oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Oe[e]=new qe(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Oe[t]=new qe(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Oe[e]=new qe(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Oe[e]=new qe(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){Oe[e]=new qe(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Oe[e]=new qe(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Oe[e]=new qe(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Oe[e]=new qe(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Oe[e]=new qe(e,5,!1,e.toLowerCase(),null,!1,!1)});var zi=/[\-:]([a-z])/g;function Ii(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(zi,Ii);Oe[t]=new qe(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(zi,Ii);Oe[t]=new qe(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(zi,Ii);Oe[t]=new qe(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Oe[e]=new qe(e,1,!1,e.toLowerCase(),null,!1,!1)});Oe.xlinkHref=new qe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Oe[e]=new qe(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ri(e,t,n,r){var s=Oe.hasOwnProperty(t)?Oe[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(zp(t,n,s,r)&&(n=null),r||s===null?Ep(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 Xt=Cp.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,hs=Symbol.for("react.element"),Dn=Symbol.for("react.portal"),Un=Symbol.for("react.fragment"),Pi=Symbol.for("react.strict_mode"),Co=Symbol.for("react.profiler"),vu=Symbol.for("react.provider"),xu=Symbol.for("react.context"),_i=Symbol.for("react.forward_ref"),No=Symbol.for("react.suspense"),Eo=Symbol.for("react.suspense_list"),Ai=Symbol.for("react.memo"),en=Symbol.for("react.lazy"),wu=Symbol.for("react.offscreen"),Al=Symbol.iterator;function vr(e){return e===null||typeof e!="object"?null:(e=Al&&e[Al]||e["@@iterator"],typeof e=="function"?e:null)}var je=Object.assign,Va;function Tr(e){if(Va===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Va=t&&t[1]||""}return`
33
+ */var Np=u,dt=Cp;function B(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 gu=new Set,Hr={};function Mn(e,t){ar(e,t),ar(e+"Capture",t)}function ar(e,t){for(Hr[e]=t,e=0;e<t.length;e++)gu.add(t[e])}var Gt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),bo=Object.prototype.hasOwnProperty,Ep=/^[: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]*$/,Rl={},Pl={};function Tp(e){return bo.call(Pl,e)?!0:bo.call(Rl,e)?!1:Ep.test(e)?Pl[e]=!0:(Rl[e]=!0,!1)}function zp(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 Ip(e,t,n,r){if(t===null||typeof t>"u"||zp(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 qe(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 Oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Oe[e]=new qe(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Oe[t]=new qe(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Oe[e]=new qe(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Oe[e]=new qe(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){Oe[e]=new qe(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Oe[e]=new qe(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Oe[e]=new qe(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Oe[e]=new qe(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Oe[e]=new qe(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ti=/[\-:]([a-z])/g;function zi(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(Ti,zi);Oe[t]=new qe(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(Ti,zi);Oe[t]=new qe(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(Ti,zi);Oe[t]=new qe(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Oe[e]=new qe(e,1,!1,e.toLowerCase(),null,!1,!1)});Oe.xlinkHref=new qe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Oe[e]=new qe(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ii(e,t,n,r){var s=Oe.hasOwnProperty(t)?Oe[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(Ip(t,n,s,r)&&(n=null),r||s===null?Tp(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 Xt=Np.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,gs=Symbol.for("react.element"),Dn=Symbol.for("react.portal"),Un=Symbol.for("react.fragment"),Ri=Symbol.for("react.strict_mode"),Co=Symbol.for("react.profiler"),yu=Symbol.for("react.provider"),vu=Symbol.for("react.context"),Pi=Symbol.for("react.forward_ref"),No=Symbol.for("react.suspense"),Eo=Symbol.for("react.suspense_list"),_i=Symbol.for("react.memo"),en=Symbol.for("react.lazy"),xu=Symbol.for("react.offscreen"),_l=Symbol.iterator;function xr(e){return e===null||typeof e!="object"?null:(e=_l&&e[_l]||e["@@iterator"],typeof e=="function"?e:null)}var je=Object.assign,Va;function zr(e){if(Va===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Va=t&&t[1]||""}return`
34
34
  `+Va+e}var Ga=!1;function Ka(e,t){if(!e||Ga)return"";Ga=!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
35
  `),o=r.stack.split(`
36
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{Ga=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Tr(e):""}function Ip(e){switch(e.tag){case 5:return Tr(e.type);case 16:return Tr("Lazy");case 13:return Tr("Suspense");case 19:return Tr("SuspenseList");case 0:case 2:case 15:return e=Ka(e.type,!1),e;case 11:return e=Ka(e.type.render,!1),e;case 1:return e=Ka(e.type,!0),e;default:return""}}function To(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 Un:return"Fragment";case Dn:return"Portal";case Co:return"Profiler";case Pi:return"StrictMode";case No:return"Suspense";case Eo:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case xu:return(e.displayName||"Context")+".Consumer";case vu:return(e._context.displayName||"Context")+".Provider";case _i:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ai:return t=e.displayName||null,t!==null?t:To(e.type)||"Memo";case en:t=e._payload,e=e._init;try{return To(e(t))}catch{}}return null}function Rp(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 To(t);case 8:return t===Pi?"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 gn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Su(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Pp(e){var t=Su(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 gs(e){e._valueTracker||(e._valueTracker=Pp(e))}function ju(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Su(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Xs(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 zo(e,t){var n=t.checked;return je({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function $l(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=gn(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 ku(e,t){t=t.checked,t!=null&&Ri(e,"checked",t,!1)}function Io(e,t){ku(e,t);var n=gn(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")?Ro(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ro(e,t.type,gn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Ll(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 Ro(e,t,n){(t!=="number"||Xs(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var zr=Array.isArray;function Zn(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=""+gn(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 Po(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(B(91));return je({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Ml(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(B(92));if(zr(n)){if(1<n.length)throw Error(B(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:gn(n)}}function bu(e,t){var n=gn(t.value),r=gn(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 Fl(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Cu(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 _o(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Cu(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var ys,Nu=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(ys=ys||document.createElement("div"),ys.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=ys.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Hr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var _r={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},_p=["Webkit","ms","Moz","O"];Object.keys(_r).forEach(function(e){_p.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),_r[t]=_r[e]})});function Eu(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||_r.hasOwnProperty(e)&&_r[e]?(""+t).trim():t+"px"}function Tu(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=Eu(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Ap=je({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 Ao(e,t){if(t){if(Ap[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(B(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(B(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(B(61))}if(t.style!=null&&typeof t.style!="object")throw Error(B(62))}}function $o(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 Lo=null;function $i(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Mo=null,er=null,tr=null;function Ol(e){if(e=us(e)){if(typeof Mo!="function")throw Error(B(280));var t=e.stateNode;t&&(t=za(t),Mo(e.stateNode,e.type,t))}}function zu(e){er?tr?tr.push(e):tr=[e]:er=e}function Iu(){if(er){var e=er,t=tr;if(tr=er=null,Ol(e),t)for(e=0;e<t.length;e++)Ol(t[e])}}function Ru(e,t){return e(t)}function Pu(){}var Ya=!1;function _u(e,t,n){if(Ya)return e(t,n);Ya=!0;try{return Ru(e,t,n)}finally{Ya=!1,(er!==null||tr!==null)&&(Pu(),Iu())}}function Vr(e,t){var n=e.stateNode;if(n===null)return null;var r=za(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(B(231,t,typeof n));return n}var Fo=!1;if(Gt)try{var xr={};Object.defineProperty(xr,"passive",{get:function(){Fo=!0}}),window.addEventListener("test",xr,xr),window.removeEventListener("test",xr,xr)}catch{Fo=!1}function $p(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 Ar=!1,qs=null,Zs=!1,Oo=null,Lp={onError:function(e){Ar=!0,qs=e}};function Mp(e,t,n,r,s,o,i,l,c){Ar=!1,qs=null,$p.apply(Lp,arguments)}function Fp(e,t,n,r,s,o,i,l,c){if(Mp.apply(this,arguments),Ar){if(Ar){var d=qs;Ar=!1,qs=null}else throw Error(B(198));Zs||(Zs=!0,Oo=d)}}function Fn(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 Au(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 Bl(e){if(Fn(e)!==e)throw Error(B(188))}function Op(e){var t=e.alternate;if(!t){if(t=Fn(e),t===null)throw Error(B(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 Bl(s),e;if(o===r)return Bl(s),t;o=o.sibling}throw Error(B(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(B(189))}}if(n.alternate!==r)throw Error(B(190))}if(n.tag!==3)throw Error(B(188));return n.stateNode.current===n?e:t}function $u(e){return e=Op(e),e!==null?Lu(e):null}function Lu(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Lu(e);if(t!==null)return t;e=e.sibling}return null}var Mu=dt.unstable_scheduleCallback,Dl=dt.unstable_cancelCallback,Bp=dt.unstable_shouldYield,Dp=dt.unstable_requestPaint,be=dt.unstable_now,Up=dt.unstable_getCurrentPriorityLevel,Li=dt.unstable_ImmediatePriority,Fu=dt.unstable_UserBlockingPriority,ea=dt.unstable_NormalPriority,Wp=dt.unstable_LowPriority,Ou=dt.unstable_IdlePriority,Ca=null,Mt=null;function Hp(e){if(Mt&&typeof Mt.onCommitFiberRoot=="function")try{Mt.onCommitFiberRoot(Ca,e,void 0,(e.current.flags&128)===128)}catch{}}var Tt=Math.clz32?Math.clz32:Kp,Vp=Math.log,Gp=Math.LN2;function Kp(e){return e>>>=0,e===0?32:31-(Vp(e)/Gp|0)|0}var vs=64,xs=4194304;function Ir(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 ta(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=Ir(l):(o&=i,o!==0&&(r=Ir(o)))}else i=n&~s,i!==0?r=Ir(i):o!==0&&(r=Ir(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-Tt(t),s=1<<n,r|=e[n],t&=~s;return r}function Yp(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 Qp(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes;0<o;){var i=31-Tt(o),l=1<<i,c=s[i];c===-1?(!(l&n)||l&r)&&(s[i]=Yp(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function Bo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Bu(){var e=vs;return vs<<=1,!(vs&4194240)&&(vs=64),e}function Qa(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function ls(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Tt(t),e[t]=n}function Jp(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-Tt(n),o=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~o}}function Mi(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Tt(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var fe=0;function Du(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Uu,Fi,Wu,Hu,Vu,Do=!1,ws=[],ln=null,cn=null,un=null,Gr=new Map,Kr=new Map,rn=[],Xp="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 Ul(e,t){switch(e){case"focusin":case"focusout":ln=null;break;case"dragenter":case"dragleave":cn=null;break;case"mouseover":case"mouseout":un=null;break;case"pointerover":case"pointerout":Gr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Kr.delete(t.pointerId)}}function wr(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=us(t),t!==null&&Fi(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function qp(e,t,n,r,s){switch(t){case"focusin":return ln=wr(ln,e,t,n,r,s),!0;case"dragenter":return cn=wr(cn,e,t,n,r,s),!0;case"mouseover":return un=wr(un,e,t,n,r,s),!0;case"pointerover":var o=s.pointerId;return Gr.set(o,wr(Gr.get(o)||null,e,t,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,Kr.set(o,wr(Kr.get(o)||null,e,t,n,r,s)),!0}return!1}function Gu(e){var t=Nn(e.target);if(t!==null){var n=Fn(t);if(n!==null){if(t=n.tag,t===13){if(t=Au(n),t!==null){e.blockedOn=t,Vu(e.priority,function(){Wu(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 Fs(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Uo(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Lo=r,n.target.dispatchEvent(r),Lo=null}else return t=us(n),t!==null&&Fi(t),e.blockedOn=n,!1;t.shift()}return!0}function Wl(e,t,n){Fs(e)&&n.delete(t)}function Zp(){Do=!1,ln!==null&&Fs(ln)&&(ln=null),cn!==null&&Fs(cn)&&(cn=null),un!==null&&Fs(un)&&(un=null),Gr.forEach(Wl),Kr.forEach(Wl)}function Sr(e,t){e.blockedOn===t&&(e.blockedOn=null,Do||(Do=!0,dt.unstable_scheduleCallback(dt.unstable_NormalPriority,Zp)))}function Yr(e){function t(s){return Sr(s,e)}if(0<ws.length){Sr(ws[0],e);for(var n=1;n<ws.length;n++){var r=ws[n];r.blockedOn===e&&(r.blockedOn=null)}}for(ln!==null&&Sr(ln,e),cn!==null&&Sr(cn,e),un!==null&&Sr(un,e),Gr.forEach(t),Kr.forEach(t),n=0;n<rn.length;n++)r=rn[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<rn.length&&(n=rn[0],n.blockedOn===null);)Gu(n),n.blockedOn===null&&rn.shift()}var nr=Xt.ReactCurrentBatchConfig,na=!0;function em(e,t,n,r){var s=fe,o=nr.transition;nr.transition=null;try{fe=1,Oi(e,t,n,r)}finally{fe=s,nr.transition=o}}function tm(e,t,n,r){var s=fe,o=nr.transition;nr.transition=null;try{fe=4,Oi(e,t,n,r)}finally{fe=s,nr.transition=o}}function Oi(e,t,n,r){if(na){var s=Uo(e,t,n,r);if(s===null)ao(e,t,r,ra,n),Ul(e,r);else if(qp(s,e,t,n,r))r.stopPropagation();else if(Ul(e,r),t&4&&-1<Xp.indexOf(e)){for(;s!==null;){var o=us(s);if(o!==null&&Uu(o),o=Uo(e,t,n,r),o===null&&ao(e,t,r,ra,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else ao(e,t,r,null,n)}}var ra=null;function Uo(e,t,n,r){if(ra=null,e=$i(r),e=Nn(e),e!==null)if(t=Fn(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Au(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 ra=e,null}function Ku(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(Up()){case Li:return 1;case Fu:return 4;case ea:case Wp:return 16;case Ou:return 536870912;default:return 16}default:return 16}}var an=null,Bi=null,Os=null;function Yu(){if(Os)return Os;var e,t=Bi,n=t.length,r,s="value"in an?an.value:an.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 Os=s.slice(e,1<r?1-r:void 0)}function Bs(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 Ss(){return!0}function Hl(){return!1}function pt(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)?Ss:Hl,this.isPropagationStopped=Hl,this}return je(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=Ss)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Ss)},persist:function(){},isPersistent:Ss}),t}var pr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Di=pt(pr),cs=je({},pr,{view:0,detail:0}),nm=pt(cs),Ja,Xa,jr,Na=je({},cs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ui,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==jr&&(jr&&e.type==="mousemove"?(Ja=e.screenX-jr.screenX,Xa=e.screenY-jr.screenY):Xa=Ja=0,jr=e),Ja)},movementY:function(e){return"movementY"in e?e.movementY:Xa}}),Vl=pt(Na),rm=je({},Na,{dataTransfer:0}),sm=pt(rm),am=je({},cs,{relatedTarget:0}),qa=pt(am),om=je({},pr,{animationName:0,elapsedTime:0,pseudoElement:0}),im=pt(om),lm=je({},pr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),cm=pt(lm),um=je({},pr,{data:0}),Gl=pt(um),dm={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},fm={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"},pm={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mm(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=pm[e])?!!t[e]:!1}function Ui(){return mm}var hm=je({},cs,{key:function(e){if(e.key){var t=dm[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Bs(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?fm[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ui,charCode:function(e){return e.type==="keypress"?Bs(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Bs(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),gm=pt(hm),ym=je({},Na,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Kl=pt(ym),vm=je({},cs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ui}),xm=pt(vm),wm=je({},pr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Sm=pt(wm),jm=je({},Na,{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}),km=pt(jm),bm=[9,13,27,32],Wi=Gt&&"CompositionEvent"in window,$r=null;Gt&&"documentMode"in document&&($r=document.documentMode);var Cm=Gt&&"TextEvent"in window&&!$r,Qu=Gt&&(!Wi||$r&&8<$r&&11>=$r),Yl=" ",Ql=!1;function Ju(e,t){switch(e){case"keyup":return bm.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Xu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Wn=!1;function Nm(e,t){switch(e){case"compositionend":return Xu(t);case"keypress":return t.which!==32?null:(Ql=!0,Yl);case"textInput":return e=t.data,e===Yl&&Ql?null:e;default:return null}}function Em(e,t){if(Wn)return e==="compositionend"||!Wi&&Ju(e,t)?(e=Yu(),Os=Bi=an=null,Wn=!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 Qu&&t.locale!=="ko"?null:t.data;default:return null}}var Tm={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 Jl(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Tm[e.type]:t==="textarea"}function qu(e,t,n,r){zu(r),t=sa(t,"onChange"),0<t.length&&(n=new Di("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Lr=null,Qr=null;function zm(e){cd(e,0)}function Ea(e){var t=Gn(e);if(ju(t))return e}function Im(e,t){if(e==="change")return t}var Zu=!1;if(Gt){var Za;if(Gt){var eo="oninput"in document;if(!eo){var Xl=document.createElement("div");Xl.setAttribute("oninput","return;"),eo=typeof Xl.oninput=="function"}Za=eo}else Za=!1;Zu=Za&&(!document.documentMode||9<document.documentMode)}function ql(){Lr&&(Lr.detachEvent("onpropertychange",ed),Qr=Lr=null)}function ed(e){if(e.propertyName==="value"&&Ea(Qr)){var t=[];qu(t,Qr,e,$i(e)),_u(zm,t)}}function Rm(e,t,n){e==="focusin"?(ql(),Lr=t,Qr=n,Lr.attachEvent("onpropertychange",ed)):e==="focusout"&&ql()}function Pm(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ea(Qr)}function _m(e,t){if(e==="click")return Ea(t)}function Am(e,t){if(e==="input"||e==="change")return Ea(t)}function $m(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var It=typeof Object.is=="function"?Object.is:$m;function Jr(e,t){if(It(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(!bo.call(t,s)||!It(e[s],t[s]))return!1}return!0}function Zl(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ec(e,t){var n=Zl(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=Zl(n)}}function td(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?td(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function nd(){for(var e=window,t=Xs();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Xs(e.document)}return t}function Hi(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 Lm(e){var t=nd(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&td(n.ownerDocument.documentElement,n)){if(r!==null&&Hi(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=ec(n,o);var i=ec(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 Mm=Gt&&"documentMode"in document&&11>=document.documentMode,Hn=null,Wo=null,Mr=null,Ho=!1;function tc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ho||Hn==null||Hn!==Xs(r)||(r=Hn,"selectionStart"in r&&Hi(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}),Mr&&Jr(Mr,r)||(Mr=r,r=sa(Wo,"onSelect"),0<r.length&&(t=new Di("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Hn)))}function js(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Vn={animationend:js("Animation","AnimationEnd"),animationiteration:js("Animation","AnimationIteration"),animationstart:js("Animation","AnimationStart"),transitionend:js("Transition","TransitionEnd")},to={},rd={};Gt&&(rd=document.createElement("div").style,"AnimationEvent"in window||(delete Vn.animationend.animation,delete Vn.animationiteration.animation,delete Vn.animationstart.animation),"TransitionEvent"in window||delete Vn.transitionend.transition);function Ta(e){if(to[e])return to[e];if(!Vn[e])return e;var t=Vn[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in rd)return to[e]=t[n];return e}var sd=Ta("animationend"),ad=Ta("animationiteration"),od=Ta("animationstart"),id=Ta("transitionend"),ld=new Map,nc="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 vn(e,t){ld.set(e,t),Mn(t,[e])}for(var no=0;no<nc.length;no++){var ro=nc[no],Fm=ro.toLowerCase(),Om=ro[0].toUpperCase()+ro.slice(1);vn(Fm,"on"+Om)}vn(sd,"onAnimationEnd");vn(ad,"onAnimationIteration");vn(od,"onAnimationStart");vn("dblclick","onDoubleClick");vn("focusin","onFocus");vn("focusout","onBlur");vn(id,"onTransitionEnd");ar("onMouseEnter",["mouseout","mouseover"]);ar("onMouseLeave",["mouseout","mouseover"]);ar("onPointerEnter",["pointerout","pointerover"]);ar("onPointerLeave",["pointerout","pointerover"]);Mn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Mn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Mn("onBeforeInput",["compositionend","keypress","textInput","paste"]);Mn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Mn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Mn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Rr="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(" "),Bm=new Set("cancel close invalid load scroll toggle".split(" ").concat(Rr));function rc(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,Fp(r,t,void 0,e),e.currentTarget=null}function cd(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;rc(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;rc(s,l,d),o=c}}}if(Zs)throw e=Oo,Zs=!1,Oo=null,e}function ge(e,t){var n=t[Qo];n===void 0&&(n=t[Qo]=new Set);var r=e+"__bubble";n.has(r)||(ud(t,e,2,!1),n.add(r))}function so(e,t,n){var r=0;t&&(r|=4),ud(n,e,r,t)}var ks="_reactListening"+Math.random().toString(36).slice(2);function Xr(e){if(!e[ks]){e[ks]=!0,yu.forEach(function(n){n!=="selectionchange"&&(Bm.has(n)||so(n,!1,e),so(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[ks]||(t[ks]=!0,so("selectionchange",!1,t))}}function ud(e,t,n,r){switch(Ku(t)){case 1:var s=em;break;case 4:s=tm;break;default:s=Oi}n=s.bind(null,t,n,e),s=void 0,!Fo||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 ao(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=Nn(l),i===null)return;if(c=i.tag,c===5||c===6){r=o=i;continue e}l=l.parentNode}}r=r.return}_u(function(){var d=o,f=$i(n),m=[];e:{var p=ld.get(e);if(p!==void 0){var x=Di,w=e;switch(e){case"keypress":if(Bs(n)===0)break e;case"keydown":case"keyup":x=gm;break;case"focusin":w="focus",x=qa;break;case"focusout":w="blur",x=qa;break;case"beforeblur":case"afterblur":x=qa;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":x=Vl;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":x=sm;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":x=xm;break;case sd:case ad:case od:x=im;break;case id:x=Sm;break;case"scroll":x=nm;break;case"wheel":x=km;break;case"copy":case"cut":case"paste":x=cm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":x=Kl}var v=(t&4)!==0,j=!v&&e==="scroll",h=v?p!==null?p+"Capture":null:p;v=[];for(var g=d,y;g!==null;){y=g;var S=y.stateNode;if(y.tag===5&&S!==null&&(y=S,h!==null&&(S=Vr(g,h),S!=null&&v.push(qr(g,S,y)))),j)break;g=g.return}0<v.length&&(p=new x(p,w,null,n,f),m.push({event:p,listeners:v}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",x=e==="mouseout"||e==="pointerout",p&&n!==Lo&&(w=n.relatedTarget||n.fromElement)&&(Nn(w)||w[Kt]))break e;if((x||p)&&(p=f.window===f?f:(p=f.ownerDocument)?p.defaultView||p.parentWindow:window,x?(w=n.relatedTarget||n.toElement,x=d,w=w?Nn(w):null,w!==null&&(j=Fn(w),w!==j||w.tag!==5&&w.tag!==6)&&(w=null)):(x=null,w=d),x!==w)){if(v=Vl,S="onMouseLeave",h="onMouseEnter",g="mouse",(e==="pointerout"||e==="pointerover")&&(v=Kl,S="onPointerLeave",h="onPointerEnter",g="pointer"),j=x==null?p:Gn(x),y=w==null?p:Gn(w),p=new v(S,g+"leave",x,n,f),p.target=j,p.relatedTarget=y,S=null,Nn(f)===d&&(v=new v(h,g+"enter",w,n,f),v.target=y,v.relatedTarget=j,S=v),j=S,x&&w)t:{for(v=x,h=w,g=0,y=v;y;y=Bn(y))g++;for(y=0,S=h;S;S=Bn(S))y++;for(;0<g-y;)v=Bn(v),g--;for(;0<y-g;)h=Bn(h),y--;for(;g--;){if(v===h||h!==null&&v===h.alternate)break t;v=Bn(v),h=Bn(h)}v=null}else v=null;x!==null&&sc(m,p,x,v,!1),w!==null&&j!==null&&sc(m,j,w,v,!0)}}e:{if(p=d?Gn(d):window,x=p.nodeName&&p.nodeName.toLowerCase(),x==="select"||x==="input"&&p.type==="file")var k=Im;else if(Jl(p))if(Zu)k=Am;else{k=Pm;var I=Rm}else(x=p.nodeName)&&x.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(k=_m);if(k&&(k=k(e,d))){qu(m,k,n,f);break e}I&&I(e,p,d),e==="focusout"&&(I=p._wrapperState)&&I.controlled&&p.type==="number"&&Ro(p,"number",p.value)}switch(I=d?Gn(d):window,e){case"focusin":(Jl(I)||I.contentEditable==="true")&&(Hn=I,Wo=d,Mr=null);break;case"focusout":Mr=Wo=Hn=null;break;case"mousedown":Ho=!0;break;case"contextmenu":case"mouseup":case"dragend":Ho=!1,tc(m,n,f);break;case"selectionchange":if(Mm)break;case"keydown":case"keyup":tc(m,n,f)}var R;if(Wi)e:{switch(e){case"compositionstart":var _="onCompositionStart";break e;case"compositionend":_="onCompositionEnd";break e;case"compositionupdate":_="onCompositionUpdate";break e}_=void 0}else Wn?Ju(e,n)&&(_="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(_="onCompositionStart");_&&(Qu&&n.locale!=="ko"&&(Wn||_!=="onCompositionStart"?_==="onCompositionEnd"&&Wn&&(R=Yu()):(an=f,Bi="value"in an?an.value:an.textContent,Wn=!0)),I=sa(d,_),0<I.length&&(_=new Gl(_,e,null,n,f),m.push({event:_,listeners:I}),R?_.data=R:(R=Xu(n),R!==null&&(_.data=R)))),(R=Cm?Nm(e,n):Em(e,n))&&(d=sa(d,"onBeforeInput"),0<d.length&&(f=new Gl("onBeforeInput","beforeinput",null,n,f),m.push({event:f,listeners:d}),f.data=R))}cd(m,t)})}function qr(e,t,n){return{instance:e,listener:t,currentTarget:n}}function sa(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=Vr(e,n),o!=null&&r.unshift(qr(e,o,s)),o=Vr(e,t),o!=null&&r.push(qr(e,o,s))),e=e.return}return r}function Bn(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function sc(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=Vr(n,o),c!=null&&i.unshift(qr(n,c,l))):s||(c=Vr(n,o),c!=null&&i.push(qr(n,c,l)))),n=n.return}i.length!==0&&e.push({event:t,listeners:i})}var Dm=/\r\n?/g,Um=/\u0000|\uFFFD/g;function ac(e){return(typeof e=="string"?e:""+e).replace(Dm,`
38
- `).replace(Um,"")}function bs(e,t,n){if(t=ac(t),ac(e)!==t&&n)throw Error(B(425))}function aa(){}var Vo=null,Go=null;function Ko(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 Yo=typeof setTimeout=="function"?setTimeout:void 0,Wm=typeof clearTimeout=="function"?clearTimeout:void 0,oc=typeof Promise=="function"?Promise:void 0,Hm=typeof queueMicrotask=="function"?queueMicrotask:typeof oc<"u"?function(e){return oc.resolve(null).then(e).catch(Vm)}:Yo;function Vm(e){setTimeout(function(){throw e})}function oo(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),Yr(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);Yr(t)}function dn(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 ic(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 mr=Math.random().toString(36).slice(2),$t="__reactFiber$"+mr,Zr="__reactProps$"+mr,Kt="__reactContainer$"+mr,Qo="__reactEvents$"+mr,Gm="__reactListeners$"+mr,Km="__reactHandles$"+mr;function Nn(e){var t=e[$t];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Kt]||n[$t]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=ic(e);e!==null;){if(n=e[$t])return n;e=ic(e)}return t}e=n,n=e.parentNode}return null}function us(e){return e=e[$t]||e[Kt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Gn(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(B(33))}function za(e){return e[Zr]||null}var Jo=[],Kn=-1;function xn(e){return{current:e}}function ye(e){0>Kn||(e.current=Jo[Kn],Jo[Kn]=null,Kn--)}function me(e,t){Kn++,Jo[Kn]=e.current,e.current=t}var yn={},Ge=xn(yn),rt=xn(!1),Pn=yn;function or(e,t){var n=e.type.contextTypes;if(!n)return yn;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 st(e){return e=e.childContextTypes,e!=null}function oa(){ye(rt),ye(Ge)}function lc(e,t,n){if(Ge.current!==yn)throw Error(B(168));me(Ge,t),me(rt,n)}function dd(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(B(108,Rp(e)||"Unknown",s));return je({},n,r)}function ia(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||yn,Pn=Ge.current,me(Ge,e),me(rt,rt.current),!0}function cc(e,t,n){var r=e.stateNode;if(!r)throw Error(B(169));n?(e=dd(e,t,Pn),r.__reactInternalMemoizedMergedChildContext=e,ye(rt),ye(Ge),me(Ge,e)):ye(rt),me(rt,n)}var Ut=null,Ia=!1,io=!1;function fd(e){Ut===null?Ut=[e]:Ut.push(e)}function Ym(e){Ia=!0,fd(e)}function wn(){if(!io&&Ut!==null){io=!0;var e=0,t=fe;try{var n=Ut;for(fe=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Ut=null,Ia=!1}catch(s){throw Ut!==null&&(Ut=Ut.slice(e+1)),Mu(Li,wn),s}finally{fe=t,io=!1}}return null}var Yn=[],Qn=0,la=null,ca=0,gt=[],yt=0,_n=null,Wt=1,Ht="";function kn(e,t){Yn[Qn++]=ca,Yn[Qn++]=la,la=e,ca=t}function pd(e,t,n){gt[yt++]=Wt,gt[yt++]=Ht,gt[yt++]=_n,_n=e;var r=Wt;e=Ht;var s=32-Tt(r)-1;r&=~(1<<s),n+=1;var o=32-Tt(t)+s;if(30<o){var i=s-s%5;o=(r&(1<<i)-1).toString(32),r>>=i,s-=i,Wt=1<<32-Tt(t)+s|n<<s|r,Ht=o+e}else Wt=1<<o|n<<s|r,Ht=e}function Vi(e){e.return!==null&&(kn(e,1),pd(e,1,0))}function Gi(e){for(;e===la;)la=Yn[--Qn],Yn[Qn]=null,ca=Yn[--Qn],Yn[Qn]=null;for(;e===_n;)_n=gt[--yt],gt[yt]=null,Ht=gt[--yt],gt[yt]=null,Wt=gt[--yt],gt[yt]=null}var ut=null,ct=null,ve=!1,Et=null;function md(e,t){var n=vt(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 uc(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,ut=e,ct=dn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ut=e,ct=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=_n!==null?{id:Wt,overflow:Ht}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=vt(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ut=e,ct=null,!0):!1;default:return!1}}function Xo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function qo(e){if(ve){var t=ct;if(t){var n=t;if(!uc(e,t)){if(Xo(e))throw Error(B(418));t=dn(n.nextSibling);var r=ut;t&&uc(e,t)?md(r,n):(e.flags=e.flags&-4097|2,ve=!1,ut=e)}}else{if(Xo(e))throw Error(B(418));e.flags=e.flags&-4097|2,ve=!1,ut=e}}}function dc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ut=e}function Cs(e){if(e!==ut)return!1;if(!ve)return dc(e),ve=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Ko(e.type,e.memoizedProps)),t&&(t=ct)){if(Xo(e))throw hd(),Error(B(418));for(;t;)md(e,t),t=dn(t.nextSibling)}if(dc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(B(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){ct=dn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ct=null}}else ct=ut?dn(e.stateNode.nextSibling):null;return!0}function hd(){for(var e=ct;e;)e=dn(e.nextSibling)}function ir(){ct=ut=null,ve=!1}function Ki(e){Et===null?Et=[e]:Et.push(e)}var Qm=Xt.ReactCurrentBatchConfig;function kr(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(B(309));var r=n.stateNode}if(!r)throw Error(B(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(B(284));if(!n._owner)throw Error(B(290,e))}return e}function Ns(e,t){throw e=Object.prototype.toString.call(t),Error(B(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function fc(e){var t=e._init;return t(e._payload)}function gd(e){function t(h,g){if(e){var y=h.deletions;y===null?(h.deletions=[g],h.flags|=16):y.push(g)}}function n(h,g){if(!e)return null;for(;g!==null;)t(h,g),g=g.sibling;return null}function r(h,g){for(h=new Map;g!==null;)g.key!==null?h.set(g.key,g):h.set(g.index,g),g=g.sibling;return h}function s(h,g){return h=hn(h,g),h.index=0,h.sibling=null,h}function o(h,g,y){return h.index=y,e?(y=h.alternate,y!==null?(y=y.index,y<g?(h.flags|=2,g):y):(h.flags|=2,g)):(h.flags|=1048576,g)}function i(h){return e&&h.alternate===null&&(h.flags|=2),h}function l(h,g,y,S){return g===null||g.tag!==6?(g=ho(y,h.mode,S),g.return=h,g):(g=s(g,y),g.return=h,g)}function c(h,g,y,S){var k=y.type;return k===Un?f(h,g,y.props.children,S,y.key):g!==null&&(g.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===en&&fc(k)===g.type)?(S=s(g,y.props),S.ref=kr(h,g,y),S.return=h,S):(S=Ks(y.type,y.key,y.props,null,h.mode,S),S.ref=kr(h,g,y),S.return=h,S)}function d(h,g,y,S){return g===null||g.tag!==4||g.stateNode.containerInfo!==y.containerInfo||g.stateNode.implementation!==y.implementation?(g=go(y,h.mode,S),g.return=h,g):(g=s(g,y.children||[]),g.return=h,g)}function f(h,g,y,S,k){return g===null||g.tag!==7?(g=Rn(y,h.mode,S,k),g.return=h,g):(g=s(g,y),g.return=h,g)}function m(h,g,y){if(typeof g=="string"&&g!==""||typeof g=="number")return g=ho(""+g,h.mode,y),g.return=h,g;if(typeof g=="object"&&g!==null){switch(g.$$typeof){case hs:return y=Ks(g.type,g.key,g.props,null,h.mode,y),y.ref=kr(h,null,g),y.return=h,y;case Dn:return g=go(g,h.mode,y),g.return=h,g;case en:var S=g._init;return m(h,S(g._payload),y)}if(zr(g)||vr(g))return g=Rn(g,h.mode,y,null),g.return=h,g;Ns(h,g)}return null}function p(h,g,y,S){var k=g!==null?g.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return k!==null?null:l(h,g,""+y,S);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case hs:return y.key===k?c(h,g,y,S):null;case Dn:return y.key===k?d(h,g,y,S):null;case en:return k=y._init,p(h,g,k(y._payload),S)}if(zr(y)||vr(y))return k!==null?null:f(h,g,y,S,null);Ns(h,y)}return null}function x(h,g,y,S,k){if(typeof S=="string"&&S!==""||typeof S=="number")return h=h.get(y)||null,l(g,h,""+S,k);if(typeof S=="object"&&S!==null){switch(S.$$typeof){case hs:return h=h.get(S.key===null?y:S.key)||null,c(g,h,S,k);case Dn:return h=h.get(S.key===null?y:S.key)||null,d(g,h,S,k);case en:var I=S._init;return x(h,g,y,I(S._payload),k)}if(zr(S)||vr(S))return h=h.get(y)||null,f(g,h,S,k,null);Ns(g,S)}return null}function w(h,g,y,S){for(var k=null,I=null,R=g,_=g=0,C=null;R!==null&&_<y.length;_++){R.index>_?(C=R,R=null):C=R.sibling;var z=p(h,R,y[_],S);if(z===null){R===null&&(R=C);break}e&&R&&z.alternate===null&&t(h,R),g=o(z,g,_),I===null?k=z:I.sibling=z,I=z,R=C}if(_===y.length)return n(h,R),ve&&kn(h,_),k;if(R===null){for(;_<y.length;_++)R=m(h,y[_],S),R!==null&&(g=o(R,g,_),I===null?k=R:I.sibling=R,I=R);return ve&&kn(h,_),k}for(R=r(h,R);_<y.length;_++)C=x(R,h,_,y[_],S),C!==null&&(e&&C.alternate!==null&&R.delete(C.key===null?_:C.key),g=o(C,g,_),I===null?k=C:I.sibling=C,I=C);return e&&R.forEach(function(D){return t(h,D)}),ve&&kn(h,_),k}function v(h,g,y,S){var k=vr(y);if(typeof k!="function")throw Error(B(150));if(y=k.call(y),y==null)throw Error(B(151));for(var I=k=null,R=g,_=g=0,C=null,z=y.next();R!==null&&!z.done;_++,z=y.next()){R.index>_?(C=R,R=null):C=R.sibling;var D=p(h,R,z.value,S);if(D===null){R===null&&(R=C);break}e&&R&&D.alternate===null&&t(h,R),g=o(D,g,_),I===null?k=D:I.sibling=D,I=D,R=C}if(z.done)return n(h,R),ve&&kn(h,_),k;if(R===null){for(;!z.done;_++,z=y.next())z=m(h,z.value,S),z!==null&&(g=o(z,g,_),I===null?k=z:I.sibling=z,I=z);return ve&&kn(h,_),k}for(R=r(h,R);!z.done;_++,z=y.next())z=x(R,h,_,z.value,S),z!==null&&(e&&z.alternate!==null&&R.delete(z.key===null?_:z.key),g=o(z,g,_),I===null?k=z:I.sibling=z,I=z);return e&&R.forEach(function(Y){return t(h,Y)}),ve&&kn(h,_),k}function j(h,g,y,S){if(typeof y=="object"&&y!==null&&y.type===Un&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case hs:e:{for(var k=y.key,I=g;I!==null;){if(I.key===k){if(k=y.type,k===Un){if(I.tag===7){n(h,I.sibling),g=s(I,y.props.children),g.return=h,h=g;break e}}else if(I.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===en&&fc(k)===I.type){n(h,I.sibling),g=s(I,y.props),g.ref=kr(h,I,y),g.return=h,h=g;break e}n(h,I);break}else t(h,I);I=I.sibling}y.type===Un?(g=Rn(y.props.children,h.mode,S,y.key),g.return=h,h=g):(S=Ks(y.type,y.key,y.props,null,h.mode,S),S.ref=kr(h,g,y),S.return=h,h=S)}return i(h);case Dn:e:{for(I=y.key;g!==null;){if(g.key===I)if(g.tag===4&&g.stateNode.containerInfo===y.containerInfo&&g.stateNode.implementation===y.implementation){n(h,g.sibling),g=s(g,y.children||[]),g.return=h,h=g;break e}else{n(h,g);break}else t(h,g);g=g.sibling}g=go(y,h.mode,S),g.return=h,h=g}return i(h);case en:return I=y._init,j(h,g,I(y._payload),S)}if(zr(y))return w(h,g,y,S);if(vr(y))return v(h,g,y,S);Ns(h,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,g!==null&&g.tag===6?(n(h,g.sibling),g=s(g,y),g.return=h,h=g):(n(h,g),g=ho(y,h.mode,S),g.return=h,h=g),i(h)):n(h,g)}return j}var lr=gd(!0),yd=gd(!1),ua=xn(null),da=null,Jn=null,Yi=null;function Qi(){Yi=Jn=da=null}function Ji(e){var t=ua.current;ye(ua),e._currentValue=t}function Zo(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 rr(e,t){da=e,Yi=Jn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(nt=!0),e.firstContext=null)}function wt(e){var t=e._currentValue;if(Yi!==e)if(e={context:e,memoizedValue:t,next:null},Jn===null){if(da===null)throw Error(B(308));Jn=e,da.dependencies={lanes:0,firstContext:e}}else Jn=Jn.next=e;return t}var En=null;function Xi(e){En===null?En=[e]:En.push(e)}function vd(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Xi(t)):(n.next=s.next,s.next=n),t.interleaved=n,Yt(e,r)}function Yt(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 tn=!1;function qi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function xd(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 Vt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function fn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,oe&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Yt(e,n)}return s=r.interleaved,s===null?(t.next=t,Xi(r)):(t.next=s.next,s.next=t),r.interleaved=t,Yt(e,n)}function Ds(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,Mi(e,n)}}function pc(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 fa(e,t,n,r){var s=e.updateQueue;tn=!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 m=s.baseState;i=0,f=d=c=null,l=o;do{var p=l.lane,x=l.eventTime;if((r&p)===p){f!==null&&(f=f.next={eventTime:x,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var w=e,v=l;switch(p=t,x=n,v.tag){case 1:if(w=v.payload,typeof w=="function"){m=w.call(x,m,p);break e}m=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=v.payload,p=typeof w=="function"?w.call(x,m,p):w,p==null)break e;m=je({},m,p);break e;case 2:tn=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else x={eventTime:x,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},f===null?(d=f=x,c=m):f=f.next=x,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=m),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);$n|=i,e.lanes=i,e.memoizedState=m}}function mc(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(B(191,s));s.call(r)}}}var ds={},Ft=xn(ds),es=xn(ds),ts=xn(ds);function Tn(e){if(e===ds)throw Error(B(174));return e}function Zi(e,t){switch(me(ts,t),me(es,e),me(Ft,ds),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:_o(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=_o(t,e)}ye(Ft),me(Ft,t)}function cr(){ye(Ft),ye(es),ye(ts)}function wd(e){Tn(ts.current);var t=Tn(Ft.current),n=_o(t,e.type);t!==n&&(me(es,e),me(Ft,n))}function el(e){es.current===e&&(ye(Ft),ye(es))}var we=xn(0);function pa(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 lo=[];function tl(){for(var e=0;e<lo.length;e++)lo[e]._workInProgressVersionPrimary=null;lo.length=0}var Us=Xt.ReactCurrentDispatcher,co=Xt.ReactCurrentBatchConfig,An=0,Se=null,Ee=null,Pe=null,ma=!1,Fr=!1,ns=0,Jm=0;function We(){throw Error(B(321))}function nl(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!It(e[n],t[n]))return!1;return!0}function rl(e,t,n,r,s,o){if(An=o,Se=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Us.current=e===null||e.memoizedState===null?eh:th,e=n(r,s),Fr){o=0;do{if(Fr=!1,ns=0,25<=o)throw Error(B(301));o+=1,Pe=Ee=null,t.updateQueue=null,Us.current=nh,e=n(r,s)}while(Fr)}if(Us.current=ha,t=Ee!==null&&Ee.next!==null,An=0,Pe=Ee=Se=null,ma=!1,t)throw Error(B(300));return e}function sl(){var e=ns!==0;return ns=0,e}function _t(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Pe===null?Se.memoizedState=Pe=e:Pe=Pe.next=e,Pe}function St(){if(Ee===null){var e=Se.alternate;e=e!==null?e.memoizedState:null}else e=Ee.next;var t=Pe===null?Se.memoizedState:Pe.next;if(t!==null)Pe=t,Ee=e;else{if(e===null)throw Error(B(310));Ee=e,e={memoizedState:Ee.memoizedState,baseState:Ee.baseState,baseQueue:Ee.baseQueue,queue:Ee.queue,next:null},Pe===null?Se.memoizedState=Pe=e:Pe=Pe.next=e}return Pe}function rs(e,t){return typeof t=="function"?t(e):t}function uo(e){var t=St(),n=t.queue;if(n===null)throw Error(B(311));n.lastRenderedReducer=e;var r=Ee,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((An&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 m={lane:f,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=m,i=r):c=c.next=m,Se.lanes|=f,$n|=f}d=d.next}while(d!==null&&d!==o);c===null?i=r:c.next=l,It(r,t.memoizedState)||(nt=!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,Se.lanes|=o,$n|=o,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function fo(e){var t=St(),n=t.queue;if(n===null)throw Error(B(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);It(o,t.memoizedState)||(nt=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Sd(){}function jd(e,t){var n=Se,r=St(),s=t(),o=!It(r.memoizedState,s);if(o&&(r.memoizedState=s,nt=!0),r=r.queue,al(Cd.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||Pe!==null&&Pe.memoizedState.tag&1){if(n.flags|=2048,ss(9,bd.bind(null,n,r,s,t),void 0,null),_e===null)throw Error(B(349));An&30||kd(n,t,s)}return s}function kd(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Se.updateQueue,t===null?(t={lastEffect:null,stores:null},Se.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function bd(e,t,n,r){t.value=n,t.getSnapshot=r,Nd(t)&&Ed(e)}function Cd(e,t,n){return n(function(){Nd(t)&&Ed(e)})}function Nd(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!It(e,n)}catch{return!0}}function Ed(e){var t=Yt(e,1);t!==null&&zt(t,e,1,-1)}function hc(e){var t=_t();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:rs,lastRenderedState:e},t.queue=e,e=e.dispatch=Zm.bind(null,Se,e),[t.memoizedState,e]}function ss(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Se.updateQueue,t===null?(t={lastEffect:null,stores:null},Se.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 Td(){return St().memoizedState}function Ws(e,t,n,r){var s=_t();Se.flags|=e,s.memoizedState=ss(1|t,n,void 0,r===void 0?null:r)}function Ra(e,t,n,r){var s=St();r=r===void 0?null:r;var o=void 0;if(Ee!==null){var i=Ee.memoizedState;if(o=i.destroy,r!==null&&nl(r,i.deps)){s.memoizedState=ss(t,n,o,r);return}}Se.flags|=e,s.memoizedState=ss(1|t,n,o,r)}function gc(e,t){return Ws(8390656,8,e,t)}function al(e,t){return Ra(2048,8,e,t)}function zd(e,t){return Ra(4,2,e,t)}function Id(e,t){return Ra(4,4,e,t)}function Rd(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 Pd(e,t,n){return n=n!=null?n.concat([e]):null,Ra(4,4,Rd.bind(null,t,e),n)}function ol(){}function _d(e,t){var n=St();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&nl(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Ad(e,t){var n=St();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&nl(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function $d(e,t,n){return An&21?(It(n,t)||(n=Bu(),Se.lanes|=n,$n|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,nt=!0),e.memoizedState=n)}function Xm(e,t){var n=fe;fe=n!==0&&4>n?n:4,e(!0);var r=co.transition;co.transition={};try{e(!1),t()}finally{fe=n,co.transition=r}}function Ld(){return St().memoizedState}function qm(e,t,n){var r=mn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Md(e))Fd(t,n);else if(n=vd(e,t,n,r),n!==null){var s=Je();zt(n,e,r,s),Od(n,t,r)}}function Zm(e,t,n){var r=mn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Md(e))Fd(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,It(l,i)){var c=t.interleaved;c===null?(s.next=s,Xi(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=vd(e,t,s,r),n!==null&&(s=Je(),zt(n,e,r,s),Od(n,t,r))}}function Md(e){var t=e.alternate;return e===Se||t!==null&&t===Se}function Fd(e,t){Fr=ma=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Od(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Mi(e,n)}}var ha={readContext:wt,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},eh={readContext:wt,useCallback:function(e,t){return _t().memoizedState=[e,t===void 0?null:t],e},useContext:wt,useEffect:gc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ws(4194308,4,Rd.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ws(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ws(4,2,e,t)},useMemo:function(e,t){var n=_t();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=_t();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=qm.bind(null,Se,e),[r.memoizedState,e]},useRef:function(e){var t=_t();return e={current:e},t.memoizedState=e},useState:hc,useDebugValue:ol,useDeferredValue:function(e){return _t().memoizedState=e},useTransition:function(){var e=hc(!1),t=e[0];return e=Xm.bind(null,e[1]),_t().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Se,s=_t();if(ve){if(n===void 0)throw Error(B(407));n=n()}else{if(n=t(),_e===null)throw Error(B(349));An&30||kd(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,gc(Cd.bind(null,r,o,e),[e]),r.flags|=2048,ss(9,bd.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=_t(),t=_e.identifierPrefix;if(ve){var n=Ht,r=Wt;n=(r&~(1<<32-Tt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=ns++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=Jm++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},th={readContext:wt,useCallback:_d,useContext:wt,useEffect:al,useImperativeHandle:Pd,useInsertionEffect:zd,useLayoutEffect:Id,useMemo:Ad,useReducer:uo,useRef:Td,useState:function(){return uo(rs)},useDebugValue:ol,useDeferredValue:function(e){var t=St();return $d(t,Ee.memoizedState,e)},useTransition:function(){var e=uo(rs)[0],t=St().memoizedState;return[e,t]},useMutableSource:Sd,useSyncExternalStore:jd,useId:Ld,unstable_isNewReconciler:!1},nh={readContext:wt,useCallback:_d,useContext:wt,useEffect:al,useImperativeHandle:Pd,useInsertionEffect:zd,useLayoutEffect:Id,useMemo:Ad,useReducer:fo,useRef:Td,useState:function(){return fo(rs)},useDebugValue:ol,useDeferredValue:function(e){var t=St();return Ee===null?t.memoizedState=e:$d(t,Ee.memoizedState,e)},useTransition:function(){var e=fo(rs)[0],t=St().memoizedState;return[e,t]},useMutableSource:Sd,useSyncExternalStore:jd,useId:Ld,unstable_isNewReconciler:!1};function Ct(e,t){if(e&&e.defaultProps){t=je({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function ei(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:je({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Pa={isMounted:function(e){return(e=e._reactInternals)?Fn(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Je(),s=mn(e),o=Vt(r,s);o.payload=t,n!=null&&(o.callback=n),t=fn(e,o,s),t!==null&&(zt(t,e,s,r),Ds(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Je(),s=mn(e),o=Vt(r,s);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=fn(e,o,s),t!==null&&(zt(t,e,s,r),Ds(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Je(),r=mn(e),s=Vt(n,r);s.tag=2,t!=null&&(s.callback=t),t=fn(e,s,r),t!==null&&(zt(t,e,r,n),Ds(t,e,r))}};function yc(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?!Jr(n,r)||!Jr(s,o):!0}function Bd(e,t,n){var r=!1,s=yn,o=t.contextType;return typeof o=="object"&&o!==null?o=wt(o):(s=st(t)?Pn:Ge.current,r=t.contextTypes,o=(r=r!=null)?or(e,s):yn),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Pa,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function vc(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&&Pa.enqueueReplaceState(t,t.state,null)}function ti(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},qi(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=wt(o):(o=st(t)?Pn:Ge.current,s.context=or(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(ei(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&&Pa.enqueueReplaceState(s,s.state,null),fa(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function ur(e,t){try{var n="",r=t;do n+=Ip(r),r=r.return;while(r);var s=n}catch(o){s=`
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{Ga=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?zr(e):""}function Rp(e){switch(e.tag){case 5:return zr(e.type);case 16:return zr("Lazy");case 13:return zr("Suspense");case 19:return zr("SuspenseList");case 0:case 2:case 15:return e=Ka(e.type,!1),e;case 11:return e=Ka(e.type.render,!1),e;case 1:return e=Ka(e.type,!0),e;default:return""}}function To(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 Un:return"Fragment";case Dn:return"Portal";case Co:return"Profiler";case Ri:return"StrictMode";case No:return"Suspense";case Eo:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case vu:return(e.displayName||"Context")+".Consumer";case yu:return(e._context.displayName||"Context")+".Provider";case Pi:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case _i:return t=e.displayName||null,t!==null?t:To(e.type)||"Memo";case en:t=e._payload,e=e._init;try{return To(e(t))}catch{}}return null}function Pp(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 To(t);case 8:return t===Ri?"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 gn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function wu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function _p(e){var t=wu(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 ys(e){e._valueTracker||(e._valueTracker=_p(e))}function Su(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=wu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function qs(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 zo(e,t){var n=t.checked;return je({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Al(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=gn(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 ju(e,t){t=t.checked,t!=null&&Ii(e,"checked",t,!1)}function Io(e,t){ju(e,t);var n=gn(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")?Ro(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ro(e,t.type,gn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function $l(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 Ro(e,t,n){(t!=="number"||qs(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Ir=Array.isArray;function Zn(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=""+gn(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 Po(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(B(91));return je({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Ll(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(B(92));if(Ir(n)){if(1<n.length)throw Error(B(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:gn(n)}}function ku(e,t){var n=gn(t.value),r=gn(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 Ml(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function bu(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 _o(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?bu(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var vs,Cu=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(vs=vs||document.createElement("div"),vs.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=vs.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Vr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ar={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},Ap=["Webkit","ms","Moz","O"];Object.keys(Ar).forEach(function(e){Ap.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ar[t]=Ar[e]})});function Nu(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Ar.hasOwnProperty(e)&&Ar[e]?(""+t).trim():t+"px"}function Eu(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=Nu(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var $p=je({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 Ao(e,t){if(t){if($p[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(B(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(B(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(B(61))}if(t.style!=null&&typeof t.style!="object")throw Error(B(62))}}function $o(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 Lo=null;function Ai(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Mo=null,er=null,tr=null;function Fl(e){if(e=ds(e)){if(typeof Mo!="function")throw Error(B(280));var t=e.stateNode;t&&(t=Ia(t),Mo(e.stateNode,e.type,t))}}function Tu(e){er?tr?tr.push(e):tr=[e]:er=e}function zu(){if(er){var e=er,t=tr;if(tr=er=null,Fl(e),t)for(e=0;e<t.length;e++)Fl(t[e])}}function Iu(e,t){return e(t)}function Ru(){}var Ya=!1;function Pu(e,t,n){if(Ya)return e(t,n);Ya=!0;try{return Iu(e,t,n)}finally{Ya=!1,(er!==null||tr!==null)&&(Ru(),zu())}}function Gr(e,t){var n=e.stateNode;if(n===null)return null;var r=Ia(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(B(231,t,typeof n));return n}var Fo=!1;if(Gt)try{var wr={};Object.defineProperty(wr,"passive",{get:function(){Fo=!0}}),window.addEventListener("test",wr,wr),window.removeEventListener("test",wr,wr)}catch{Fo=!1}function Lp(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 $r=!1,Zs=null,ea=!1,Oo=null,Mp={onError:function(e){$r=!0,Zs=e}};function Fp(e,t,n,r,s,o,i,l,c){$r=!1,Zs=null,Lp.apply(Mp,arguments)}function Op(e,t,n,r,s,o,i,l,c){if(Fp.apply(this,arguments),$r){if($r){var d=Zs;$r=!1,Zs=null}else throw Error(B(198));ea||(ea=!0,Oo=d)}}function Fn(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 _u(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 Ol(e){if(Fn(e)!==e)throw Error(B(188))}function Bp(e){var t=e.alternate;if(!t){if(t=Fn(e),t===null)throw Error(B(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 Ol(s),e;if(o===r)return Ol(s),t;o=o.sibling}throw Error(B(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(B(189))}}if(n.alternate!==r)throw Error(B(190))}if(n.tag!==3)throw Error(B(188));return n.stateNode.current===n?e:t}function Au(e){return e=Bp(e),e!==null?$u(e):null}function $u(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=$u(e);if(t!==null)return t;e=e.sibling}return null}var Lu=dt.unstable_scheduleCallback,Bl=dt.unstable_cancelCallback,Dp=dt.unstable_shouldYield,Up=dt.unstable_requestPaint,be=dt.unstable_now,Wp=dt.unstable_getCurrentPriorityLevel,$i=dt.unstable_ImmediatePriority,Mu=dt.unstable_UserBlockingPriority,ta=dt.unstable_NormalPriority,Hp=dt.unstable_LowPriority,Fu=dt.unstable_IdlePriority,Na=null,Mt=null;function Vp(e){if(Mt&&typeof Mt.onCommitFiberRoot=="function")try{Mt.onCommitFiberRoot(Na,e,void 0,(e.current.flags&128)===128)}catch{}}var Tt=Math.clz32?Math.clz32:Yp,Gp=Math.log,Kp=Math.LN2;function Yp(e){return e>>>=0,e===0?32:31-(Gp(e)/Kp|0)|0}var xs=64,ws=4194304;function Rr(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 na(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=Rr(l):(o&=i,o!==0&&(r=Rr(o)))}else i=n&~s,i!==0?r=Rr(i):o!==0&&(r=Rr(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-Tt(t),s=1<<n,r|=e[n],t&=~s;return r}function Qp(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 Jp(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes;0<o;){var i=31-Tt(o),l=1<<i,c=s[i];c===-1?(!(l&n)||l&r)&&(s[i]=Qp(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function Bo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Ou(){var e=xs;return xs<<=1,!(xs&4194240)&&(xs=64),e}function Qa(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function cs(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Tt(t),e[t]=n}function Xp(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-Tt(n),o=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~o}}function Li(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Tt(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var fe=0;function Bu(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Du,Mi,Uu,Wu,Hu,Do=!1,Ss=[],ln=null,cn=null,un=null,Kr=new Map,Yr=new Map,rn=[],qp="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 Dl(e,t){switch(e){case"focusin":case"focusout":ln=null;break;case"dragenter":case"dragleave":cn=null;break;case"mouseover":case"mouseout":un=null;break;case"pointerover":case"pointerout":Kr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Yr.delete(t.pointerId)}}function Sr(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=ds(t),t!==null&&Mi(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function Zp(e,t,n,r,s){switch(t){case"focusin":return ln=Sr(ln,e,t,n,r,s),!0;case"dragenter":return cn=Sr(cn,e,t,n,r,s),!0;case"mouseover":return un=Sr(un,e,t,n,r,s),!0;case"pointerover":var o=s.pointerId;return Kr.set(o,Sr(Kr.get(o)||null,e,t,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,Yr.set(o,Sr(Yr.get(o)||null,e,t,n,r,s)),!0}return!1}function Vu(e){var t=Nn(e.target);if(t!==null){var n=Fn(t);if(n!==null){if(t=n.tag,t===13){if(t=_u(n),t!==null){e.blockedOn=t,Hu(e.priority,function(){Uu(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 Os(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Uo(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Lo=r,n.target.dispatchEvent(r),Lo=null}else return t=ds(n),t!==null&&Mi(t),e.blockedOn=n,!1;t.shift()}return!0}function Ul(e,t,n){Os(e)&&n.delete(t)}function em(){Do=!1,ln!==null&&Os(ln)&&(ln=null),cn!==null&&Os(cn)&&(cn=null),un!==null&&Os(un)&&(un=null),Kr.forEach(Ul),Yr.forEach(Ul)}function jr(e,t){e.blockedOn===t&&(e.blockedOn=null,Do||(Do=!0,dt.unstable_scheduleCallback(dt.unstable_NormalPriority,em)))}function Qr(e){function t(s){return jr(s,e)}if(0<Ss.length){jr(Ss[0],e);for(var n=1;n<Ss.length;n++){var r=Ss[n];r.blockedOn===e&&(r.blockedOn=null)}}for(ln!==null&&jr(ln,e),cn!==null&&jr(cn,e),un!==null&&jr(un,e),Kr.forEach(t),Yr.forEach(t),n=0;n<rn.length;n++)r=rn[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<rn.length&&(n=rn[0],n.blockedOn===null);)Vu(n),n.blockedOn===null&&rn.shift()}var nr=Xt.ReactCurrentBatchConfig,ra=!0;function tm(e,t,n,r){var s=fe,o=nr.transition;nr.transition=null;try{fe=1,Fi(e,t,n,r)}finally{fe=s,nr.transition=o}}function nm(e,t,n,r){var s=fe,o=nr.transition;nr.transition=null;try{fe=4,Fi(e,t,n,r)}finally{fe=s,nr.transition=o}}function Fi(e,t,n,r){if(ra){var s=Uo(e,t,n,r);if(s===null)ao(e,t,r,sa,n),Dl(e,r);else if(Zp(s,e,t,n,r))r.stopPropagation();else if(Dl(e,r),t&4&&-1<qp.indexOf(e)){for(;s!==null;){var o=ds(s);if(o!==null&&Du(o),o=Uo(e,t,n,r),o===null&&ao(e,t,r,sa,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else ao(e,t,r,null,n)}}var sa=null;function Uo(e,t,n,r){if(sa=null,e=Ai(r),e=Nn(e),e!==null)if(t=Fn(e),t===null)e=null;else if(n=t.tag,n===13){if(e=_u(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 sa=e,null}function Gu(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(Wp()){case $i:return 1;case Mu:return 4;case ta:case Hp:return 16;case Fu:return 536870912;default:return 16}default:return 16}}var an=null,Oi=null,Bs=null;function Ku(){if(Bs)return Bs;var e,t=Oi,n=t.length,r,s="value"in an?an.value:an.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 Bs=s.slice(e,1<r?1-r:void 0)}function Ds(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 js(){return!0}function Wl(){return!1}function pt(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)?js:Wl,this.isPropagationStopped=Wl,this}return je(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=js)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=js)},persist:function(){},isPersistent:js}),t}var pr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Bi=pt(pr),us=je({},pr,{view:0,detail:0}),rm=pt(us),Ja,Xa,kr,Ea=je({},us,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Di,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!==kr&&(kr&&e.type==="mousemove"?(Ja=e.screenX-kr.screenX,Xa=e.screenY-kr.screenY):Xa=Ja=0,kr=e),Ja)},movementY:function(e){return"movementY"in e?e.movementY:Xa}}),Hl=pt(Ea),sm=je({},Ea,{dataTransfer:0}),am=pt(sm),om=je({},us,{relatedTarget:0}),qa=pt(om),im=je({},pr,{animationName:0,elapsedTime:0,pseudoElement:0}),lm=pt(im),cm=je({},pr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),um=pt(cm),dm=je({},pr,{data:0}),Vl=pt(dm),fm={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},pm={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"},mm={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function hm(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=mm[e])?!!t[e]:!1}function Di(){return hm}var gm=je({},us,{key:function(e){if(e.key){var t=fm[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Ds(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?pm[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Di,charCode:function(e){return e.type==="keypress"?Ds(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ds(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),ym=pt(gm),vm=je({},Ea,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Gl=pt(vm),xm=je({},us,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Di}),wm=pt(xm),Sm=je({},pr,{propertyName:0,elapsedTime:0,pseudoElement:0}),jm=pt(Sm),km=je({},Ea,{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}),bm=pt(km),Cm=[9,13,27,32],Ui=Gt&&"CompositionEvent"in window,Lr=null;Gt&&"documentMode"in document&&(Lr=document.documentMode);var Nm=Gt&&"TextEvent"in window&&!Lr,Yu=Gt&&(!Ui||Lr&&8<Lr&&11>=Lr),Kl=" ",Yl=!1;function Qu(e,t){switch(e){case"keyup":return Cm.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ju(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Wn=!1;function Em(e,t){switch(e){case"compositionend":return Ju(t);case"keypress":return t.which!==32?null:(Yl=!0,Kl);case"textInput":return e=t.data,e===Kl&&Yl?null:e;default:return null}}function Tm(e,t){if(Wn)return e==="compositionend"||!Ui&&Qu(e,t)?(e=Ku(),Bs=Oi=an=null,Wn=!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 Yu&&t.locale!=="ko"?null:t.data;default:return null}}var zm={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 Ql(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!zm[e.type]:t==="textarea"}function Xu(e,t,n,r){Tu(r),t=aa(t,"onChange"),0<t.length&&(n=new Bi("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Mr=null,Jr=null;function Im(e){ld(e,0)}function Ta(e){var t=Gn(e);if(Su(t))return e}function Rm(e,t){if(e==="change")return t}var qu=!1;if(Gt){var Za;if(Gt){var eo="oninput"in document;if(!eo){var Jl=document.createElement("div");Jl.setAttribute("oninput","return;"),eo=typeof Jl.oninput=="function"}Za=eo}else Za=!1;qu=Za&&(!document.documentMode||9<document.documentMode)}function Xl(){Mr&&(Mr.detachEvent("onpropertychange",Zu),Jr=Mr=null)}function Zu(e){if(e.propertyName==="value"&&Ta(Jr)){var t=[];Xu(t,Jr,e,Ai(e)),Pu(Im,t)}}function Pm(e,t,n){e==="focusin"?(Xl(),Mr=t,Jr=n,Mr.attachEvent("onpropertychange",Zu)):e==="focusout"&&Xl()}function _m(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ta(Jr)}function Am(e,t){if(e==="click")return Ta(t)}function $m(e,t){if(e==="input"||e==="change")return Ta(t)}function Lm(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var It=typeof Object.is=="function"?Object.is:Lm;function Xr(e,t){if(It(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(!bo.call(t,s)||!It(e[s],t[s]))return!1}return!0}function ql(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Zl(e,t){var n=ql(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=ql(n)}}function ed(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ed(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function td(){for(var e=window,t=qs();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=qs(e.document)}return t}function Wi(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 Mm(e){var t=td(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&ed(n.ownerDocument.documentElement,n)){if(r!==null&&Wi(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=Zl(n,o);var i=Zl(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 Fm=Gt&&"documentMode"in document&&11>=document.documentMode,Hn=null,Wo=null,Fr=null,Ho=!1;function ec(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ho||Hn==null||Hn!==qs(r)||(r=Hn,"selectionStart"in r&&Wi(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}),Fr&&Xr(Fr,r)||(Fr=r,r=aa(Wo,"onSelect"),0<r.length&&(t=new Bi("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Hn)))}function ks(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Vn={animationend:ks("Animation","AnimationEnd"),animationiteration:ks("Animation","AnimationIteration"),animationstart:ks("Animation","AnimationStart"),transitionend:ks("Transition","TransitionEnd")},to={},nd={};Gt&&(nd=document.createElement("div").style,"AnimationEvent"in window||(delete Vn.animationend.animation,delete Vn.animationiteration.animation,delete Vn.animationstart.animation),"TransitionEvent"in window||delete Vn.transitionend.transition);function za(e){if(to[e])return to[e];if(!Vn[e])return e;var t=Vn[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in nd)return to[e]=t[n];return e}var rd=za("animationend"),sd=za("animationiteration"),ad=za("animationstart"),od=za("transitionend"),id=new Map,tc="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 vn(e,t){id.set(e,t),Mn(t,[e])}for(var no=0;no<tc.length;no++){var ro=tc[no],Om=ro.toLowerCase(),Bm=ro[0].toUpperCase()+ro.slice(1);vn(Om,"on"+Bm)}vn(rd,"onAnimationEnd");vn(sd,"onAnimationIteration");vn(ad,"onAnimationStart");vn("dblclick","onDoubleClick");vn("focusin","onFocus");vn("focusout","onBlur");vn(od,"onTransitionEnd");ar("onMouseEnter",["mouseout","mouseover"]);ar("onMouseLeave",["mouseout","mouseover"]);ar("onPointerEnter",["pointerout","pointerover"]);ar("onPointerLeave",["pointerout","pointerover"]);Mn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Mn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Mn("onBeforeInput",["compositionend","keypress","textInput","paste"]);Mn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Mn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Mn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Pr="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(" "),Dm=new Set("cancel close invalid load scroll toggle".split(" ").concat(Pr));function nc(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,Op(r,t,void 0,e),e.currentTarget=null}function ld(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;nc(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;nc(s,l,d),o=c}}}if(ea)throw e=Oo,ea=!1,Oo=null,e}function ge(e,t){var n=t[Qo];n===void 0&&(n=t[Qo]=new Set);var r=e+"__bubble";n.has(r)||(cd(t,e,2,!1),n.add(r))}function so(e,t,n){var r=0;t&&(r|=4),cd(n,e,r,t)}var bs="_reactListening"+Math.random().toString(36).slice(2);function qr(e){if(!e[bs]){e[bs]=!0,gu.forEach(function(n){n!=="selectionchange"&&(Dm.has(n)||so(n,!1,e),so(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[bs]||(t[bs]=!0,so("selectionchange",!1,t))}}function cd(e,t,n,r){switch(Gu(t)){case 1:var s=tm;break;case 4:s=nm;break;default:s=Fi}n=s.bind(null,t,n,e),s=void 0,!Fo||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 ao(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=Nn(l),i===null)return;if(c=i.tag,c===5||c===6){r=o=i;continue e}l=l.parentNode}}r=r.return}Pu(function(){var d=o,f=Ai(n),m=[];e:{var p=id.get(e);if(p!==void 0){var x=Bi,w=e;switch(e){case"keypress":if(Ds(n)===0)break e;case"keydown":case"keyup":x=ym;break;case"focusin":w="focus",x=qa;break;case"focusout":w="blur",x=qa;break;case"beforeblur":case"afterblur":x=qa;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":x=Hl;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":x=am;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":x=wm;break;case rd:case sd:case ad:x=lm;break;case od:x=jm;break;case"scroll":x=rm;break;case"wheel":x=bm;break;case"copy":case"cut":case"paste":x=um;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":x=Gl}var v=(t&4)!==0,j=!v&&e==="scroll",h=v?p!==null?p+"Capture":null:p;v=[];for(var g=d,y;g!==null;){y=g;var S=y.stateNode;if(y.tag===5&&S!==null&&(y=S,h!==null&&(S=Gr(g,h),S!=null&&v.push(Zr(g,S,y)))),j)break;g=g.return}0<v.length&&(p=new x(p,w,null,n,f),m.push({event:p,listeners:v}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",x=e==="mouseout"||e==="pointerout",p&&n!==Lo&&(w=n.relatedTarget||n.fromElement)&&(Nn(w)||w[Kt]))break e;if((x||p)&&(p=f.window===f?f:(p=f.ownerDocument)?p.defaultView||p.parentWindow:window,x?(w=n.relatedTarget||n.toElement,x=d,w=w?Nn(w):null,w!==null&&(j=Fn(w),w!==j||w.tag!==5&&w.tag!==6)&&(w=null)):(x=null,w=d),x!==w)){if(v=Hl,S="onMouseLeave",h="onMouseEnter",g="mouse",(e==="pointerout"||e==="pointerover")&&(v=Gl,S="onPointerLeave",h="onPointerEnter",g="pointer"),j=x==null?p:Gn(x),y=w==null?p:Gn(w),p=new v(S,g+"leave",x,n,f),p.target=j,p.relatedTarget=y,S=null,Nn(f)===d&&(v=new v(h,g+"enter",w,n,f),v.target=y,v.relatedTarget=j,S=v),j=S,x&&w)t:{for(v=x,h=w,g=0,y=v;y;y=Bn(y))g++;for(y=0,S=h;S;S=Bn(S))y++;for(;0<g-y;)v=Bn(v),g--;for(;0<y-g;)h=Bn(h),y--;for(;g--;){if(v===h||h!==null&&v===h.alternate)break t;v=Bn(v),h=Bn(h)}v=null}else v=null;x!==null&&rc(m,p,x,v,!1),w!==null&&j!==null&&rc(m,j,w,v,!0)}}e:{if(p=d?Gn(d):window,x=p.nodeName&&p.nodeName.toLowerCase(),x==="select"||x==="input"&&p.type==="file")var k=Rm;else if(Ql(p))if(qu)k=$m;else{k=_m;var I=Pm}else(x=p.nodeName)&&x.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(k=Am);if(k&&(k=k(e,d))){Xu(m,k,n,f);break e}I&&I(e,p,d),e==="focusout"&&(I=p._wrapperState)&&I.controlled&&p.type==="number"&&Ro(p,"number",p.value)}switch(I=d?Gn(d):window,e){case"focusin":(Ql(I)||I.contentEditable==="true")&&(Hn=I,Wo=d,Fr=null);break;case"focusout":Fr=Wo=Hn=null;break;case"mousedown":Ho=!0;break;case"contextmenu":case"mouseup":case"dragend":Ho=!1,ec(m,n,f);break;case"selectionchange":if(Fm)break;case"keydown":case"keyup":ec(m,n,f)}var R;if(Ui)e:{switch(e){case"compositionstart":var _="onCompositionStart";break e;case"compositionend":_="onCompositionEnd";break e;case"compositionupdate":_="onCompositionUpdate";break e}_=void 0}else Wn?Qu(e,n)&&(_="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(_="onCompositionStart");_&&(Yu&&n.locale!=="ko"&&(Wn||_!=="onCompositionStart"?_==="onCompositionEnd"&&Wn&&(R=Ku()):(an=f,Oi="value"in an?an.value:an.textContent,Wn=!0)),I=aa(d,_),0<I.length&&(_=new Vl(_,e,null,n,f),m.push({event:_,listeners:I}),R?_.data=R:(R=Ju(n),R!==null&&(_.data=R)))),(R=Nm?Em(e,n):Tm(e,n))&&(d=aa(d,"onBeforeInput"),0<d.length&&(f=new Vl("onBeforeInput","beforeinput",null,n,f),m.push({event:f,listeners:d}),f.data=R))}ld(m,t)})}function Zr(e,t,n){return{instance:e,listener:t,currentTarget:n}}function aa(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=Gr(e,n),o!=null&&r.unshift(Zr(e,o,s)),o=Gr(e,t),o!=null&&r.push(Zr(e,o,s))),e=e.return}return r}function Bn(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function rc(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=Gr(n,o),c!=null&&i.unshift(Zr(n,c,l))):s||(c=Gr(n,o),c!=null&&i.push(Zr(n,c,l)))),n=n.return}i.length!==0&&e.push({event:t,listeners:i})}var Um=/\r\n?/g,Wm=/\u0000|\uFFFD/g;function sc(e){return(typeof e=="string"?e:""+e).replace(Um,`
38
+ `).replace(Wm,"")}function Cs(e,t,n){if(t=sc(t),sc(e)!==t&&n)throw Error(B(425))}function oa(){}var Vo=null,Go=null;function Ko(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 Yo=typeof setTimeout=="function"?setTimeout:void 0,Hm=typeof clearTimeout=="function"?clearTimeout:void 0,ac=typeof Promise=="function"?Promise:void 0,Vm=typeof queueMicrotask=="function"?queueMicrotask:typeof ac<"u"?function(e){return ac.resolve(null).then(e).catch(Gm)}:Yo;function Gm(e){setTimeout(function(){throw e})}function oo(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),Qr(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);Qr(t)}function dn(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 oc(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 mr=Math.random().toString(36).slice(2),$t="__reactFiber$"+mr,es="__reactProps$"+mr,Kt="__reactContainer$"+mr,Qo="__reactEvents$"+mr,Km="__reactListeners$"+mr,Ym="__reactHandles$"+mr;function Nn(e){var t=e[$t];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Kt]||n[$t]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=oc(e);e!==null;){if(n=e[$t])return n;e=oc(e)}return t}e=n,n=e.parentNode}return null}function ds(e){return e=e[$t]||e[Kt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Gn(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(B(33))}function Ia(e){return e[es]||null}var Jo=[],Kn=-1;function xn(e){return{current:e}}function ye(e){0>Kn||(e.current=Jo[Kn],Jo[Kn]=null,Kn--)}function me(e,t){Kn++,Jo[Kn]=e.current,e.current=t}var yn={},Ge=xn(yn),rt=xn(!1),Pn=yn;function or(e,t){var n=e.type.contextTypes;if(!n)return yn;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 st(e){return e=e.childContextTypes,e!=null}function ia(){ye(rt),ye(Ge)}function ic(e,t,n){if(Ge.current!==yn)throw Error(B(168));me(Ge,t),me(rt,n)}function ud(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(B(108,Pp(e)||"Unknown",s));return je({},n,r)}function la(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||yn,Pn=Ge.current,me(Ge,e),me(rt,rt.current),!0}function lc(e,t,n){var r=e.stateNode;if(!r)throw Error(B(169));n?(e=ud(e,t,Pn),r.__reactInternalMemoizedMergedChildContext=e,ye(rt),ye(Ge),me(Ge,e)):ye(rt),me(rt,n)}var Ut=null,Ra=!1,io=!1;function dd(e){Ut===null?Ut=[e]:Ut.push(e)}function Qm(e){Ra=!0,dd(e)}function wn(){if(!io&&Ut!==null){io=!0;var e=0,t=fe;try{var n=Ut;for(fe=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Ut=null,Ra=!1}catch(s){throw Ut!==null&&(Ut=Ut.slice(e+1)),Lu($i,wn),s}finally{fe=t,io=!1}}return null}var Yn=[],Qn=0,ca=null,ua=0,gt=[],yt=0,_n=null,Wt=1,Ht="";function kn(e,t){Yn[Qn++]=ua,Yn[Qn++]=ca,ca=e,ua=t}function fd(e,t,n){gt[yt++]=Wt,gt[yt++]=Ht,gt[yt++]=_n,_n=e;var r=Wt;e=Ht;var s=32-Tt(r)-1;r&=~(1<<s),n+=1;var o=32-Tt(t)+s;if(30<o){var i=s-s%5;o=(r&(1<<i)-1).toString(32),r>>=i,s-=i,Wt=1<<32-Tt(t)+s|n<<s|r,Ht=o+e}else Wt=1<<o|n<<s|r,Ht=e}function Hi(e){e.return!==null&&(kn(e,1),fd(e,1,0))}function Vi(e){for(;e===ca;)ca=Yn[--Qn],Yn[Qn]=null,ua=Yn[--Qn],Yn[Qn]=null;for(;e===_n;)_n=gt[--yt],gt[yt]=null,Ht=gt[--yt],gt[yt]=null,Wt=gt[--yt],gt[yt]=null}var ut=null,ct=null,ve=!1,Et=null;function pd(e,t){var n=vt(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 cc(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,ut=e,ct=dn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ut=e,ct=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=_n!==null?{id:Wt,overflow:Ht}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=vt(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ut=e,ct=null,!0):!1;default:return!1}}function Xo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function qo(e){if(ve){var t=ct;if(t){var n=t;if(!cc(e,t)){if(Xo(e))throw Error(B(418));t=dn(n.nextSibling);var r=ut;t&&cc(e,t)?pd(r,n):(e.flags=e.flags&-4097|2,ve=!1,ut=e)}}else{if(Xo(e))throw Error(B(418));e.flags=e.flags&-4097|2,ve=!1,ut=e}}}function uc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ut=e}function Ns(e){if(e!==ut)return!1;if(!ve)return uc(e),ve=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Ko(e.type,e.memoizedProps)),t&&(t=ct)){if(Xo(e))throw md(),Error(B(418));for(;t;)pd(e,t),t=dn(t.nextSibling)}if(uc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(B(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){ct=dn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ct=null}}else ct=ut?dn(e.stateNode.nextSibling):null;return!0}function md(){for(var e=ct;e;)e=dn(e.nextSibling)}function ir(){ct=ut=null,ve=!1}function Gi(e){Et===null?Et=[e]:Et.push(e)}var Jm=Xt.ReactCurrentBatchConfig;function br(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(B(309));var r=n.stateNode}if(!r)throw Error(B(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(B(284));if(!n._owner)throw Error(B(290,e))}return e}function Es(e,t){throw e=Object.prototype.toString.call(t),Error(B(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function dc(e){var t=e._init;return t(e._payload)}function hd(e){function t(h,g){if(e){var y=h.deletions;y===null?(h.deletions=[g],h.flags|=16):y.push(g)}}function n(h,g){if(!e)return null;for(;g!==null;)t(h,g),g=g.sibling;return null}function r(h,g){for(h=new Map;g!==null;)g.key!==null?h.set(g.key,g):h.set(g.index,g),g=g.sibling;return h}function s(h,g){return h=hn(h,g),h.index=0,h.sibling=null,h}function o(h,g,y){return h.index=y,e?(y=h.alternate,y!==null?(y=y.index,y<g?(h.flags|=2,g):y):(h.flags|=2,g)):(h.flags|=1048576,g)}function i(h){return e&&h.alternate===null&&(h.flags|=2),h}function l(h,g,y,S){return g===null||g.tag!==6?(g=ho(y,h.mode,S),g.return=h,g):(g=s(g,y),g.return=h,g)}function c(h,g,y,S){var k=y.type;return k===Un?f(h,g,y.props.children,S,y.key):g!==null&&(g.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===en&&dc(k)===g.type)?(S=s(g,y.props),S.ref=br(h,g,y),S.return=h,S):(S=Ys(y.type,y.key,y.props,null,h.mode,S),S.ref=br(h,g,y),S.return=h,S)}function d(h,g,y,S){return g===null||g.tag!==4||g.stateNode.containerInfo!==y.containerInfo||g.stateNode.implementation!==y.implementation?(g=go(y,h.mode,S),g.return=h,g):(g=s(g,y.children||[]),g.return=h,g)}function f(h,g,y,S,k){return g===null||g.tag!==7?(g=Rn(y,h.mode,S,k),g.return=h,g):(g=s(g,y),g.return=h,g)}function m(h,g,y){if(typeof g=="string"&&g!==""||typeof g=="number")return g=ho(""+g,h.mode,y),g.return=h,g;if(typeof g=="object"&&g!==null){switch(g.$$typeof){case gs:return y=Ys(g.type,g.key,g.props,null,h.mode,y),y.ref=br(h,null,g),y.return=h,y;case Dn:return g=go(g,h.mode,y),g.return=h,g;case en:var S=g._init;return m(h,S(g._payload),y)}if(Ir(g)||xr(g))return g=Rn(g,h.mode,y,null),g.return=h,g;Es(h,g)}return null}function p(h,g,y,S){var k=g!==null?g.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return k!==null?null:l(h,g,""+y,S);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case gs:return y.key===k?c(h,g,y,S):null;case Dn:return y.key===k?d(h,g,y,S):null;case en:return k=y._init,p(h,g,k(y._payload),S)}if(Ir(y)||xr(y))return k!==null?null:f(h,g,y,S,null);Es(h,y)}return null}function x(h,g,y,S,k){if(typeof S=="string"&&S!==""||typeof S=="number")return h=h.get(y)||null,l(g,h,""+S,k);if(typeof S=="object"&&S!==null){switch(S.$$typeof){case gs:return h=h.get(S.key===null?y:S.key)||null,c(g,h,S,k);case Dn:return h=h.get(S.key===null?y:S.key)||null,d(g,h,S,k);case en:var I=S._init;return x(h,g,y,I(S._payload),k)}if(Ir(S)||xr(S))return h=h.get(y)||null,f(g,h,S,k,null);Es(g,S)}return null}function w(h,g,y,S){for(var k=null,I=null,R=g,_=g=0,C=null;R!==null&&_<y.length;_++){R.index>_?(C=R,R=null):C=R.sibling;var z=p(h,R,y[_],S);if(z===null){R===null&&(R=C);break}e&&R&&z.alternate===null&&t(h,R),g=o(z,g,_),I===null?k=z:I.sibling=z,I=z,R=C}if(_===y.length)return n(h,R),ve&&kn(h,_),k;if(R===null){for(;_<y.length;_++)R=m(h,y[_],S),R!==null&&(g=o(R,g,_),I===null?k=R:I.sibling=R,I=R);return ve&&kn(h,_),k}for(R=r(h,R);_<y.length;_++)C=x(R,h,_,y[_],S),C!==null&&(e&&C.alternate!==null&&R.delete(C.key===null?_:C.key),g=o(C,g,_),I===null?k=C:I.sibling=C,I=C);return e&&R.forEach(function(D){return t(h,D)}),ve&&kn(h,_),k}function v(h,g,y,S){var k=xr(y);if(typeof k!="function")throw Error(B(150));if(y=k.call(y),y==null)throw Error(B(151));for(var I=k=null,R=g,_=g=0,C=null,z=y.next();R!==null&&!z.done;_++,z=y.next()){R.index>_?(C=R,R=null):C=R.sibling;var D=p(h,R,z.value,S);if(D===null){R===null&&(R=C);break}e&&R&&D.alternate===null&&t(h,R),g=o(D,g,_),I===null?k=D:I.sibling=D,I=D,R=C}if(z.done)return n(h,R),ve&&kn(h,_),k;if(R===null){for(;!z.done;_++,z=y.next())z=m(h,z.value,S),z!==null&&(g=o(z,g,_),I===null?k=z:I.sibling=z,I=z);return ve&&kn(h,_),k}for(R=r(h,R);!z.done;_++,z=y.next())z=x(R,h,_,z.value,S),z!==null&&(e&&z.alternate!==null&&R.delete(z.key===null?_:z.key),g=o(z,g,_),I===null?k=z:I.sibling=z,I=z);return e&&R.forEach(function(Y){return t(h,Y)}),ve&&kn(h,_),k}function j(h,g,y,S){if(typeof y=="object"&&y!==null&&y.type===Un&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case gs:e:{for(var k=y.key,I=g;I!==null;){if(I.key===k){if(k=y.type,k===Un){if(I.tag===7){n(h,I.sibling),g=s(I,y.props.children),g.return=h,h=g;break e}}else if(I.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===en&&dc(k)===I.type){n(h,I.sibling),g=s(I,y.props),g.ref=br(h,I,y),g.return=h,h=g;break e}n(h,I);break}else t(h,I);I=I.sibling}y.type===Un?(g=Rn(y.props.children,h.mode,S,y.key),g.return=h,h=g):(S=Ys(y.type,y.key,y.props,null,h.mode,S),S.ref=br(h,g,y),S.return=h,h=S)}return i(h);case Dn:e:{for(I=y.key;g!==null;){if(g.key===I)if(g.tag===4&&g.stateNode.containerInfo===y.containerInfo&&g.stateNode.implementation===y.implementation){n(h,g.sibling),g=s(g,y.children||[]),g.return=h,h=g;break e}else{n(h,g);break}else t(h,g);g=g.sibling}g=go(y,h.mode,S),g.return=h,h=g}return i(h);case en:return I=y._init,j(h,g,I(y._payload),S)}if(Ir(y))return w(h,g,y,S);if(xr(y))return v(h,g,y,S);Es(h,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,g!==null&&g.tag===6?(n(h,g.sibling),g=s(g,y),g.return=h,h=g):(n(h,g),g=ho(y,h.mode,S),g.return=h,h=g),i(h)):n(h,g)}return j}var lr=hd(!0),gd=hd(!1),da=xn(null),fa=null,Jn=null,Ki=null;function Yi(){Ki=Jn=fa=null}function Qi(e){var t=da.current;ye(da),e._currentValue=t}function Zo(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 rr(e,t){fa=e,Ki=Jn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(nt=!0),e.firstContext=null)}function wt(e){var t=e._currentValue;if(Ki!==e)if(e={context:e,memoizedValue:t,next:null},Jn===null){if(fa===null)throw Error(B(308));Jn=e,fa.dependencies={lanes:0,firstContext:e}}else Jn=Jn.next=e;return t}var En=null;function Ji(e){En===null?En=[e]:En.push(e)}function yd(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Ji(t)):(n.next=s.next,s.next=n),t.interleaved=n,Yt(e,r)}function Yt(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 tn=!1;function Xi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function vd(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 Vt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function fn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,oe&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Yt(e,n)}return s=r.interleaved,s===null?(t.next=t,Ji(r)):(t.next=s.next,s.next=t),r.interleaved=t,Yt(e,n)}function Us(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,Li(e,n)}}function fc(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 pa(e,t,n,r){var s=e.updateQueue;tn=!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 m=s.baseState;i=0,f=d=c=null,l=o;do{var p=l.lane,x=l.eventTime;if((r&p)===p){f!==null&&(f=f.next={eventTime:x,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var w=e,v=l;switch(p=t,x=n,v.tag){case 1:if(w=v.payload,typeof w=="function"){m=w.call(x,m,p);break e}m=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=v.payload,p=typeof w=="function"?w.call(x,m,p):w,p==null)break e;m=je({},m,p);break e;case 2:tn=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else x={eventTime:x,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},f===null?(d=f=x,c=m):f=f.next=x,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=m),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);$n|=i,e.lanes=i,e.memoizedState=m}}function pc(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(B(191,s));s.call(r)}}}var fs={},Ft=xn(fs),ts=xn(fs),ns=xn(fs);function Tn(e){if(e===fs)throw Error(B(174));return e}function qi(e,t){switch(me(ns,t),me(ts,e),me(Ft,fs),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:_o(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=_o(t,e)}ye(Ft),me(Ft,t)}function cr(){ye(Ft),ye(ts),ye(ns)}function xd(e){Tn(ns.current);var t=Tn(Ft.current),n=_o(t,e.type);t!==n&&(me(ts,e),me(Ft,n))}function Zi(e){ts.current===e&&(ye(Ft),ye(ts))}var we=xn(0);function ma(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 lo=[];function el(){for(var e=0;e<lo.length;e++)lo[e]._workInProgressVersionPrimary=null;lo.length=0}var Ws=Xt.ReactCurrentDispatcher,co=Xt.ReactCurrentBatchConfig,An=0,Se=null,Ee=null,Pe=null,ha=!1,Or=!1,rs=0,Xm=0;function We(){throw Error(B(321))}function tl(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!It(e[n],t[n]))return!1;return!0}function nl(e,t,n,r,s,o){if(An=o,Se=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Ws.current=e===null||e.memoizedState===null?th:nh,e=n(r,s),Or){o=0;do{if(Or=!1,rs=0,25<=o)throw Error(B(301));o+=1,Pe=Ee=null,t.updateQueue=null,Ws.current=rh,e=n(r,s)}while(Or)}if(Ws.current=ga,t=Ee!==null&&Ee.next!==null,An=0,Pe=Ee=Se=null,ha=!1,t)throw Error(B(300));return e}function rl(){var e=rs!==0;return rs=0,e}function _t(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Pe===null?Se.memoizedState=Pe=e:Pe=Pe.next=e,Pe}function St(){if(Ee===null){var e=Se.alternate;e=e!==null?e.memoizedState:null}else e=Ee.next;var t=Pe===null?Se.memoizedState:Pe.next;if(t!==null)Pe=t,Ee=e;else{if(e===null)throw Error(B(310));Ee=e,e={memoizedState:Ee.memoizedState,baseState:Ee.baseState,baseQueue:Ee.baseQueue,queue:Ee.queue,next:null},Pe===null?Se.memoizedState=Pe=e:Pe=Pe.next=e}return Pe}function ss(e,t){return typeof t=="function"?t(e):t}function uo(e){var t=St(),n=t.queue;if(n===null)throw Error(B(311));n.lastRenderedReducer=e;var r=Ee,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((An&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 m={lane:f,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=m,i=r):c=c.next=m,Se.lanes|=f,$n|=f}d=d.next}while(d!==null&&d!==o);c===null?i=r:c.next=l,It(r,t.memoizedState)||(nt=!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,Se.lanes|=o,$n|=o,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function fo(e){var t=St(),n=t.queue;if(n===null)throw Error(B(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);It(o,t.memoizedState)||(nt=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function wd(){}function Sd(e,t){var n=Se,r=St(),s=t(),o=!It(r.memoizedState,s);if(o&&(r.memoizedState=s,nt=!0),r=r.queue,sl(bd.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||Pe!==null&&Pe.memoizedState.tag&1){if(n.flags|=2048,as(9,kd.bind(null,n,r,s,t),void 0,null),_e===null)throw Error(B(349));An&30||jd(n,t,s)}return s}function jd(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Se.updateQueue,t===null?(t={lastEffect:null,stores:null},Se.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function kd(e,t,n,r){t.value=n,t.getSnapshot=r,Cd(t)&&Nd(e)}function bd(e,t,n){return n(function(){Cd(t)&&Nd(e)})}function Cd(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!It(e,n)}catch{return!0}}function Nd(e){var t=Yt(e,1);t!==null&&zt(t,e,1,-1)}function mc(e){var t=_t();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:e},t.queue=e,e=e.dispatch=eh.bind(null,Se,e),[t.memoizedState,e]}function as(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Se.updateQueue,t===null?(t={lastEffect:null,stores:null},Se.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 Ed(){return St().memoizedState}function Hs(e,t,n,r){var s=_t();Se.flags|=e,s.memoizedState=as(1|t,n,void 0,r===void 0?null:r)}function Pa(e,t,n,r){var s=St();r=r===void 0?null:r;var o=void 0;if(Ee!==null){var i=Ee.memoizedState;if(o=i.destroy,r!==null&&tl(r,i.deps)){s.memoizedState=as(t,n,o,r);return}}Se.flags|=e,s.memoizedState=as(1|t,n,o,r)}function hc(e,t){return Hs(8390656,8,e,t)}function sl(e,t){return Pa(2048,8,e,t)}function Td(e,t){return Pa(4,2,e,t)}function zd(e,t){return Pa(4,4,e,t)}function Id(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 Rd(e,t,n){return n=n!=null?n.concat([e]):null,Pa(4,4,Id.bind(null,t,e),n)}function al(){}function Pd(e,t){var n=St();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&tl(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function _d(e,t){var n=St();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&tl(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Ad(e,t,n){return An&21?(It(n,t)||(n=Ou(),Se.lanes|=n,$n|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,nt=!0),e.memoizedState=n)}function qm(e,t){var n=fe;fe=n!==0&&4>n?n:4,e(!0);var r=co.transition;co.transition={};try{e(!1),t()}finally{fe=n,co.transition=r}}function $d(){return St().memoizedState}function Zm(e,t,n){var r=mn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ld(e))Md(t,n);else if(n=yd(e,t,n,r),n!==null){var s=Je();zt(n,e,r,s),Fd(n,t,r)}}function eh(e,t,n){var r=mn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ld(e))Md(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,It(l,i)){var c=t.interleaved;c===null?(s.next=s,Ji(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=yd(e,t,s,r),n!==null&&(s=Je(),zt(n,e,r,s),Fd(n,t,r))}}function Ld(e){var t=e.alternate;return e===Se||t!==null&&t===Se}function Md(e,t){Or=ha=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Fd(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Li(e,n)}}var ga={readContext:wt,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},th={readContext:wt,useCallback:function(e,t){return _t().memoizedState=[e,t===void 0?null:t],e},useContext:wt,useEffect:hc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Hs(4194308,4,Id.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Hs(4194308,4,e,t)},useInsertionEffect:function(e,t){return Hs(4,2,e,t)},useMemo:function(e,t){var n=_t();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=_t();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=Zm.bind(null,Se,e),[r.memoizedState,e]},useRef:function(e){var t=_t();return e={current:e},t.memoizedState=e},useState:mc,useDebugValue:al,useDeferredValue:function(e){return _t().memoizedState=e},useTransition:function(){var e=mc(!1),t=e[0];return e=qm.bind(null,e[1]),_t().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Se,s=_t();if(ve){if(n===void 0)throw Error(B(407));n=n()}else{if(n=t(),_e===null)throw Error(B(349));An&30||jd(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,hc(bd.bind(null,r,o,e),[e]),r.flags|=2048,as(9,kd.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=_t(),t=_e.identifierPrefix;if(ve){var n=Ht,r=Wt;n=(r&~(1<<32-Tt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=rs++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=Xm++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},nh={readContext:wt,useCallback:Pd,useContext:wt,useEffect:sl,useImperativeHandle:Rd,useInsertionEffect:Td,useLayoutEffect:zd,useMemo:_d,useReducer:uo,useRef:Ed,useState:function(){return uo(ss)},useDebugValue:al,useDeferredValue:function(e){var t=St();return Ad(t,Ee.memoizedState,e)},useTransition:function(){var e=uo(ss)[0],t=St().memoizedState;return[e,t]},useMutableSource:wd,useSyncExternalStore:Sd,useId:$d,unstable_isNewReconciler:!1},rh={readContext:wt,useCallback:Pd,useContext:wt,useEffect:sl,useImperativeHandle:Rd,useInsertionEffect:Td,useLayoutEffect:zd,useMemo:_d,useReducer:fo,useRef:Ed,useState:function(){return fo(ss)},useDebugValue:al,useDeferredValue:function(e){var t=St();return Ee===null?t.memoizedState=e:Ad(t,Ee.memoizedState,e)},useTransition:function(){var e=fo(ss)[0],t=St().memoizedState;return[e,t]},useMutableSource:wd,useSyncExternalStore:Sd,useId:$d,unstable_isNewReconciler:!1};function Ct(e,t){if(e&&e.defaultProps){t=je({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function ei(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:je({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var _a={isMounted:function(e){return(e=e._reactInternals)?Fn(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Je(),s=mn(e),o=Vt(r,s);o.payload=t,n!=null&&(o.callback=n),t=fn(e,o,s),t!==null&&(zt(t,e,s,r),Us(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Je(),s=mn(e),o=Vt(r,s);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=fn(e,o,s),t!==null&&(zt(t,e,s,r),Us(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Je(),r=mn(e),s=Vt(n,r);s.tag=2,t!=null&&(s.callback=t),t=fn(e,s,r),t!==null&&(zt(t,e,r,n),Us(t,e,r))}};function gc(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?!Xr(n,r)||!Xr(s,o):!0}function Od(e,t,n){var r=!1,s=yn,o=t.contextType;return typeof o=="object"&&o!==null?o=wt(o):(s=st(t)?Pn:Ge.current,r=t.contextTypes,o=(r=r!=null)?or(e,s):yn),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=_a,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function yc(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&&_a.enqueueReplaceState(t,t.state,null)}function ti(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},Xi(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=wt(o):(o=st(t)?Pn:Ge.current,s.context=or(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(ei(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&&_a.enqueueReplaceState(s,s.state,null),pa(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function ur(e,t){try{var n="",r=t;do n+=Rp(r),r=r.return;while(r);var s=n}catch(o){s=`
39
39
  Error generating stack: `+o.message+`
40
- `+o.stack}return{value:e,source:t,stack:s,digest:null}}function po(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function ni(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var rh=typeof WeakMap=="function"?WeakMap:Map;function Dd(e,t,n){n=Vt(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){ya||(ya=!0,fi=r),ni(e,t)},n}function Ud(e,t,n){n=Vt(-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(){ni(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){ni(e,t),typeof r!="function"&&(pn===null?pn=new Set([this]):pn.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function xc(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new rh;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=yh.bind(null,e,t,n),t.then(e,e))}function wc(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 Sc(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=Vt(-1,1),t.tag=2,fn(n,t,1))),n.lanes|=1),e)}var sh=Xt.ReactCurrentOwner,nt=!1;function Ye(e,t,n,r){t.child=e===null?yd(t,null,n,r):lr(t,e.child,n,r)}function jc(e,t,n,r,s){n=n.render;var o=t.ref;return rr(t,s),r=rl(e,t,n,r,o,s),n=sl(),e!==null&&!nt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,Qt(e,t,s)):(ve&&n&&Vi(t),t.flags|=1,Ye(e,t,r,s),t.child)}function kc(e,t,n,r,s){if(e===null){var o=n.type;return typeof o=="function"&&!ml(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,Wd(e,t,o,r,s)):(e=Ks(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:Jr,n(i,r)&&e.ref===t.ref)return Qt(e,t,s)}return t.flags|=1,e=hn(o,r),e.ref=t.ref,e.return=t,t.child=e}function Wd(e,t,n,r,s){if(e!==null){var o=e.memoizedProps;if(Jr(o,r)&&e.ref===t.ref)if(nt=!1,t.pendingProps=r=o,(e.lanes&s)!==0)e.flags&131072&&(nt=!0);else return t.lanes=e.lanes,Qt(e,t,s)}return ri(e,t,n,r,s)}function Hd(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},me(qn,lt),lt|=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,me(qn,lt),lt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,me(qn,lt),lt|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,me(qn,lt),lt|=r;return Ye(e,t,s,n),t.child}function Vd(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function ri(e,t,n,r,s){var o=st(n)?Pn:Ge.current;return o=or(t,o),rr(t,s),n=rl(e,t,n,r,o,s),r=sl(),e!==null&&!nt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,Qt(e,t,s)):(ve&&r&&Vi(t),t.flags|=1,Ye(e,t,n,s),t.child)}function bc(e,t,n,r,s){if(st(n)){var o=!0;ia(t)}else o=!1;if(rr(t,s),t.stateNode===null)Hs(e,t),Bd(t,n,r),ti(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=wt(d):(d=st(n)?Pn:Ge.current,d=or(t,d));var f=n.getDerivedStateFromProps,m=typeof f=="function"||typeof i.getSnapshotBeforeUpdate=="function";m||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==r||c!==d)&&vc(t,i,r,d),tn=!1;var p=t.memoizedState;i.state=p,fa(t,r,i,s),c=t.memoizedState,l!==r||p!==c||rt.current||tn?(typeof f=="function"&&(ei(t,n,f,r),c=t.memoizedState),(l=tn||yc(t,n,l,r,p,c,d))?(m||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,xd(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:Ct(t.type,l),i.props=d,m=t.pendingProps,p=i.context,c=n.contextType,typeof c=="object"&&c!==null?c=wt(c):(c=st(n)?Pn:Ge.current,c=or(t,c));var x=n.getDerivedStateFromProps;(f=typeof x=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==m||p!==c)&&vc(t,i,r,c),tn=!1,p=t.memoizedState,i.state=p,fa(t,r,i,s);var w=t.memoizedState;l!==m||p!==w||rt.current||tn?(typeof x=="function"&&(ei(t,n,x,r),w=t.memoizedState),(d=tn||yc(t,n,d,r,p,w,c)||!1)?(f||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,w,c),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,w,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=w),i.props=r,i.state=w,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 si(e,t,n,r,o,s)}function si(e,t,n,r,s,o){Vd(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return s&&cc(t,n,!1),Qt(e,t,o);r=t.stateNode,sh.current=t;var l=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=lr(t,e.child,null,o),t.child=lr(t,null,l,o)):Ye(e,t,l,o),t.memoizedState=r.state,s&&cc(t,n,!0),t.child}function Gd(e){var t=e.stateNode;t.pendingContext?lc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&lc(e,t.context,!1),Zi(e,t.containerInfo)}function Cc(e,t,n,r,s){return ir(),Ki(s),t.flags|=256,Ye(e,t,n,r),t.child}var ai={dehydrated:null,treeContext:null,retryLane:0};function oi(e){return{baseLanes:e,cachePool:null,transitions:null}}function Kd(e,t,n){var r=t.pendingProps,s=we.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),me(we,s&1),e===null)return qo(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=$a(i,r,0,null),e=Rn(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=oi(n),t.memoizedState=ai,e):il(t,i));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return ah(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=hn(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?o=hn(l,o):(o=Rn(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?oi(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},o.memoizedState=i,o.childLanes=e.childLanes&~n,t.memoizedState=ai,r}return o=e.child,e=o.sibling,r=hn(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 il(e,t){return t=$a({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Es(e,t,n,r){return r!==null&&Ki(r),lr(t,e.child,null,n),e=il(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function ah(e,t,n,r,s,o,i){if(n)return t.flags&256?(t.flags&=-257,r=po(Error(B(422))),Es(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,s=t.mode,r=$a({mode:"visible",children:r.children},s,0,null),o=Rn(o,s,i,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&lr(t,e.child,null,i),t.child.memoizedState=oi(i),t.memoizedState=ai,o);if(!(t.mode&1))return Es(e,t,i,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(B(419)),r=po(o,r,void 0),Es(e,t,i,r)}if(l=(i&e.childLanes)!==0,nt||l){if(r=_e,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,Yt(e,s),zt(r,e,s,-1))}return pl(),r=po(Error(B(421))),Es(e,t,i,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=vh.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,ct=dn(s.nextSibling),ut=t,ve=!0,Et=null,e!==null&&(gt[yt++]=Wt,gt[yt++]=Ht,gt[yt++]=_n,Wt=e.id,Ht=e.overflow,_n=t),t=il(t,r.children),t.flags|=4096,t)}function Nc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Zo(e.return,t,n)}function mo(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 Yd(e,t,n){var r=t.pendingProps,s=r.revealOrder,o=r.tail;if(Ye(e,t,r.children,n),r=we.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&&Nc(e,n,t);else if(e.tag===19)Nc(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(me(we,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&&pa(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),mo(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&&pa(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}mo(t,!0,n,null,o);break;case"together":mo(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Hs(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Qt(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),$n|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(B(153));if(t.child!==null){for(e=t.child,n=hn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=hn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function oh(e,t,n){switch(t.tag){case 3:Gd(t),ir();break;case 5:wd(t);break;case 1:st(t.type)&&ia(t);break;case 4:Zi(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;me(ua,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(me(we,we.current&1),t.flags|=128,null):n&t.child.childLanes?Kd(e,t,n):(me(we,we.current&1),e=Qt(e,t,n),e!==null?e.sibling:null);me(we,we.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Yd(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),me(we,we.current),r)break;return null;case 22:case 23:return t.lanes=0,Hd(e,t,n)}return Qt(e,t,n)}var Qd,ii,Jd,Xd;Qd=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}};ii=function(){};Jd=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Tn(Ft.current);var o=null;switch(n){case"input":s=zo(e,s),r=zo(e,r),o=[];break;case"select":s=je({},s,{value:void 0}),r=je({},r,{value:void 0}),o=[];break;case"textarea":s=Po(e,s),r=Po(e,r),o=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=aa)}Ao(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"&&(Wr.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"&&(Wr.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&ge("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)}};Xd=function(e,t,n,r){n!==r&&(t.flags|=4)};function br(e,t){if(!ve)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 ih(e,t,n){var r=t.pendingProps;switch(Gi(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 st(t.type)&&oa(),He(t),null;case 3:return r=t.stateNode,cr(),ye(rt),ye(Ge),tl(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Cs(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Et!==null&&(hi(Et),Et=null))),ii(e,t),He(t),null;case 5:el(t);var s=Tn(ts.current);if(n=t.type,e!==null&&t.stateNode!=null)Jd(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(B(166));return He(t),null}if(e=Tn(Ft.current),Cs(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[$t]=t,r[Zr]=o,e=(t.mode&1)!==0,n){case"dialog":ge("cancel",r),ge("close",r);break;case"iframe":case"object":case"embed":ge("load",r);break;case"video":case"audio":for(s=0;s<Rr.length;s++)ge(Rr[s],r);break;case"source":ge("error",r);break;case"img":case"image":case"link":ge("error",r),ge("load",r);break;case"details":ge("toggle",r);break;case"input":$l(r,o),ge("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},ge("invalid",r);break;case"textarea":Ml(r,o),ge("invalid",r)}Ao(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&&bs(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&bs(r.textContent,l,e),s=["children",""+l]):Wr.hasOwnProperty(i)&&l!=null&&i==="onScroll"&&ge("scroll",r)}switch(n){case"input":gs(r),Ll(r,o,!0);break;case"textarea":gs(r),Fl(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=aa)}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=Cu(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[$t]=t,e[Zr]=r,Qd(e,t,!1,!1),t.stateNode=e;e:{switch(i=$o(n,r),n){case"dialog":ge("cancel",e),ge("close",e),s=r;break;case"iframe":case"object":case"embed":ge("load",e),s=r;break;case"video":case"audio":for(s=0;s<Rr.length;s++)ge(Rr[s],e);s=r;break;case"source":ge("error",e),s=r;break;case"img":case"image":case"link":ge("error",e),ge("load",e),s=r;break;case"details":ge("toggle",e),s=r;break;case"input":$l(e,r),s=zo(e,r),ge("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=je({},r,{value:void 0}),ge("invalid",e);break;case"textarea":Ml(e,r),s=Po(e,r),ge("invalid",e);break;default:s=r}Ao(n,s),l=s;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?Tu(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&Nu(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Hr(e,c):typeof c=="number"&&Hr(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Wr.hasOwnProperty(o)?c!=null&&o==="onScroll"&&ge("scroll",e):c!=null&&Ri(e,o,c,i))}switch(n){case"input":gs(e),Ll(e,r,!1);break;case"textarea":gs(e),Fl(e);break;case"option":r.value!=null&&e.setAttribute("value",""+gn(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?Zn(e,!!r.multiple,o,!1):r.defaultValue!=null&&Zn(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=aa)}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)Xd(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(B(166));if(n=Tn(ts.current),Tn(Ft.current),Cs(t)){if(r=t.stateNode,n=t.memoizedProps,r[$t]=t,(o=r.nodeValue!==n)&&(e=ut,e!==null))switch(e.tag){case 3:bs(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&bs(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[$t]=t,t.stateNode=r}return He(t),null;case 13:if(ye(we),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ve&&ct!==null&&t.mode&1&&!(t.flags&128))hd(),ir(),t.flags|=98560,o=!1;else if(o=Cs(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(B(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(B(317));o[$t]=t}else ir(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;He(t),o=!1}else Et!==null&&(hi(Et),Et=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||we.current&1?Te===0&&(Te=3):pl())),t.updateQueue!==null&&(t.flags|=4),He(t),null);case 4:return cr(),ii(e,t),e===null&&Xr(t.stateNode.containerInfo),He(t),null;case 10:return Ji(t.type._context),He(t),null;case 17:return st(t.type)&&oa(),He(t),null;case 19:if(ye(we),o=t.memoizedState,o===null)return He(t),null;if(r=(t.flags&128)!==0,i=o.rendering,i===null)if(r)br(o,!1);else{if(Te!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=pa(e),i!==null){for(t.flags|=128,br(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 me(we,we.current&1|2),t.child}e=e.sibling}o.tail!==null&&be()>dr&&(t.flags|=128,r=!0,br(o,!1),t.lanes=4194304)}else{if(!r)if(e=pa(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),br(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!ve)return He(t),null}else 2*be()-o.renderingStartTime>dr&&n!==1073741824&&(t.flags|=128,r=!0,br(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=be(),t.sibling=null,n=we.current,me(we,r?n&1|2:n&1),t):(He(t),null);case 22:case 23:return fl(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?lt&1073741824&&(He(t),t.subtreeFlags&6&&(t.flags|=8192)):He(t),null;case 24:return null;case 25:return null}throw Error(B(156,t.tag))}function lh(e,t){switch(Gi(t),t.tag){case 1:return st(t.type)&&oa(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return cr(),ye(rt),ye(Ge),tl(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return el(t),null;case 13:if(ye(we),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(B(340));ir()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ye(we),null;case 4:return cr(),null;case 10:return Ji(t.type._context),null;case 22:case 23:return fl(),null;case 24:return null;default:return null}}var Ts=!1,Ve=!1,ch=typeof WeakSet=="function"?WeakSet:Set,Q=null;function Xn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ke(e,t,r)}else n.current=null}function li(e,t,n){try{n()}catch(r){ke(e,t,r)}}var Ec=!1;function uh(e,t){if(Vo=na,e=nd(),Hi(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,m=e,p=null;t:for(;;){for(var x;m!==n||s!==0&&m.nodeType!==3||(l=i+s),m!==o||r!==0&&m.nodeType!==3||(c=i+r),m.nodeType===3&&(i+=m.nodeValue.length),(x=m.firstChild)!==null;)p=m,m=x;for(;;){if(m===e)break t;if(p===n&&++d===s&&(l=i),p===o&&++f===r&&(c=i),(x=m.nextSibling)!==null)break;m=p,p=m.parentNode}m=x}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Go={focusedElem:e,selectionRange:n},na=!1,Q=t;Q!==null;)if(t=Q,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Q=e;else for(;Q!==null;){t=Q;try{var w=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var v=w.memoizedProps,j=w.memoizedState,h=t.stateNode,g=h.getSnapshotBeforeUpdate(t.elementType===t.type?v:Ct(t.type,v),j);h.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(B(163))}}catch(S){ke(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,Q=e;break}Q=t.return}return w=Ec,Ec=!1,w}function Or(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&&li(t,n,o)}s=s.next}while(s!==r)}}function _a(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 ci(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 qd(e){var t=e.alternate;t!==null&&(e.alternate=null,qd(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[$t],delete t[Zr],delete t[Qo],delete t[Gm],delete t[Km])),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 Zd(e){return e.tag===5||e.tag===3||e.tag===4}function Tc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Zd(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 ui(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=aa));else if(r!==4&&(e=e.child,e!==null))for(ui(e,t,n),e=e.sibling;e!==null;)ui(e,t,n),e=e.sibling}function di(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(di(e,t,n),e=e.sibling;e!==null;)di(e,t,n),e=e.sibling}var Me=null,Nt=!1;function Zt(e,t,n){for(n=n.child;n!==null;)ef(e,t,n),n=n.sibling}function ef(e,t,n){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(Ca,n)}catch{}switch(n.tag){case 5:Ve||Xn(n,t);case 6:var r=Me,s=Nt;Me=null,Zt(e,t,n),Me=r,Nt=s,Me!==null&&(Nt?(e=Me,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Me.removeChild(n.stateNode));break;case 18:Me!==null&&(Nt?(e=Me,n=n.stateNode,e.nodeType===8?oo(e.parentNode,n):e.nodeType===1&&oo(e,n),Yr(e)):oo(Me,n.stateNode));break;case 4:r=Me,s=Nt,Me=n.stateNode.containerInfo,Nt=!0,Zt(e,t,n),Me=r,Nt=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)&&li(n,t,i),s=s.next}while(s!==r)}Zt(e,t,n);break;case 1:if(!Ve&&(Xn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){ke(n,t,l)}Zt(e,t,n);break;case 21:Zt(e,t,n);break;case 22:n.mode&1?(Ve=(r=Ve)||n.memoizedState!==null,Zt(e,t,n),Ve=r):Zt(e,t,n);break;default:Zt(e,t,n)}}function zc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new ch),t.forEach(function(r){var s=xh.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function bt(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:Me=l.stateNode,Nt=!1;break e;case 3:Me=l.stateNode.containerInfo,Nt=!0;break e;case 4:Me=l.stateNode.containerInfo,Nt=!0;break e}l=l.return}if(Me===null)throw Error(B(160));ef(o,i,s),Me=null,Nt=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(d){ke(s,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)tf(t,e),t=t.sibling}function tf(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(bt(t,e),Pt(e),r&4){try{Or(3,e,e.return),_a(3,e)}catch(v){ke(e,e.return,v)}try{Or(5,e,e.return)}catch(v){ke(e,e.return,v)}}break;case 1:bt(t,e),Pt(e),r&512&&n!==null&&Xn(n,n.return);break;case 5:if(bt(t,e),Pt(e),r&512&&n!==null&&Xn(n,n.return),e.flags&32){var s=e.stateNode;try{Hr(s,"")}catch(v){ke(e,e.return,v)}}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&&ku(s,o),$o(l,i);var d=$o(l,o);for(i=0;i<c.length;i+=2){var f=c[i],m=c[i+1];f==="style"?Tu(s,m):f==="dangerouslySetInnerHTML"?Nu(s,m):f==="children"?Hr(s,m):Ri(s,f,m,d)}switch(l){case"input":Io(s,o);break;case"textarea":bu(s,o);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var x=o.value;x!=null?Zn(s,!!o.multiple,x,!1):p!==!!o.multiple&&(o.defaultValue!=null?Zn(s,!!o.multiple,o.defaultValue,!0):Zn(s,!!o.multiple,o.multiple?[]:"",!1))}s[Zr]=o}catch(v){ke(e,e.return,v)}}break;case 6:if(bt(t,e),Pt(e),r&4){if(e.stateNode===null)throw Error(B(162));s=e.stateNode,o=e.memoizedProps;try{s.nodeValue=o}catch(v){ke(e,e.return,v)}}break;case 3:if(bt(t,e),Pt(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Yr(t.containerInfo)}catch(v){ke(e,e.return,v)}break;case 4:bt(t,e),Pt(e);break;case 13:bt(t,e),Pt(e),s=e.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(ul=be())),r&4&&zc(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Ve=(d=Ve)||f,bt(t,e),Ve=d):bt(t,e),Pt(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(Q=e,f=e.child;f!==null;){for(m=Q=f;Q!==null;){switch(p=Q,x=p.child,p.tag){case 0:case 11:case 14:case 15:Or(4,p,p.return);break;case 1:Xn(p,p.return);var w=p.stateNode;if(typeof w.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,w.props=t.memoizedProps,w.state=t.memoizedState,w.componentWillUnmount()}catch(v){ke(r,n,v)}}break;case 5:Xn(p,p.return);break;case 22:if(p.memoizedState!==null){Rc(m);continue}}x!==null?(x.return=p,Q=x):Rc(m)}f=f.sibling}e:for(f=null,m=e;;){if(m.tag===5){if(f===null){f=m;try{s=m.stateNode,d?(o=s.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(l=m.stateNode,c=m.memoizedProps.style,i=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=Eu("display",i))}catch(v){ke(e,e.return,v)}}}else if(m.tag===6){if(f===null)try{m.stateNode.nodeValue=d?"":m.memoizedProps}catch(v){ke(e,e.return,v)}}else if((m.tag!==22&&m.tag!==23||m.memoizedState===null||m===e)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===e)break e;for(;m.sibling===null;){if(m.return===null||m.return===e)break e;f===m&&(f=null),m=m.return}f===m&&(f=null),m.sibling.return=m.return,m=m.sibling}}break;case 19:bt(t,e),Pt(e),r&4&&zc(e);break;case 21:break;default:bt(t,e),Pt(e)}}function Pt(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Zd(n)){var r=n;break e}n=n.return}throw Error(B(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Hr(s,""),r.flags&=-33);var o=Tc(e);di(e,o,s);break;case 3:case 4:var i=r.stateNode.containerInfo,l=Tc(e);ui(e,l,i);break;default:throw Error(B(161))}}catch(c){ke(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function dh(e,t,n){Q=e,nf(e)}function nf(e,t,n){for(var r=(e.mode&1)!==0;Q!==null;){var s=Q,o=s.child;if(s.tag===22&&r){var i=s.memoizedState!==null||Ts;if(!i){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Ve;l=Ts;var d=Ve;if(Ts=i,(Ve=c)&&!d)for(Q=s;Q!==null;)i=Q,c=i.child,i.tag===22&&i.memoizedState!==null?Pc(s):c!==null?(c.return=i,Q=c):Pc(s);for(;o!==null;)Q=o,nf(o),o=o.sibling;Q=s,Ts=l,Ve=d}Ic(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,Q=o):Ic(e)}}function Ic(e){for(;Q!==null;){var t=Q;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Ve||_a(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:Ct(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&mc(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}mc(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 m=f.dehydrated;m!==null&&Yr(m)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(B(163))}Ve||t.flags&512&&ci(t)}catch(p){ke(t,t.return,p)}}if(t===e){Q=null;break}if(n=t.sibling,n!==null){n.return=t.return,Q=n;break}Q=t.return}}function Rc(e){for(;Q!==null;){var t=Q;if(t===e){Q=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Q=n;break}Q=t.return}}function Pc(e){for(;Q!==null;){var t=Q;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{_a(4,t)}catch(c){ke(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){ke(t,s,c)}}var o=t.return;try{ci(t)}catch(c){ke(t,o,c)}break;case 5:var i=t.return;try{ci(t)}catch(c){ke(t,i,c)}}}catch(c){ke(t,t.return,c)}if(t===e){Q=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Q=l;break}Q=t.return}}var fh=Math.ceil,ga=Xt.ReactCurrentDispatcher,ll=Xt.ReactCurrentOwner,xt=Xt.ReactCurrentBatchConfig,oe=0,_e=null,Ne=null,Fe=0,lt=0,qn=xn(0),Te=0,as=null,$n=0,Aa=0,cl=0,Br=null,tt=null,ul=0,dr=1/0,Dt=null,ya=!1,fi=null,pn=null,zs=!1,on=null,va=0,Dr=0,pi=null,Vs=-1,Gs=0;function Je(){return oe&6?be():Vs!==-1?Vs:Vs=be()}function mn(e){return e.mode&1?oe&2&&Fe!==0?Fe&-Fe:Qm.transition!==null?(Gs===0&&(Gs=Bu()),Gs):(e=fe,e!==0||(e=window.event,e=e===void 0?16:Ku(e.type)),e):1}function zt(e,t,n,r){if(50<Dr)throw Dr=0,pi=null,Error(B(185));ls(e,n,r),(!(oe&2)||e!==_e)&&(e===_e&&(!(oe&2)&&(Aa|=n),Te===4&&sn(e,Fe)),at(e,r),n===1&&oe===0&&!(t.mode&1)&&(dr=be()+500,Ia&&wn()))}function at(e,t){var n=e.callbackNode;Qp(e,t);var r=ta(e,e===_e?Fe:0);if(r===0)n!==null&&Dl(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Dl(n),t===1)e.tag===0?Ym(_c.bind(null,e)):fd(_c.bind(null,e)),Hm(function(){!(oe&6)&&wn()}),n=null;else{switch(Du(r)){case 1:n=Li;break;case 4:n=Fu;break;case 16:n=ea;break;case 536870912:n=Ou;break;default:n=ea}n=df(n,rf.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function rf(e,t){if(Vs=-1,Gs=0,oe&6)throw Error(B(327));var n=e.callbackNode;if(sr()&&e.callbackNode!==n)return null;var r=ta(e,e===_e?Fe:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=xa(e,r);else{t=r;var s=oe;oe|=2;var o=af();(_e!==e||Fe!==t)&&(Dt=null,dr=be()+500,In(e,t));do try{hh();break}catch(l){sf(e,l)}while(!0);Qi(),ga.current=o,oe=s,Ne!==null?t=0:(_e=null,Fe=0,t=Te)}if(t!==0){if(t===2&&(s=Bo(e),s!==0&&(r=s,t=mi(e,s))),t===1)throw n=as,In(e,0),sn(e,r),at(e,be()),n;if(t===6)sn(e,r);else{if(s=e.current.alternate,!(r&30)&&!ph(s)&&(t=xa(e,r),t===2&&(o=Bo(e),o!==0&&(r=o,t=mi(e,o))),t===1))throw n=as,In(e,0),sn(e,r),at(e,be()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(B(345));case 2:bn(e,tt,Dt);break;case 3:if(sn(e,r),(r&130023424)===r&&(t=ul+500-be(),10<t)){if(ta(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Je(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=Yo(bn.bind(null,e,tt,Dt),t);break}bn(e,tt,Dt);break;case 4:if(sn(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var i=31-Tt(r);o=1<<i,i=t[i],i>s&&(s=i),r&=~o}if(r=s,r=be()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*fh(r/1960))-r,10<r){e.timeoutHandle=Yo(bn.bind(null,e,tt,Dt),r);break}bn(e,tt,Dt);break;case 5:bn(e,tt,Dt);break;default:throw Error(B(329))}}}return at(e,be()),e.callbackNode===n?rf.bind(null,e):null}function mi(e,t){var n=Br;return e.current.memoizedState.isDehydrated&&(In(e,t).flags|=256),e=xa(e,t),e!==2&&(t=tt,tt=n,t!==null&&hi(t)),e}function hi(e){tt===null?tt=e:tt.push.apply(tt,e)}function ph(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(!It(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 sn(e,t){for(t&=~cl,t&=~Aa,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Tt(t),r=1<<n;e[n]=-1,t&=~r}}function _c(e){if(oe&6)throw Error(B(327));sr();var t=ta(e,0);if(!(t&1))return at(e,be()),null;var n=xa(e,t);if(e.tag!==0&&n===2){var r=Bo(e);r!==0&&(t=r,n=mi(e,r))}if(n===1)throw n=as,In(e,0),sn(e,t),at(e,be()),n;if(n===6)throw Error(B(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,bn(e,tt,Dt),at(e,be()),null}function dl(e,t){var n=oe;oe|=1;try{return e(t)}finally{oe=n,oe===0&&(dr=be()+500,Ia&&wn())}}function Ln(e){on!==null&&on.tag===0&&!(oe&6)&&sr();var t=oe;oe|=1;var n=xt.transition,r=fe;try{if(xt.transition=null,fe=1,e)return e()}finally{fe=r,xt.transition=n,oe=t,!(oe&6)&&wn()}}function fl(){lt=qn.current,ye(qn)}function In(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Wm(n)),Ne!==null)for(n=Ne.return;n!==null;){var r=n;switch(Gi(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&oa();break;case 3:cr(),ye(rt),ye(Ge),tl();break;case 5:el(r);break;case 4:cr();break;case 13:ye(we);break;case 19:ye(we);break;case 10:Ji(r.type._context);break;case 22:case 23:fl()}n=n.return}if(_e=e,Ne=e=hn(e.current,null),Fe=lt=t,Te=0,as=null,cl=Aa=$n=0,tt=Br=null,En!==null){for(t=0;t<En.length;t++)if(n=En[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}En=null}return e}function sf(e,t){do{var n=Ne;try{if(Qi(),Us.current=ha,ma){for(var r=Se.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}ma=!1}if(An=0,Pe=Ee=Se=null,Fr=!1,ns=0,ll.current=null,n===null||n.return===null){Te=1,as=t,Ne=null;break}e:{var o=e,i=n.return,l=n,c=t;if(t=Fe,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,f=l,m=f.tag;if(!(f.mode&1)&&(m===0||m===11||m===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 x=wc(i);if(x!==null){x.flags&=-257,Sc(x,i,l,o,t),x.mode&1&&xc(o,d,t),t=x,c=d;var w=t.updateQueue;if(w===null){var v=new Set;v.add(c),t.updateQueue=v}else w.add(c);break e}else{if(!(t&1)){xc(o,d,t),pl();break e}c=Error(B(426))}}else if(ve&&l.mode&1){var j=wc(i);if(j!==null){!(j.flags&65536)&&(j.flags|=256),Sc(j,i,l,o,t),Ki(ur(c,l));break e}}o=c=ur(c,l),Te!==4&&(Te=2),Br===null?Br=[o]:Br.push(o),o=i;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var h=Dd(o,c,t);pc(o,h);break e;case 1:l=c;var g=o.type,y=o.stateNode;if(!(o.flags&128)&&(typeof g.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(pn===null||!pn.has(y)))){o.flags|=65536,t&=-t,o.lanes|=t;var S=Ud(o,l,t);pc(o,S);break e}}o=o.return}while(o!==null)}lf(n)}catch(k){t=k,Ne===n&&n!==null&&(Ne=n=n.return);continue}break}while(!0)}function af(){var e=ga.current;return ga.current=ha,e===null?ha:e}function pl(){(Te===0||Te===3||Te===2)&&(Te=4),_e===null||!($n&268435455)&&!(Aa&268435455)||sn(_e,Fe)}function xa(e,t){var n=oe;oe|=2;var r=af();(_e!==e||Fe!==t)&&(Dt=null,In(e,t));do try{mh();break}catch(s){sf(e,s)}while(!0);if(Qi(),oe=n,ga.current=r,Ne!==null)throw Error(B(261));return _e=null,Fe=0,Te}function mh(){for(;Ne!==null;)of(Ne)}function hh(){for(;Ne!==null&&!Bp();)of(Ne)}function of(e){var t=uf(e.alternate,e,lt);e.memoizedProps=e.pendingProps,t===null?lf(e):Ne=t,ll.current=null}function lf(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=lh(n,t),n!==null){n.flags&=32767,Ne=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Te=6,Ne=null;return}}else if(n=ih(n,t,lt),n!==null){Ne=n;return}if(t=t.sibling,t!==null){Ne=t;return}Ne=t=e}while(t!==null);Te===0&&(Te=5)}function bn(e,t,n){var r=fe,s=xt.transition;try{xt.transition=null,fe=1,gh(e,t,n,r)}finally{xt.transition=s,fe=r}return null}function gh(e,t,n,r){do sr();while(on!==null);if(oe&6)throw Error(B(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(B(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(Jp(e,o),e===_e&&(Ne=_e=null,Fe=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||zs||(zs=!0,df(ea,function(){return sr(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=xt.transition,xt.transition=null;var i=fe;fe=1;var l=oe;oe|=4,ll.current=null,uh(e,n),tf(n,e),Lm(Go),na=!!Vo,Go=Vo=null,e.current=n,dh(n),Dp(),oe=l,fe=i,xt.transition=o}else e.current=n;if(zs&&(zs=!1,on=e,va=s),o=e.pendingLanes,o===0&&(pn=null),Hp(n.stateNode),at(e,be()),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(ya)throw ya=!1,e=fi,fi=null,e;return va&1&&e.tag!==0&&sr(),o=e.pendingLanes,o&1?e===pi?Dr++:(Dr=0,pi=e):Dr=0,wn(),null}function sr(){if(on!==null){var e=Du(va),t=xt.transition,n=fe;try{if(xt.transition=null,fe=16>e?16:e,on===null)var r=!1;else{if(e=on,on=null,va=0,oe&6)throw Error(B(331));var s=oe;for(oe|=4,Q=e.current;Q!==null;){var o=Q,i=o.child;if(Q.flags&16){var l=o.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(Q=d;Q!==null;){var f=Q;switch(f.tag){case 0:case 11:case 15:Or(8,f,o)}var m=f.child;if(m!==null)m.return=f,Q=m;else for(;Q!==null;){f=Q;var p=f.sibling,x=f.return;if(qd(f),f===d){Q=null;break}if(p!==null){p.return=x,Q=p;break}Q=x}}}var w=o.alternate;if(w!==null){var v=w.child;if(v!==null){w.child=null;do{var j=v.sibling;v.sibling=null,v=j}while(v!==null)}}Q=o}}if(o.subtreeFlags&2064&&i!==null)i.return=o,Q=i;else e:for(;Q!==null;){if(o=Q,o.flags&2048)switch(o.tag){case 0:case 11:case 15:Or(9,o,o.return)}var h=o.sibling;if(h!==null){h.return=o.return,Q=h;break e}Q=o.return}}var g=e.current;for(Q=g;Q!==null;){i=Q;var y=i.child;if(i.subtreeFlags&2064&&y!==null)y.return=i,Q=y;else e:for(i=g;Q!==null;){if(l=Q,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:_a(9,l)}}catch(k){ke(l,l.return,k)}if(l===i){Q=null;break e}var S=l.sibling;if(S!==null){S.return=l.return,Q=S;break e}Q=l.return}}if(oe=s,wn(),Mt&&typeof Mt.onPostCommitFiberRoot=="function")try{Mt.onPostCommitFiberRoot(Ca,e)}catch{}r=!0}return r}finally{fe=n,xt.transition=t}}return!1}function Ac(e,t,n){t=ur(n,t),t=Dd(e,t,1),e=fn(e,t,1),t=Je(),e!==null&&(ls(e,1,t),at(e,t))}function ke(e,t,n){if(e.tag===3)Ac(e,e,n);else for(;t!==null;){if(t.tag===3){Ac(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(pn===null||!pn.has(r))){e=ur(n,e),e=Ud(t,e,1),t=fn(t,e,1),e=Je(),t!==null&&(ls(t,1,e),at(t,e));break}}t=t.return}}function yh(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Je(),e.pingedLanes|=e.suspendedLanes&n,_e===e&&(Fe&n)===n&&(Te===4||Te===3&&(Fe&130023424)===Fe&&500>be()-ul?In(e,0):cl|=n),at(e,t)}function cf(e,t){t===0&&(e.mode&1?(t=xs,xs<<=1,!(xs&130023424)&&(xs=4194304)):t=1);var n=Je();e=Yt(e,t),e!==null&&(ls(e,t,n),at(e,n))}function vh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),cf(e,n)}function xh(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(B(314))}r!==null&&r.delete(t),cf(e,n)}var uf;uf=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||rt.current)nt=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return nt=!1,oh(e,t,n);nt=!!(e.flags&131072)}else nt=!1,ve&&t.flags&1048576&&pd(t,ca,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Hs(e,t),e=t.pendingProps;var s=or(t,Ge.current);rr(t,n),s=rl(null,t,r,e,s,n);var o=sl();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,st(r)?(o=!0,ia(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,qi(t),s.updater=Pa,t.stateNode=s,s._reactInternals=t,ti(t,r,e,n),t=si(null,t,r,!0,o,n)):(t.tag=0,ve&&o&&Vi(t),Ye(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Hs(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=Sh(r),e=Ct(r,e),s){case 0:t=ri(null,t,r,e,n);break e;case 1:t=bc(null,t,r,e,n);break e;case 11:t=jc(null,t,r,e,n);break e;case 14:t=kc(null,t,r,Ct(r.type,e),n);break e}throw Error(B(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ct(r,s),ri(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ct(r,s),bc(e,t,r,s,n);case 3:e:{if(Gd(t),e===null)throw Error(B(387));r=t.pendingProps,o=t.memoizedState,s=o.element,xd(e,t),fa(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=ur(Error(B(423)),t),t=Cc(e,t,r,n,s);break e}else if(r!==s){s=ur(Error(B(424)),t),t=Cc(e,t,r,n,s);break e}else for(ct=dn(t.stateNode.containerInfo.firstChild),ut=t,ve=!0,Et=null,n=yd(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(ir(),r===s){t=Qt(e,t,n);break e}Ye(e,t,r,n)}t=t.child}return t;case 5:return wd(t),e===null&&qo(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,i=s.children,Ko(r,s)?i=null:o!==null&&Ko(r,o)&&(t.flags|=32),Vd(e,t),Ye(e,t,i,n),t.child;case 6:return e===null&&qo(t),null;case 13:return Kd(e,t,n);case 4:return Zi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=lr(t,null,r,n):Ye(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ct(r,s),jc(e,t,r,s,n);case 7:return Ye(e,t,t.pendingProps,n),t.child;case 8:return Ye(e,t,t.pendingProps.children,n),t.child;case 12:return Ye(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,me(ua,r._currentValue),r._currentValue=i,o!==null)if(It(o.value,i)){if(o.children===s.children&&!rt.current){t=Qt(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=Vt(-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),Zo(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(B(341));i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),Zo(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}Ye(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,rr(t,n),s=wt(s),r=r(s),t.flags|=1,Ye(e,t,r,n),t.child;case 14:return r=t.type,s=Ct(r,t.pendingProps),s=Ct(r.type,s),kc(e,t,r,s,n);case 15:return Wd(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ct(r,s),Hs(e,t),t.tag=1,st(r)?(e=!0,ia(t)):e=!1,rr(t,n),Bd(t,r,s),ti(t,r,s,n),si(null,t,r,!0,e,n);case 19:return Yd(e,t,n);case 22:return Hd(e,t,n)}throw Error(B(156,t.tag))};function df(e,t){return Mu(e,t)}function wh(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 vt(e,t,n,r){return new wh(e,t,n,r)}function ml(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Sh(e){if(typeof e=="function")return ml(e)?1:0;if(e!=null){if(e=e.$$typeof,e===_i)return 11;if(e===Ai)return 14}return 2}function hn(e,t){var n=e.alternate;return n===null?(n=vt(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 Ks(e,t,n,r,s,o){var i=2;if(r=e,typeof e=="function")ml(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Un:return Rn(n.children,s,o,t);case Pi:i=8,s|=8;break;case Co:return e=vt(12,n,t,s|2),e.elementType=Co,e.lanes=o,e;case No:return e=vt(13,n,t,s),e.elementType=No,e.lanes=o,e;case Eo:return e=vt(19,n,t,s),e.elementType=Eo,e.lanes=o,e;case wu:return $a(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case vu:i=10;break e;case xu:i=9;break e;case _i:i=11;break e;case Ai:i=14;break e;case en:i=16,r=null;break e}throw Error(B(130,e==null?e:typeof e,""))}return t=vt(i,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function Rn(e,t,n,r){return e=vt(7,e,r,t),e.lanes=n,e}function $a(e,t,n,r){return e=vt(22,e,r,t),e.elementType=wu,e.lanes=n,e.stateNode={isHidden:!1},e}function ho(e,t,n){return e=vt(6,e,null,t),e.lanes=n,e}function go(e,t,n){return t=vt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function jh(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=Qa(0),this.expirationTimes=Qa(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qa(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function hl(e,t,n,r,s,o,i,l,c){return e=new jh(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=vt(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},qi(o),e}function kh(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Dn,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function ff(e){if(!e)return yn;e=e._reactInternals;e:{if(Fn(e)!==e||e.tag!==1)throw Error(B(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(st(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(B(171))}if(e.tag===1){var n=e.type;if(st(n))return dd(e,n,t)}return t}function pf(e,t,n,r,s,o,i,l,c){return e=hl(n,r,!0,e,s,o,i,l,c),e.context=ff(null),n=e.current,r=Je(),s=mn(n),o=Vt(r,s),o.callback=t??null,fn(n,o,s),e.current.lanes=s,ls(e,s,r),at(e,r),e}function La(e,t,n,r){var s=t.current,o=Je(),i=mn(s);return n=ff(n),t.context===null?t.context=n:t.pendingContext=n,t=Vt(o,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=fn(s,t,i),e!==null&&(zt(e,s,i,o),Ds(e,s,i)),i}function wa(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 $c(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function gl(e,t){$c(e,t),(e=e.alternate)&&$c(e,t)}function bh(){return null}var mf=typeof reportError=="function"?reportError:function(e){console.error(e)};function yl(e){this._internalRoot=e}Ma.prototype.render=yl.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(B(409));La(e,t,null,null)};Ma.prototype.unmount=yl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Ln(function(){La(null,e,null,null)}),t[Kt]=null}};function Ma(e){this._internalRoot=e}Ma.prototype.unstable_scheduleHydration=function(e){if(e){var t=Hu();e={blockedOn:null,target:e,priority:t};for(var n=0;n<rn.length&&t!==0&&t<rn[n].priority;n++);rn.splice(n,0,e),n===0&&Gu(e)}};function vl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Fa(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Lc(){}function Ch(e,t,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var d=wa(i);o.call(d)}}var i=pf(t,r,e,0,null,!1,!1,"",Lc);return e._reactRootContainer=i,e[Kt]=i.current,Xr(e.nodeType===8?e.parentNode:e),Ln(),i}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var d=wa(c);l.call(d)}}var c=hl(e,0,!1,null,null,!1,!1,"",Lc);return e._reactRootContainer=c,e[Kt]=c.current,Xr(e.nodeType===8?e.parentNode:e),Ln(function(){La(t,c,n,r)}),c}function Oa(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=wa(i);l.call(c)}}La(t,i,e,s)}else i=Ch(n,t,e,s,r);return wa(i)}Uu=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Ir(t.pendingLanes);n!==0&&(Mi(t,n|1),at(t,be()),!(oe&6)&&(dr=be()+500,wn()))}break;case 13:Ln(function(){var r=Yt(e,1);if(r!==null){var s=Je();zt(r,e,1,s)}}),gl(e,1)}};Fi=function(e){if(e.tag===13){var t=Yt(e,134217728);if(t!==null){var n=Je();zt(t,e,134217728,n)}gl(e,134217728)}};Wu=function(e){if(e.tag===13){var t=mn(e),n=Yt(e,t);if(n!==null){var r=Je();zt(n,e,t,r)}gl(e,t)}};Hu=function(){return fe};Vu=function(e,t){var n=fe;try{return fe=e,t()}finally{fe=n}};Mo=function(e,t,n){switch(t){case"input":if(Io(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=za(r);if(!s)throw Error(B(90));ju(r),Io(r,s)}}}break;case"textarea":bu(e,n);break;case"select":t=n.value,t!=null&&Zn(e,!!n.multiple,t,!1)}};Ru=dl;Pu=Ln;var Nh={usingClientEntryPoint:!1,Events:[us,Gn,za,zu,Iu,dl]},Cr={findFiberByHostInstance:Nn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Eh={bundleType:Cr.bundleType,version:Cr.version,rendererPackageName:Cr.rendererPackageName,rendererConfig:Cr.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Xt.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=$u(e),e===null?null:e.stateNode},findFiberByHostInstance:Cr.findFiberByHostInstance||bh,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 Is=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Is.isDisabled&&Is.supportsFiber)try{Ca=Is.inject(Eh),Mt=Is}catch{}}ft.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Nh;ft.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!vl(t))throw Error(B(200));return kh(e,t,null,n)};ft.createRoot=function(e,t){if(!vl(e))throw Error(B(299));var n=!1,r="",s=mf;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=hl(e,1,!1,null,null,n,!1,r,s),e[Kt]=t.current,Xr(e.nodeType===8?e.parentNode:e),new yl(t)};ft.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(B(188)):(e=Object.keys(e).join(","),Error(B(268,e)));return e=$u(t),e=e===null?null:e.stateNode,e};ft.flushSync=function(e){return Ln(e)};ft.hydrate=function(e,t,n){if(!Fa(t))throw Error(B(200));return Oa(null,e,t,!0,n)};ft.hydrateRoot=function(e,t,n){if(!vl(e))throw Error(B(405));var r=n!=null&&n.hydratedSources||null,s=!1,o="",i=mf;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(i=n.onRecoverableError)),t=pf(t,null,e,1,n??null,s,!1,o,i),e[Kt]=t.current,Xr(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 Ma(t)};ft.render=function(e,t,n){if(!Fa(t))throw Error(B(200));return Oa(null,e,t,!1,n)};ft.unmountComponentAtNode=function(e){if(!Fa(e))throw Error(B(40));return e._reactRootContainer?(Ln(function(){Oa(null,null,e,!1,function(){e._reactRootContainer=null,e[Kt]=null})}),!0):!1};ft.unstable_batchedUpdates=dl;ft.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Fa(n))throw Error(B(200));if(e==null||e._reactInternals===void 0)throw Error(B(38));return Oa(e,t,n,!1,r)};ft.version="18.3.1-next-f1338f8080-20240426";function hf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(hf)}catch(e){console.error(e)}}hf(),mu.exports=ft;var gf=mu.exports,yf,Mc=gf;yf=Mc.createRoot,Mc.hydrateRoot;/**
40
+ `+o.stack}return{value:e,source:t,stack:s,digest:null}}function po(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function ni(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var sh=typeof WeakMap=="function"?WeakMap:Map;function Bd(e,t,n){n=Vt(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){va||(va=!0,fi=r),ni(e,t)},n}function Dd(e,t,n){n=Vt(-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(){ni(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){ni(e,t),typeof r!="function"&&(pn===null?pn=new Set([this]):pn.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function vc(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new sh;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=vh.bind(null,e,t,n),t.then(e,e))}function xc(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 wc(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=Vt(-1,1),t.tag=2,fn(n,t,1))),n.lanes|=1),e)}var ah=Xt.ReactCurrentOwner,nt=!1;function Ye(e,t,n,r){t.child=e===null?gd(t,null,n,r):lr(t,e.child,n,r)}function Sc(e,t,n,r,s){n=n.render;var o=t.ref;return rr(t,s),r=nl(e,t,n,r,o,s),n=rl(),e!==null&&!nt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,Qt(e,t,s)):(ve&&n&&Hi(t),t.flags|=1,Ye(e,t,r,s),t.child)}function jc(e,t,n,r,s){if(e===null){var o=n.type;return typeof o=="function"&&!pl(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,Ud(e,t,o,r,s)):(e=Ys(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:Xr,n(i,r)&&e.ref===t.ref)return Qt(e,t,s)}return t.flags|=1,e=hn(o,r),e.ref=t.ref,e.return=t,t.child=e}function Ud(e,t,n,r,s){if(e!==null){var o=e.memoizedProps;if(Xr(o,r)&&e.ref===t.ref)if(nt=!1,t.pendingProps=r=o,(e.lanes&s)!==0)e.flags&131072&&(nt=!0);else return t.lanes=e.lanes,Qt(e,t,s)}return ri(e,t,n,r,s)}function Wd(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},me(qn,lt),lt|=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,me(qn,lt),lt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,me(qn,lt),lt|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,me(qn,lt),lt|=r;return Ye(e,t,s,n),t.child}function Hd(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function ri(e,t,n,r,s){var o=st(n)?Pn:Ge.current;return o=or(t,o),rr(t,s),n=nl(e,t,n,r,o,s),r=rl(),e!==null&&!nt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,Qt(e,t,s)):(ve&&r&&Hi(t),t.flags|=1,Ye(e,t,n,s),t.child)}function kc(e,t,n,r,s){if(st(n)){var o=!0;la(t)}else o=!1;if(rr(t,s),t.stateNode===null)Vs(e,t),Od(t,n,r),ti(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=wt(d):(d=st(n)?Pn:Ge.current,d=or(t,d));var f=n.getDerivedStateFromProps,m=typeof f=="function"||typeof i.getSnapshotBeforeUpdate=="function";m||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==r||c!==d)&&yc(t,i,r,d),tn=!1;var p=t.memoizedState;i.state=p,pa(t,r,i,s),c=t.memoizedState,l!==r||p!==c||rt.current||tn?(typeof f=="function"&&(ei(t,n,f,r),c=t.memoizedState),(l=tn||gc(t,n,l,r,p,c,d))?(m||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,vd(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:Ct(t.type,l),i.props=d,m=t.pendingProps,p=i.context,c=n.contextType,typeof c=="object"&&c!==null?c=wt(c):(c=st(n)?Pn:Ge.current,c=or(t,c));var x=n.getDerivedStateFromProps;(f=typeof x=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==m||p!==c)&&yc(t,i,r,c),tn=!1,p=t.memoizedState,i.state=p,pa(t,r,i,s);var w=t.memoizedState;l!==m||p!==w||rt.current||tn?(typeof x=="function"&&(ei(t,n,x,r),w=t.memoizedState),(d=tn||gc(t,n,d,r,p,w,c)||!1)?(f||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,w,c),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,w,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=w),i.props=r,i.state=w,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 si(e,t,n,r,o,s)}function si(e,t,n,r,s,o){Hd(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return s&&lc(t,n,!1),Qt(e,t,o);r=t.stateNode,ah.current=t;var l=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=lr(t,e.child,null,o),t.child=lr(t,null,l,o)):Ye(e,t,l,o),t.memoizedState=r.state,s&&lc(t,n,!0),t.child}function Vd(e){var t=e.stateNode;t.pendingContext?ic(e,t.pendingContext,t.pendingContext!==t.context):t.context&&ic(e,t.context,!1),qi(e,t.containerInfo)}function bc(e,t,n,r,s){return ir(),Gi(s),t.flags|=256,Ye(e,t,n,r),t.child}var ai={dehydrated:null,treeContext:null,retryLane:0};function oi(e){return{baseLanes:e,cachePool:null,transitions:null}}function Gd(e,t,n){var r=t.pendingProps,s=we.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),me(we,s&1),e===null)return qo(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=La(i,r,0,null),e=Rn(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=oi(n),t.memoizedState=ai,e):ol(t,i));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return oh(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=hn(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?o=hn(l,o):(o=Rn(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?oi(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},o.memoizedState=i,o.childLanes=e.childLanes&~n,t.memoizedState=ai,r}return o=e.child,e=o.sibling,r=hn(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 ol(e,t){return t=La({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ts(e,t,n,r){return r!==null&&Gi(r),lr(t,e.child,null,n),e=ol(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function oh(e,t,n,r,s,o,i){if(n)return t.flags&256?(t.flags&=-257,r=po(Error(B(422))),Ts(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,s=t.mode,r=La({mode:"visible",children:r.children},s,0,null),o=Rn(o,s,i,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&lr(t,e.child,null,i),t.child.memoizedState=oi(i),t.memoizedState=ai,o);if(!(t.mode&1))return Ts(e,t,i,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(B(419)),r=po(o,r,void 0),Ts(e,t,i,r)}if(l=(i&e.childLanes)!==0,nt||l){if(r=_e,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,Yt(e,s),zt(r,e,s,-1))}return fl(),r=po(Error(B(421))),Ts(e,t,i,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=xh.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,ct=dn(s.nextSibling),ut=t,ve=!0,Et=null,e!==null&&(gt[yt++]=Wt,gt[yt++]=Ht,gt[yt++]=_n,Wt=e.id,Ht=e.overflow,_n=t),t=ol(t,r.children),t.flags|=4096,t)}function Cc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Zo(e.return,t,n)}function mo(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 Kd(e,t,n){var r=t.pendingProps,s=r.revealOrder,o=r.tail;if(Ye(e,t,r.children,n),r=we.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&&Cc(e,n,t);else if(e.tag===19)Cc(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(me(we,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&&ma(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),mo(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&&ma(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}mo(t,!0,n,null,o);break;case"together":mo(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Vs(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Qt(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),$n|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(B(153));if(t.child!==null){for(e=t.child,n=hn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=hn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function ih(e,t,n){switch(t.tag){case 3:Vd(t),ir();break;case 5:xd(t);break;case 1:st(t.type)&&la(t);break;case 4:qi(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;me(da,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(me(we,we.current&1),t.flags|=128,null):n&t.child.childLanes?Gd(e,t,n):(me(we,we.current&1),e=Qt(e,t,n),e!==null?e.sibling:null);me(we,we.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Kd(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),me(we,we.current),r)break;return null;case 22:case 23:return t.lanes=0,Wd(e,t,n)}return Qt(e,t,n)}var Yd,ii,Qd,Jd;Yd=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}};ii=function(){};Qd=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Tn(Ft.current);var o=null;switch(n){case"input":s=zo(e,s),r=zo(e,r),o=[];break;case"select":s=je({},s,{value:void 0}),r=je({},r,{value:void 0}),o=[];break;case"textarea":s=Po(e,s),r=Po(e,r),o=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=oa)}Ao(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"&&(Hr.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"&&(Hr.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&ge("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)}};Jd=function(e,t,n,r){n!==r&&(t.flags|=4)};function Cr(e,t){if(!ve)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 lh(e,t,n){var r=t.pendingProps;switch(Vi(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 st(t.type)&&ia(),He(t),null;case 3:return r=t.stateNode,cr(),ye(rt),ye(Ge),el(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Ns(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Et!==null&&(hi(Et),Et=null))),ii(e,t),He(t),null;case 5:Zi(t);var s=Tn(ns.current);if(n=t.type,e!==null&&t.stateNode!=null)Qd(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(B(166));return He(t),null}if(e=Tn(Ft.current),Ns(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[$t]=t,r[es]=o,e=(t.mode&1)!==0,n){case"dialog":ge("cancel",r),ge("close",r);break;case"iframe":case"object":case"embed":ge("load",r);break;case"video":case"audio":for(s=0;s<Pr.length;s++)ge(Pr[s],r);break;case"source":ge("error",r);break;case"img":case"image":case"link":ge("error",r),ge("load",r);break;case"details":ge("toggle",r);break;case"input":Al(r,o),ge("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},ge("invalid",r);break;case"textarea":Ll(r,o),ge("invalid",r)}Ao(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&&Cs(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&Cs(r.textContent,l,e),s=["children",""+l]):Hr.hasOwnProperty(i)&&l!=null&&i==="onScroll"&&ge("scroll",r)}switch(n){case"input":ys(r),$l(r,o,!0);break;case"textarea":ys(r),Ml(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=oa)}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=bu(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[$t]=t,e[es]=r,Yd(e,t,!1,!1),t.stateNode=e;e:{switch(i=$o(n,r),n){case"dialog":ge("cancel",e),ge("close",e),s=r;break;case"iframe":case"object":case"embed":ge("load",e),s=r;break;case"video":case"audio":for(s=0;s<Pr.length;s++)ge(Pr[s],e);s=r;break;case"source":ge("error",e),s=r;break;case"img":case"image":case"link":ge("error",e),ge("load",e),s=r;break;case"details":ge("toggle",e),s=r;break;case"input":Al(e,r),s=zo(e,r),ge("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=je({},r,{value:void 0}),ge("invalid",e);break;case"textarea":Ll(e,r),s=Po(e,r),ge("invalid",e);break;default:s=r}Ao(n,s),l=s;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?Eu(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&Cu(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Vr(e,c):typeof c=="number"&&Vr(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Hr.hasOwnProperty(o)?c!=null&&o==="onScroll"&&ge("scroll",e):c!=null&&Ii(e,o,c,i))}switch(n){case"input":ys(e),$l(e,r,!1);break;case"textarea":ys(e),Ml(e);break;case"option":r.value!=null&&e.setAttribute("value",""+gn(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?Zn(e,!!r.multiple,o,!1):r.defaultValue!=null&&Zn(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=oa)}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)Jd(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(B(166));if(n=Tn(ns.current),Tn(Ft.current),Ns(t)){if(r=t.stateNode,n=t.memoizedProps,r[$t]=t,(o=r.nodeValue!==n)&&(e=ut,e!==null))switch(e.tag){case 3:Cs(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Cs(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[$t]=t,t.stateNode=r}return He(t),null;case 13:if(ye(we),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ve&&ct!==null&&t.mode&1&&!(t.flags&128))md(),ir(),t.flags|=98560,o=!1;else if(o=Ns(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(B(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(B(317));o[$t]=t}else ir(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;He(t),o=!1}else Et!==null&&(hi(Et),Et=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||we.current&1?Te===0&&(Te=3):fl())),t.updateQueue!==null&&(t.flags|=4),He(t),null);case 4:return cr(),ii(e,t),e===null&&qr(t.stateNode.containerInfo),He(t),null;case 10:return Qi(t.type._context),He(t),null;case 17:return st(t.type)&&ia(),He(t),null;case 19:if(ye(we),o=t.memoizedState,o===null)return He(t),null;if(r=(t.flags&128)!==0,i=o.rendering,i===null)if(r)Cr(o,!1);else{if(Te!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=ma(e),i!==null){for(t.flags|=128,Cr(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 me(we,we.current&1|2),t.child}e=e.sibling}o.tail!==null&&be()>dr&&(t.flags|=128,r=!0,Cr(o,!1),t.lanes=4194304)}else{if(!r)if(e=ma(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Cr(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!ve)return He(t),null}else 2*be()-o.renderingStartTime>dr&&n!==1073741824&&(t.flags|=128,r=!0,Cr(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=be(),t.sibling=null,n=we.current,me(we,r?n&1|2:n&1),t):(He(t),null);case 22:case 23:return dl(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?lt&1073741824&&(He(t),t.subtreeFlags&6&&(t.flags|=8192)):He(t),null;case 24:return null;case 25:return null}throw Error(B(156,t.tag))}function ch(e,t){switch(Vi(t),t.tag){case 1:return st(t.type)&&ia(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return cr(),ye(rt),ye(Ge),el(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Zi(t),null;case 13:if(ye(we),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(B(340));ir()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ye(we),null;case 4:return cr(),null;case 10:return Qi(t.type._context),null;case 22:case 23:return dl(),null;case 24:return null;default:return null}}var zs=!1,Ve=!1,uh=typeof WeakSet=="function"?WeakSet:Set,Q=null;function Xn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ke(e,t,r)}else n.current=null}function li(e,t,n){try{n()}catch(r){ke(e,t,r)}}var Nc=!1;function dh(e,t){if(Vo=ra,e=td(),Wi(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,m=e,p=null;t:for(;;){for(var x;m!==n||s!==0&&m.nodeType!==3||(l=i+s),m!==o||r!==0&&m.nodeType!==3||(c=i+r),m.nodeType===3&&(i+=m.nodeValue.length),(x=m.firstChild)!==null;)p=m,m=x;for(;;){if(m===e)break t;if(p===n&&++d===s&&(l=i),p===o&&++f===r&&(c=i),(x=m.nextSibling)!==null)break;m=p,p=m.parentNode}m=x}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Go={focusedElem:e,selectionRange:n},ra=!1,Q=t;Q!==null;)if(t=Q,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Q=e;else for(;Q!==null;){t=Q;try{var w=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var v=w.memoizedProps,j=w.memoizedState,h=t.stateNode,g=h.getSnapshotBeforeUpdate(t.elementType===t.type?v:Ct(t.type,v),j);h.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(B(163))}}catch(S){ke(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,Q=e;break}Q=t.return}return w=Nc,Nc=!1,w}function Br(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&&li(t,n,o)}s=s.next}while(s!==r)}}function Aa(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 ci(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 Xd(e){var t=e.alternate;t!==null&&(e.alternate=null,Xd(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[$t],delete t[es],delete t[Qo],delete t[Km],delete t[Ym])),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 qd(e){return e.tag===5||e.tag===3||e.tag===4}function Ec(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||qd(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 ui(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=oa));else if(r!==4&&(e=e.child,e!==null))for(ui(e,t,n),e=e.sibling;e!==null;)ui(e,t,n),e=e.sibling}function di(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(di(e,t,n),e=e.sibling;e!==null;)di(e,t,n),e=e.sibling}var Me=null,Nt=!1;function Zt(e,t,n){for(n=n.child;n!==null;)Zd(e,t,n),n=n.sibling}function Zd(e,t,n){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(Na,n)}catch{}switch(n.tag){case 5:Ve||Xn(n,t);case 6:var r=Me,s=Nt;Me=null,Zt(e,t,n),Me=r,Nt=s,Me!==null&&(Nt?(e=Me,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Me.removeChild(n.stateNode));break;case 18:Me!==null&&(Nt?(e=Me,n=n.stateNode,e.nodeType===8?oo(e.parentNode,n):e.nodeType===1&&oo(e,n),Qr(e)):oo(Me,n.stateNode));break;case 4:r=Me,s=Nt,Me=n.stateNode.containerInfo,Nt=!0,Zt(e,t,n),Me=r,Nt=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)&&li(n,t,i),s=s.next}while(s!==r)}Zt(e,t,n);break;case 1:if(!Ve&&(Xn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){ke(n,t,l)}Zt(e,t,n);break;case 21:Zt(e,t,n);break;case 22:n.mode&1?(Ve=(r=Ve)||n.memoizedState!==null,Zt(e,t,n),Ve=r):Zt(e,t,n);break;default:Zt(e,t,n)}}function Tc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new uh),t.forEach(function(r){var s=wh.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function bt(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:Me=l.stateNode,Nt=!1;break e;case 3:Me=l.stateNode.containerInfo,Nt=!0;break e;case 4:Me=l.stateNode.containerInfo,Nt=!0;break e}l=l.return}if(Me===null)throw Error(B(160));Zd(o,i,s),Me=null,Nt=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(d){ke(s,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)ef(t,e),t=t.sibling}function ef(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(bt(t,e),Pt(e),r&4){try{Br(3,e,e.return),Aa(3,e)}catch(v){ke(e,e.return,v)}try{Br(5,e,e.return)}catch(v){ke(e,e.return,v)}}break;case 1:bt(t,e),Pt(e),r&512&&n!==null&&Xn(n,n.return);break;case 5:if(bt(t,e),Pt(e),r&512&&n!==null&&Xn(n,n.return),e.flags&32){var s=e.stateNode;try{Vr(s,"")}catch(v){ke(e,e.return,v)}}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&&ju(s,o),$o(l,i);var d=$o(l,o);for(i=0;i<c.length;i+=2){var f=c[i],m=c[i+1];f==="style"?Eu(s,m):f==="dangerouslySetInnerHTML"?Cu(s,m):f==="children"?Vr(s,m):Ii(s,f,m,d)}switch(l){case"input":Io(s,o);break;case"textarea":ku(s,o);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var x=o.value;x!=null?Zn(s,!!o.multiple,x,!1):p!==!!o.multiple&&(o.defaultValue!=null?Zn(s,!!o.multiple,o.defaultValue,!0):Zn(s,!!o.multiple,o.multiple?[]:"",!1))}s[es]=o}catch(v){ke(e,e.return,v)}}break;case 6:if(bt(t,e),Pt(e),r&4){if(e.stateNode===null)throw Error(B(162));s=e.stateNode,o=e.memoizedProps;try{s.nodeValue=o}catch(v){ke(e,e.return,v)}}break;case 3:if(bt(t,e),Pt(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Qr(t.containerInfo)}catch(v){ke(e,e.return,v)}break;case 4:bt(t,e),Pt(e);break;case 13:bt(t,e),Pt(e),s=e.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(cl=be())),r&4&&Tc(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Ve=(d=Ve)||f,bt(t,e),Ve=d):bt(t,e),Pt(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(Q=e,f=e.child;f!==null;){for(m=Q=f;Q!==null;){switch(p=Q,x=p.child,p.tag){case 0:case 11:case 14:case 15:Br(4,p,p.return);break;case 1:Xn(p,p.return);var w=p.stateNode;if(typeof w.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,w.props=t.memoizedProps,w.state=t.memoizedState,w.componentWillUnmount()}catch(v){ke(r,n,v)}}break;case 5:Xn(p,p.return);break;case 22:if(p.memoizedState!==null){Ic(m);continue}}x!==null?(x.return=p,Q=x):Ic(m)}f=f.sibling}e:for(f=null,m=e;;){if(m.tag===5){if(f===null){f=m;try{s=m.stateNode,d?(o=s.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(l=m.stateNode,c=m.memoizedProps.style,i=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=Nu("display",i))}catch(v){ke(e,e.return,v)}}}else if(m.tag===6){if(f===null)try{m.stateNode.nodeValue=d?"":m.memoizedProps}catch(v){ke(e,e.return,v)}}else if((m.tag!==22&&m.tag!==23||m.memoizedState===null||m===e)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===e)break e;for(;m.sibling===null;){if(m.return===null||m.return===e)break e;f===m&&(f=null),m=m.return}f===m&&(f=null),m.sibling.return=m.return,m=m.sibling}}break;case 19:bt(t,e),Pt(e),r&4&&Tc(e);break;case 21:break;default:bt(t,e),Pt(e)}}function Pt(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(qd(n)){var r=n;break e}n=n.return}throw Error(B(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Vr(s,""),r.flags&=-33);var o=Ec(e);di(e,o,s);break;case 3:case 4:var i=r.stateNode.containerInfo,l=Ec(e);ui(e,l,i);break;default:throw Error(B(161))}}catch(c){ke(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function fh(e,t,n){Q=e,tf(e)}function tf(e,t,n){for(var r=(e.mode&1)!==0;Q!==null;){var s=Q,o=s.child;if(s.tag===22&&r){var i=s.memoizedState!==null||zs;if(!i){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Ve;l=zs;var d=Ve;if(zs=i,(Ve=c)&&!d)for(Q=s;Q!==null;)i=Q,c=i.child,i.tag===22&&i.memoizedState!==null?Rc(s):c!==null?(c.return=i,Q=c):Rc(s);for(;o!==null;)Q=o,tf(o),o=o.sibling;Q=s,zs=l,Ve=d}zc(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,Q=o):zc(e)}}function zc(e){for(;Q!==null;){var t=Q;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Ve||Aa(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:Ct(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&pc(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}pc(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 m=f.dehydrated;m!==null&&Qr(m)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(B(163))}Ve||t.flags&512&&ci(t)}catch(p){ke(t,t.return,p)}}if(t===e){Q=null;break}if(n=t.sibling,n!==null){n.return=t.return,Q=n;break}Q=t.return}}function Ic(e){for(;Q!==null;){var t=Q;if(t===e){Q=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Q=n;break}Q=t.return}}function Rc(e){for(;Q!==null;){var t=Q;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Aa(4,t)}catch(c){ke(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){ke(t,s,c)}}var o=t.return;try{ci(t)}catch(c){ke(t,o,c)}break;case 5:var i=t.return;try{ci(t)}catch(c){ke(t,i,c)}}}catch(c){ke(t,t.return,c)}if(t===e){Q=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Q=l;break}Q=t.return}}var ph=Math.ceil,ya=Xt.ReactCurrentDispatcher,il=Xt.ReactCurrentOwner,xt=Xt.ReactCurrentBatchConfig,oe=0,_e=null,Ne=null,Fe=0,lt=0,qn=xn(0),Te=0,os=null,$n=0,$a=0,ll=0,Dr=null,tt=null,cl=0,dr=1/0,Dt=null,va=!1,fi=null,pn=null,Is=!1,on=null,xa=0,Ur=0,pi=null,Gs=-1,Ks=0;function Je(){return oe&6?be():Gs!==-1?Gs:Gs=be()}function mn(e){return e.mode&1?oe&2&&Fe!==0?Fe&-Fe:Jm.transition!==null?(Ks===0&&(Ks=Ou()),Ks):(e=fe,e!==0||(e=window.event,e=e===void 0?16:Gu(e.type)),e):1}function zt(e,t,n,r){if(50<Ur)throw Ur=0,pi=null,Error(B(185));cs(e,n,r),(!(oe&2)||e!==_e)&&(e===_e&&(!(oe&2)&&($a|=n),Te===4&&sn(e,Fe)),at(e,r),n===1&&oe===0&&!(t.mode&1)&&(dr=be()+500,Ra&&wn()))}function at(e,t){var n=e.callbackNode;Jp(e,t);var r=na(e,e===_e?Fe:0);if(r===0)n!==null&&Bl(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Bl(n),t===1)e.tag===0?Qm(Pc.bind(null,e)):dd(Pc.bind(null,e)),Vm(function(){!(oe&6)&&wn()}),n=null;else{switch(Bu(r)){case 1:n=$i;break;case 4:n=Mu;break;case 16:n=ta;break;case 536870912:n=Fu;break;default:n=ta}n=uf(n,nf.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function nf(e,t){if(Gs=-1,Ks=0,oe&6)throw Error(B(327));var n=e.callbackNode;if(sr()&&e.callbackNode!==n)return null;var r=na(e,e===_e?Fe:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=wa(e,r);else{t=r;var s=oe;oe|=2;var o=sf();(_e!==e||Fe!==t)&&(Dt=null,dr=be()+500,In(e,t));do try{gh();break}catch(l){rf(e,l)}while(!0);Yi(),ya.current=o,oe=s,Ne!==null?t=0:(_e=null,Fe=0,t=Te)}if(t!==0){if(t===2&&(s=Bo(e),s!==0&&(r=s,t=mi(e,s))),t===1)throw n=os,In(e,0),sn(e,r),at(e,be()),n;if(t===6)sn(e,r);else{if(s=e.current.alternate,!(r&30)&&!mh(s)&&(t=wa(e,r),t===2&&(o=Bo(e),o!==0&&(r=o,t=mi(e,o))),t===1))throw n=os,In(e,0),sn(e,r),at(e,be()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(B(345));case 2:bn(e,tt,Dt);break;case 3:if(sn(e,r),(r&130023424)===r&&(t=cl+500-be(),10<t)){if(na(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Je(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=Yo(bn.bind(null,e,tt,Dt),t);break}bn(e,tt,Dt);break;case 4:if(sn(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var i=31-Tt(r);o=1<<i,i=t[i],i>s&&(s=i),r&=~o}if(r=s,r=be()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*ph(r/1960))-r,10<r){e.timeoutHandle=Yo(bn.bind(null,e,tt,Dt),r);break}bn(e,tt,Dt);break;case 5:bn(e,tt,Dt);break;default:throw Error(B(329))}}}return at(e,be()),e.callbackNode===n?nf.bind(null,e):null}function mi(e,t){var n=Dr;return e.current.memoizedState.isDehydrated&&(In(e,t).flags|=256),e=wa(e,t),e!==2&&(t=tt,tt=n,t!==null&&hi(t)),e}function hi(e){tt===null?tt=e:tt.push.apply(tt,e)}function mh(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(!It(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 sn(e,t){for(t&=~ll,t&=~$a,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Tt(t),r=1<<n;e[n]=-1,t&=~r}}function Pc(e){if(oe&6)throw Error(B(327));sr();var t=na(e,0);if(!(t&1))return at(e,be()),null;var n=wa(e,t);if(e.tag!==0&&n===2){var r=Bo(e);r!==0&&(t=r,n=mi(e,r))}if(n===1)throw n=os,In(e,0),sn(e,t),at(e,be()),n;if(n===6)throw Error(B(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,bn(e,tt,Dt),at(e,be()),null}function ul(e,t){var n=oe;oe|=1;try{return e(t)}finally{oe=n,oe===0&&(dr=be()+500,Ra&&wn())}}function Ln(e){on!==null&&on.tag===0&&!(oe&6)&&sr();var t=oe;oe|=1;var n=xt.transition,r=fe;try{if(xt.transition=null,fe=1,e)return e()}finally{fe=r,xt.transition=n,oe=t,!(oe&6)&&wn()}}function dl(){lt=qn.current,ye(qn)}function In(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Hm(n)),Ne!==null)for(n=Ne.return;n!==null;){var r=n;switch(Vi(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&ia();break;case 3:cr(),ye(rt),ye(Ge),el();break;case 5:Zi(r);break;case 4:cr();break;case 13:ye(we);break;case 19:ye(we);break;case 10:Qi(r.type._context);break;case 22:case 23:dl()}n=n.return}if(_e=e,Ne=e=hn(e.current,null),Fe=lt=t,Te=0,os=null,ll=$a=$n=0,tt=Dr=null,En!==null){for(t=0;t<En.length;t++)if(n=En[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}En=null}return e}function rf(e,t){do{var n=Ne;try{if(Yi(),Ws.current=ga,ha){for(var r=Se.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}ha=!1}if(An=0,Pe=Ee=Se=null,Or=!1,rs=0,il.current=null,n===null||n.return===null){Te=1,os=t,Ne=null;break}e:{var o=e,i=n.return,l=n,c=t;if(t=Fe,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,f=l,m=f.tag;if(!(f.mode&1)&&(m===0||m===11||m===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 x=xc(i);if(x!==null){x.flags&=-257,wc(x,i,l,o,t),x.mode&1&&vc(o,d,t),t=x,c=d;var w=t.updateQueue;if(w===null){var v=new Set;v.add(c),t.updateQueue=v}else w.add(c);break e}else{if(!(t&1)){vc(o,d,t),fl();break e}c=Error(B(426))}}else if(ve&&l.mode&1){var j=xc(i);if(j!==null){!(j.flags&65536)&&(j.flags|=256),wc(j,i,l,o,t),Gi(ur(c,l));break e}}o=c=ur(c,l),Te!==4&&(Te=2),Dr===null?Dr=[o]:Dr.push(o),o=i;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var h=Bd(o,c,t);fc(o,h);break e;case 1:l=c;var g=o.type,y=o.stateNode;if(!(o.flags&128)&&(typeof g.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(pn===null||!pn.has(y)))){o.flags|=65536,t&=-t,o.lanes|=t;var S=Dd(o,l,t);fc(o,S);break e}}o=o.return}while(o!==null)}of(n)}catch(k){t=k,Ne===n&&n!==null&&(Ne=n=n.return);continue}break}while(!0)}function sf(){var e=ya.current;return ya.current=ga,e===null?ga:e}function fl(){(Te===0||Te===3||Te===2)&&(Te=4),_e===null||!($n&268435455)&&!($a&268435455)||sn(_e,Fe)}function wa(e,t){var n=oe;oe|=2;var r=sf();(_e!==e||Fe!==t)&&(Dt=null,In(e,t));do try{hh();break}catch(s){rf(e,s)}while(!0);if(Yi(),oe=n,ya.current=r,Ne!==null)throw Error(B(261));return _e=null,Fe=0,Te}function hh(){for(;Ne!==null;)af(Ne)}function gh(){for(;Ne!==null&&!Dp();)af(Ne)}function af(e){var t=cf(e.alternate,e,lt);e.memoizedProps=e.pendingProps,t===null?of(e):Ne=t,il.current=null}function of(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=ch(n,t),n!==null){n.flags&=32767,Ne=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Te=6,Ne=null;return}}else if(n=lh(n,t,lt),n!==null){Ne=n;return}if(t=t.sibling,t!==null){Ne=t;return}Ne=t=e}while(t!==null);Te===0&&(Te=5)}function bn(e,t,n){var r=fe,s=xt.transition;try{xt.transition=null,fe=1,yh(e,t,n,r)}finally{xt.transition=s,fe=r}return null}function yh(e,t,n,r){do sr();while(on!==null);if(oe&6)throw Error(B(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(B(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(Xp(e,o),e===_e&&(Ne=_e=null,Fe=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Is||(Is=!0,uf(ta,function(){return sr(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=xt.transition,xt.transition=null;var i=fe;fe=1;var l=oe;oe|=4,il.current=null,dh(e,n),ef(n,e),Mm(Go),ra=!!Vo,Go=Vo=null,e.current=n,fh(n),Up(),oe=l,fe=i,xt.transition=o}else e.current=n;if(Is&&(Is=!1,on=e,xa=s),o=e.pendingLanes,o===0&&(pn=null),Vp(n.stateNode),at(e,be()),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(va)throw va=!1,e=fi,fi=null,e;return xa&1&&e.tag!==0&&sr(),o=e.pendingLanes,o&1?e===pi?Ur++:(Ur=0,pi=e):Ur=0,wn(),null}function sr(){if(on!==null){var e=Bu(xa),t=xt.transition,n=fe;try{if(xt.transition=null,fe=16>e?16:e,on===null)var r=!1;else{if(e=on,on=null,xa=0,oe&6)throw Error(B(331));var s=oe;for(oe|=4,Q=e.current;Q!==null;){var o=Q,i=o.child;if(Q.flags&16){var l=o.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(Q=d;Q!==null;){var f=Q;switch(f.tag){case 0:case 11:case 15:Br(8,f,o)}var m=f.child;if(m!==null)m.return=f,Q=m;else for(;Q!==null;){f=Q;var p=f.sibling,x=f.return;if(Xd(f),f===d){Q=null;break}if(p!==null){p.return=x,Q=p;break}Q=x}}}var w=o.alternate;if(w!==null){var v=w.child;if(v!==null){w.child=null;do{var j=v.sibling;v.sibling=null,v=j}while(v!==null)}}Q=o}}if(o.subtreeFlags&2064&&i!==null)i.return=o,Q=i;else e:for(;Q!==null;){if(o=Q,o.flags&2048)switch(o.tag){case 0:case 11:case 15:Br(9,o,o.return)}var h=o.sibling;if(h!==null){h.return=o.return,Q=h;break e}Q=o.return}}var g=e.current;for(Q=g;Q!==null;){i=Q;var y=i.child;if(i.subtreeFlags&2064&&y!==null)y.return=i,Q=y;else e:for(i=g;Q!==null;){if(l=Q,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Aa(9,l)}}catch(k){ke(l,l.return,k)}if(l===i){Q=null;break e}var S=l.sibling;if(S!==null){S.return=l.return,Q=S;break e}Q=l.return}}if(oe=s,wn(),Mt&&typeof Mt.onPostCommitFiberRoot=="function")try{Mt.onPostCommitFiberRoot(Na,e)}catch{}r=!0}return r}finally{fe=n,xt.transition=t}}return!1}function _c(e,t,n){t=ur(n,t),t=Bd(e,t,1),e=fn(e,t,1),t=Je(),e!==null&&(cs(e,1,t),at(e,t))}function ke(e,t,n){if(e.tag===3)_c(e,e,n);else for(;t!==null;){if(t.tag===3){_c(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(pn===null||!pn.has(r))){e=ur(n,e),e=Dd(t,e,1),t=fn(t,e,1),e=Je(),t!==null&&(cs(t,1,e),at(t,e));break}}t=t.return}}function vh(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Je(),e.pingedLanes|=e.suspendedLanes&n,_e===e&&(Fe&n)===n&&(Te===4||Te===3&&(Fe&130023424)===Fe&&500>be()-cl?In(e,0):ll|=n),at(e,t)}function lf(e,t){t===0&&(e.mode&1?(t=ws,ws<<=1,!(ws&130023424)&&(ws=4194304)):t=1);var n=Je();e=Yt(e,t),e!==null&&(cs(e,t,n),at(e,n))}function xh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),lf(e,n)}function wh(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(B(314))}r!==null&&r.delete(t),lf(e,n)}var cf;cf=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||rt.current)nt=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return nt=!1,ih(e,t,n);nt=!!(e.flags&131072)}else nt=!1,ve&&t.flags&1048576&&fd(t,ua,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Vs(e,t),e=t.pendingProps;var s=or(t,Ge.current);rr(t,n),s=nl(null,t,r,e,s,n);var o=rl();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,st(r)?(o=!0,la(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Xi(t),s.updater=_a,t.stateNode=s,s._reactInternals=t,ti(t,r,e,n),t=si(null,t,r,!0,o,n)):(t.tag=0,ve&&o&&Hi(t),Ye(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Vs(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=jh(r),e=Ct(r,e),s){case 0:t=ri(null,t,r,e,n);break e;case 1:t=kc(null,t,r,e,n);break e;case 11:t=Sc(null,t,r,e,n);break e;case 14:t=jc(null,t,r,Ct(r.type,e),n);break e}throw Error(B(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ct(r,s),ri(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ct(r,s),kc(e,t,r,s,n);case 3:e:{if(Vd(t),e===null)throw Error(B(387));r=t.pendingProps,o=t.memoizedState,s=o.element,vd(e,t),pa(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=ur(Error(B(423)),t),t=bc(e,t,r,n,s);break e}else if(r!==s){s=ur(Error(B(424)),t),t=bc(e,t,r,n,s);break e}else for(ct=dn(t.stateNode.containerInfo.firstChild),ut=t,ve=!0,Et=null,n=gd(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(ir(),r===s){t=Qt(e,t,n);break e}Ye(e,t,r,n)}t=t.child}return t;case 5:return xd(t),e===null&&qo(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,i=s.children,Ko(r,s)?i=null:o!==null&&Ko(r,o)&&(t.flags|=32),Hd(e,t),Ye(e,t,i,n),t.child;case 6:return e===null&&qo(t),null;case 13:return Gd(e,t,n);case 4:return qi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=lr(t,null,r,n):Ye(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ct(r,s),Sc(e,t,r,s,n);case 7:return Ye(e,t,t.pendingProps,n),t.child;case 8:return Ye(e,t,t.pendingProps.children,n),t.child;case 12:return Ye(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,me(da,r._currentValue),r._currentValue=i,o!==null)if(It(o.value,i)){if(o.children===s.children&&!rt.current){t=Qt(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=Vt(-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),Zo(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(B(341));i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),Zo(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}Ye(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,rr(t,n),s=wt(s),r=r(s),t.flags|=1,Ye(e,t,r,n),t.child;case 14:return r=t.type,s=Ct(r,t.pendingProps),s=Ct(r.type,s),jc(e,t,r,s,n);case 15:return Ud(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ct(r,s),Vs(e,t),t.tag=1,st(r)?(e=!0,la(t)):e=!1,rr(t,n),Od(t,r,s),ti(t,r,s,n),si(null,t,r,!0,e,n);case 19:return Kd(e,t,n);case 22:return Wd(e,t,n)}throw Error(B(156,t.tag))};function uf(e,t){return Lu(e,t)}function Sh(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 vt(e,t,n,r){return new Sh(e,t,n,r)}function pl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function jh(e){if(typeof e=="function")return pl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Pi)return 11;if(e===_i)return 14}return 2}function hn(e,t){var n=e.alternate;return n===null?(n=vt(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 Ys(e,t,n,r,s,o){var i=2;if(r=e,typeof e=="function")pl(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Un:return Rn(n.children,s,o,t);case Ri:i=8,s|=8;break;case Co:return e=vt(12,n,t,s|2),e.elementType=Co,e.lanes=o,e;case No:return e=vt(13,n,t,s),e.elementType=No,e.lanes=o,e;case Eo:return e=vt(19,n,t,s),e.elementType=Eo,e.lanes=o,e;case xu:return La(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case yu:i=10;break e;case vu:i=9;break e;case Pi:i=11;break e;case _i:i=14;break e;case en:i=16,r=null;break e}throw Error(B(130,e==null?e:typeof e,""))}return t=vt(i,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function Rn(e,t,n,r){return e=vt(7,e,r,t),e.lanes=n,e}function La(e,t,n,r){return e=vt(22,e,r,t),e.elementType=xu,e.lanes=n,e.stateNode={isHidden:!1},e}function ho(e,t,n){return e=vt(6,e,null,t),e.lanes=n,e}function go(e,t,n){return t=vt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function kh(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=Qa(0),this.expirationTimes=Qa(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qa(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function ml(e,t,n,r,s,o,i,l,c){return e=new kh(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=vt(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Xi(o),e}function bh(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Dn,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function df(e){if(!e)return yn;e=e._reactInternals;e:{if(Fn(e)!==e||e.tag!==1)throw Error(B(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(st(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(B(171))}if(e.tag===1){var n=e.type;if(st(n))return ud(e,n,t)}return t}function ff(e,t,n,r,s,o,i,l,c){return e=ml(n,r,!0,e,s,o,i,l,c),e.context=df(null),n=e.current,r=Je(),s=mn(n),o=Vt(r,s),o.callback=t??null,fn(n,o,s),e.current.lanes=s,cs(e,s,r),at(e,r),e}function Ma(e,t,n,r){var s=t.current,o=Je(),i=mn(s);return n=df(n),t.context===null?t.context=n:t.pendingContext=n,t=Vt(o,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=fn(s,t,i),e!==null&&(zt(e,s,i,o),Us(e,s,i)),i}function Sa(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 Ac(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function hl(e,t){Ac(e,t),(e=e.alternate)&&Ac(e,t)}function Ch(){return null}var pf=typeof reportError=="function"?reportError:function(e){console.error(e)};function gl(e){this._internalRoot=e}Fa.prototype.render=gl.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(B(409));Ma(e,t,null,null)};Fa.prototype.unmount=gl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Ln(function(){Ma(null,e,null,null)}),t[Kt]=null}};function Fa(e){this._internalRoot=e}Fa.prototype.unstable_scheduleHydration=function(e){if(e){var t=Wu();e={blockedOn:null,target:e,priority:t};for(var n=0;n<rn.length&&t!==0&&t<rn[n].priority;n++);rn.splice(n,0,e),n===0&&Vu(e)}};function yl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Oa(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function $c(){}function Nh(e,t,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var d=Sa(i);o.call(d)}}var i=ff(t,r,e,0,null,!1,!1,"",$c);return e._reactRootContainer=i,e[Kt]=i.current,qr(e.nodeType===8?e.parentNode:e),Ln(),i}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var d=Sa(c);l.call(d)}}var c=ml(e,0,!1,null,null,!1,!1,"",$c);return e._reactRootContainer=c,e[Kt]=c.current,qr(e.nodeType===8?e.parentNode:e),Ln(function(){Ma(t,c,n,r)}),c}function Ba(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=Sa(i);l.call(c)}}Ma(t,i,e,s)}else i=Nh(n,t,e,s,r);return Sa(i)}Du=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Rr(t.pendingLanes);n!==0&&(Li(t,n|1),at(t,be()),!(oe&6)&&(dr=be()+500,wn()))}break;case 13:Ln(function(){var r=Yt(e,1);if(r!==null){var s=Je();zt(r,e,1,s)}}),hl(e,1)}};Mi=function(e){if(e.tag===13){var t=Yt(e,134217728);if(t!==null){var n=Je();zt(t,e,134217728,n)}hl(e,134217728)}};Uu=function(e){if(e.tag===13){var t=mn(e),n=Yt(e,t);if(n!==null){var r=Je();zt(n,e,t,r)}hl(e,t)}};Wu=function(){return fe};Hu=function(e,t){var n=fe;try{return fe=e,t()}finally{fe=n}};Mo=function(e,t,n){switch(t){case"input":if(Io(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=Ia(r);if(!s)throw Error(B(90));Su(r),Io(r,s)}}}break;case"textarea":ku(e,n);break;case"select":t=n.value,t!=null&&Zn(e,!!n.multiple,t,!1)}};Iu=ul;Ru=Ln;var Eh={usingClientEntryPoint:!1,Events:[ds,Gn,Ia,Tu,zu,ul]},Nr={findFiberByHostInstance:Nn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Th={bundleType:Nr.bundleType,version:Nr.version,rendererPackageName:Nr.rendererPackageName,rendererConfig:Nr.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Xt.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Au(e),e===null?null:e.stateNode},findFiberByHostInstance:Nr.findFiberByHostInstance||Ch,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 Rs=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Rs.isDisabled&&Rs.supportsFiber)try{Na=Rs.inject(Th),Mt=Rs}catch{}}ft.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Eh;ft.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!yl(t))throw Error(B(200));return bh(e,t,null,n)};ft.createRoot=function(e,t){if(!yl(e))throw Error(B(299));var n=!1,r="",s=pf;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=ml(e,1,!1,null,null,n,!1,r,s),e[Kt]=t.current,qr(e.nodeType===8?e.parentNode:e),new gl(t)};ft.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(B(188)):(e=Object.keys(e).join(","),Error(B(268,e)));return e=Au(t),e=e===null?null:e.stateNode,e};ft.flushSync=function(e){return Ln(e)};ft.hydrate=function(e,t,n){if(!Oa(t))throw Error(B(200));return Ba(null,e,t,!0,n)};ft.hydrateRoot=function(e,t,n){if(!yl(e))throw Error(B(405));var r=n!=null&&n.hydratedSources||null,s=!1,o="",i=pf;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(i=n.onRecoverableError)),t=ff(t,null,e,1,n??null,s,!1,o,i),e[Kt]=t.current,qr(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 Fa(t)};ft.render=function(e,t,n){if(!Oa(t))throw Error(B(200));return Ba(null,e,t,!1,n)};ft.unmountComponentAtNode=function(e){if(!Oa(e))throw Error(B(40));return e._reactRootContainer?(Ln(function(){Ba(null,null,e,!1,function(){e._reactRootContainer=null,e[Kt]=null})}),!0):!1};ft.unstable_batchedUpdates=ul;ft.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Oa(n))throw Error(B(200));if(e==null||e._reactInternals===void 0)throw Error(B(38));return Ba(e,t,n,!1,r)};ft.version="18.3.1-next-f1338f8080-20240426";function mf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(mf)}catch(e){console.error(e)}}mf(),pu.exports=ft;var hf=pu.exports,gf,Lc=hf;gf=Lc.createRoot,Lc.hydrateRoot;/**
41
41
  * react-router v7.13.1
42
42
  *
43
43
  * Copyright (c) Remix Software Inc.
@@ -46,32 +46,32 @@ Error generating stack: `+o.message+`
46
46
  * LICENSE.md file in the root directory of this source tree.
47
47
  *
48
48
  * @license MIT
49
- */var Fc="popstate";function Oc(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Th(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 gi("",{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:os(s)}return Ih(t,n,null,e)}function xe(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function jt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function zh(){return Math.random().toString(36).substring(2,10)}function Bc(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 gi(e,t,n=null,r,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?hr(t):t,state:n,key:t&&t.key||r||zh(),unstable_mask:s}}function os({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 hr(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 Ih(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 m(){l="POP";let j=f(),h=j==null?null:j-d;d=j,c&&c({action:l,location:v.location,delta:h})}function p(j,h){l="PUSH";let g=Oc(j)?j:gi(v.location,j,h);d=f()+1;let y=Bc(g,d),S=v.createHref(g.unstable_mask||g);try{i.pushState(y,"",S)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;s.location.assign(S)}o&&c&&c({action:l,location:v.location,delta:1})}function x(j,h){l="REPLACE";let g=Oc(j)?j:gi(v.location,j,h);d=f();let y=Bc(g,d),S=v.createHref(g.unstable_mask||g);i.replaceState(y,"",S),o&&c&&c({action:l,location:v.location,delta:0})}function w(j){return Rh(j)}let v={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(Fc,m),c=j,()=>{s.removeEventListener(Fc,m),c=null}},createHref(j){return t(s,j)},createURL:w,encodeLocation(j){let h=w(j);return{pathname:h.pathname,search:h.search,hash:h.hash}},push:p,replace:x,go(j){return i.go(j)}};return v}function Rh(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),xe(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:os(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function vf(e,t,n="/"){return Ph(e,t,n,!1)}function Ph(e,t,n,r){let s=typeof t=="string"?hr(t):t,o=Jt(s.pathname||"/",n);if(o==null)return null;let i=xf(e);_h(i);let l=null;for(let c=0;l==null&&c<i.length;++c){let d=Hh(o);l=Uh(i[c],d,r)}return l}function xf(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;xe(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 m=Ot([r,f.relativePath]),p=n.concat(f);i.children&&i.children.length>0&&(xe(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),xf(i.children,t,p,m,c)),!(i.path==null&&!i.index)&&t.push({path:m,score:Bh(m,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 wf(i.path))o(i,l,!0,d)}),t}function wf(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=wf(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 _h(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Dh(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Ah=/^:[\w-]+$/,$h=3,Lh=2,Mh=1,Fh=10,Oh=-2,Dc=e=>e==="*";function Bh(e,t){let n=e.split("/"),r=n.length;return n.some(Dc)&&(r+=Oh),t&&(r+=Lh),n.filter(s=>!Dc(s)).reduce((s,o)=>s+(Ah.test(o)?$h:o===""?Mh:Fh),r)}function Dh(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 Uh(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)||"/",m=Sa({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},f),p=c.route;if(!m&&d&&n&&!r[r.length-1].route.index&&(m=Sa({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!m)return null;Object.assign(s,m.params),i.push({params:s,pathname:Ot([o,m.pathname]),pathnameBase:Yh(Ot([o,m.pathnameBase])),route:p}),m.pathnameBase!=="/"&&(o=Ot([o,m.pathnameBase]))}return i}function Sa(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Wh(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:m},p)=>{if(f==="*"){let w=l[p]||"";i=o.slice(0,o.length-w.length).replace(/(.)\/+$/,"$1")}const x=l[p];return m&&!x?d[f]=void 0:d[f]=(x||"").replace(/%2F/g,"/"),d},{}),pathname:o,pathnameBase:i,pattern:e}}function Wh(e,t=!1,n=!0){jt(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 m=f.charAt(d+i.length);return m&&m!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}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 Hh(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return jt(!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 Jt(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 Vh=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Gh(e,t="/"){let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?hr(e):e,o;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?o=Uc(n.substring(1),"/"):o=Uc(n,t)):o=t,{pathname:o,search:Qh(r),hash:Jh(s)}}function Uc(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 yo(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 Kh(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function xl(e){let t=Kh(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Ba(e,t,n,r=!1){let s;typeof e=="string"?s=hr(e):(s={...e},xe(!s.pathname||!s.pathname.includes("?"),yo("?","pathname","search",s)),xe(!s.pathname||!s.pathname.includes("#"),yo("#","pathname","hash",s)),xe(!s.search||!s.search.includes("#"),yo("#","search","hash",s)));let o=e===""||s.pathname==="",i=o?"/":s.pathname,l;if(i==null)l=n;else{let m=t.length-1;if(!r&&i.startsWith("..")){let p=i.split("/");for(;p[0]==="..";)p.shift(),m-=1;s.pathname=p.join("/")}l=m>=0?t[m]:"/"}let c=Gh(s,l),d=i&&i!=="/"&&i.endsWith("/"),f=(o||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var Ot=e=>e.join("/").replace(/\/\/+/g,"/"),Yh=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Qh=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Jh=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Xh=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 qh(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Zh(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Sf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function jf(e,t){let n=e;if(typeof n!="string"||!Vh.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,s=!1;if(Sf)try{let o=new URL(window.location.href),i=n.startsWith("//")?new URL(o.protocol+n):new URL(n),l=Jt(i.pathname,t);i.origin===o.origin&&l!=null?n=l+i.search+i.hash:s=!0}catch{jt(!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 kf=["POST","PUT","PATCH","DELETE"];new Set(kf);var eg=["GET",...kf];new Set(eg);var gr=u.createContext(null);gr.displayName="DataRouter";var Da=u.createContext(null);Da.displayName="DataRouterState";var tg=u.createContext(!1),bf=u.createContext({isTransitioning:!1});bf.displayName="ViewTransition";var ng=u.createContext(new Map);ng.displayName="Fetchers";var rg=u.createContext(null);rg.displayName="Await";var mt=u.createContext(null);mt.displayName="Navigation";var fs=u.createContext(null);fs.displayName="Location";var Rt=u.createContext({outlet:null,matches:[],isDataRoute:!1});Rt.displayName="Route";var wl=u.createContext(null);wl.displayName="RouteError";var Cf="REACT_ROUTER_ERROR",sg="REDIRECT",ag="ROUTE_ERROR_RESPONSE";function og(e){if(e.startsWith(`${Cf}:${sg}:{`))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 ig(e){if(e.startsWith(`${Cf}:${ag}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Xh(t.status,t.statusText,t.data)}catch{}}function lg(e,{relative:t}={}){xe(yr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=u.useContext(mt),{hash:s,pathname:o,search:i}=ps(e,{relative:t}),l=o;return n!=="/"&&(l=o==="/"?n:Ot([n,o])),r.createHref({pathname:l,search:i,hash:s})}function yr(){return u.useContext(fs)!=null}function kt(){return xe(yr(),"useLocation() may be used only in the context of a <Router> component."),u.useContext(fs).location}var Nf="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ef(e){u.useContext(mt).static||u.useLayoutEffect(e)}function qt(){let{isDataRoute:e}=u.useContext(Rt);return e?kg():cg()}function cg(){xe(yr(),"useNavigate() may be used only in the context of a <Router> component.");let e=u.useContext(gr),{basename:t,navigator:n}=u.useContext(mt),{matches:r}=u.useContext(Rt),{pathname:s}=kt(),o=JSON.stringify(xl(r)),i=u.useRef(!1);return Ef(()=>{i.current=!0}),u.useCallback((c,d={})=>{if(jt(i.current,Nf),!i.current)return;if(typeof c=="number"){n.go(c);return}let f=Ba(c,JSON.parse(o),s,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Ot([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,o,s,e])}var ug=u.createContext(null);function dg(e){let t=u.useContext(Rt).outlet;return u.useMemo(()=>t&&u.createElement(ug.Provider,{value:e},t),[t,e])}function ps(e,{relative:t}={}){let{matches:n}=u.useContext(Rt),{pathname:r}=kt(),s=JSON.stringify(xl(n));return u.useMemo(()=>Ba(e,JSON.parse(s),r,t==="path"),[e,s,r,t])}function fg(e,t){return Tf(e,t)}function Tf(e,t,n){var j;xe(yr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=u.useContext(mt),{matches:s}=u.useContext(Rt),o=s[s.length-1],i=o?o.params:{},l=o?o.pathname:"/",c=o?o.pathnameBase:"/",d=o&&o.route;{let h=d&&d.path||"";If(l,!d||h.endsWith("*")||h.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${h}">) 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.
49
+ */var Mc="popstate";function Fc(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function zh(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 gi("",{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:is(s)}return Rh(t,n,null,e)}function xe(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function jt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Ih(){return Math.random().toString(36).substring(2,10)}function Oc(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 gi(e,t,n=null,r,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?hr(t):t,state:n,key:t&&t.key||r||Ih(),unstable_mask:s}}function is({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 hr(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 Rh(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 m(){l="POP";let j=f(),h=j==null?null:j-d;d=j,c&&c({action:l,location:v.location,delta:h})}function p(j,h){l="PUSH";let g=Fc(j)?j:gi(v.location,j,h);d=f()+1;let y=Oc(g,d),S=v.createHref(g.unstable_mask||g);try{i.pushState(y,"",S)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;s.location.assign(S)}o&&c&&c({action:l,location:v.location,delta:1})}function x(j,h){l="REPLACE";let g=Fc(j)?j:gi(v.location,j,h);d=f();let y=Oc(g,d),S=v.createHref(g.unstable_mask||g);i.replaceState(y,"",S),o&&c&&c({action:l,location:v.location,delta:0})}function w(j){return Ph(j)}let v={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(Mc,m),c=j,()=>{s.removeEventListener(Mc,m),c=null}},createHref(j){return t(s,j)},createURL:w,encodeLocation(j){let h=w(j);return{pathname:h.pathname,search:h.search,hash:h.hash}},push:p,replace:x,go(j){return i.go(j)}};return v}function Ph(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),xe(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:is(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function yf(e,t,n="/"){return _h(e,t,n,!1)}function _h(e,t,n,r){let s=typeof t=="string"?hr(t):t,o=Jt(s.pathname||"/",n);if(o==null)return null;let i=vf(e);Ah(i);let l=null;for(let c=0;l==null&&c<i.length;++c){let d=Vh(o);l=Wh(i[c],d,r)}return l}function vf(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;xe(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 m=Ot([r,f.relativePath]),p=n.concat(f);i.children&&i.children.length>0&&(xe(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),vf(i.children,t,p,m,c)),!(i.path==null&&!i.index)&&t.push({path:m,score:Dh(m,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 xf(i.path))o(i,l,!0,d)}),t}function xf(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=xf(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 Ah(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Uh(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var $h=/^:[\w-]+$/,Lh=3,Mh=2,Fh=1,Oh=10,Bh=-2,Bc=e=>e==="*";function Dh(e,t){let n=e.split("/"),r=n.length;return n.some(Bc)&&(r+=Bh),t&&(r+=Mh),n.filter(s=>!Bc(s)).reduce((s,o)=>s+($h.test(o)?Lh:o===""?Fh:Oh),r)}function Uh(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 Wh(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)||"/",m=ja({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},f),p=c.route;if(!m&&d&&n&&!r[r.length-1].route.index&&(m=ja({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!m)return null;Object.assign(s,m.params),i.push({params:s,pathname:Ot([o,m.pathname]),pathnameBase:Qh(Ot([o,m.pathnameBase])),route:p}),m.pathnameBase!=="/"&&(o=Ot([o,m.pathnameBase]))}return i}function ja(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Hh(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:m},p)=>{if(f==="*"){let w=l[p]||"";i=o.slice(0,o.length-w.length).replace(/(.)\/+$/,"$1")}const x=l[p];return m&&!x?d[f]=void 0:d[f]=(x||"").replace(/%2F/g,"/"),d},{}),pathname:o,pathnameBase:i,pattern:e}}function Hh(e,t=!1,n=!0){jt(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 m=f.charAt(d+i.length);return m&&m!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}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 Vh(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return jt(!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 Jt(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 Gh=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Kh(e,t="/"){let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?hr(e):e,o;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?o=Dc(n.substring(1),"/"):o=Dc(n,t)):o=t,{pathname:o,search:Jh(r),hash:Xh(s)}}function Dc(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 yo(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 Yh(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function vl(e){let t=Yh(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Da(e,t,n,r=!1){let s;typeof e=="string"?s=hr(e):(s={...e},xe(!s.pathname||!s.pathname.includes("?"),yo("?","pathname","search",s)),xe(!s.pathname||!s.pathname.includes("#"),yo("#","pathname","hash",s)),xe(!s.search||!s.search.includes("#"),yo("#","search","hash",s)));let o=e===""||s.pathname==="",i=o?"/":s.pathname,l;if(i==null)l=n;else{let m=t.length-1;if(!r&&i.startsWith("..")){let p=i.split("/");for(;p[0]==="..";)p.shift(),m-=1;s.pathname=p.join("/")}l=m>=0?t[m]:"/"}let c=Kh(s,l),d=i&&i!=="/"&&i.endsWith("/"),f=(o||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var Ot=e=>e.join("/").replace(/\/\/+/g,"/"),Qh=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Jh=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Xh=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,qh=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 Zh(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function eg(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var wf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Sf(e,t){let n=e;if(typeof n!="string"||!Gh.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,s=!1;if(wf)try{let o=new URL(window.location.href),i=n.startsWith("//")?new URL(o.protocol+n):new URL(n),l=Jt(i.pathname,t);i.origin===o.origin&&l!=null?n=l+i.search+i.hash:s=!0}catch{jt(!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 jf=["POST","PUT","PATCH","DELETE"];new Set(jf);var tg=["GET",...jf];new Set(tg);var gr=u.createContext(null);gr.displayName="DataRouter";var Ua=u.createContext(null);Ua.displayName="DataRouterState";var ng=u.createContext(!1),kf=u.createContext({isTransitioning:!1});kf.displayName="ViewTransition";var rg=u.createContext(new Map);rg.displayName="Fetchers";var sg=u.createContext(null);sg.displayName="Await";var mt=u.createContext(null);mt.displayName="Navigation";var ps=u.createContext(null);ps.displayName="Location";var Rt=u.createContext({outlet:null,matches:[],isDataRoute:!1});Rt.displayName="Route";var xl=u.createContext(null);xl.displayName="RouteError";var bf="REACT_ROUTER_ERROR",ag="REDIRECT",og="ROUTE_ERROR_RESPONSE";function ig(e){if(e.startsWith(`${bf}:${ag}:{`))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 lg(e){if(e.startsWith(`${bf}:${og}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new qh(t.status,t.statusText,t.data)}catch{}}function cg(e,{relative:t}={}){xe(yr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=u.useContext(mt),{hash:s,pathname:o,search:i}=ms(e,{relative:t}),l=o;return n!=="/"&&(l=o==="/"?n:Ot([n,o])),r.createHref({pathname:l,search:i,hash:s})}function yr(){return u.useContext(ps)!=null}function kt(){return xe(yr(),"useLocation() may be used only in the context of a <Router> component."),u.useContext(ps).location}var Cf="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Nf(e){u.useContext(mt).static||u.useLayoutEffect(e)}function qt(){let{isDataRoute:e}=u.useContext(Rt);return e?bg():ug()}function ug(){xe(yr(),"useNavigate() may be used only in the context of a <Router> component.");let e=u.useContext(gr),{basename:t,navigator:n}=u.useContext(mt),{matches:r}=u.useContext(Rt),{pathname:s}=kt(),o=JSON.stringify(vl(r)),i=u.useRef(!1);return Nf(()=>{i.current=!0}),u.useCallback((c,d={})=>{if(jt(i.current,Cf),!i.current)return;if(typeof c=="number"){n.go(c);return}let f=Da(c,JSON.parse(o),s,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Ot([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,o,s,e])}var dg=u.createContext(null);function fg(e){let t=u.useContext(Rt).outlet;return u.useMemo(()=>t&&u.createElement(dg.Provider,{value:e},t),[t,e])}function ms(e,{relative:t}={}){let{matches:n}=u.useContext(Rt),{pathname:r}=kt(),s=JSON.stringify(vl(n));return u.useMemo(()=>Da(e,JSON.parse(s),r,t==="path"),[e,s,r,t])}function pg(e,t){return Ef(e,t)}function Ef(e,t,n){var j;xe(yr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=u.useContext(mt),{matches:s}=u.useContext(Rt),o=s[s.length-1],i=o?o.params:{},l=o?o.pathname:"/",c=o?o.pathnameBase:"/",d=o&&o.route;{let h=d&&d.path||"";zf(l,!d||h.endsWith("*")||h.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${h}">) 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
50
 
51
- Please change the parent <Route path="${h}"> to <Route path="${h==="/"?"*":`${h}/*`}">.`)}let f=kt(),m;if(t){let h=typeof t=="string"?hr(t):t;xe(c==="/"||((j=h.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 "${h.pathname}" was given in the \`location\` prop.`),m=h}else m=f;let p=m.pathname||"/",x=p;if(c!=="/"){let h=c.replace(/^\//,"").split("/");x="/"+p.replace(/^\//,"").split("/").slice(h.length).join("/")}let w=vf(e,{pathname:x});jt(d||w!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),jt(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.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 v=yg(w&&w.map(h=>Object.assign({},h,{params:Object.assign({},i,h.params),pathname:Ot([c,r.encodeLocation?r.encodeLocation(h.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathname]),pathnameBase:h.pathnameBase==="/"?c:Ot([c,r.encodeLocation?r.encodeLocation(h.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathnameBase])})),s,n);return t&&v?u.createElement(fs.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...m},navigationType:"POP"}},v):v}function pg(){let e=jg(),t=qh(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 mg=u.createElement(pg,null),zf=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=ig(e.digest);n&&(e=n)}let t=e!==void 0?u.createElement(Rt.Provider,{value:this.props.routeContext},u.createElement(wl.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?u.createElement(hg,{error:e},t):t}};zf.contextType=tg;var vo=new WeakMap;function hg({children:e,error:t}){let{basename:n}=u.useContext(mt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=og(t.digest);if(r){let s=vo.get(t);if(s)throw s;let o=jf(r.location,n);if(Sf&&!vo.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 vo.set(t,i),i}return u.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o.absoluteURL||o.to}`})}}return e}function gg({routeContext:e,match:t,children:n}){let r=u.useContext(gr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),u.createElement(Rt.Provider,{value:e},n)}function yg(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(m=>m.route.id&&(o==null?void 0:o[m.route.id])!==void 0);xe(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 m=s[f];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(l=f),m.route.id){let{loaderData:p,errors:x}=r,w=m.route.loader&&!p.hasOwnProperty(m.route.id)&&(!x||x[m.route.id]===void 0);if(m.route.lazy||w){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,m)=>{var p,x;c(f,{location:r.location,params:((x=(p=r.matches)==null?void 0:p[0])==null?void 0:x.params)??{},unstable_pattern:Zh(r.matches),errorInfo:m})}:void 0;return s.reduceRight((f,m,p)=>{let x,w=!1,v=null,j=null;r&&(x=o&&m.route.id?o[m.route.id]:void 0,v=m.route.errorElement||mg,i&&(l<0&&p===0?(If("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),w=!0,j=null):l===p&&(w=!0,j=m.route.hydrateFallbackElement||null)));let h=t.concat(s.slice(0,p+1)),g=()=>{let y;return x?y=v:w?y=j:m.route.Component?y=u.createElement(m.route.Component,null):m.route.element?y=m.route.element:y=f,u.createElement(gg,{match:m,routeContext:{outlet:f,matches:h,isDataRoute:r!=null},children:y})};return r&&(m.route.ErrorBoundary||m.route.errorElement||p===0)?u.createElement(zf,{location:r.location,revalidation:r.revalidation,component:v,error:x,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:d}):g()},null)}function Sl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function vg(e){let t=u.useContext(gr);return xe(t,Sl(e)),t}function xg(e){let t=u.useContext(Da);return xe(t,Sl(e)),t}function wg(e){let t=u.useContext(Rt);return xe(t,Sl(e)),t}function jl(e){let t=wg(e),n=t.matches[t.matches.length-1];return xe(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Sg(){return jl("useRouteId")}function jg(){var r;let e=u.useContext(wl),t=xg("useRouteError"),n=jl("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function kg(){let{router:e}=vg("useNavigate"),t=jl("useNavigate"),n=u.useRef(!1);return Ef(()=>{n.current=!0}),u.useCallback(async(s,o={})=>{jt(n.current,Nf),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...o}))},[e,t])}var Wc={};function If(e,t,n){!t&&!Wc[e]&&(Wc[e]=!0,jt(!1,n))}u.memo(bg);function bg({routes:e,future:t,state:n,isStatic:r,onError:s}){return Tf(e,void 0,{state:n,isStatic:r,onError:s})}function nn({to:e,replace:t,state:n,relative:r}){xe(yr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=u.useContext(mt);jt(!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(Rt),{pathname:i}=kt(),l=qt(),c=Ba(e,xl(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 Cg(e){return dg(e.context)}function Re(e){xe(!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 Ng({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:s,static:o=!1,unstable_useTransitions:i}){xe(!yr(),"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=hr(n));let{pathname:d="/",search:f="",hash:m="",state:p=null,key:x="default",unstable_mask:w}=n,v=u.useMemo(()=>{let j=Jt(d,l);return j==null?null:{location:{pathname:j,search:f,hash:m,state:p,key:x,unstable_mask:w},navigationType:r}},[l,d,f,m,p,x,r,w]);return jt(v!=null,`<Router basename="${l}"> is not able to match the URL "${d}${f}${m}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:u.createElement(mt.Provider,{value:c},u.createElement(fs.Provider,{children:t,value:v}))}function Eg({children:e,location:t}){return fg(yi(e),t)}function yi(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,yi(r.props.children,o));return}xe(r.type===Re,`[${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>`),xe(!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=yi(r.props.children,o)),n.push(i)}),n}var Ys="get",Qs="application/x-www-form-urlencoded";function Ua(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Tg(e){return Ua(e)&&e.tagName.toLowerCase()==="button"}function zg(e){return Ua(e)&&e.tagName.toLowerCase()==="form"}function Ig(e){return Ua(e)&&e.tagName.toLowerCase()==="input"}function Rg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Pg(e,t){return e.button===0&&(!t||t==="_self")&&!Rg(e)}function vi(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 _g(e,t){let n=vi(e);return t&&t.forEach((r,s)=>{n.has(s)||t.getAll(s).forEach(o=>{n.append(s,o)})}),n}var Rs=null;function Ag(){if(Rs===null)try{new FormData(document.createElement("form"),0),Rs=!1}catch{Rs=!0}return Rs}var $g=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function xo(e){return e!=null&&!$g.has(e)?(jt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Qs}"`),null):e}function Lg(e,t){let n,r,s,o,i;if(zg(e)){let l=e.getAttribute("action");r=l?Jt(l,t):null,n=e.getAttribute("method")||Ys,s=xo(e.getAttribute("enctype"))||Qs,o=new FormData(e)}else if(Tg(e)||Ig(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?Jt(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Ys,s=xo(e.getAttribute("formenctype"))||xo(l.getAttribute("enctype"))||Qs,o=new FormData(l,e),!Ag()){let{name:d,type:f,value:m}=e;if(f==="image"){let p=d?`${d}.`:"";o.append(`${p}x`,"0"),o.append(`${p}y`,"0")}else d&&o.append(d,m)}}else{if(Ua(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Ys,r=null,s=Qs,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 kl(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Mg(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&&Jt(s.pathname,t)==="/"?s.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:s.pathname=`${s.pathname.replace(/\/$/,"")}.${r}`,s}async function Fg(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 Og(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 Bg(e,t,n){let r=await Promise.all(e.map(async s=>{let o=t.routes[s.route.id];if(o){let i=await Fg(o,n);return i.links?i.links():[]}return[]}));return Hg(r.flat(1).filter(Og).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function Hc(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 m;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:((m=n[0])==null?void 0:m.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof p=="boolean")return p}return!0}):[]}function Dg(e,t,{includeHydrateFallback:n}={}){return Ug(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 Ug(e){return[...new Set(e)]}function Wg(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Hg(e,t){let n=new Set;return new Set(t),e.reduce((r,s)=>{let o=JSON.stringify(Wg(s));return n.has(o)||(n.add(o),r.push({key:o,link:s})),r},[])}function Rf(){let e=u.useContext(gr);return kl(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Vg(){let e=u.useContext(Da);return kl(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var bl=u.createContext(void 0);bl.displayName="FrameworkContext";function Pf(){let e=u.useContext(bl);return kl(e,"You must render this element inside a <HydratedRouter> element"),e}function Gg(e,t){let n=u.useContext(bl),[r,s]=u.useState(!1),[o,i]=u.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:f,onTouchStart:m}=t,p=u.useRef(null);u.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let v=h=>{h.forEach(g=>{i(g.isIntersecting)})},j=new IntersectionObserver(v,{threshold:.5});return p.current&&j.observe(p.current),()=>{j.disconnect()}}},[e]),u.useEffect(()=>{if(r){let v=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(v)}}},[r]);let x=()=>{s(!0)},w=()=>{s(!1),i(!1)};return n?e!=="intent"?[o,p,{}]:[o,p,{onFocus:Nr(l,x),onBlur:Nr(c,w),onMouseEnter:Nr(d,x),onMouseLeave:Nr(f,w),onTouchStart:Nr(m,x)}]:[!1,p,{}]}function Nr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Kg({page:e,...t}){let{router:n}=Rf(),r=u.useMemo(()=>vf(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?u.createElement(Qg,{page:e,matches:r,...t}):null}function Yg(e){let{manifest:t,routeModules:n}=Pf(),[r,s]=u.useState([]);return u.useEffect(()=>{let o=!1;return Bg(e,t,n).then(i=>{o||s(i)}),()=>{o=!0}},[e,t,n]),r}function Qg({page:e,matches:t,...n}){let r=kt(),{future:s,manifest:o,routeModules:i}=Pf(),{basename:l}=Rf(),{loaderData:c,matches:d}=Vg(),f=u.useMemo(()=>Hc(e,t,d,o,r,"data"),[e,t,d,o,r]),m=u.useMemo(()=>Hc(e,t,d,o,r,"assets"),[e,t,d,o,r]),p=u.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let v=new Set,j=!1;if(t.forEach(g=>{var S;let y=o.routes[g.route.id];!y||!y.hasLoader||(!f.some(k=>k.route.id===g.route.id)&&g.route.id in c&&((S=i[g.route.id])!=null&&S.shouldRevalidate)||y.hasClientLoader?j=!0:v.add(g.route.id))}),v.size===0)return[];let h=Mg(e,l,s.unstable_trailingSlashAwareDataRequests,"data");return j&&v.size>0&&h.searchParams.set("_routes",t.filter(g=>v.has(g.route.id)).map(g=>g.route.id).join(",")),[h.pathname+h.search]},[l,s.unstable_trailingSlashAwareDataRequests,c,r,o,f,t,e,i]),x=u.useMemo(()=>Dg(m,o),[m,o]),w=Yg(m);return u.createElement(u.Fragment,null,p.map(v=>u.createElement("link",{key:v,rel:"prefetch",as:"fetch",href:v,...n})),x.map(v=>u.createElement("link",{key:v,rel:"modulepreload",href:v,...n})),w.map(({key:v,link:j})=>u.createElement("link",{key:v,nonce:n.nonce,...j,crossOrigin:j.crossOrigin??n.crossOrigin})))}function Jg(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Xg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Xg&&(window.__reactRouterVersion="7.13.1")}catch{}function qg({basename:e,children:t,unstable_useTransitions:n,window:r}){let s=u.useRef();s.current==null&&(s.current=Th({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(Ng,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:o,unstable_useTransitions:n})}var _f=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Qe=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:m,viewTransition:p,unstable_defaultShouldRevalidate:x,...w},v){let{basename:j,navigator:h,unstable_useTransitions:g}=u.useContext(mt),y=typeof f=="string"&&_f.test(f),S=jf(f,j);f=S.to;let k=lg(f,{relative:s}),I=kt(),R=null;if(l){let T=Ba(l,[],I.unstable_mask?I.unstable_mask.pathname:"/",!0);j!=="/"&&(T.pathname=T.pathname==="/"?j:Ot([j,T.pathname])),R=h.createHref(T)}let[_,C,z]=Gg(r,w),D=ty(f,{replace:i,unstable_mask:l,state:c,target:d,preventScrollReset:m,relative:s,viewTransition:p,unstable_defaultShouldRevalidate:x,unstable_useTransitions:g});function Y(T){t&&t(T),T.defaultPrevented||D(T)}let K=!(S.isExternal||o),W=u.createElement("a",{...w,...z,href:(K?R:void 0)||S.absoluteURL||k,onClick:K?Y:t,ref:Jg(v,C),target:d,"data-discover":!y&&n==="render"?"true":void 0});return _&&!y?u.createElement(u.Fragment,null,W,u.createElement(Kg,{page:k})):W});Qe.displayName="Link";var Cl=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 m=ps(i,{relative:d.relative}),p=kt(),x=u.useContext(Da),{navigator:w,basename:v}=u.useContext(mt),j=x!=null&&oy(m)&&l===!0,h=w.encodeLocation?w.encodeLocation(m).pathname:m.pathname,g=p.pathname,y=x&&x.navigation&&x.navigation.location?x.navigation.location.pathname:null;n||(g=g.toLowerCase(),y=y?y.toLowerCase():null,h=h.toLowerCase()),y&&v&&(y=Jt(y,v)||y);const S=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let k=g===h||!s&&g.startsWith(h)&&g.charAt(S)==="/",I=y!=null&&(y===h||!s&&y.startsWith(h)&&y.charAt(h.length)==="/"),R={isActive:k,isPending:I,isTransitioning:j},_=k?t:void 0,C;typeof r=="function"?C=r(R):C=[r,k?"active":null,I?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let z=typeof o=="function"?o(R):o;return u.createElement(Qe,{...d,"aria-current":_,className:C,ref:f,style:z,to:i,viewTransition:l},typeof c=="function"?c(R):c)});Cl.displayName="NavLink";var Zg=u.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:s,state:o,method:i=Ys,action:l,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:m,unstable_defaultShouldRevalidate:p,...x},w)=>{let{unstable_useTransitions:v}=u.useContext(mt),j=sy(),h=ay(l,{relative:d}),g=i.toLowerCase()==="get"?"get":"post",y=typeof l=="string"&&_f.test(l),S=k=>{if(c&&c(k),k.defaultPrevented)return;k.preventDefault();let I=k.nativeEvent.submitter,R=(I==null?void 0:I.getAttribute("formmethod"))||i,_=()=>j(I||k.currentTarget,{fetcherKey:t,method:R,navigate:n,replace:s,state:o,relative:d,preventScrollReset:f,viewTransition:m,unstable_defaultShouldRevalidate:p});v&&n!==!1?u.startTransition(()=>_()):_()};return u.createElement("form",{ref:w,method:g,action:h,onSubmit:r?c:S,...x,"data-discover":!y&&e==="render"?"true":void 0})});Zg.displayName="Form";function ey(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Af(e){let t=u.useContext(gr);return xe(t,ey(e)),t}function ty(e,{target:t,replace:n,unstable_mask:r,state:s,preventScrollReset:o,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c,unstable_useTransitions:d}={}){let f=qt(),m=kt(),p=ps(e,{relative:i});return u.useCallback(x=>{if(Pg(x,t)){x.preventDefault();let w=n!==void 0?n:os(m)===os(p),v=()=>f(e,{replace:w,unstable_mask:r,state:s,preventScrollReset:o,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c});d?u.startTransition(()=>v()):v()}},[m,f,p,n,r,s,t,e,o,i,l,c,d])}function $f(e){jt(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(vi(e)),n=u.useRef(!1),r=kt(),s=u.useMemo(()=>_g(r.search,n.current?null:t.current),[r.search]),o=qt(),i=u.useCallback((l,c)=>{const d=vi(typeof l=="function"?l(new URLSearchParams(s)):l);n.current=!0,o("?"+d,c)},[o,s]);return[s,i]}var ny=0,ry=()=>`__${String(++ny)}__`;function sy(){let{router:e}=Af("useSubmit"),{basename:t}=u.useContext(mt),n=Sg(),r=e.fetch,s=e.navigate;return u.useCallback(async(o,i={})=>{let{action:l,method:c,encType:d,formData:f,body:m}=Lg(o,t);if(i.navigate===!1){let p=i.fetcherKey||ry();await r(p,n,i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:m,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:m,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 ay(e,{relative:t}={}){let{basename:n}=u.useContext(mt),r=u.useContext(Rt);xe(r,"useFormAction must be used inside a RouteContext");let[s]=r.matches.slice(-1),o={...ps(e||".",{relative:t})},i=kt();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(m=>m).forEach(m=>l.append("index",m));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:Ot([n,o.pathname])),os(o)}function oy(e,{relative:t}={}){let n=u.useContext(bf);xe(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Af("useViewTransitionState"),s=ps(e,{relative:t});if(!n.isTransitioning)return!1;let o=Jt(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=Jt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Sa(s.pathname,i)!=null||Sa(s.pathname,o)!=null}class Lf extends Error{constructor(n){super("different_account");Wa(this,"summary");this.name="DifferentAccountError",this.summary=n}}class iy{constructor(){Wa(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 Lf(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 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 m=new Date(c);m.setUTCDate(c.getUTCDate()-f),l.push(m.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 $=new iy,Mf=u.createContext(null);function ly({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),[m,p]=u.useState(null),[x,w]=u.useState(!1),[v,j]=u.useState(""),h=u.useRef(!1),g=u.useRef(null),y=u.useCallback(async()=>{if(h.current)try{const _=await $.getMyTeam();if(_){const{group:C,membership:z}=_;f(C),p(z),s("team"),i(C);const D=g.current??z.domains[0]??"owner";c(D)}else f(null),p(null),s("personal")}catch{}},[]);u.useEffect(()=>{const _=()=>{document.visibilityState==="visible"&&y()};return document.addEventListener("visibilitychange",_),()=>document.removeEventListener("visibilitychange",_)},[y]);const S=u.useCallback(async(_,C={})=>{w(!0),j("");try{$.setApiKey(_),h.current=!0;const z=await $.login(_,C);n(z),g.current=z.id;const D=await $.getGroups(),Y=D.find(K=>K.isPersonal)??D[0]??null;i(Y),c("owner"),await y()}catch(z){throw $.clearApiKey(),h.current=!1,j(z instanceof Error?z.message:"Login failed"),z}finally{w(!1)}},[y]),k=u.useCallback(async()=>{await $.logout(),$.clearApiKey(),h.current=!1,g.current=null,n(null),i(null),c(""),f(null),p(null),s("personal"),j("")},[]),I=u.useCallback(()=>j(""),[]),R=u.useCallback((_,C)=>{i(_),c(C)},[]);return a.jsx(Mf.Provider,{value:{user:t,mode:r,group:o,domain:l,groupId:(o==null?void 0:o.id)??null,activeTeam:d,activeMembership:m,isLoading:x,error:v,login:S,logout:k,clearError:I,activeGroup:o,activeDomain:l,groups:o?[o]:[],setActiveContext:R,refreshGroups:y},children:e})}function Ae(){const e=u.useContext(Mf);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const Ff=u.createContext(null);function cy({children:e}){const{user:t}=Ae(),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=$.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,m=>{let p;try{p=JSON.parse(m.data)}catch{p=null}const x=o.current.get(f);if(x)for(const w of x)try{w(p)}catch(v){console.error(`[EventSource] handler for "${f}" threw:`,v)}});return()=>{c.close(),n.current=null,s(!1)}},[t]),a.jsx(Ff.Provider,{value:{connected:r,addListener:i},children:e})}function ue(e,t){const n=u.useContext(Ff);if(!n)return;const{addListener:r}=n;u.useEffect(()=>r(e,t),[e,t,r])}const Ur="suveren-theme",Vc="hap-theme";function Ps(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const t=localStorage.getItem(Vc);t!==null&&localStorage.getItem(Ur)===null&&localStorage.setItem(Ur,t),t!==null&&localStorage.removeItem(Vc)})();function Of(){const[e,t]=u.useState(()=>{const o=localStorage.getItem(Ur);return o==="light"||o==="dark"?o:"system"}),[n,r]=u.useState(()=>Ps(e));u.useEffect(()=>{const o=document.documentElement,i=Ps(e);o.setAttribute("data-theme",i),e==="system"?localStorage.removeItem(Ur):localStorage.setItem(Ur,e),r(Ps(e))},[e]),u.useEffect(()=>{if(e!=="system")return;const o=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>r(Ps("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 uy=5*60*1e3,dy=2e3;function Nl(){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,m]=u.useState(!1),[p,x]=u.useState(!1),w=u.useRef(null);return u.useEffect(()=>{let v=!1;const j=(y=!1)=>{fetch(y?"/health?refresh=1":"/health").then(S=>S.json()).then(S=>{v||(S.installMethod&&r(S.installMethod),typeof S.latestVersion<"u"&&l(S.latestVersion),S.updateAvailable&&t(!0),S.version&&(o(S.version),w.current===null?w.current=S.version:S.version!==w.current&&S.version!=="dev"&&d(!0)))}).catch(()=>{})};j(!0);const h=setInterval(()=>j(!1),p?dy:uy),g=()=>{document.visibilityState==="visible"&&j(!1)};return document.addEventListener("visibilitychange",g),window.addEventListener("focus",g),()=>{v=!0,clearInterval(h),document.removeEventListener("visibilitychange",g),window.removeEventListener("focus",g)}},[p]),{updateAvailable:e&&!f,installMethod:n,version:s,latestVersion:i,serverRestarted:c,startFastPolling:()=>x(!0),dismiss:()=>m(!0)}}function fy({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 py(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const Gc={system:"◑",light:"☀",dark:"☾"};function El({onMenuToggle:e}){const{user:t,logout:n}=Ae(),{theme:r,toggle:s}=Of(),{version:o,updateAvailable:i,latestVersion:l}=Nl(),c=py(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(fy,{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:Gc[r]}),a.jsx("button",{className:"nav-logout",onClick:n,children:"Logout"})]}):a.jsx("button",{className:"theme-toggle",onClick:s,title:`Theme: ${r}`,children:Gc[r]})}),t&&e&&a.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function At(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 Bf(e,t){const n={active:[],pending:[],expired:[],revoked:[]};for(const r of e)n[At(r,t)].push(r);return n}function my(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 Lt(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 Df=u.createContext(null),hy=3e4,gy=5e3,yy=3e5;function vy(e,t,n){return t===0?"loading":e!=null&&e.running?"running":e!=null&&e.error?"error":e&&n?"starting":"not-running"}function xy({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,m]=await Promise.all([$.getIntegrationManifests().catch(()=>(d=!0,{manifests:[]})),$.getMcpHealth().catch(()=>null)]);n(x=>({...x,manifests:f.manifests,integrations:(m==null?void 0:m.integrations)??x.integrations,activeSessions:(m==null?void 0:m.activeSessions)??x.activeSessions,mcpServerUp:!!m,manifestsError:d,fetchCount:x.fetchCount+1}));const p=f.manifests.filter(x=>x.oauth);if(p.length>0){const x=await Promise.all(p.map(async w=>[w.id,await $.getOAuthHealth(w.id)]));n(w=>({...w,authHealth:Object.fromEntries(x)}))}},[]),o=t.fetchCount>0&&t.manifests.some(d=>{const f=t.integrations.find(m=>m.id===d.id);return f&&!f.running});ue("integration-changed",s),Lt(s,o?gy:yy);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 m=r.current!==null&&f-r.current<hy;return t.manifests.map(p=>{const x=d.get(p.id),w=vy(x,t.fetchCount,m),v=t.authHealth[p.id];return{id:p.id,manifest:p,integration:x,state:w,authStatus:v==null?void 0:v.status,authAccount:v==null?void 0:v.account,authError:v==null?void 0:v.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(Df.Provider,{value:c,children:e})}function Tl(){const e=u.useContext(Df);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const wy=[{to:"/",icon:"□",label:"Dashboard"},{to:"/proposals",icon:"▷",label:"Pending Approvals",statusKey:"proposals"},{to:"/authorizations",icon:"☰",label:"Authorizations",statusKey:"authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief"},{to:"/audit",icon:"▣",label:"Receipts"},{to:"/groups",icon:"◉",label:"Team",teamOnly:!0},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations"},{to:"/settings",icon:"⚙",label:"AI Assistant",statusKey:"assistant"}];function Sy(){const{activeDomain:e}=Ae(),[t,n]=u.useState({}),r=u.useCallback(async()=>{try{const[s,o,i,l,c]=await Promise.all([$.getCredential("ai-config").catch(()=>null),$.getMyAttestations().catch(()=>null),$.getProposals(e||"owner").catch(()=>null),$.getProposalsForApprover().catch(()=>null),$.getAgentContext().catch(()=>"")]),d={};if(s&&!s.configured&&(d.assistant=1),o){const x=Bf(o).expired.length;x>0&&(d.authorizations=x)}const f=(i==null?void 0:i.length)??0,m=(l==null?void 0:l.length)??0,p=f+m;p>0&&(d.proposals=p),(!c||!c.trim())&&(d.brief=1),n(d)}catch{}},[e]);return ue("attestation-changed",r),ue("proposal-added",r),ue("proposal-resolved",r),ue("proposal-approved",r),ue("proposal-rejected",r),ue("team-membership-changed",r),Lt(r,3e5,e),t}const jy={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},ky={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 by(){const{mode:e,group:t,domain:n,activeTeam:r}=Ae(),s=Sy(),{attentionCount:o}=Tl(),i={...s};o>0&&(i.integrations=o);const l=wy.filter(p=>!p.teamOnly||e==="team"),c=u.useRef(null),[d,f]=u.useState(null),m=kt();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)},[m.pathname]),a.jsxs("div",{className:"sidebar",children:[a.jsx("ul",{className:"sidebar-nav",children:l.map(p=>{const x=p.statusKey?i[p.statusKey]:0;return a.jsx("li",{children:a.jsxs(Cl,{to:p.to,end:p.to==="/",className:({isActive:w})=>`sidebar-item${w?" active":""}`,children:[a.jsx("span",{className:"icon",children:p.icon}),p.label,x?a.jsx("span",{style:jy,children:x}):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:ky,role:"status","aria-live":"polite",children:d})]})}const wo="suveren:updatedTo";function Cy(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 Ny(){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 Uf(){const{updateAvailable:e,installMethod:t,version:n,latestVersion:r,serverRestarted:s,startFastPolling:o,dismiss:i}=Nl(),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[m,p]=u.useState(()=>{try{const y=sessionStorage.getItem(wo);if(y)return sessionStorage.removeItem(wo),y}catch{}return null}),x=Cy(t),w=u.useRef(null),v=y=>{try{sessionStorage.setItem(wo,y||r||"✓")}catch{}window.location.reload()};u.useEffect(()=>{if(!m)return;const y=setTimeout(()=>p(null),6e3);return()=>clearTimeout(y)},[m]),u.useEffect(()=>{if(!l||!s)return;const y=()=>Ny()?!1:(v(n),!0);if(y())return;const S=setInterval(y,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&&!m||!!m&&!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 y=()=>{var I;const k=((I=w.current)==null?void 0:I.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${k}px`)};y();const S=new ResizeObserver(y);return w.current&&S.observe(w.current),()=>{S.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[j]);const h=()=>{c(!0),o()},g=async()=>{try{await navigator.clipboard.writeText(x),f(!0),setTimeout(()=>f(!1),1800)}catch{}};return a.jsxs(a.Fragment,{children:[m&&!l&&a.jsx("div",{ref:w,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",m&&m!=="✓"?` — ${m} is live`:" — now live","."]}),a.jsx("button",{className:"update-banner-x",onClick:()=>p(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!l&&!m&&a.jsx("div",{ref:w,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:h,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:x}),a.jsx("button",{className:"btn btn-sm btn-primary",onClick:g,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:()=>v(n),children:"Reload now"}),a.jsx("button",{className:"btn btn-secondary",onClick:()=>c(!1),children:"Cancel"})]})]})})]})}const Ey={system:"◑",light:"☀",dark:"☾"},Ty=[{to:"/",icon:"□",label:"Dashboard"},{to:"/proposals",icon:"▷",label:"Pending Approvals"},{to:"/authorizations",icon:"☰",label:"Authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/audit",icon:"▣",label:"Receipts"},{to:"/groups",icon:"◉",label:"Team"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"AI Assistant"}];function zy({open:e,onClose:t}){const{user:n,activeGroup:r,activeDomain:s,logout:o}=Ae(),{theme:i,toggle:l}=Of(),c=kt();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:Ty.map(d=>a.jsxs(Cl,{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:Ey[i]}),"Theme: ",i]}),a.jsx("button",{className:"mobile-menu-action",onClick:()=>{o(),t()},children:"Logout"})]})]})]}):null}function Wf(e){return e.status==="pending"}function Iy(e,t){return e.filter(Wf).length+t.length}const jn=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],Ry=500;function Py(){const{user:e,domain:t}=Ae(),[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([$.getProposals(t||"owner").catch(()=>[]),$.getProposalsForApprover().catch(()=>[])]);r(Iy(l,c))}catch{r(0)}},[e,t]),i=u.useCallback(()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o()},Ry)},[o]);return u.useEffect(()=>(o(),()=>{s.current&&clearTimeout(s.current)}),[o]),ue(jn[0],i),ue(jn[1],i),ue(jn[2],i),ue(jn[3],i),ue(jn[4],i),ue(jn[5],i),ue(jn[6],i),n}const Kc="Suveren",_y="/favicon.svg",Ay="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",_s={x1:74.54,y1:22.74,x2:94.46,y2:34.24},$y=14,Ly="#f59e0b";function My(e){const t=Hf(e);return t>0?`(${t}) ${Kc}`:Kc}function Hf(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function Fy(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
52
- <path class="m" d="${Ay}"/>
53
- <line class="m" x1="${_s.x1}" y1="${_s.y1}" x2="${_s.x2}" y2="${_s.y2}"/>
54
- <circle cx="103" cy="103" r="25" fill="${Ly}"/>
55
- <style>.m{stroke:#111111;stroke-width:${$y};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 Oy(){return document.querySelector('link[rel="icon"]')}function Vf(e){const t=Hf(e);document.title=My(t);const n=Oy();if(!n)return;const r=t>0?Fy():_y;n.getAttribute("href")!==r&&n.setAttribute("href",r)}function By(){Vf(0)}function Dy(){const e=Py();return u.useEffect(()=>{Vf(e)},[e]),u.useEffect(()=>By,[]),null}function Uy(){const[e,t]=u.useState(!1);return a.jsxs(xy,{children:[a.jsx(Dy,{}),a.jsx(El,{onMenuToggle:()=>t(!e)}),a.jsx(Uf,{}),a.jsx(by,{}),a.jsx(zy,{open:e,onClose:()=>t(!1)}),a.jsx("div",{className:"main-content",children:a.jsx("div",{className:"page-inner",children:a.jsx(Cg,{})})})]})}function Wy(){const[e,t]=u.useState(""),{login:n,isLoading:r,error:s,clearError:o}=Ae(),[i,l]=u.useState(null),c=async()=>{if(e.trim()){o();try{await n(e)}catch(m){if(m instanceof Lf){l(m.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(El,{}),a.jsx(Uf,{}),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:m=>t(m.target.value),onKeyDown:m=>m.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((m,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,"."]}),m]},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:m=>m.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 Hy(){const{setActiveContext:e}=Ae(),t=qt(),[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 $.joinGroup(n.trim());e(p,p.myDomains[0]||""),t("/")}catch(p){l(p instanceof Error?p.message:"Failed to join group")}finally{d(!1)}}},m=async()=>{if(s.trim()){d(!0),l("");try{const p=await $.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(El,{}),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"&&m(),style:{flex:1},disabled:c}),a.jsx("button",{className:"btn btn-secondary",onClick:m,disabled:c,children:"Create"})]})]})]})})]})}const xi="suveren-setup-ai-skipped",wi="suveren-setup-agent-done",Si="suveren-setup-dismissed",Vy={"hap-setup-ai-skipped":xi,"hap-setup-agent-done":wi,"hap-setup-dismissed":Si};function Gy(){for(const[e,t]of Object.entries(Vy)){const n=localStorage.getItem(e);n!==null&&localStorage.getItem(t)===null&&localStorage.setItem(t,n),n!==null&&localStorage.removeItem(e)}}Gy();const So={"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:
51
+ Please change the parent <Route path="${h}"> to <Route path="${h==="/"?"*":`${h}/*`}">.`)}let f=kt(),m;if(t){let h=typeof t=="string"?hr(t):t;xe(c==="/"||((j=h.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 "${h.pathname}" was given in the \`location\` prop.`),m=h}else m=f;let p=m.pathname||"/",x=p;if(c!=="/"){let h=c.replace(/^\//,"").split("/");x="/"+p.replace(/^\//,"").split("/").slice(h.length).join("/")}let w=yf(e,{pathname:x});jt(d||w!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),jt(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.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 v=vg(w&&w.map(h=>Object.assign({},h,{params:Object.assign({},i,h.params),pathname:Ot([c,r.encodeLocation?r.encodeLocation(h.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathname]),pathnameBase:h.pathnameBase==="/"?c:Ot([c,r.encodeLocation?r.encodeLocation(h.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathnameBase])})),s,n);return t&&v?u.createElement(ps.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...m},navigationType:"POP"}},v):v}function mg(){let e=kg(),t=Zh(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 hg=u.createElement(mg,null),Tf=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=lg(e.digest);n&&(e=n)}let t=e!==void 0?u.createElement(Rt.Provider,{value:this.props.routeContext},u.createElement(xl.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?u.createElement(gg,{error:e},t):t}};Tf.contextType=ng;var vo=new WeakMap;function gg({children:e,error:t}){let{basename:n}=u.useContext(mt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=ig(t.digest);if(r){let s=vo.get(t);if(s)throw s;let o=Sf(r.location,n);if(wf&&!vo.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 vo.set(t,i),i}return u.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o.absoluteURL||o.to}`})}}return e}function yg({routeContext:e,match:t,children:n}){let r=u.useContext(gr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),u.createElement(Rt.Provider,{value:e},n)}function vg(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(m=>m.route.id&&(o==null?void 0:o[m.route.id])!==void 0);xe(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 m=s[f];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(l=f),m.route.id){let{loaderData:p,errors:x}=r,w=m.route.loader&&!p.hasOwnProperty(m.route.id)&&(!x||x[m.route.id]===void 0);if(m.route.lazy||w){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,m)=>{var p,x;c(f,{location:r.location,params:((x=(p=r.matches)==null?void 0:p[0])==null?void 0:x.params)??{},unstable_pattern:eg(r.matches),errorInfo:m})}:void 0;return s.reduceRight((f,m,p)=>{let x,w=!1,v=null,j=null;r&&(x=o&&m.route.id?o[m.route.id]:void 0,v=m.route.errorElement||hg,i&&(l<0&&p===0?(zf("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),w=!0,j=null):l===p&&(w=!0,j=m.route.hydrateFallbackElement||null)));let h=t.concat(s.slice(0,p+1)),g=()=>{let y;return x?y=v:w?y=j:m.route.Component?y=u.createElement(m.route.Component,null):m.route.element?y=m.route.element:y=f,u.createElement(yg,{match:m,routeContext:{outlet:f,matches:h,isDataRoute:r!=null},children:y})};return r&&(m.route.ErrorBoundary||m.route.errorElement||p===0)?u.createElement(Tf,{location:r.location,revalidation:r.revalidation,component:v,error:x,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:d}):g()},null)}function wl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function xg(e){let t=u.useContext(gr);return xe(t,wl(e)),t}function wg(e){let t=u.useContext(Ua);return xe(t,wl(e)),t}function Sg(e){let t=u.useContext(Rt);return xe(t,wl(e)),t}function Sl(e){let t=Sg(e),n=t.matches[t.matches.length-1];return xe(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function jg(){return Sl("useRouteId")}function kg(){var r;let e=u.useContext(xl),t=wg("useRouteError"),n=Sl("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function bg(){let{router:e}=xg("useNavigate"),t=Sl("useNavigate"),n=u.useRef(!1);return Nf(()=>{n.current=!0}),u.useCallback(async(s,o={})=>{jt(n.current,Cf),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...o}))},[e,t])}var Uc={};function zf(e,t,n){!t&&!Uc[e]&&(Uc[e]=!0,jt(!1,n))}u.memo(Cg);function Cg({routes:e,future:t,state:n,isStatic:r,onError:s}){return Ef(e,void 0,{state:n,isStatic:r,onError:s})}function nn({to:e,replace:t,state:n,relative:r}){xe(yr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=u.useContext(mt);jt(!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(Rt),{pathname:i}=kt(),l=qt(),c=Da(e,vl(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 Ng(e){return fg(e.context)}function Re(e){xe(!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 Eg({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:s,static:o=!1,unstable_useTransitions:i}){xe(!yr(),"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=hr(n));let{pathname:d="/",search:f="",hash:m="",state:p=null,key:x="default",unstable_mask:w}=n,v=u.useMemo(()=>{let j=Jt(d,l);return j==null?null:{location:{pathname:j,search:f,hash:m,state:p,key:x,unstable_mask:w},navigationType:r}},[l,d,f,m,p,x,r,w]);return jt(v!=null,`<Router basename="${l}"> is not able to match the URL "${d}${f}${m}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:u.createElement(mt.Provider,{value:c},u.createElement(ps.Provider,{children:t,value:v}))}function Tg({children:e,location:t}){return pg(yi(e),t)}function yi(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,yi(r.props.children,o));return}xe(r.type===Re,`[${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>`),xe(!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=yi(r.props.children,o)),n.push(i)}),n}var Qs="get",Js="application/x-www-form-urlencoded";function Wa(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function zg(e){return Wa(e)&&e.tagName.toLowerCase()==="button"}function Ig(e){return Wa(e)&&e.tagName.toLowerCase()==="form"}function Rg(e){return Wa(e)&&e.tagName.toLowerCase()==="input"}function Pg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function _g(e,t){return e.button===0&&(!t||t==="_self")&&!Pg(e)}function vi(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 Ag(e,t){let n=vi(e);return t&&t.forEach((r,s)=>{n.has(s)||t.getAll(s).forEach(o=>{n.append(s,o)})}),n}var Ps=null;function $g(){if(Ps===null)try{new FormData(document.createElement("form"),0),Ps=!1}catch{Ps=!0}return Ps}var Lg=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function xo(e){return e!=null&&!Lg.has(e)?(jt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Js}"`),null):e}function Mg(e,t){let n,r,s,o,i;if(Ig(e)){let l=e.getAttribute("action");r=l?Jt(l,t):null,n=e.getAttribute("method")||Qs,s=xo(e.getAttribute("enctype"))||Js,o=new FormData(e)}else if(zg(e)||Rg(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?Jt(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Qs,s=xo(e.getAttribute("formenctype"))||xo(l.getAttribute("enctype"))||Js,o=new FormData(l,e),!$g()){let{name:d,type:f,value:m}=e;if(f==="image"){let p=d?`${d}.`:"";o.append(`${p}x`,"0"),o.append(`${p}y`,"0")}else d&&o.append(d,m)}}else{if(Wa(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Qs,r=null,s=Js,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 jl(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Fg(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&&Jt(s.pathname,t)==="/"?s.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:s.pathname=`${s.pathname.replace(/\/$/,"")}.${r}`,s}async function Og(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 Bg(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 Dg(e,t,n){let r=await Promise.all(e.map(async s=>{let o=t.routes[s.route.id];if(o){let i=await Og(o,n);return i.links?i.links():[]}return[]}));return Vg(r.flat(1).filter(Bg).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function Wc(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 m;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:((m=n[0])==null?void 0:m.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof p=="boolean")return p}return!0}):[]}function Ug(e,t,{includeHydrateFallback:n}={}){return Wg(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 Wg(e){return[...new Set(e)]}function Hg(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Vg(e,t){let n=new Set;return new Set(t),e.reduce((r,s)=>{let o=JSON.stringify(Hg(s));return n.has(o)||(n.add(o),r.push({key:o,link:s})),r},[])}function If(){let e=u.useContext(gr);return jl(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Gg(){let e=u.useContext(Ua);return jl(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var kl=u.createContext(void 0);kl.displayName="FrameworkContext";function Rf(){let e=u.useContext(kl);return jl(e,"You must render this element inside a <HydratedRouter> element"),e}function Kg(e,t){let n=u.useContext(kl),[r,s]=u.useState(!1),[o,i]=u.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:f,onTouchStart:m}=t,p=u.useRef(null);u.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let v=h=>{h.forEach(g=>{i(g.isIntersecting)})},j=new IntersectionObserver(v,{threshold:.5});return p.current&&j.observe(p.current),()=>{j.disconnect()}}},[e]),u.useEffect(()=>{if(r){let v=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(v)}}},[r]);let x=()=>{s(!0)},w=()=>{s(!1),i(!1)};return n?e!=="intent"?[o,p,{}]:[o,p,{onFocus:Er(l,x),onBlur:Er(c,w),onMouseEnter:Er(d,x),onMouseLeave:Er(f,w),onTouchStart:Er(m,x)}]:[!1,p,{}]}function Er(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Yg({page:e,...t}){let{router:n}=If(),r=u.useMemo(()=>yf(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?u.createElement(Jg,{page:e,matches:r,...t}):null}function Qg(e){let{manifest:t,routeModules:n}=Rf(),[r,s]=u.useState([]);return u.useEffect(()=>{let o=!1;return Dg(e,t,n).then(i=>{o||s(i)}),()=>{o=!0}},[e,t,n]),r}function Jg({page:e,matches:t,...n}){let r=kt(),{future:s,manifest:o,routeModules:i}=Rf(),{basename:l}=If(),{loaderData:c,matches:d}=Gg(),f=u.useMemo(()=>Wc(e,t,d,o,r,"data"),[e,t,d,o,r]),m=u.useMemo(()=>Wc(e,t,d,o,r,"assets"),[e,t,d,o,r]),p=u.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let v=new Set,j=!1;if(t.forEach(g=>{var S;let y=o.routes[g.route.id];!y||!y.hasLoader||(!f.some(k=>k.route.id===g.route.id)&&g.route.id in c&&((S=i[g.route.id])!=null&&S.shouldRevalidate)||y.hasClientLoader?j=!0:v.add(g.route.id))}),v.size===0)return[];let h=Fg(e,l,s.unstable_trailingSlashAwareDataRequests,"data");return j&&v.size>0&&h.searchParams.set("_routes",t.filter(g=>v.has(g.route.id)).map(g=>g.route.id).join(",")),[h.pathname+h.search]},[l,s.unstable_trailingSlashAwareDataRequests,c,r,o,f,t,e,i]),x=u.useMemo(()=>Ug(m,o),[m,o]),w=Qg(m);return u.createElement(u.Fragment,null,p.map(v=>u.createElement("link",{key:v,rel:"prefetch",as:"fetch",href:v,...n})),x.map(v=>u.createElement("link",{key:v,rel:"modulepreload",href:v,...n})),w.map(({key:v,link:j})=>u.createElement("link",{key:v,nonce:n.nonce,...j,crossOrigin:j.crossOrigin??n.crossOrigin})))}function Xg(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var qg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{qg&&(window.__reactRouterVersion="7.13.1")}catch{}function Zg({basename:e,children:t,unstable_useTransitions:n,window:r}){let s=u.useRef();s.current==null&&(s.current=zh({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(Eg,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:o,unstable_useTransitions:n})}var Pf=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Qe=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:m,viewTransition:p,unstable_defaultShouldRevalidate:x,...w},v){let{basename:j,navigator:h,unstable_useTransitions:g}=u.useContext(mt),y=typeof f=="string"&&Pf.test(f),S=Sf(f,j);f=S.to;let k=cg(f,{relative:s}),I=kt(),R=null;if(l){let T=Da(l,[],I.unstable_mask?I.unstable_mask.pathname:"/",!0);j!=="/"&&(T.pathname=T.pathname==="/"?j:Ot([j,T.pathname])),R=h.createHref(T)}let[_,C,z]=Kg(r,w),D=ny(f,{replace:i,unstable_mask:l,state:c,target:d,preventScrollReset:m,relative:s,viewTransition:p,unstable_defaultShouldRevalidate:x,unstable_useTransitions:g});function Y(T){t&&t(T),T.defaultPrevented||D(T)}let K=!(S.isExternal||o),W=u.createElement("a",{...w,...z,href:(K?R:void 0)||S.absoluteURL||k,onClick:K?Y:t,ref:Xg(v,C),target:d,"data-discover":!y&&n==="render"?"true":void 0});return _&&!y?u.createElement(u.Fragment,null,W,u.createElement(Yg,{page:k})):W});Qe.displayName="Link";var bl=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 m=ms(i,{relative:d.relative}),p=kt(),x=u.useContext(Ua),{navigator:w,basename:v}=u.useContext(mt),j=x!=null&&iy(m)&&l===!0,h=w.encodeLocation?w.encodeLocation(m).pathname:m.pathname,g=p.pathname,y=x&&x.navigation&&x.navigation.location?x.navigation.location.pathname:null;n||(g=g.toLowerCase(),y=y?y.toLowerCase():null,h=h.toLowerCase()),y&&v&&(y=Jt(y,v)||y);const S=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let k=g===h||!s&&g.startsWith(h)&&g.charAt(S)==="/",I=y!=null&&(y===h||!s&&y.startsWith(h)&&y.charAt(h.length)==="/"),R={isActive:k,isPending:I,isTransitioning:j},_=k?t:void 0,C;typeof r=="function"?C=r(R):C=[r,k?"active":null,I?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let z=typeof o=="function"?o(R):o;return u.createElement(Qe,{...d,"aria-current":_,className:C,ref:f,style:z,to:i,viewTransition:l},typeof c=="function"?c(R):c)});bl.displayName="NavLink";var ey=u.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:s,state:o,method:i=Qs,action:l,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:m,unstable_defaultShouldRevalidate:p,...x},w)=>{let{unstable_useTransitions:v}=u.useContext(mt),j=ay(),h=oy(l,{relative:d}),g=i.toLowerCase()==="get"?"get":"post",y=typeof l=="string"&&Pf.test(l),S=k=>{if(c&&c(k),k.defaultPrevented)return;k.preventDefault();let I=k.nativeEvent.submitter,R=(I==null?void 0:I.getAttribute("formmethod"))||i,_=()=>j(I||k.currentTarget,{fetcherKey:t,method:R,navigate:n,replace:s,state:o,relative:d,preventScrollReset:f,viewTransition:m,unstable_defaultShouldRevalidate:p});v&&n!==!1?u.startTransition(()=>_()):_()};return u.createElement("form",{ref:w,method:g,action:h,onSubmit:r?c:S,...x,"data-discover":!y&&e==="render"?"true":void 0})});ey.displayName="Form";function ty(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function _f(e){let t=u.useContext(gr);return xe(t,ty(e)),t}function ny(e,{target:t,replace:n,unstable_mask:r,state:s,preventScrollReset:o,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c,unstable_useTransitions:d}={}){let f=qt(),m=kt(),p=ms(e,{relative:i});return u.useCallback(x=>{if(_g(x,t)){x.preventDefault();let w=n!==void 0?n:is(m)===is(p),v=()=>f(e,{replace:w,unstable_mask:r,state:s,preventScrollReset:o,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c});d?u.startTransition(()=>v()):v()}},[m,f,p,n,r,s,t,e,o,i,l,c,d])}function Af(e){jt(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(vi(e)),n=u.useRef(!1),r=kt(),s=u.useMemo(()=>Ag(r.search,n.current?null:t.current),[r.search]),o=qt(),i=u.useCallback((l,c)=>{const d=vi(typeof l=="function"?l(new URLSearchParams(s)):l);n.current=!0,o("?"+d,c)},[o,s]);return[s,i]}var ry=0,sy=()=>`__${String(++ry)}__`;function ay(){let{router:e}=_f("useSubmit"),{basename:t}=u.useContext(mt),n=jg(),r=e.fetch,s=e.navigate;return u.useCallback(async(o,i={})=>{let{action:l,method:c,encType:d,formData:f,body:m}=Mg(o,t);if(i.navigate===!1){let p=i.fetcherKey||sy();await r(p,n,i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:m,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:m,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 oy(e,{relative:t}={}){let{basename:n}=u.useContext(mt),r=u.useContext(Rt);xe(r,"useFormAction must be used inside a RouteContext");let[s]=r.matches.slice(-1),o={...ms(e||".",{relative:t})},i=kt();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(m=>m).forEach(m=>l.append("index",m));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:Ot([n,o.pathname])),is(o)}function iy(e,{relative:t}={}){let n=u.useContext(kf);xe(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=_f("useViewTransitionState"),s=ms(e,{relative:t});if(!n.isTransitioning)return!1;let o=Jt(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=Jt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return ja(s.pathname,i)!=null||ja(s.pathname,o)!=null}class $f extends Error{constructor(n){super("different_account");vr(this,"summary");this.name="DifferentAccountError",this.summary=n}}class ly{constructor(){vr(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 $f(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 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 m=new Date(c);m.setUTCDate(c.getUTCDate()-f),l.push(m.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 $=new ly,Lf=u.createContext(null);function cy({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),[m,p]=u.useState(null),[x,w]=u.useState(!1),[v,j]=u.useState(""),h=u.useRef(!1),g=u.useRef(null),y=u.useCallback(async()=>{if(h.current)try{const _=await $.getMyTeam();if(_){const{group:C,membership:z}=_;f(C),p(z),s("team"),i(C);const D=g.current??z.domains[0]??"owner";c(D)}else f(null),p(null),s("personal")}catch{}},[]);u.useEffect(()=>{const _=()=>{document.visibilityState==="visible"&&y()};return document.addEventListener("visibilitychange",_),()=>document.removeEventListener("visibilitychange",_)},[y]);const S=u.useCallback(async(_,C={})=>{w(!0),j("");try{$.setApiKey(_),h.current=!0;const z=await $.login(_,C);n(z),g.current=z.id;const D=await $.getGroups(),Y=D.find(K=>K.isPersonal)??D[0]??null;i(Y),c("owner"),await y()}catch(z){throw $.clearApiKey(),h.current=!1,j(z instanceof Error?z.message:"Login failed"),z}finally{w(!1)}},[y]),k=u.useCallback(async()=>{await $.logout(),$.clearApiKey(),h.current=!1,g.current=null,n(null),i(null),c(""),f(null),p(null),s("personal"),j("")},[]),I=u.useCallback(()=>j(""),[]),R=u.useCallback((_,C)=>{i(_),c(C)},[]);return a.jsx(Lf.Provider,{value:{user:t,mode:r,group:o,domain:l,groupId:(o==null?void 0:o.id)??null,activeTeam:d,activeMembership:m,isLoading:x,error:v,login:S,logout:k,clearError:I,activeGroup:o,activeDomain:l,groups:o?[o]:[],setActiveContext:R,refreshGroups:y},children:e})}function Ae(){const e=u.useContext(Lf);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const Mf=u.createContext(null);function uy({children:e}){const{user:t}=Ae(),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=$.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,m=>{let p;try{p=JSON.parse(m.data)}catch{p=null}const x=o.current.get(f);if(x)for(const w of x)try{w(p)}catch(v){console.error(`[EventSource] handler for "${f}" threw:`,v)}});return()=>{c.close(),n.current=null,s(!1)}},[t]),a.jsx(Mf.Provider,{value:{connected:r,addListener:i},children:e})}function ue(e,t){const n=u.useContext(Mf);if(!n)return;const{addListener:r}=n;u.useEffect(()=>r(e,t),[e,t,r])}const Wr="suveren-theme",Hc="hap-theme";function _s(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const t=localStorage.getItem(Hc);t!==null&&localStorage.getItem(Wr)===null&&localStorage.setItem(Wr,t),t!==null&&localStorage.removeItem(Hc)})();function Ff(){const[e,t]=u.useState(()=>{const o=localStorage.getItem(Wr);return o==="light"||o==="dark"?o:"system"}),[n,r]=u.useState(()=>_s(e));u.useEffect(()=>{const o=document.documentElement,i=_s(e);o.setAttribute("data-theme",i),e==="system"?localStorage.removeItem(Wr):localStorage.setItem(Wr,e),r(_s(e))},[e]),u.useEffect(()=>{if(e!=="system")return;const o=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>r(_s("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 dy=5*60*1e3,fy=2e3;function Cl(){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,m]=u.useState(!1),[p,x]=u.useState(!1),w=u.useRef(null);return u.useEffect(()=>{let v=!1;const j=(y=!1)=>{fetch(y?"/health?refresh=1":"/health").then(S=>S.json()).then(S=>{v||(S.installMethod&&r(S.installMethod),typeof S.latestVersion<"u"&&l(S.latestVersion),S.updateAvailable&&t(!0),S.version&&(o(S.version),w.current===null?w.current=S.version:S.version!==w.current&&S.version!=="dev"&&d(!0)))}).catch(()=>{})};j(!0);const h=setInterval(()=>j(!1),p?fy:dy),g=()=>{document.visibilityState==="visible"&&j(!1)};return document.addEventListener("visibilitychange",g),window.addEventListener("focus",g),()=>{v=!0,clearInterval(h),document.removeEventListener("visibilitychange",g),window.removeEventListener("focus",g)}},[p]),{updateAvailable:e&&!f,installMethod:n,version:s,latestVersion:i,serverRestarted:c,startFastPolling:()=>x(!0),dismiss:()=>m(!0)}}function py({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 my(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const Vc={system:"◑",light:"☀",dark:"☾"};function Nl({onMenuToggle:e}){const{user:t,logout:n}=Ae(),{theme:r,toggle:s}=Ff(),{version:o,updateAvailable:i,latestVersion:l}=Cl(),c=my(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(py,{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:Vc[r]}),a.jsx("button",{className:"nav-logout",onClick:n,children:"Logout"})]}):a.jsx("button",{className:"theme-toggle",onClick:s,title:`Theme: ${r}`,children:Vc[r]})}),t&&e&&a.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function At(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 Of(e,t){const n={active:[],pending:[],expired:[],revoked:[]};for(const r of e)n[At(r,t)].push(r);return n}function hy(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 Lt(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 Bf=u.createContext(null),gy=3e4,yy=5e3,vy=3e5;function xy(e,t,n){return t===0?"loading":e!=null&&e.running?"running":e!=null&&e.error?"error":e&&n?"starting":"not-running"}function wy({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,m]=await Promise.all([$.getIntegrationManifests().catch(()=>(d=!0,{manifests:[]})),$.getMcpHealth().catch(()=>null)]);n(x=>({...x,manifests:f.manifests,integrations:(m==null?void 0:m.integrations)??x.integrations,activeSessions:(m==null?void 0:m.activeSessions)??x.activeSessions,mcpServerUp:!!m,manifestsError:d,fetchCount:x.fetchCount+1}));const p=f.manifests.filter(x=>x.oauth);if(p.length>0){const x=await Promise.all(p.map(async w=>[w.id,await $.getOAuthHealth(w.id)]));n(w=>({...w,authHealth:Object.fromEntries(x)}))}},[]),o=t.fetchCount>0&&t.manifests.some(d=>{const f=t.integrations.find(m=>m.id===d.id);return f&&!f.running});ue("integration-changed",s),Lt(s,o?yy:vy);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 m=r.current!==null&&f-r.current<gy;return t.manifests.map(p=>{const x=d.get(p.id),w=xy(x,t.fetchCount,m),v=t.authHealth[p.id];return{id:p.id,manifest:p,integration:x,state:w,authStatus:v==null?void 0:v.status,authAccount:v==null?void 0:v.account,authError:v==null?void 0:v.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(Bf.Provider,{value:c,children:e})}function El(){const e=u.useContext(Bf);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const Sy=[{to:"/",icon:"□",label:"Dashboard"},{to:"/proposals",icon:"▷",label:"Pending Approvals",statusKey:"proposals"},{to:"/authorizations",icon:"☰",label:"Authorizations",statusKey:"authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief"},{to:"/audit",icon:"▣",label:"Receipts"},{to:"/groups",icon:"◉",label:"Team",teamOnly:!0},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations"},{to:"/settings",icon:"⚙",label:"AI Assistant",statusKey:"assistant"}];function jy(){const{activeDomain:e}=Ae(),[t,n]=u.useState({}),r=u.useCallback(async()=>{try{const[s,o,i,l,c]=await Promise.all([$.getCredential("ai-config").catch(()=>null),$.getMyAttestations().catch(()=>null),$.getProposals(e||"owner").catch(()=>null),$.getProposalsForApprover().catch(()=>null),$.getAgentContext().catch(()=>"")]),d={};if(s&&!s.configured&&(d.assistant=1),o){const x=Of(o).expired.length;x>0&&(d.authorizations=x)}const f=(i==null?void 0:i.length)??0,m=(l==null?void 0:l.length)??0,p=f+m;p>0&&(d.proposals=p),(!c||!c.trim())&&(d.brief=1),n(d)}catch{}},[e]);return ue("attestation-changed",r),ue("proposal-added",r),ue("proposal-resolved",r),ue("proposal-approved",r),ue("proposal-rejected",r),ue("team-membership-changed",r),Lt(r,3e5,e),t}const ky={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},by={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 Cy(){const{mode:e,group:t,domain:n,activeTeam:r}=Ae(),s=jy(),{attentionCount:o}=El(),i={...s};o>0&&(i.integrations=o);const l=Sy.filter(p=>!p.teamOnly||e==="team"),c=u.useRef(null),[d,f]=u.useState(null),m=kt();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)},[m.pathname]),a.jsxs("div",{className:"sidebar",children:[a.jsx("ul",{className:"sidebar-nav",children:l.map(p=>{const x=p.statusKey?i[p.statusKey]:0;return a.jsx("li",{children:a.jsxs(bl,{to:p.to,end:p.to==="/",className:({isActive:w})=>`sidebar-item${w?" active":""}`,children:[a.jsx("span",{className:"icon",children:p.icon}),p.label,x?a.jsx("span",{style:ky,children:x}):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:by,role:"status","aria-live":"polite",children:d})]})}const wo="suveren:updatedTo";function Ny(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 Ey(){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 Df(){const{updateAvailable:e,installMethod:t,version:n,latestVersion:r,serverRestarted:s,startFastPolling:o,dismiss:i}=Cl(),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[m,p]=u.useState(()=>{try{const y=sessionStorage.getItem(wo);if(y)return sessionStorage.removeItem(wo),y}catch{}return null}),x=Ny(t),w=u.useRef(null),v=y=>{try{sessionStorage.setItem(wo,y||r||"✓")}catch{}window.location.reload()};u.useEffect(()=>{if(!m)return;const y=setTimeout(()=>p(null),6e3);return()=>clearTimeout(y)},[m]),u.useEffect(()=>{if(!l||!s)return;const y=()=>Ey()?!1:(v(n),!0);if(y())return;const S=setInterval(y,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&&!m||!!m&&!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 y=()=>{var I;const k=((I=w.current)==null?void 0:I.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${k}px`)};y();const S=new ResizeObserver(y);return w.current&&S.observe(w.current),()=>{S.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[j]);const h=()=>{c(!0),o()},g=async()=>{try{await navigator.clipboard.writeText(x),f(!0),setTimeout(()=>f(!1),1800)}catch{}};return a.jsxs(a.Fragment,{children:[m&&!l&&a.jsx("div",{ref:w,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",m&&m!=="✓"?` — ${m} is live`:" — now live","."]}),a.jsx("button",{className:"update-banner-x",onClick:()=>p(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!l&&!m&&a.jsx("div",{ref:w,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:h,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:x}),a.jsx("button",{className:"btn btn-sm btn-primary",onClick:g,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:()=>v(n),children:"Reload now"}),a.jsx("button",{className:"btn btn-secondary",onClick:()=>c(!1),children:"Cancel"})]})]})})]})}const Ty={system:"◑",light:"☀",dark:"☾"},zy=[{to:"/",icon:"□",label:"Dashboard"},{to:"/proposals",icon:"▷",label:"Pending Approvals"},{to:"/authorizations",icon:"☰",label:"Authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/audit",icon:"▣",label:"Receipts"},{to:"/groups",icon:"◉",label:"Team"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"AI Assistant"}];function Iy({open:e,onClose:t}){const{user:n,activeGroup:r,activeDomain:s,logout:o}=Ae(),{theme:i,toggle:l}=Ff(),c=kt();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:zy.map(d=>a.jsxs(bl,{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:Ty[i]}),"Theme: ",i]}),a.jsx("button",{className:"mobile-menu-action",onClick:()=>{o(),t()},children:"Logout"})]})]})]}):null}function Uf(e){return e.status==="pending"}function Ry(e,t){return e.filter(Uf).length+t.length}const jn=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],Py=500;function _y(){const{user:e,domain:t}=Ae(),[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([$.getProposals(t||"owner").catch(()=>[]),$.getProposalsForApprover().catch(()=>[])]);r(Ry(l,c))}catch{r(0)}},[e,t]),i=u.useCallback(()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o()},Py)},[o]);return u.useEffect(()=>(o(),()=>{s.current&&clearTimeout(s.current)}),[o]),ue(jn[0],i),ue(jn[1],i),ue(jn[2],i),ue(jn[3],i),ue(jn[4],i),ue(jn[5],i),ue(jn[6],i),n}const Gc="Suveren",Ay="/favicon.svg",$y="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",As={x1:74.54,y1:22.74,x2:94.46,y2:34.24},Ly=14,My="#f59e0b";function Fy(e){const t=Wf(e);return t>0?`(${t}) ${Gc}`:Gc}function Wf(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function Oy(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
52
+ <path class="m" d="${$y}"/>
53
+ <line class="m" x1="${As.x1}" y1="${As.y1}" x2="${As.x2}" y2="${As.y2}"/>
54
+ <circle cx="103" cy="103" r="25" fill="${My}"/>
55
+ <style>.m{stroke:#111111;stroke-width:${Ly};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 By(){return document.querySelector('link[rel="icon"]')}function Hf(e){const t=Wf(e);document.title=Fy(t);const n=By();if(!n)return;const r=t>0?Oy():Ay;n.getAttribute("href")!==r&&n.setAttribute("href",r)}function Dy(){Hf(0)}function Uy(){const e=_y();return u.useEffect(()=>{Hf(e)},[e]),u.useEffect(()=>Dy,[]),null}function Wy(){const[e,t]=u.useState(!1);return a.jsxs(wy,{children:[a.jsx(Uy,{}),a.jsx(Nl,{onMenuToggle:()=>t(!e)}),a.jsx(Df,{}),a.jsx(Cy,{}),a.jsx(Iy,{open:e,onClose:()=>t(!1)}),a.jsx("div",{className:"main-content",children:a.jsx("div",{className:"page-inner",children:a.jsx(Ng,{})})})]})}function Hy(){const[e,t]=u.useState(""),{login:n,isLoading:r,error:s,clearError:o}=Ae(),[i,l]=u.useState(null),c=async()=>{if(e.trim()){o();try{await n(e)}catch(m){if(m instanceof $f){l(m.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(Nl,{}),a.jsx(Df,{}),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:m=>t(m.target.value),onKeyDown:m=>m.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((m,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,"."]}),m]},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:m=>m.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 Vy(){const{setActiveContext:e}=Ae(),t=qt(),[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 $.joinGroup(n.trim());e(p,p.myDomains[0]||""),t("/")}catch(p){l(p instanceof Error?p.message:"Failed to join group")}finally{d(!1)}}},m=async()=>{if(s.trim()){d(!0),l("");try{const p=await $.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(Nl,{}),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"&&m(),style:{flex:1},disabled:c}),a.jsx("button",{className:"btn btn-secondary",onClick:m,disabled:c,children:"Create"})]})]})]})})]})}const xi="suveren-setup-ai-skipped",wi="suveren-setup-agent-done",Si="suveren-setup-dismissed",Gy={"hap-setup-ai-skipped":xi,"hap-setup-agent-done":wi,"hap-setup-dismissed":Si};function Ky(){for(const[e,t]of Object.entries(Gy)){const n=localStorage.getItem(e);n!==null&&localStorage.getItem(t)===null&&localStorage.setItem(t,n),n!==null&&localStorage.removeItem(e)}}Ky();const So={"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
57
 
58
58
  ${JSON.stringify({mcpServers:{"suveren-gateway":{url:`${e}/sse`}}},null,2)}`},other:{label:"Other",snippet:e=>`Streamable HTTP: POST ${e}/mcp
59
59
  SSE transport: GET ${e}/sse
60
- Health check: GET ${e}/health`}};function Ky({aiConfigured:e,hasRunningIntegration:t,hasActiveAuth:n,hasAgentConnected:r,mcpEndpoint:s}){const[o,i]=u.useState(()=>localStorage.getItem(xi)==="true"),[l,c]=u.useState(()=>localStorage.getItem(wi)==="true"),[d,f]=u.useState(()=>localStorage.getItem(Si)==="true"),[m,p]=u.useState(null),[x,w]=u.useState("claude-code"),[v,j]=u.useState(!1),h=[{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"}],g=h.filter(C=>C.status==="done"||C.status==="skipped").length,y=g===h.length,S=u.useCallback(()=>{localStorage.setItem(xi,"true"),i(!0)},[]),k=u.useCallback(()=>{localStorage.setItem(wi,"true"),c(!0),p(null)},[]),I=u.useCallback(()=>{localStorage.setItem(Si,"true"),f(!0)},[]),R=u.useCallback(async C=>{try{await navigator.clipboard.writeText(C),j(!0),setTimeout(()=>j(!1),2e3)}catch{}},[]);if(d||y)return null;const _=h.findIndex(C=>C.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:I,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:h.map((C,z)=>{const D=z===_,Y=C.status==="done"||C.status==="skipped"?"●":"○",K=C.status==="done"?"var(--success)":C.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:K,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:Y}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[C.to&&C.status==="pending"?a.jsx(Qe,{to:C.to,style:{fontSize:"0.9rem",fontWeight:D?600:500,color:D?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:C.label}):C.status==="pending"&&z===3?a.jsx("button",{onClick:()=>p(m===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:C.label}):a.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:C.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:C.label}),C.optional&&C.status==="pending"&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),C.status==="skipped"&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),C.detail&&C.status==="pending"&&D&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:C.detail})]}),C.optional&&C.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"}),C.to&&C.status==="pending"&&a.jsx(Qe,{to:C.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),z===3&&m===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(So).map(([W,T])=>a.jsx("button",{onClick:()=>w(W),style:{padding:"0.375rem 0.75rem",fontSize:"0.75rem",fontWeight:x===W?600:400,background:x===W?"var(--accent-subtle)":"transparent",color:x===W?"var(--accent)":"var(--text-secondary)",border:`1px solid ${x===W?"var(--accent)":"var(--border)"}`,borderRadius:"0.375rem",cursor:"pointer"},children:T.label},W))}),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:So[x].snippet(s)}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>R(So[x].snippet(s)),children:v?"Copied":"Copy"}),a.jsx("button",{className:"btn btn-primary btn-sm",onClick:k,children:"Done"})]})]})]},z)})}),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:`${g/h.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:[g," of ",h.length," complete"]})]})]})}function zn({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 jo(){return a.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[a.jsx(zn,{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(zn,{variant:"line",style:{width:"35%"}}),a.jsx(zn,{variant:"line-sm",style:{width:"65%"}})]})]})}const Yy={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},Gf=e=>Yy[e]??e,Qy={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 Jy(e){return Qy[e]??{chip:"Blocked",sev:"info"}}function Xy(e){const t=Gf(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 qy(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 Zy=5;function ev(){const[e,t]=u.useState(null),[n,r]=u.useState(0),[s,o]=u.useState(!1),[i,l]=u.useState(!1),c=u.useCallback(()=>{$.getDenials({limit:s?200:Zy}).then(({count:f,records:m})=>{r(f),t(m),l(!1)}).catch(()=>l(!0))},[s]);if(u.useEffect(()=>{c()},[c]),Lt(c,12e4),i||e===null)return null;const d=(f,m)=>{const p=Jy(f.reason);return a.jsxs("div",{className:"rb-row",children:[a.jsx("span",{className:`rb-dot ${p.sev==="act"?"act":p.sev==="info"?"info":""}`,"aria-hidden":"true"}),a.jsxs("div",{className:"rb-body",children:[a.jsx("div",{className:"rb-line",children:Xy(f)}),a.jsxs("div",{className:"rb-meta",children:[a.jsx("span",{className:`rb-chip ${p.sev==="act"?"act":p.sev==="warn"?"warn":""}`,children:p.chip}),a.jsx("span",{className:"rb-via",children:Gf(f.integrationId)})]}),p.fixTo&&a.jsx(Qe,{className:"rb-fix",to:p.fixTo,children:"Set a read window →"})]}),a.jsx("div",{className:"rb-when",children:qy(f.ts,Date.now())})]},`${f.ts}-${m}`)};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>0&&a.jsx("span",{className:"rb-count",children:n})]}),e.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.jsx("h3",{children:"Nothing blocked"}),a.jsx("p",{children:"Your agent has stayed within every limit you set."})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"rb-sub",children:"Limits you set that stopped your agent. Seeing them here means the gateway is doing its job."}),a.jsx("div",{className:"rb-rows",children:e.map(d)}),!s&&n>e.length&&a.jsx("div",{className:"rb-foot",children:a.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!0),children:["View all ",n," blocks"]})})]})]})}const tv=30*60;function ko(e){return e.replace(/@.*$/,"").split("/").pop()??e}function nv(){var W;const{domain:e}=Ae(),[t,n]=u.useState([]),[r,s]=u.useState([]),[o,i]=u.useState([]),[l,c]=u.useState(!0),[d,f]=u.useState(!1),[m,p]=u.useState(!1),[x,w]=u.useState(!1),{entries:v,activeSessions:j,loading:h}=Tl(),g=!h,y=u.useCallback(()=>{$.getMyAttestations().then(T=>{n(T),f(!0)}).catch(()=>f(!0)),$.getProposals(e||"owner").then(T=>{s(T),p(!0)}).catch(()=>p(!0)),$.getProposalsForApprover().then(T=>i(T)).catch(()=>i([])),$.getCredential("ai-config").then(T=>{c(T.configured),w(!0)}).catch(()=>w(!0))},[e]);ue("attestation-changed",y),ue("proposal-added",y),ue("proposal-resolved",y),ue("proposal-approved",y),ue("proposal-rejected",y),Lt(y,3e5,e);const S=d&&m&&x&&g,k=Bf(t),I=k.active,R=k.expired,_=I.filter(T=>T.remaining_seconds!==null&&T.remaining_seconds<=tv),C=r.filter(Wf),z=v.filter(T=>T.state==="running"),D=v.filter(T=>T.state==="starting"),Y=v.filter(T=>T.state==="not-running"||T.state==="error"),K=[];for(const T of o)K.push({label:"Approval needed",detail:`${T.tool} — above-cap action under ${ko(T.profileId)}`,to:"/proposals",color:"var(--warning)"});for(const T of C)K.push({label:"Approval pending",detail:`${T.tool} awaiting your approval`,to:"/proposals",color:"var(--warning)"});for(const T of _){const q=Math.ceil((T.remaining_seconds??0)/60);K.push({label:"Expiring soon",detail:`${T.title??ko(T.profile_id)} — ${q} min remaining`,to:"/authorizations",color:"var(--warning)"})}for(const T of R)K.push({label:"Expired",detail:T.title??ko(T.profile_id),to:"/authorizations",color:"var(--danger)"});for(const T of Y)K.push({label:T.state==="error"?"Integration error":"Integration stopped",detail:T.state==="error"&&((W=T.integration)!=null&&W.error)?`${T.manifest.name}: ${T.integration.error}`:`${T.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"});for(const T of D)K.push({label:"Integration starting",detail:`${T.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const T of v)T.authStatus==="failed"&&T.state!=="not-running"&&T.state!=="error"&&K.push({label:"Reconnect needed",detail:`${T.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return l||K.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"})}),S&&a.jsx(Ky,{aiConfigured:l,hasRunningIntegration:z.length>0,hasActiveAuth:I.length>0,hasAgentConnected:j>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(Qe,{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:I.length>0?"var(--success)":"var(--text-tertiary)"},children:I.length}):a.jsx(zn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),a.jsx(Qe,{to:"/proposals",style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[m?a.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:C.length>0?"var(--warning)":"var(--text-tertiary)"},children:C.length}):a.jsx(zn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),a.jsx(Qe,{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:R.length>0?"var(--danger)":"var(--text-tertiary)"},children:R.length}):a.jsx(zn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),a.jsx(Qe,{to:"/integrations",style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[g?a.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:z.length>0?"var(--success)":"var(--text-tertiary)"},children:z.length}):a.jsx(zn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),K.length>0?a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:K.map((T,q)=>a.jsx(Qe,{to:T.to,style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"0.75rem 1rem",display:"flex",alignItems:"center",gap:"0.75rem"},children:[a.jsx("span",{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",background:T.color,flexShrink:0}}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:T.label}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T.detail})]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]})},q))}):S?a.jsx("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:a.jsx("div",{style:{fontSize:"0.9rem",color:"var(--text-secondary)"},children:"All clear. Nothing needs your attention."})}):a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[a.jsx(jo,{}),a.jsx(jo,{}),a.jsx(jo,{})]}),a.jsx(ev,{})]})}const rv=["Scope & Limits","Intent","Authorize"];function Kf({currentStep:e,onStepClick:t}){const n=qt();return a.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",marginBottom:"2.5rem"},children:[a.jsx("div",{style:{display:"flex",alignItems:"center",flex:1,overflow:"hidden"},children:rv.map((r,s)=>{const o=s+2,i=o<e,l=o===e;return a.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[s>0&&a.jsx("div",{style:{width:"1.5rem",height:"2px",background:i?"var(--accent)":"var(--border)",flexShrink:1}}),a.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0},children:[a.jsx("div",{className:`step-circle${i?" completed":""}${l?" current":""}`,onClick:i&&t?()=>t(o):void 0,style:i&&t?{cursor:"pointer"}:void 0,children:i?"✓":s+1}),a.jsx("span",{className:"step-label-text",style:{fontSize:"0.6rem",marginTop:"0.3rem",color:l?"var(--accent)":i?"var(--text-secondary)":"var(--text-tertiary)",fontWeight:l?600:400,textAlign:"center"},children:r})]})]},o)})}),a.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>n("/agent/new"),style:{flexShrink:0,fontSize:"0.8rem",marginTop:"0.15rem"},children:"Cancel"})]})}const sv=40;function ze(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,sv)}function av({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:"})," ",ze(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 ov({integrationId:e,field:t,value:n,onChange:r,disabled:s,onLabels:o}){const[i,l]=u.useState(null),[c,d]=u.useState(null),[f,m]=u.useState(!0);u.useEffect(()=>{let w=!1;return $.discoverScopeField(e,t).then(v=>{var j;w||(l(v.options),m(!1),(j=v.options)!=null&&j.length&&(o==null||o(Object.fromEntries(v.options.map(h=>[h.value,h.label])))))}).catch(v=>{w||(d(v instanceof Error?v.message:String(v)),m(!1))}),()=>{w=!0}},[e,t]);const p=new Set(n.split(",").map(w=>w.trim()).filter(Boolean)),x=w=>{const v=new Set(p);v.has(w)?v.delete(w):v.add(w),r(Array.from(v).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:w=>r(w.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(w=>{const v=w.extras??{},j=typeof v.access=="string"?v.access:void 0,h=j==="reader",g=v.primary===!0;return a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:h?"var(--text-tertiary)":"var(--text-primary)",cursor:s||h?"not-allowed":"pointer"},title:h?"Read-only — you can authorize list/read but not writes":void 0,children:[a.jsx("input",{type:"checkbox",checked:p.has(String(w.value)),onChange:()=>x(String(w.value)),disabled:s||h}),a.jsx("span",{children:w.label||w.value}),g&&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]})]},w.value)})})}function iv(e){return e.replace(/@.*$/,"").split("/").pop()??e}function lv(e,t){return t.displayName?t.displayName:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function cv(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function uv(e){var t;return!!(e.enum&&((t=e.constraint)!=null&&t.enforceable.includes("subset")))}function Yc(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 dv(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}function fv(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function pv(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 mv(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 hv({id:e,value:t,onChange:n,disabled:r,placeholder:s,unit:o}){const i=fv(o),l=pv(o),c=dv(o),d=mv(t,o),f=t===""?null:Number(t),m=()=>{const x=t===""?0:Number(t),w=x%i,v=w===0?x+i:x+(i-w);n(String(v))},p=()=>{const x=t===""?0:Number(t);if(x<=0)return;const w=x%i,v=w===0?x-i:x-w;n(String(Math.max(0,v)))};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:p,disabled:r||t===""||Number(t)<=0,"aria-label":"Decrease",children:"−"}),a.jsx("input",{id:e,className:"stepper-input",type:"number",min:0,step:i,value:t,placeholder:s??"0",onChange:x=>n(x.target.value),onFocus:x=>x.target.select(),disabled:r}),a.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:m,disabled:r,"aria-label":"Increase",children:"+"}),c&&a.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:c})]}),l.length>0&&!r&&a.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:l.map(x=>a.jsx("button",{type:"button",className:`preset-chip${f===x.value?" preset-chip-selected":""}`,onClick:()=>n(String(x.value)),children:x.label},x.value))}),d&&a.jsxs("div",{className:"bounded-input-echo",children:["≈ ",d]})]})}function Qc({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 gv({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),m=t?t.split(",").map(h=>h.trim()).filter(Boolean):[],p=h=>{const g=h.trim();if(!g)return;if(!Yc(g,s)){d(!0);return}d(!1);const y=m.includes(g)?m:[...m,g];n(y.join(",")),l("")},x=h=>{const g=m.filter((y,S)=>S!==h);n(g.join(","))},w=h=>{h.key==="Enter"||h.key===","||h.key==="Tab"?i.trim()&&(h.preventDefault(),p(i)):h.key==="Backspace"&&!i&&m.length>0&&x(m.length-1)},v=h=>{const g=h.clipboardData.getData("text");if(g.includes(",")){h.preventDefault();const S=g.split(",").map(I=>I.trim()).filter(Boolean).filter(I=>Yc(I,s)),k=[...new Set([...m,...S])];n(k.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 h;return(h=f.current)==null?void 0:h.focus()},children:[m.map((h,g)=>a.jsxs("span",{className:"tag-pill",children:[h,!r&&a.jsx("button",{type:"button",className:"tag-remove",onClick:y=>{y.stopPropagation(),x(g)},"aria-label":`Remove ${h}`,children:"×"})]},h)),!r&&a.jsx("input",{ref:f,id:e,className:"tag-input-field",type:"text",value:i,onChange:h=>{l(h.target.value),d(!1)},onKeyDown:w,onPaste:v,onBlur:()=>{i.trim()&&p(i)},placeholder:m.length===0?o??j:""})]})}function yv({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 Jc({fieldKey:e,fieldDef:t,value:n,onChange:r,prefix:s,readOnly:o,twoColumn:i,discoveryIntegrationId:l,onLabels:c}){const d=lv(e,t),f=`${s}-field-${e}`,m=a.jsx(a.Fragment,{children:uv(t)?a.jsx(yv,{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(hv,{id:f,value:n,onChange:p=>r(e,p),disabled:o,unit:t.unit}):cv(t)?a.jsx(gv,{id:f,value:n,onChange:p=>r(e,p),disabled:o,format:t.format}):l?a.jsx(ov,{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(Qc,{htmlFor:f,label:d,description:t.description})}),a.jsx("div",{className:"bounds-field-input",children:m})]},`${s}-${e}`):a.jsxs("div",{className:"form-group",children:[a.jsx(Qc,{htmlFor:f,label:d,description:t.description}),m]},`${s}-${e}`)}function vv(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 xv(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 wv({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,m=e.contextSchema,p=f?Object.entries(f.fields).filter(([A,U])=>!(A==="profile"||A==="path"||U.enforced===!1||U.enforcedBy==="gatekeeper")):[],x=f?Object.entries(f.fields).filter(([,A])=>A.enforcedBy==="gatekeeper").filter(([,A])=>A.enforced!==!1).map(([A,U])=>U.displayName??A):[],w=m&&m.keyOrder.length>0?Object.entries(m.fields):[],v=s??i??{},j=o??{},h={};for(const[A]of p)h[A]=v[A]!==void 0?String(v[A]):"";const g={};for(const[A]of w)g[A]=j[A]!==void 0?String(j[A]):"";const[y,S]=u.useState(h),[k,I]=u.useState(g),[R,_]=u.useState({}),[C,z]=u.useState(null);u.useEffect(()=>{const A=iv(e.id);$.getIntegrationManifests().then(({manifests:U})=>{const O=U.find(G=>G.profile===A&&G.contextDiscovery&&Object.keys(G.contextDiscovery).length>0);z(O??null)}).catch(()=>z(null))},[e.id]);const D=vv(y,l),Y=xv(y,l==null?void 0:l.caps),K=(A,U)=>{S(O=>({...O,[A]:U}))},W=(A,U)=>{I(O=>({...O,[A]:U}))},T=()=>{const A={profile:e.id};for(const[O,G]of p)G.type==="number"?A[O]=y[O]===""?0:Number(y[O]):A[O]=y[O];const U={};for(const[O,G]of w)G.type==="number"?U[O]=k[O]===""?0:Number(k[O]):U[O]=k[O];return[A,U]},q=()=>{const[A,U]=T();t(A,U,R)},ee=()=>{const A=(l==null?void 0:l.caps)??{},U={...y};for(const X of Y)A[X]!==void 0&&(U[X]=String(A[X]));S(U);const O={profile:e.id};for(const[X,Z]of p)if(Z.type==="number"){const de=U[X]??"";O[X]=de===""?0:Number(de)}else O[X]=U[X]??"";const G={};for(const[X,Z]of w)Z.type==="number"?G[X]=k[X]===""?0:Number(k[X]):G[X]=k[X];t(O,G,R)},F=A=>{const U=l==null?void 0:l.caps;if(!U||U[A]===void 0)return null;const O=U[A],G=Y.has(A);return D==="hard-ceiling"&&G?a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",O," — exceeds team ceiling"]}):D==="above-approvers"&&G?a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",O," — above cap"]}):a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",O," ok"]})},L=()=>{var A;if(D==="no-config")return null;if(D==="approvers-dormant"){const U=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: ",U]}),a.jsxs("div",{children:["No caps are set on this profile, so ",U," 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 U=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 ",U,". Within-cap actions run per the mode you choose."]})]})}if(D==="hard-ceiling"){const U=Array.from(Y)[0],O=U?(A=l==null?void 0:l.caps)==null?void 0:A[U]:void 0,G=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 ",O??"the configured limit",". Lower your bound or ask ",G," 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:ee,children:"Save below cap"}),n&&a.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:n,children:"Cancel"})]})]})}return null},H=D==="hard-ceiling";return a.jsxs("div",{children:[w.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"})]})]}),w.map(([A,U])=>{var G;const O=!!((G=C==null?void 0:C.contextDiscovery)!=null&&G[A]);return a.jsx(Jc,{fieldKey:A,fieldDef:U,value:k[A],onChange:W,prefix:"context",readOnly:r,discoveryIntegrationId:O?C.id:void 0,onLabels:(X,Z)=>_(de=>({...de,[X]:Z}))},`context-${A}`)})]}),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 Service Provider"})]})]}),a.jsx("div",{className:"bounds-fields-grid",children:p.map(([A,U])=>{var O;return a.jsxs("div",{style:{display:"contents"},children:[a.jsx(Jc,{fieldKey:A,fieldDef:U,value:y[A],onChange:K,prefix:"bounds",readOnly:r,twoColumn:!0}),D!=="no-config"&&((O=l==null?void 0:l.caps)==null?void 0:O[A])!==void 0&&a.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:F(A)})]},`bounds-${A}`)})}),L(),x.length>0&&a.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[x.join(", ")," ",x.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(Qe,{to:"/integrations",children:"Integrations"}),"."]})]}),a.jsx("button",{className:"btn btn-primary",onClick:q,disabled:H,style:{marginTop:"0.5rem"},children:r?"Next: Gates":"Next: Problem Statement"})]})}function Sv(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 jv(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const kv="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 ja({target:e,currentText:t,onApply:n,greeting:r,placeholder:s,title:o}){const[i,l]=u.useState([{role:"assistant",content:r??kv}]),[c,d]=u.useState(""),[f,m]=u.useState(!1),[p,x]=u.useState(null),w=u.useRef(null);u.useEffect(()=>{w.current&&(w.current.scrollTop=w.current.scrollHeight)},[i,f]);const v=async()=>{const h=c.trim();if(!h||f)return;const g=[...i,{role:"user",content:h}];l(g),d(""),x(null),m(!0);try{const y=await $.aiChat({target:e,currentText:t,messages:g.filter((S,k)=>!(k===0&&S.role==="assistant"))});y.success&&y.reply?l(S=>[...S,{role:"assistant",content:y.reply}]):x(y.error??"AI returned no reply")}catch(y){x(y instanceof Error?y.message:"Chat failed")}finally{m(!1)}},j=h=>{h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.preventDefault(),v())};return a.jsxs("div",{className:"intent-chat",children:[a.jsx("h3",{className:"card-title",children:o??"AI Assistant"}),a.jsxs("div",{ref:w,className:"chat-messages",children:[i.map((h,g)=>{const y=h.role==="assistant"?Sv(h.content):null,S=y?jv(h.content):h.content;return a.jsx("div",{className:`chat-msg ${h.role}`,children:a.jsxs("div",{className:"chat-msg-body",children:[S&&a.jsx("div",{className:"chat-msg-prose",children:S}),y!==null&&a.jsxs(a.Fragment,{children:[a.jsx("pre",{className:"chat-fenced-block",children:y}),a.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>n(y),children:"Apply this draft"})]})]})},g)}),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:h=>d(h.target.value),onKeyDown:j,placeholder:s??"Ask for help articulating the intent…",rows:1,disabled:f}),a.jsx("button",{type:"button",className:"chat-send-btn",onClick:v,disabled:f||!c.trim(),"aria-label":"Send",children:"↑"})]}),a.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Yf({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]),gf.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 bv(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cv(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 m,p;return((m=f.scope)==null?void 0:m.toLowerCase())===d||((p=f.scope)==null?void 0:p.split(",").map(x=>x.trim().toLowerCase()).includes(d))})},i=["\\[\\d+\\]",...r.map(bv)],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 m=f.scope&&f.scope!=="all (unscoped)"?f.scope:"all recipients",p=n?`${n}: ${m}`:m;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 Xc=`Why — What's the situation? Why does this need to happen?
60
+ Health check: GET ${e}/health`}};function Yy({aiConfigured:e,hasRunningIntegration:t,hasActiveAuth:n,hasAgentConnected:r,mcpEndpoint:s}){const[o,i]=u.useState(()=>localStorage.getItem(xi)==="true"),[l,c]=u.useState(()=>localStorage.getItem(wi)==="true"),[d,f]=u.useState(()=>localStorage.getItem(Si)==="true"),[m,p]=u.useState(null),[x,w]=u.useState("claude-code"),[v,j]=u.useState(!1),h=[{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"}],g=h.filter(C=>C.status==="done"||C.status==="skipped").length,y=g===h.length,S=u.useCallback(()=>{localStorage.setItem(xi,"true"),i(!0)},[]),k=u.useCallback(()=>{localStorage.setItem(wi,"true"),c(!0),p(null)},[]),I=u.useCallback(()=>{localStorage.setItem(Si,"true"),f(!0)},[]),R=u.useCallback(async C=>{try{await navigator.clipboard.writeText(C),j(!0),setTimeout(()=>j(!1),2e3)}catch{}},[]);if(d||y)return null;const _=h.findIndex(C=>C.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:I,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:h.map((C,z)=>{const D=z===_,Y=C.status==="done"||C.status==="skipped"?"●":"○",K=C.status==="done"?"var(--success)":C.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:K,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:Y}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[C.to&&C.status==="pending"?a.jsx(Qe,{to:C.to,style:{fontSize:"0.9rem",fontWeight:D?600:500,color:D?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:C.label}):C.status==="pending"&&z===3?a.jsx("button",{onClick:()=>p(m===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:C.label}):a.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:C.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:C.label}),C.optional&&C.status==="pending"&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),C.status==="skipped"&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),C.detail&&C.status==="pending"&&D&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:C.detail})]}),C.optional&&C.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"}),C.to&&C.status==="pending"&&a.jsx(Qe,{to:C.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),z===3&&m===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(So).map(([W,T])=>a.jsx("button",{onClick:()=>w(W),style:{padding:"0.375rem 0.75rem",fontSize:"0.75rem",fontWeight:x===W?600:400,background:x===W?"var(--accent-subtle)":"transparent",color:x===W?"var(--accent)":"var(--text-secondary)",border:`1px solid ${x===W?"var(--accent)":"var(--border)"}`,borderRadius:"0.375rem",cursor:"pointer"},children:T.label},W))}),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:So[x].snippet(s)}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>R(So[x].snippet(s)),children:v?"Copied":"Copy"}),a.jsx("button",{className:"btn btn-primary btn-sm",onClick:k,children:"Done"})]})]})]},z)})}),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:`${g/h.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:[g," of ",h.length," complete"]})]})]})}function zn({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 jo(){return a.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[a.jsx(zn,{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(zn,{variant:"line",style:{width:"35%"}}),a.jsx(zn,{variant:"line-sm",style:{width:"65%"}})]})]})}const Qy={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},Vf=e=>Qy[e]??e,Jy={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 Xy(e){return Jy[e]??{chip:"Blocked",sev:"info"}}function qy(e){const t=Vf(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 Zy(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 ev=5;function tv(){const[e,t]=u.useState(null),[n,r]=u.useState(0),[s,o]=u.useState(!1),[i,l]=u.useState(!1),c=u.useCallback(()=>{$.getDenials({limit:s?200:ev}).then(({count:f,records:m})=>{r(f),t(m),l(!1)}).catch(()=>l(!0))},[s]);if(u.useEffect(()=>{c()},[c]),Lt(c,12e4),i||e===null)return null;const d=(f,m)=>{const p=Xy(f.reason);return a.jsxs("div",{className:"rb-row",children:[a.jsx("span",{className:`rb-dot ${p.sev==="act"?"act":p.sev==="info"?"info":""}`,"aria-hidden":"true"}),a.jsxs("div",{className:"rb-body",children:[a.jsx("div",{className:"rb-line",children:qy(f)}),a.jsxs("div",{className:"rb-meta",children:[a.jsx("span",{className:`rb-chip ${p.sev==="act"?"act":p.sev==="warn"?"warn":""}`,children:p.chip}),a.jsx("span",{className:"rb-via",children:Vf(f.integrationId)})]}),p.fixTo&&a.jsx(Qe,{className:"rb-fix",to:p.fixTo,children:"Set a read window →"})]}),a.jsx("div",{className:"rb-when",children:Zy(f.ts,Date.now())})]},`${f.ts}-${m}`)};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>0&&a.jsx("span",{className:"rb-count",children:n})]}),e.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.jsx("h3",{children:"Nothing blocked"}),a.jsx("p",{children:"Your agent has stayed within every limit you set."})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"rb-sub",children:"Limits you set that stopped your agent. Seeing them here means the gateway is doing its job."}),a.jsx("div",{className:"rb-rows",children:e.map(d)}),!s&&n>e.length&&a.jsx("div",{className:"rb-foot",children:a.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!0),children:["View all ",n," blocks"]})})]})]})}const nv=30*60;function ko(e){return e.replace(/@.*$/,"").split("/").pop()??e}function rv(){var W;const{domain:e}=Ae(),[t,n]=u.useState([]),[r,s]=u.useState([]),[o,i]=u.useState([]),[l,c]=u.useState(!0),[d,f]=u.useState(!1),[m,p]=u.useState(!1),[x,w]=u.useState(!1),{entries:v,activeSessions:j,loading:h}=El(),g=!h,y=u.useCallback(()=>{$.getMyAttestations().then(T=>{n(T),f(!0)}).catch(()=>f(!0)),$.getProposals(e||"owner").then(T=>{s(T),p(!0)}).catch(()=>p(!0)),$.getProposalsForApprover().then(T=>i(T)).catch(()=>i([])),$.getCredential("ai-config").then(T=>{c(T.configured),w(!0)}).catch(()=>w(!0))},[e]);ue("attestation-changed",y),ue("proposal-added",y),ue("proposal-resolved",y),ue("proposal-approved",y),ue("proposal-rejected",y),Lt(y,3e5,e);const S=d&&m&&x&&g,k=Of(t),I=k.active,R=k.expired,_=I.filter(T=>T.remaining_seconds!==null&&T.remaining_seconds<=nv),C=r.filter(Uf),z=v.filter(T=>T.state==="running"),D=v.filter(T=>T.state==="starting"),Y=v.filter(T=>T.state==="not-running"||T.state==="error"),K=[];for(const T of o)K.push({label:"Approval needed",detail:`${T.tool} — above-cap action under ${ko(T.profileId)}`,to:"/proposals",color:"var(--warning)"});for(const T of C)K.push({label:"Approval pending",detail:`${T.tool} awaiting your approval`,to:"/proposals",color:"var(--warning)"});for(const T of _){const q=Math.ceil((T.remaining_seconds??0)/60);K.push({label:"Expiring soon",detail:`${T.title??ko(T.profile_id)} — ${q} min remaining`,to:"/authorizations",color:"var(--warning)"})}for(const T of R)K.push({label:"Expired",detail:T.title??ko(T.profile_id),to:"/authorizations",color:"var(--danger)"});for(const T of Y)K.push({label:T.state==="error"?"Integration error":"Integration stopped",detail:T.state==="error"&&((W=T.integration)!=null&&W.error)?`${T.manifest.name}: ${T.integration.error}`:`${T.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"});for(const T of D)K.push({label:"Integration starting",detail:`${T.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const T of v)T.authStatus==="failed"&&T.state!=="not-running"&&T.state!=="error"&&K.push({label:"Reconnect needed",detail:`${T.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return l||K.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"})}),S&&a.jsx(Yy,{aiConfigured:l,hasRunningIntegration:z.length>0,hasActiveAuth:I.length>0,hasAgentConnected:j>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(Qe,{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:I.length>0?"var(--success)":"var(--text-tertiary)"},children:I.length}):a.jsx(zn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),a.jsx(Qe,{to:"/proposals",style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[m?a.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:C.length>0?"var(--warning)":"var(--text-tertiary)"},children:C.length}):a.jsx(zn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),a.jsx(Qe,{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:R.length>0?"var(--danger)":"var(--text-tertiary)"},children:R.length}):a.jsx(zn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),a.jsx(Qe,{to:"/integrations",style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[g?a.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:z.length>0?"var(--success)":"var(--text-tertiary)"},children:z.length}):a.jsx(zn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),K.length>0?a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:K.map((T,q)=>a.jsx(Qe,{to:T.to,style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"0.75rem 1rem",display:"flex",alignItems:"center",gap:"0.75rem"},children:[a.jsx("span",{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",background:T.color,flexShrink:0}}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:T.label}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T.detail})]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]})},q))}):S?a.jsx("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:a.jsx("div",{style:{fontSize:"0.9rem",color:"var(--text-secondary)"},children:"All clear. Nothing needs your attention."})}):a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[a.jsx(jo,{}),a.jsx(jo,{}),a.jsx(jo,{})]}),a.jsx(tv,{})]})}const sv=["Scope & Limits","Intent","Authorize"];function Gf({currentStep:e,onStepClick:t}){const n=qt();return a.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",marginBottom:"2.5rem"},children:[a.jsx("div",{style:{display:"flex",alignItems:"center",flex:1,overflow:"hidden"},children:sv.map((r,s)=>{const o=s+2,i=o<e,l=o===e;return a.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[s>0&&a.jsx("div",{style:{width:"1.5rem",height:"2px",background:i?"var(--accent)":"var(--border)",flexShrink:1}}),a.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0},children:[a.jsx("div",{className:`step-circle${i?" completed":""}${l?" current":""}`,onClick:i&&t?()=>t(o):void 0,style:i&&t?{cursor:"pointer"}:void 0,children:i?"✓":s+1}),a.jsx("span",{className:"step-label-text",style:{fontSize:"0.6rem",marginTop:"0.3rem",color:l?"var(--accent)":i?"var(--text-secondary)":"var(--text-tertiary)",fontWeight:l?600:400,textAlign:"center"},children:r})]})]},o)})}),a.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>n("/agent/new"),style:{flexShrink:0,fontSize:"0.8rem",marginTop:"0.15rem"},children:"Cancel"})]})}const av=40;function ze(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,av)}function ov({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:"})," ",ze(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 iv({integrationId:e,field:t,value:n,onChange:r,disabled:s,onLabels:o}){const[i,l]=u.useState(null),[c,d]=u.useState(null),[f,m]=u.useState(!0);u.useEffect(()=>{let w=!1;return $.discoverScopeField(e,t).then(v=>{var j;w||(l(v.options),m(!1),(j=v.options)!=null&&j.length&&(o==null||o(Object.fromEntries(v.options.map(h=>[h.value,h.label])))))}).catch(v=>{w||(d(v instanceof Error?v.message:String(v)),m(!1))}),()=>{w=!0}},[e,t]);const p=new Set(n.split(",").map(w=>w.trim()).filter(Boolean)),x=w=>{const v=new Set(p);v.has(w)?v.delete(w):v.add(w),r(Array.from(v).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:w=>r(w.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(w=>{const v=w.extras??{},j=typeof v.access=="string"?v.access:void 0,h=j==="reader",g=v.primary===!0;return a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:h?"var(--text-tertiary)":"var(--text-primary)",cursor:s||h?"not-allowed":"pointer"},title:h?"Read-only — you can authorize list/read but not writes":void 0,children:[a.jsx("input",{type:"checkbox",checked:p.has(String(w.value)),onChange:()=>x(String(w.value)),disabled:s||h}),a.jsx("span",{children:w.label||w.value}),g&&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]})]},w.value)})})}function lv(e){return e.replace(/@.*$/,"").split("/").pop()??e}function cv(e,t){return t.displayName?t.displayName:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function uv(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function dv(e){var t;return!!(e.enum&&((t=e.constraint)!=null&&t.enforceable.includes("subset")))}function Kc(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 fv(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}function pv(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function mv(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 hv(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 gv({id:e,value:t,onChange:n,disabled:r,placeholder:s,unit:o}){const i=pv(o),l=mv(o),c=fv(o),d=hv(t,o),f=t===""?null:Number(t),m=()=>{const x=t===""?0:Number(t),w=x%i,v=w===0?x+i:x+(i-w);n(String(v))},p=()=>{const x=t===""?0:Number(t);if(x<=0)return;const w=x%i,v=w===0?x-i:x-w;n(String(Math.max(0,v)))};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:p,disabled:r||t===""||Number(t)<=0,"aria-label":"Decrease",children:"−"}),a.jsx("input",{id:e,className:"stepper-input",type:"number",min:0,step:i,value:t,placeholder:s??"0",onChange:x=>n(x.target.value),onFocus:x=>x.target.select(),disabled:r}),a.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:m,disabled:r,"aria-label":"Increase",children:"+"}),c&&a.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:c})]}),l.length>0&&!r&&a.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:l.map(x=>a.jsx("button",{type:"button",className:`preset-chip${f===x.value?" preset-chip-selected":""}`,onClick:()=>n(String(x.value)),children:x.label},x.value))}),d&&a.jsxs("div",{className:"bounded-input-echo",children:["≈ ",d]})]})}function Yc({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 yv({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),m=t?t.split(",").map(h=>h.trim()).filter(Boolean):[],p=h=>{const g=h.trim();if(!g)return;if(!Kc(g,s)){d(!0);return}d(!1);const y=m.includes(g)?m:[...m,g];n(y.join(",")),l("")},x=h=>{const g=m.filter((y,S)=>S!==h);n(g.join(","))},w=h=>{h.key==="Enter"||h.key===","||h.key==="Tab"?i.trim()&&(h.preventDefault(),p(i)):h.key==="Backspace"&&!i&&m.length>0&&x(m.length-1)},v=h=>{const g=h.clipboardData.getData("text");if(g.includes(",")){h.preventDefault();const S=g.split(",").map(I=>I.trim()).filter(Boolean).filter(I=>Kc(I,s)),k=[...new Set([...m,...S])];n(k.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 h;return(h=f.current)==null?void 0:h.focus()},children:[m.map((h,g)=>a.jsxs("span",{className:"tag-pill",children:[h,!r&&a.jsx("button",{type:"button",className:"tag-remove",onClick:y=>{y.stopPropagation(),x(g)},"aria-label":`Remove ${h}`,children:"×"})]},h)),!r&&a.jsx("input",{ref:f,id:e,className:"tag-input-field",type:"text",value:i,onChange:h=>{l(h.target.value),d(!1)},onKeyDown:w,onPaste:v,onBlur:()=>{i.trim()&&p(i)},placeholder:m.length===0?o??j:""})]})}function vv({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 Qc({fieldKey:e,fieldDef:t,value:n,onChange:r,prefix:s,readOnly:o,twoColumn:i,discoveryIntegrationId:l,onLabels:c}){const d=cv(e,t),f=`${s}-field-${e}`,m=a.jsx(a.Fragment,{children:dv(t)?a.jsx(vv,{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(gv,{id:f,value:n,onChange:p=>r(e,p),disabled:o,unit:t.unit}):uv(t)?a.jsx(yv,{id:f,value:n,onChange:p=>r(e,p),disabled:o,format:t.format}):l?a.jsx(iv,{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(Yc,{htmlFor:f,label:d,description:t.description})}),a.jsx("div",{className:"bounds-field-input",children:m})]},`${s}-${e}`):a.jsxs("div",{className:"form-group",children:[a.jsx(Yc,{htmlFor:f,label:d,description:t.description}),m]},`${s}-${e}`)}function xv(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 wv(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 Sv({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,m=e.contextSchema,p=f?Object.entries(f.fields).filter(([A,U])=>!(A==="profile"||A==="path"||U.enforced===!1||U.enforcedBy==="gatekeeper")):[],x=f?Object.entries(f.fields).filter(([,A])=>A.enforcedBy==="gatekeeper").filter(([,A])=>A.enforced!==!1).map(([A,U])=>U.displayName??A):[],w=m&&m.keyOrder.length>0?Object.entries(m.fields):[],v=s??i??{},j=o??{},h={};for(const[A]of p)h[A]=v[A]!==void 0?String(v[A]):"";const g={};for(const[A]of w)g[A]=j[A]!==void 0?String(j[A]):"";const[y,S]=u.useState(h),[k,I]=u.useState(g),[R,_]=u.useState({}),[C,z]=u.useState(null);u.useEffect(()=>{const A=lv(e.id);$.getIntegrationManifests().then(({manifests:U})=>{const O=U.find(G=>G.profile===A&&G.contextDiscovery&&Object.keys(G.contextDiscovery).length>0);z(O??null)}).catch(()=>z(null))},[e.id]);const D=xv(y,l),Y=wv(y,l==null?void 0:l.caps),K=(A,U)=>{S(O=>({...O,[A]:U}))},W=(A,U)=>{I(O=>({...O,[A]:U}))},T=()=>{const A={profile:e.id};for(const[O,G]of p)G.type==="number"?A[O]=y[O]===""?0:Number(y[O]):A[O]=y[O];const U={};for(const[O,G]of w)G.type==="number"?U[O]=k[O]===""?0:Number(k[O]):U[O]=k[O];return[A,U]},q=()=>{const[A,U]=T();t(A,U,R)},ee=()=>{const A=(l==null?void 0:l.caps)??{},U={...y};for(const X of Y)A[X]!==void 0&&(U[X]=String(A[X]));S(U);const O={profile:e.id};for(const[X,Z]of p)if(Z.type==="number"){const de=U[X]??"";O[X]=de===""?0:Number(de)}else O[X]=U[X]??"";const G={};for(const[X,Z]of w)Z.type==="number"?G[X]=k[X]===""?0:Number(k[X]):G[X]=k[X];t(O,G,R)},F=A=>{const U=l==null?void 0:l.caps;if(!U||U[A]===void 0)return null;const O=U[A],G=Y.has(A);return D==="hard-ceiling"&&G?a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",O," — exceeds team ceiling"]}):D==="above-approvers"&&G?a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",O," — above cap"]}):a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",O," ok"]})},L=()=>{var A;if(D==="no-config")return null;if(D==="approvers-dormant"){const U=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: ",U]}),a.jsxs("div",{children:["No caps are set on this profile, so ",U," 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 U=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 ",U,". Within-cap actions run per the mode you choose."]})]})}if(D==="hard-ceiling"){const U=Array.from(Y)[0],O=U?(A=l==null?void 0:l.caps)==null?void 0:A[U]:void 0,G=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 ",O??"the configured limit",". Lower your bound or ask ",G," 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:ee,children:"Save below cap"}),n&&a.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:n,children:"Cancel"})]})]})}return null},H=D==="hard-ceiling";return a.jsxs("div",{children:[w.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"})]})]}),w.map(([A,U])=>{var G;const O=!!((G=C==null?void 0:C.contextDiscovery)!=null&&G[A]);return a.jsx(Qc,{fieldKey:A,fieldDef:U,value:k[A],onChange:W,prefix:"context",readOnly:r,discoveryIntegrationId:O?C.id:void 0,onLabels:(X,Z)=>_(de=>({...de,[X]:Z}))},`context-${A}`)})]}),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 Service Provider"})]})]}),a.jsx("div",{className:"bounds-fields-grid",children:p.map(([A,U])=>{var O;return a.jsxs("div",{style:{display:"contents"},children:[a.jsx(Qc,{fieldKey:A,fieldDef:U,value:y[A],onChange:K,prefix:"bounds",readOnly:r,twoColumn:!0}),D!=="no-config"&&((O=l==null?void 0:l.caps)==null?void 0:O[A])!==void 0&&a.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:F(A)})]},`bounds-${A}`)})}),L(),x.length>0&&a.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[x.join(", ")," ",x.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(Qe,{to:"/integrations",children:"Integrations"}),"."]})]}),a.jsx("button",{className:"btn btn-primary",onClick:q,disabled:H,style:{marginTop:"0.5rem"},children:r?"Next: Gates":"Next: Problem Statement"})]})}function jv(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 kv(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const bv="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 ka({target:e,currentText:t,onApply:n,greeting:r,placeholder:s,title:o}){const[i,l]=u.useState([{role:"assistant",content:r??bv}]),[c,d]=u.useState(""),[f,m]=u.useState(!1),[p,x]=u.useState(null),w=u.useRef(null);u.useEffect(()=>{w.current&&(w.current.scrollTop=w.current.scrollHeight)},[i,f]);const v=async()=>{const h=c.trim();if(!h||f)return;const g=[...i,{role:"user",content:h}];l(g),d(""),x(null),m(!0);try{const y=await $.aiChat({target:e,currentText:t,messages:g.filter((S,k)=>!(k===0&&S.role==="assistant"))});y.success&&y.reply?l(S=>[...S,{role:"assistant",content:y.reply}]):x(y.error??"AI returned no reply")}catch(y){x(y instanceof Error?y.message:"Chat failed")}finally{m(!1)}},j=h=>{h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.preventDefault(),v())};return a.jsxs("div",{className:"intent-chat",children:[a.jsx("h3",{className:"card-title",children:o??"AI Assistant"}),a.jsxs("div",{ref:w,className:"chat-messages",children:[i.map((h,g)=>{const y=h.role==="assistant"?jv(h.content):null,S=y?kv(h.content):h.content;return a.jsx("div",{className:`chat-msg ${h.role}`,children:a.jsxs("div",{className:"chat-msg-body",children:[S&&a.jsx("div",{className:"chat-msg-prose",children:S}),y!==null&&a.jsxs(a.Fragment,{children:[a.jsx("pre",{className:"chat-fenced-block",children:y}),a.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>n(y),children:"Apply this draft"})]})]})},g)}),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:h=>d(h.target.value),onKeyDown:j,placeholder:s??"Ask for help articulating the intent…",rows:1,disabled:f}),a.jsx("button",{type:"button",className:"chat-send-btn",onClick:v,disabled:f||!c.trim(),"aria-label":"Send",children:"↑"})]}),a.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Kf({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]),hf.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 Cv(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Nv(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 m,p;return((m=f.scope)==null?void 0:m.toLowerCase())===d||((p=f.scope)==null?void 0:p.split(",").map(x=>x.trim().toLowerCase()).includes(d))})},i=["\\[\\d+\\]",...r.map(Cv)],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 m=f.scope&&f.scope!=="all (unscoped)"?f.scope:"all recipients",p=n?`${n}: ${m}`:m;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 Jc=`Why — What's the situation? Why does this need to happen?
61
61
 
62
62
  Goal — What should the agent try to achieve?
63
63
 
64
- Watch out — What should the agent avoid or be careful about?`;function Nv(e,t,n,r){return Cv(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 Ev(){var le;const e=qt(),[t]=$f(),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),[m,p]=u.useState(null),[x,w]=u.useState({}),[v,j]=u.useState(Xc),[h,g]=u.useState(!1),[y,S]=u.useState(!0),[k,I]=u.useState(null),[R,_]=u.useState([]),[C,z]=u.useState(void 0),[D,Y]=u.useState(!1),[K,W]=u.useState(null),[T,q]=u.useState(null),[ee,F]=u.useState(null),[L,H]=u.useState([]),[A,U]=u.useState(null);u.useEffect(()=>{var he;const M=sessionStorage.getItem("agentAuth");if(!M){e("/agent/new");return}const J=JSON.parse(M);s(J);const te=sessionStorage.getItem("agentGate");if(te){const pe=JSON.parse(te);pe.bounds&&f(pe.bounds),pe.context&&p(pe.context),(he=pe.gateContent)!=null&&he.intent&&j(pe.gateContent.intent)}$.getProfile(J.profileId).then(pe=>i(pe)).catch(()=>e("/agent/new")).finally(()=>S(!1)),J.groupId&&Promise.all([$.getTeamProfileConfig(J.groupId,J.profileId).catch(()=>null),$.getGroupById(J.groupId).catch(()=>null),$.listUsers().catch(()=>[])]).then(([pe,Le,ot])=>{if(I(pe),pe){const De=new Map;for(const se of ot){const Ue=se.name&&se.email?`${se.name} (${se.email})`:se.name||se.email||se.id;De.set(se.id,Ue)}const ht=(Le==null?void 0:Le.members)??[];for(const se of ht){const Ue=se.userId??se.id;Ue&&(se.name&&se.email?De.set(Ue,`${se.name} (${se.email})`):se.name&&De.set(Ue,se.name))}const Ie=(pe.approvers??[]).map(se=>De.get(se)??se);_(Ie);const Ke=ht.find(se=>se.role==="admin");if(Ke){const se=Ke.userId??Ke.id;se&&z(De.get(se)??Ke.name)}}})},[e]);const O=d?Object.entries(d).filter(([M])=>M!=="profile"&&M!=="path").map(([M,J])=>`${M} = ${J}`).join(", "):"",G=(M,J,te)=>{f(M),p(J),te&&w(te),c(3)},X=v.trim()!==Xc.trim()&&v.trim()!=="",Z=M=>{X&&!confirm("Replace your current intent with the AI draft?")||j(M)},de=()=>{const M=o==null?void 0:o.ttl,J={intent:v},te=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...te,bounds:d,context:m,contextLabels:x,gateContent:J,ttlConfig:M})),e("/agent/review")},$e=async()=>{if(r){Y(!0),W(null),q(null),F(null),H([]),U(null);try{const M=await $.aiIntentReview({profileId:r.profileId,newIntent:v,context:m??void 0});H(M.grants??[]),M.success?M.review?W(M.review):q(M.note??"No other authorizations on this profile to compare against."):F(M.error??"Check failed.")}catch(M){F(M instanceof Error?M.message:"Check failed.")}finally{Y(!1)}}},Be=M=>{j(M),(K||T||ee)&&(W(null),q(null),F(null),H([]),U(null))};return y||!r||!o?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):a.jsxs(a.Fragment,{children:[a.jsx(Kf,{currentStep:l,onStepClick:M=>{M>=2&&c(M)}}),a.jsx(av,{profileId:r.profileId,bounds:O||void 0,groupName:r.groupName,domain:r.domain}),l===2&&a.jsx("div",{className:"card",children:a.jsx(wv,{profile:o,onConfirm:G,onCancel:()=>e("/agent/new"),initialBounds:d||void 0,initialContext:m||void 0,profileConfig:k,approverNames:R,adminName:C})}),l===3&&a.jsxs("div",{className:"intent-layout",children:[a.jsx("div",{className:"card intent-pane chat tool",children:a.jsx(ja,{target:{kind:"intent",profileId:r.profileId,bounds:O||void 0},currentText:v,onApply:Z})}),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:v,onChange:M=>Be(M.target.value)}),a.jsxs("div",{className:"char-counter",children:[v.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:$e,disabled:D||!X,children:D?"Checking…":"Check against my other grants"}),ee&&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:ee})]}),T&&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:T})]}),K&&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:Nv(K,L,U,ze(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:de,disabled:!X,children:"Continue to Review"})]}),(((le=k==null?void 0:k.approvers)==null?void 0:le.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 ",R.length>0?R.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",R.length>0?R.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:()=>g(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),a.jsx(Yf,{open:h,onClose:()=>g(!1),ariaLabel:"Intent assistant",children:a.jsx(ja,{target:{kind:"intent",profileId:r.profileId,bounds:O||void 0},currentText:v,onApply:M=>{Z(M),g(!1)}})}),A&&a.jsx("div",{className:"modal-backdrop",onClick:M=>M.target===M.currentTarget&&U(null),children:a.jsxs("div",{className:"modal",children:[a.jsxs("div",{className:"modal-header",children:[a.jsx("h3",{className:"modal-title",children:A.length>1?`Existing authorizations (${A.length})`:"Existing authorization"}),a.jsx("button",{className:"modal-close",onClick:()=>U(null),children:"×"})]}),a.jsx("div",{className:"modal-body",children:A.map((M,J)=>{var te;return a.jsxs("div",{style:{marginBottom:J<A.length-1?"1rem":0,paddingBottom:J<A.length-1?"1rem":0,borderBottom:J<A.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:M.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:((te=M.intent)==null?void 0:te.trim())||"(no intent recorded)"}),Object.entries(M.bounds).filter(([he])=>he!=="profile"&&he!=="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(M.bounds).filter(([he])=>he!=="profile"&&he!=="path").map(([he,pe])=>`${he}: ${pe}`).join(" · ")})]})]},J)})})]})})]})]})}function Tv(e){return e.normalize("NFC").replace(/\r\n?/g,`
64
+ Watch out — What should the agent avoid or be careful about?`;function Ev(e,t,n,r){return Nv(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 Tv(){var le;const e=qt(),[t]=Af(),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),[m,p]=u.useState(null),[x,w]=u.useState({}),[v,j]=u.useState(Jc),[h,g]=u.useState(!1),[y,S]=u.useState(!0),[k,I]=u.useState(null),[R,_]=u.useState([]),[C,z]=u.useState(void 0),[D,Y]=u.useState(!1),[K,W]=u.useState(null),[T,q]=u.useState(null),[ee,F]=u.useState(null),[L,H]=u.useState([]),[A,U]=u.useState(null);u.useEffect(()=>{var he;const M=sessionStorage.getItem("agentAuth");if(!M){e("/agent/new");return}const J=JSON.parse(M);s(J);const te=sessionStorage.getItem("agentGate");if(te){const pe=JSON.parse(te);pe.bounds&&f(pe.bounds),pe.context&&p(pe.context),(he=pe.gateContent)!=null&&he.intent&&j(pe.gateContent.intent)}$.getProfile(J.profileId).then(pe=>i(pe)).catch(()=>e("/agent/new")).finally(()=>S(!1)),J.groupId&&Promise.all([$.getTeamProfileConfig(J.groupId,J.profileId).catch(()=>null),$.getGroupById(J.groupId).catch(()=>null),$.listUsers().catch(()=>[])]).then(([pe,Le,ot])=>{if(I(pe),pe){const De=new Map;for(const se of ot){const Ue=se.name&&se.email?`${se.name} (${se.email})`:se.name||se.email||se.id;De.set(se.id,Ue)}const ht=(Le==null?void 0:Le.members)??[];for(const se of ht){const Ue=se.userId??se.id;Ue&&(se.name&&se.email?De.set(Ue,`${se.name} (${se.email})`):se.name&&De.set(Ue,se.name))}const Ie=(pe.approvers??[]).map(se=>De.get(se)??se);_(Ie);const Ke=ht.find(se=>se.role==="admin");if(Ke){const se=Ke.userId??Ke.id;se&&z(De.get(se)??Ke.name)}}})},[e]);const O=d?Object.entries(d).filter(([M])=>M!=="profile"&&M!=="path").map(([M,J])=>`${M} = ${J}`).join(", "):"",G=(M,J,te)=>{f(M),p(J),te&&w(te),c(3)},X=v.trim()!==Jc.trim()&&v.trim()!=="",Z=M=>{X&&!confirm("Replace your current intent with the AI draft?")||j(M)},de=()=>{const M=o==null?void 0:o.ttl,J={intent:v},te=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...te,bounds:d,context:m,contextLabels:x,gateContent:J,ttlConfig:M})),e("/agent/review")},$e=async()=>{if(r){Y(!0),W(null),q(null),F(null),H([]),U(null);try{const M=await $.aiIntentReview({profileId:r.profileId,newIntent:v,context:m??void 0});H(M.grants??[]),M.success?M.review?W(M.review):q(M.note??"No other authorizations on this profile to compare against."):F(M.error??"Check failed.")}catch(M){F(M instanceof Error?M.message:"Check failed.")}finally{Y(!1)}}},Be=M=>{j(M),(K||T||ee)&&(W(null),q(null),F(null),H([]),U(null))};return y||!r||!o?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):a.jsxs(a.Fragment,{children:[a.jsx(Gf,{currentStep:l,onStepClick:M=>{M>=2&&c(M)}}),a.jsx(ov,{profileId:r.profileId,bounds:O||void 0,groupName:r.groupName,domain:r.domain}),l===2&&a.jsx("div",{className:"card",children:a.jsx(Sv,{profile:o,onConfirm:G,onCancel:()=>e("/agent/new"),initialBounds:d||void 0,initialContext:m||void 0,profileConfig:k,approverNames:R,adminName:C})}),l===3&&a.jsxs("div",{className:"intent-layout",children:[a.jsx("div",{className:"card intent-pane chat tool",children:a.jsx(ka,{target:{kind:"intent",profileId:r.profileId,bounds:O||void 0},currentText:v,onApply:Z})}),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:v,onChange:M=>Be(M.target.value)}),a.jsxs("div",{className:"char-counter",children:[v.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:$e,disabled:D||!X,children:D?"Checking…":"Check against my other grants"}),ee&&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:ee})]}),T&&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:T})]}),K&&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:Ev(K,L,U,ze(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:de,disabled:!X,children:"Continue to Review"})]}),(((le=k==null?void 0:k.approvers)==null?void 0:le.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 ",R.length>0?R.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",R.length>0?R.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:()=>g(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),a.jsx(Kf,{open:h,onClose:()=>g(!1),ariaLabel:"Intent assistant",children:a.jsx(ka,{target:{kind:"intent",profileId:r.profileId,bounds:O||void 0},currentText:v,onApply:M=>{Z(M),g(!1)}})}),A&&a.jsx("div",{className:"modal-backdrop",onClick:M=>M.target===M.currentTarget&&U(null),children:a.jsxs("div",{className:"modal",children:[a.jsxs("div",{className:"modal-header",children:[a.jsx("h3",{className:"modal-title",children:A.length>1?`Existing authorizations (${A.length})`:"Existing authorization"}),a.jsx("button",{className:"modal-close",onClick:()=>U(null),children:"×"})]}),a.jsx("div",{className:"modal-body",children:A.map((M,J)=>{var te;return a.jsxs("div",{style:{marginBottom:J<A.length-1?"1rem":0,paddingBottom:J<A.length-1?"1rem":0,borderBottom:J<A.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:M.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:((te=M.intent)==null?void 0:te.trim())||"(no intent recorded)"}),Object.entries(M.bounds).filter(([he])=>he!=="profile"&&he!=="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(M.bounds).filter(([he])=>he!=="profile"&&he!=="path").map(([he,pe])=>`${he}: ${pe}`).join(" · ")})]})]},J)})})]})})]})]})}function zv(e){return e.normalize("NFC").replace(/\r\n?/g,`
65
65
  `).split(`
66
66
  `).map(s=>s.replace(/[ \t]+$/,"")).join(`
67
- `).replace(/\n+$/,"")}async function ji(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("")}async function Js(e,t){const n=t.boundsSchema??t.frameSchema;if(!n)throw new Error("Profile has no boundsSchema or frameSchema");const s=n.keyOrder.map(i=>`${i}=${String(e[i])}`).join(`
68
- `);return`sha256:${await ji(s)}`}async function Qf(e,t){if(!t.contextSchema||t.contextSchema.keyOrder.length===0)return`sha256:${await ji("")}`;const r=t.contextSchema.keyOrder.map(o=>`${o}=${String(e[o])}`).join(`
69
- `);return`sha256:${await ji(r)}`}async function ka(e){const t=new TextEncoder().encode(Tv(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 Jf(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 qc(e){return e==null?new Set:new Set(String(e).split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}function zv(e,t){for(const n of e)if(t.has(n))return!0;return!1}function Iv(e,t,n){for(const r of e){const s=qc(t[r]),o=qc(n[r]);if(!(s.size===0||o.size===0)&&!zv(s,o))return!1}return!0}function Rv(e){return e.length>24?`${e.slice(0,10)}…`:e}function Xf(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} (${Rv(o)})`:o}).join(", ")}function Pv(){var Ke,se,Ue;const e=qt(),{user:t,mode:n,domain:r}=Ae(),[s,o]=u.useState(null),[i,l]=u.useState(null),[c,d]=u.useState(null),[f,m]=u.useState("per-action"),[p,x]=u.useState(1800),[w,v]=u.useState(86400),[j,h]=u.useState(""),[g,y]=u.useState("hours"),[S,k]=u.useState(""),[I,R]=u.useState(!0),[_,C]=u.useState(!1),[z,D]=u.useState(""),[Y,K]=u.useState(null),[W,T]=u.useState([]),[q,ee]=u.useState(!1),[F,L]=u.useState([]),[H,A]=u.useState(0);u.useEffect(()=>{var ce;const P=sessionStorage.getItem("agentAuth"),b=sessionStorage.getItem("agentGate");if(!P||!b){e("/agent/new");return}const N=JSON.parse(P),E=JSON.parse(b),V={bounds:E.bounds??{},context:E.context??{},contextLabels:E.contextLabels??void 0,gateContent:E.gateContent};o(N),l(V),E.ttlConfig&&(x(E.ttlConfig.default??1800),v(E.ttlConfig.max??86400)),E.templateMode==="automatic"?m("immediate"):E.templateMode==="review"&&m("per-action");const ne=((ce=E.ttlConfig)==null?void 0:ce.max)??86400;if(typeof E.templateTtl=="number"&&E.templateTtl>0){const ie=Math.min(E.templateTtl,ne);x(ie),[3600,86400,604800,2592e3,31536e3].includes(ie)||(ie%86400===0?(h(String(ie/86400)),y("days")):(h(String(Math.max(1,Math.round(ie/3600)))),y("hours")))}$.getProfile(N.profileId).then(ie=>{var Ce;if(d(ie),!S){const Ze=ie.name??((Ce=N.profileId.split("/").pop())==null?void 0:Ce.replace(/@.*$/,""))??"",et=[];if(V.context&&ie.contextSchema)for(const it of ie.contextSchema.keyOrder){const ae=V.context[it];if(ae!==void 0&&ae!==""){const Bt=String(ae).split(",").map(On=>On.trim()).filter(Boolean);et.push(Bt.join(", "))}}const Sn=et.length>0?`${Ze}: ${et.join(" · ")}`:Ze;k(Sn)}}).catch(()=>{}),N.groupId?Promise.all([$.getTeamProfileConfig(N.groupId,N.profileId).catch(()=>null),$.getGroupById(N.groupId).catch(()=>null),$.listUsers().catch(()=>[])]).then(([ie,Ce,Ze])=>{if(K(ie),ie){const et=new Map;for(const ae of Ze){const Bt=ae.name&&ae.email?`${ae.name} (${ae.email})`:ae.name||ae.email||ae.id;et.set(ae.id,Bt)}const Sn=(Ce==null?void 0:Ce.members)??[];for(const ae of Sn){const Bt=ae.userId??ae.id;Bt&&(ae.name&&ae.email?et.set(Bt,`${ae.name} (${ae.email})`):ae.name&&et.set(Bt,ae.name))}const it=(ie.approvers??[]).map(ae=>et.get(ae)??ae);T(it)}}).finally(()=>{ee(!0)}):ee(!0)},[e]),u.useEffect(()=>{if(!(s!=null&&s.profileId))return;const P=s.profileId,b=sessionStorage.getItem("agentEditReplaces");$.getEnrichedAuthorizations().then(N=>{const E=N.filter(V=>V.profileId===P&&V.authorizationId!==b).map(V=>({authorizationId:V.authorizationId,bounds:V.bounds,context:V.context??{},intent:V.intent}));L(E)}).catch(()=>L([]))},[s==null?void 0:s.profileId]),u.useEffect(()=>{if(!i||!c||F.length===0){A(0);return}let P=!1;return(async()=>{const b=await Js(i.bounds,c),N=await Promise.all(F.map(E=>Js(E.bounds,c).catch(()=>null)));P||A(N.filter(E=>E===b).length)})().catch(()=>{P||A(0)}),()=>{P=!0}},[i,c,F]);const U=async()=>{if(!(!s||!i||!c||!t)){if(!s.groupId){D("No active group; cannot create authorization.");return}C(!0),D("");try{const P=r||s.domain||"owner",b=await Js(i.bounds,c),N=await Qf(i.context,c),[E,V]=await Promise.all([ka(i.gateContent.intent),ka(JSON.stringify({profile:s.profileId,domain:P,group:s.groupId}))]);let ne,ce,ie,Ce;if(s.isTeam){const it=await $.getApproversPubkeys(s.groupId,s.profileId);if(it.length>0){const ae=await $.encryptIntent(i.gateContent.intent,it);ne=ae.intentCiphertext,ce=ae.encryptedKeys,ie=ae.approversFrozen,Ce=ae.intentDisclosureHash}}const Ze=`authz_${crypto.randomUUID()}`,et=sessionStorage.getItem("agentEditReplaces")||void 0,Sn=await $.attest({authorization_id:Ze,replaces:et,profile_id:s.profileId,bounds:i.bounds,bounds_hash:b,context_hash:N,domain:P,did:t.did,gate_content_hashes:{intent:E},execution_context_hash:V,group_id:s.groupId,ttl:p,commitment_mode:f==="per-action"?"review":"automatic",title:S.trim(),intent_ciphertext:ne,encrypted_keys:ce,approvers_frozen:ie,intent_disclosure_hash:Ce,disclose_identity:I});try{await $.pushGateContent(Jf(Sn,{boundsHash:b,contextHash:N,context:i.context,contextLabels:i.contextLabels,gateContent:i.gateContent}))}catch(it){try{await $.revokeAttestation(Ze,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Authorization signed but gate content delivery failed. The attestation was revoked. Please try again. (${it instanceof Error?it.message:"Unknown error"})`)}if(et)try{await $.revokeAttestation(et,`Replaced by ${Ze} (edit)`),$.resyncGates().catch(()=>{})}catch{}sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),e(`/authorizations?highlight=${encodeURIComponent(Ze)}`)}catch(P){D(P instanceof Error?P.message:"Attestation failed")}finally{C(!1)}}};if(!s||!i)return a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const O=Object.entries(i.bounds).filter(([P])=>P!=="profile"&&P!=="path"),G=Object.entries(i.context),Z=((Y==null?void 0:Y.caps)!=null?Object.keys(Y.caps):[]).length!==0,de=W.length>0?W.join(", "):((Y==null?void 0:Y.approvers)??[]).join(", "),$e=Z?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${de}, regardless of your mode.`:"No caps set — they won't gate any action, but your intent is encrypted and shared with them as an accountability record.",Be=Z?`Over-cap actions will be reviewed by you and ${de}. Within-cap actions run per the mode you chose above.`:`Approvers ${de} can read your intent but won't gate any action — no caps configured on this profile.`,le=!!((Ke=Y==null?void 0:Y.approvers)!=null&&Ke.length),M=p>w,J={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"},te={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"},he=((se=c==null?void 0:c.contextSchema)==null?void 0:se.keyOrder)??[],pe=F.filter(P=>Iv(he,i.context,P.context)),Le=pe.length>0,ot=ze(s.profileId),De=P=>{const b=Object.values(P).map(N=>String(N).trim()).filter(Boolean);return b.length>0?b.join(", "):"all (unscoped)"},ht=pe.map(P=>De(P.context)).join("; "),Ie=`This grant's scope overlaps an existing grant on ${ot} (scoped to: ${ht}). 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(Kf,{currentStep:4,onStepClick:P=>{P<=3&&e(`/agent/gate?step=${P}`)}}),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."}),z&&a.jsx("div",{className:"error-message",children:z}),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. ${ze(s.profileId)}: daily operations`,value:S,onChange:P=>k(P.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:()=>m("per-action"),style:te,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:()=>m("immediate"),style:J,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(P=>P.seconds<=w).map(P=>a.jsx("button",{onClick:()=>{x(P.seconds),h("")},style:{padding:"0.5rem 0.85rem",border:p===P.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:p===P.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:P.label},P.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:P=>{h(P.target.value);const b=parseInt(P.target.value,10);if(b>0){const N=g==="days"?b*86400:b*3600;x(Math.min(N,w))}}}),a.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:g,onChange:P=>{y(P.target.value);const b=parseInt(j,10);if(b>0){const N=P.target.value==="days"?b*86400:b*3600;x(Math.min(N,w))}},children:[a.jsx("option",{value:"hours",children:"hours"}),a.jsx("option",{value:"days",children:"days"})]})]}),M&&a.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",w>=86400?`${Math.floor(w/86400)} days`:`${Math.floor(w/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:I,onChange:P=>R(P.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})]}),(!!O.length||!!G.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:[G.map(([P,b])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:P}),a.jsx("dd",{children:Xf(P,b,i.contextLabels)})]},P)),O.map(([P,b])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:P}),a.jsx("dd",{children:String(b)})]},P))]})]}),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:[ze(s.profileId),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:s.profileId})]}),s.groupName&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Team"}),a.jsx("dd",{children:s.groupName})]}),s.groupId&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Approvers"}),a.jsx("dd",{children:q?(((Ue=Y==null?void 0:Y.approvers)==null?void 0:Ue.length)??0)===0?a.jsxs(a.Fragment,{children:[a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"None — solo authorization"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:"No approvers configured for this profile in this team. Your intent stays on your gateway."})]}):a.jsxs(a.Fragment,{children:[de,a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:$e})]}):a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),H>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:[H===1?`An active grant on ${ot} already has exactly these limits.`:`${H} active grants on ${ot} 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,Le?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:Ie})]})]}):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:U,disabled:_||!S.trim(),children:_?"Signing...":f==="immediate"?"Authorize":"Authorize (Review Mode)"})]}),a.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:le?"block":"none"},children:Be})]})]})}const _v={card:"💳",mail:"✉️"};function Av(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 $v=[0,7,30,90,365,3650];function As(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 Lv({manifest:e,integration:t,state:n,onStatusChange:r,onSuccess:s}){var Ue;const[o,i]=u.useState({}),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[m,p]=u.useState({}),[x,w]=u.useState({}),[v,j]=u.useState(void 0),[h,g]=u.useState(!1),[y,S]=u.useState(null),[k,I]=u.useState(!1),[R,_]=u.useState(!1),[C,z]=u.useState(!1),[D,Y]=u.useState(!1),[K,W]=u.useState({}),[T,q]=u.useState(null),[ee,F]=u.useState(!1),[L,H]=u.useState(null),[A,U]=u.useState(!1);u.useEffect(()=>{let P=!1;return $.getCredential(e.id).then(b=>{var N;if(!(P||!b.configured)){if(c(!0),f(!0),b.fields){const E={};for(const V of e.credentials.fields)b.fields[V.key]!=null&&(E[V.key]=b.fields[V.key]);p(E)}if(w(b.secrets??{}),j(b.updatedAt),e.oauth){const E=((N=b.fieldNames)==null?void 0:N.includes(e.oauth.tokenStorage))??!1;g(E),E&&$.getOAuthHealth(e.id).then(V=>{P||S(V)})}}}).catch(()=>{}),()=>{P=!0}},[e.id,e.oauth]);const O=Av(e.toolGating),G=t?t.readAgeDays??null:void 0,X=ee&&T?T.value:G,Z=async P=>{q({value:P}),F(!0),H(null);try{await $.setReadPolicy(e.id,P),s(P===null?`${e.name} read window now follows your authorization`:`${e.name} read window set to ${As(P).toLowerCase()}`),r()}catch(b){H(b instanceof Error?b.message:"Could not save")}finally{F(!1),q(null)}},de=!!e.oauth||e.credentials.fields.some(P=>!P.optional),$e=e.oauth?h:l,Be=!de||$e,le=n==="starting"?"starting":Be?t!=null&&t.running?"running":!l&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&l&&!h?"needs-oauth":"unconfigured",M=async()=>{if(e.credentials.fields.some(b=>{var N;return(N=o[b.key])==null?void 0:N.trim()})){I(!0);try{await $.setCredential(e.id,o),c(!0),i({}),e.oauth?s(`${e.name} credentials saved!`):(s(`${e.name} credentials saved — starting integration...`),await Le())}catch{s(`Failed to save ${e.name} credentials`)}finally{I(!1)}}},J=()=>{const P={};for(const b of e.credentials.fields){const N=o[b.key];b.type==="password"?N!=null&&N.trim()&&(P[b.key]=N):N!=null&&N!==(m[b.key]??"")&&(P[b.key]=N)}return P},te=Object.keys(J()).length>0,he=async()=>{const P=J();if(Object.keys(P).length!==0){I(!0);try{await $.setCredential(e.id,P),i({}),c(!0),e.oauth?s(`${e.name} credentials saved — now click Connect.`):(Y(!1),s(`${e.name} credentials updated — restarting...`),await Le())}catch{s(`Failed to update ${e.name} credentials`)}finally{I(!1)}}},pe=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const P=setInterval(async()=>{var b;try{const N=await $.getCredential(e.id);N.configured&&e.oauth&&((b=N.fieldNames)!=null&&b.includes(e.oauth.tokenStorage))&&(g(!0),Y(!1),S(null),clearInterval(P),s(`${e.name} connected — starting integration...`),$.getOAuthHealth(e.id).then(S).catch(()=>{}),await Le())}catch{}},2e3);setTimeout(()=>clearInterval(P),12e4)},Le=async()=>{z(!0);try{const P=await $.activateIntegration(e.id);P.warning?s(P.warning):s(`${e.name} integration started with ${P.tools.length} tools`),r()}catch(P){s(`Failed to start ${e.name}: ${P instanceof Error?P.message:"Unknown error"}`)}finally{z(!1)}},ot=async()=>{try{await $.removeMcpIntegration(e.id),s(`${e.name} integration removed`),r()}catch{s(`Failed to remove ${e.name}`)}},De=_v[e.icon]??"🔧",ht=le==="running"?{c:"int-chip-ok",t:"Running"}:le==="starting"?{c:"int-chip-idle",t:"Starting"}:t&&!t.running&&t.error?{c:"int-chip-bad",t:"Crashed"}:{c:"int-chip-idle",t:"Stopped"},Ie=e.oauth&&h&&(y==null?void 0:y.status)==="failed",Ke=de?Ie?{c:"int-chip-bad",t:"Auth failed"}:$e?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},se=P=>P.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:De}),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:[le!=="unconfigured"&&le!=="needs-oauth"&&a.jsxs("span",{className:`int-chip ${ht.c}`,children:[a.jsx("span",{className:"int-dot"}),ht.t]}),a.jsxs("span",{className:`int-chip ${Ke.c}`,children:[a.jsx("span",{className:"int-dot"}),Ke.t]})]})]}),e.oauth&&h&&a.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:y!=null&&y.account?a.jsxs(a.Fragment,{children:["Connected as ",a.jsx("b",{children:y.account})]}):a.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),Ie&&!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:[(y==null?void 0:y.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."]}):y!=null&&y.error?a.jsxs(a.Fragment,{children:["The provider reported ",a.jsx("code",{children:y.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:pe,children:["Reconnect ",e.name]}),a.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{i({...m}),Y(!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:((Ue=e.oauth.scopes)==null?void 0:Ue.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&&(le!=="running"||Ie)&&a.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a.jsxs("button",{onClick:()=>_(!R),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:R?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),R&&a.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((P,b)=>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:b+1}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:P.title}),a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[se(P.description),P.link&&a.jsxs(a.Fragment,{children:[" ",a.jsxs("a",{href:P.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},b))})]}),le==="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(P=>{var b;return a.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[a.jsx("label",{className:"form-label",children:P.label}),P.type==="password"?a.jsxs("div",{className:"cred-field",children:[a.jsx("input",{className:"form-input",type:K[P.key]?"text":"password",name:`${e.id}-${P.key}-credential`,autoComplete:"new-password",placeholder:(b=x[P.key])!=null&&b.preview?`Unchanged — ends in ${x[P.key].preview}`:d?"Unchanged — paste a new value to replace":P.placeholder,value:o[P.key]||"",onChange:N=>i(E=>({...E,[P.key]:N.target.value}))}),a.jsx("button",{className:"cred-toggle",onClick:()=>W(N=>({...N,[P.key]:!N[P.key]})),children:K[P.key]?"hide":"show"})]}):a.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${P.key}-credential`,autoComplete:"off",placeholder:P.placeholder,value:o[P.key]||"",onChange:N=>i(E=>({...E,[P.key]:N.target.value}))})]},P.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:he,disabled:k||!te,children:k?"Saving…":"Save"}),!te&&!k&&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:pe,children:["Connect ",e.name]}),a.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{Y(!1),i({})},children:"Cancel"})]})]}),!D&&le==="running"&&t&&a.jsxs(a.Fragment,{children:[(Object.keys(m).length>0||Object.keys(x).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(P=>{const b=P.type==="password",N=x[P.key];return!b&&m[P.key]==null||b&&N==null?null:a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[a.jsx("span",{style:{color:"var(--text-muted)"},children:P.label}),a.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[b?N.preview??"set":m[P.key],b&&v&&a.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(v).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},P.key)})}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[a.jsx(Qe,{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({...m}),Y(!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:ot,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"})]}),O&&X!==void 0&&!A&&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:X===null?"window from your authorization":As(X).toLowerCase()}),ee&&a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),L&&a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:L})]}),a.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>U(!0),children:"Edit"})]})}),O&&X!==void 0&&A&&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:()=>U(!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:[$v.map(P=>{const b=X===P;return a.jsx("button",{className:`btn btn-sm ${b?"btn-primary":"btn-secondary"}`,"aria-pressed":b,disabled:ee,onClick:()=>Z(P),children:As(P)},P)}),a.jsx("button",{className:`btn btn-sm ${X===null?"btn-primary":"btn-ghost"}`,"aria-pressed":X===null,disabled:ee,onClick:()=>Z(null),title:"Clear the local setting and use the read window from your signed authorization instead.",children:As(null)})]}),a.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:L?a.jsx("span",{style:{color:"var(--danger)"},children:L}):ee?a.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):X===null?a.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your authorization. If none is set there, reads are blocked."}):X===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 ",X," days is blocked, whoever it is from."]})})]}),a.jsx("div",{style:{display:"none"},children:a.jsx(Qe,{to:"/agent/new",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Authorize your agent"})})]}),le==="unconfigured"&&(()=>{const P=e.credentials.fields.every(E=>E.optional),b=e.credentials.fields.some(E=>!E.optional),N=e.credentials.fields.some(E=>{var V;return(V=o[E.key])==null?void 0:V.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&&g(!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(E=>a.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[a.jsx("label",{className:"form-label",children:E.label}),E.type==="password"?a.jsxs("div",{className:"cred-field",children:[a.jsx("input",{className:"form-input",type:K[E.key]?"text":"password",name:`${e.id}-${E.key}-credential`,autoComplete:"new-password",placeholder:E.placeholder,value:o[E.key]||"",onChange:V=>i(ne=>({...ne,[E.key]:V.target.value}))}),a.jsx("button",{className:"cred-toggle",onClick:()=>W(V=>({...V,[E.key]:!V[E.key]})),children:K[E.key]?"hide":"show"})]}):a.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${E.key}-credential`,autoComplete:"off",placeholder:E.placeholder,value:o[E.key]||"",onChange:V=>i(ne=>({...ne,[E.key]:V.target.value}))})]},E.key)),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[N&&a.jsx("button",{className:"btn btn-primary",onClick:M,disabled:k||b&&!e.credentials.fields.filter(E=>!E.optional).every(E=>{var V;return(V=o[E.key])==null?void 0:V.trim()}),children:k?"Saving...":"Save & Encrypt"}),P&&!N&&a.jsx("button",{className:"btn btn-primary",onClick:Le,disabled:C,children:C?"Starting...":`Activate ${e.name}`})]})]})})(),le==="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:pe,children:["Connect ",e.name," Account"]}),a.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Change Credentials"})]})]}),le==="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:Le,disabled:C,children:C?"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),g(!1)},children:"Change Credentials"})]})]}),le==="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:Le,disabled:C,children:C?"Starting...":"Start"}),a.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:ot,children:"Disable"})]})]})]})}function Mv(){const{loading:e,mcpServerUp:t,manifestsError:n,entries:r,refresh:s}=Tl(),[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(Lv,{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 Fv(){var D,Y,K;const{activeTeam:e,activeMembership:t,refreshGroups:n,user:r}=Ae(),[s,o]=u.useState(null),[i,l]=u.useState(!1),[c,d]=u.useState(""),[f,m]=u.useState(""),[p,x]=u.useState(!1),[w,v]=u.useState(""),[j,h]=u.useState("");u.useEffect(()=>{fetch("/health").then(W=>W.json()).then(W=>{typeof W.spUrl=="string"&&h(W.spUrl)}).catch(()=>{})},[]),u.useEffect(()=>{if(!e){o(null);return}$.getGroupById(e.id).then(W=>{const T=W.group??W,q=W.members??[],ee=W.isAdmin??!1,F=q.map(L=>{const H=L.userId||L.id||"",A=L.role||(ee&&H===T.createdBy?"admin":"member");return{id:H,name:L.name||H.slice(0,8)||"Member",email:L.email||"",domains:L.domains||[],role:A,isAdmin:A==="admin"||ee&&H===T.createdBy}});o({id:T.id,name:T.name,members:F})}).catch(()=>o(null))},[e==null?void 0:e.id]);const g=(s==null?void 0:s.members.filter(W=>W.isAdmin))??[],y=(e==null?void 0:e.isAdmin)===!0&&g.length<=1&&g.some(W=>W.id===(r==null?void 0:r.id)),S=(e==null?void 0:e.name)??"",k=w.trim()===S&&!i,I=()=>{v(""),x(!0)},R=()=>{x(!1),v("")},_=async()=>{if(!(!e||!k)){l(!0),d("");try{await $.leaveTeam(e.id),await n(),m("You have left the team."),o(null),R()}catch(W){d(W instanceof Error?W.message:"Failed to leave team")}finally{l(!1)}}},C=e&&j?`${j}/dashboard/groups/${e.id}`:void 0,z=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," ",(((Y=s==null?void 0:s.members)==null?void 0:Y.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),a.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(K=s==null?void 0:s.members)==null?void 0:K.map(W=>a.jsxs("div",{className:"member-row",children:[a.jsx("div",{className:"member-avatar",children:W.name.split(" ").map(T=>T[0]).join("").slice(0,2).toUpperCase()}),a.jsxs("div",{className:"member-info",children:[a.jsx("div",{className:"member-name",children:W.name}),a.jsx("div",{className:"member-email",children:W.email})]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:W.role})]},W.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:[C&&a.jsx("a",{className:"btn btn-secondary btn-sm",href:C,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Service Provider →"}),a.jsx("span",{title:y?"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:I,disabled:i||y,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."}),z&&a.jsx("a",{className:"btn btn-primary btn-sm",href:z,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:R,children:a.jsxs("div",{className:"card",onClick:W=>W.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:w,onChange:W=>v(W.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:R,disabled:i,children:"Cancel"}),a.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:_,disabled:!k,children:i?"Leaving...":"Leave team"})]})]})})]})}function Ov({onDismiss:e}){const t=qt(),{group:n,groupId:r,domain:s}=Ae(),[o,i]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState([]),[m,p]=u.useState(!0),[x,w]=u.useState({}),[v,j]=u.useState(null);u.useEffect(()=>{Promise.all([$.listProfiles().catch(()=>[]),$.getIntegrationManifests().then(C=>C.manifests??[]).catch(()=>[]),$.getMcpHealth().then(C=>C.integrations??[]).catch(()=>[])]).then(async([C,z,D])=>{if(i(C),c(z),f(D),r){const Y=await Promise.all(C.map(W=>$.getTeamProfileConfig(r,W.id).catch(()=>null))),K={};C.forEach((W,T)=>{const q=Y[T];q&&(K[W.id]=q)}),w(K)}}).finally(()=>p(!1))},[r]);const h=new Map;for(const C of l)C.profile&&h.set(C.profile,C);const g=C=>C.replace(/@.*$/,"").split("/").pop()??C,y=C=>C.split("@")[1]??"",S=new Map;for(const C of o){const z=g(C.id);if(!h.has(z))continue;const D=S.get(z);(!D||y(C.id).localeCompare(y(D.id),void 0,{numeric:!0})>0)&&S.set(z,C)}const k=l.map(C=>{const z=C.profile?S.get(C.profile):void 0;return z?{manifest:C,profile:z,integration:d.find(D=>D.id===C.id)}:null}).filter(C=>C!==null),I=C=>C in x,R=(C,z)=>{if(!r){console.error("No active group when creating authorization");return}const D=I(C);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:C,groupId:r,groupName:(n==null?void 0:n.name)??null,domain:s,isTeam:D})),z?sessionStorage.setItem("agentGate",JSON.stringify({bounds:z.bounds,context:z.context,gateContent:{intent:z.intent},ttlConfig:{max:z.ttl},templateMode:z.mode,templateTtl:z.ttl})):sessionStorage.removeItem("agentGate"),j(null),e==null||e(),t("/agent/gate")},_=(C,z)=>{r&&(z!=null&&z.templates&&z.templates.length>0?j({profileId:C,manifest:z}):R(C))};if(v){const C=v.manifest.templates??[];return a.jsxs(a.Fragment,{children:[a.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginBottom:"1rem"},onClick:()=>j(null),children:"← Back to profiles"}),a.jsxs("h3",{style:{margin:"0 0 0.25rem 0",fontSize:"1rem"},children:["Set up ",v.manifest.name," authorization"]}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.5rem",marginBottom:"0.75rem",fontWeight:600},children:"Quick start"}),a.jsx("div",{style:{display:"grid",gap:"0.75rem",gridTemplateColumns:`repeat(${Math.min(C.length,3)}, 1fr)`},children:C.map(z=>a.jsxs("button",{className:"template-card",onClick:()=>R(v.profileId,z),children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.375rem"},children:[a.jsx("span",{className:`template-mode template-mode-${z.mode==="automatic"?"auto":"review"}`,children:z.mode==="automatic"?"Auto":"Review"}),a.jsx("span",{className:"template-risk","data-risk":z.risk,children:z.risk})]}),a.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.25rem"},children:z.name}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",lineHeight:1.45,marginBottom:"0.5rem"},children:z.description}),a.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.3rem"},children:z.tags.map(D=>a.jsx("span",{className:"template-tag",children:D},D))})]},z.name))}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",margin:"1.5rem 0"},children:[a.jsx("div",{style:{flex:1,height:"1px",background:"var(--border)"}}),a.jsx("span",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"or"}),a.jsx("div",{style:{flex:1,height:"1px",background:"var(--border)"}})]}),a.jsx("button",{className:"btn btn-primary",style:{width:"100%",textAlign:"center",padding:"0.75rem"},onClick:()=>R(v.profileId),children:"Custom — define your own limits and scope"})]})}return a.jsxs(a.Fragment,{children:[a.jsx("style",{children:`
67
+ `).replace(/\n+$/,"")}async function Yf(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 Iv extends Error{constructor(n,r,s){super(s);vr(this,"code");vr(this,"field");this.name="CanonicalValueError",this.code=n,this.field=r}}function Rv(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 Qf(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 Iv(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}=${Rv(i)}`)}return r.join(`
69
+ `)}async function Xs(e,t){const n=t.boundsSchema??t.frameSchema;if(!n)throw new Error("Profile has no boundsSchema or frameSchema");const r=Qf(e,n.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await Yf(r)}`}async function Jf(e,t){const n=t.contextSchema?Qf(e,t.contextSchema.keyOrder,"CONTEXT_INVALID_VALUE"):"";return`sha256:${await Yf(n)}`}async function ba(e){const t=new TextEncoder().encode(zv(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 Xf(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 Xc(e){return e==null?new Set:new Set(String(e).split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}function Pv(e,t){for(const n of e)if(t.has(n))return!0;return!1}function _v(e,t,n){for(const r of e){const s=Xc(t[r]),o=Xc(n[r]);if(!(s.size===0||o.size===0)&&!Pv(s,o))return!1}return!0}function Av(e){return e.length>24?`${e.slice(0,10)}…`:e}function qf(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} (${Av(o)})`:o}).join(", ")}function $v(){var Ke,se,Ue;const e=qt(),{user:t,mode:n,domain:r}=Ae(),[s,o]=u.useState(null),[i,l]=u.useState(null),[c,d]=u.useState(null),[f,m]=u.useState("per-action"),[p,x]=u.useState(1800),[w,v]=u.useState(86400),[j,h]=u.useState(""),[g,y]=u.useState("hours"),[S,k]=u.useState(""),[I,R]=u.useState(!0),[_,C]=u.useState(!1),[z,D]=u.useState(""),[Y,K]=u.useState(null),[W,T]=u.useState([]),[q,ee]=u.useState(!1),[F,L]=u.useState([]),[H,A]=u.useState(0);u.useEffect(()=>{var ce;const P=sessionStorage.getItem("agentAuth"),b=sessionStorage.getItem("agentGate");if(!P||!b){e("/agent/new");return}const N=JSON.parse(P),E=JSON.parse(b),V={bounds:E.bounds??{},context:E.context??{},contextLabels:E.contextLabels??void 0,gateContent:E.gateContent};o(N),l(V),E.ttlConfig&&(x(E.ttlConfig.default??1800),v(E.ttlConfig.max??86400)),E.templateMode==="automatic"?m("immediate"):E.templateMode==="review"&&m("per-action");const ne=((ce=E.ttlConfig)==null?void 0:ce.max)??86400;if(typeof E.templateTtl=="number"&&E.templateTtl>0){const ie=Math.min(E.templateTtl,ne);x(ie),[3600,86400,604800,2592e3,31536e3].includes(ie)||(ie%86400===0?(h(String(ie/86400)),y("days")):(h(String(Math.max(1,Math.round(ie/3600)))),y("hours")))}$.getProfile(N.profileId).then(ie=>{var Ce;if(d(ie),!S){const Ze=ie.name??((Ce=N.profileId.split("/").pop())==null?void 0:Ce.replace(/@.*$/,""))??"",et=[];if(V.context&&ie.contextSchema)for(const it of ie.contextSchema.keyOrder){const ae=V.context[it];if(ae!==void 0&&ae!==""){const Bt=String(ae).split(",").map(On=>On.trim()).filter(Boolean);et.push(Bt.join(", "))}}const Sn=et.length>0?`${Ze}: ${et.join(" · ")}`:Ze;k(Sn)}}).catch(()=>{}),N.groupId?Promise.all([$.getTeamProfileConfig(N.groupId,N.profileId).catch(()=>null),$.getGroupById(N.groupId).catch(()=>null),$.listUsers().catch(()=>[])]).then(([ie,Ce,Ze])=>{if(K(ie),ie){const et=new Map;for(const ae of Ze){const Bt=ae.name&&ae.email?`${ae.name} (${ae.email})`:ae.name||ae.email||ae.id;et.set(ae.id,Bt)}const Sn=(Ce==null?void 0:Ce.members)??[];for(const ae of Sn){const Bt=ae.userId??ae.id;Bt&&(ae.name&&ae.email?et.set(Bt,`${ae.name} (${ae.email})`):ae.name&&et.set(Bt,ae.name))}const it=(ie.approvers??[]).map(ae=>et.get(ae)??ae);T(it)}}).finally(()=>{ee(!0)}):ee(!0)},[e]),u.useEffect(()=>{if(!(s!=null&&s.profileId))return;const P=s.profileId,b=sessionStorage.getItem("agentEditReplaces");$.getEnrichedAuthorizations().then(N=>{const E=N.filter(V=>V.profileId===P&&V.authorizationId!==b).map(V=>({authorizationId:V.authorizationId,bounds:V.bounds,context:V.context??{},intent:V.intent}));L(E)}).catch(()=>L([]))},[s==null?void 0:s.profileId]),u.useEffect(()=>{if(!i||!c||F.length===0){A(0);return}let P=!1;return(async()=>{const b=await Xs(i.bounds,c),N=await Promise.all(F.map(E=>Xs(E.bounds,c).catch(()=>null)));P||A(N.filter(E=>E===b).length)})().catch(()=>{P||A(0)}),()=>{P=!0}},[i,c,F]);const U=async()=>{if(!(!s||!i||!c||!t)){if(!s.groupId){D("No active group; cannot create authorization.");return}C(!0),D("");try{const P=r||s.domain||"owner",b=await Xs(i.bounds,c),N=await Jf(i.context,c),[E,V]=await Promise.all([ba(i.gateContent.intent),ba(JSON.stringify({profile:s.profileId,domain:P,group:s.groupId}))]);let ne,ce,ie,Ce;if(s.isTeam){const it=await $.getApproversPubkeys(s.groupId,s.profileId);if(it.length>0){const ae=await $.encryptIntent(i.gateContent.intent,it);ne=ae.intentCiphertext,ce=ae.encryptedKeys,ie=ae.approversFrozen,Ce=ae.intentDisclosureHash}}const Ze=`authz_${crypto.randomUUID()}`,et=sessionStorage.getItem("agentEditReplaces")||void 0,Sn=await $.attest({authorization_id:Ze,replaces:et,profile_id:s.profileId,bounds:i.bounds,bounds_hash:b,context_hash:N,domain:P,did:t.did,gate_content_hashes:{intent:E},execution_context_hash:V,group_id:s.groupId,ttl:p,commitment_mode:f==="per-action"?"review":"automatic",title:S.trim(),intent_ciphertext:ne,encrypted_keys:ce,approvers_frozen:ie,intent_disclosure_hash:Ce,disclose_identity:I});try{await $.pushGateContent(Xf(Sn,{boundsHash:b,contextHash:N,context:i.context,contextLabels:i.contextLabels,gateContent:i.gateContent}))}catch(it){try{await $.revokeAttestation(Ze,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Authorization signed but gate content delivery failed. The attestation was revoked. Please try again. (${it instanceof Error?it.message:"Unknown error"})`)}if(et)try{await $.revokeAttestation(et,`Replaced by ${Ze} (edit)`),$.resyncGates().catch(()=>{})}catch{}sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),e(`/authorizations?highlight=${encodeURIComponent(Ze)}`)}catch(P){D(P instanceof Error?P.message:"Attestation failed")}finally{C(!1)}}};if(!s||!i)return a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const O=Object.entries(i.bounds).filter(([P])=>P!=="profile"&&P!=="path"),G=Object.entries(i.context),Z=((Y==null?void 0:Y.caps)!=null?Object.keys(Y.caps):[]).length!==0,de=W.length>0?W.join(", "):((Y==null?void 0:Y.approvers)??[]).join(", "),$e=Z?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${de}, regardless of your mode.`:"No caps set — they won't gate any action, but your intent is encrypted and shared with them as an accountability record.",Be=Z?`Over-cap actions will be reviewed by you and ${de}. Within-cap actions run per the mode you chose above.`:`Approvers ${de} can read your intent but won't gate any action — no caps configured on this profile.`,le=!!((Ke=Y==null?void 0:Y.approvers)!=null&&Ke.length),M=p>w,J={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"},te={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"},he=((se=c==null?void 0:c.contextSchema)==null?void 0:se.keyOrder)??[],pe=F.filter(P=>_v(he,i.context,P.context)),Le=pe.length>0,ot=ze(s.profileId),De=P=>{const b=Object.values(P).map(N=>String(N).trim()).filter(Boolean);return b.length>0?b.join(", "):"all (unscoped)"},ht=pe.map(P=>De(P.context)).join("; "),Ie=`This grant's scope overlaps an existing grant on ${ot} (scoped to: ${ht}). 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(Gf,{currentStep:4,onStepClick:P=>{P<=3&&e(`/agent/gate?step=${P}`)}}),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."}),z&&a.jsx("div",{className:"error-message",children:z}),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. ${ze(s.profileId)}: daily operations`,value:S,onChange:P=>k(P.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:()=>m("per-action"),style:te,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:()=>m("immediate"),style:J,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(P=>P.seconds<=w).map(P=>a.jsx("button",{onClick:()=>{x(P.seconds),h("")},style:{padding:"0.5rem 0.85rem",border:p===P.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:p===P.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:P.label},P.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:P=>{h(P.target.value);const b=parseInt(P.target.value,10);if(b>0){const N=g==="days"?b*86400:b*3600;x(Math.min(N,w))}}}),a.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:g,onChange:P=>{y(P.target.value);const b=parseInt(j,10);if(b>0){const N=P.target.value==="days"?b*86400:b*3600;x(Math.min(N,w))}},children:[a.jsx("option",{value:"hours",children:"hours"}),a.jsx("option",{value:"days",children:"days"})]})]}),M&&a.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",w>=86400?`${Math.floor(w/86400)} days`:`${Math.floor(w/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:I,onChange:P=>R(P.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})]}),(!!O.length||!!G.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:[G.map(([P,b])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:P}),a.jsx("dd",{children:qf(P,b,i.contextLabels)})]},P)),O.map(([P,b])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:P}),a.jsx("dd",{children:String(b)})]},P))]})]}),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:[ze(s.profileId),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:s.profileId})]}),s.groupName&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Team"}),a.jsx("dd",{children:s.groupName})]}),s.groupId&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Approvers"}),a.jsx("dd",{children:q?(((Ue=Y==null?void 0:Y.approvers)==null?void 0:Ue.length)??0)===0?a.jsxs(a.Fragment,{children:[a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"None — solo authorization"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:"No approvers configured for this profile in this team. Your intent stays on your gateway."})]}):a.jsxs(a.Fragment,{children:[de,a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:$e})]}):a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),H>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:[H===1?`An active grant on ${ot} already has exactly these limits.`:`${H} active grants on ${ot} 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,Le?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:Ie})]})]}):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:U,disabled:_||!S.trim(),children:_?"Signing...":f==="immediate"?"Authorize":"Authorize (Review Mode)"})]}),a.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:le?"block":"none"},children:Be})]})]})}const Lv={card:"💳",mail:"✉️"};function Mv(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 Fv=[0,7,30,90,365,3650];function $s(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 Ov({manifest:e,integration:t,state:n,onStatusChange:r,onSuccess:s}){var Ue;const[o,i]=u.useState({}),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[m,p]=u.useState({}),[x,w]=u.useState({}),[v,j]=u.useState(void 0),[h,g]=u.useState(!1),[y,S]=u.useState(null),[k,I]=u.useState(!1),[R,_]=u.useState(!1),[C,z]=u.useState(!1),[D,Y]=u.useState(!1),[K,W]=u.useState({}),[T,q]=u.useState(null),[ee,F]=u.useState(!1),[L,H]=u.useState(null),[A,U]=u.useState(!1);u.useEffect(()=>{let P=!1;return $.getCredential(e.id).then(b=>{var N;if(!(P||!b.configured)){if(c(!0),f(!0),b.fields){const E={};for(const V of e.credentials.fields)b.fields[V.key]!=null&&(E[V.key]=b.fields[V.key]);p(E)}if(w(b.secrets??{}),j(b.updatedAt),e.oauth){const E=((N=b.fieldNames)==null?void 0:N.includes(e.oauth.tokenStorage))??!1;g(E),E&&$.getOAuthHealth(e.id).then(V=>{P||S(V)})}}}).catch(()=>{}),()=>{P=!0}},[e.id,e.oauth]);const O=Mv(e.toolGating),G=t?t.readAgeDays??null:void 0,X=ee&&T?T.value:G,Z=async P=>{q({value:P}),F(!0),H(null);try{await $.setReadPolicy(e.id,P),s(P===null?`${e.name} read window now follows your authorization`:`${e.name} read window set to ${$s(P).toLowerCase()}`),r()}catch(b){H(b instanceof Error?b.message:"Could not save")}finally{F(!1),q(null)}},de=!!e.oauth||e.credentials.fields.some(P=>!P.optional),$e=e.oauth?h:l,Be=!de||$e,le=n==="starting"?"starting":Be?t!=null&&t.running?"running":!l&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&l&&!h?"needs-oauth":"unconfigured",M=async()=>{if(e.credentials.fields.some(b=>{var N;return(N=o[b.key])==null?void 0:N.trim()})){I(!0);try{await $.setCredential(e.id,o),c(!0),i({}),e.oauth?s(`${e.name} credentials saved!`):(s(`${e.name} credentials saved — starting integration...`),await Le())}catch{s(`Failed to save ${e.name} credentials`)}finally{I(!1)}}},J=()=>{const P={};for(const b of e.credentials.fields){const N=o[b.key];b.type==="password"?N!=null&&N.trim()&&(P[b.key]=N):N!=null&&N!==(m[b.key]??"")&&(P[b.key]=N)}return P},te=Object.keys(J()).length>0,he=async()=>{const P=J();if(Object.keys(P).length!==0){I(!0);try{await $.setCredential(e.id,P),i({}),c(!0),e.oauth?s(`${e.name} credentials saved — now click Connect.`):(Y(!1),s(`${e.name} credentials updated — restarting...`),await Le())}catch{s(`Failed to update ${e.name} credentials`)}finally{I(!1)}}},pe=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const P=setInterval(async()=>{var b;try{const N=await $.getCredential(e.id);N.configured&&e.oauth&&((b=N.fieldNames)!=null&&b.includes(e.oauth.tokenStorage))&&(g(!0),Y(!1),S(null),clearInterval(P),s(`${e.name} connected — starting integration...`),$.getOAuthHealth(e.id).then(S).catch(()=>{}),await Le())}catch{}},2e3);setTimeout(()=>clearInterval(P),12e4)},Le=async()=>{z(!0);try{const P=await $.activateIntegration(e.id);P.warning?s(P.warning):s(`${e.name} integration started with ${P.tools.length} tools`),r()}catch(P){s(`Failed to start ${e.name}: ${P instanceof Error?P.message:"Unknown error"}`)}finally{z(!1)}},ot=async()=>{try{await $.removeMcpIntegration(e.id),s(`${e.name} integration removed`),r()}catch{s(`Failed to remove ${e.name}`)}},De=Lv[e.icon]??"🔧",ht=le==="running"?{c:"int-chip-ok",t:"Running"}:le==="starting"?{c:"int-chip-idle",t:"Starting"}:t&&!t.running&&t.error?{c:"int-chip-bad",t:"Crashed"}:{c:"int-chip-idle",t:"Stopped"},Ie=e.oauth&&h&&(y==null?void 0:y.status)==="failed",Ke=de?Ie?{c:"int-chip-bad",t:"Auth failed"}:$e?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},se=P=>P.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:De}),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:[le!=="unconfigured"&&le!=="needs-oauth"&&a.jsxs("span",{className:`int-chip ${ht.c}`,children:[a.jsx("span",{className:"int-dot"}),ht.t]}),a.jsxs("span",{className:`int-chip ${Ke.c}`,children:[a.jsx("span",{className:"int-dot"}),Ke.t]})]})]}),e.oauth&&h&&a.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:y!=null&&y.account?a.jsxs(a.Fragment,{children:["Connected as ",a.jsx("b",{children:y.account})]}):a.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),Ie&&!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:[(y==null?void 0:y.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."]}):y!=null&&y.error?a.jsxs(a.Fragment,{children:["The provider reported ",a.jsx("code",{children:y.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:pe,children:["Reconnect ",e.name]}),a.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{i({...m}),Y(!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:((Ue=e.oauth.scopes)==null?void 0:Ue.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&&(le!=="running"||Ie)&&a.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a.jsxs("button",{onClick:()=>_(!R),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:R?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),R&&a.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((P,b)=>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:b+1}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:P.title}),a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[se(P.description),P.link&&a.jsxs(a.Fragment,{children:[" ",a.jsxs("a",{href:P.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},b))})]}),le==="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(P=>{var b;return a.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[a.jsx("label",{className:"form-label",children:P.label}),P.type==="password"?a.jsxs("div",{className:"cred-field",children:[a.jsx("input",{className:"form-input",type:K[P.key]?"text":"password",name:`${e.id}-${P.key}-credential`,autoComplete:"new-password",placeholder:(b=x[P.key])!=null&&b.preview?`Unchanged — ends in ${x[P.key].preview}`:d?"Unchanged — paste a new value to replace":P.placeholder,value:o[P.key]||"",onChange:N=>i(E=>({...E,[P.key]:N.target.value}))}),a.jsx("button",{className:"cred-toggle",onClick:()=>W(N=>({...N,[P.key]:!N[P.key]})),children:K[P.key]?"hide":"show"})]}):a.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${P.key}-credential`,autoComplete:"off",placeholder:P.placeholder,value:o[P.key]||"",onChange:N=>i(E=>({...E,[P.key]:N.target.value}))})]},P.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:he,disabled:k||!te,children:k?"Saving…":"Save"}),!te&&!k&&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:pe,children:["Connect ",e.name]}),a.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{Y(!1),i({})},children:"Cancel"})]})]}),!D&&le==="running"&&t&&a.jsxs(a.Fragment,{children:[(Object.keys(m).length>0||Object.keys(x).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(P=>{const b=P.type==="password",N=x[P.key];return!b&&m[P.key]==null||b&&N==null?null:a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[a.jsx("span",{style:{color:"var(--text-muted)"},children:P.label}),a.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[b?N.preview??"set":m[P.key],b&&v&&a.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(v).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},P.key)})}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[a.jsx(Qe,{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({...m}),Y(!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:ot,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"})]}),O&&X!==void 0&&!A&&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:X===null?"window from your authorization":$s(X).toLowerCase()}),ee&&a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),L&&a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:L})]}),a.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>U(!0),children:"Edit"})]})}),O&&X!==void 0&&A&&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:()=>U(!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:[Fv.map(P=>{const b=X===P;return a.jsx("button",{className:`btn btn-sm ${b?"btn-primary":"btn-secondary"}`,"aria-pressed":b,disabled:ee,onClick:()=>Z(P),children:$s(P)},P)}),a.jsx("button",{className:`btn btn-sm ${X===null?"btn-primary":"btn-ghost"}`,"aria-pressed":X===null,disabled:ee,onClick:()=>Z(null),title:"Clear the local setting and use the read window from your signed authorization instead.",children:$s(null)})]}),a.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:L?a.jsx("span",{style:{color:"var(--danger)"},children:L}):ee?a.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):X===null?a.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your authorization. If none is set there, reads are blocked."}):X===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 ",X," days is blocked, whoever it is from."]})})]}),a.jsx("div",{style:{display:"none"},children:a.jsx(Qe,{to:"/agent/new",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Authorize your agent"})})]}),le==="unconfigured"&&(()=>{const P=e.credentials.fields.every(E=>E.optional),b=e.credentials.fields.some(E=>!E.optional),N=e.credentials.fields.some(E=>{var V;return(V=o[E.key])==null?void 0:V.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&&g(!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(E=>a.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[a.jsx("label",{className:"form-label",children:E.label}),E.type==="password"?a.jsxs("div",{className:"cred-field",children:[a.jsx("input",{className:"form-input",type:K[E.key]?"text":"password",name:`${e.id}-${E.key}-credential`,autoComplete:"new-password",placeholder:E.placeholder,value:o[E.key]||"",onChange:V=>i(ne=>({...ne,[E.key]:V.target.value}))}),a.jsx("button",{className:"cred-toggle",onClick:()=>W(V=>({...V,[E.key]:!V[E.key]})),children:K[E.key]?"hide":"show"})]}):a.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${E.key}-credential`,autoComplete:"off",placeholder:E.placeholder,value:o[E.key]||"",onChange:V=>i(ne=>({...ne,[E.key]:V.target.value}))})]},E.key)),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[N&&a.jsx("button",{className:"btn btn-primary",onClick:M,disabled:k||b&&!e.credentials.fields.filter(E=>!E.optional).every(E=>{var V;return(V=o[E.key])==null?void 0:V.trim()}),children:k?"Saving...":"Save & Encrypt"}),P&&!N&&a.jsx("button",{className:"btn btn-primary",onClick:Le,disabled:C,children:C?"Starting...":`Activate ${e.name}`})]})]})})(),le==="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:pe,children:["Connect ",e.name," Account"]}),a.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Change Credentials"})]})]}),le==="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:Le,disabled:C,children:C?"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),g(!1)},children:"Change Credentials"})]})]}),le==="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:Le,disabled:C,children:C?"Starting...":"Start"}),a.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:ot,children:"Disable"})]})]})]})}function Bv(){const{loading:e,mcpServerUp:t,manifestsError:n,entries:r,refresh:s}=El(),[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(Ov,{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 Dv(){var D,Y,K;const{activeTeam:e,activeMembership:t,refreshGroups:n,user:r}=Ae(),[s,o]=u.useState(null),[i,l]=u.useState(!1),[c,d]=u.useState(""),[f,m]=u.useState(""),[p,x]=u.useState(!1),[w,v]=u.useState(""),[j,h]=u.useState("");u.useEffect(()=>{fetch("/health").then(W=>W.json()).then(W=>{typeof W.spUrl=="string"&&h(W.spUrl)}).catch(()=>{})},[]),u.useEffect(()=>{if(!e){o(null);return}$.getGroupById(e.id).then(W=>{const T=W.group??W,q=W.members??[],ee=W.isAdmin??!1,F=q.map(L=>{const H=L.userId||L.id||"",A=L.role||(ee&&H===T.createdBy?"admin":"member");return{id:H,name:L.name||H.slice(0,8)||"Member",email:L.email||"",domains:L.domains||[],role:A,isAdmin:A==="admin"||ee&&H===T.createdBy}});o({id:T.id,name:T.name,members:F})}).catch(()=>o(null))},[e==null?void 0:e.id]);const g=(s==null?void 0:s.members.filter(W=>W.isAdmin))??[],y=(e==null?void 0:e.isAdmin)===!0&&g.length<=1&&g.some(W=>W.id===(r==null?void 0:r.id)),S=(e==null?void 0:e.name)??"",k=w.trim()===S&&!i,I=()=>{v(""),x(!0)},R=()=>{x(!1),v("")},_=async()=>{if(!(!e||!k)){l(!0),d("");try{await $.leaveTeam(e.id),await n(),m("You have left the team."),o(null),R()}catch(W){d(W instanceof Error?W.message:"Failed to leave team")}finally{l(!1)}}},C=e&&j?`${j}/dashboard/groups/${e.id}`:void 0,z=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," ",(((Y=s==null?void 0:s.members)==null?void 0:Y.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),a.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(K=s==null?void 0:s.members)==null?void 0:K.map(W=>a.jsxs("div",{className:"member-row",children:[a.jsx("div",{className:"member-avatar",children:W.name.split(" ").map(T=>T[0]).join("").slice(0,2).toUpperCase()}),a.jsxs("div",{className:"member-info",children:[a.jsx("div",{className:"member-name",children:W.name}),a.jsx("div",{className:"member-email",children:W.email})]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:W.role})]},W.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:[C&&a.jsx("a",{className:"btn btn-secondary btn-sm",href:C,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Service Provider →"}),a.jsx("span",{title:y?"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:I,disabled:i||y,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."}),z&&a.jsx("a",{className:"btn btn-primary btn-sm",href:z,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:R,children:a.jsxs("div",{className:"card",onClick:W=>W.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:w,onChange:W=>v(W.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:R,disabled:i,children:"Cancel"}),a.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:_,disabled:!k,children:i?"Leaving...":"Leave team"})]})]})})]})}function Uv({onDismiss:e}){const t=qt(),{group:n,groupId:r,domain:s}=Ae(),[o,i]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState([]),[m,p]=u.useState(!0),[x,w]=u.useState({}),[v,j]=u.useState(null);u.useEffect(()=>{Promise.all([$.listProfiles().catch(()=>[]),$.getIntegrationManifests().then(C=>C.manifests??[]).catch(()=>[]),$.getMcpHealth().then(C=>C.integrations??[]).catch(()=>[])]).then(async([C,z,D])=>{if(i(C),c(z),f(D),r){const Y=await Promise.all(C.map(W=>$.getTeamProfileConfig(r,W.id).catch(()=>null))),K={};C.forEach((W,T)=>{const q=Y[T];q&&(K[W.id]=q)}),w(K)}}).finally(()=>p(!1))},[r]);const h=new Map;for(const C of l)C.profile&&h.set(C.profile,C);const g=C=>C.replace(/@.*$/,"").split("/").pop()??C,y=C=>C.split("@")[1]??"",S=new Map;for(const C of o){const z=g(C.id);if(!h.has(z))continue;const D=S.get(z);(!D||y(C.id).localeCompare(y(D.id),void 0,{numeric:!0})>0)&&S.set(z,C)}const k=l.map(C=>{const z=C.profile?S.get(C.profile):void 0;return z?{manifest:C,profile:z,integration:d.find(D=>D.id===C.id)}:null}).filter(C=>C!==null),I=C=>C in x,R=(C,z)=>{if(!r){console.error("No active group when creating authorization");return}const D=I(C);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:C,groupId:r,groupName:(n==null?void 0:n.name)??null,domain:s,isTeam:D})),z?sessionStorage.setItem("agentGate",JSON.stringify({bounds:z.bounds,context:z.context,gateContent:{intent:z.intent},ttlConfig:{max:z.ttl},templateMode:z.mode,templateTtl:z.ttl})):sessionStorage.removeItem("agentGate"),j(null),e==null||e(),t("/agent/gate")},_=(C,z)=>{r&&(z!=null&&z.templates&&z.templates.length>0?j({profileId:C,manifest:z}):R(C))};if(v){const C=v.manifest.templates??[];return a.jsxs(a.Fragment,{children:[a.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginBottom:"1rem"},onClick:()=>j(null),children:"← Back to profiles"}),a.jsxs("h3",{style:{margin:"0 0 0.25rem 0",fontSize:"1rem"},children:["Set up ",v.manifest.name," authorization"]}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.5rem",marginBottom:"0.75rem",fontWeight:600},children:"Quick start"}),a.jsx("div",{style:{display:"grid",gap:"0.75rem",gridTemplateColumns:`repeat(${Math.min(C.length,3)}, 1fr)`},children:C.map(z=>a.jsxs("button",{className:"template-card",onClick:()=>R(v.profileId,z),children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.375rem"},children:[a.jsx("span",{className:`template-mode template-mode-${z.mode==="automatic"?"auto":"review"}`,children:z.mode==="automatic"?"Auto":"Review"}),a.jsx("span",{className:"template-risk","data-risk":z.risk,children:z.risk})]}),a.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.25rem"},children:z.name}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",lineHeight:1.45,marginBottom:"0.5rem"},children:z.description}),a.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.3rem"},children:z.tags.map(D=>a.jsx("span",{className:"template-tag",children:D},D))})]},z.name))}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",margin:"1.5rem 0"},children:[a.jsx("div",{style:{flex:1,height:"1px",background:"var(--border)"}}),a.jsx("span",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"or"}),a.jsx("div",{style:{flex:1,height:"1px",background:"var(--border)"}})]}),a.jsx("button",{className:"btn btn-primary",style:{width:"100%",textAlign:"center",padding:"0.75rem"},onClick:()=>R(v.profileId),children:"Custom — define your own limits and scope"})]})}return a.jsxs(a.Fragment,{children:[a.jsx("style",{children:`
70
70
  .profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
71
71
  .profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
72
72
  @media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
73
73
  @media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
74
- `}),m?a.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):k.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(Qe,{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:k.map(({manifest:C,profile:z,integration:D})=>{const Y=I(z.id),K=(D==null?void 0:D.running)===!0;return a.jsxs("div",{className:"card",style:K?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}),Y?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||z.description}),K?a.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>_(z.id,C),children:"Authorize"}):a.jsxs(Qe,{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 Bv={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function Dv({status:e,label:t}){return a.jsx("span",{className:`status-badge status-${e}`,children:t||Bv[e]})}function Uv({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 Cn=86400,Pr=3600,$s=60,Wv=30*Cn;function Hv(e){if(e<=0)return"Expired";if(e>90*Cn){const t=Math.floor(e/Wv);return`${t} ${t===1?"month":"months"} remaining`}if(e>7*Cn){const t=Math.floor(e/Cn);return`${t} ${t===1?"day":"days"} remaining`}if(e>=2*Cn){const t=Math.floor(e/Cn),n=Math.floor(e%Cn/Pr);return`${t} ${t===1?"day":"days"} ${n}h remaining`}if(e>=2*Pr){const t=Math.floor(e/Pr),n=Math.floor(e%Pr/$s);return`${t}h ${String(n).padStart(2,"0")}m remaining`}if(e>=$s){const t=Math.floor(e/$s),n=Math.floor(e%$s);return`${t}m ${String(n).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function Vv({expiresAt:e}){const[t,n]=u.useState(()=>e-Date.now()/1e3),r=t<2*Pr;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:Hv(t)})}function qf({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 Gv(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 Kv=[{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 Yv({item:e,onClose:t,onSuccess:n}){var y;const{user:r,activeDomain:s,groupId:o}=Ae(),[i,l]=u.useState(null);u.useEffect(()=>{let S=!1;return $.getProfile(e.profile_id).then(k=>{var I;S||l(((I=k==null?void 0:k.ttl)==null?void 0:I.max)??null)}).catch(()=>{}),()=>{S=!0}},[e.profile_id]);const c=e.remaining_seconds??0,d=Kv.filter(S=>S.seconds>c&&(i===null||S.seconds<=i)),f=((y=d[0])==null?void 0:y.seconds)??2592e3,[m,p]=u.useState(f);u.useEffect(()=>{var S;if(i!==null&&m>i){const k=(S=d[d.length-1])==null?void 0:S.seconds;k&&p(k)}},[i]);const[x,w]=u.useState(!1),[v,j]=u.useState(""),h=Object.entries(e.frame).filter(([S])=>S!=="profile"&&S!=="path"),g=async()=>{var S;if(r){w(!0),j("");try{const k=e.authorization_id,I=await $.getGateContent(k);if(!I)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const R=await $.getProfile(e.profile_id),_=e.frame,C=I.context??{},z=e.attested_domains[0]||s||"owner",D=await Js(_,R),Y=await Qf(C,R),[K,W]=await Promise.all([ka(I.gateContent.intent),ka(JSON.stringify({profile:e.profile_id,path:e.path,domain:z}))]);if(!o)throw new Error("No active group; cannot extend authorization.");const T=(((S=e.deferred_commitment_domains)==null?void 0:S.length)??0)>0?"review":"automatic",q=await $.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,bounds:_,bounds_hash:D,context_hash:Y,domain:z,did:r.did,gate_content_hashes:{intent:K},execution_context_hash:W,group_id:o,commitment_mode:T,ttl:m});await $.pushGateContent(Jf(q,{boundsHash:D,contextHash:Y,context:C,path:e.path,gateContent:I.gateContent})),n()}catch(k){j(k instanceof Error?k.message:"Extension failed")}finally{w(!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:[ze(e.profile_id)," / ",e.path]}),h.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:h.map(([S,k])=>`${S}=${k}`).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 ",Gv(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 ${m===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)."}),v&&a.jsx("div",{className:"error-message",children:v})]}),a.jsxs("div",{className:"modal-footer",children:[a.jsx("button",{className:"btn btn-secondary",onClick:t,disabled:x,children:"Cancel"}),a.jsx("button",{className:"btn btn-primary",onClick:g,disabled:x,children:x?"Extending...":"Extend"})]})]})})}function Qv(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=At(r,{revokedSet:t}),i=At(s,{revokedSet:t}),l={active:0,pending:1,expired:2,revoked:3};return l[o]!==l[i]?l[o]-l[i]:new Date(s.created_at).getTime()-new Date(r.created_at).getTime()})}function Jv({item:e,newerProfile:t,revokedSet:n,expandedHash:r,gateCache:s,gateLoading:o,copiedHash:i,revokingHash:l,copyingHash:c,profileConfigCache:d,mode:f,ownerLabel:m,isAdmin:p,onExpand:x,onCopyHash:w,onCopy:v,onRevoke:j,onExtend:h,highlightHash:g}){var U;const y=At(e,{revokedSet:n}),S=r===e.authorization_id,k=s[e.authorization_id],I=y==="active"||y==="pending"||y==="expired",R=Object.entries(e.frame).filter(([O])=>O!=="profile"&&O!=="path"),_=d.get(e.profile_id)??null,C=(((U=_==null?void 0:_.approvers)==null?void 0:U.length)??0)>0,z=new Map;if(_!=null&&_.caps&&f==="team")for(const[O,G]of R){const X=_.caps[O];X!==void 0&&Number(G)>X&&z.set(O,{authorized:Number(G),cap:X})}const D=z.size>0,Y=e.approvers_frozen??[],K=(_==null?void 0:_.approvers)??[],W=f==="team"&&Y.length>0&&K.length>0&&(Y.length!==K.length||Y.some(O=>!K.includes(O))||K.some(O=>!Y.includes(O))),T=Array.from(z.entries()).map(([O,G])=>`${O}: ${G.authorized} (cap ${G.cap})`).join(", "),q=Array.from(z.entries()).map(([O,G])=>`${O}: ${G.authorized} → ${G.cap}`).join(", "),ee=D?C?z.size===1?`Above team cap: ${T} — actions require approval`:`Above team cap (${z.size}): ${T} — actions require approval`:z.size===1?`Reduced by hard cap: ${q}`:`Reduced by hard cap (${z.size}): ${q}`:"",F=D?C?"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,L=ze(e.profile_id),H=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:[L,"@",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,A=g!=null&&e.authorization_id===g;return a.jsxs("div",{className:`card${A?" card-highlight":""}`,style:{marginBottom:0},children:[H,m&&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:m})]}),a.jsxs("div",{className:"auth-card-header",children:[a.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:L}),e.title&&a.jsx("span",{style:{fontWeight:500,fontSize:"0.85rem",color:"var(--text-secondary)"},children:e.title}),a.jsx(Dv,{status:y}),y==="active"&&e.earliest_expiry&&a.jsx(Vv,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),y==="expired"&&(()=>{const O=my(e,y);return O?a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(O.iso).toLocaleString()}`,children:new Date(O.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(O=>a.jsx(Uv,{domain:O,attested:e.attested_domains.includes(O)},O)),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"}),D&&a.jsx("span",{title:F,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:C?"var(--accent-subtle)":"var(--danger-subtle)",color:C?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:ee}),W&&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:()=>v(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"})]}),R.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:R.map(([O,G],X)=>{const Z=z.get(O);return a.jsxs("span",{children:[X>0&&" · ",Z?C?a.jsxs("span",{title:`Team cap on ${O} is ${Z.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${Z.authorized}.`,children:[a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[O,"=",String(G)]}),a.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",Z.cap]})]}):a.jsxs("span",{title:`Team cap on ${O} is ${Z.cap} with no approvers configured (hard cap). Authorized for ${Z.authorized}; effective ${Z.cap}.`,children:[a.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[O,"=",String(G)]}),a.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",Z.cap]})]}):a.jsxs("span",{children:[O,"=",String(G)]})]},O)})}),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",onClick:()=>x(e),children:S?"▲ Hide Details":"▼ Details"})}),S&&a.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[R.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:R.map(([O,G])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:O}),a.jsx("dd",{children:String(G)})]},O))})]}),(k==null?void 0:k.context)&&Object.keys(k.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(k.context).map(([O,G])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:O}),a.jsx("dd",{title:String(G),children:Xf(O,G,k.contextLabels)})]},O))})]}),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..."}):k?a.jsx("div",{className:"gate-content-block",children:a.jsx("div",{className:"gate-content-item",children:a.jsx("div",{className:"gate-content-text",children:k.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:()=>w(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:[!m&&a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>v(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"}),!m&&(y==="active"||y==="pending")&&a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>v(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"}),!m&&I&&a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>h(e),children:"↻ Extend"}),m&&p&&y!=="revoked"?a.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>j(e.authorization_id,m,L),disabled:l===e.authorization_id,children:l===e.authorization_id?"Revoking…":"Revoke"}):!m&&(y==="active"||y==="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 Xv(){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,m]=u.useState("mine"),[p,x]=u.useState("active"),[w,v]=u.useState(null),[j,h]=u.useState(null),[g,y]=$f(),[S,k]=u.useState(()=>g.get("new")==="1"),[I,R]=u.useState(()=>g.get("highlight")),[_,C]=u.useState(null),[z,D]=u.useState({}),[Y,K]=u.useState(null),[W,T]=u.useState(null),[q,ee]=u.useState(null),[F,L]=u.useState(new Set),[H,A]=u.useState(null),[U,O]=u.useState(null),G=qt(),{group:X,groupId:Z,domain:de,mode:$e,activeTeam:Be}=Ae(),le=(Be==null?void 0:Be.isAdmin)===!0,[M,J]=u.useState(()=>new Map),te=u.useCallback(()=>{r(!0),$.getMyAttestations().then(t).catch(()=>{}).finally(()=>r(!1))},[]),he=u.useCallback(()=>{Z&&(l(!0),$.listTeamAuthorizations(Z).then(o).catch(()=>{}).finally(()=>l(!1)))},[Z]);ue("attestation-changed",()=>{te(),le&&Z&&he()}),u.useEffect(()=>{if(!I)return;g.get("highlight")&&(g.delete("highlight"),y(g,{replace:!0}));const N=window.setTimeout(()=>R(null),3e3);return()=>window.clearTimeout(N)},[]),Lt(te,3e5),u.useEffect(()=>{f==="team"&&le&&Z&&s.length===0&&!i&&he()},[f,le,Z,s.length,i,he]),u.useEffect(()=>{let N=!1;return $.listProfiles().then(E=>{if(N)return;const V=ie=>ie.replace(/@.*$/,"").split("/").pop()??ie,ne=ie=>ie.split("@")[1]??"",ce=new Map;for(const ie of E){const Ce=V(ie.id),Ze=ce.get(Ce);(!Ze||ne(ie.id).localeCompare(ne(Ze.id),void 0,{numeric:!0})>0)&&ce.set(Ce,ie)}d(ce)}).catch(()=>{}),()=>{N=!0}},[]);const pe=u.useCallback(N=>{const E=Ce=>Ce.replace(/@.*$/,"").split("/").pop()??Ce,V=Ce=>Ce.split("@")[1]??"",ne=c.get(E(N));if(!ne)return;const ce=V(N),ie=V(ne.id);if(!(!ce||!ie))return ie.localeCompare(ce,void 0,{numeric:!0})>0?ne:void 0},[c]);u.useEffect(()=>{if($e!=="team"||!Z)return;const N=f==="mine"?e:s;if(N.length===0)return;const E=[...new Set(N.map(V=>V.profile_id))].filter(V=>!M.has(V));if(E.length!==0){J(V=>{const ne=new Map(V);for(const ce of E)ne.set(ce,null);return ne});for(const V of E)$.getTeamProfileConfig(Z,V).then(ne=>{J(ce=>new Map(ce).set(V,ne))}).catch(()=>{})}},[e,s,f,Z,$e,M]);const Le=async N=>{if(_===N.authorization_id){C(null);return}C(N.authorization_id);const E=N.authorization_id;if(!(E in z)){K(N.authorization_id);try{const V=await $.getGateContent(E);D(ne=>({...ne,[E]:V}))}catch{D(V=>({...V,[E]:null}))}finally{K(null)}}},ot=N=>{navigator.clipboard.writeText(N).then(()=>{ee(N),setTimeout(()=>ee(null),2e3)})},De=async(N,E)=>{var V;if(!Z){alert("No active group; cannot copy authorization.");return}O(N.authorization_id);try{const ne=N.authorization_id;let ce=z[ne]??null;ne in z||(ce=await $.getGateContent(ne),D(On=>({...On,[ne]:ce})));const ie=Object.fromEntries(Object.entries(N.frame).filter(([On])=>On!=="profile"&&On!=="path")),Ce=(ce==null?void 0:ce.context)??{},Ze=((V=ce==null?void 0:ce.gateContent)==null?void 0:V.intent)??"",et=N.deferred_commitment_domains.length>0?"review":"automatic",Sn=N.attested_domains[0]||de||"owner",it=Date.parse(N.created_at),ae=N.earliest_expiry?Date.parse(N.earliest_expiry):NaN,Bt=Number.isFinite(it)&&Number.isFinite(ae)&&ae>it?Math.round((ae-it)/1e3):void 0;sessionStorage.setItem("agentAuth",JSON.stringify({profileId:N.profile_id,groupId:Z,groupName:(X==null?void 0:X.name)??null,domain:Sn})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:ie,context:Ce,gateContent:{intent:Ze},templateMode:et,templateTtl:Bt})),E!=null&&E.asEdit?sessionStorage.setItem("agentEditReplaces",N.authorization_id):sessionStorage.removeItem("agentEditReplaces"),G("/agent/gate")}catch(ne){alert(ne instanceof Error?ne.message:"Failed to copy authorization")}finally{O(null)}},ht=async(N,E,V)=>{const ne=E&&V?`Revoke ${E}'s ${V} authorization? This cannot be undone.`:"Revoke this authorization? The agent will no longer be able to execute actions under this attestation.";if(confirm(ne)){A(N);try{await $.revokeAttestation(N),L(ce=>new Set(ce).add(N)),$.resyncGates().catch(()=>{}),E&&Z&&he()}catch(ce){alert(ce instanceof Error?ce.message:"Failed to revoke authorization")}finally{A(null)}}},Ie=f==="mine"?e:s,Ke=f==="mine"?n:i,se={active:Ie.filter(N=>At(N,{revokedSet:F})==="active").length,pending:Ie.filter(N=>At(N,{revokedSet:F})==="pending").length,expired:Ie.filter(N=>At(N,{revokedSet:F})==="expired").length,revoked:Ie.filter(N=>At(N,{revokedSet:F})==="revoked").length},Ue=(()=>{const N=new Map;for(const E of Ie){if(At(E,{revokedSet:F})!==p)continue;const V=N.get(E.profile_id)??{count:0,review:!1};V.count+=1,E.deferred_commitment_domains.length>0&&(V.review=!0),N.set(E.profile_id,V)}return Array.from(N.entries()).map(([E,V])=>({profileId:E,...V})).sort((E,V)=>ze(E.profileId).localeCompare(ze(V.profileId)))})(),P=Qv(Ie.filter(N=>{if(At(N,{revokedSet:F})!==p||w!==null&&N.profile_id!==w)return!1;if(j!==null){const E=N.deferred_commitment_domains.length>0;if(j==="review"&&!E||j==="auto"&&E)return!1}return!0}),F,I),b={revokedSet:F,expandedHash:_,gateCache:z,gateLoading:Y,copiedHash:q,revokingHash:H,copyingHash:U,profileConfigCache:M,mode:$e,activeDomain:de,group:X,groupId:Z,onExpand:Le,onCopyHash:ot,onCopy:De,onRevoke:ht,onExtend:T,highlightHash:I};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:"Authorizations"}),a.jsx("p",{className:"page-subtitle",children:"Active, pending, and expired agent authorizations."})]}),a.jsx("button",{className:"btn btn-primary",onClick:()=>k(!0),children:"+ New authorization"})]}),S&&a.jsx("div",{className:"modal-backdrop",onClick:()=>{k(!1),g.get("new")&&(g.delete("new"),y(g,{replace:!0}))},children:a.jsxs("div",{className:"modal",onClick:N=>N.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:()=>{k(!1),g.get("new")&&(g.delete("new"),y(g,{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(Ov,{onDismiss:()=>k(!1)})]})]})}),le&&a.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[a.jsx("button",{className:`nav-tab${f==="mine"?" active":""}`,onClick:()=>{m("mine"),x("active"),v(null),h(null),C(null)},children:"Mine"}),a.jsx("button",{className:`nav-tab${f==="team"?" active":""}`,onClick:()=>{m("team"),x("active"),v(null),h(null),C(null)},children:"Team"})]}),a.jsx("div",{className:"nav-tabs",children:["active","pending","expired","revoked"].map(N=>a.jsxs("button",{className:`nav-tab${p===N?" active":""}`,onClick:()=>{x(N),v(null),h(null)},children:[N.charAt(0).toUpperCase()+N.slice(1)," (",se[N],")"]},N))}),Ue.length>0&&a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[Ue.map(N=>{const E=w===N.profileId;return a.jsx("button",{className:`btn btn-sm ${E?"btn-primary":"btn-secondary"}`,onClick:()=>v(E?null:N.profileId),children:ze(N.profileId)},N.profileId)}),a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(N=>{const E=j===N;return a.jsx("button",{className:`btn btn-sm ${E?"btn-primary":"btn-secondary"}`,onClick:()=>h(E?null:N),children:N==="auto"?"Auto":"Review"},N)})]}),Ke&&Ie.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):P.length===0?a.jsx(qf,{icon:"☰",title:"No authorizations",text:`No ${p} authorizations found.`}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:P.map(N=>{const E=f==="team"?N:null,V=E!=null&&E.owner?E.owner.name??E.owner.email??E.owner.userId:void 0;return a.jsx(Jv,{item:N,newerProfile:pe(N.profile_id),ownerLabel:V,isAdmin:le,...b},N.authorization_id)})}),W&&a.jsx(Yv,{item:W,onClose:()=>T(null),onSuccess:()=>{T(null),te()}})]})}function qv(e){const t=e.indexOf("__");return t<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,t),toolName:e.slice(t+2)}}function Zv(e,t){var c,d,f;const{integrationId:n,toolName:r}=qv(e.action),s=t.find(m=>m.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=ze(e.profileId),l=(f=e.executionContext)==null?void 0:f.action_type;return typeof l=="string"&&l?`${i} · ${l}`:`${i} · ${r}`}function ex(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 tx(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 nx(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`,m=Object.keys(t??{}).filter(j=>j.endsWith(f)),p=(r&&m.find(j=>j.startsWith(`${r}_`)))??(m.length===1?m[0]:void 0),w=(p?/^(amount|spend)_/.test(p):!1)?d.amount:d.count,v=p?Number(t==null?void 0:t[p]):NaN;p&&Number.isFinite(v)?s.push(`${w} of ${v} ${c}`):s.push(`${d.count} ${d.count===1?"call":"calls"} ${c}`)}return s.join(" · ")}function rx(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function sx(e){const t=ze(e),n=e.split("@")[1];return n?`${t}@${n}`:t}function Er({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 ax({receipt:e,manifests:t,localAuth:n,localUnavailable:r,signature:s,grantTitle:o,ownerLabel:i,spUrl:l,formatDate:c,onOpenComplete:d}){var w;const f=ex(e),m=tx(n==null?void 0:n.context),p=nx(e,(n==null?void 0:n.bounds)??e.limits),x=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:Zv(e,t)}),a.jsx("span",{className:"receipt-tag",children:rx(e)?"review":"automatic"}),e.contentHash&&a.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(w=e.contentBinding)!=null&&w.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(Er,{label:"authorization",children:a.jsx("strong",{children:o||sx(e.profileId)})}),i&&a.jsx(Er,{label:"owner",children:i}),m&&a.jsx(Er,{label:"allowed",children:m}),p&&a.jsx(Er,{label:"used",children:a.jsx("span",{className:"receipt-num",children:p})}),a.jsx(Er,{label:"intent",children:x?a.jsx("span",{className:"receipt-intent",children:x}):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(([v,j])=>`${v}=${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 ox({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,m]=u.useState(!1);u.useEffect(()=>{let j=!1;return d(!0),$.getArchivedReceipt(e.id).then(h=>{j||(r(h),o(h?"local":"authority-server"),l((h==null?void 0:h.signature)??null))}).catch(()=>{j||o("authority-server")}).finally(()=>{j||d(!1)}),()=>{j=!0}},[e.id]);const p=n?n.entry:{receipt:e},x=JSON.stringify(p,null,2);function w(){const j=URL.createObjectURL(new Blob([x],{type:"application/json"})),h=document.createElement("a");h.href=j,h.download=`suveren-receipt-${e.id.slice(0,8)}.json`,h.click(),URL.revokeObjectURL(j)}async function v(){try{await navigator.clipboard.writeText(x),m(!0),setTimeout(()=>m(!1),2e3)}catch{m(!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:x})]}),a.jsxs("div",{className:"modal-footer",children:[a.jsx("button",{className:"btn btn-primary btn-sm",onClick:w,children:"Download"}),a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:v,children:f?"Copied":"Copy"})]})]})})}function ix(e){return new Date(e*1e3).toLocaleString()}function lx(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 cx(e,t){if(!t)return!0;const n=t.toLowerCase();return e.profileId.toLowerCase().includes(n)||ze(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 Zc(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 ux(){const{activeTeam:e,groupId:t}=Ae(),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(""),[m,p]=u.useState(!0),[x,w]=u.useState({}),[v,j]=u.useState(new Set),[h,g]=u.useState(""),[y,S]=u.useState(new Set),[k,I]=u.useState(new Set),[R,_]=u.useState("all"),[C,z]=u.useState(!1),[D,Y]=u.useState(!1),[K,W]=u.useState(null),[T,q]=u.useState({}),[ee,F]=u.useState(!1),[L,H]=u.useState({}),[A,U]=u.useState({}),[O,G]=u.useState(null),[X,Z]=u.useState(null),[de,$e]=u.useState(!1),[Be,le]=u.useState(!1),M=u.useRef(""),J=u.useCallback(b=>r==="team"&&n&&t?$.listTeamReceiptsPage(t,{before:b,limit:200}):$.getMyReceiptsPage({before:b,limit:200}),[r,n,t]),te=u.useCallback(()=>{const b=r==="team"?`team:${t}`:"mine",N=M.current!==b;M.current=b,p(!0),le(!1),J().then(E=>{i(V=>N?E.receipts:Zc(V,E.receipts)),Z(V=>N?E.nextBefore:V??E.nextBefore)}).catch(()=>{N&&i([]),le(!0)}).finally(()=>p(!1))},[J,r,t]),he=u.useCallback(()=>{!X||de||($e(!0),le(!1),J(X).then(b=>{i(N=>Zc(N,b.receipts)),Z(b.nextBefore)}).catch(()=>le(!0)).finally(()=>$e(!1)))},[X,de,J]);Lt(te,12e4),u.useEffect(()=>{$.getIntegrationManifests().then(({manifests:b})=>c(b)).catch(()=>{}),fetch("/health").then(b=>b.json()).then(b=>{typeof b.spUrl=="string"&&f(b.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),u.useEffect(()=>{$.getLocalAuthorizations().then(({authorizations:b,signatures:N})=>{q(b),H(N),F(!1)}).catch(()=>{q({}),H({}),F(!0)}),$.getMyAttestations().then(b=>{const N={};for(const E of b)E.authorization_id&&E.title&&(N[E.authorization_id]=E.title);U(N)}).catch(()=>{})},[]),u.useEffect(()=>{r!=="team"||Object.keys(x).length>0||$.listUsers().then(b=>{const N={};for(const E of b)N[E.id]={name:E.name,email:E.email};w(N)}).catch(()=>{})},[r,x]);const pe=u.useMemo(()=>{const b=new Set;for(const N of o)b.add(ze(N.profileId));return[...b].sort()},[o]),Le=u.useMemo(()=>{const b=new Set;for(const N of o)b.add(N.action);return[...b].sort()},[o]),ot=u.useMemo(()=>{if(r!=="team")return[];const b=new Set;for(const N of o)N.userId&&b.add(N.userId);return[...b].map(N=>{var E;return{id:N,label:(E=x[N])!=null&&E.name?`${x[N].name} (${x[N].email})`:N}}).sort((N,E)=>N.label.localeCompare(E.label))},[r,o,x]),De=u.useMemo(()=>o.filter(b=>!(!cx(b,h)||y.size>0&&!y.has(ze(b.profileId))||k.size>0&&!k.has(b.action)||v.size>0&&b.userId&&!v.has(b.userId)||!lx(b,R))),[o,h,y,k,v,R]),ht=y.size>0||k.size>0||v.size>0||R!=="all";function Ie(b){S(N=>{const E=new Set(N);return E.has(b)?E.delete(b):E.add(b),E})}function Ke(b){I(N=>{const E=new Set(N);return E.has(b)?E.delete(b):E.add(b),E})}function se(b){j(N=>{const E=new Set(N);return E.has(b)?E.delete(b):E.add(b),E})}function Ue(){S(new Set),I(new Set),j(new Set),_("all"),g("")}async function P(){Y(!0),W(null);try{const{bundle:b,filename:N}=await $.fetchEvidenceBundle(),E=URL.createObjectURL(new Blob([JSON.stringify(b,null,2)],{type:"application/json"})),V=document.createElement("a");V.href=E,V.download=N,V.click(),URL.revokeObjectURL(E);const ne=b.sources??{};ne.authorityServer?ne.local||W(`Downloaded Authority Server history only — ${ne.localError??"local archive unavailable."}`):W(`Downloaded local evidence only — ${ne.asError??"Authority Server export unavailable."}`)}catch(b){W(`Export failed: ${b instanceof Error?b.message:String(b)}`)}finally{Y(!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:"Receipts"}),a.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),a.jsx("button",{className:"btn btn-secondary",onClick:P,disabled:D,children:D?"Preparing…":"Download evidence"})]}),K&&a.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:K}),n&&a.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(b=>a.jsx("button",{onClick:()=>s(b),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:r===b?"2px solid var(--accent)":"2px solid transparent",color:r===b?"var(--text-primary)":"var(--text-tertiary)",fontWeight:r===b?600:500},children:b==="mine"?"Mine":"Team"},b))}),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:h,onChange:b=>g(b.target.value)}),h&&a.jsx("button",{className:"search-clear",onClick:()=>g(""),children:"×"})]}),a.jsxs("button",{className:`btn btn-sm btn-secondary${C?" active":""}`,onClick:()=>z(!C),children:["Filters",ht?` (${y.size+k.size+(R!=="all"?1:0)})`:""]})]}),C&&a.jsxs("div",{className:"filter-panel",children:[pe.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Profile"}),a.jsx("div",{className:"filter-chips",children:pe.map(b=>a.jsx("button",{className:`filter-chip${y.has(b)?" selected":""}`,onClick:()=>Ie(b),children:b},b))})]}),Le.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Action"}),a.jsx("div",{className:"filter-chips",children:Le.map(b=>a.jsx("button",{className:`filter-chip${k.has(b)?" selected":""}`,onClick:()=>Ke(b),children:b},b))})]}),r==="team"&&ot.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Owner"}),a.jsx("div",{className:"filter-chips",children:ot.map(b=>a.jsx("button",{className:`filter-chip${v.has(b.id)?" selected":""}`,onClick:()=>se(b.id),children:b.label},b.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(([b,N])=>a.jsx("button",{className:`filter-chip${R===b?" selected":""}`,onClick:()=>_(b),children:N},b))})]})]}),ht&&a.jsxs("div",{className:"active-filters",children:[[...y].map(b=>a.jsxs("span",{className:"active-chip",onClick:()=>Ie(b),children:[b," ",a.jsx("span",{className:"chip-remove",children:"×"})]},b)),[...k].map(b=>a.jsxs("span",{className:"active-chip",onClick:()=>Ke(b),children:[b," ",a.jsx("span",{className:"chip-remove",children:"×"})]},b)),[...v].map(b=>{const N=x[b],E=N?N.name:b;return a.jsxs("span",{className:"active-chip",onClick:()=>se(b),children:[E," ",a.jsx("span",{className:"chip-remove",children:"×"})]},b)}),R!=="all"&&a.jsxs("span",{className:"active-chip",onClick:()=>_("all"),children:[R==="1d"?"Today":R==="7d"?"7 days":"30 days"," ",a.jsx("span",{className:"chip-remove",children:"×"})]}),a.jsx("button",{className:"clear-filters",onClick:Ue,children:"Clear all"})]}),Be&&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."})}),m&&o.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):De.length===0?a.jsx(qf,{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:De.length===o.length?`${o.length} receipt${o.length!==1?"s":""}`:`${De.length} of ${o.length} receipts`}),a.jsx("div",{className:"timeline",children:De.map(b=>{const N=b.userId?x[b.userId]:void 0;return a.jsx("div",{className:"timeline-event",children:a.jsx(ax,{receipt:b,manifests:l,localAuth:b.authorizationId?T[b.authorizationId]:void 0,localUnavailable:ee,signature:L[b.id],grantTitle:b.authorizationId?A[b.authorizationId]:null,ownerLabel:r==="team"&&b.userId?N?`${N.name} (${N.email})`:b.userId:null,spUrl:d,formatDate:ix,onOpenComplete:()=>G(b)})},b.id)})})]}),O&&a.jsx(ox,{receipt:O,onClose:()=>G(null)}),X&&a.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:he,disabled:de,children:de?"Loading…":"Load older"})})]})}const dx={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function fx(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[s,o]=u.useState(null),i=u.useCallback(async()=>{try{t(await $.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 $.setAutostart(!e.installed)}catch(d){o(d instanceof Error?d.message:"Failed")}finally{try{t(await $.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=dx[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 px(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[s,o]=u.useState(null),i=u.useCallback(async()=>{try{const c=await $.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 $.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 hx(){const{version:e,latestVersion:t,updateAvailable:n,installMethod:r}=Nl();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 gx={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 yx(){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,m]=u.useState(""),[p,x]=u.useState(!1),[w,v]=u.useState(!1),[j,h]=u.useState(!1),[g,y]=u.useState(null),[S,k]=u.useState([]),[I,R]=u.useState(!1),[_,C]=u.useState(null),[z,D]=u.useState(""),Y=u.useCallback(L=>{t(L),setTimeout(()=>t(""),3e3)},[]),K=u.useCallback(async(L,H,A)=>{R(!0),C(null);try{const U=await $.aiModels({provider:L,endpoint:H,...A?{apiKey:A}:{}});U.ok&&U.models.length>0?(k(U.models),C(`${U.models.length} models available`)):(k([]),C(U.message||"No models returned — using defaults"))}catch(U){k([]),C(U instanceof Error?U.message:"Failed to load models")}finally{R(!1)}},[]),W=u.useCallback(async()=>{try{const L=await $.getCredential("ai-config");if(x(L.configured),L.configured&&L.fields){const H=L.fields.provider||"openai-compatible",A=L.fields.endpoint||"";L.fields.provider&&o(H),L.fields.endpoint&&l(A),L.fields.model&&d(L.fields.model),A.includes("openai.com")?r("openai"):A.includes("groq.com")?r("groq"):A.includes("together.xyz")?r("together"):A.includes("openrouter.ai")?r("openrouter"):r("ollama"),A&&K(H,A)}}catch{}},[K]);u.useEffect(()=>{W()},[W]);const T=L=>{r(L),k([]),C(null),D("");const H=gx[L];H&&(o(H.provider),l(H.endpoint),d(""),K(H.provider,H.endpoint,f||void 0))},q=()=>K(s,i,f||void 0),ee=async()=>{v(!0);try{await $.setCredential("ai-config",{provider:s,endpoint:i,model:c,...f?{apiKey:f}:{}}),x(!0),Y("AI configuration saved!")}catch{Y("Failed to save AI config")}finally{v(!1)}},F=async()=>{h(!0),y(null);try{const L=await $.aiTest({provider:s,endpoint:i,model:c,...f?{apiKey:f}:{}});y(L.ok?`OK: ${L.message}`:`Failed: ${L.message}`)}catch(L){y(`Error: ${L instanceof Error?L.message:"Unknown"}`)}finally{h(!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:L=>T(L.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:L=>m(L.target.value),onBlur:()=>{f.trim()&&K(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:q,disabled:I,title:"Re-fetch the model list from the provider",children:I?"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:I?"Loading models…":s==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const L=S,H=L.includes(c),A=L.length>12,U=z.trim().toLowerCase();let O=U?L.filter(G=>G.toLowerCase().includes(U)):L;return H&&!O.includes(c)&&(O=[c,...O]),a.jsxs(a.Fragment,{children:[A&&a.jsx("input",{className:"form-input",value:z,onChange:G=>D(G.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),a.jsxs("select",{className:"form-input",value:H?c:"__unset__",onChange:G=>d(G.target.value==="__unset__"?"":G.target.value),children:[a.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),O.map(G=>a.jsx("option",{value:G,children:G},G)),U&&O.length===0&&a.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",z,"”"]})]})]})})(),_&&a.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:_})]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.jsx("button",{className:"btn btn-primary",onClick:ee,disabled:w||!c.trim(),title:c.trim()?void 0:"Select a model first",children:w?"Saving...":"Save & Encrypt"}),p&&a.jsx("button",{className:"btn btn-ghost",onClick:F,disabled:j,children:j?"Testing...":"Test Connection"})]}),g&&a.jsx("div",{className:`alert ${g.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:g})]}),a.jsx(vx,{}),a.jsx(fx,{}),a.jsx(px,{}),a.jsx(hx,{}),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 vx(){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,m]=u.useState(!1),p=u.useCallback(async()=>{if(!f)try{const v=await $.getAIPrompts();t(v),r({intent:v.intent.current,context:v.context.current}),m(!0)}catch(v){l(v instanceof Error?v.message:"Failed to load prompts")}},[f]),x=async v=>{if(e){o(v),l(null);try{const j=n[v],h=j.trim()===e[v].default.trim()?"":j;await $.setAIPrompt(v,h);const g=await $.getAIPrompts();t(g),r({intent:g.intent.current,context:g.context.current}),d(v),setTimeout(()=>d(null),2e3)}catch(j){l(j instanceof Error?j.message:"Save failed")}finally{o(null)}}},w=async v=>{if(confirm(`Revert ${v} prompt to the built-in default?`)){o(v),l(null);try{await $.setAIPrompt(v,"");const j=await $.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:v=>{v.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(eu,{kind:"intent",label:"Intent — per-authorization",description:"Used on the Intent gate when creating a new authorization.",state:e.intent,draft:n.intent,onChange:v=>r(j=>({...j,intent:v})),onSave:()=>x("intent"),onRevert:()=>w("intent"),saving:s==="intent",justSaved:c==="intent"}),a.jsx(eu,{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:v=>r(j=>({...j,context:v})),onSave:()=>x("context"),onRevert:()=>w("context"),saving:s==="context",justSaved:c==="context"})]})]})}function eu({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:m=>o(m.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 xx(e){return e.proposalId?"review":"automatic"}function tu(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=xx(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 Zf(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 Sx({profileId:e}){return a.jsx("span",{className:"profile-badge",children:ze(e)})}function ep(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 jx={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},kx={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"};function bx(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 Cx(e){return e.split("__").pop()??e}function Nx(e){const t=e.toLowerCase();return t.includes("delete")||t.includes("refund")||t.includes("cancel")||t.includes("revoke")}const Ex=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]),Tx=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function zx(e,t){return typeof t!="string"?!1:/^data:image\//i.test(t)?!0:Tx.test(e)?/^https?:\/\//.test(t):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(t)}function ki(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=>ki(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function nu({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=Cx(l),d=Nx(l),f=o?e.proposal.toolArgs:null,m=o?e.proposal.executionContext:e.receipt.executionContext,p=o?null:e.receipt.cumulativeState,x=o?Zf(s,e.proposal.toolArgs):[],w=f?Object.entries(f).filter(([j])=>!Ex.has(j)):[],v=Object.entries(m??{});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(Sx,{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=ep(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 ${kx[i]}`,children:jx[i]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:bx(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)"}})]}),x.length>0&&a.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:x.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&&w.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:w.map(([j,h])=>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:zx(j,h)?a.jsx("img",{src:h,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:g=>{const y=g.currentTarget,S=y.parentElement;if(!S)return;y.style.display="none";const k=document.createElement("span");k.textContent=h,k.style.color="var(--text-tertiary)",S.appendChild(k)}}):ki(h)})]},j))})]}),v.length>0&&a.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:v.map(([j,h])=>`${j}=${ki(h)}`).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 Ix=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function bi(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=>bi(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Rx(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 Px({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),[m,p]=u.useState(!1),[x,w]=u.useState(null),[v,j]=u.useState(!1),h=e.tool.split("__").pop()??e.tool,g=Object.entries(e.toolArgs).filter(([T])=>!Ix.has(T)),y=Object.entries(e.executionContext),S=Zf(s,e.toolArgs),k=e.pendingApprovers??[],I=e.approvedBy??{},R=Object.keys(I).length,_=k.filter(T=>!(T in I)).length,C=t in I,z=async()=>{if(d===null){p(!0),w(null);try{const T=await $.getAttestationIntent(e.authorizationId);if(!T){w("Intent not available or you are not an authorized approver.");return}const q=await $.decryptIntent({intentCiphertext:T.intentCiphertext,encryptedKey:T.encryptedKey,approverId:t});f(q)}catch(T){w(T instanceof Error?T.message:"Failed to decrypt intent")}finally{p(!1)}}},D=async()=>{v?j(!1):(j(!0),await z())},Y=async()=>{i(!0),r("");try{await $.approveProposal(e.id);try{if(d===null){const T=await $.getAttestationIntent(e.authorizationId);if(T){const q=await $.decryptIntent({intentCiphertext:T.intentCiphertext,encryptedKey:T.encryptedKey,approverId:t});f(q),await $.storeApprovedIntent(e.authorizationId,q)}}else await $.storeApprovedIntent(e.authorizationId,d)}catch{}r(`Approved. ${_-1>0?`${_-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),n()}catch(T){r(T instanceof Error?T.message:"Approval failed")}finally{i(!1)}},K=async()=>{const T=prompt("Rejection reason (optional):");if(T!==null){c(!0),r("");try{await $.rejectProposal(e.id,T||void 0),r("Action rejected."),n()}catch(q){r(q instanceof Error?q.message:"Rejection failed")}finally{c(!1)}}},W=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:ze(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 T=ep(e.expiresAt,Date.now());return a.jsx("span",{style:{fontSize:"0.72rem",color:T.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:T.urgent?600:400,whiteSpace:"nowrap"},children:T.label})})(),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Rx(e.createdAt)})]})]}),a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[R," of ",k.length," approver",k.length===1?"":"s"," signed off",k.map(T=>{const q=T in I;return a.jsxs("span",{style:{marginLeft:"0.5rem",color:q?"var(--success, green)":"var(--text-tertiary)"},children:[q?"✓":"○"," ",T===t?"You":T]},T)})]}),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:h})]}),S.length>0&&a.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:S.map(T=>a.jsxs("a",{href:T.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:T.description??T.href,children:[T.label," ↗"]},T.label))}),g.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:g.map(([T,q])=>a.jsxs(u.Fragment,{children:[a.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:T}),a.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:bi(q)})]},T))})]}),y.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:y.map(([T,q])=>`${T}=${bi(q)}`).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:m,children:[v?"▲ Hide intent":"▼ Show intent",m&&" (decrypting...)"]}),v&&a.jsx("div",{style:{marginTop:"0.5rem",padding:"0.75rem",background:"var(--bg-main)",borderRadius:"0.375rem",border:"1px solid var(--border)"},children:x?a.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:x}):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."})})]}),!C&&a.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[a.jsx("button",{className:"btn btn-primary",onClick:Y,disabled:W,children:o?"Approving...":"Approve"}),a.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:K,disabled:W,children:l?"Rejecting...":"Reject"})]}),C&&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 _x(){const{domain:e,user:t}=Ae(),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),[m,p]=u.useState(""),x=u.useCallback(async()=>{try{const M=await $.getProposalsForApprover();i(M)}catch{}finally{f(!1)}},[]);ue("proposal-added",x),ue("proposal-approved",x),ue("proposal-rejected",x),ue("proposal-resolved",x),Lt(x,3e4);const[w,v]=u.useState([]),j=u.useCallback(async()=>{try{const M=await $.getProposals(e||"owner");v(M)}catch{}},[e]);ue("proposal-added",j),ue("proposal-approved",j),ue("proposal-rejected",j),ue("proposal-resolved",j),Lt(j,3e4,e);const h=u.useMemo(()=>w.filter(M=>{var J;return M.status==="pending"&&(((J=M.pendingApprovers)==null?void 0:J.length)??0)===0}),[w]),g=u.useMemo(()=>tu(h,[],{status:"pending"}),[h]),[y,S]=u.useState([]),k=u.useCallback(async()=>{if(n)try{const J=(await $.getProposals(e||"owner")).filter(te=>te.status==="pending"&&te.pendingApprovers&&te.pendingApprovers.includes(n)&&te.approvedBy&&n in te.approvedBy);S(J)}catch{}},[n,e]);ue("proposal-approved",k),ue("proposal-rejected",k),Lt(k,3e4,`${n}:${e}`),u.useEffect(()=>{$.getIntegrationManifests().then(M=>c(M.manifests??[])).catch(()=>{})},[]);const I=M=>{var J;return(J=l.find(te=>te.id===M.split("__")[0]))==null?void 0:J.proposalLinks};u.useEffect(()=>{x(),j(),k()},[]);const[R,_]=u.useState([]),[C,z]=u.useState([]),[D,Y]=u.useState(!0),[K,W]=u.useState(null),[T,q]=u.useState(""),[ee,F]=u.useState("pending"),[L,H]=u.useState(null),[A,U]=u.useState(!1),O=u.useCallback(async()=>{try{const{proposals:M,receipts:J}=await $.getThread({domain:e,status:ee,sinceDays:7});_(M),z(J)}catch{}finally{Y(!1)}},[e,ee]);Lt(O,3e4,`${e}:${ee}`);const G=async(M,J)=>{W(M),q("");try{const te=e||"owner",he=await $.resolveProposal(M,J,te);q(J==="commit"?`Action approved. Status: ${he.status}`:"Action rejected."),await Promise.all([O(),j()])}catch(te){q(te instanceof Error?te.message:"Failed")}finally{W(null)}},X=u.useMemo(()=>{const M=new Set;for(const J of R)M.add(J.profileId);for(const J of C)M.add(J.profileId);return Array.from(M).sort()},[R,C]),Z=u.useMemo(()=>tu(R,C,{status:ee,profile:L??void 0,includeAutonomous:A}),[R,C,ee,L,A]),de=u.useCallback(()=>{x(),k()},[x,k]),$e=u.useMemo(()=>{const M=new Set,J=[];for(const te of y)M.has(te.id)||(M.add(te.id),J.push(te));return J.sort((te,he)=>he.createdAt-te.createdAt)},[y]),Be=o.length+g.length,le=$e.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 ",Be>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:Be})]}),a.jsxs("button",{className:`nav-tab${r==="awaiting-others"?" active":""}`,onClick:()=>s("awaiting-others"),children:["Awaiting others ",le>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:le})]}),a.jsx("button",{className:`nav-tab${r==="all"?" active":""}`,onClick:()=>{s("all"),O()},children:"All"})]}),r==="awaiting-me"&&a.jsx(a.Fragment,{children:d&&Be===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Be===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:[(m||T)&&a.jsx("div",{className:"alert alert-success",children:m||T}),g.map(M=>a.jsx(nu,{proposalLinks:M.kind==="proposal"?I(M.proposal.tool):void 0,item:M,onApprove:J=>G(J,"commit"),onReject:J=>G(J,"reject"),resolving:K===M.id},M.id)),o.map(M=>a.jsx(Px,{proposal:M,currentUserId:n,onAction:de,onMessage:p,proposalLinks:I(M.tool)},M.id))]})}),r==="awaiting-others"&&a.jsx(a.Fragment,{children:$e.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:$e.map(M=>a.jsx($x,{proposal:M,currentUserId:n,onCancel:async()=>{try{await $.rejectProposal(M.id,"cancelled by creator"),k(),j()}catch(J){alert(J instanceof Error?J.message:"Cancel failed")}}},M.id))})}),r==="all"&&a.jsxs(a.Fragment,{children:[T&&a.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:T}),a.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[a.jsx("button",{className:`filter-chip ${ee==="pending"?"selected":""}`,onClick:()=>F("pending"),children:"Pending"}),a.jsx("button",{className:`filter-chip ${ee==="all"?"selected":""}`,onClick:()=>F("all"),children:"All"}),X.length>0&&a.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),X.map(M=>a.jsx("button",{className:`filter-chip ${L===M?"selected":""}`,onClick:()=>H(L===M?null:M),children:ze(M)},M)),ee==="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 ${A?"selected":""}`,onClick:()=>U(!A),title:"Include actions executed without human review (automatic commitment mode)",children:[A?"✓ ":"","Autonomous actions"]})]})]}),D&&Z.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Z.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:ee==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:ee==="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:Z.map(M=>a.jsx(nu,{proposalLinks:M.kind==="proposal"?I(M.proposal.tool):void 0,item:M,onApprove:J=>G(J,"commit"),onReject:J=>G(J,"reject"),resolving:K===M.id},M.id))})]})]})}function Ax(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 $x({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:ze(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:Ax(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 Lx=`# Agent Brief
74
+ `}),m?a.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):k.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(Qe,{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:k.map(({manifest:C,profile:z,integration:D})=>{const Y=I(z.id),K=(D==null?void 0:D.running)===!0;return a.jsxs("div",{className:"card",style:K?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}),Y?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||z.description}),K?a.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>_(z.id,C),children:"Authorize"}):a.jsxs(Qe,{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 Wv={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function Hv({status:e,label:t}){return a.jsx("span",{className:`status-badge status-${e}`,children:t||Wv[e]})}function Vv({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 Cn=86400,_r=3600,Ls=60,Gv=30*Cn;function Kv(e){if(e<=0)return"Expired";if(e>90*Cn){const t=Math.floor(e/Gv);return`${t} ${t===1?"month":"months"} remaining`}if(e>7*Cn){const t=Math.floor(e/Cn);return`${t} ${t===1?"day":"days"} remaining`}if(e>=2*Cn){const t=Math.floor(e/Cn),n=Math.floor(e%Cn/_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/Ls);return`${t}h ${String(n).padStart(2,"0")}m remaining`}if(e>=Ls){const t=Math.floor(e/Ls),n=Math.floor(e%Ls);return`${t}m ${String(n).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function Yv({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:Kv(t)})}function Zf({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 Qv(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 Jv=[{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 Xv({item:e,onClose:t,onSuccess:n}){var y;const{user:r,activeDomain:s,groupId:o}=Ae(),[i,l]=u.useState(null);u.useEffect(()=>{let S=!1;return $.getProfile(e.profile_id).then(k=>{var I;S||l(((I=k==null?void 0:k.ttl)==null?void 0:I.max)??null)}).catch(()=>{}),()=>{S=!0}},[e.profile_id]);const c=e.remaining_seconds??0,d=Jv.filter(S=>S.seconds>c&&(i===null||S.seconds<=i)),f=((y=d[0])==null?void 0:y.seconds)??2592e3,[m,p]=u.useState(f);u.useEffect(()=>{var S;if(i!==null&&m>i){const k=(S=d[d.length-1])==null?void 0:S.seconds;k&&p(k)}},[i]);const[x,w]=u.useState(!1),[v,j]=u.useState(""),h=Object.entries(e.frame).filter(([S])=>S!=="profile"&&S!=="path"),g=async()=>{var S;if(r){w(!0),j("");try{const k=e.authorization_id,I=await $.getGateContent(k);if(!I)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const R=await $.getProfile(e.profile_id),_=e.frame,C=I.context??{},z=e.attested_domains[0]||s||"owner",D=await Xs(_,R),Y=await Jf(C,R),[K,W]=await Promise.all([ba(I.gateContent.intent),ba(JSON.stringify({profile:e.profile_id,path:e.path,domain:z}))]);if(!o)throw new Error("No active group; cannot extend authorization.");const T=(((S=e.deferred_commitment_domains)==null?void 0:S.length)??0)>0?"review":"automatic",q=await $.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,bounds:_,bounds_hash:D,context_hash:Y,domain:z,did:r.did,gate_content_hashes:{intent:K},execution_context_hash:W,group_id:o,commitment_mode:T,ttl:m});await $.pushGateContent(Xf(q,{boundsHash:D,contextHash:Y,context:C,path:e.path,gateContent:I.gateContent})),n()}catch(k){j(k instanceof Error?k.message:"Extension failed")}finally{w(!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:[ze(e.profile_id)," / ",e.path]}),h.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:h.map(([S,k])=>`${S}=${k}`).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 ",Qv(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 ${m===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)."}),v&&a.jsx("div",{className:"error-message",children:v})]}),a.jsxs("div",{className:"modal-footer",children:[a.jsx("button",{className:"btn btn-secondary",onClick:t,disabled:x,children:"Cancel"}),a.jsx("button",{className:"btn btn-primary",onClick:g,disabled:x,children:x?"Extending...":"Extend"})]})]})})}function qv(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=At(r,{revokedSet:t}),i=At(s,{revokedSet:t}),l={active:0,pending:1,expired:2,revoked:3};return l[o]!==l[i]?l[o]-l[i]:new Date(s.created_at).getTime()-new Date(r.created_at).getTime()})}function Zv({item:e,newerProfile:t,revokedSet:n,expandedHash:r,gateCache:s,gateLoading:o,copiedHash:i,revokingHash:l,copyingHash:c,profileConfigCache:d,mode:f,ownerLabel:m,isAdmin:p,onExpand:x,onCopyHash:w,onCopy:v,onRevoke:j,onExtend:h,highlightHash:g}){var U;const y=At(e,{revokedSet:n}),S=r===e.authorization_id,k=s[e.authorization_id],I=y==="active"||y==="pending"||y==="expired",R=Object.entries(e.frame).filter(([O])=>O!=="profile"&&O!=="path"),_=d.get(e.profile_id)??null,C=(((U=_==null?void 0:_.approvers)==null?void 0:U.length)??0)>0,z=new Map;if(_!=null&&_.caps&&f==="team")for(const[O,G]of R){const X=_.caps[O];X!==void 0&&Number(G)>X&&z.set(O,{authorized:Number(G),cap:X})}const D=z.size>0,Y=e.approvers_frozen??[],K=(_==null?void 0:_.approvers)??[],W=f==="team"&&Y.length>0&&K.length>0&&(Y.length!==K.length||Y.some(O=>!K.includes(O))||K.some(O=>!Y.includes(O))),T=Array.from(z.entries()).map(([O,G])=>`${O}: ${G.authorized} (cap ${G.cap})`).join(", "),q=Array.from(z.entries()).map(([O,G])=>`${O}: ${G.authorized} → ${G.cap}`).join(", "),ee=D?C?z.size===1?`Above team cap: ${T} — actions require approval`:`Above team cap (${z.size}): ${T} — actions require approval`:z.size===1?`Reduced by hard cap: ${q}`:`Reduced by hard cap (${z.size}): ${q}`:"",F=D?C?"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,L=ze(e.profile_id),H=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:[L,"@",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,A=g!=null&&e.authorization_id===g;return a.jsxs("div",{className:`card${A?" card-highlight":""}`,style:{marginBottom:0},children:[H,m&&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:m})]}),a.jsxs("div",{className:"auth-card-header",children:[a.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:L}),e.title&&a.jsx("span",{style:{fontWeight:500,fontSize:"0.85rem",color:"var(--text-secondary)"},children:e.title}),a.jsx(Hv,{status:y}),y==="active"&&e.earliest_expiry&&a.jsx(Yv,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),y==="expired"&&(()=>{const O=hy(e,y);return O?a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(O.iso).toLocaleString()}`,children:new Date(O.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(O=>a.jsx(Vv,{domain:O,attested:e.attested_domains.includes(O)},O)),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"}),D&&a.jsx("span",{title:F,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:C?"var(--accent-subtle)":"var(--danger-subtle)",color:C?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:ee}),W&&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:()=>v(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"})]}),R.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:R.map(([O,G],X)=>{const Z=z.get(O);return a.jsxs("span",{children:[X>0&&" · ",Z?C?a.jsxs("span",{title:`Team cap on ${O} is ${Z.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${Z.authorized}.`,children:[a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[O,"=",String(G)]}),a.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",Z.cap]})]}):a.jsxs("span",{title:`Team cap on ${O} is ${Z.cap} with no approvers configured (hard cap). Authorized for ${Z.authorized}; effective ${Z.cap}.`,children:[a.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[O,"=",String(G)]}),a.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",Z.cap]})]}):a.jsxs("span",{children:[O,"=",String(G)]})]},O)})}),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",onClick:()=>x(e),children:S?"▲ Hide Details":"▼ Details"})}),S&&a.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[R.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:R.map(([O,G])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:O}),a.jsx("dd",{children:String(G)})]},O))})]}),(k==null?void 0:k.context)&&Object.keys(k.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(k.context).map(([O,G])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:O}),a.jsx("dd",{title:String(G),children:qf(O,G,k.contextLabels)})]},O))})]}),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..."}):k?a.jsx("div",{className:"gate-content-block",children:a.jsx("div",{className:"gate-content-item",children:a.jsx("div",{className:"gate-content-text",children:k.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:()=>w(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:[!m&&a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>v(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"}),!m&&(y==="active"||y==="pending")&&a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>v(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"}),!m&&I&&a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>h(e),children:"↻ Extend"}),m&&p&&y!=="revoked"?a.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>j(e.authorization_id,m,L),disabled:l===e.authorization_id,children:l===e.authorization_id?"Revoking…":"Revoke"}):!m&&(y==="active"||y==="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 ex(){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,m]=u.useState("mine"),[p,x]=u.useState("active"),[w,v]=u.useState(null),[j,h]=u.useState(null),[g,y]=Af(),[S,k]=u.useState(()=>g.get("new")==="1"),[I,R]=u.useState(()=>g.get("highlight")),[_,C]=u.useState(null),[z,D]=u.useState({}),[Y,K]=u.useState(null),[W,T]=u.useState(null),[q,ee]=u.useState(null),[F,L]=u.useState(new Set),[H,A]=u.useState(null),[U,O]=u.useState(null),G=qt(),{group:X,groupId:Z,domain:de,mode:$e,activeTeam:Be}=Ae(),le=(Be==null?void 0:Be.isAdmin)===!0,[M,J]=u.useState(()=>new Map),te=u.useCallback(()=>{r(!0),$.getMyAttestations().then(t).catch(()=>{}).finally(()=>r(!1))},[]),he=u.useCallback(()=>{Z&&(l(!0),$.listTeamAuthorizations(Z).then(o).catch(()=>{}).finally(()=>l(!1)))},[Z]);ue("attestation-changed",()=>{te(),le&&Z&&he()}),u.useEffect(()=>{if(!I)return;g.get("highlight")&&(g.delete("highlight"),y(g,{replace:!0}));const N=window.setTimeout(()=>R(null),3e3);return()=>window.clearTimeout(N)},[]),Lt(te,3e5),u.useEffect(()=>{f==="team"&&le&&Z&&s.length===0&&!i&&he()},[f,le,Z,s.length,i,he]),u.useEffect(()=>{let N=!1;return $.listProfiles().then(E=>{if(N)return;const V=ie=>ie.replace(/@.*$/,"").split("/").pop()??ie,ne=ie=>ie.split("@")[1]??"",ce=new Map;for(const ie of E){const Ce=V(ie.id),Ze=ce.get(Ce);(!Ze||ne(ie.id).localeCompare(ne(Ze.id),void 0,{numeric:!0})>0)&&ce.set(Ce,ie)}d(ce)}).catch(()=>{}),()=>{N=!0}},[]);const pe=u.useCallback(N=>{const E=Ce=>Ce.replace(/@.*$/,"").split("/").pop()??Ce,V=Ce=>Ce.split("@")[1]??"",ne=c.get(E(N));if(!ne)return;const ce=V(N),ie=V(ne.id);if(!(!ce||!ie))return ie.localeCompare(ce,void 0,{numeric:!0})>0?ne:void 0},[c]);u.useEffect(()=>{if($e!=="team"||!Z)return;const N=f==="mine"?e:s;if(N.length===0)return;const E=[...new Set(N.map(V=>V.profile_id))].filter(V=>!M.has(V));if(E.length!==0){J(V=>{const ne=new Map(V);for(const ce of E)ne.set(ce,null);return ne});for(const V of E)$.getTeamProfileConfig(Z,V).then(ne=>{J(ce=>new Map(ce).set(V,ne))}).catch(()=>{})}},[e,s,f,Z,$e,M]);const Le=async N=>{if(_===N.authorization_id){C(null);return}C(N.authorization_id);const E=N.authorization_id;if(!(E in z)){K(N.authorization_id);try{const V=await $.getGateContent(E);D(ne=>({...ne,[E]:V}))}catch{D(V=>({...V,[E]:null}))}finally{K(null)}}},ot=N=>{navigator.clipboard.writeText(N).then(()=>{ee(N),setTimeout(()=>ee(null),2e3)})},De=async(N,E)=>{var V;if(!Z){alert("No active group; cannot copy authorization.");return}O(N.authorization_id);try{const ne=N.authorization_id;let ce=z[ne]??null;ne in z||(ce=await $.getGateContent(ne),D(On=>({...On,[ne]:ce})));const ie=Object.fromEntries(Object.entries(N.frame).filter(([On])=>On!=="profile"&&On!=="path")),Ce=(ce==null?void 0:ce.context)??{},Ze=((V=ce==null?void 0:ce.gateContent)==null?void 0:V.intent)??"",et=N.deferred_commitment_domains.length>0?"review":"automatic",Sn=N.attested_domains[0]||de||"owner",it=Date.parse(N.created_at),ae=N.earliest_expiry?Date.parse(N.earliest_expiry):NaN,Bt=Number.isFinite(it)&&Number.isFinite(ae)&&ae>it?Math.round((ae-it)/1e3):void 0;sessionStorage.setItem("agentAuth",JSON.stringify({profileId:N.profile_id,groupId:Z,groupName:(X==null?void 0:X.name)??null,domain:Sn})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:ie,context:Ce,gateContent:{intent:Ze},templateMode:et,templateTtl:Bt})),E!=null&&E.asEdit?sessionStorage.setItem("agentEditReplaces",N.authorization_id):sessionStorage.removeItem("agentEditReplaces"),G("/agent/gate")}catch(ne){alert(ne instanceof Error?ne.message:"Failed to copy authorization")}finally{O(null)}},ht=async(N,E,V)=>{const ne=E&&V?`Revoke ${E}'s ${V} authorization? This cannot be undone.`:"Revoke this authorization? The agent will no longer be able to execute actions under this attestation.";if(confirm(ne)){A(N);try{await $.revokeAttestation(N),L(ce=>new Set(ce).add(N)),$.resyncGates().catch(()=>{}),E&&Z&&he()}catch(ce){alert(ce instanceof Error?ce.message:"Failed to revoke authorization")}finally{A(null)}}},Ie=f==="mine"?e:s,Ke=f==="mine"?n:i,se={active:Ie.filter(N=>At(N,{revokedSet:F})==="active").length,pending:Ie.filter(N=>At(N,{revokedSet:F})==="pending").length,expired:Ie.filter(N=>At(N,{revokedSet:F})==="expired").length,revoked:Ie.filter(N=>At(N,{revokedSet:F})==="revoked").length},Ue=(()=>{const N=new Map;for(const E of Ie){if(At(E,{revokedSet:F})!==p)continue;const V=N.get(E.profile_id)??{count:0,review:!1};V.count+=1,E.deferred_commitment_domains.length>0&&(V.review=!0),N.set(E.profile_id,V)}return Array.from(N.entries()).map(([E,V])=>({profileId:E,...V})).sort((E,V)=>ze(E.profileId).localeCompare(ze(V.profileId)))})(),P=qv(Ie.filter(N=>{if(At(N,{revokedSet:F})!==p||w!==null&&N.profile_id!==w)return!1;if(j!==null){const E=N.deferred_commitment_domains.length>0;if(j==="review"&&!E||j==="auto"&&E)return!1}return!0}),F,I),b={revokedSet:F,expandedHash:_,gateCache:z,gateLoading:Y,copiedHash:q,revokingHash:H,copyingHash:U,profileConfigCache:M,mode:$e,activeDomain:de,group:X,groupId:Z,onExpand:Le,onCopyHash:ot,onCopy:De,onRevoke:ht,onExtend:T,highlightHash:I};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:"Authorizations"}),a.jsx("p",{className:"page-subtitle",children:"Active, pending, and expired agent authorizations."})]}),a.jsx("button",{className:"btn btn-primary",onClick:()=>k(!0),children:"+ New authorization"})]}),S&&a.jsx("div",{className:"modal-backdrop",onClick:()=>{k(!1),g.get("new")&&(g.delete("new"),y(g,{replace:!0}))},children:a.jsxs("div",{className:"modal",onClick:N=>N.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:()=>{k(!1),g.get("new")&&(g.delete("new"),y(g,{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(Uv,{onDismiss:()=>k(!1)})]})]})}),le&&a.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[a.jsx("button",{className:`nav-tab${f==="mine"?" active":""}`,onClick:()=>{m("mine"),x("active"),v(null),h(null),C(null)},children:"Mine"}),a.jsx("button",{className:`nav-tab${f==="team"?" active":""}`,onClick:()=>{m("team"),x("active"),v(null),h(null),C(null)},children:"Team"})]}),a.jsx("div",{className:"nav-tabs",children:["active","pending","expired","revoked"].map(N=>a.jsxs("button",{className:`nav-tab${p===N?" active":""}`,onClick:()=>{x(N),v(null),h(null)},children:[N.charAt(0).toUpperCase()+N.slice(1)," (",se[N],")"]},N))}),Ue.length>0&&a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[Ue.map(N=>{const E=w===N.profileId;return a.jsx("button",{className:`btn btn-sm ${E?"btn-primary":"btn-secondary"}`,onClick:()=>v(E?null:N.profileId),children:ze(N.profileId)},N.profileId)}),a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(N=>{const E=j===N;return a.jsx("button",{className:`btn btn-sm ${E?"btn-primary":"btn-secondary"}`,onClick:()=>h(E?null:N),children:N==="auto"?"Auto":"Review"},N)})]}),Ke&&Ie.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):P.length===0?a.jsx(Zf,{icon:"☰",title:"No authorizations",text:`No ${p} authorizations found.`}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:P.map(N=>{const E=f==="team"?N:null,V=E!=null&&E.owner?E.owner.name??E.owner.email??E.owner.userId:void 0;return a.jsx(Zv,{item:N,newerProfile:pe(N.profile_id),ownerLabel:V,isAdmin:le,...b},N.authorization_id)})}),W&&a.jsx(Xv,{item:W,onClose:()=>T(null),onSuccess:()=>{T(null),te()}})]})}function tx(e){const t=e.indexOf("__");return t<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,t),toolName:e.slice(t+2)}}function nx(e,t){var c,d,f;const{integrationId:n,toolName:r}=tx(e.action),s=t.find(m=>m.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=ze(e.profileId),l=(f=e.executionContext)==null?void 0:f.action_type;return typeof l=="string"&&l?`${i} · ${l}`:`${i} · ${r}`}function rx(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 sx(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 ax(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`,m=Object.keys(t??{}).filter(j=>j.endsWith(f)),p=(r&&m.find(j=>j.startsWith(`${r}_`)))??(m.length===1?m[0]:void 0),w=(p?/^(amount|spend)_/.test(p):!1)?d.amount:d.count,v=p?Number(t==null?void 0:t[p]):NaN;p&&Number.isFinite(v)?s.push(`${w} of ${v} ${c}`):s.push(`${d.count} ${d.count===1?"call":"calls"} ${c}`)}return s.join(" · ")}function ox(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function ix(e){const t=ze(e),n=e.split("@")[1];return n?`${t}@${n}`:t}function Tr({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 lx({receipt:e,manifests:t,localAuth:n,localUnavailable:r,signature:s,grantTitle:o,ownerLabel:i,spUrl:l,formatDate:c,onOpenComplete:d}){var w;const f=rx(e),m=sx(n==null?void 0:n.context),p=ax(e,(n==null?void 0:n.bounds)??e.limits),x=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:nx(e,t)}),a.jsx("span",{className:"receipt-tag",children:ox(e)?"review":"automatic"}),e.contentHash&&a.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(w=e.contentBinding)!=null&&w.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(Tr,{label:"authorization",children:a.jsx("strong",{children:o||ix(e.profileId)})}),i&&a.jsx(Tr,{label:"owner",children:i}),m&&a.jsx(Tr,{label:"allowed",children:m}),p&&a.jsx(Tr,{label:"used",children:a.jsx("span",{className:"receipt-num",children:p})}),a.jsx(Tr,{label:"intent",children:x?a.jsx("span",{className:"receipt-intent",children:x}):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(([v,j])=>`${v}=${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 cx({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,m]=u.useState(!1);u.useEffect(()=>{let j=!1;return d(!0),$.getArchivedReceipt(e.id).then(h=>{j||(r(h),o(h?"local":"authority-server"),l((h==null?void 0:h.signature)??null))}).catch(()=>{j||o("authority-server")}).finally(()=>{j||d(!1)}),()=>{j=!0}},[e.id]);const p=n?n.entry:{receipt:e},x=JSON.stringify(p,null,2);function w(){const j=URL.createObjectURL(new Blob([x],{type:"application/json"})),h=document.createElement("a");h.href=j,h.download=`suveren-receipt-${e.id.slice(0,8)}.json`,h.click(),URL.revokeObjectURL(j)}async function v(){try{await navigator.clipboard.writeText(x),m(!0),setTimeout(()=>m(!1),2e3)}catch{m(!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:x})]}),a.jsxs("div",{className:"modal-footer",children:[a.jsx("button",{className:"btn btn-primary btn-sm",onClick:w,children:"Download"}),a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:v,children:f?"Copied":"Copy"})]})]})})}function ux(e){return new Date(e*1e3).toLocaleString()}function dx(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 fx(e,t){if(!t)return!0;const n=t.toLowerCase();return e.profileId.toLowerCase().includes(n)||ze(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 qc(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 px(){const{activeTeam:e,groupId:t}=Ae(),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(""),[m,p]=u.useState(!0),[x,w]=u.useState({}),[v,j]=u.useState(new Set),[h,g]=u.useState(""),[y,S]=u.useState(new Set),[k,I]=u.useState(new Set),[R,_]=u.useState("all"),[C,z]=u.useState(!1),[D,Y]=u.useState(!1),[K,W]=u.useState(null),[T,q]=u.useState({}),[ee,F]=u.useState(!1),[L,H]=u.useState({}),[A,U]=u.useState({}),[O,G]=u.useState(null),[X,Z]=u.useState(null),[de,$e]=u.useState(!1),[Be,le]=u.useState(!1),M=u.useRef(""),J=u.useCallback(b=>r==="team"&&n&&t?$.listTeamReceiptsPage(t,{before:b,limit:200}):$.getMyReceiptsPage({before:b,limit:200}),[r,n,t]),te=u.useCallback(()=>{const b=r==="team"?`team:${t}`:"mine",N=M.current!==b;M.current=b,p(!0),le(!1),J().then(E=>{i(V=>N?E.receipts:qc(V,E.receipts)),Z(V=>N?E.nextBefore:V??E.nextBefore)}).catch(()=>{N&&i([]),le(!0)}).finally(()=>p(!1))},[J,r,t]),he=u.useCallback(()=>{!X||de||($e(!0),le(!1),J(X).then(b=>{i(N=>qc(N,b.receipts)),Z(b.nextBefore)}).catch(()=>le(!0)).finally(()=>$e(!1)))},[X,de,J]);Lt(te,12e4),u.useEffect(()=>{$.getIntegrationManifests().then(({manifests:b})=>c(b)).catch(()=>{}),fetch("/health").then(b=>b.json()).then(b=>{typeof b.spUrl=="string"&&f(b.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),u.useEffect(()=>{$.getLocalAuthorizations().then(({authorizations:b,signatures:N})=>{q(b),H(N),F(!1)}).catch(()=>{q({}),H({}),F(!0)}),$.getMyAttestations().then(b=>{const N={};for(const E of b)E.authorization_id&&E.title&&(N[E.authorization_id]=E.title);U(N)}).catch(()=>{})},[]),u.useEffect(()=>{r!=="team"||Object.keys(x).length>0||$.listUsers().then(b=>{const N={};for(const E of b)N[E.id]={name:E.name,email:E.email};w(N)}).catch(()=>{})},[r,x]);const pe=u.useMemo(()=>{const b=new Set;for(const N of o)b.add(ze(N.profileId));return[...b].sort()},[o]),Le=u.useMemo(()=>{const b=new Set;for(const N of o)b.add(N.action);return[...b].sort()},[o]),ot=u.useMemo(()=>{if(r!=="team")return[];const b=new Set;for(const N of o)N.userId&&b.add(N.userId);return[...b].map(N=>{var E;return{id:N,label:(E=x[N])!=null&&E.name?`${x[N].name} (${x[N].email})`:N}}).sort((N,E)=>N.label.localeCompare(E.label))},[r,o,x]),De=u.useMemo(()=>o.filter(b=>!(!fx(b,h)||y.size>0&&!y.has(ze(b.profileId))||k.size>0&&!k.has(b.action)||v.size>0&&b.userId&&!v.has(b.userId)||!dx(b,R))),[o,h,y,k,v,R]),ht=y.size>0||k.size>0||v.size>0||R!=="all";function Ie(b){S(N=>{const E=new Set(N);return E.has(b)?E.delete(b):E.add(b),E})}function Ke(b){I(N=>{const E=new Set(N);return E.has(b)?E.delete(b):E.add(b),E})}function se(b){j(N=>{const E=new Set(N);return E.has(b)?E.delete(b):E.add(b),E})}function Ue(){S(new Set),I(new Set),j(new Set),_("all"),g("")}async function P(){Y(!0),W(null);try{const{bundle:b,filename:N}=await $.fetchEvidenceBundle(),E=URL.createObjectURL(new Blob([JSON.stringify(b,null,2)],{type:"application/json"})),V=document.createElement("a");V.href=E,V.download=N,V.click(),URL.revokeObjectURL(E);const ne=b.sources??{};ne.authorityServer?ne.local||W(`Downloaded Authority Server history only — ${ne.localError??"local archive unavailable."}`):W(`Downloaded local evidence only — ${ne.asError??"Authority Server export unavailable."}`)}catch(b){W(`Export failed: ${b instanceof Error?b.message:String(b)}`)}finally{Y(!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:"Receipts"}),a.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),a.jsx("button",{className:"btn btn-secondary",onClick:P,disabled:D,children:D?"Preparing…":"Download evidence"})]}),K&&a.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:K}),n&&a.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(b=>a.jsx("button",{onClick:()=>s(b),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:r===b?"2px solid var(--accent)":"2px solid transparent",color:r===b?"var(--text-primary)":"var(--text-tertiary)",fontWeight:r===b?600:500},children:b==="mine"?"Mine":"Team"},b))}),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:h,onChange:b=>g(b.target.value)}),h&&a.jsx("button",{className:"search-clear",onClick:()=>g(""),children:"×"})]}),a.jsxs("button",{className:`btn btn-sm btn-secondary${C?" active":""}`,onClick:()=>z(!C),children:["Filters",ht?` (${y.size+k.size+(R!=="all"?1:0)})`:""]})]}),C&&a.jsxs("div",{className:"filter-panel",children:[pe.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Profile"}),a.jsx("div",{className:"filter-chips",children:pe.map(b=>a.jsx("button",{className:`filter-chip${y.has(b)?" selected":""}`,onClick:()=>Ie(b),children:b},b))})]}),Le.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Action"}),a.jsx("div",{className:"filter-chips",children:Le.map(b=>a.jsx("button",{className:`filter-chip${k.has(b)?" selected":""}`,onClick:()=>Ke(b),children:b},b))})]}),r==="team"&&ot.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Owner"}),a.jsx("div",{className:"filter-chips",children:ot.map(b=>a.jsx("button",{className:`filter-chip${v.has(b.id)?" selected":""}`,onClick:()=>se(b.id),children:b.label},b.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(([b,N])=>a.jsx("button",{className:`filter-chip${R===b?" selected":""}`,onClick:()=>_(b),children:N},b))})]})]}),ht&&a.jsxs("div",{className:"active-filters",children:[[...y].map(b=>a.jsxs("span",{className:"active-chip",onClick:()=>Ie(b),children:[b," ",a.jsx("span",{className:"chip-remove",children:"×"})]},b)),[...k].map(b=>a.jsxs("span",{className:"active-chip",onClick:()=>Ke(b),children:[b," ",a.jsx("span",{className:"chip-remove",children:"×"})]},b)),[...v].map(b=>{const N=x[b],E=N?N.name:b;return a.jsxs("span",{className:"active-chip",onClick:()=>se(b),children:[E," ",a.jsx("span",{className:"chip-remove",children:"×"})]},b)}),R!=="all"&&a.jsxs("span",{className:"active-chip",onClick:()=>_("all"),children:[R==="1d"?"Today":R==="7d"?"7 days":"30 days"," ",a.jsx("span",{className:"chip-remove",children:"×"})]}),a.jsx("button",{className:"clear-filters",onClick:Ue,children:"Clear all"})]}),Be&&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."})}),m&&o.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):De.length===0?a.jsx(Zf,{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:De.length===o.length?`${o.length} receipt${o.length!==1?"s":""}`:`${De.length} of ${o.length} receipts`}),a.jsx("div",{className:"timeline",children:De.map(b=>{const N=b.userId?x[b.userId]:void 0;return a.jsx("div",{className:"timeline-event",children:a.jsx(lx,{receipt:b,manifests:l,localAuth:b.authorizationId?T[b.authorizationId]:void 0,localUnavailable:ee,signature:L[b.id],grantTitle:b.authorizationId?A[b.authorizationId]:null,ownerLabel:r==="team"&&b.userId?N?`${N.name} (${N.email})`:b.userId:null,spUrl:d,formatDate:ux,onOpenComplete:()=>G(b)})},b.id)})})]}),O&&a.jsx(cx,{receipt:O,onClose:()=>G(null)}),X&&a.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:he,disabled:de,children:de?"Loading…":"Load older"})})]})}const mx={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function hx(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[s,o]=u.useState(null),i=u.useCallback(async()=>{try{t(await $.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 $.setAutostart(!e.installed)}catch(d){o(d instanceof Error?d.message:"Failed")}finally{try{t(await $.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=mx[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 gx(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[s,o]=u.useState(null),i=u.useCallback(async()=>{try{const c=await $.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 $.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 yx={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 vx(){const{version:e,latestVersion:t,updateAvailable:n,installMethod:r}=Cl();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:[yx[r]??"Update checking is unavailable",r==="dev"&&a.jsx(a.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}const xx={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 wx(){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,m]=u.useState(""),[p,x]=u.useState(!1),[w,v]=u.useState(!1),[j,h]=u.useState(!1),[g,y]=u.useState(null),[S,k]=u.useState([]),[I,R]=u.useState(!1),[_,C]=u.useState(null),[z,D]=u.useState(""),Y=u.useCallback(L=>{t(L),setTimeout(()=>t(""),3e3)},[]),K=u.useCallback(async(L,H,A)=>{R(!0),C(null);try{const U=await $.aiModels({provider:L,endpoint:H,...A?{apiKey:A}:{}});U.ok&&U.models.length>0?(k(U.models),C(`${U.models.length} models available`)):(k([]),C(U.message||"No models returned — using defaults"))}catch(U){k([]),C(U instanceof Error?U.message:"Failed to load models")}finally{R(!1)}},[]),W=u.useCallback(async()=>{try{const L=await $.getCredential("ai-config");if(x(L.configured),L.configured&&L.fields){const H=L.fields.provider||"openai-compatible",A=L.fields.endpoint||"";L.fields.provider&&o(H),L.fields.endpoint&&l(A),L.fields.model&&d(L.fields.model),A.includes("openai.com")?r("openai"):A.includes("groq.com")?r("groq"):A.includes("together.xyz")?r("together"):A.includes("openrouter.ai")?r("openrouter"):r("ollama"),A&&K(H,A)}}catch{}},[K]);u.useEffect(()=>{W()},[W]);const T=L=>{r(L),k([]),C(null),D("");const H=xx[L];H&&(o(H.provider),l(H.endpoint),d(""),K(H.provider,H.endpoint,f||void 0))},q=()=>K(s,i,f||void 0),ee=async()=>{v(!0);try{await $.setCredential("ai-config",{provider:s,endpoint:i,model:c,...f?{apiKey:f}:{}}),x(!0),Y("AI configuration saved!")}catch{Y("Failed to save AI config")}finally{v(!1)}},F=async()=>{h(!0),y(null);try{const L=await $.aiTest({provider:s,endpoint:i,model:c,...f?{apiKey:f}:{}});y(L.ok?`OK: ${L.message}`:`Failed: ${L.message}`)}catch(L){y(`Error: ${L instanceof Error?L.message:"Unknown"}`)}finally{h(!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:L=>T(L.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:L=>m(L.target.value),onBlur:()=>{f.trim()&&K(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:q,disabled:I,title:"Re-fetch the model list from the provider",children:I?"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:I?"Loading models…":s==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const L=S,H=L.includes(c),A=L.length>12,U=z.trim().toLowerCase();let O=U?L.filter(G=>G.toLowerCase().includes(U)):L;return H&&!O.includes(c)&&(O=[c,...O]),a.jsxs(a.Fragment,{children:[A&&a.jsx("input",{className:"form-input",value:z,onChange:G=>D(G.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),a.jsxs("select",{className:"form-input",value:H?c:"__unset__",onChange:G=>d(G.target.value==="__unset__"?"":G.target.value),children:[a.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),O.map(G=>a.jsx("option",{value:G,children:G},G)),U&&O.length===0&&a.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",z,"”"]})]})]})})(),_&&a.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:_})]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.jsx("button",{className:"btn btn-primary",onClick:ee,disabled:w||!c.trim(),title:c.trim()?void 0:"Select a model first",children:w?"Saving...":"Save & Encrypt"}),p&&a.jsx("button",{className:"btn btn-ghost",onClick:F,disabled:j,children:j?"Testing...":"Test Connection"})]}),g&&a.jsx("div",{className:`alert ${g.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:g})]}),a.jsx(Sx,{}),a.jsx(hx,{}),a.jsx(gx,{}),a.jsx(vx,{}),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 Sx(){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,m]=u.useState(!1),p=u.useCallback(async()=>{if(!f)try{const v=await $.getAIPrompts();t(v),r({intent:v.intent.current,context:v.context.current}),m(!0)}catch(v){l(v instanceof Error?v.message:"Failed to load prompts")}},[f]),x=async v=>{if(e){o(v),l(null);try{const j=n[v],h=j.trim()===e[v].default.trim()?"":j;await $.setAIPrompt(v,h);const g=await $.getAIPrompts();t(g),r({intent:g.intent.current,context:g.context.current}),d(v),setTimeout(()=>d(null),2e3)}catch(j){l(j instanceof Error?j.message:"Save failed")}finally{o(null)}}},w=async v=>{if(confirm(`Revert ${v} prompt to the built-in default?`)){o(v),l(null);try{await $.setAIPrompt(v,"");const j=await $.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:v=>{v.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(Zc,{kind:"intent",label:"Intent — per-authorization",description:"Used on the Intent gate when creating a new authorization.",state:e.intent,draft:n.intent,onChange:v=>r(j=>({...j,intent:v})),onSave:()=>x("intent"),onRevert:()=>w("intent"),saving:s==="intent",justSaved:c==="intent"}),a.jsx(Zc,{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:v=>r(j=>({...j,context:v})),onSave:()=>x("context"),onRevert:()=>w("context"),saving:s==="context",justSaved:c==="context"})]})]})}function Zc({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:m=>o(m.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 jx(e){return e.proposalId?"review":"automatic"}function eu(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=jx(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 kx=["https://","http://"];function ep(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)?[]:kx.some(s=>r.toLowerCase().startsWith(s))?[{label:n.label,href:r,description:n.description}]:[]}):[]}function bx({profileId:e}){return a.jsx("span",{className:"profile-badge",children:ze(e)})}function tp(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 Cx={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},Nx={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"};function Ex(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 Tx(e){return e.split("__").pop()??e}function zx(e){const t=e.toLowerCase();return t.includes("delete")||t.includes("refund")||t.includes("cancel")||t.includes("revoke")}const Ix=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]),Rx=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function Px(e,t){return typeof t!="string"?!1:/^data:image\//i.test(t)?!0:Rx.test(e)?/^https?:\/\//.test(t):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(t)}function ji(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=>ji(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function tu({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=Tx(l),d=zx(l),f=o?e.proposal.toolArgs:null,m=o?e.proposal.executionContext:e.receipt.executionContext,p=o?null:e.receipt.cumulativeState,x=o?ep(s,e.proposal.toolArgs):[],w=f?Object.entries(f).filter(([j])=>!Ix.has(j)):[],v=Object.entries(m??{});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(bx,{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=tp(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 ${Nx[i]}`,children:Cx[i]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Ex(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)"}})]}),x.length>0&&a.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:x.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&&w.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:w.map(([j,h])=>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:Px(j,h)?a.jsx("img",{src:h,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:g=>{const y=g.currentTarget,S=y.parentElement;if(!S)return;y.style.display="none";const k=document.createElement("span");k.textContent=h,k.style.color="var(--text-tertiary)",S.appendChild(k)}}):ji(h)})]},j))})]}),v.length>0&&a.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:v.map(([j,h])=>`${j}=${ji(h)}`).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 _x=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function ki(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=>ki(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ax(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 $x({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),[m,p]=u.useState(!1),[x,w]=u.useState(null),[v,j]=u.useState(!1),h=e.tool.split("__").pop()??e.tool,g=Object.entries(e.toolArgs).filter(([T])=>!_x.has(T)),y=Object.entries(e.executionContext),S=ep(s,e.toolArgs),k=e.pendingApprovers??[],I=e.approvedBy??{},R=Object.keys(I).length,_=k.filter(T=>!(T in I)).length,C=t in I,z=async()=>{if(d===null){p(!0),w(null);try{const T=await $.getAttestationIntent(e.authorizationId);if(!T){w("Intent not available or you are not an authorized approver.");return}const q=await $.decryptIntent({intentCiphertext:T.intentCiphertext,encryptedKey:T.encryptedKey,approverId:t});f(q)}catch(T){w(T instanceof Error?T.message:"Failed to decrypt intent")}finally{p(!1)}}},D=async()=>{v?j(!1):(j(!0),await z())},Y=async()=>{i(!0),r("");try{await $.approveProposal(e.id);try{if(d===null){const T=await $.getAttestationIntent(e.authorizationId);if(T){const q=await $.decryptIntent({intentCiphertext:T.intentCiphertext,encryptedKey:T.encryptedKey,approverId:t});f(q),await $.storeApprovedIntent(e.authorizationId,q)}}else await $.storeApprovedIntent(e.authorizationId,d)}catch{}r(`Approved. ${_-1>0?`${_-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),n()}catch(T){r(T instanceof Error?T.message:"Approval failed")}finally{i(!1)}},K=async()=>{const T=prompt("Rejection reason (optional):");if(T!==null){c(!0),r("");try{await $.rejectProposal(e.id,T||void 0),r("Action rejected."),n()}catch(q){r(q instanceof Error?q.message:"Rejection failed")}finally{c(!1)}}},W=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:ze(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 T=tp(e.expiresAt,Date.now());return a.jsx("span",{style:{fontSize:"0.72rem",color:T.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:T.urgent?600:400,whiteSpace:"nowrap"},children:T.label})})(),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Ax(e.createdAt)})]})]}),a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[R," of ",k.length," approver",k.length===1?"":"s"," signed off",k.map(T=>{const q=T in I;return a.jsxs("span",{style:{marginLeft:"0.5rem",color:q?"var(--success, green)":"var(--text-tertiary)"},children:[q?"✓":"○"," ",T===t?"You":T]},T)})]}),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:h})]}),S.length>0&&a.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:S.map(T=>a.jsxs("a",{href:T.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:T.description??T.href,children:[T.label," ↗"]},T.label))}),g.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:g.map(([T,q])=>a.jsxs(u.Fragment,{children:[a.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:T}),a.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:ki(q)})]},T))})]}),y.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:y.map(([T,q])=>`${T}=${ki(q)}`).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:m,children:[v?"▲ Hide intent":"▼ Show intent",m&&" (decrypting...)"]}),v&&a.jsx("div",{style:{marginTop:"0.5rem",padding:"0.75rem",background:"var(--bg-main)",borderRadius:"0.375rem",border:"1px solid var(--border)"},children:x?a.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:x}):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."})})]}),!C&&a.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[a.jsx("button",{className:"btn btn-primary",onClick:Y,disabled:W,children:o?"Approving...":"Approve"}),a.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:K,disabled:W,children:l?"Rejecting...":"Reject"})]}),C&&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 Lx(){const{domain:e,user:t}=Ae(),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),[m,p]=u.useState(""),x=u.useCallback(async()=>{try{const M=await $.getProposalsForApprover();i(M)}catch{}finally{f(!1)}},[]);ue("proposal-added",x),ue("proposal-approved",x),ue("proposal-rejected",x),ue("proposal-resolved",x),Lt(x,3e4);const[w,v]=u.useState([]),j=u.useCallback(async()=>{try{const M=await $.getProposals(e||"owner");v(M)}catch{}},[e]);ue("proposal-added",j),ue("proposal-approved",j),ue("proposal-rejected",j),ue("proposal-resolved",j),Lt(j,3e4,e);const h=u.useMemo(()=>w.filter(M=>{var J;return M.status==="pending"&&(((J=M.pendingApprovers)==null?void 0:J.length)??0)===0}),[w]),g=u.useMemo(()=>eu(h,[],{status:"pending"}),[h]),[y,S]=u.useState([]),k=u.useCallback(async()=>{if(n)try{const J=(await $.getProposals(e||"owner")).filter(te=>te.status==="pending"&&te.pendingApprovers&&te.pendingApprovers.includes(n)&&te.approvedBy&&n in te.approvedBy);S(J)}catch{}},[n,e]);ue("proposal-approved",k),ue("proposal-rejected",k),Lt(k,3e4,`${n}:${e}`),u.useEffect(()=>{$.getIntegrationManifests().then(M=>c(M.manifests??[])).catch(()=>{})},[]);const I=M=>{var J;return(J=l.find(te=>te.id===M.split("__")[0]))==null?void 0:J.proposalLinks};u.useEffect(()=>{x(),j(),k()},[]);const[R,_]=u.useState([]),[C,z]=u.useState([]),[D,Y]=u.useState(!0),[K,W]=u.useState(null),[T,q]=u.useState(""),[ee,F]=u.useState("pending"),[L,H]=u.useState(null),[A,U]=u.useState(!1),O=u.useCallback(async()=>{try{const{proposals:M,receipts:J}=await $.getThread({domain:e,status:ee,sinceDays:7});_(M),z(J)}catch{}finally{Y(!1)}},[e,ee]);Lt(O,3e4,`${e}:${ee}`);const G=async(M,J)=>{W(M),q("");try{const te=e||"owner",he=await $.resolveProposal(M,J,te);q(J==="commit"?`Action approved. Status: ${he.status}`:"Action rejected."),await Promise.all([O(),j()])}catch(te){q(te instanceof Error?te.message:"Failed")}finally{W(null)}},X=u.useMemo(()=>{const M=new Set;for(const J of R)M.add(J.profileId);for(const J of C)M.add(J.profileId);return Array.from(M).sort()},[R,C]),Z=u.useMemo(()=>eu(R,C,{status:ee,profile:L??void 0,includeAutonomous:A}),[R,C,ee,L,A]),de=u.useCallback(()=>{x(),k()},[x,k]),$e=u.useMemo(()=>{const M=new Set,J=[];for(const te of y)M.has(te.id)||(M.add(te.id),J.push(te));return J.sort((te,he)=>he.createdAt-te.createdAt)},[y]),Be=o.length+g.length,le=$e.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 ",Be>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:Be})]}),a.jsxs("button",{className:`nav-tab${r==="awaiting-others"?" active":""}`,onClick:()=>s("awaiting-others"),children:["Awaiting others ",le>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:le})]}),a.jsx("button",{className:`nav-tab${r==="all"?" active":""}`,onClick:()=>{s("all"),O()},children:"All"})]}),r==="awaiting-me"&&a.jsx(a.Fragment,{children:d&&Be===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Be===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:[(m||T)&&a.jsx("div",{className:"alert alert-success",children:m||T}),g.map(M=>a.jsx(tu,{proposalLinks:M.kind==="proposal"?I(M.proposal.tool):void 0,item:M,onApprove:J=>G(J,"commit"),onReject:J=>G(J,"reject"),resolving:K===M.id},M.id)),o.map(M=>a.jsx($x,{proposal:M,currentUserId:n,onAction:de,onMessage:p,proposalLinks:I(M.tool)},M.id))]})}),r==="awaiting-others"&&a.jsx(a.Fragment,{children:$e.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:$e.map(M=>a.jsx(Fx,{proposal:M,currentUserId:n,onCancel:async()=>{try{await $.rejectProposal(M.id,"cancelled by creator"),k(),j()}catch(J){alert(J instanceof Error?J.message:"Cancel failed")}}},M.id))})}),r==="all"&&a.jsxs(a.Fragment,{children:[T&&a.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:T}),a.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[a.jsx("button",{className:`filter-chip ${ee==="pending"?"selected":""}`,onClick:()=>F("pending"),children:"Pending"}),a.jsx("button",{className:`filter-chip ${ee==="all"?"selected":""}`,onClick:()=>F("all"),children:"All"}),X.length>0&&a.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),X.map(M=>a.jsx("button",{className:`filter-chip ${L===M?"selected":""}`,onClick:()=>H(L===M?null:M),children:ze(M)},M)),ee==="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 ${A?"selected":""}`,onClick:()=>U(!A),title:"Include actions executed without human review (automatic commitment mode)",children:[A?"✓ ":"","Autonomous actions"]})]})]}),D&&Z.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Z.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:ee==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:ee==="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:Z.map(M=>a.jsx(tu,{proposalLinks:M.kind==="proposal"?I(M.proposal.tool):void 0,item:M,onApprove:J=>G(J,"commit"),onReject:J=>G(J,"reject"),resolving:K===M.id},M.id))})]})]})}function Mx(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 Fx({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:ze(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:Mx(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 Ox=`# Agent Brief
75
75
 
76
76
  You act on my behalf through Suveren — the gateway that gates every
77
77
  privileged tool call you make. Suveren implements the bounded-authority
@@ -107,4 +107,4 @@ executes. When you propose an action:
107
107
  next.
108
108
  - Never email anyone outside the company without asking first.
109
109
  - When drafting posts, prefer plain language over marketing copy.
110
- `;function Mx(){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,m]=u.useState(!1),p=e!==n,x=new Blob([e]).size,w=16*1024;u.useEffect(()=>{if(!p)return;const g=S=>{S.preventDefault(),S.returnValue=""},y=S=>{var R,_;if(S.defaultPrevented||S.button!==0||S.metaKey||S.ctrlKey||S.shiftKey||S.altKey)return;const k=(_=(R=S.target)==null?void 0:R.closest)==null?void 0:_.call(R,"a");if(!k||!k.href)return;let I;try{I=new URL(k.href)}catch{return}I.origin===window.location.origin&&I.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(S.preventDefault(),S.stopPropagation()))};return window.addEventListener("beforeunload",g),document.addEventListener("click",y,!0),()=>{window.removeEventListener("beforeunload",g),document.removeEventListener("click",y,!0)}},[p]),u.useEffect(()=>{let g=!1;return $.getAgentContext().then(y=>{g||(t(y),r(y))}).catch(y=>{g||d({kind:"error",text:y instanceof Error?y.message:"Failed to load context"})}).finally(()=>{g||o(!1)}),()=>{g=!0}},[]);const v=async()=>{l(!0),d(null);try{await $.saveAgentContext(e),r(e),d({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(g){d({kind:"error",text:g instanceof Error?g.message:"Save failed"})}finally{l(!1)}},j=()=>{t(n),d(null)},h=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||t(Lx)};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:h,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(ja,{target:{kind:"context"},currentText:e,onApply:g=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||t(g)},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:x>w?"var(--danger)":"var(--text-muted)"},children:[x.toLocaleString()," / ",w.toLocaleString()," bytes"]})]}),a.jsx("textarea",{className:"form-textarea",value:e,onChange:g=>t(g.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:v,disabled:i||!p||x>w||s,children:i?"Saving…":"Save"})]})]}),a.jsx("button",{type:"button",className:"floating-help",onClick:()=>m(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),a.jsx(Yf,{open:f,onClose:()=>m(!1),ariaLabel:"Brief assistant",children:a.jsx(ja,{target:{kind:"context"},currentText:e,onApply:g=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(t(g),m(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function Fx({children:e}){const{user:t,mode:n,domain:r}=Ae();return t?n==="team"&&!r?a.jsx(nn,{to:"/onboarding",replace:!0}):a.jsx(a.Fragment,{children:e}):a.jsx(nn,{to:"/login",replace:!0})}function Ox(){const{user:e}=Ae();return a.jsxs(Eg,{children:[a.jsx(Re,{path:"/login",element:e?a.jsx(nn,{to:"/",replace:!0}):a.jsx(Wy,{})}),a.jsx(Re,{path:"/onboarding",element:e?a.jsx(Hy,{}):a.jsx(nn,{to:"/login",replace:!0})}),a.jsxs(Re,{element:a.jsx(Fx,{children:a.jsx(Uy,{})}),children:[a.jsx(Re,{path:"/",element:a.jsx(nv,{})}),a.jsx(Re,{path:"/agent/new",element:a.jsx(nn,{to:"/authorizations?new=1",replace:!0})}),a.jsx(Re,{path:"/agent/gate",element:a.jsx(Ev,{})}),a.jsx(Re,{path:"/agent/review",element:a.jsx(Pv,{})}),a.jsx(Re,{path:"/integrations",element:a.jsx(Mv,{})}),a.jsx(Re,{path:"/groups",element:a.jsx(Fv,{})}),a.jsx(Re,{path:"/authorizations",element:a.jsx(Xv,{})}),a.jsx(Re,{path:"/audit",element:a.jsx(ux,{})}),a.jsx(Re,{path:"/proposals",element:a.jsx(_x,{})}),a.jsx(Re,{path:"/agent-brief",element:a.jsx(Mx,{})}),a.jsx(Re,{path:"/settings",element:a.jsx(yx,{})}),a.jsx(Re,{path:"/settings/services",element:a.jsx(nn,{to:"/settings",replace:!0})}),a.jsx(Re,{path:"/deploy",element:a.jsx(nn,{to:"/integrations",replace:!0})})]}),a.jsx(Re,{path:"*",element:a.jsx(nn,{to:"/",replace:!0})})]})}function Bx(){return a.jsx(qg,{children:a.jsx(ly,{children:a.jsx(cy,{children:a.jsx(Ox,{})})})})}yf(document.getElementById("root")).render(a.jsx(u.StrictMode,{children:a.jsx(Bx,{})}));
110
+ `;function Bx(){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,m]=u.useState(!1),p=e!==n,x=new Blob([e]).size,w=16*1024;u.useEffect(()=>{if(!p)return;const g=S=>{S.preventDefault(),S.returnValue=""},y=S=>{var R,_;if(S.defaultPrevented||S.button!==0||S.metaKey||S.ctrlKey||S.shiftKey||S.altKey)return;const k=(_=(R=S.target)==null?void 0:R.closest)==null?void 0:_.call(R,"a");if(!k||!k.href)return;let I;try{I=new URL(k.href)}catch{return}I.origin===window.location.origin&&I.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(S.preventDefault(),S.stopPropagation()))};return window.addEventListener("beforeunload",g),document.addEventListener("click",y,!0),()=>{window.removeEventListener("beforeunload",g),document.removeEventListener("click",y,!0)}},[p]),u.useEffect(()=>{let g=!1;return $.getAgentContext().then(y=>{g||(t(y),r(y))}).catch(y=>{g||d({kind:"error",text:y instanceof Error?y.message:"Failed to load context"})}).finally(()=>{g||o(!1)}),()=>{g=!0}},[]);const v=async()=>{l(!0),d(null);try{await $.saveAgentContext(e),r(e),d({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(g){d({kind:"error",text:g instanceof Error?g.message:"Save failed"})}finally{l(!1)}},j=()=>{t(n),d(null)},h=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||t(Ox)};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:h,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(ka,{target:{kind:"context"},currentText:e,onApply:g=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||t(g)},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:x>w?"var(--danger)":"var(--text-muted)"},children:[x.toLocaleString()," / ",w.toLocaleString()," bytes"]})]}),a.jsx("textarea",{className:"form-textarea",value:e,onChange:g=>t(g.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:v,disabled:i||!p||x>w||s,children:i?"Saving…":"Save"})]})]}),a.jsx("button",{type:"button",className:"floating-help",onClick:()=>m(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),a.jsx(Kf,{open:f,onClose:()=>m(!1),ariaLabel:"Brief assistant",children:a.jsx(ka,{target:{kind:"context"},currentText:e,onApply:g=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(t(g),m(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function Dx({children:e}){const{user:t,mode:n,domain:r}=Ae();return t?n==="team"&&!r?a.jsx(nn,{to:"/onboarding",replace:!0}):a.jsx(a.Fragment,{children:e}):a.jsx(nn,{to:"/login",replace:!0})}function Ux(){const{user:e}=Ae();return a.jsxs(Tg,{children:[a.jsx(Re,{path:"/login",element:e?a.jsx(nn,{to:"/",replace:!0}):a.jsx(Hy,{})}),a.jsx(Re,{path:"/onboarding",element:e?a.jsx(Vy,{}):a.jsx(nn,{to:"/login",replace:!0})}),a.jsxs(Re,{element:a.jsx(Dx,{children:a.jsx(Wy,{})}),children:[a.jsx(Re,{path:"/",element:a.jsx(rv,{})}),a.jsx(Re,{path:"/agent/new",element:a.jsx(nn,{to:"/authorizations?new=1",replace:!0})}),a.jsx(Re,{path:"/agent/gate",element:a.jsx(Tv,{})}),a.jsx(Re,{path:"/agent/review",element:a.jsx($v,{})}),a.jsx(Re,{path:"/integrations",element:a.jsx(Bv,{})}),a.jsx(Re,{path:"/groups",element:a.jsx(Dv,{})}),a.jsx(Re,{path:"/authorizations",element:a.jsx(ex,{})}),a.jsx(Re,{path:"/audit",element:a.jsx(px,{})}),a.jsx(Re,{path:"/proposals",element:a.jsx(Lx,{})}),a.jsx(Re,{path:"/agent-brief",element:a.jsx(Bx,{})}),a.jsx(Re,{path:"/settings",element:a.jsx(wx,{})}),a.jsx(Re,{path:"/settings/services",element:a.jsx(nn,{to:"/settings",replace:!0})}),a.jsx(Re,{path:"/deploy",element:a.jsx(nn,{to:"/integrations",replace:!0})})]}),a.jsx(Re,{path:"*",element:a.jsx(nn,{to:"/",replace:!0})})]})}function Wx(){return a.jsx(Zg,{children:a.jsx(cy,{children:a.jsx(uy,{children:a.jsx(Ux,{})})})})}gf(document.getElementById("root")).render(a.jsx(u.StrictMode,{children:a.jsx(Wx,{})}));