@lamalibre/create-lamaste 4.5.0 → 4.7.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 (178) hide show
  1. package/package.json +2 -2
  2. package/scripts/bundle-vendor.js +20 -3
  3. package/scripts/lamaste-priv +56 -5
  4. package/scripts/pin-release.js +98 -0
  5. package/src/index.js +8 -1
  6. package/src/lib/env.js +19 -0
  7. package/src/lib/service-config.js +7 -0
  8. package/src/tasks/redeploy.js +8 -0
  9. package/vendor/docs/00-introduction/how-it-works.md +2 -2
  10. package/vendor/docs/00-introduction/quickstart.md +5 -5
  11. package/vendor/docs/00-introduction/what-is-lamaste.md +5 -5
  12. package/vendor/docs/01-concepts/authentication.md +6 -2
  13. package/vendor/docs/01-concepts/authorization.md +4 -0
  14. package/vendor/docs/01-concepts/certificates.md +3 -3
  15. package/vendor/docs/01-concepts/dns-and-domains.md +9 -0
  16. package/vendor/docs/01-concepts/mtls.md +2 -2
  17. package/vendor/docs/01-concepts/security-model.md +28 -3
  18. package/vendor/docs/01-concepts/tickets.md +2 -2
  19. package/vendor/docs/01-concepts/tunneling.md +4 -4
  20. package/vendor/docs/02-guides/agent-setup.md +5 -5
  21. package/vendor/docs/02-guides/certificate-management.md +2 -2
  22. package/vendor/docs/02-guides/cloud-provisioning.md +3 -3
  23. package/vendor/docs/02-guides/desktop-app-setup.md +10 -10
  24. package/vendor/docs/02-guides/installation.md +3 -3
  25. package/vendor/docs/02-guides/managing-users.md +5 -11
  26. package/vendor/docs/02-guides/onboarding.md +2 -2
  27. package/vendor/docs/02-guides/second-domain.md +82 -0
  28. package/vendor/docs/02-guides/standalone-plugin-with-tickets.md +2 -2
  29. package/vendor/docs/02-guides/static-sites.md +4 -0
  30. package/vendor/docs/03-architecture/installer-flow.md +2 -2
  31. package/vendor/docs/03-architecture/installer.md +4 -4
  32. package/vendor/docs/03-architecture/management-flow.md +1 -1
  33. package/vendor/docs/03-architecture/nginx-configuration.md +80 -12
  34. package/vendor/docs/03-architecture/overview.md +5 -5
  35. package/vendor/docs/03-architecture/panel-client.md +6 -6
  36. package/vendor/docs/03-architecture/panel-server.md +2 -2
  37. package/vendor/docs/03-architecture/state-management.md +3 -3
  38. package/vendor/docs/03-architecture/system-overview.md +1 -1
  39. package/vendor/docs/04-api-reference/agent-hosted-plugins.md +116 -37
  40. package/vendor/docs/04-api-reference/app-host.md +3 -3
  41. package/vendor/docs/04-api-reference/domains.md +192 -0
  42. package/vendor/docs/04-api-reference/gatekeeper.md +54 -8
  43. package/vendor/docs/04-api-reference/lifecycle-hooks.md +4 -4
  44. package/vendor/docs/04-api-reference/onboarding.md +1 -1
  45. package/vendor/docs/04-api-reference/overview.md +9 -0
  46. package/vendor/docs/04-api-reference/registry-and-oidc.md +26 -13
  47. package/vendor/docs/04-api-reference/sites.md +9 -0
  48. package/vendor/docs/04-api-reference/tunnels.md +35 -28
  49. package/vendor/docs/04-api-reference/users.md +41 -29
  50. package/vendor/docs/05-operations/backup-and-restore.md +1 -1
  51. package/vendor/docs/05-operations/uninstalling.md +1 -1
  52. package/vendor/docs/05-operations/upgrades.md +15 -6
  53. package/vendor/docs/06-reference/config-files.md +19 -15
  54. package/vendor/docs/06-reference/glossary.md +3 -3
  55. package/vendor/docs/06-reference/installer-flags.md +13 -13
  56. package/vendor/docs/06-reference/ports-and-services.md +1 -1
  57. package/vendor/docs/06-reference/troubleshooting.md +8 -8
  58. package/vendor/docs/_index.json +105 -19
  59. package/vendor/docs/external-members-design.md +816 -0
  60. package/vendor/docs/gatekeeper-design.md +8 -8
  61. package/vendor/docs/identity-directory-design.md +3 -3
  62. package/vendor/docs/multi-domain-relay-design.md +836 -0
  63. package/vendor/docs/package.json +1 -1
  64. package/vendor/docs/todo/lib-cli-desktop-refactor.md +27 -27
  65. package/vendor/gatekeeper/dist/index.d.ts +3 -3
  66. package/vendor/gatekeeper/dist/index.d.ts.map +1 -1
  67. package/vendor/gatekeeper/dist/index.js +2 -2
  68. package/vendor/gatekeeper/dist/index.js.map +1 -1
  69. package/vendor/gatekeeper/dist/lib/authz.d.ts +9 -0
  70. package/vendor/gatekeeper/dist/lib/authz.d.ts.map +1 -1
  71. package/vendor/gatekeeper/dist/lib/authz.js +31 -0
  72. package/vendor/gatekeeper/dist/lib/authz.js.map +1 -1
  73. package/vendor/gatekeeper/dist/lib/constants.d.ts +5 -2
  74. package/vendor/gatekeeper/dist/lib/constants.d.ts.map +1 -1
  75. package/vendor/gatekeeper/dist/lib/constants.js +5 -2
  76. package/vendor/gatekeeper/dist/lib/constants.js.map +1 -1
  77. package/vendor/gatekeeper/dist/lib/grants.d.ts.map +1 -1
  78. package/vendor/gatekeeper/dist/lib/grants.js +20 -13
  79. package/vendor/gatekeeper/dist/lib/grants.js.map +1 -1
  80. package/vendor/gatekeeper/dist/lib/migrations/gatekeeper/0004_unconsume_access_grants.sql +8 -0
  81. package/vendor/gatekeeper/dist/lib/secret.d.ts +6 -0
  82. package/vendor/gatekeeper/dist/lib/secret.d.ts.map +1 -0
  83. package/vendor/gatekeeper/dist/lib/secret.js +12 -0
  84. package/vendor/gatekeeper/dist/lib/secret.js.map +1 -0
  85. package/vendor/gatekeeper/dist/lib/templates.d.ts +20 -0
  86. package/vendor/gatekeeper/dist/lib/templates.d.ts.map +1 -1
  87. package/vendor/gatekeeper/dist/lib/templates.js +80 -14
  88. package/vendor/gatekeeper/dist/lib/templates.js.map +1 -1
  89. package/vendor/gatekeeper/dist/lib/tunnels.d.ts +3 -6
  90. package/vendor/gatekeeper/dist/lib/tunnels.d.ts.map +1 -1
  91. package/vendor/gatekeeper/dist/lib/tunnels.js +4 -16
  92. package/vendor/gatekeeper/dist/lib/tunnels.js.map +1 -1
  93. package/vendor/gatekeeper/dist/lib/types.d.ts +0 -19
  94. package/vendor/gatekeeper/dist/lib/types.d.ts.map +1 -1
  95. package/vendor/gatekeeper/dist/server/index.d.ts +6 -1
  96. package/vendor/gatekeeper/dist/server/index.d.ts.map +1 -1
  97. package/vendor/gatekeeper/dist/server/index.js +56 -11
  98. package/vendor/gatekeeper/dist/server/index.js.map +1 -1
  99. package/vendor/gatekeeper/dist/server/routes/authz.d.ts.map +1 -1
  100. package/vendor/gatekeeper/dist/server/routes/authz.js +325 -55
  101. package/vendor/gatekeeper/dist/server/routes/authz.js.map +1 -1
  102. package/vendor/gatekeeper/dist/server/routes/diagnostic.d.ts.map +1 -1
  103. package/vendor/gatekeeper/dist/server/routes/diagnostic.js +5 -2
  104. package/vendor/gatekeeper/dist/server/routes/diagnostic.js.map +1 -1
  105. package/vendor/gatekeeper/package.json +2 -2
  106. package/vendor/server/bin/lamaste-server.js +7 -0
  107. package/vendor/server/package.json +2 -2
  108. package/vendor/server/src/commands/domains.js +214 -0
  109. package/vendor/server/src/commands/plugin-identity.js +2 -16
  110. package/vendor/server/src/commands/plugin-web-surface.js +269 -0
  111. package/vendor/server/src/commands/plugins.js +175 -14
  112. package/vendor/server/src/commands/registry-credential.js +10 -3
  113. package/vendor/server/src/commands/sites.js +18 -1
  114. package/vendor/server/src/commands/status.js +19 -0
  115. package/vendor/server/src/commands/tunnels.js +4 -1
  116. package/vendor/server/src/commands/users.js +8 -19
  117. package/vendor/server/src/domains.js +92 -0
  118. package/vendor/server/src/fail.js +21 -0
  119. package/vendor/server/src/oidc-client-grants.js +63 -0
  120. package/vendor/server/src/panel-api.js +15 -0
  121. package/vendor/server/src/plugin-approval.js +80 -1
  122. package/vendor/server/src/plugin-web-surface.js +307 -0
  123. package/vendor/server-ui/dist/assets/index-B8Tv_ocF.js +84 -0
  124. package/vendor/server-ui/dist/assets/index-Cb-ADsbB.css +1 -0
  125. package/vendor/server-ui/dist/index.html +2 -2
  126. package/vendor/serverd/package.json +2 -2
  127. package/vendor/serverd/src/index.js +50 -19
  128. package/vendor/serverd/src/lib/app-error.js +24 -0
  129. package/vendor/serverd/src/lib/audience.js +12 -3
  130. package/vendor/serverd/src/lib/authelia.js +341 -35
  131. package/vendor/serverd/src/lib/chisel-runtime.js +18 -6
  132. package/vendor/serverd/src/lib/chisel.js +10 -2
  133. package/vendor/serverd/src/lib/directory.js +67 -52
  134. package/vendor/serverd/src/lib/domains.js +1792 -0
  135. package/vendor/serverd/src/lib/gatekeeper-client.js +34 -7
  136. package/vendor/serverd/src/lib/hook-pipelines.js +8 -3
  137. package/vendor/serverd/src/lib/identity-sync.js +35 -0
  138. package/vendor/serverd/src/lib/migrations/state/0015_plugin_web_surface.sql +14 -0
  139. package/vendor/serverd/src/lib/migrations/state/0016_domains.sql +53 -0
  140. package/vendor/serverd/src/lib/migrations/state/0017_membership_kind.sql +15 -0
  141. package/vendor/serverd/src/lib/migrations/state/0018_domain_group_keys.sql +23 -0
  142. package/vendor/serverd/src/lib/nginx.js +576 -131
  143. package/vendor/serverd/src/lib/owned-groups.js +326 -0
  144. package/vendor/serverd/src/lib/plugin-domain.js +86 -0
  145. package/vendor/serverd/src/lib/plugin-hooks.js +40 -11
  146. package/vendor/serverd/src/lib/plugin-lifecycle.js +129 -5
  147. package/vendor/serverd/src/lib/plugin-oidc.js +144 -42
  148. package/vendor/serverd/src/lib/plugin-packages.js +74 -2
  149. package/vendor/serverd/src/lib/plugins.js +82 -9
  150. package/vendor/serverd/src/lib/registry-credential.js +39 -6
  151. package/vendor/serverd/src/lib/services.js +9 -1
  152. package/vendor/serverd/src/lib/state.js +29 -0
  153. package/vendor/serverd/src/lib/tunnel-deps.js +2 -4
  154. package/vendor/serverd/src/lib/user-surface.js +77 -31
  155. package/vendor/serverd/src/lib/users-lock.js +23 -0
  156. package/vendor/serverd/src/lib/vhost-reconcile.js +151 -41
  157. package/vendor/serverd/src/lib/web-surface.js +783 -0
  158. package/vendor/serverd/src/middleware/user-access-session.js +11 -4
  159. package/vendor/serverd/src/routes/invite.js +15 -5
  160. package/vendor/serverd/src/routes/management/domains.js +154 -0
  161. package/vendor/serverd/src/routes/management/gatekeeper-proxy.js +44 -8
  162. package/vendor/serverd/src/routes/management/identity.js +21 -7
  163. package/vendor/serverd/src/routes/management/invitations.js +33 -4
  164. package/vendor/serverd/src/routes/management/plugin-web-surface.js +151 -0
  165. package/vendor/serverd/src/routes/management/plugins.js +6 -2
  166. package/vendor/serverd/src/routes/management/registry-credential.js +86 -57
  167. package/vendor/serverd/src/routes/management/sites.js +188 -71
  168. package/vendor/serverd/src/routes/management/tunnels.js +37 -22
  169. package/vendor/serverd/src/routes/management/users.js +184 -64
  170. package/vendor/serverd/src/routes/management.js +4 -0
  171. package/vendor/serverd/src/routes/onboarding/dns.js +3 -17
  172. package/vendor/serverd/src/routes/onboarding/provision.js +22 -13
  173. package/vendor/serverd/src/routes/user-access.js +13 -1
  174. package/vendor/gatekeeper/dist/lib/migrations/migrations/gatekeeper/0001_groups.sql +0 -7
  175. package/vendor/gatekeeper/dist/lib/migrations/migrations/gatekeeper/0002_access_grants.sql +0 -14
  176. package/vendor/gatekeeper/dist/lib/migrations/migrations/gatekeeper/0003_access_request_log.sql +0 -9
  177. package/vendor/server-ui/dist/assets/index-D-fer5ef.css +0 -1
  178. package/vendor/server-ui/dist/assets/index-DSaDPJaw.js +0 -84
@@ -1,84 +0,0 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((e=>{var t=Symbol.for(`react.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.provider`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.iterator;function p(e){return typeof e!=`object`||!e?null:(e=f&&e[f]||e[`@@iterator`],typeof e==`function`?e:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h=Object.assign,g={};function _(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}_.prototype.isReactComponent={},_.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`)},_.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function v(){}v.prototype=_.prototype;function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}var b=y.prototype=new v;b.constructor=y,h(b,_.prototype),b.isPureReactComponent=!0;var x=Array.isArray,S=Object.prototype.hasOwnProperty,C={current:null},w={key:!0,ref:!0,__self:!0,__source:!0};function T(e,n,r){var i,a={},o=null,s=null;if(n!=null)for(i in n.ref!==void 0&&(s=n.ref),n.key!==void 0&&(o=``+n.key),n)S.call(n,i)&&!w.hasOwnProperty(i)&&(a[i]=n[i]);var c=arguments.length-2;if(c===1)a.children=r;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];a.children=l}if(e&&e.defaultProps)for(i in c=e.defaultProps,c)a[i]===void 0&&(a[i]=c[i]);return{$$typeof:t,type:e,key:o,ref:s,props:a,_owner:C.current}}function E(e,n){return{$$typeof:t,type:e.type,key:n,ref:e.ref,props:e.props,_owner:e._owner}}function D(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function O(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ee=/\/+/g;function te(e,t){return typeof e==`object`&&e&&e.key!=null?O(``+e.key):t.toString(36)}function ne(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0}}if(c)return c=e,o=o(c),e=a===``?`.`+te(c,0):a,x(o)?(i=``,e!=null&&(i=e.replace(ee,`$&/`)+`/`),ne(o,r,i,``,function(e){return e})):o!=null&&(D(o)&&(o=E(o,i+(!o.key||c&&c.key===o.key?``:(``+o.key).replace(ee,`$&/`)+`/`)+e)),r.push(o)),1;if(c=0,a=a===``?`.`:a+`:`,x(e))for(var l=0;l<e.length;l++){s=e[l];var u=a+te(s,l);c+=ne(s,r,i,u,o)}else if(u=p(e),typeof u==`function`)for(e=u.call(e),l=0;!(s=e.next()).done;)s=s.value,u=a+te(s,l++),c+=ne(s,r,i,u,o);else if(s===`object`)throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`);return c}function re(e,t,n){if(e==null)return e;var r=[],i=0;return ne(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ie(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var ae={current:null},oe={transition:null},se={ReactCurrentDispatcher:ae,ReactCurrentBatchConfig:oe,ReactCurrentOwner:C};function ce(){throw Error(`act(...) is not supported in production builds of React.`)}e.Children={map:re,forEach:function(e,t,n){re(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return re(e,function(){t++}),t},toArray:function(e){return re(e,function(e){return e})||[]},only:function(e){if(!D(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}},e.Component=_,e.Fragment=r,e.Profiler=a,e.PureComponent=y,e.StrictMode=i,e.Suspense=l,e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=se,e.act=ce,e.cloneElement=function(e,n,r){if(e==null)throw Error(`React.cloneElement(...): The argument must be a React element, but you passed `+e+`.`);var i=h({},e.props),a=e.key,o=e.ref,s=e._owner;if(n!=null){if(n.ref!==void 0&&(o=n.ref,s=C.current),n.key!==void 0&&(a=``+n.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in n)S.call(n,l)&&!w.hasOwnProperty(l)&&(i[l]=n[l]===void 0&&c!==void 0?c[l]:n[l])}var l=arguments.length-2;if(l===1)i.children=r;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];i.children=c}return{$$typeof:t,type:e.type,key:a,ref:o,props:i,_owner:s}},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:o,_context:e},e.Consumer=e},e.createElement=T,e.createFactory=function(e){var t=T.bind(null,e);return t.type=e,t},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=D,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ie}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=oe.transition;oe.transition={};try{e()}finally{oe.transition=t}},e.unstable_act=ce,e.useCallback=function(e,t){return ae.current.useCallback(e,t)},e.useContext=function(e){return ae.current.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e){return ae.current.useDeferredValue(e)},e.useEffect=function(e,t){return ae.current.useEffect(e,t)},e.useId=function(){return ae.current.useId()},e.useImperativeHandle=function(e,t,n){return ae.current.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return ae.current.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return ae.current.useLayoutEffect(e,t)},e.useMemo=function(e,t){return ae.current.useMemo(e,t)},e.useReducer=function(e,t,n){return ae.current.useReducer(e,t,n)},e.useRef=function(e){return ae.current.useRef(e)},e.useState=function(e){return ae.current.useState(e)},e.useSyncExternalStore=function(e,t,n){return ae.current.useSyncExternalStore(e,t,n)},e.useTransition=function(){return ae.current.useTransition()},e.version=`18.3.1`})),u=o(((e,t)=>{t.exports=l()})),d=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=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(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function b(e){if(h=!1,y(e),!m)if(n(c)!==null)m=!0,re(x);else{var t=n(l);t!==null&&ie(b,t.startTime-e)}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!D());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&ie(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,E=-1;function D(){return!(e.unstable_now()-E<T)}function O(){if(C!==null){var t=e.unstable_now();E=t;var n=!0;try{n=C(!0,t)}finally{n?ee():(S=!1,C=null)}}else S=!1}var ee;if(typeof v==`function`)ee=function(){v(O)};else if(typeof MessageChannel<`u`){var te=new MessageChannel,ne=te.port2;te.port1.onmessage=O,ee=function(){ne.postMessage(null)}}else ee=function(){g(O,0)};function re(e){C=e,S||(S=!0,ee())}function ie(t,n){w=g(function(){t(e.unstable_now())},n)}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(e){e.callback=null},e.unstable_continueExecution=function(){m||p||(m=!0,re(x))},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):T=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(_(w),w=-1):h=!0,ie(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,re(x))),r},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u(),n=f();function r(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 i=new Set,a={};function o(e,t){s(e,t),s(e+`Capture`,t)}function s(e,t){for(a[e]=t,e=0;e<t.length;e++)i.add(t[e])}var c=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),l=Object.prototype.hasOwnProperty,d=/^[: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]*$/,p={},m={};function h(e){return l.call(m,e)?!0:l.call(p,e)?!1:d.test(e)?m[e]=!0:(p[e]=!0,!1)}function g(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?(e=e.toLowerCase().slice(0,5),e!==`data-`&&e!==`aria-`):!n.acceptsBooleans;default:return!1}}function _(e,t,n,r){if(t==null||g(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function v(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var y={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){y[e]=new v(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];y[t]=new v(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){y[e]=new v(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){y[e]=new v(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){y[e]=new v(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){y[e]=new v(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){y[e]=new v(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){y[e]=new v(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){y[e]=new v(e,5,!1,e.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function x(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(b,x);y[t]=new v(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(b,x);y[t]=new v(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(b,x);y[t]=new v(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){y[e]=new v(e,1,!1,e.toLowerCase(),null,!1,!1)}),y.xlinkHref=new v(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){y[e]=new v(e,1,!1,e.toLowerCase(),null,!0,!0)});function S(e,t,n,r){var i=y.hasOwnProperty(t)?y[t]:null;(i===null?r||!(2<t.length)||t[0]!==`o`&&t[0]!==`O`||t[1]!==`n`&&t[1]!==`N`:i.type!==0)&&(_(t,n,i,r)&&(n=null),r||i===null?h(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,``+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type===3?!1:``:n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&!0===n?``:``+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var C=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,w=Symbol.for(`react.element`),T=Symbol.for(`react.portal`),E=Symbol.for(`react.fragment`),D=Symbol.for(`react.strict_mode`),O=Symbol.for(`react.profiler`),ee=Symbol.for(`react.provider`),te=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),oe=Symbol.for(`react.lazy`),se=Symbol.for(`react.offscreen`),ce=Symbol.iterator;function le(e){return typeof e!=`object`||!e?null:(e=ce&&e[ce]||e[`@@iterator`],typeof e==`function`?e:null)}var k=Object.assign,ue;function A(e){if(ue===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ue=t&&t[1]||``}return`
2
- `+ue+e}var de=!1;function fe(e,t){if(!e||de)return``;de=!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(e){var r=e}Reflect.construct(e,[],t)}else{try{t.call()}catch(e){r=e}e.call(t.prototype)}else{try{throw Error()}catch(e){r=e}e()}}catch(t){if(t&&r&&typeof t.stack==`string`){for(var i=t.stack.split(`
3
- `),a=r.stack.split(`
4
- `),o=i.length-1,s=a.length-1;1<=o&&0<=s&&i[o]!==a[s];)s--;for(;1<=o&&0<=s;o--,s--)if(i[o]!==a[s]){if(o!==1||s!==1)do if(o--,s--,0>s||i[o]!==a[s]){var c=`
5
- `+i[o].replace(` at new `,` at `);return e.displayName&&c.includes(`<anonymous>`)&&(c=c.replace(`<anonymous>`,e.displayName)),c}while(1<=o&&0<=s);break}}}finally{de=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:``)?A(e):``}function pe(e){switch(e.tag){case 5:return A(e.type);case 16:return A(`Lazy`);case 13:return A(`Suspense`);case 19:return A(`SuspenseList`);case 0:case 2:case 15:return e=fe(e.type,!1),e;case 11:return e=fe(e.type.render,!1),e;case 1:return e=fe(e.type,!0),e;default:return``}}function me(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 E:return`Fragment`;case T:return`Portal`;case O:return`Profiler`;case D:return`StrictMode`;case re:return`Suspense`;case ie:return`SuspenseList`}if(typeof e==`object`)switch(e.$$typeof){case te:return(e.displayName||`Context`)+`.Consumer`;case ee:return(e._context.displayName||`Context`)+`.Provider`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?me(e.type)||`Memo`:t;case oe:t=e._payload,e=e._init;try{return me(e(t))}catch{}}return null}function he(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`:`ForwardRef(`+e+`)`);case 7:return`Fragment`;case 5:return t;case 4:return`Portal`;case 3:return`Root`;case 6:return`Text`;case 16:return me(t);case 8:return t===D?`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 ge(e){switch(typeof e){case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function _e(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function ve(e){var t=_e(e)?`checked`:`value`,n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=``+e[t];if(!e.hasOwnProperty(t)&&n!==void 0&&typeof n.get==`function`&&typeof n.set==`function`){var i=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ye(e){e._valueTracker||=ve(e)}function be(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=_e(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function xe(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Se(e,t){var n=t.checked;return k({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Ce(e,t){var n=t.defaultValue==null?``:t.defaultValue,r=t.checked==null?t.defaultChecked:t.checked;n=ge(t.value==null?n:t.value),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type===`checkbox`||t.type===`radio`?t.checked!=null:t.value!=null}}function we(e,t){t=t.checked,t!=null&&S(e,`checked`,t,!1)}function Te(e,t){we(e,t);var n=ge(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`)?De(e,t.type,n):t.hasOwnProperty(`defaultValue`)&&De(e,t.type,ge(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Ee(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 De(e,t,n){(t!==`number`||xe(e.ownerDocument)!==e)&&(n==null?e.defaultValue=``+e._wrapperState.initialValue:e.defaultValue!==``+n&&(e.defaultValue=``+n))}var Oe=Array.isArray;function ke(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+ge(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Ae(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(r(91));return k({},t,{value:void 0,defaultValue:void 0,children:``+e._wrapperState.initialValue})}function je(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(r(92));if(Oe(n)){if(1<n.length)throw Error(r(93));n=n[0]}t=n}t??=``,n=t}e._wrapperState={initialValue:ge(n)}}function Me(e,t){var n=ge(t.value),r=ge(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 Ne(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==``&&t!==null&&(e.value=t)}function Pe(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 Fe(e,t){return e==null||e===`http://www.w3.org/1999/xhtml`?Pe(t):e===`http://www.w3.org/2000/svg`&&t===`foreignObject`?`http://www.w3.org/1999/xhtml`:e}var Ie,Le=function(e){return typeof MSApp<`u`&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!==`http://www.w3.org/2000/svg`||`innerHTML`in e)e.innerHTML=t;else{for(Ie||=document.createElement(`div`),Ie.innerHTML=`<svg>`+t.valueOf().toString()+`</svg>`,t=Ie.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Re(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ze={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},Be=[`Webkit`,`ms`,`Moz`,`O`];Object.keys(ze).forEach(function(e){Be.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ze[t]=ze[e]})});function Ve(e,t,n){return t==null||typeof t==`boolean`||t===``?``:n||typeof t!=`number`||t===0||ze.hasOwnProperty(e)&&ze[e]?(``+t).trim():t+`px`}function He(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=n.indexOf(`--`)===0,i=Ve(n,t[n],r);n===`float`&&(n=`cssFloat`),r?e.setProperty(n,i):e[n]=i}}var Ue=k({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 We(e,t){if(t){if(Ue[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(r(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(r(60));if(typeof t.dangerouslySetInnerHTML!=`object`||!(`__html`in t.dangerouslySetInnerHTML))throw Error(r(61))}if(t.style!=null&&typeof t.style!=`object`)throw Error(r(62))}}function Ge(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 Ke=null;function qe(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Je=null,Ye=null,j=null;function Xe(e){if(e=Vi(e)){if(typeof Je!=`function`)throw Error(r(280));var t=e.stateNode;t&&(t=Ui(t),Je(e.stateNode,e.type,t))}}function Ze(e){Ye?j?j.push(e):j=[e]:Ye=e}function Qe(){if(Ye){var e=Ye,t=j;if(j=Ye=null,Xe(e),t)for(e=0;e<t.length;e++)Xe(t[e])}}function $e(e,t){return e(t)}function et(){}var tt=!1;function nt(e,t,n){if(tt)return e(t,n);tt=!0;try{return $e(e,t,n)}finally{tt=!1,(Ye!==null||j!==null)&&(et(),Qe())}}function rt(e,t){var n=e.stateNode;if(n===null)return null;var i=Ui(n);if(i===null)return null;n=i[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(i=!i.disabled)||(e=e.type,i=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!i;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(r(231,t,typeof n));return n}var it=!1;if(c)try{var at={};Object.defineProperty(at,`passive`,{get:function(){it=!0}}),window.addEventListener(`test`,at,at),window.removeEventListener(`test`,at,at)}catch{it=!1}function ot(e,t,n,r,i,a,o,s,c){var l=Array.prototype.slice.call(arguments,3);try{t.apply(n,l)}catch(e){this.onError(e)}}var st=!1,ct=null,lt=!1,ut=null,dt={onError:function(e){st=!0,ct=e}};function ft(e,t,n,r,i,a,o,s,c){st=!1,ct=null,ot.apply(dt,arguments)}function pt(e,t,n,i,a,o,s,c,l){if(ft.apply(this,arguments),st){if(st){var u=ct;st=!1,ct=null}else throw Error(r(198));lt||(lt=!0,ut=u)}}function mt(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 ht(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 gt(e){if(mt(e)!==e)throw Error(r(188))}function _t(e){var t=e.alternate;if(!t){if(t=mt(e),t===null)throw Error(r(188));return t===e?e:null}for(var n=e,i=t;;){var a=n.return;if(a===null)break;var o=a.alternate;if(o===null){if(i=a.return,i!==null){n=i;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return gt(a),e;if(o===i)return gt(a),t;o=o.sibling}throw Error(r(188))}if(n.return!==i.return)n=a,i=o;else{for(var s=!1,c=a.child;c;){if(c===n){s=!0,n=a,i=o;break}if(c===i){s=!0,i=a,n=o;break}c=c.sibling}if(!s){for(c=o.child;c;){if(c===n){s=!0,n=o,i=a;break}if(c===i){s=!0,i=o,n=a;break}c=c.sibling}if(!s)throw Error(r(189))}}if(n.alternate!==i)throw Error(r(190))}if(n.tag!==3)throw Error(r(188));return n.stateNode.current===n?e:t}function vt(e){return e=_t(e),e===null?null:yt(e)}function yt(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=yt(e);if(t!==null)return t;e=e.sibling}return null}var bt=n.unstable_scheduleCallback,xt=n.unstable_cancelCallback,St=n.unstable_shouldYield,Ct=n.unstable_requestPaint,wt=n.unstable_now,Tt=n.unstable_getCurrentPriorityLevel,Et=n.unstable_ImmediatePriority,Dt=n.unstable_UserBlockingPriority,Ot=n.unstable_NormalPriority,kt=n.unstable_LowPriority,At=n.unstable_IdlePriority,jt=null,Mt=null;function Nt(e){if(Mt&&typeof Mt.onCommitFiberRoot==`function`)try{Mt.onCommitFiberRoot(jt,e,void 0,(e.current.flags&128)==128)}catch{}}var Pt=Math.clz32?Math.clz32:Lt,Ft=Math.log,It=Math.LN2;function Lt(e){return e>>>=0,e===0?32:31-(Ft(e)/It|0)|0}var Rt=64,zt=4194304;function Bt(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 Vt(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~i;s===0?(a&=o,a!==0&&(r=Bt(a))):r=Bt(s)}else o=n&~i,o===0?a!==0&&(r=Bt(a)):r=Bt(o);if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,a=t&-t,i>=a||i===16&&a&4194240))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Pt(t),i=1<<n,r|=e[n],t&=~i;return r}function Ht(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 Ut(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes;0<a;){var o=31-Pt(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Ht(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}}function Wt(e){return e=e.pendingLanes&-1073741825,e===0?e&1073741824?1073741824:0:e}function Gt(){var e=Rt;return Rt<<=1,!(Rt&4194240)&&(Rt=64),e}function Kt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function qt(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Pt(t),e[t]=n}function Jt(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 i=31-Pt(n),a=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~a}}function Yt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Pt(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var M=0;function Xt(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Zt,Qt,$t,en,tn,nn=!1,rn=[],an=null,on=null,sn=null,cn=new Map,ln=new Map,un=[],dn=`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 fn(e,t){switch(e){case`focusin`:case`focusout`:an=null;break;case`dragenter`:case`dragleave`:on=null;break;case`mouseover`:case`mouseout`:sn=null;break;case`pointerover`:case`pointerout`:cn.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:ln.delete(t.pointerId)}}function pn(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Vi(t),t!==null&&Qt(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function mn(e,t,n,r,i){switch(t){case`focusin`:return an=pn(an,e,t,n,r,i),!0;case`dragenter`:return on=pn(on,e,t,n,r,i),!0;case`mouseover`:return sn=pn(sn,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return cn.set(a,pn(cn.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,ln.set(a,pn(ln.get(a)||null,e,t,n,r,i)),!0}return!1}function hn(e){var t=Bi(e.target);if(t!==null){var n=mt(t);if(n!==null){if(t=n.tag,t===13){if(t=ht(n),t!==null){e.blockedOn=t,tn(e.priority,function(){$t(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 gn(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=En(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Ke=r,n.target.dispatchEvent(r),Ke=null}else return t=Vi(n),t!==null&&Qt(t),e.blockedOn=n,!1;t.shift()}return!0}function _n(e,t,n){gn(e)&&n.delete(t)}function vn(){nn=!1,an!==null&&gn(an)&&(an=null),on!==null&&gn(on)&&(on=null),sn!==null&&gn(sn)&&(sn=null),cn.forEach(_n),ln.forEach(_n)}function yn(e,t){e.blockedOn===t&&(e.blockedOn=null,nn||(nn=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,vn)))}function bn(e){function t(t){return yn(t,e)}if(0<rn.length){yn(rn[0],e);for(var n=1;n<rn.length;n++){var r=rn[n];r.blockedOn===e&&(r.blockedOn=null)}}for(an!==null&&yn(an,e),on!==null&&yn(on,e),sn!==null&&yn(sn,e),cn.forEach(t),ln.forEach(t),n=0;n<un.length;n++)r=un[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<un.length&&(n=un[0],n.blockedOn===null);)hn(n),n.blockedOn===null&&un.shift()}var N=C.ReactCurrentBatchConfig,xn=!0;function Sn(e,t,n,r){var i=M,a=N.transition;N.transition=null;try{M=1,wn(e,t,n,r)}finally{M=i,N.transition=a}}function Cn(e,t,n,r){var i=M,a=N.transition;N.transition=null;try{M=4,wn(e,t,n,r)}finally{M=i,N.transition=a}}function wn(e,t,n,r){if(xn){var i=En(e,t,n,r);if(i===null)fi(e,t,r,Tn,n),fn(e,r);else if(mn(i,e,t,n,r))r.stopPropagation();else if(fn(e,r),t&4&&-1<dn.indexOf(e)){for(;i!==null;){var a=Vi(i);if(a!==null&&Zt(a),a=En(e,t,n,r),a===null&&fi(e,t,r,Tn,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else fi(e,t,r,null,n)}}var Tn=null;function En(e,t,n,r){if(Tn=null,e=qe(r),e=Bi(e),e!==null)if(t=mt(e),t===null)e=null;else if(n=t.tag,n===13){if(e=ht(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 Tn=e,null}function Dn(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(Tt()){case Et:return 1;case Dt:return 4;case Ot:case kt:return 16;case At:return 536870912;default:return 16}default:return 16}}var On=null,kn=null,An=null;function jn(){if(An)return An;var e,t=kn,n=t.length,r,i=`value`in On?On.value:On.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return An=i.slice(e,1<r?1-r:void 0)}function Mn(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 Nn(){return!0}function Pn(){return!1}function Fn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?Nn:Pn,this.isPropagationStopped=Pn,this}return k(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=Nn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Nn)},persist:function(){},isPersistent:Nn}),t}var In={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ln=Fn(In),Rn=k({},In,{view:0,detail:0}),zn=Fn(Rn),Bn,Vn,Hn,Un=k({},Rn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:F,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!==Hn&&(Hn&&e.type===`mousemove`?(Bn=e.screenX-Hn.screenX,Vn=e.screenY-Hn.screenY):Vn=Bn=0,Hn=e),Bn)},movementY:function(e){return`movementY`in e?e.movementY:Vn}}),Wn=Fn(Un),Gn=Fn(k({},Un,{dataTransfer:0})),Kn=Fn(k({},Rn,{relatedTarget:0})),qn=Fn(k({},In,{animationName:0,elapsedTime:0,pseudoElement:0})),Jn=Fn(k({},In,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Yn=Fn(k({},In,{data:0})),Xn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Zn={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`},P={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Qn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=P[e])?!!t[e]:!1}function F(){return Qn}var $n=Fn(k({},Rn,{key:function(e){if(e.key){var t=Xn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Mn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Zn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:F,charCode:function(e){return e.type===`keypress`?Mn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Mn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),er=Fn(k({},Un,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),tr=Fn(k({},Rn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:F})),nr=Fn(k({},In,{propertyName:0,elapsedTime:0,pseudoElement:0})),rr=Fn(k({},Un,{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})),ir=[9,13,27,32],ar=c&&`CompositionEvent`in window,or=null;c&&`documentMode`in document&&(or=document.documentMode);var sr=c&&`TextEvent`in window&&!or,cr=c&&(!ar||or&&8<or&&11>=or),lr=` `,ur=!1;function dr(e,t){switch(e){case`keyup`:return ir.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function fr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var I=!1;function L(e,t){switch(e){case`compositionend`:return fr(t);case`keypress`:return t.which===32?(ur=!0,lr):null;case`textInput`:return e=t.data,e===lr&&ur?null:e;default:return null}}function pr(e,t){if(I)return e===`compositionend`||!ar&&dr(e,t)?(e=jn(),An=kn=On=null,I=!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 cr&&t.locale!==`ko`?null:t.data;default:return null}}var mr={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 hr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!mr[e.type]:t===`textarea`}function gr(e,t,n,r){Ze(r),t=mi(t,`onChange`),0<t.length&&(n=new Ln(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var _r=null,vr=null;function yr(e){si(e,0)}function br(e){if(be(Hi(e)))return e}function xr(e,t){if(e===`change`)return t}var Sr=!1;if(c){var Cr;if(c){var wr=`oninput`in document;if(!wr){var Tr=document.createElement(`div`);Tr.setAttribute(`oninput`,`return;`),wr=typeof Tr.oninput==`function`}Cr=wr}else Cr=!1;Sr=Cr&&(!document.documentMode||9<document.documentMode)}function Er(){_r&&(_r.detachEvent(`onpropertychange`,Dr),vr=_r=null)}function Dr(e){if(e.propertyName===`value`&&br(vr)){var t=[];gr(t,vr,e,qe(e)),nt(yr,t)}}function Or(e,t,n){e===`focusin`?(Er(),_r=t,vr=n,_r.attachEvent(`onpropertychange`,Dr)):e===`focusout`&&Er()}function kr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return br(vr)}function Ar(e,t){if(e===`click`)return br(t)}function jr(e,t){if(e===`input`||e===`change`)return br(t)}function Mr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Nr=typeof Object.is==`function`?Object.is:Mr;function Pr(e,t){if(Nr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)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 i=n[r];if(!l.call(t,i)||!Nr(e[i],t[i]))return!1}return!0}function Fr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Ir(e,t){var n=Fr(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}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Fr(n)}}function Lr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Lr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Rr(){for(var e=window,t=xe();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=xe(e.document)}return t}function zr(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 Br(e){var t=Rr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Lr(n.ownerDocument.documentElement,n)){if(r!==null&&zr(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 i=n.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=Ir(n,a);var o=Ir(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.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 Vr=c&&`documentMode`in document&&11>=document.documentMode,Hr=null,Ur=null,Wr=null,Gr=!1;function Kr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Gr||Hr==null||Hr!==xe(r)||(r=Hr,`selectionStart`in r&&zr(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}),Wr&&Pr(Wr,r)||(Wr=r,r=mi(Ur,`onSelect`),0<r.length&&(t=new Ln(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Hr)))}function R(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var qr={animationend:R(`Animation`,`AnimationEnd`),animationiteration:R(`Animation`,`AnimationIteration`),animationstart:R(`Animation`,`AnimationStart`),transitionend:R(`Transition`,`TransitionEnd`)},Jr={},Yr={};c&&(Yr=document.createElement(`div`).style,`AnimationEvent`in window||(delete qr.animationend.animation,delete qr.animationiteration.animation,delete qr.animationstart.animation),`TransitionEvent`in window||delete qr.transitionend.transition);function z(e){if(Jr[e])return Jr[e];if(!qr[e])return e;var t=qr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Yr)return Jr[e]=t[n];return e}var Xr=z(`animationend`),Zr=z(`animationiteration`),Qr=z(`animationstart`),$r=z(`transitionend`),ei=new Map,B=`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 ti(e,t){ei.set(e,t),o(t,[e])}for(var ni=0;ni<B.length;ni++){var ri=B[ni];ti(ri.toLowerCase(),`on`+(ri[0].toUpperCase()+ri.slice(1)))}ti(Xr,`onAnimationEnd`),ti(Zr,`onAnimationIteration`),ti(Qr,`onAnimationStart`),ti(`dblclick`,`onDoubleClick`),ti(`focusin`,`onFocus`),ti(`focusout`,`onBlur`),ti($r,`onTransitionEnd`),s(`onMouseEnter`,[`mouseout`,`mouseover`]),s(`onMouseLeave`,[`mouseout`,`mouseover`]),s(`onPointerEnter`,[`pointerout`,`pointerover`]),s(`onPointerLeave`,[`pointerout`,`pointerover`]),o(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),o(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),o(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),o(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),o(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),o(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var ii=`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(` `),ai=new Set(`cancel close invalid load scroll toggle`.split(` `).concat(ii));function oi(e,t,n){var r=e.type||`unknown-event`;e.currentTarget=n,pt(r,t,void 0,e),e.currentTarget=null}function si(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;oi(i,s,l),a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;oi(i,s,l),a=c}}}if(lt)throw e=ut,lt=!1,ut=null,e}function V(e,t){var n=t[Li];n===void 0&&(n=t[Li]=new Set);var r=e+`__bubble`;n.has(r)||(di(t,e,2,!1),n.add(r))}function ci(e,t,n){var r=0;t&&(r|=4),di(n,e,r,t)}var li=`_reactListening`+Math.random().toString(36).slice(2);function ui(e){if(!e[li]){e[li]=!0,i.forEach(function(t){t!==`selectionchange`&&(ai.has(t)||ci(t,!1,e),ci(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[li]||(t[li]=!0,ci(`selectionchange`,!1,t))}}function di(e,t,n,r){switch(Dn(t)){case 1:var i=Sn;break;case 4:i=Cn;break;default:i=wn}n=i.bind(null,t,n,e),i=void 0,!it||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function fi(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i||s.nodeType===8&&s.parentNode===i)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&(c=o.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;o=o.return}for(;s!==null;){if(o=Bi(s),o===null)return;if(c=o.tag,c===5||c===6){r=a=o;continue a}s=s.parentNode}}r=r.return}nt(function(){var r=a,i=qe(n),o=[];a:{var s=ei.get(e);if(s!==void 0){var c=Ln,l=e;switch(e){case`keypress`:if(Mn(n)===0)break a;case`keydown`:case`keyup`:c=$n;break;case`focusin`:l=`focus`,c=Kn;break;case`focusout`:l=`blur`,c=Kn;break;case`beforeblur`:case`afterblur`:c=Kn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:c=Wn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:c=Gn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:c=tr;break;case Xr:case Zr:case Qr:c=qn;break;case $r:c=nr;break;case`scroll`:c=zn;break;case`wheel`:c=rr;break;case`copy`:case`cut`:case`paste`:c=Jn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:c=er}var u=(t&4)!=0,d=!u&&e===`scroll`,f=u?s===null?null:s+`Capture`:s;u=[];for(var p=r,m;p!==null;){m=p;var h=m.stateNode;if(m.tag===5&&h!==null&&(m=h,f!==null&&(h=rt(p,f),h!=null&&u.push(pi(p,h,m)))),d)break;p=p.return}0<u.length&&(s=new c(s,l,null,n,i),o.push({event:s,listeners:u}))}}if(!(t&7)){a:{if(s=e===`mouseover`||e===`pointerover`,c=e===`mouseout`||e===`pointerout`,s&&n!==Ke&&(l=n.relatedTarget||n.fromElement)&&(Bi(l)||l[Ii]))break a;if((c||s)&&(s=i.window===i?i:(s=i.ownerDocument)?s.defaultView||s.parentWindow:window,c?(l=n.relatedTarget||n.toElement,c=r,l=l?Bi(l):null,l!==null&&(d=mt(l),l!==d||l.tag!==5&&l.tag!==6)&&(l=null)):(c=null,l=r),c!==l)){if(u=Wn,h=`onMouseLeave`,f=`onMouseEnter`,p=`mouse`,(e===`pointerout`||e===`pointerover`)&&(u=er,h=`onPointerLeave`,f=`onPointerEnter`,p=`pointer`),d=c==null?s:Hi(c),m=l==null?s:Hi(l),s=new u(h,p+`leave`,c,n,i),s.target=d,s.relatedTarget=m,h=null,Bi(i)===r&&(u=new u(f,p+`enter`,l,n,i),u.target=m,u.relatedTarget=d,h=u),d=h,c&&l)b:{for(u=c,f=l,p=0,m=u;m;m=hi(m))p++;for(m=0,h=f;h;h=hi(h))m++;for(;0<p-m;)u=hi(u),p--;for(;0<m-p;)f=hi(f),m--;for(;p--;){if(u===f||f!==null&&u===f.alternate)break b;u=hi(u),f=hi(f)}u=null}else u=null;c!==null&&gi(o,s,c,u,!1),l!==null&&d!==null&&gi(o,d,l,u,!0)}}a:{if(s=r?Hi(r):window,c=s.nodeName&&s.nodeName.toLowerCase(),c===`select`||c===`input`&&s.type===`file`)var g=xr;else if(hr(s))if(Sr)g=jr;else{g=kr;var _=Or}else (c=s.nodeName)&&c.toLowerCase()===`input`&&(s.type===`checkbox`||s.type===`radio`)&&(g=Ar);if(g&&=g(e,r)){gr(o,g,n,i);break a}_&&_(e,s,r),e===`focusout`&&(_=s._wrapperState)&&_.controlled&&s.type===`number`&&De(s,`number`,s.value)}switch(_=r?Hi(r):window,e){case`focusin`:(hr(_)||_.contentEditable===`true`)&&(Hr=_,Ur=r,Wr=null);break;case`focusout`:Wr=Ur=Hr=null;break;case`mousedown`:Gr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Gr=!1,Kr(o,n,i);break;case`selectionchange`:if(Vr)break;case`keydown`:case`keyup`:Kr(o,n,i)}var v;if(ar)b:{switch(e){case`compositionstart`:var y=`onCompositionStart`;break b;case`compositionend`:y=`onCompositionEnd`;break b;case`compositionupdate`:y=`onCompositionUpdate`;break b}y=void 0}else I?dr(e,n)&&(y=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(y=`onCompositionStart`);y&&(cr&&n.locale!==`ko`&&(I||y!==`onCompositionStart`?y===`onCompositionEnd`&&I&&(v=jn()):(On=i,kn=`value`in On?On.value:On.textContent,I=!0)),_=mi(r,y),0<_.length&&(y=new Yn(y,e,null,n,i),o.push({event:y,listeners:_}),v?y.data=v:(v=fr(n),v!==null&&(y.data=v)))),(v=sr?L(e,n):pr(e,n))&&(r=mi(r,`onBeforeInput`),0<r.length&&(i=new Yn(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:i,listeners:r}),i.data=v))}si(o,t)})}function pi(e,t,n){return{instance:e,listener:t,currentTarget:n}}function mi(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;i.tag===5&&a!==null&&(i=a,a=rt(e,n),a!=null&&r.unshift(pi(e,a,i)),a=rt(e,t),a!=null&&r.push(pi(e,a,i))),e=e.return}return r}function hi(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function gi(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(c!==null&&c===r)break;s.tag===5&&l!==null&&(s=l,i?(c=rt(n,a),c!=null&&o.unshift(pi(n,c,s))):i||(c=rt(n,a),c!=null&&o.push(pi(n,c,s)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var _i=/\r\n?/g,vi=/\u0000|\uFFFD/g;function yi(e){return(typeof e==`string`?e:``+e).replace(_i,`
6
- `).replace(vi,``)}function bi(e,t,n){if(t=yi(t),yi(e)!==t&&n)throw Error(r(425))}function xi(){}var Si=null,Ci=null;function wi(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 Ti=typeof setTimeout==`function`?setTimeout:void 0,Ei=typeof clearTimeout==`function`?clearTimeout:void 0,Di=typeof Promise==`function`?Promise:void 0,Oi=typeof queueMicrotask==`function`?queueMicrotask:Di===void 0?Ti:function(e){return Di.resolve(null).then(e).catch(ki)};function ki(e){setTimeout(function(){throw e})}function Ai(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`){if(r===0){e.removeChild(i),bn(t);return}r--}else n!==`$`&&n!==`$?`&&n!==`$!`||r++;n=i}while(n);bn(t)}function ji(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 Mi(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 Ni=Math.random().toString(36).slice(2),Pi=`__reactFiber$`+Ni,Fi=`__reactProps$`+Ni,Ii=`__reactContainer$`+Ni,Li=`__reactEvents$`+Ni,Ri=`__reactListeners$`+Ni,zi=`__reactHandles$`+Ni;function Bi(e){var t=e[Pi];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ii]||n[Pi]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Mi(e);e!==null;){if(n=e[Pi])return n;e=Mi(e)}return t}e=n,n=e.parentNode}return null}function Vi(e){return e=e[Pi]||e[Ii],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Hi(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(r(33))}function Ui(e){return e[Fi]||null}var Wi=[],Gi=-1;function H(e){return{current:e}}function U(e){0>Gi||(e.current=Wi[Gi],Wi[Gi]=null,Gi--)}function W(e,t){Gi++,Wi[Gi]=e.current,e.current=t}var Ki={},qi=H(Ki),Ji=H(!1),Yi=Ki;function Xi(e,t){var n=e.type.contextTypes;if(!n)return Ki;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Zi(e){return e=e.childContextTypes,e!=null}function Qi(){U(Ji),U(qi)}function $i(e,t,n){if(qi.current!==Ki)throw Error(r(168));W(qi,t),W(Ji,n)}function ea(e,t,n){var i=e.stateNode;if(t=t.childContextTypes,typeof i.getChildContext!=`function`)return n;for(var a in i=i.getChildContext(),i)if(!(a in t))throw Error(r(108,he(e)||`Unknown`,a));return k({},n,i)}function ta(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ki,Yi=qi.current,W(qi,e),W(Ji,Ji.current),!0}function na(e,t,n){var i=e.stateNode;if(!i)throw Error(r(169));n?(e=ea(e,t,Yi),i.__reactInternalMemoizedMergedChildContext=e,U(Ji),U(qi),W(qi,e)):U(Ji),W(Ji,n)}var ra=null,ia=!1,aa=!1;function oa(e){ra===null?ra=[e]:ra.push(e)}function sa(e){ia=!0,oa(e)}function ca(){if(!aa&&ra!==null){aa=!0;var e=0,t=M;try{var n=ra;for(M=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}ra=null,ia=!1}catch(t){throw ra!==null&&(ra=ra.slice(e+1)),bt(Et,ca),t}finally{M=t,aa=!1}}return null}var la=[],ua=0,da=null,fa=0,pa=[],ma=0,ha=null,ga=1,_a=``;function va(e,t){la[ua++]=fa,la[ua++]=da,da=e,fa=t}function ya(e,t,n){pa[ma++]=ga,pa[ma++]=_a,pa[ma++]=ha,ha=e;var r=ga;e=_a;var i=32-Pt(r)-1;r&=~(1<<i),n+=1;var a=32-Pt(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,ga=1<<32-Pt(t)+i|n<<i|r,_a=a+e}else ga=1<<a|n<<i|r,_a=e}function ba(e){e.return!==null&&(va(e,1),ya(e,1,0))}function xa(e){for(;e===da;)da=la[--ua],la[ua]=null,fa=la[--ua],la[ua]=null;for(;e===ha;)ha=pa[--ma],pa[ma]=null,_a=pa[--ma],pa[ma]=null,ga=pa[--ma],pa[ma]=null}var Sa=null,Ca=null,wa=!1,Ta=null;function Ea(e,t){var n=Zl(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 Da(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?!1:(e.stateNode=t,Sa=e,Ca=ji(t.firstChild),!0);case 6:return t=e.pendingProps===``||t.nodeType!==3?null:t,t===null?!1:(e.stateNode=t,Sa=e,Ca=null,!0);case 13:return t=t.nodeType===8?t:null,t===null?!1:(n=ha===null?null:{id:ga,overflow:_a},e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Zl(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,Sa=e,Ca=null,!0);default:return!1}}function Oa(e){return(e.mode&1)!=0&&(e.flags&128)==0}function ka(e){if(wa){var t=Ca;if(t){var n=t;if(!Da(e,t)){if(Oa(e))throw Error(r(418));t=ji(n.nextSibling);var i=Sa;t&&Da(e,t)?Ea(i,n):(e.flags=e.flags&-4097|2,wa=!1,Sa=e)}}else{if(Oa(e))throw Error(r(418));e.flags=e.flags&-4097|2,wa=!1,Sa=e}}}function Aa(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Sa=e}function ja(e){if(e!==Sa)return!1;if(!wa)return Aa(e),wa=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!==`head`&&t!==`body`&&!wi(e.type,e.memoizedProps)),t&&=Ca){if(Oa(e))throw Ma(),Error(r(418));for(;t;)Ea(e,t),t=ji(t.nextSibling)}if(Aa(e),e.tag===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(317));a:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`){if(t===0){Ca=ji(e.nextSibling);break a}t--}else n!==`$`&&n!==`$!`&&n!==`$?`||t++}e=e.nextSibling}Ca=null}}else Ca=Sa?ji(e.stateNode.nextSibling):null;return!0}function Ma(){for(var e=Ca;e;)e=ji(e.nextSibling)}function Na(){Ca=Sa=null,wa=!1}function Pa(e){Ta===null?Ta=[e]:Ta.push(e)}var Fa=C.ReactCurrentBatchConfig;function Ia(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(r(309));var i=n.stateNode}if(!i)throw Error(r(147,e));var a=i,o=``+e;return t!==null&&t.ref!==null&&typeof t.ref==`function`&&t.ref._stringRef===o?t.ref:(t=function(e){var t=a.refs;e===null?delete t[o]:t[o]=e},t._stringRef=o,t)}if(typeof e!=`string`)throw Error(r(284));if(!n._owner)throw Error(r(290,e))}return e}function La(e,t){throw e=Object.prototype.toString.call(t),Error(r(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e))}function Ra(e){var t=e._init;return t(e._payload)}function za(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function i(e,t){for(e=new Map;t!==null;)t.key===null?e.set(t.index,t):e.set(t.key,t),t=t.sibling;return e}function a(e,t){return e=eu(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=2,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=2),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=iu(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===E?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===oe&&Ra(i)===t.type)?(r=a(t,n.props),r.ref=Ia(e,t,n),r.return=e,r):(r=tu(n.type,n.key,n.props,null,e.mode,r),r.ref=Ia(e,t,n),r.return=e,r)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=au(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=nu(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`)return t=iu(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case w:return n=tu(t.type,t.key,t.props,null,e.mode,n),n.ref=Ia(e,null,t),n.return=e,n;case T:return t=au(t,e.mode,n),t.return=e,t;case oe:var r=t._init;return f(e,r(t._payload),n)}if(Oe(t)||le(t))return t=nu(t,e.mode,n,null),t.return=e,t;La(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case w:return n.key===i?l(e,t,n,r):null;case T:return n.key===i?u(e,t,n,r):null;case oe:return i=n._init,p(e,t,i(n._payload),r)}if(Oe(n)||le(n))return i===null?d(e,t,n,r,null):null;La(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case w:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case T:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case oe:var a=r._init;return m(e,t,n,a(r._payload),i)}if(Oe(r)||le(r))return e=e.get(n)||null,d(t,e,r,i,null);La(t,r)}return null}function h(r,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(r,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(r,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(r,d),wa&&va(r,h),l;if(d===null){for(;h<s.length;h++)d=f(r,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return wa&&va(r,h),l}for(d=i(r,d);h<s.length;h++)g=m(d,r,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(r,e)}),wa&&va(r,h),l}function g(a,s,c,l){var u=le(c);if(typeof u!=`function`)throw Error(r(150));if(c=u.call(c),c==null)throw Error(r(151));for(var d=u=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),wa&&va(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return wa&&va(a,g),u}for(h=i(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),wa&&va(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===E&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case w:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===E){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===oe&&Ra(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=Ia(e,l,i),r.return=e,e=r;break a}n(e,l);break}else t(e,l);l=l.sibling}i.type===E?(r=nu(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=tu(i.type,i.key,i.props,null,e.mode,o),o.ref=Ia(e,r,i),o.return=e,e=o)}return s(e);case T:a:{for(l=i.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}else{n(e,r);break}else t(e,r);r=r.sibling}r=au(i,e.mode,o),r.return=e,e=r}return s(e);case oe:return l=i._init,_(e,r,l(i._payload),o)}if(Oe(i))return h(e,r,i,o);if(le(i))return g(e,r,i,o);La(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=iu(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var G=za(!0),Ba=za(!1),Va=H(null),Ha=null,Ua=null,Wa=null;function Ga(){Wa=Ua=Ha=null}function Ka(e){var t=Va.current;U(Va),e._currentValue=t}function qa(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Ja(e,t){Ha=e,Wa=Ua=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Ls=!0),e.firstContext=null)}function Ya(e){var t=e._currentValue;if(Wa!==e)if(e={context:e,memoizedValue:t,next:null},Ua===null){if(Ha===null)throw Error(r(308));Ua=e,Ha.dependencies={lanes:0,firstContext:e}}else Ua=Ua.next=e;return t}var Xa=null;function Za(e){Xa===null?Xa=[e]:Xa.push(e)}function Qa(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Za(t)):(n.next=i.next,i.next=n),t.interleaved=n,$a(e,r)}function $a(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 eo=!1;function to(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function no(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 ro(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function io(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,J&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,$a(e,n)}return i=r.interleaved,i===null?(t.next=t,Za(r)):(t.next=i.next,i.next=t),r.interleaved=t,$a(e,n)}function ao(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Yt(e,n)}}function oo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,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 so(e,t,n,r){var i=e.updateQueue;eo=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=k({},d,f);break a;case 2:eo=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);$c|=o,e.lanes=o,e.memoizedState=d}}function co(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var i=e[t],a=i.callback;if(a!==null){if(i.callback=null,i=n,typeof a!=`function`)throw Error(r(191,a));a.call(i)}}}var lo={},uo=H(lo),fo=H(lo),po=H(lo);function mo(e){if(e===lo)throw Error(r(174));return e}function ho(e,t){switch(W(po,t),W(fo,e),W(uo,lo),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Fe(null,``);break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Fe(t,e)}U(uo),W(uo,t)}function go(){U(uo),U(fo),U(po)}function _o(e){mo(po.current);var t=mo(uo.current),n=Fe(t,e.type);t!==n&&(W(fo,e),W(uo,n))}function K(e){fo.current===e&&(U(uo),U(fo))}var vo=H(0);function yo(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 bo=[];function xo(){for(var e=0;e<bo.length;e++)bo[e]._workInProgressVersionPrimary=null;bo.length=0}var So=C.ReactCurrentDispatcher,Co=C.ReactCurrentBatchConfig,wo=0,To=null,Eo=null,Do=null,Oo=!1,ko=!1,Ao=0,jo=0;function Mo(){throw Error(r(321))}function No(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Nr(e[n],t[n]))return!1;return!0}function Po(e,t,n,i,a,o){if(wo=o,To=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,So.current=e===null||e.memoizedState===null?_s:vs,e=n(i,a),ko){o=0;do{if(ko=!1,Ao=0,25<=o)throw Error(r(301));o+=1,Do=Eo=null,t.updateQueue=null,So.current=ys,e=n(i,a)}while(ko)}if(So.current=gs,t=Eo!==null&&Eo.next!==null,wo=0,Do=Eo=To=null,Oo=!1,t)throw Error(r(300));return e}function Fo(){var e=Ao!==0;return Ao=0,e}function Io(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Do===null?To.memoizedState=Do=e:Do=Do.next=e,Do}function Lo(){if(Eo===null){var e=To.alternate;e=e===null?null:e.memoizedState}else e=Eo.next;var t=Do===null?To.memoizedState:Do.next;if(t!==null)Do=t,Eo=e;else{if(e===null)throw Error(r(310));Eo=e,e={memoizedState:Eo.memoizedState,baseState:Eo.baseState,baseQueue:Eo.baseQueue,queue:Eo.queue,next:null},Do===null?To.memoizedState=Do=e:Do=Do.next=e}return Do}function Ro(e,t){return typeof t==`function`?t(e):t}function zo(e){var t=Lo(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var i=Eo,a=i.baseQueue,o=n.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}i.baseQueue=a=o,n.pending=null}if(a!==null){o=a.next,i=i.baseState;var c=s=null,l=null,u=o;do{var d=u.lane;if((wo&d)===d)l!==null&&(l=l.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),i=u.hasEagerState?u.eagerState:e(i,u.action);else{var f={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};l===null?(c=l=f,s=i):l=l.next=f,To.lanes|=d,$c|=d}u=u.next}while(u!==null&&u!==o);l===null?s=i:l.next=c,Nr(i,t.memoizedState)||(Ls=!0),t.memoizedState=i,t.baseState=s,t.baseQueue=l,n.lastRenderedState=i}if(e=n.interleaved,e!==null){a=e;do o=a.lane,To.lanes|=o,$c|=o,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Bo(e){var t=Lo(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var i=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Nr(o,t.memoizedState)||(Ls=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,i]}function Vo(){}function Ho(e,t){var n=To,i=Lo(),a=t(),o=!Nr(i.memoizedState,a);if(o&&(i.memoizedState=a,Ls=!0),i=i.queue,es(Go.bind(null,n,i,e),[e]),i.getSnapshot!==t||o||Do!==null&&Do.memoizedState.tag&1){if(n.flags|=2048,Yo(9,Wo.bind(null,n,i,a,t),void 0,null),Kc===null)throw Error(r(349));wo&30||Uo(n,t,a)}return a}function Uo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=To.updateQueue,t===null?(t={lastEffect:null,stores:null},To.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Wo(e,t,n,r){t.value=n,t.getSnapshot=r,Ko(t)&&qo(e)}function Go(e,t,n){return n(function(){Ko(t)&&qo(e)})}function Ko(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Nr(e,n)}catch{return!0}}function qo(e){var t=$a(e,1);t!==null&&yl(t,e,1,-1)}function Jo(e){var t=Io();return typeof e==`function`&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ro,lastRenderedState:e},t.queue=e,e=e.dispatch=fs.bind(null,To,e),[t.memoizedState,e]}function Yo(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=To.updateQueue,t===null?(t={lastEffect:null,stores:null},To.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 Xo(){return Lo().memoizedState}function Zo(e,t,n,r){var i=Io();To.flags|=e,i.memoizedState=Yo(1|t,n,void 0,r===void 0?null:r)}function Qo(e,t,n,r){var i=Lo();r=r===void 0?null:r;var a=void 0;if(Eo!==null){var o=Eo.memoizedState;if(a=o.destroy,r!==null&&No(r,o.deps)){i.memoizedState=Yo(t,n,a,r);return}}To.flags|=e,i.memoizedState=Yo(1|t,n,a,r)}function $o(e,t){return Zo(8390656,8,e,t)}function es(e,t){return Qo(2048,8,e,t)}function ts(e,t){return Qo(4,2,e,t)}function ns(e,t){return Qo(4,4,e,t)}function rs(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 is(e,t,n){return n=n==null?null:n.concat([e]),Qo(4,4,rs.bind(null,t,e),n)}function as(){}function os(e,t){var n=Lo();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&No(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ss(e,t){var n=Lo();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&No(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function cs(e,t,n){return wo&21?(Nr(n,t)||(n=Gt(),To.lanes|=n,$c|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Ls=!0),e.memoizedState=n)}function ls(e,t){var n=M;M=n!==0&&4>n?n:4,e(!0);var r=Co.transition;Co.transition={};try{e(!1),t()}finally{M=n,Co.transition=r}}function us(){return Lo().memoizedState}function ds(e,t,n){var r=vl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ps(e))ms(t,n);else if(n=Qa(e,t,n,r),n!==null){var i=_l();yl(n,e,r,i),hs(n,t,r)}}function fs(e,t,n){var r=vl(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ps(e))ms(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Nr(s,o)){var c=t.interleaved;c===null?(i.next=i,Za(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=Qa(e,t,i,r),n!==null&&(i=_l(),yl(n,e,r,i),hs(n,t,r))}}function ps(e){var t=e.alternate;return e===To||t!==null&&t===To}function ms(e,t){ko=Oo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function hs(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Yt(e,n)}}var gs={readContext:Ya,useCallback:Mo,useContext:Mo,useEffect:Mo,useImperativeHandle:Mo,useInsertionEffect:Mo,useLayoutEffect:Mo,useMemo:Mo,useReducer:Mo,useRef:Mo,useState:Mo,useDebugValue:Mo,useDeferredValue:Mo,useTransition:Mo,useMutableSource:Mo,useSyncExternalStore:Mo,useId:Mo,unstable_isNewReconciler:!1},_s={readContext:Ya,useCallback:function(e,t){return Io().memoizedState=[e,t===void 0?null:t],e},useContext:Ya,useEffect:$o,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),Zo(4194308,4,rs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Zo(4194308,4,e,t)},useInsertionEffect:function(e,t){return Zo(4,2,e,t)},useMemo:function(e,t){var n=Io();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Io();return t=n===void 0?t:n(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=ds.bind(null,To,e),[r.memoizedState,e]},useRef:function(e){var t=Io();return e={current:e},t.memoizedState=e},useState:Jo,useDebugValue:as,useDeferredValue:function(e){return Io().memoizedState=e},useTransition:function(){var e=Jo(!1),t=e[0];return e=ls.bind(null,e[1]),Io().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var i=To,a=Io();if(wa){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),Kc===null)throw Error(r(349));wo&30||Uo(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,$o(Go.bind(null,i,o,e),[e]),i.flags|=2048,Yo(9,Wo.bind(null,i,o,n,t),void 0,null),n},useId:function(){var e=Io(),t=Kc.identifierPrefix;if(wa){var n=_a,r=ga;n=(r&~(1<<32-Pt(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=Ao++,0<n&&(t+=`H`+n.toString(32)),t+=`:`}else n=jo++,t=`:`+t+`r`+n.toString(32)+`:`;return e.memoizedState=t},unstable_isNewReconciler:!1},vs={readContext:Ya,useCallback:os,useContext:Ya,useEffect:es,useImperativeHandle:is,useInsertionEffect:ts,useLayoutEffect:ns,useMemo:ss,useReducer:zo,useRef:Xo,useState:function(){return zo(Ro)},useDebugValue:as,useDeferredValue:function(e){return cs(Lo(),Eo.memoizedState,e)},useTransition:function(){return[zo(Ro)[0],Lo().memoizedState]},useMutableSource:Vo,useSyncExternalStore:Ho,useId:us,unstable_isNewReconciler:!1},ys={readContext:Ya,useCallback:os,useContext:Ya,useEffect:es,useImperativeHandle:is,useInsertionEffect:ts,useLayoutEffect:ns,useMemo:ss,useReducer:Bo,useRef:Xo,useState:function(){return Bo(Ro)},useDebugValue:as,useDeferredValue:function(e){var t=Lo();return Eo===null?t.memoizedState=e:cs(t,Eo.memoizedState,e)},useTransition:function(){return[Bo(Ro)[0],Lo().memoizedState]},useMutableSource:Vo,useSyncExternalStore:Ho,useId:us,unstable_isNewReconciler:!1};function bs(e,t){if(e&&e.defaultProps){for(var n in t=k({},t),e=e.defaultProps,e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function xs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:k({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ss={isMounted:function(e){return(e=e._reactInternals)?mt(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=_l(),i=vl(e),a=ro(r,i);a.payload=t,n!=null&&(a.callback=n),t=io(e,a,i),t!==null&&(yl(t,e,i,r),ao(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=_l(),i=vl(e),a=ro(r,i);a.tag=1,a.payload=t,n!=null&&(a.callback=n),t=io(e,a,i),t!==null&&(yl(t,e,i,r),ao(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=_l(),r=vl(e),i=ro(n,r);i.tag=2,t!=null&&(i.callback=t),t=io(e,i,r),t!==null&&(yl(t,e,r,n),ao(t,e,r))}};function Cs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Pr(n,r)||!Pr(i,a):!0}function ws(e,t,n){var r=!1,i=Ki,a=t.contextType;return typeof a==`object`&&a?a=Ya(a):(i=Zi(t)?Yi:qi.current,r=t.contextTypes,a=(r=r!=null)?Xi(e,i):Ki),t=new t(n,a),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ss,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=a),t}function Ts(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&&Ss.enqueueReplaceState(t,t.state,null)}function Es(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},to(e);var a=t.contextType;typeof a==`object`&&a?i.context=Ya(a):(a=Zi(t)?Yi:qi.current,i.context=Xi(e,a)),i.state=e.memoizedState,a=t.getDerivedStateFromProps,typeof a==`function`&&(xs(e,t,a,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps==`function`||typeof i.getSnapshotBeforeUpdate==`function`||typeof i.UNSAFE_componentWillMount!=`function`&&typeof i.componentWillMount!=`function`||(t=i.state,typeof i.componentWillMount==`function`&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount==`function`&&i.UNSAFE_componentWillMount(),t!==i.state&&Ss.enqueueReplaceState(i,i.state,null),so(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount==`function`&&(e.flags|=4194308)}function Ds(e,t){try{var n=``,r=t;do n+=pe(r),r=r.return;while(r);var i=n}catch(e){i=`
7
- Error generating stack: `+e.message+`
8
- `+e.stack}return{value:e,source:t,stack:i,digest:null}}function Os(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function ks(e,t){try{console.error(t.value)}catch(e){setTimeout(function(){throw e})}}var As=typeof WeakMap==`function`?WeakMap:Map;function js(e,t,n){n=ro(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){sl||(sl=!0,cl=r),ks(e,t)},n}function Ms(e,t,n){n=ro(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r==`function`){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){ks(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch==`function`&&(n.callback=function(){ks(e,t),typeof r!=`function`&&(ll===null?ll=new Set([this]):ll.add(this));var n=t.stack;this.componentDidCatch(t.value,{componentStack:n===null?``:n})}),n}function Ns(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new As;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=Wl.bind(null,e,t,n),t.then(e,e))}function Ps(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t===null?!0:t.dehydrated!==null),t)return e;e=e.return}while(e!==null);return null}function Fs(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,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=ro(-1,1),t.tag=2,io(n,t,1))),n.lanes|=1),e)}var Is=C.ReactCurrentOwner,Ls=!1;function Rs(e,t,n,r){t.child=e===null?Ba(t,null,n,r):G(t,e.child,n,r)}function zs(e,t,n,r,i){n=n.render;var a=t.ref;return Ja(t,i),r=Po(e,t,n,r,a,i),n=Fo(),e!==null&&!Ls?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,ac(e,t,i)):(wa&&n&&ba(t),t.flags|=1,Rs(e,t,r,i),t.child)}function Bs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Ql(a)&&a.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=a,Vs(e,t,a,r,i)):(e=tu(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,(e.lanes&i)===0){var o=a.memoizedProps;if(n=n.compare,n=n===null?Pr:n,n(o,r)&&e.ref===t.ref)return ac(e,t,i)}return t.flags|=1,e=eu(a,r),e.ref=t.ref,e.return=t,t.child=e}function Vs(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Pr(a,r)&&e.ref===t.ref)if(Ls=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(Ls=!0);else return t.lanes=e.lanes,ac(e,t,i)}return Ws(e,t,n,r,i)}function Hs(e,t,n){var r=t.pendingProps,i=r.children,a=e===null?null:e.memoizedState;if(r.mode===`hidden`)if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},W(Xc,Yc),Yc|=n;else{if(!(n&1073741824))return e=a===null?n:a.baseLanes|n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,W(Xc,Yc),Yc|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a===null?n:a.baseLanes,W(Xc,Yc),Yc|=r}else a===null?r=n:(r=a.baseLanes|n,t.memoizedState=null),W(Xc,Yc),Yc|=r;return Rs(e,t,i,n),t.child}function Us(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ws(e,t,n,r,i){var a=Zi(n)?Yi:qi.current;return a=Xi(t,a),Ja(t,i),n=Po(e,t,n,r,a,i),r=Fo(),e!==null&&!Ls?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,ac(e,t,i)):(wa&&r&&ba(t),t.flags|=1,Rs(e,t,n,i),t.child)}function Gs(e,t,n,r,i){if(Zi(n)){var a=!0;ta(t)}else a=!1;if(Ja(t,i),t.stateNode===null)ic(e,t),ws(t,n,r),Es(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,s=t.memoizedProps;o.props=s;var c=o.context,l=n.contextType;typeof l==`object`&&l?l=Ya(l):(l=Zi(n)?Yi:qi.current,l=Xi(t,l));var u=n.getDerivedStateFromProps,d=typeof u==`function`||typeof o.getSnapshotBeforeUpdate==`function`;d||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==r||c!==l)&&Ts(t,o,r,l),eo=!1;var f=t.memoizedState;o.state=f,so(t,r,o,i),c=t.memoizedState,s!==r||f!==c||Ji.current||eo?(typeof u==`function`&&(xs(t,n,u,r),c=t.memoizedState),(s=eo||Cs(t,n,s,r,f,c,l))?(d||typeof o.UNSAFE_componentWillMount!=`function`&&typeof o.componentWillMount!=`function`||(typeof o.componentWillMount==`function`&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount==`function`&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount==`function`&&(t.flags|=4194308)):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=l,r=s):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,no(e,t),s=t.memoizedProps,l=t.type===t.elementType?s:bs(t.type,s),o.props=l,d=t.pendingProps,f=o.context,c=n.contextType,typeof c==`object`&&c?c=Ya(c):(c=Zi(n)?Yi:qi.current,c=Xi(t,c));var p=n.getDerivedStateFromProps;(u=typeof p==`function`||typeof o.getSnapshotBeforeUpdate==`function`)||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==d||f!==c)&&Ts(t,o,r,c),eo=!1,f=t.memoizedState,o.state=f,so(t,r,o,i);var m=t.memoizedState;s!==d||f!==m||Ji.current||eo?(typeof p==`function`&&(xs(t,n,p,r),m=t.memoizedState),(l=eo||Cs(t,n,l,r,f,m,c)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!=`function`&&typeof o.componentWillUpdate!=`function`||(typeof o.componentWillUpdate==`function`&&o.componentWillUpdate(r,m,c),typeof o.UNSAFE_componentWillUpdate==`function`&&o.UNSAFE_componentWillUpdate(r,m,c)),typeof o.componentDidUpdate==`function`&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=m),o.props=r,o.state=m,o.context=c,r=l):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return Ks(e,t,n,r,a,i)}function Ks(e,t,n,r,i,a){Us(e,t);var o=(t.flags&128)!=0;if(!r&&!o)return i&&na(t,n,!1),ac(e,t,a);r=t.stateNode,Is.current=t;var s=o&&typeof n.getDerivedStateFromError!=`function`?null:r.render();return t.flags|=1,e!==null&&o?(t.child=G(t,e.child,null,a),t.child=G(t,null,s,a)):Rs(e,t,s,a),t.memoizedState=r.state,i&&na(t,n,!0),t.child}function qs(e){var t=e.stateNode;t.pendingContext?$i(e,t.pendingContext,t.pendingContext!==t.context):t.context&&$i(e,t.context,!1),ho(e,t.containerInfo)}function Js(e,t,n,r,i){return Na(),Pa(i),t.flags|=256,Rs(e,t,n,r),t.child}var Ys={dehydrated:null,treeContext:null,retryLane:0};function Xs(e){return{baseLanes:e,cachePool:null,transitions:null}}function Zs(e,t,n){var r=t.pendingProps,i=vo.current,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(i&2)!=0),s?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),W(vo,i&1),e===null)return ka(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):(o=r.children,e=r.fallback,a?(r=t.mode,a=t.child,o={mode:`hidden`,children:o},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=o):a=ru(o,r,0,null),e=nu(e,r,n,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=Xs(n),t.memoizedState=Ys,e):Qs(t,o));if(i=e.memoizedState,i!==null&&(s=i.dehydrated,s!==null))return ec(e,t,o,r,s,i,n);if(a){a=r.fallback,o=t.mode,i=e.child,s=i.sibling;var c={mode:`hidden`,children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=eu(i,c),r.subtreeFlags=i.subtreeFlags&14680064),s===null?(a=nu(a,o,n,null),a.flags|=2):a=eu(s,a),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,o=e.child.memoizedState,o=o===null?Xs(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},a.memoizedState=o,a.childLanes=e.childLanes&~n,t.memoizedState=Ys,r}return a=e.child,e=a.sibling,r=eu(a,{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 Qs(e,t){return t=ru({mode:`visible`,children:t},e.mode,0,null),t.return=e,e.child=t}function $s(e,t,n,r){return r!==null&&Pa(r),G(t,e.child,null,n),e=Qs(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function ec(e,t,n,i,a,o,s){if(n)return t.flags&256?(t.flags&=-257,i=Os(Error(r(422))),$s(e,t,s,i)):t.memoizedState===null?(o=i.fallback,a=t.mode,i=ru({mode:`visible`,children:i.children},a,0,null),o=nu(o,a,s,null),o.flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,t.mode&1&&G(t,e.child,null,s),t.child.memoizedState=Xs(s),t.memoizedState=Ys,o):(t.child=e.child,t.flags|=128,null);if(!(t.mode&1))return $s(e,t,s,null);if(a.data===`$!`){if(i=a.nextSibling&&a.nextSibling.dataset,i)var c=i.dgst;return i=c,o=Error(r(419)),i=Os(o,i,void 0),$s(e,t,s,i)}if(c=(s&e.childLanes)!==0,Ls||c){if(i=Kc,i!==null){switch(s&-s){case 4:a=2;break;case 16:a=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:a=32;break;case 536870912:a=268435456;break;default:a=0}a=(a&(i.suspendedLanes|s))===0?a:0,a!==0&&a!==o.retryLane&&(o.retryLane=a,$a(e,a),yl(i,e,a,-1))}return Nl(),i=Os(Error(r(421))),$s(e,t,s,i)}return a.data===`$?`?(t.flags|=128,t.child=e.child,t=Kl.bind(null,e),a._reactRetry=t,null):(e=o.treeContext,Ca=ji(a.nextSibling),Sa=t,wa=!0,Ta=null,e!==null&&(pa[ma++]=ga,pa[ma++]=_a,pa[ma++]=ha,ga=e.id,_a=e.overflow,ha=t),t=Qs(t,i.children),t.flags|=4096,t)}function tc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),qa(e.return,t,n)}function nc(e,t,n,r,i){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailMode=i)}function rc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(Rs(e,t,r.children,n),r=vo.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&tc(e,n,t);else if(e.tag===19)tc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(W(vo,r),!(t.mode&1))t.memoizedState=null;else switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&yo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),nc(t,!1,i,n,a);break;case`backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&yo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}nc(t,!0,n,null,a);break;case`together`:nc(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function ic(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ac(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),$c|=t.lanes,(n&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=eu(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=eu(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function oc(e,t,n){switch(t.tag){case 3:qs(t),Na();break;case 5:_o(t);break;case 1:Zi(t.type)&&ta(t);break;case 4:ho(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;W(Va,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(W(vo,vo.current&1),e=ac(e,t,n),e===null?null:e.sibling):Zs(e,t,n):(W(vo,vo.current&1),t.flags|=128,null);W(vo,vo.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return rc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),W(vo,vo.current),r)break;return null;case 22:case 23:return t.lanes=0,Hs(e,t,n)}return ac(e,t,n)}var sc=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}},cc=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,mo(uo.current);var o=null;switch(n){case`input`:i=Se(e,i),r=Se(e,r),o=[];break;case`select`:i=k({},i,{value:void 0}),r=k({},r,{value:void 0}),o=[];break;case`textarea`:i=Ae(e,i),r=Ae(e,r),o=[];break;default:typeof i.onClick!=`function`&&typeof r.onClick==`function`&&(e.onclick=xi)}We(n,r);var s;for(u in n=null,i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u===`style`){var c=i[u];for(s in c)c.hasOwnProperty(s)&&(n||={},n[s]=``)}else u!==`dangerouslySetInnerHTML`&&u!==`children`&&u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&u!==`autoFocus`&&(a.hasOwnProperty(u)?o||=[]:(o||=[]).push(u,null));for(u in r){var l=r[u];if(c=i?.[u],r.hasOwnProperty(u)&&l!==c&&(l!=null||c!=null))if(u===`style`)if(c){for(s in c)!c.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(n||={},n[s]=``);for(s in l)l.hasOwnProperty(s)&&c[s]!==l[s]&&(n||={},n[s]=l[s])}else n||(o||=[],o.push(u,n)),n=l;else u===`dangerouslySetInnerHTML`?(l=l?l.__html:void 0,c=c?c.__html:void 0,l!=null&&c!==l&&(o||=[]).push(u,l)):u===`children`?typeof l!=`string`&&typeof l!=`number`||(o||=[]).push(u,``+l):u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&(a.hasOwnProperty(u)?(l!=null&&u===`onScroll`&&V(`scroll`,e),o||c===l||(o=[])):(o||=[]).push(u,l))}n&&(o||=[]).push(`style`,n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}},lc=function(e,t,n,r){n!==r&&(t.flags|=4)};function uc(e,t){if(!wa)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 dc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function fc(e,t,n){var i=t.pendingProps;switch(xa(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dc(t),null;case 1:return Zi(t.type)&&Qi(),dc(t),null;case 3:return i=t.stateNode,go(),U(Ji),U(qi),xo(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(e===null||e.child===null)&&(ja(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ta!==null&&(Cl(Ta),Ta=null))),dc(t),null;case 5:K(t);var o=mo(po.current);if(n=t.type,e!==null&&t.stateNode!=null)cc(e,t,n,i,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!i){if(t.stateNode===null)throw Error(r(166));return dc(t),null}if(e=mo(uo.current),ja(t)){i=t.stateNode,n=t.type;var s=t.memoizedProps;switch(i[Pi]=t,i[Fi]=s,e=(t.mode&1)!=0,n){case`dialog`:V(`cancel`,i),V(`close`,i);break;case`iframe`:case`object`:case`embed`:V(`load`,i);break;case`video`:case`audio`:for(o=0;o<ii.length;o++)V(ii[o],i);break;case`source`:V(`error`,i);break;case`img`:case`image`:case`link`:V(`error`,i),V(`load`,i);break;case`details`:V(`toggle`,i);break;case`input`:Ce(i,s),V(`invalid`,i);break;case`select`:i._wrapperState={wasMultiple:!!s.multiple},V(`invalid`,i);break;case`textarea`:je(i,s),V(`invalid`,i)}for(var c in We(n,s),o=null,s)if(s.hasOwnProperty(c)){var l=s[c];c===`children`?typeof l==`string`?i.textContent!==l&&(!0!==s.suppressHydrationWarning&&bi(i.textContent,l,e),o=[`children`,l]):typeof l==`number`&&i.textContent!==``+l&&(!0!==s.suppressHydrationWarning&&bi(i.textContent,l,e),o=[`children`,``+l]):a.hasOwnProperty(c)&&l!=null&&c===`onScroll`&&V(`scroll`,i)}switch(n){case`input`:ye(i),Ee(i,s,!0);break;case`textarea`:ye(i),Ne(i);break;case`select`:case`option`:break;default:typeof s.onClick==`function`&&(i.onclick=xi)}i=o,t.updateQueue=i,i!==null&&(t.flags|=4)}else{c=o.nodeType===9?o:o.ownerDocument,e===`http://www.w3.org/1999/xhtml`&&(e=Pe(n)),e===`http://www.w3.org/1999/xhtml`?n===`script`?(e=c.createElement(`div`),e.innerHTML=`<script><\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[Pi]=t,e[Fi]=i,sc(e,t,!1,!1),t.stateNode=e;a:{switch(c=Ge(n,i),n){case`dialog`:V(`cancel`,e),V(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:V(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;o<ii.length;o++)V(ii[o],e);o=i;break;case`source`:V(`error`,e),o=i;break;case`img`:case`image`:case`link`:V(`error`,e),V(`load`,e),o=i;break;case`details`:V(`toggle`,e),o=i;break;case`input`:Ce(e,i),o=Se(e,i),V(`invalid`,e);break;case`option`:o=i;break;case`select`:e._wrapperState={wasMultiple:!!i.multiple},o=k({},i,{value:void 0}),V(`invalid`,e);break;case`textarea`:je(e,i),o=Ae(e,i),V(`invalid`,e);break;default:o=i}for(s in We(n,o),l=o,l)if(l.hasOwnProperty(s)){var u=l[s];s===`style`?He(e,u):s===`dangerouslySetInnerHTML`?(u=u?u.__html:void 0,u!=null&&Le(e,u)):s===`children`?typeof u==`string`?(n!==`textarea`||u!==``)&&Re(e,u):typeof u==`number`&&Re(e,``+u):s!==`suppressContentEditableWarning`&&s!==`suppressHydrationWarning`&&s!==`autoFocus`&&(a.hasOwnProperty(s)?u!=null&&s===`onScroll`&&V(`scroll`,e):u!=null&&S(e,s,u,c))}switch(n){case`input`:ye(e),Ee(e,i,!1);break;case`textarea`:ye(e),Ne(e);break;case`option`:i.value!=null&&e.setAttribute(`value`,``+ge(i.value));break;case`select`:e.multiple=!!i.multiple,s=i.value,s==null?i.defaultValue!=null&&ke(e,!!i.multiple,i.defaultValue,!0):ke(e,!!i.multiple,s,!1);break;default:typeof o.onClick==`function`&&(e.onclick=xi)}switch(n){case`button`:case`input`:case`select`:case`textarea`:i=!!i.autoFocus;break a;case`img`:i=!0;break a;default:i=!1}}i&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return dc(t),null;case 6:if(e&&t.stateNode!=null)lc(e,t,e.memoizedProps,i);else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(n=mo(po.current),mo(uo.current),ja(t)){if(i=t.stateNode,n=t.memoizedProps,i[Pi]=t,(s=i.nodeValue!==n)&&(e=Sa,e!==null))switch(e.tag){case 3:bi(i.nodeValue,n,(e.mode&1)!=0);break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&bi(i.nodeValue,n,(e.mode&1)!=0)}s&&(t.flags|=4)}else i=(n.nodeType===9?n:n.ownerDocument).createTextNode(i),i[Pi]=t,t.stateNode=i}return dc(t),null;case 13:if(U(vo),i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(wa&&Ca!==null&&t.mode&1&&!(t.flags&128))Ma(),Na(),t.flags|=98560,s=!1;else if(s=ja(t),i!==null&&i.dehydrated!==null){if(e===null){if(!s)throw Error(r(318));if(s=t.memoizedState,s=s===null?null:s.dehydrated,!s)throw Error(r(317));s[Pi]=t}else Na(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;dc(t),s=!1}else Ta!==null&&(Cl(Ta),Ta=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(i=i!==null,i!==(e!==null&&e.memoizedState!==null)&&i&&(t.child.flags|=8192,t.mode&1&&(e===null||vo.current&1?Zc===0&&(Zc=3):Nl())),t.updateQueue!==null&&(t.flags|=4),dc(t),null);case 4:return go(),e===null&&ui(t.stateNode.containerInfo),dc(t),null;case 10:return Ka(t.type._context),dc(t),null;case 17:return Zi(t.type)&&Qi(),dc(t),null;case 19:if(U(vo),s=t.memoizedState,s===null)return dc(t),null;if(i=(t.flags&128)!=0,c=s.rendering,c===null)if(i)uc(s,!1);else{if(Zc!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(c=yo(e),c!==null){for(t.flags|=128,uc(s,!1),i=c.updateQueue,i!==null&&(t.updateQueue=i,t.flags|=4),t.subtreeFlags=0,i=n,n=t.child;n!==null;)s=n,e=i,s.flags&=14680066,c=s.alternate,c===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=c.childLanes,s.lanes=c.lanes,s.child=c.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=c.memoizedProps,s.memoizedState=c.memoizedState,s.updateQueue=c.updateQueue,s.type=c.type,e=c.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return W(vo,vo.current&1|2),t.child}e=e.sibling}s.tail!==null&&wt()>al&&(t.flags|=128,i=!0,uc(s,!1),t.lanes=4194304)}else{if(!i)if(e=yo(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),uc(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!wa)return dc(t),null}else 2*wt()-s.renderingStartTime>al&&n!==1073741824&&(t.flags|=128,i=!0,uc(s,!1),t.lanes=4194304);s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(dc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=wt(),t.sibling=null,n=vo.current,W(vo,i?n&1|2:n&1),t);case 22:case 23:return kl(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?Yc&1073741824&&(dc(t),t.subtreeFlags&6&&(t.flags|=8192)):dc(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function pc(e,t){switch(xa(t),t.tag){case 1:return Zi(t.type)&&Qi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return go(),U(Ji),U(qi),xo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return K(t),null;case 13:if(U(vo),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Na()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return U(vo),null;case 4:return go(),null;case 10:return Ka(t.type._context),null;case 22:case 23:return kl(),null;case 24:return null;default:return null}}var mc=!1,hc=!1,gc=typeof WeakSet==`function`?WeakSet:Set,q=null;function _c(e,t){var n=e.ref;if(n!==null)if(typeof n==`function`)try{n(null)}catch(n){Ul(e,t,n)}else n.current=null}function vc(e,t,n){try{n()}catch(n){Ul(e,t,n)}}var yc=!1;function bc(e,t){if(Si=xn,e=Rr(),zr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Ci={focusedElem:e,selectionRange:n},xn=!1,q=t;q!==null;)if(t=q,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,q=e;else for(;q!==null;){t=q;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:bs(t.type,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(r(163))}}catch(e){Ul(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,q=e;break}q=t.return}return h=yc,yc=!1,h}function xc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&vc(t,n,a)}i=i.next}while(i!==r)}}function Sc(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,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 Cc(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 wc(e){var t=e.alternate;t!==null&&(e.alternate=null,wc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Pi],delete t[Fi],delete t[Li],delete t[Ri],delete t[zi])),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 Tc(e){return e.tag===5||e.tag===3||e.tag===4}function Ec(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Tc(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 a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Dc(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=xi));else if(r!==4&&(e=e.child,e!==null))for(Dc(e,t,n),e=e.sibling;e!==null;)Dc(e,t,n),e=e.sibling}function Oc(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(Oc(e,t,n),e=e.sibling;e!==null;)Oc(e,t,n),e=e.sibling}var kc=null,Ac=!1;function jc(e,t,n){for(n=n.child;n!==null;)Mc(e,t,n),n=n.sibling}function Mc(e,t,n){if(Mt&&typeof Mt.onCommitFiberUnmount==`function`)try{Mt.onCommitFiberUnmount(jt,n)}catch{}switch(n.tag){case 5:hc||_c(n,t);case 6:var r=kc,i=Ac;kc=null,jc(e,t,n),kc=r,Ac=i,kc!==null&&(Ac?(e=kc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):kc.removeChild(n.stateNode));break;case 18:kc!==null&&(Ac?(e=kc,n=n.stateNode,e.nodeType===8?Ai(e.parentNode,n):e.nodeType===1&&Ai(e,n),bn(e)):Ai(kc,n.stateNode));break;case 4:r=kc,i=Ac,kc=n.stateNode.containerInfo,Ac=!0,jc(e,t,n),kc=r,Ac=i;break;case 0:case 11:case 14:case 15:if(!hc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&vc(n,t,o),i=i.next}while(i!==r)}jc(e,t,n);break;case 1:if(!hc&&(_c(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Ul(n,t,e)}jc(e,t,n);break;case 21:jc(e,t,n);break;case 22:n.mode&1?(hc=(r=hc)||n.memoizedState!==null,jc(e,t,n),hc=r):jc(e,t,n);break;default:jc(e,t,n)}}function Nc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new gc),t.forEach(function(t){var r=ql.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function Pc(e,t){var n=t.deletions;if(n!==null)for(var i=0;i<n.length;i++){var a=n[i];try{var o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 5:kc=c.stateNode,Ac=!1;break a;case 3:kc=c.stateNode.containerInfo,Ac=!0;break a;case 4:kc=c.stateNode.containerInfo,Ac=!0;break a}c=c.return}if(kc===null)throw Error(r(160));Mc(o,s,a),kc=null,Ac=!1;var l=a.alternate;l!==null&&(l.return=null),a.return=null}catch(e){Ul(a,t,e)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Fc(t,e),t=t.sibling}function Fc(e,t){var n=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Pc(t,e),Ic(e),i&4){try{xc(3,e,e.return),Sc(3,e)}catch(t){Ul(e,e.return,t)}try{xc(5,e,e.return)}catch(t){Ul(e,e.return,t)}}break;case 1:Pc(t,e),Ic(e),i&512&&n!==null&&_c(n,n.return);break;case 5:if(Pc(t,e),Ic(e),i&512&&n!==null&&_c(n,n.return),e.flags&32){var a=e.stateNode;try{Re(a,``)}catch(t){Ul(e,e.return,t)}}if(i&4&&(a=e.stateNode,a!=null)){var o=e.memoizedProps,s=n===null?o:n.memoizedProps,c=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{c===`input`&&o.type===`radio`&&o.name!=null&&we(a,o),Ge(c,s);var u=Ge(c,o);for(s=0;s<l.length;s+=2){var d=l[s],f=l[s+1];d===`style`?He(a,f):d===`dangerouslySetInnerHTML`?Le(a,f):d===`children`?Re(a,f):S(a,d,f,u)}switch(c){case`input`:Te(a,o);break;case`textarea`:Me(a,o);break;case`select`:var p=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!o.multiple;var m=o.value;m==null?p!==!!o.multiple&&(o.defaultValue==null?ke(a,!!o.multiple,o.multiple?[]:``,!1):ke(a,!!o.multiple,o.defaultValue,!0)):ke(a,!!o.multiple,m,!1)}a[Fi]=o}catch(t){Ul(e,e.return,t)}}break;case 6:if(Pc(t,e),Ic(e),i&4){if(e.stateNode===null)throw Error(r(162));a=e.stateNode,o=e.memoizedProps;try{a.nodeValue=o}catch(t){Ul(e,e.return,t)}}break;case 3:if(Pc(t,e),Ic(e),i&4&&n!==null&&n.memoizedState.isDehydrated)try{bn(t.containerInfo)}catch(t){Ul(e,e.return,t)}break;case 4:Pc(t,e),Ic(e);break;case 13:Pc(t,e),Ic(e),a=e.child,a.flags&8192&&(o=a.memoizedState!==null,a.stateNode.isHidden=o,!o||a.alternate!==null&&a.alternate.memoizedState!==null||(il=wt())),i&4&&Nc(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(hc=(u=hc)||d,Pc(t,e),hc=u):Pc(t,e),Ic(e),i&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(q=e,d=e.child;d!==null;){for(f=q=d;q!==null;){switch(p=q,m=p.child,p.tag){case 0:case 11:case 14:case 15:xc(4,p,p.return);break;case 1:_c(p,p.return);var h=p.stateNode;if(typeof h.componentWillUnmount==`function`){i=p,n=p.return;try{t=i,h.props=t.memoizedProps,h.state=t.memoizedState,h.componentWillUnmount()}catch(e){Ul(i,n,e)}}break;case 5:_c(p,p.return);break;case 22:if(p.memoizedState!==null){Bc(f);continue}}m===null?Bc(f):(m.return=p,q=m)}d=d.sibling}a:for(d=null,f=e;;){if(f.tag===5){if(d===null){d=f;try{a=f.stateNode,u?(o=a.style,typeof o.setProperty==`function`?o.setProperty(`display`,`none`,`important`):o.display=`none`):(c=f.stateNode,l=f.memoizedProps.style,s=l!=null&&l.hasOwnProperty(`display`)?l.display:null,c.style.display=Ve(`display`,s))}catch(t){Ul(e,e.return,t)}}}else if(f.tag===6){if(d===null)try{f.stateNode.nodeValue=u?``:f.memoizedProps}catch(t){Ul(e,e.return,t)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break a;for(;f.sibling===null;){if(f.return===null||f.return===e)break a;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Pc(t,e),Ic(e),i&4&&Nc(e);break;case 21:break;default:Pc(t,e),Ic(e)}}function Ic(e){var t=e.flags;if(t&2){try{a:{for(var n=e.return;n!==null;){if(Tc(n)){var i=n;break a}n=n.return}throw Error(r(160))}switch(i.tag){case 5:var a=i.stateNode;i.flags&32&&(Re(a,``),i.flags&=-33),Oc(e,Ec(e),a);break;case 3:case 4:var o=i.stateNode.containerInfo;Dc(e,Ec(e),o);break;default:throw Error(r(161))}}catch(t){Ul(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Lc(e,t,n){q=e,Rc(e,t,n)}function Rc(e,t,n){for(var r=(e.mode&1)!=0;q!==null;){var i=q,a=i.child;if(i.tag===22&&r){var o=i.memoizedState!==null||mc;if(!o){var s=i.alternate,c=s!==null&&s.memoizedState!==null||hc;s=mc;var l=hc;if(mc=o,(hc=c)&&!l)for(q=i;q!==null;)o=q,c=o.child,o.tag===22&&o.memoizedState!==null||c===null?Vc(i):(c.return=o,q=c);for(;a!==null;)q=a,Rc(a,t,n),a=a.sibling;q=i,mc=s,hc=l}zc(e,t,n)}else i.subtreeFlags&8772&&a!==null?(a.return=i,q=a):zc(e,t,n)}}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:hc||Sc(5,t);break;case 1:var i=t.stateNode;if(t.flags&4&&!hc)if(n===null)i.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:bs(t.type,n.memoizedProps);i.componentDidUpdate(a,n.memoizedState,i.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&co(t,o,i);break;case 3:var s=t.updateQueue;if(s!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}co(t,s,n)}break;case 5:var c=t.stateNode;if(n===null&&t.flags&4){n=c;var l=t.memoizedProps;switch(t.type){case`button`:case`input`:case`select`:case`textarea`:l.autoFocus&&n.focus();break;case`img`:l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var f=d.dehydrated;f!==null&&bn(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}hc||t.flags&512&&Cc(t)}catch(e){Ul(t,t.return,e)}}if(t===e){q=null;break}if(n=t.sibling,n!==null){n.return=t.return,q=n;break}q=t.return}}function Bc(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 Vc(e){for(;q!==null;){var t=q;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Sc(4,t)}catch(e){Ul(t,n,e)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount==`function`){var i=t.return;try{r.componentDidMount()}catch(e){Ul(t,i,e)}}var a=t.return;try{Cc(t)}catch(e){Ul(t,a,e)}break;case 5:var o=t.return;try{Cc(t)}catch(e){Ul(t,o,e)}}}catch(e){Ul(t,t.return,e)}if(t===e){q=null;break}var s=t.sibling;if(s!==null){s.return=t.return,q=s;break}q=t.return}}var Hc=Math.ceil,Uc=C.ReactCurrentDispatcher,Wc=C.ReactCurrentOwner,Gc=C.ReactCurrentBatchConfig,J=0,Kc=null,qc=null,Jc=0,Yc=0,Xc=H(0),Zc=0,Qc=null,$c=0,el=0,tl=0,nl=null,rl=null,il=0,al=1/0,ol=null,sl=!1,cl=null,ll=null,ul=!1,dl=null,fl=0,pl=0,ml=null,hl=-1,gl=0;function _l(){return J&6?wt():hl===-1?hl=wt():hl}function vl(e){return e.mode&1?J&2&&Jc!==0?Jc&-Jc:Fa.transition===null?(e=M,e===0?(e=window.event,e=e===void 0?16:Dn(e.type),e):e):(gl===0&&(gl=Gt()),gl):1}function yl(e,t,n,i){if(50<pl)throw pl=0,ml=null,Error(r(185));qt(e,n,i),(!(J&2)||e!==Kc)&&(e===Kc&&(!(J&2)&&(el|=n),Zc===4&&Tl(e,Jc)),bl(e,i),n===1&&J===0&&!(t.mode&1)&&(al=wt()+500,ia&&ca()))}function bl(e,t){var n=e.callbackNode;Ut(e,t);var r=Vt(e,e===Kc?Jc:0);if(r===0)n!==null&&xt(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&xt(n),t===1)e.tag===0?sa(El.bind(null,e)):oa(El.bind(null,e)),Oi(function(){!(J&6)&&ca()}),n=null;else{switch(Xt(r)){case 1:n=Et;break;case 4:n=Dt;break;case 16:n=Ot;break;case 536870912:n=At;break;default:n=Ot}n=Yl(n,xl.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function xl(e,t){if(hl=-1,gl=0,J&6)throw Error(r(327));var n=e.callbackNode;if(Vl()&&e.callbackNode!==n)return null;var i=Vt(e,e===Kc?Jc:0);if(i===0)return null;if(i&30||(i&e.expiredLanes)!==0||t)t=Pl(e,i);else{t=i;var a=J;J|=2;var o=Ml();(Kc!==e||Jc!==t)&&(ol=null,al=wt()+500,Al(e,t));do try{Il();break}catch(t){jl(e,t)}while(1);Ga(),Uc.current=o,J=a,qc===null?(Kc=null,Jc=0,t=Zc):t=0}if(t!==0){if(t===2&&(a=Wt(e),a!==0&&(i=a,t=Sl(e,a))),t===1)throw n=Qc,Al(e,0),Tl(e,i),bl(e,wt()),n;if(t===6)Tl(e,i);else{if(a=e.current.alternate,!(i&30)&&!wl(a)&&(t=Pl(e,i),t===2&&(o=Wt(e),o!==0&&(i=o,t=Sl(e,o))),t===1))throw n=Qc,Al(e,0),Tl(e,i),bl(e,wt()),n;switch(e.finishedWork=a,e.finishedLanes=i,t){case 0:case 1:throw Error(r(345));case 2:zl(e,rl,ol);break;case 3:if(Tl(e,i),(i&130023424)===i&&(t=il+500-wt(),10<t)){if(Vt(e,0)!==0)break;if(a=e.suspendedLanes,(a&i)!==i){_l(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Ti(zl.bind(null,e,rl,ol),t);break}zl(e,rl,ol);break;case 4:if(Tl(e,i),(i&4194240)===i)break;for(t=e.eventTimes,a=-1;0<i;){var s=31-Pt(i);o=1<<s,s=t[s],s>a&&(a=s),i&=~o}if(i=a,i=wt()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*Hc(i/1960))-i,10<i){e.timeoutHandle=Ti(zl.bind(null,e,rl,ol),i);break}zl(e,rl,ol);break;case 5:zl(e,rl,ol);break;default:throw Error(r(329))}}}return bl(e,wt()),e.callbackNode===n?xl.bind(null,e):null}function Sl(e,t){var n=nl;return e.current.memoizedState.isDehydrated&&(Al(e,t).flags|=256),e=Pl(e,t),e!==2&&(t=rl,rl=n,t!==null&&Cl(t)),e}function Cl(e){rl===null?rl=e:rl.push.apply(rl,e)}function wl(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 i=n[r],a=i.getSnapshot;i=i.value;try{if(!Nr(a(),i))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 Tl(e,t){for(t&=~tl,t&=~el,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Pt(t),r=1<<n;e[n]=-1,t&=~r}}function El(e){if(J&6)throw Error(r(327));Vl();var t=Vt(e,0);if(!(t&1))return bl(e,wt()),null;var n=Pl(e,t);if(e.tag!==0&&n===2){var i=Wt(e);i!==0&&(t=i,n=Sl(e,i))}if(n===1)throw n=Qc,Al(e,0),Tl(e,t),bl(e,wt()),n;if(n===6)throw Error(r(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,zl(e,rl,ol),bl(e,wt()),null}function Dl(e,t){var n=J;J|=1;try{return e(t)}finally{J=n,J===0&&(al=wt()+500,ia&&ca())}}function Ol(e){dl!==null&&dl.tag===0&&!(J&6)&&Vl();var t=J;J|=1;var n=Gc.transition,r=M;try{if(Gc.transition=null,M=1,e)return e()}finally{M=r,Gc.transition=n,J=t,!(J&6)&&ca()}}function kl(){Yc=Xc.current,U(Xc)}function Al(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Ei(n)),qc!==null)for(n=qc.return;n!==null;){var r=n;switch(xa(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Qi();break;case 3:go(),U(Ji),U(qi),xo();break;case 5:K(r);break;case 4:go();break;case 13:U(vo);break;case 19:U(vo);break;case 10:Ka(r.type._context);break;case 22:case 23:kl()}n=n.return}if(Kc=e,qc=e=eu(e.current,null),Jc=Yc=t,Zc=0,Qc=null,tl=el=$c=0,rl=nl=null,Xa!==null){for(t=0;t<Xa.length;t++)if(n=Xa[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,a=n.pending;if(a!==null){var o=a.next;a.next=i,r.next=o}n.pending=r}Xa=null}return e}function jl(e,t){do{var n=qc;try{if(Ga(),So.current=gs,Oo){for(var i=To.memoizedState;i!==null;){var a=i.queue;a!==null&&(a.pending=null),i=i.next}Oo=!1}if(wo=0,Do=Eo=To=null,ko=!1,Ao=0,Wc.current=null,n===null||n.return===null){Zc=1,Qc=t,qc=null;break}a:{var o=e,s=n.return,c=n,l=t;if(t=Jc,c.flags|=32768,typeof l==`object`&&l&&typeof l.then==`function`){var u=l,d=c,f=d.tag;if(!(d.mode&1)&&(f===0||f===11||f===15)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var m=Ps(s);if(m!==null){m.flags&=-257,Fs(m,s,c,o,t),m.mode&1&&Ns(o,u,t),t=m,l=u;var h=t.updateQueue;if(h===null){var g=new Set;g.add(l),t.updateQueue=g}else h.add(l);break a}else{if(!(t&1)){Ns(o,u,t),Nl();break a}l=Error(r(426))}}else if(wa&&c.mode&1){var _=Ps(s);if(_!==null){!(_.flags&65536)&&(_.flags|=256),Fs(_,s,c,o,t),Pa(Ds(l,c));break a}}o=l=Ds(l,c),Zc!==4&&(Zc=2),nl===null?nl=[o]:nl.push(o),o=s;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var v=js(o,l,t);oo(o,v);break a;case 1:c=l;var y=o.type,b=o.stateNode;if(!(o.flags&128)&&(typeof y.getDerivedStateFromError==`function`||b!==null&&typeof b.componentDidCatch==`function`&&(ll===null||!ll.has(b)))){o.flags|=65536,t&=-t,o.lanes|=t;var x=Ms(o,c,t);oo(o,x);break a}}o=o.return}while(o!==null)}Rl(n)}catch(e){t=e,qc===n&&n!==null&&(qc=n=n.return);continue}break}while(1)}function Ml(){var e=Uc.current;return Uc.current=gs,e===null?gs:e}function Nl(){(Zc===0||Zc===3||Zc===2)&&(Zc=4),Kc===null||!($c&268435455)&&!(el&268435455)||Tl(Kc,Jc)}function Pl(e,t){var n=J;J|=2;var i=Ml();(Kc!==e||Jc!==t)&&(ol=null,Al(e,t));do try{Fl();break}catch(t){jl(e,t)}while(1);if(Ga(),J=n,Uc.current=i,qc!==null)throw Error(r(261));return Kc=null,Jc=0,Zc}function Fl(){for(;qc!==null;)Ll(qc)}function Il(){for(;qc!==null&&!St();)Ll(qc)}function Ll(e){var t=Jl(e.alternate,e,Yc);e.memoizedProps=e.pendingProps,t===null?Rl(e):qc=t,Wc.current=null}function Rl(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=pc(n,t),n!==null){n.flags&=32767,qc=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Zc=6,qc=null;return}}else if(n=fc(n,t,Yc),n!==null){qc=n;return}if(t=t.sibling,t!==null){qc=t;return}qc=t=e}while(t!==null);Zc===0&&(Zc=5)}function zl(e,t,n){var r=M,i=Gc.transition;try{Gc.transition=null,M=1,Bl(e,t,n,r)}finally{Gc.transition=i,M=r}return null}function Bl(e,t,n,i){do Vl();while(dl!==null);if(J&6)throw Error(r(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(r(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(Jt(e,o),e===Kc&&(qc=Kc=null,Jc=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||ul||(ul=!0,Yl(Ot,function(){return Vl(),null})),o=(n.flags&15990)!=0,n.subtreeFlags&15990||o){o=Gc.transition,Gc.transition=null;var s=M;M=1;var c=J;J|=4,Wc.current=null,bc(e,n),Fc(n,e),Br(Ci),xn=!!Si,Ci=Si=null,e.current=n,Lc(n,e,a),Ct(),J=c,M=s,Gc.transition=o}else e.current=n;if(ul&&(ul=!1,dl=e,fl=a),o=e.pendingLanes,o===0&&(ll=null),Nt(n.stateNode,i),bl(e,wt()),t!==null)for(i=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],i(a.value,{componentStack:a.stack,digest:a.digest});if(sl)throw sl=!1,e=cl,cl=null,e;return fl&1&&e.tag!==0&&Vl(),o=e.pendingLanes,o&1?e===ml?pl++:(pl=0,ml=e):pl=0,ca(),null}function Vl(){if(dl!==null){var e=Xt(fl),t=Gc.transition,n=M;try{if(Gc.transition=null,M=16>e?16:e,dl===null)var i=!1;else{if(e=dl,dl=null,fl=0,J&6)throw Error(r(331));var a=J;for(J|=4,q=e.current;q!==null;){var o=q,s=o.child;if(q.flags&16){var c=o.deletions;if(c!==null){for(var l=0;l<c.length;l++){var u=c[l];for(q=u;q!==null;){var d=q;switch(d.tag){case 0:case 11:case 15:xc(8,d,o)}var f=d.child;if(f!==null)f.return=d,q=f;else for(;q!==null;){d=q;var p=d.sibling,m=d.return;if(wc(d),d===u){q=null;break}if(p!==null){p.return=m,q=p;break}q=m}}}var h=o.alternate;if(h!==null){var g=h.child;if(g!==null){h.child=null;do{var _=g.sibling;g.sibling=null,g=_}while(g!==null)}}q=o}}if(o.subtreeFlags&2064&&s!==null)s.return=o,q=s;else b:for(;q!==null;){if(o=q,o.flags&2048)switch(o.tag){case 0:case 11:case 15:xc(9,o,o.return)}var v=o.sibling;if(v!==null){v.return=o.return,q=v;break b}q=o.return}}var y=e.current;for(q=y;q!==null;){s=q;var b=s.child;if(s.subtreeFlags&2064&&b!==null)b.return=s,q=b;else b:for(s=y;q!==null;){if(c=q,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:Sc(9,c)}}catch(e){Ul(c,c.return,e)}if(c===s){q=null;break b}var x=c.sibling;if(x!==null){x.return=c.return,q=x;break b}q=c.return}}if(J=a,ca(),Mt&&typeof Mt.onPostCommitFiberRoot==`function`)try{Mt.onPostCommitFiberRoot(jt,e)}catch{}i=!0}return i}finally{M=n,Gc.transition=t}}return!1}function Hl(e,t,n){t=Ds(n,t),t=js(e,t,1),e=io(e,t,1),t=_l(),e!==null&&(qt(e,1,t),bl(e,t))}function Ul(e,t,n){if(e.tag===3)Hl(e,e,n);else for(;t!==null;){if(t.tag===3){Hl(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(ll===null||!ll.has(r))){e=Ds(n,e),e=Ms(t,e,1),t=io(t,e,1),e=_l(),t!==null&&(qt(t,1,e),bl(t,e));break}}t=t.return}}function Wl(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=_l(),e.pingedLanes|=e.suspendedLanes&n,Kc===e&&(Jc&n)===n&&(Zc===4||Zc===3&&(Jc&130023424)===Jc&&500>wt()-il?Al(e,0):tl|=n),bl(e,t)}function Gl(e,t){t===0&&(e.mode&1?(t=zt,zt<<=1,!(zt&130023424)&&(zt=4194304)):t=1);var n=_l();e=$a(e,t),e!==null&&(qt(e,t,n),bl(e,n))}function Kl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Gl(e,n)}function ql(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),Gl(e,n)}var Jl=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ji.current)Ls=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Ls=!1,oc(e,t,n);Ls=!!(e.flags&131072)}else Ls=!1,wa&&t.flags&1048576&&ya(t,fa,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;ic(e,t),e=t.pendingProps;var a=Xi(t,qi.current);Ja(t,n),a=Po(null,t,i,e,a,n);var o=Fo();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Zi(i)?(o=!0,ta(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,to(t),a.updater=Ss,t.stateNode=a,a._reactInternals=t,Es(t,i,e,n),t=Ks(null,t,i,!0,o,n)):(t.tag=0,wa&&o&&ba(t),Rs(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(ic(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=$l(i),e=bs(i,e),a){case 0:t=Ws(null,t,i,e,n);break a;case 1:t=Gs(null,t,i,e,n);break a;case 11:t=zs(null,t,i,e,n);break a;case 14:t=Bs(null,t,i,bs(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:bs(i,a),Ws(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:bs(i,a),Gs(e,t,i,a,n);case 3:a:{if(qs(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,no(e,t),so(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated)if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Ds(Error(r(423)),t),t=Js(e,t,i,n,a);break a}else if(i!==a){a=Ds(Error(r(424)),t),t=Js(e,t,i,n,a);break a}else for(Ca=ji(t.stateNode.containerInfo.firstChild),Sa=t,wa=!0,Ta=null,n=Ba(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Na(),i===a){t=ac(e,t,n);break a}Rs(e,t,i,n)}t=t.child}return t;case 5:return _o(t),e===null&&ka(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,wi(i,a)?s=null:o!==null&&wi(i,o)&&(t.flags|=32),Us(e,t),Rs(e,t,s,n),t.child;case 6:return e===null&&ka(t),null;case 13:return Zs(e,t,n);case 4:return ho(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=G(t,null,i,n):Rs(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:bs(i,a),zs(e,t,i,a,n);case 7:return Rs(e,t,t.pendingProps,n),t.child;case 8:return Rs(e,t,t.pendingProps.children,n),t.child;case 12:return Rs(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,W(Va,i._currentValue),i._currentValue=s,o!==null)if(Nr(o.value,s)){if(o.children===a.children&&!Ji.current){t=ac(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=ro(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),qa(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),qa(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}Rs(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,Ja(t,n),a=Ya(a),i=i(a),t.flags|=1,Rs(e,t,i,n),t.child;case 14:return i=t.type,a=bs(i,t.pendingProps),a=bs(i.type,a),Bs(e,t,i,a,n);case 15:return Vs(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:bs(i,a),ic(e,t),t.tag=1,Zi(i)?(e=!0,ta(t)):e=!1,Ja(t,n),ws(t,i,a),Es(t,i,a,n),Ks(null,t,i,!0,e,n);case 19:return rc(e,t,n);case 22:return Hs(e,t,n)}throw Error(r(156,t.tag))};function Yl(e,t){return bt(e,t)}function Xl(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 Zl(e,t,n,r){return new Xl(e,t,n,r)}function Ql(e){return e=e.prototype,!(!e||!e.isReactComponent)}function $l(e){if(typeof e==`function`)return+!!Ql(e);if(e!=null){if(e=e.$$typeof,e===ne)return 11;if(e===ae)return 14}return 2}function eu(e,t){var n=e.alternate;return n===null?(n=Zl(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 tu(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)Ql(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case E:return nu(n.children,a,o,t);case D:s=8,a|=8;break;case O:return e=Zl(12,n,t,a|2),e.elementType=O,e.lanes=o,e;case re:return e=Zl(13,n,t,a),e.elementType=re,e.lanes=o,e;case ie:return e=Zl(19,n,t,a),e.elementType=ie,e.lanes=o,e;case se:return ru(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case ee:s=10;break a;case te:s=9;break a;case ne:s=11;break a;case ae:s=14;break a;case oe:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=Zl(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function nu(e,t,n,r){return e=Zl(7,e,r,t),e.lanes=n,e}function ru(e,t,n,r){return e=Zl(22,e,r,t),e.elementType=se,e.lanes=n,e.stateNode={isHidden:!1},e}function iu(e,t,n){return e=Zl(6,e,null,t),e.lanes=n,e}function au(e,t,n){return t=Zl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function ou(e,t,n,r,i){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=Kt(0),this.expirationTimes=Kt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Kt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function su(e,t,n,r,i,a,o,s,c){return e=new ou(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Zl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},to(a),e}function cu(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:T,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}function lu(e){if(!e)return Ki;e=e._reactInternals;a:{if(mt(e)!==e||e.tag!==1)throw Error(r(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break a;case 1:if(Zi(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break a}}t=t.return}while(t!==null);throw Error(r(171))}if(e.tag===1){var n=e.type;if(Zi(n))return ea(e,n,t)}return t}function uu(e,t,n,r,i,a,o,s,c){return e=su(n,r,!0,e,i,a,o,s,c),e.context=lu(null),n=e.current,r=_l(),i=vl(n),a=ro(r,i),a.callback=t??null,io(n,a,i),e.current.lanes=i,qt(e,i,r),bl(e,r),e}function du(e,t,n,r){var i=t.current,a=_l(),o=vl(i);return n=lu(n),t.context===null?t.context=n:t.pendingContext=n,t=ro(a,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=io(i,t,o),e!==null&&(yl(e,i,o,a),ao(e,i,o)),o}function fu(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 pu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function mu(e,t){pu(e,t),(e=e.alternate)&&pu(e,t)}function hu(){return null}var gu=typeof reportError==`function`?reportError:function(e){console.error(e)};function _u(e){this._internalRoot=e}vu.prototype.render=_u.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(r(409));du(e,t,null,null)},vu.prototype.unmount=_u.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Ol(function(){du(null,e,null,null)}),t[Ii]=null}};function vu(e){this._internalRoot=e}vu.prototype.unstable_scheduleHydration=function(e){if(e){var t=en();e={blockedOn:null,target:e,priority:t};for(var n=0;n<un.length&&t!==0&&t<un[n].priority;n++);un.splice(n,0,e),n===0&&hn(e)}};function yu(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function bu(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==` react-mount-point-unstable `))}function xu(){}function Su(e,t,n,r,i){if(i){if(typeof r==`function`){var a=r;r=function(){var e=fu(o);a.call(e)}}var o=uu(t,r,e,0,null,!1,!1,``,xu);return e._reactRootContainer=o,e[Ii]=o.current,ui(e.nodeType===8?e.parentNode:e),Ol(),o}for(;i=e.lastChild;)e.removeChild(i);if(typeof r==`function`){var s=r;r=function(){var e=fu(c);s.call(e)}}var c=su(e,0,!1,null,null,!1,!1,``,xu);return e._reactRootContainer=c,e[Ii]=c.current,ui(e.nodeType===8?e.parentNode:e),Ol(function(){du(t,c,n,r)}),c}function Cu(e,t,n,r,i){var a=n._reactRootContainer;if(a){var o=a;if(typeof i==`function`){var s=i;i=function(){var e=fu(o);s.call(e)}}du(t,o,e,i)}else o=Su(n,t,e,i,r);return fu(o)}Zt=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Bt(t.pendingLanes);n!==0&&(Yt(t,n|1),bl(t,wt()),!(J&6)&&(al=wt()+500,ca()))}break;case 13:Ol(function(){var t=$a(e,1);t!==null&&yl(t,e,1,_l())}),mu(e,1)}},Qt=function(e){if(e.tag===13){var t=$a(e,134217728);t!==null&&yl(t,e,134217728,_l()),mu(e,134217728)}},$t=function(e){if(e.tag===13){var t=vl(e),n=$a(e,t);n!==null&&yl(n,e,t,_l()),mu(e,t)}},en=function(){return M},tn=function(e,t){var n=M;try{return M=e,t()}finally{M=n}},Je=function(e,t,n){switch(t){case`input`:if(Te(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 i=n[t];if(i!==e&&i.form===e.form){var a=Ui(i);if(!a)throw Error(r(90));be(i),Te(i,a)}}}break;case`textarea`:Me(e,n);break;case`select`:t=n.value,t!=null&&ke(e,!!n.multiple,t,!1)}},$e=Dl,et=Ol;var wu={usingClientEntryPoint:!1,Events:[Vi,Hi,Ui,Ze,Qe,Dl]},Tu={findFiberByHostInstance:Bi,bundleType:0,version:`18.3.1`,rendererPackageName:`react-dom`},Eu={bundleType:Tu.bundleType,version:Tu.version,rendererPackageName:Tu.rendererPackageName,rendererConfig:Tu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=vt(e),e===null?null:e.stateNode},findFiberByHostInstance:Tu.findFiberByHostInstance||hu,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 Du=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Du.isDisabled&&Du.supportsFiber)try{jt=Du.inject(Eu),Mt=Du}catch{}}e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=wu,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!yu(t))throw Error(r(200));return cu(e,t,null,n)},e.createRoot=function(e,t){if(!yu(e))throw Error(r(299));var n=!1,i=``,a=gu;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=su(e,1,!1,null,null,n,!1,i,a),e[Ii]=t.current,ui(e.nodeType===8?e.parentNode:e),new _u(t)},e.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(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=vt(t),e=e===null?null:e.stateNode,e},e.flushSync=function(e){return Ol(e)},e.hydrate=function(e,t,n){if(!bu(t))throw Error(r(200));return Cu(null,e,t,!0,n)},e.hydrateRoot=function(e,t,n){if(!yu(e))throw Error(r(405));var i=n!=null&&n.hydratedSources||null,a=!1,o=``,s=gu;if(n!=null&&(!0===n.unstable_strictMode&&(a=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(s=n.onRecoverableError)),t=uu(t,null,e,1,n??null,a,!1,o,s),e[Ii]=t.current,ui(e),i)for(e=0;e<i.length;e++)n=i[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new vu(t)},e.render=function(e,t,n){if(!bu(t))throw Error(r(200));return Cu(null,e,t,!1,n)},e.unmountComponentAtNode=function(e){if(!bu(e))throw Error(r(40));return e._reactRootContainer?(Ol(function(){Cu(null,null,e,!1,function(){e._reactRootContainer=null,e[Ii]=null})}),!0):!1},e.unstable_batchedUpdates=Dl,e.unstable_renderSubtreeIntoContainer=function(e,t,n,i){if(!bu(n))throw Error(r(200));if(e==null||e._reactInternals===void 0)throw Error(r(38));return Cu(e,t,n,!1,i)},e.version=`18.3.1-next-f1338f8080-20240426`})),m=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=m();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),g=c(u()),_=c(h(),1);m();function v(){return v=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},v.apply(this,arguments)}var y;(function(e){e.Pop=`POP`,e.Push=`PUSH`,e.Replace=`REPLACE`})(y||={});var b=`popstate`;function x(e){e===void 0&&(e={});function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return E(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){return typeof t==`string`?t:D(t)}return ee(t,n,null,e)}function S(e,t){if(e===!1||e==null)throw Error(t)}function C(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function w(){return Math.random().toString(36).substr(2,8)}function T(e,t){return{usr:e.state,key:e.key,idx:t}}function E(e,t,n,r){return n===void 0&&(n=null),v({pathname:typeof e==`string`?e:e.pathname,search:``,hash:``},typeof t==`string`?O(t):t,{state:n,key:t&&t.key||r||w()})}function D(e){let{pathname:t=`/`,search:n=``,hash:r=``}=e;return n&&n!==`?`&&(t+=n.charAt(0)===`?`?n:`?`+n),r&&r!==`#`&&(t+=r.charAt(0)===`#`?r:`#`+r),t}function O(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function ee(e,t,n,r){r===void 0&&(r={});let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=y.Pop,c=null,l=u();l??(l=0,o.replaceState(v({},o.state,{idx:l}),``));function u(){return(o.state||{idx:null}).idx}function d(){s=y.Pop;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=y.Push;let r=E(h.location,e,t);n&&n(r,e),l=u()+1;let d=T(r,l),f=h.createHref(r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=y.Replace;let r=E(h.location,e,t);n&&n(r,e),l=u();let i=T(r,l),d=h.createHref(r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){let t=i.location.origin===`null`?i.location.href:i.location.origin,n=typeof e==`string`?e:D(e);return n=n.replace(/ $/,`%20`),S(t,`No window.location.(origin|href) available to create URL for href: `+n),new URL(n,t)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(b,d),c=e,()=>{i.removeEventListener(b,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}var te;(function(e){e.data=`data`,e.deferred=`deferred`,e.redirect=`redirect`,e.error=`error`})(te||={});function ne(e,t,n){return n===void 0&&(n=`/`),re(e,t,n,!1)}function re(e,t,n,r){let i=ve((typeof t==`string`?O(t):t).pathname||`/`,n);if(i==null)return null;let a=ie(e);oe(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=_e(i);o=me(a[e],t,r)}return o}function ie(e,t,n,r){t===void 0&&(t=[]),n===void 0&&(n=[]),r===void 0&&(r=``);let i=(e,i,a)=>{let o={relativePath:a===void 0?e.path||``:a,caseSensitive:e.caseSensitive===!0,childrenIndex:i,route:e};o.relativePath.startsWith(`/`)&&(S(o.relativePath.startsWith(r),`Absolute route path "`+o.relativePath+`" nested under path `+(`"`+r+`" is not valid. An absolute child route path `)+`must start with the combined path of all its parent routes.`),o.relativePath=o.relativePath.slice(r.length));let s=De([r,o.relativePath]),c=n.concat(o);e.children&&e.children.length>0&&(S(e.index!==!0,`Index routes must not have child routes. Please remove `+(`all child routes from route path "`+s+`".`)),ie(e.children,t,c,s)),!(e.path==null&&!e.index)&&t.push({path:s,score:fe(s,e.index),routesMeta:c})};return e.forEach((e,t)=>{var n;if(e.path===``||!((n=e.path)!=null&&n.includes(`?`)))i(e,t);else for(let n of ae(e.path))i(e,t,n)}),t}function ae(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=ae(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function oe(e){e.sort((e,t)=>e.score===t.score?pe(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var se=/^:[\w-]+$/,ce=3,le=2,k=1,ue=10,A=-2,de=e=>e===`*`;function fe(e,t){let n=e.split(`/`),r=n.length;return n.some(de)&&(r+=A),t&&(r+=le),n.filter(e=>!de(e)).reduce((e,t)=>e+(se.test(t)?ce:t===``?k:ue),r)}function pe(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function me(e,t,n){n===void 0&&(n=!1);let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=he({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=he({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:De([a,u.pathname]),pathnameBase:Oe(De([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=De([a,u.pathnameBase]))}return o}function he(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ge(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,t,n)=>{let{paramName:r,isOptional:i}=t;if(r===`*`){let e=s[n]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let c=s[n];return i&&!c?e[r]=void 0:e[r]=(c||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function ge(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),C(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=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`));return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function _e(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return C(!1,`The URL path "`+e+`" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent `+(`encoding (`+t+`).`)),e}}function ve(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 ye=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,be=e=>ye.test(e);function xe(e,t){t===void 0&&(t=`/`);let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?O(e):e,a;if(n)if(be(n))a=n;else{if(n.includes(`//`)){let e=n;n=n.replace(/\/\/+/g,`/`),C(!1,`Pathnames cannot have embedded double slashes - normalizing `+(e+` -> `+n))}a=n.startsWith(`/`)?Se(n.substring(1),`/`):Se(n,t)}else a=t;return{pathname:a,search:ke(r),hash:Ae(i)}}function Se(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Ce(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 we(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Te(e,t){let n=we(e);return t?n.map((e,t)=>t===n.length-1?e.pathname:e.pathnameBase):n.map(e=>e.pathnameBase)}function Ee(e,t,n,r){r===void 0&&(r=!1);let i;typeof e==`string`?i=O(e):(i=v({},e),S(!i.pathname||!i.pathname.includes(`?`),Ce(`?`,`pathname`,`search`,i)),S(!i.pathname||!i.pathname.includes(`#`),Ce(`#`,`pathname`,`hash`,i)),S(!i.search||!i.search.includes(`#`),Ce(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=xe(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var De=e=>e.join(`/`).replace(/\/\/+/g,`/`),Oe=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),ke=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Ae=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e;function je(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}var Me=[`post`,`put`,`patch`,`delete`];new Set(Me);var Ne=[`get`,...Me];new Set(Ne);function Pe(){return Pe=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Pe.apply(this,arguments)}var Fe=g.createContext(null),Ie=g.createContext(null),Le=g.createContext(null),Re=g.createContext(null),ze=g.createContext({outlet:null,matches:[],isDataRoute:!1}),Be=g.createContext(null);function Ve(e,t){let{relative:n}=t===void 0?{}:t;!He()&&S(!1);let{basename:r,navigator:i}=g.useContext(Le),{hash:a,pathname:o,search:s}=j(e,{relative:n}),c=o;return r!==`/`&&(c=o===`/`?r:De([r,o])),i.createHref({pathname:c,search:s,hash:a})}function He(){return g.useContext(Re)!=null}function Ue(){return!He()&&S(!1),g.useContext(Re).location}function We(e){g.useContext(Le).static||g.useLayoutEffect(e)}function Ge(){let{isDataRoute:e}=g.useContext(ze);return e?ut():Ke()}function Ke(){!He()&&S(!1);let e=g.useContext(Fe),{basename:t,future:n,navigator:r}=g.useContext(Le),{matches:i}=g.useContext(ze),{pathname:a}=Ue(),o=JSON.stringify(Te(i,n.v7_relativeSplatPath)),s=g.useRef(!1);return We(()=>{s.current=!0}),g.useCallback(function(n,i){if(i===void 0&&(i={}),!s.current)return;if(typeof n==`number`){r.go(n);return}let c=Ee(n,JSON.parse(o),a,i.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:De([t,c.pathname])),(i.replace?r.replace:r.push)(c,i.state,i)},[t,r,o,a,e])}var qe=g.createContext(null);function Je(e){let t=g.useContext(ze).outlet;return t&&g.createElement(qe.Provider,{value:e},t)}function Ye(){let{matches:e}=g.useContext(ze),t=e[e.length-1];return t?t.params:{}}function j(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=g.useContext(Le),{matches:i}=g.useContext(ze),{pathname:a}=Ue(),o=JSON.stringify(Te(i,r.v7_relativeSplatPath));return g.useMemo(()=>Ee(e,JSON.parse(o),a,n===`path`),[e,o,a,n])}function Xe(e,t){return Ze(e,t)}function Ze(e,t,n,r){!He()&&S(!1);let{navigator:i}=g.useContext(Le),{matches:a}=g.useContext(ze),o=a[a.length-1],s=o?o.params:{};o&&o.pathname;let c=o?o.pathnameBase:`/`;o&&o.route;let l=Ue(),u;if(t){let e=typeof t==`string`?O(t):t;!(c===`/`||e.pathname?.startsWith(c))&&S(!1),u=e}else u=l;let d=u.pathname||`/`,f=d;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);f=`/`+d.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let p=ne(e,{pathname:f}),m=nt(p&&p.map(e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:De([c,i.encodeLocation?i.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:De([c,i.encodeLocation?i.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])})),a,n,r);return t&&m?g.createElement(Re.Provider,{value:{location:Pe({pathname:`/`,search:``,hash:``,state:null,key:`default`},u),navigationType:y.Pop}},m):m}function Qe(){let e=lt(),t=je(e)?e.status+` `+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null;return g.createElement(g.Fragment,null,g.createElement(`h2`,null,`Unexpected Application Error!`),g.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?g.createElement(`pre`,{style:{padding:`0.5rem`,backgroundColor:`rgba(200,200,200, 0.5)`}},n):null,null)}var $e=g.createElement(Qe,null),et=class extends g.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?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error(`React Router caught the following error during render`,e,t)}render(){return this.state.error===void 0?this.props.children:g.createElement(ze.Provider,{value:this.props.routeContext},g.createElement(Be.Provider,{value:this.state.error,children:this.props.component}))}};function tt(e){let{routeContext:t,match:n,children:r}=e,i=g.useContext(Fe);return i&&i.static&&i.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(ze.Provider,{value:t},r)}function nt(e,t,n,r){if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,o=n?.errors;if(o!=null){let e=a.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);!(e>=0)&&S(!1),a=a.slice(0,Math.min(a.length,e+1))}let s=!1,c=-1;if(n&&r&&r.v7_partialHydration)for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=e),t.route.id){let{loaderData:e,errors:r}=n,i=t.route.loader&&e[t.route.id]===void 0&&(!r||r[t.route.id]===void 0);if(t.route.lazy||i){s=!0,a=c>=0?a.slice(0,c+1):[a[0]];break}}}return a.reduceRight((e,r,i)=>{let l,u=!1,d=null,f=null;n&&(l=o&&r.route.id?o[r.route.id]:void 0,d=r.route.errorElement||$e,s&&(c<0&&i===0?(ft(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),u=!0,f=null):c===i&&(u=!0,f=r.route.hydrateFallbackElement||null)));let p=t.concat(a.slice(0,i+1)),m=()=>{let t;return t=l?d:u?f:r.route.Component?g.createElement(r.route.Component,null):r.route.element?r.route.element:e,g.createElement(tt,{match:r,routeContext:{outlet:e,matches:p,isDataRoute:n!=null},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||i===0)?g.createElement(et,{location:n.location,revalidation:n.revalidation,component:d,error:l,children:m(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):m()},null)}var rt=function(e){return e.UseBlocker=`useBlocker`,e.UseRevalidator=`useRevalidator`,e.UseNavigateStable=`useNavigate`,e}(rt||{}),it=function(e){return e.UseBlocker=`useBlocker`,e.UseLoaderData=`useLoaderData`,e.UseActionData=`useActionData`,e.UseRouteError=`useRouteError`,e.UseNavigation=`useNavigation`,e.UseRouteLoaderData=`useRouteLoaderData`,e.UseMatches=`useMatches`,e.UseRevalidator=`useRevalidator`,e.UseNavigateStable=`useNavigate`,e.UseRouteId=`useRouteId`,e}(it||{});function at(e){let t=g.useContext(Fe);return!t&&S(!1),t}function ot(e){let t=g.useContext(Ie);return!t&&S(!1),t}function st(e){let t=g.useContext(ze);return!t&&S(!1),t}function ct(e){let t=st(e),n=t.matches[t.matches.length-1];return!n.route.id&&S(!1),n.route.id}function lt(){let e=g.useContext(Be),t=ot(it.UseRouteError),n=ct(it.UseRouteError);return e===void 0?t.errors?.[n]:e}function ut(){let{router:e}=at(rt.UseNavigateStable),t=ct(it.UseNavigateStable),n=g.useRef(!1);return We(()=>{n.current=!0}),g.useCallback(function(r,i){i===void 0&&(i={}),n.current&&(typeof r==`number`?e.navigate(r):e.navigate(r,Pe({fromRouteId:t},i)))},[e,t])}var dt={};function ft(e,t,n){!t&&!dt[e]&&(dt[e]=!0)}var pt=(e,t,n)=>(``+t+("You can use the `"+e+"` future flag to opt-in early. ")+(`For more information, see `+n+`.`),void 0);function mt(e,t){e?.v7_startTransition===void 0&&pt(`v7_startTransition`,"React Router will begin wrapping state updates in `React.startTransition` in v7",`https://reactrouter.com/v6/upgrading/future#v7_starttransition`),e?.v7_relativeSplatPath===void 0&&(!t||t.v7_relativeSplatPath===void 0)&&pt(`v7_relativeSplatPath`,`Relative route resolution within Splat routes is changing in v7`,`https://reactrouter.com/v6/upgrading/future#v7_relativesplatpath`),t&&(t.v7_fetcherPersist===void 0&&pt(`v7_fetcherPersist`,`The persistence behavior of fetchers is changing in v7`,`https://reactrouter.com/v6/upgrading/future#v7_fetcherpersist`),t.v7_normalizeFormMethod===void 0&&pt(`v7_normalizeFormMethod`,"Casing of `formMethod` fields is being normalized to uppercase in v7",`https://reactrouter.com/v6/upgrading/future#v7_normalizeformmethod`),t.v7_partialHydration===void 0&&pt(`v7_partialHydration`,"`RouterProvider` hydration behavior is changing in v7",`https://reactrouter.com/v6/upgrading/future#v7_partialhydration`),t.v7_skipActionErrorRevalidation===void 0&&pt(`v7_skipActionErrorRevalidation`,"The revalidation behavior after 4xx/5xx `action` responses is changing in v7",`https://reactrouter.com/v6/upgrading/future#v7_skipactionerrorrevalidation`))}function ht(e){return Je(e.context)}function gt(e){S(!1)}function _t(e){let{basename:t=`/`,children:n=null,location:r,navigationType:i=y.Pop,navigator:a,static:o=!1,future:s}=e;He()&&S(!1);let c=t.replace(/^\/*/,`/`),l=g.useMemo(()=>({basename:c,navigator:a,static:o,future:Pe({v7_relativeSplatPath:!1},s)}),[c,s,a,o]);typeof r==`string`&&(r=O(r));let{pathname:u=`/`,search:d=``,hash:f=``,state:p=null,key:m=`default`}=r,h=g.useMemo(()=>{let e=ve(u,c);return e==null?null:{location:{pathname:e,search:d,hash:f,state:p,key:m},navigationType:i}},[c,u,d,f,p,m,i]);return h==null?null:g.createElement(Le.Provider,{value:l},g.createElement(Re.Provider,{children:n,value:h}))}function vt(e){let{children:t,location:n}=e;return Xe(bt(t),n)}var yt=function(e){return e[e.pending=0]=`pending`,e[e.success=1]=`success`,e[e.error=2]=`error`,e}(yt||{});new Promise(()=>{}),g.Component;function bt(e,t){t===void 0&&(t=[]);let n=[];return g.Children.forEach(e,(e,r)=>{if(!g.isValidElement(e))return;let i=[...t,r];if(e.type===g.Fragment){n.push.apply(n,bt(e.props.children,i));return}e.type!==gt&&S(!1),!(!e.props.index||!e.props.children)&&S(!1);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,loader:e.props.loader,action:e.props.action,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=bt(e.props.children,i)),n.push(a)}),n}function xt(){return xt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},xt.apply(this,arguments)}function St(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function Ct(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function wt(e,t){return e.button===0&&(!t||t===`_self`)&&!Ct(e)}var Tt=[`onClick`,`relative`,`reloadDocument`,`replace`,`state`,`target`,`to`,`preventScrollReset`,`viewTransition`],Et=[`aria-current`,`caseSensitive`,`className`,`end`,`style`,`to`,`viewTransition`,`children`],Dt=`6`;try{window.__reactRouterVersion=Dt}catch{}var Ot=g.createContext({isTransitioning:!1}),kt=g.startTransition;function At(e){let{basename:t,children:n,future:r,window:i}=e,a=g.useRef();a.current??=x({window:i,v5Compat:!0});let o=a.current,[s,c]=g.useState({action:o.action,location:o.location}),{v7_startTransition:l}=r||{},u=g.useCallback(e=>{l&&kt?kt(()=>c(e)):c(e)},[c,l]);return g.useLayoutEffect(()=>o.listen(u),[o,u]),g.useEffect(()=>mt(r),[r]),g.createElement(_t,{basename:t,children:n,location:s.location,navigationType:s.action,navigator:o,future:r})}var jt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Mt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Nt=g.forwardRef(function(e,t){let{onClick:n,relative:r,reloadDocument:i,replace:a,state:o,target:s,to:c,preventScrollReset:l,viewTransition:u}=e,d=St(e,Tt),{basename:f}=g.useContext(Le),p,m=!1;if(typeof c==`string`&&Mt.test(c)&&(p=c,jt))try{let e=new URL(window.location.href),t=c.startsWith(`//`)?new URL(e.protocol+c):new URL(c),n=ve(t.pathname,f);t.origin===e.origin&&n!=null?c=n+t.search+t.hash:m=!0}catch{}let h=Ve(c,{relative:r}),_=Rt(c,{replace:a,state:o,target:s,preventScrollReset:l,relative:r,viewTransition:u});function v(e){n&&n(e),e.defaultPrevented||_(e)}return g.createElement(`a`,xt({},d,{href:p||h,onClick:m||i?n:v,ref:t,target:s}))}),Pt=g.forwardRef(function(e,t){let{"aria-current":n=`page`,caseSensitive:r=!1,className:i=``,end:a=!1,style:o,to:s,viewTransition:c,children:l}=e,u=St(e,Et),d=j(s,{relative:u.relative}),f=Ue(),p=g.useContext(Ie),{navigator:m,basename:h}=g.useContext(Le),_=p!=null&&zt(d)&&c===!0,v=m.encodeLocation?m.encodeLocation(d).pathname:d.pathname,y=f.pathname,b=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;r||(y=y.toLowerCase(),b=b?b.toLowerCase():null,v=v.toLowerCase()),b&&h&&(b=ve(b,h)||b);let x=v!==`/`&&v.endsWith(`/`)?v.length-1:v.length,S=y===v||!a&&y.startsWith(v)&&y.charAt(x)===`/`,C=b!=null&&(b===v||!a&&b.startsWith(v)&&b.charAt(v.length)===`/`),w={isActive:S,isPending:C,isTransitioning:_},T=S?n:void 0,E;E=typeof i==`function`?i(w):[i,S?`active`:null,C?`pending`:null,_?`transitioning`:null].filter(Boolean).join(` `);let D=typeof o==`function`?o(w):o;return g.createElement(Nt,xt({},u,{"aria-current":T,className:E,ref:t,style:D,to:s,viewTransition:c}),typeof l==`function`?l(w):l)}),Ft;(function(e){e.UseScrollRestoration=`useScrollRestoration`,e.UseSubmit=`useSubmit`,e.UseSubmitFetcher=`useSubmitFetcher`,e.UseFetcher=`useFetcher`,e.useViewTransitionState=`useViewTransitionState`})(Ft||={});var It;(function(e){e.UseFetcher=`useFetcher`,e.UseFetchers=`useFetchers`,e.UseScrollRestoration=`useScrollRestoration`})(It||={});function Lt(e){let t=g.useContext(Fe);return!t&&S(!1),t}function Rt(e,t){let{target:n,replace:r,state:i,preventScrollReset:a,relative:o,viewTransition:s}=t===void 0?{}:t,c=Ge(),l=Ue(),u=j(e,{relative:o});return g.useCallback(t=>{wt(t,n)&&(t.preventDefault(),c(e,{replace:r===void 0?D(l)===D(u):r,state:i,preventScrollReset:a,relative:o,viewTransition:s}))},[l,c,u,r,i,n,e,a,o,s])}function zt(e,t){t===void 0&&(t={});let n=g.useContext(Ot);n??S(!1);let{basename:r}=Lt(Ft.useViewTransitionState),i=j(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=ve(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=ve(n.nextLocation.pathname,r)||n.nextLocation.pathname;return he(i.pathname,o)!=null||he(i.pathname,a)!=null}var Bt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Vt=new class extends Bt{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Ht={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ut=new class{#e=Ht;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function Wt(e){setTimeout(e,0)}var Gt=typeof window>`u`||`Deno`in globalThis;function Kt(){}function qt(e,t){return typeof e==`function`?e(t):e}function Jt(e){return typeof e==`number`&&e>=0&&e!==1/0}function Yt(e,t){return Math.max(e+(t||0)-Date.now(),0)}function M(e,t){return typeof e==`function`?e(t):e}function Xt(e,t){return typeof e==`function`?e(t):e}function Zt(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==$t(o,t.options))return!1}else if(!tn(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Qt(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(en(t.options.mutationKey)!==en(a))return!1}else if(!tn(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function $t(e,t){return(t?.queryKeyHashFn||en)(e)}function en(e){return JSON.stringify(e,(e,t)=>sn(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function tn(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>tn(e[n],t[n])):!1}var nn=Object.prototype.hasOwnProperty;function rn(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=on(e)&&on(t);if(!r&&!(sn(e)&&sn(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:nn.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=rn(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function an(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function on(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function sn(e){if(!cn(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!cn(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function cn(e){return Object.prototype.toString.call(e)===`[object Object]`}function ln(e){return new Promise(t=>{Ut.setTimeout(t,e)})}function un(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:rn(e,t)}function dn(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function fn(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var pn=Symbol();function mn(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===pn?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function hn(e,t){return typeof e==`function`?e(...t):!!e}function gn(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var _n=(()=>{let e=()=>Gt;return{isServer(){return e()},setIsServer(t){e=t}}})();function vn(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var yn=Wt;function bn(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=yn,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var N=bn(),xn=new class extends Bt{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Sn(e){return Math.min(1e3*2**e,3e4)}function Cn(e){return(e??`online`)===`online`?xn.isOnline():!0}var wn=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Tn(e){let t=!1,n=0,r,i=vn(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new wn(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Vt.isFocused()&&(e.networkMode===`always`||xn.isOnline())&&e.canRun(),u=()=>Cn(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(_n.isServer()?0:3),o=e.retryDelay??Sn,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),ln(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var En=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Jt(this.gcTime)&&(this.#e=Ut.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(_n.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Ut.clearTimeout(this.#e),this.#e=void 0)}};function Dn(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{gn(e,()=>t.signal,()=>n=!0)},u=mn(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?fn:dn;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?kn:On,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:On(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function On(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function kn(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function An(e,t){return t?On(e,t)!=null:!1}function jn(e,t){return!t||!e.getPreviousPageParam?!1:kn(e,t)!=null}var Mn=class extends En{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Fn(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Fn(this.options);e.data!==void 0&&(this.setState(Pn(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=un(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(Kt).catch(Kt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Xt(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===pn||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>M(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Yt(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=mn(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?Dn(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=Tn({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof wn&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof wn){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Nn(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Pn(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),N.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Nn(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Cn(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Pn(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Fn(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var In=class extends Bt{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=vn(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Rn(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return zn(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return zn(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Xt(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!an(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Bn(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Xt(this.options.enabled,this.#t)!==Xt(t.enabled,this.#t)||M(this.options.staleTime,this.#t)!==M(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Xt(this.options.enabled,this.#t)!==Xt(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Hn(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Kt)),t}#g(){this.#b();let e=M(this.options.staleTime,this.#t);if(_n.isServer()||this.#r.isStale||!Jt(e))return;let t=Yt(this.#r.dataUpdatedAt,e)+1;this.#d=Ut.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(_n.isServer()||Xt(this.options.enabled,this.#t)===!1||!Jt(this.#p)||this.#p===0)&&(this.#f=Ut.setInterval(()=>{(this.options.refetchIntervalInBackground||Vt.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Ut.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Ut.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Rn(e,t),o=i&&Bn(e,n,t,r);(a||o)&&(l={...l,...Nn(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=un(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=un(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Vn(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Xt(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=vn())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!an(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){N.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function Ln(e,t){return Xt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&Xt(t.retryOnMount,e)===!1)}function Rn(e,t){return Ln(e,t)||e.state.data!==void 0&&zn(e,t,t.refetchOnMount)}function zn(e,t,n){if(Xt(t.enabled,e)!==!1&&M(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Vn(e,t)}return!1}function Bn(e,t,n,r){return(e!==t||Xt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Vn(e,n)}function Vn(e,t){return Xt(t.enabled,e)!==!1&&e.isStaleByTime(M(t.staleTime,e))}function Hn(e,t){return!an(e.getCurrentResult(),t)}var Un=class extends In{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:An(t,n.data),hasPreviousPage:jn(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},Wn=class extends En{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Gn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Tn({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),N.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Gn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Kn=class extends Bt{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Wn({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=qn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=qn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=qn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=qn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){N.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Qt(t,e))}findAll(e={}){return this.getAll().filter(t=>Qt(e,t))}notify(e){N.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return N.batch(()=>Promise.all(e.map(e=>e.continue().catch(Kt))))}};function qn(e){return e.options.scope?.id}var Jn=class extends Bt{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),an(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&en(t.mutationKey)!==en(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Gn();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){N.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Yn=class extends Bt{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??$t(r,t),a=this.get(i);return a||(a=new Mn({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){N.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Zt(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Zt(e,t)):t}notify(e){N.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){N.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){N.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Xn=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Yn,this.#t=e.mutationCache||new Kn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Vt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=xn.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(M(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=qt(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return N.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;N.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return N.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=N.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Kt).catch(Kt)}invalidateQueries(e,t={}){return N.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=N.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Kt)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Kt)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(M(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Kt).catch(Kt)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Kt).catch(Kt)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return xn.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(en(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{tn(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(en(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{tn(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=$t(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===pn&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Zn=o((e=>{var t=u(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),P=o(((e,t)=>{t.exports=Zn()}))(),Qn=g.createContext(void 0),F=e=>{let t=g.useContext(Qn);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},$n=({client:e,children:t})=>(g.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,P.jsx)(Qn.Provider,{value:e,children:t})),er=g.createContext(!1),tr=()=>g.useContext(er);er.Provider;function nr(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var rr=g.createContext(nr()),ir=()=>g.useContext(rr),ar=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?hn(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},or=e=>{g.useEffect(()=>{e.clearReset()},[e])},sr=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||hn(n,[e.error,r])),cr=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},lr=(e,t)=>e.isLoading&&e.isFetching&&!t,ur=(e,t)=>e?.suspense&&t.isPending,dr=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function fr(e,t,n){let r=tr(),i=ir(),a=F(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,cr(o),ar(o,i,s),or(i);let c=!a.getQueryCache().get(o.queryHash),[l]=g.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(g.useSyncExternalStore(g.useCallback(e=>{let t=d?l.subscribe(N.batchCalls(e)):Kt;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),g.useEffect(()=>{l.setOptions(o)},[o,l]),ur(o,u))throw dr(o,l,i);if(sr({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!_n.isServer()&&lr(u,r)&&(c?dr(o,l,i):s?.promise)?.catch(Kt).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function I(e,t){return fr(e,In,t)}function L(e,t){let n=F(t),[r]=g.useState(()=>new Jn(n,e));g.useEffect(()=>{r.setOptions(e)},[r,e]);let i=g.useSyncExternalStore(g.useCallback(e=>r.subscribe(N.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=g.useCallback((e,t)=>{r.mutate(e,t).catch(Kt)},[r]);if(i.error&&hn(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function pr(e,t){return fr(e,Un,t)}function mr(e,t=1){if(e===0)return`0 B`;let n=1024,r=[`B`,`KB`,`MB`,`GB`,`TB`],i=Math.floor(Math.log(e)/Math.log(n));return`${(e/n**+i).toFixed(t)} ${r[i]}`}function hr(e){if(!e||e<=0)return`0s`;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=Math.floor(e%60),a=[];return t>0&&a.push(`${t}d`),n>0&&a.push(`${n}h`),r>0&&a.push(`${r}m`),a.length===0&&a.push(`${i}s`),a.join(` `)}function gr(e,t=Date.now()){if(!e)return``;let n=t-new Date(e).getTime();if(n<0)return`just now`;let r=Math.floor(n/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function _r(e,t){let n=Date.parse(e);if(!Number.isFinite(n))return`an unknown time`;let r=new Date(n);return`${new Date(t).toDateString()===r.toDateString()?r.toLocaleTimeString():r.toLocaleString()} (${gr(e,t)})`}function vr(e){return!e||e.health?.state!==`down`?null:{agentLabel:e.agentLabel,reason:e.health.reason??null,since:e.health.since??null,agentLastSeenAt:e.agentLastSeenAt??null}}function yr(e){return!e||e.state!==`down`?null:{agentLabel:e.agentLabel,reason:e.reason??null,since:e.since??null,agentLastSeenAt:e.agentLastSeenAt??null}}function br(e,t){let n=e.since?_r(e.since,t):`an unknown time`;if(e.reason===`app`)return`The agent half is not responding since ${n}`;if(e.reason===`tunnel`){let r=e.agentLastSeenAt?`last sync ${_r(e.agentLastSeenAt,t)}`:`no sync recorded`;return`Hosting agent ${e.agentLabel} is offline since ${n} — ${r}`}return`The hosting on ${e.agentLabel} is down since ${n}`}function xr(e,t){if(!e||e.hosting!==`agent`||e.agent==null)return{state:`mount`};let n=e.agentHosting,r=e.displayName||e.name;if(!n)return{state:`waiting`,message:`${r} is not hosted on an agent — host it on the Plugins page`};if(n.phase&&n.phase!==`active`)return{state:`waiting`,message:n.phase===`installing`?`The hosting of ${r} on ${n.agentLabel} is being set up`:`The hosting of ${r} on ${n.agentLabel} is being removed`};let i=vr(n);return i?{state:`offline`,message:br(i,t)}:{state:`mount`}}function Sr(e,t){let n=e.hosting;if(!n)return`Not hosted on an agent yet`;if(n.phase&&n.phase!==`active`)return n.phase===`installing`?`The hosting on ${n.agentLabel} is being set up`:`The hosting on ${n.agentLabel} is being removed`;let r=yr(n);return r?br(r,t):typeof e.revision==`number`?null:`The settings could not be read from the agent half yet`}function Cr(e){return e.required===!0&&e.default===void 0}function wr(e){return e.type===`secret`?e.required!==!0:!Cr(e)}function Tr(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?t:null;case`integer`:case`number`:return typeof t==`number`&&Number.isFinite(t)?String(t):``;case`string`:case`enum`:return typeof t==`string`?t:``;default:return``}}function Er(e){let t={};for(let n of e.fields)n.type!==`secret`&&(t[n.key]=Tr(n,e.values?.[n.key]));return t}function Dr(e,t){let n=e.values?.[t];return typeof n==`object`&&n&&n.set===!0?{set:!0,setAt:typeof n.setAt==`string`?n.setAt:null}:{set:!1,setAt:null}}function Or(e){let t={};for(let n of e.fields)n.type===`secret`&&(t[n.key]=Dr(e,n.key).set?`keep`:`replace`);return t}function kr(e){if(!e.set)return`Not set`;if(!e.setAt)return`Set`;let t=new Date(e.setAt);return Number.isNaN(t.getTime())?`Set`:`Set on ${t.toLocaleString()}`}function Ar(e){return e.type===`integer`?`Must be an integer`:`Must be a number`}function jr(e,t){return e.min!==void 0&&t<e.min?`Must be at least ${e.min}`:e.max!==void 0&&t>e.max?`Must be at most ${e.max}`:null}function Mr(e,t){if(e.pattern===void 0)return!0;let n;try{n=new RegExp(e.pattern,`u`)}catch{return!0}return n.test(t)}function Nr(e,t,{badInput:n=!1}={}){switch(e.type){case`string`:{let n=typeof t==`string`?t:``;if(n===``)return{ok:!0,value:null};let r=e.maxLength??1024;return n.length>r?{ok:!1,message:`Must be at most ${r} characters`}:Mr(e,n)?{ok:!0,value:n}:{ok:!1,message:`Does not match the required format`}}case`integer`:case`number`:{if(n)return{ok:!1,message:Ar(e)};let r=typeof t==`string`?t.trim():``;if(r===``)return{ok:!0,value:null};let i=Number(r);if(!(e.type===`integer`?Number.isSafeInteger(i):Number.isFinite(i)))return{ok:!1,message:Ar(e)};let a=jr(e,i);return a?{ok:!1,message:a}:{ok:!0,value:i}}case`boolean`:return{ok:!0,value:typeof t==`boolean`?t:null};case`enum`:{let n=typeof t==`string`?t:``;return n===``?{ok:!0,value:null}:(e.options??[]).some(e=>e.value===n)?{ok:!0,value:n}:{ok:!1,message:`Must be one of the options`}}default:return{ok:!1,message:`Cannot be set in this form`}}}function Pr(e,t,n,{badInput:r=!1}={}){if(n===void 0)return!1;if(e.type===`integer`||e.type===`number`){if(r)return!0;let e=typeof t==`string`?t.trim():``,i=typeof n==`string`?n.trim():``;if(e===``||i===``)return e!==i;let a=Number(e),o=Number(i);return Number.isNaN(a)||Number.isNaN(o)?e!==i:a!==o}return t!==n}function Fr(e){return JSON.stringify(e??[])}function Ir(e,t){let n=Er(e),r=[];for(let i of e.fields){let e=i.key;if(i.type===`secret`){let n=t.secretActions[e];(n===`clear`||n===`replace`&&t.secretFilled?.[e]===!0)&&r.push(e)}else Pr(i,n[e],t.inputs[e],{badInput:t.badInput?.[e]})&&r.push(e)}return r}function Lr(e,t){let n=Er(e),r=[],i=[],a=[];for(let o of e.fields){let e=o.key;if(o.type===`secret`){let{action:n,value:r=``}=t.secrets[e]??{action:`keep`};if(n===`clear`)wr(o)?i.push([e,null]):a.push([e,`Is required`]);else if(n===`replace`&&r!==``){let t=o.maxLength??1024;r.length>t?a.push([e,`Must be at most ${t} characters`]):i.push([e,r])}continue}let s=t.badInput?.[e]===!0;if(!Pr(o,n[e],t.inputs[e],{badInput:s}))continue;let c=Nr(o,t.inputs[e],{badInput:s});c.ok?c.value===null&&!wr(o)?a.push([e,`Is required`]):r.push([e,c.value]):a.push([e,c.message])}return a.length>0?{ok:!1,errors:Object.fromEntries(a)}:{ok:!0,body:{revision:e.revision,...r.length>0?{values:Object.fromEntries(r)}:{},...i.length>0?{secrets:Object.fromEntries(i)}:{}},changed:[...r,...i].map(([e])=>e)}}function Rr(e){if(typeof e!=`object`||!e)return null;let t=e.errors;if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=Object.entries(t).filter(([,e])=>typeof e==`string`);return n.length>0?Object.fromEntries(n):null}function zr(e,t){return e.source===`live`?`Read from the agent half`:e.source===`cache`?e.syncedAt?`From the relay's copy, synced from the agent half ${_r(e.syncedAt,t)}`:`From the relay's copy`:`Never synced from the agent half — showing the defaults`}var Br=/key|token|secret|password|passwd|credential/i;function Vr(e){return e.type===`string`?Br.test(e.key)||Br.test(e.label??``):!1}function Hr(e){try{return typeof e?.supports==`function`&&e.supports(`-webkit-text-security`,`disc`)}catch{return!1}}function Ur(e){let t=e.type;if((e.type===`integer`||e.type===`number`)&&(e.min!==void 0&&e.max!==void 0?t+=` ${e.min}–${e.max}`:e.min===void 0?e.max!==void 0&&(t+=` ≤ ${e.max}`):t+=` ≥ ${e.min}`),e.type===`enum`){let n=(e.options??[]).map(e=>e.value);t+=`: ${n.length>5?`${n.slice(0,5).join(` | `)} | …`:n.join(` | `)}`}return e.required?`${t}, required`:t}function Wr(e){if(!e||typeof e!=`object`)return null;let t=e=>Array.isArray(e)?e:[],n=e=>e&&typeof e==`object`?`${e.key} (${e.type})`:String(e),r=[{label:`added`,entries:t(e.added).map(n),note:null},{label:`removed`,entries:t(e.removed).map(n),note:`their values are dropped`},{label:`type changed`,entries:t(e.retyped).map(e=>e&&typeof e==`object`?`${e.key} (${e.from} → ${e.to})`:String(e)),note:`their values are dropped, not converted`},{label:`newly required`,entries:t(e.newRequired).map(String),note:`to be set after the update`}].filter(e=>e.entries.length>0),i=t(e.secretToPlain).map(String);return r.length===0&&i.length===0?null:{rows:r,secretToPlain:i}}var Gr=`lamaste:2fa-required`;function Kr(e,t){let n=e.error||`Request failed with status ${t}`,r=(Array.isArray(e.details?.issues)?e.details.issues:[]).filter(e=>typeof e?.message==`string`).map(e=>Array.isArray(e.path)&&e.path.length>0?`${e.path.join(`.`)}: ${e.message}`:e.message);return r.length>0?`${n}: ${[...new Set(r)].join(`; `)}`:n}async function R(e,t){let n=await fetch(e,t);if(n.status===401)try{if((await n.clone().json()).error===`2fa_required`)throw window.dispatchEvent(new CustomEvent(Gr)),Error(`2fa_required`)}catch(e){if(e.message===`2fa_required`)throw e}if(!n.ok){let e=await n.json().catch(()=>null),t=typeof e==`object`&&e?e:{},r=Rr(t);throw Object.assign(Error(Kr(t,n.status)),{status:n.status,...typeof t.code==`string`?{code:t.code}:{},...Array.isArray(t.reasons)?{reasons:t.reasons}:{},...typeof t.operationId==`string`?{operationId:t.operationId}:{},...r?{errors:r}:{}})}return n.json()}async function qr(){return R(`/api/onboarding/status`)}function Jr(){let{data:e,isLoading:t,isError:n,error:r,refetch:i}=I({queryKey:[`onboarding`,`status`],queryFn:qr,staleTime:3e4,retry:2,refetchOnWindowFocus:!0});return{status:e?.status,domain:e?.domain??null,ip:e?.ip??null,isLoading:t,isError:n,error:r,refetch:i}}var Yr=(0,g.createContext)(null);function z(){let e=(0,g.useContext)(Yr);if(!e)throw Error(`useAdminClient must be used within an AdminClientProvider`);return e}function Xr({client:e,children:t}){return(0,P.jsx)(Yr.Provider,{value:e,children:t})}var Zr=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Qr=(...e)=>e.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(` `),$r={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},ei=(0,g.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,g.createElement)(`svg`,{ref:c,...$r,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Qr(`lucide`,i),...s},[...o.map(([e,t])=>(0,g.createElement)(e,t)),...Array.isArray(a)?a:[a]])),B=(e,t)=>{let n=(0,g.forwardRef)(({className:n,...r},i)=>(0,g.createElement)(ei,{ref:i,iconNode:t,className:Qr(`lucide-${Zr(e)}`,n),...r}));return n.displayName=`${e}`,n},ti=B(`Activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),ni=B(`Archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),ri=B(`ArrowDown`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),ii=B(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ai=B(`BarChart3`,[[`path`,{d:`M3 3v18h18`,key:`1s2lah`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),oi=B(`Bell`,[[`path`,{d:`M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9`,key:`1qo2s2`}],[`path`,{d:`M10.3 21a1.94 1.94 0 0 0 3.4 0`,key:`qgo35s`}]]),si=B(`BookOpen`,[[`path`,{d:`M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z`,key:`vv98re`}],[`path`,{d:`M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z`,key:`1cyq3y`}]]),V=B(`Box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),ci=B(`CheckCheck`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),li=B(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),ui=B(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),di=B(`ChevronLeft`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),fi=B(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),pi=B(`ChevronUp`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),mi=B(`CircleAlert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),hi=B(`CircleCheckBig`,[[`path`,{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`,key:`g774vq`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),gi=B(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),_i=B(`CircleX`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),vi=B(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),yi=B(`Clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),bi=B(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),xi=B(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]),Si=B(`Database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),Ci=B(`Download`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`7 10 12 15 17 10`,key:`2ggqvy`}],[`line`,{x1:`12`,x2:`12`,y1:`15`,y2:`3`,key:`1vk2je`}]]),wi=B(`Eraser`,[[`path`,{d:`m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21`,key:`182aya`}],[`path`,{d:`M22 21H7`,key:`t4ddhn`}],[`path`,{d:`m5 11 9 9`,key:`1mo9qw`}]]),Ti=B(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Ei=B(`EyeOff`,[[`path`,{d:`M9.88 9.88a3 3 0 1 0 4.24 4.24`,key:`1jxqfv`}],[`path`,{d:`M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68`,key:`9wicm4`}],[`path`,{d:`M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61`,key:`1jreej`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),Di=B(`Eye`,[[`path`,{d:`M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z`,key:`rwhkz3`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Oi=B(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),ki=B(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),Ai=B(`Fingerprint`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]),ji=B(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Mi=B(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Ni=B(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),Pi=B(`Globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Fi=B(`HardDrive`,[[`line`,{x1:`22`,x2:`2`,y1:`12`,y2:`12`,key:`1y58io`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}],[`line`,{x1:`6`,x2:`6.01`,y1:`16`,y2:`16`,key:`sgf278`}],[`line`,{x1:`10`,x2:`10.01`,y1:`16`,y2:`16`,key:`1l4acy`}]]),Ii=B(`Heart`,[[`path`,{d:`M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z`,key:`c3ymky`}]]),Li=B(`Home`,[[`path`,{d:`m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`y5dka4`}],[`polyline`,{points:`9 22 9 12 15 12 15 22`,key:`e2us08`}]]),Ri=B(`Info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),zi=B(`KeyRound`,[[`path`,{d:`M2 18v3c0 .6.4 1 1 1h4v-3h3v-3h2l1.4-1.4a6.5 6.5 0 1 0-4-4Z`,key:`167ctg`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Bi=B(`Key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),Vi=B(`Layers`,[[`path`,{d:`m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z`,key:`8b97xw`}],[`path`,{d:`m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65`,key:`dd6zsq`}],[`path`,{d:`m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65`,key:`ep9fru`}]]),Hi=B(`LayoutDashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),Ui=B(`Link2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Wi=B(`Link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),Gi=B(`List`,[[`line`,{x1:`8`,x2:`21`,y1:`6`,y2:`6`,key:`7ey8pc`}],[`line`,{x1:`8`,x2:`21`,y1:`12`,y2:`12`,key:`rjfblc`}],[`line`,{x1:`8`,x2:`21`,y1:`18`,y2:`18`,key:`c3b1m8`}],[`line`,{x1:`3`,x2:`3.01`,y1:`6`,y2:`6`,key:`1g7gq3`}],[`line`,{x1:`3`,x2:`3.01`,y1:`12`,y2:`12`,key:`1pjlvk`}],[`line`,{x1:`3`,x2:`3.01`,y1:`18`,y2:`18`,key:`28t2mc`}]]),H=B(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),U=B(`LockOpen`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]]),W=B(`Lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Ki=B(`Mail`,[[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}]]),qi=B(`Map`,[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]),Ji=B(`Menu`,[[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}],[`line`,{x1:`4`,x2:`20`,y1:`6`,y2:`6`,key:`1owob3`}],[`line`,{x1:`4`,x2:`20`,y1:`18`,y2:`18`,key:`yk5zj1`}]]),Yi=B(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Xi=B(`Network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),Zi=B(`Package`,[[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),Qi=B(`Pencil`,[[`path`,{d:`M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z`,key:`5qss01`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),$i=B(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),ea=B(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),ta=B(`PowerOff`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),na=B(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),ra=B(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),ia=B(`RotateCcw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),aa=B(`RotateCw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),oa=B(`Save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),sa=B(`ScrollText`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),ca=B(`ServerOff`,[[`path`,{d:`M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5`,key:`bt2siv`}],[`path`,{d:`M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z`,key:`1hjrv1`}],[`path`,{d:`M22 17v-1a2 2 0 0 0-2-2h-1`,key:`1iynyr`}],[`path`,{d:`M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z`,key:`161ggg`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),la=B(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),ua=B(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),da=B(`Settings`,[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),fa=B(`ShieldAlert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),pa=B(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ma=B(`Shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),ha=B(`SlidersHorizontal`,[[`line`,{x1:`21`,x2:`14`,y1:`4`,y2:`4`,key:`obuewd`}],[`line`,{x1:`10`,x2:`3`,y1:`4`,y2:`4`,key:`1q6298`}],[`line`,{x1:`21`,x2:`12`,y1:`12`,y2:`12`,key:`1iu8h1`}],[`line`,{x1:`8`,x2:`3`,y1:`12`,y2:`12`,key:`ntss68`}],[`line`,{x1:`21`,x2:`16`,y1:`20`,y2:`20`,key:`14d8ph`}],[`line`,{x1:`12`,x2:`3`,y1:`20`,y2:`20`,key:`m0wm8r`}],[`line`,{x1:`14`,x2:`14`,y1:`2`,y2:`6`,key:`14e1ph`}],[`line`,{x1:`8`,x2:`8`,y1:`10`,y2:`14`,key:`1i6ji0`}],[`line`,{x1:`16`,x2:`16`,y1:`18`,y2:`22`,key:`1lctlv`}]]),ga=B(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),_a=B(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),va=B(`Ticket`,[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]),ya=B(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),ba=B(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),xa=B(`Truck`,[[`path`,{d:`M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2`,key:`wrbu53`}],[`path`,{d:`M15 18H9`,key:`1lyqi6`}],[`path`,{d:`M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14`,key:`lysw3i`}],[`circle`,{cx:`17`,cy:`18`,r:`2`,key:`332jqn`}],[`circle`,{cx:`7`,cy:`18`,r:`2`,key:`19iecd`}]]),Sa=B(`Undo2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5v0a5.5 5.5 0 0 1-5.5 5.5H11`,key:`llx8ln`}]]),Ca=B(`Unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),wa=B(`Upload`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`17 8 12 3 7 8`,key:`t8dd8p`}],[`line`,{x1:`12`,x2:`12`,y1:`3`,y2:`15`,key:`widbto`}]]),Ta=B(`UserCheck`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`polyline`,{points:`16 11 18 13 22 9`,key:`1pwet4`}]]),Ea=B(`UserPlus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),Da=B(`UserX`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`17`,x2:`22`,y1:`8`,y2:`13`,key:`3nzzx3`}],[`line`,{x1:`22`,x2:`17`,y1:`8`,y2:`13`,key:`1swrse`}]]),Oa=B(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),ka=B(`UsersRound`,[[`path`,{d:`M18 21a8 8 0 0 0-16 0`,key:`3ypg7q`}],[`circle`,{cx:`10`,cy:`8`,r:`5`,key:`o932ke`}],[`path`,{d:`M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3`,key:`10s06x`}]]),Aa=B(`Users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`path`,{d:`M16 3.13a4 4 0 0 1 0 7.75`,key:`1da9ce`}]]),ja=B(`WifiOff`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ma=B(`Wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),Na=B(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),Pa=B(`Zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]);function Fa({onVerified:e}){let t=z(),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(!1),c=(0,g.useRef)(null);(0,g.useEffect)(()=>{c.current?.focus()},[]);function l(e){r(e.target.value.replace(/\D/g,``).slice(0,6)),a(``)}async function u(i){if(i.preventDefault(),n.length!==6){a(`Enter a 6-digit code`);return}s(!0),a(``);try{(await t.verify2fa(n)).verified?e():a(`Verification failed. Please try again.`)}catch(e){let t=e?.message||String(e);a(t===`2fa_required`?`Session expired`:t||`Verification failed`)}finally{s(!1),r(``)}}return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,P.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg bg-zinc-800 p-6 shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,P.jsx)(pa,{className:`h-6 w-6 text-cyan-400`}),(0,P.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:`Two-Factor Authentication`})]}),(0,P.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Enter the 6-digit code from your authenticator app to continue.`}),(0,P.jsxs)(`form`,{onSubmit:u,className:`space-y-4`,children:[(0,P.jsx)(`input`,{ref:c,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,value:n,onChange:l,placeholder:`000000`,maxLength:6,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-4 py-3 text-center font-mono text-2xl tracking-[0.3em] text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`}),i&&(0,P.jsx)(`p`,{className:`text-sm text-red-400`,children:i}),(0,P.jsx)(`button`,{type:`submit`,disabled:o||n.length!==6,className:`w-full rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:o?`Verifying...`:`Verify`})]}),(0,P.jsxs)(`p`,{className:`mt-4 text-xs text-zinc-600`,children:[`Lost your authenticator? Run`,` `,(0,P.jsx)(`code`,{className:`text-zinc-500`,children:`sudo lamaste-reset-admin`}),` on the server.`]})]})})}var Ia=(0,g.createContext)(null),La=`lamaste:2fa-required`;function Ra({children:e}){let t=z(),n=F(),[r,i]=(0,g.useState)(!1),{data:a}=I({queryKey:[`settings-2fa`],queryFn:()=>t.get2faStatus(),staleTime:6e4,retry:!1}),o=a?.enabled??!1,s=(0,g.useCallback)(()=>{i(!0)},[]),c=(0,g.useCallback)(()=>{i(!1),n.invalidateQueries()},[n]);return(0,g.useEffect)(()=>{function e(){i(!0)}if(typeof window<`u`)return window.addEventListener(La,e),()=>window.removeEventListener(La,e)},[]),(0,P.jsxs)(Ia.Provider,{value:{is2faEnabled:o,is2faRequired:r,require2fa:s,clearRequirement:c},children:[e,r&&(0,P.jsx)(Fa,{onVerified:c})]})}var za=(0,g.createContext)(null);function G(){let e=(0,g.useContext)(za);if(!e)throw Error(`useToast must be used within a ToastProvider`);return e}var Ba=0;function Va({children:e}){let[t,n]=(0,g.useState)([]),r=(0,g.useCallback)((e,t=`success`)=>{let r=++Ba;n(n=>[...n,{id:r,message:e,variant:t}]),setTimeout(()=>{n(e=>e.filter(e=>e.id!==r))},3e3)},[]),i=(0,g.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return(0,P.jsxs)(za.Provider,{value:r,children:[e,(0,P.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:t.map(e=>(0,P.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border px-4 py-3 text-sm font-mono shadow-lg ${e.variant===`error`?`bg-red-500/10 border-red-500/20 text-red-400`:`bg-green-500/10 border-green-500/20 text-green-400`}`,children:[(0,P.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),className:`text-zinc-500 hover:text-zinc-300`,children:(0,P.jsx)(Na,{size:14})})]},e.id))})]})}function Ha(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&e.id!==``&&typeof e.secret==`string`&&e.secret!==``).map(({id:e,secret:t})=>({id:e,secret:t})):[]}function Ua(e){if(typeof e!=`object`||!e)return{result:e,secrets:[]};let{oidcClients:t,...n}=e;return{result:n,secrets:Ha(t)}}function Wa(e,t){return e.status===`running`?null:t===`reading`?`reading`:e.revealPending===!0?t===`followed`?`read`:`offer`:t===`followed`?`forget`:null}function Ga(e,t){return e?.operations?{...e,operations:e.operations.map(e=>e.id===t?{...e,revealPending:!1}:e)}:e}var Ka={next:1,queue:[]};function qa(e,t){switch(t.type){case`reveal`:{let n=Ha(t.secrets);if(n.length===0)return e;let r={key:e.next,plugin:t.plugin,cause:t.cause,secrets:n};return{next:e.next+1,queue:[...e.queue,r]}}case`acknowledge`:return e.queue[0]?.key===t.key?{...e,queue:e.queue.slice(1)}:e;default:return e}}var Ja={install:`Installing`,enable:`Enabling`,update:`Updating`};function Ya({plugin:e,cause:t,secrets:n}){let r=n.length===1?`a confidential OIDC client`:`${n.length} confidential OIDC clients`,i=Ja[t];return i?`${i} ${e} created ${r}`:`An operation on ${e} created ${r}`}var Xa=(0,g.createContext)(null);function Za(){let e=(0,g.useContext)(Xa);if(!e)throw Error(`useOidcSecretReveal must be used within an OidcSecretRevealProvider`);return e}function Qa({children:e}){let[t,n]=(0,g.useReducer)(qa,Ka),[r,i]=(0,g.useState)(()=>new Map),a=(0,g.useRef)(new Set),o=(0,g.useCallback)(({plugin:e,cause:t,secrets:r})=>n({type:`reveal`,plugin:e,cause:t,secrets:r}),[]),s=(0,g.useCallback)(e=>i(t=>new Map(t).set(e,`followed`)),[]),c=(0,g.useCallback)(e=>a.current.has(e)?!1:(a.current.add(e),i(t=>new Map(t).set(e,`reading`)),!0),[]),l=(0,g.useCallback)(e=>{a.current.delete(e),i(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),u=(0,g.useCallback)(e=>r.get(e),[r]),d=(0,g.useMemo)(()=>({reveal:o,followOperation:s,followState:u,claimOperation:c,releaseOperation:l}),[o,s,u,c,l]),f=t.queue[0]??null;return(0,g.useEffect)(()=>{if(!f)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[f]),(0,P.jsxs)(Xa.Provider,{value:d,children:[e,f&&(0,P.jsx)(eo,{reveal:f,waiting:t.queue.length-1,onAcknowledge:()=>n({type:`acknowledge`,key:f.key})},f.key)]})}var $a=`button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`;function eo({reveal:e,waiting:t,onAcknowledge:n}){let[r,i]=(0,g.useState)(!1),a=(0,g.useRef)(null),o=(0,g.useId)(),s=(0,g.useId)(),c=e.secrets.length===1;return(0,g.useEffect)(()=>{a.current?.focus()},[]),(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,P.jsxs)(`div`,{ref:a,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":o,"aria-describedby":s,tabIndex:-1,onKeyDown:e=>{if(e.key!==`Tab`||!a.current)return;let t=[...a.current.querySelectorAll($a)];if(t.length===0)return;let n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&(i===n||i===a.current)?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())},className:`flex max-h-full w-full max-w-lg flex-col rounded-lg border border-zinc-800 bg-zinc-900 shadow-xl focus:outline-none`,children:[(0,P.jsxs)(`div`,{className:`border-b border-zinc-800 px-6 py-4`,children:[(0,P.jsxs)(`h3`,{id:o,className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[(0,P.jsx)(zi,{size:20,className:`text-cyan-400`}),c?`Client secret`:`Client secrets`,` — shown once`]}),(0,P.jsxs)(`p`,{className:`mt-1 text-sm text-zinc-400`,children:[Ya(e),`.`]})]}),(0,P.jsxs)(`div`,{className:`space-y-5 overflow-y-auto px-6 py-5`,children:[(0,P.jsxs)(`div`,{id:s,className:`space-y-1 rounded-lg border border-amber-500/20 bg-amber-500/10 p-4 text-sm text-amber-400`,children:[(0,P.jsxs)(`p`,{className:`font-semibold`,children:[`Store `,c?`this secret`:`these secrets`,` now — Lamaste never shows`,` `,c?`it`:`them`,` again.`]}),(0,P.jsxs)(`p`,{children:[`Copy `,c?`it`:`each one`,` into the application that authenticates with`,` `,c?`it`:`them`,`, or into your password manager. A secret that was not stored can only be replaced:`,` `,(0,P.jsx)(`code`,{className:`font-mono text-xs text-amber-300`,children:`lamaste-server plugins rotate-secret <plugin> <client id>`})]})]}),e.secrets.map(({id:e,secret:t})=>(0,P.jsx)(to,{clientId:e,secret:t},e)),(0,P.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-zinc-300`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked),className:`accent-cyan-500`}),`I have stored `,c?`this secret`:`these secrets`]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,P.jsx)(`span`,{className:`text-xs text-zinc-500`,children:t>0&&`${t} more to show after this`}),(0,P.jsx)(`button`,{type:`button`,disabled:!r,onClick:n,className:`rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:cursor-not-allowed disabled:opacity-50`,children:`Done`})]})]})]})})}function to({clientId:e,secret:t}){let[n,r]=(0,g.useState)(`idle`),i=(0,g.useRef)(null),a=(0,g.useRef)(null);return(0,g.useEffect)(()=>()=>clearTimeout(a.current),[]),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`mb-1 flex items-baseline gap-2 text-sm`,children:[(0,P.jsx)(`span`,{className:`shrink-0 text-zinc-500`,children:`Client ID`}),(0,P.jsx)(`span`,{className:`select-all break-all font-mono text-zinc-200`,children:e})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{ref:i,className:`flex-1 select-all break-all rounded border border-zinc-700 bg-zinc-950 p-3 font-mono text-sm text-yellow-400`,children:t}),(0,P.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(t),r(`copied`),clearTimeout(a.current),a.current=setTimeout(()=>r(`idle`),2e3)}catch{let e=document.createRange();e.selectNodeContents(i.current);let t=window.getSelection();t.removeAllRanges(),t.addRange(e),r(`failed`)}},title:`Copy the secret`,"aria-label":`Copy the secret of ${e}`,className:`shrink-0 rounded bg-zinc-700 p-2 text-zinc-300 hover:bg-zinc-600`,children:n===`copied`?(0,P.jsx)(li,{size:16,className:`text-green-400`}):(0,P.jsx)(bi,{size:16})})]}),n===`failed`&&(0,P.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:`Copying is not available here — the secret is selected; copy it with ⌘C or Ctrl+C.`})]})}function no(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function ro(e){return new Date(e).toLocaleString()}function io({currentPath:e,onNavigate:t}){let n=e===`.`?[]:e.split(`/`);return(0,P.jsxs)(`div`,{className:`flex items-center gap-1 text-sm text-zinc-400 overflow-x-auto`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(`.`),className:`flex items-center gap-1 hover:text-cyan-400 shrink-0`,children:(0,P.jsx)(Li,{size:14})}),n.map((e,r)=>{let i=n.slice(0,r+1).join(`/`),a=r===n.length-1;return(0,P.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0`,children:[(0,P.jsx)(fi,{size:12,className:`text-zinc-600`}),a?(0,P.jsx)(`span`,{className:`text-zinc-200`,children:e}):(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(i),className:`hover:text-cyan-400`,children:e})]},i)})]})}function ao({fileName:e,onConfirm:t,onCancel:n,isPending:r}){return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:`Delete File`}),(0,P.jsxs)(`p`,{className:`text-zinc-400 text-sm mb-6`,children:[`Are you sure you want to delete`,` `,(0,P.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:e}),`?`]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,onClick:t,disabled:r,className:`flex items-center gap-2 rounded bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-500 disabled:opacity-50`,children:r?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:14,className:`animate-spin`}),`Deleting...`]}):`Delete`})]})]})})}function oo({site:e,onBack:t}){let n=z(),r=F(),i=G(),a=(0,g.useRef)(null),[o,s]=(0,g.useState)(`.`),[c,l]=(0,g.useState)(null),u=I({queryKey:[`site-files`,e.id,o],queryFn:()=>n.getSiteFiles(e.id,o),refetchInterval:5e3}),d=L({mutationFn:({files:t})=>n.uploadSiteFiles(e.id,o,t),onSuccess:t=>{r.invalidateQueries({queryKey:[`site-files`,e.id]}),r.invalidateQueries({queryKey:[`sites`]});let n=t?.files?.length??0;i(t?.warning?`${n} file(s) uploaded. ${t.warning}`:`${n} file(s) uploaded`)},onError:e=>{i(e?.message||String(e),`error`)}}),f=L({mutationFn:t=>n.deleteSiteFile(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`site-files`,e.id]}),r.invalidateQueries({queryKey:[`sites`]}),i(`File deleted`),l(null)},onError:e=>{i(e?.message||String(e),`error`),l(null)}}),p=(0,g.useCallback)(e=>{s(e)},[]),m=(0,g.useCallback)(e=>{e.type===`directory`&&s(e.relativePath)},[]),h=(0,g.useCallback)(()=>{a.current?.click()},[]),_=(0,g.useCallback)(e=>{let t=Array.from(e.target.files||[]);t.length>0&&d.mutate({files:t}),e.target.value=``},[d]),v=u.data?.files||[];return(0,P.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,P.jsxs)(`div`,{className:`mb-6`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 text-sm text-zinc-400 hover:text-zinc-200 mb-3`,children:[(0,P.jsx)(ii,{size:14}),`Back to Sites`]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`h1`,{className:`text-xl font-bold text-white`,children:[e.name,(0,P.jsx)(`span`,{className:`text-zinc-500 font-normal ml-2 text-base`,children:`Files`})]}),(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1 font-mono`,children:e.fqdn})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`input`,{ref:a,type:`file`,multiple:!0,onChange:_,className:`hidden`}),(0,P.jsx)(`button`,{type:`button`,onClick:h,disabled:d.isPending,className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:d.isPending?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:14,className:`animate-spin`}),`Uploading...`]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(wa,{size:14}),`Upload`]})})]})]})]}),(0,P.jsx)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-t-lg px-4 py-3`,children:(0,P.jsx)(io,{currentPath:o,onNavigate:p})}),u.isLoading?(0,P.jsx)(`div`,{className:`bg-zinc-900 border border-t-0 border-zinc-800 rounded-b-lg p-8 text-center`,children:(0,P.jsx)(H,{size:24,className:`mx-auto text-zinc-500 animate-spin`})}):u.isError?(0,P.jsx)(`div`,{className:`bg-zinc-900 border border-t-0 border-zinc-800 rounded-b-lg p-6`,children:(0,P.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load files`})}):v.length===0?(0,P.jsx)(`div`,{className:`bg-zinc-900 border border-t-0 border-zinc-800 rounded-b-lg p-8 text-center`,children:(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm`,children:`This directory is empty.`})}):(0,P.jsx)(`div`,{className:`bg-zinc-900 border border-t-0 border-zinc-800 rounded-b-lg overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-800`,children:[(0,P.jsx)(`th`,{className:`text-left text-zinc-500 text-xs uppercase font-semibold py-2 px-4`,children:`Name`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-500 text-xs uppercase font-semibold py-2 px-4 hidden sm:table-cell`,children:`Size`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-500 text-xs uppercase font-semibold py-2 px-4 hidden md:table-cell`,children:`Modified`}),(0,P.jsx)(`th`,{className:`text-right text-zinc-500 text-xs uppercase font-semibold py-2 px-4 w-16`})]})}),(0,P.jsx)(`tbody`,{children:v.map(e=>(0,P.jsxs)(`tr`,{className:`border-b border-zinc-800/50 ${e.type===`directory`?`cursor-pointer hover:bg-zinc-800/50`:``}`,onClick:()=>m(e),children:[(0,P.jsx)(`td`,{className:`py-2.5 px-4 text-sm`,children:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e.type===`directory`?(0,P.jsx)(Mi,{size:14,className:`text-cyan-400 shrink-0`}):(0,P.jsx)(ki,{size:14,className:`text-zinc-500 shrink-0`}),(0,P.jsx)(`span`,{className:`font-mono ${e.type===`directory`?`text-cyan-400`:`text-zinc-200`}`,children:e.name})]})}),(0,P.jsx)(`td`,{className:`py-2.5 px-4 text-sm text-zinc-500 font-mono hidden sm:table-cell`,children:e.type===`file`?no(e.size):`—`}),(0,P.jsx)(`td`,{className:`py-2.5 px-4 text-sm text-zinc-600 hidden md:table-cell`,children:ro(e.modifiedAt)}),(0,P.jsx)(`td`,{className:`py-2.5 px-4 text-right`,children:(0,P.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),l(e)},className:`inline-flex items-center p-1 text-zinc-600 hover:text-red-400`,title:`Delete`,children:(0,P.jsx)(ya,{size:14})})})]},e.relativePath))})]})}),c&&(0,P.jsx)(ao,{fileName:c.name,onConfirm:()=>f.mutate(c.relativePath),onCancel:()=>l(null),isPending:f.isPending})]})}var so={bg:`zinc-950`,card:`zinc-900`,accent:`cyan-400`,border:`zinc-800`},co=1e4,lo=3e4;function uo(e,t){e.textContent=``;let n=document.createElement(`div`);n.className=`flex items-center justify-center h-64`;let r=document.createElement(`p`);r.className=`text-zinc-500 text-sm`,r.textContent=t,n.appendChild(r),e.appendChild(n)}function fo(e,t){return e?.plugins?.find(e=>e.name===t)}function po({availability:e}){return(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsxs)(`div`,{className:`flex items-start gap-3`,children:[e.state===`offline`?(0,P.jsx)(ja,{size:18,className:`mt-0.5 shrink-0 text-red-400`}):(0,P.jsx)(ca,{size:18,className:`mt-0.5 shrink-0 text-zinc-500`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-sm text-zinc-200`,children:e.message}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:`Its pages come from its agent half. This page checks every 10 seconds and opens them once the hosting is up.`})]})]})})}function mo({pluginName:e,subPath:t=``,basePath:n,panelUrl:r}){let i=z(),a=(0,g.useRef)(null),o=I({queryKey:[`plugins`],queryFn:()=>i.getPlugins(),refetchInterval:t=>xr(fo(t.state.data,e),Date.now()).state===`mount`?lo:co}),s=o.data?xr(fo(o.data,e),o.dataUpdatedAt):o.isError?{state:`mount`}:{state:`checking`},[c,l]=(0,g.useState)(null);s.state===`mount`&&c!==e&&l(e);let u=s.state===`mount`||c===e;return(0,g.useEffect)(()=>{let o=a.current;if(!e||!u||!o)return;let s=!1,c=null,l=()=>{let i=window.__lamalibrePlugins?.[e];if(!i||typeof i.mount!=`function`)throw Error(`The plugin bundle registered no panel`);o.textContent=``;let a=i.mount({mountPoint:o,panelUrl:r||window.location.origin,basePath:n||`/plugins/${e}`,subPath:t||``,theme:so});a&&typeof a.unmount==`function`?c=a.unmount:typeof a==`function`&&(c=a)},d=()=>{s||uo(o,`Failed to load plugin panel for "${e}"`)};if(window.__lamalibrePlugins?.[e])try{l()}catch{d()}else uo(o,`Loading plugin...`),i.fetchPluginBundle(e).then(e=>{if(!s)try{window.__lamalibrePlugins||(window.__lamalibrePlugins={}),Function(e)(),l()}catch{d()}},d);return()=>{s=!0,c&&c()}},[e,t,n,r,i,u]),(0,P.jsxs)(`div`,{className:`p-6 max-w-6xl mx-auto`,children:[!u&&s.state===`checking`&&(0,P.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm`,children:`Loading plugin...`})}),!u&&(s.state===`offline`||s.state===`waiting`)&&(0,P.jsx)(po,{availability:s}),u&&(s.state===`offline`||s.state===`waiting`)&&(0,P.jsxs)(`div`,{className:`mb-4 flex items-start gap-2 rounded border px-3 py-2 text-xs ${s.state===`offline`?`border-red-500/30 text-red-400`:`border-zinc-700 text-zinc-400`}`,children:[(0,P.jsx)(ja,{size:12,className:`mt-0.5 shrink-0`}),(0,P.jsxs)(`span`,{children:[s.message,` — this page cannot reach its agent half until the hosting is up again.`]})]}),u&&(0,P.jsx)(`div`,{ref:a,className:`min-h-64`,"data-plugin":e})]})}function ho({icon:e,label:t,value:n,isLoading:r,isError:i}){return(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:[(0,P.jsx)(e,{size:20,className:`text-cyan-400 mb-2`}),(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm mb-1`,children:t}),r?(0,P.jsx)(`div`,{className:`h-7 w-24 animate-pulse rounded bg-zinc-700`}):i?(0,P.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Error`}):(0,P.jsx)(`p`,{className:`text-xl font-semibold text-white`,children:n})]})}function go({status:e}){return(0,P.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full ${e===`active`?`bg-green-500`:e===`failed`?`bg-red-500`:`bg-zinc-500`}`})}function _o(){let e=z(),t=I({queryKey:[`system-stats`],queryFn:()=>e.getSystemStats(),refetchInterval:5e3}),n=I({queryKey:[`services`],queryFn:()=>e.getServices(),refetchInterval:5e3}),r=t.data,i=n.data?.services;return(0,P.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,P.jsxs)(`div`,{className:`mb-6`,children:[(0,P.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Dashboard`}),(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`System overview and service health`})]}),(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 mb-8`,children:[(0,P.jsx)(ho,{icon:xi,label:`CPU Usage`,value:r?`${r.cpu.usage}%`:`—`,isLoading:t.isLoading,isError:t.isError}),(0,P.jsx)(ho,{icon:Si,label:`Memory Usage`,value:r?`${mr(r.memory.used)} / ${mr(r.memory.total)}`:`—`,isLoading:t.isLoading,isError:t.isError}),(0,P.jsx)(ho,{icon:Fi,label:`Disk Usage`,value:r?`${mr(r.disk.used)} / ${mr(r.disk.total)}`:`—`,isLoading:t.isLoading,isError:t.isError}),(0,P.jsx)(ho,{icon:yi,label:`Uptime`,value:r?hr(r.uptime):`—`,isLoading:t.isLoading,isError:t.isError})]}),(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6 mb-8`,children:[(0,P.jsxs)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4 flex items-center gap-2`,children:[(0,P.jsx)(ti,{size:14,className:`text-cyan-400`}),`Service Health`]}),n.isLoading?(0,P.jsx)(`div`,{className:`flex gap-6 flex-wrap`,children:Array.from({length:4}).map((e,t)=>(0,P.jsx)(`div`,{className:`h-5 w-28 animate-pulse rounded bg-zinc-700`},t))}):n.isError?(0,P.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load service status`}):(0,P.jsx)(`div`,{className:`flex gap-6 flex-wrap`,children:i?.map(e=>(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(go,{status:e.status}),(0,P.jsx)(`span`,{className:`text-zinc-300 text-sm`,children:e.name})]},e.name))})]}),(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:[(0,P.jsxs)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4 flex items-center gap-2`,children:[(0,P.jsx)(ti,{size:14,className:`text-cyan-400`}),`Quick Overview`]}),(0,P.jsxs)(`div`,{className:`flex gap-8 flex-wrap text-sm`,children:[(0,P.jsxs)(`div`,{className:`text-zinc-400`,children:[`Active Services:`,` `,(0,P.jsx)(`span`,{className:`text-white`,children:i?i.filter(e=>e.status===`active`).length:`—`})]}),(0,P.jsxs)(`div`,{className:`text-zinc-400`,children:[`Total Services: `,(0,P.jsx)(`span`,{className:`text-white`,children:i?i.length:`—`})]})]})]})]})}function K(e){return typeof e==`string`?e||`An unknown error occurred`:e instanceof Error?e.message||`An unknown error occurred`:String(e??`An unknown error occurred`)||`An unknown error occurred`}function vo(e){return typeof e!=`object`||!e?{code:null,reasons:[]}:{code:typeof e.code==`string`?e.code:null,reasons:Array.isArray(e.reasons)?e.reasons.filter(e=>typeof e==`string`):[]}}function yo({status:e}){let t=e===`active`?`bg-green-500/20 text-green-400`:e===`failed`?`bg-red-500/20 text-red-400`:`bg-zinc-500/20 text-zinc-400`,n=e===`active`?`Active`:e===`failed`?`Failed`:e===`inactive`?`Inactive`:`Unknown`;return(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${t}`,children:n})}function bo({service:e,onAction:t,isActing:n}){let[r,i]=(0,g.useState)(!1),a=e.name===`lamalibre-lamaste-serverd`,o=()=>{if(!a){if(!r){i(!0);return}i(!1),t(e.name,`stop`)}};return(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(la,{size:16,className:`text-cyan-400`}),(0,P.jsx)(`span`,{className:`text-white font-semibold`,children:e.name})]}),(0,P.jsx)(yo,{status:e.status})]}),(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm mb-4`,children:e.status===`active`&&e.uptime?`Uptime: ${e.uptime}`:`—`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>t(e.name,`start`),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,P.jsx)($i,{size:12}),`Start`]}),r?(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-zinc-400`,children:`Stop?`}),(0,P.jsx)(`button`,{type:`button`,onClick:o,className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500`,children:`Yes`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>i(!1),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`})]}):(0,P.jsxs)(`button`,{type:`button`,disabled:n||a,onClick:o,title:a?`Cannot stop panel service`:`Stop service`,className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,P.jsx)(ga,{size:12}),`Stop`]}),(0,P.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>t(e.name,`restart`),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,P.jsx)(aa,{size:12}),`Restart`]})]})]})}var xo=1e3;function So({services:e}){let t=z(),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)([]),[o,s]=(0,g.useState)(null),c=(0,g.useRef)(null),l=(0,g.useRef)(null),u=(0,g.useCallback)(e=>{r(e.target.value),a([]),s(null)},[]);(0,g.useEffect)(()=>{let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[i]),(0,g.useEffect)(()=>{if(l.current&&=(l.current(),null),n)return l.current=t.startLogStream(n,e=>{a(t=>{let n=[...t,e];return n.length>xo?n.slice(-xo):n})}),()=>{l.current&&=(l.current(),null)}},[n,t]);let d=e?.map(e=>e.name)||[];return(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4`,children:`Service Logs`}),(0,P.jsxs)(`select`,{value:n,onChange:u,className:`mb-4 rounded bg-zinc-800 border border-zinc-700 px-3 py-1.5 text-sm text-zinc-300 focus:outline-none focus:border-cyan-400`,children:[(0,P.jsx)(`option`,{value:``,children:`Select a service...`}),d.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]}),(0,P.jsx)(`div`,{ref:c,className:`h-96 overflow-y-auto rounded-lg border border-zinc-800 bg-zinc-950 p-4 font-mono text-sm`,children:n?o?(0,P.jsx)(`p`,{className:`text-red-400`,children:o}):i.length===0?(0,P.jsx)(`p`,{className:`text-zinc-500 text-center mt-36`,children:`Waiting for log data...`}):i.map((e,t)=>(0,P.jsxs)(`div`,{className:`leading-relaxed`,children:[e.timestamp&&(0,P.jsxs)(`span`,{className:`text-zinc-500`,children:[e.timestamp,` `]}),(0,P.jsx)(`span`,{className:`text-zinc-300`,children:e.message})]},t)):(0,P.jsx)(`p`,{className:`text-zinc-500 text-center mt-36`,children:`Select a service to view its logs`})})]})}function Co(){let e=z(),t=F(),n=G(),r=I({queryKey:[`services`],queryFn:()=>e.getServices(),refetchInterval:5e3}),i=L({mutationFn:({name:t,action:n})=>e.serviceAction(t,n),onSuccess:e=>{t.invalidateQueries({queryKey:[`services`]}),n(`${e.name} ${e.action}ed successfully`)},onError:e=>{n(K(e),`error`)}}),a=(0,g.useCallback)((e,t)=>{i.mutate({name:e,action:t})},[i]),o=r.data?.services;return(0,P.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,P.jsxs)(`div`,{className:`mb-6`,children:[(0,P.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Services`}),(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Manage system services and view live logs`})]}),r.isLoading?(0,P.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 mb-8`,children:Array.from({length:4}).map((e,t)=>(0,P.jsx)(`div`,{className:`h-40 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):r.isError?(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6 mb-8`,children:(0,P.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load services`})}):(0,P.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 mb-8`,children:o?.map(e=>(0,P.jsx)(bo,{service:e,onAction:a,isActing:i.isPending},e.name))}),(0,P.jsx)(So,{services:o})]})}function wo(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return a>30?new Date(e).toLocaleDateString():a>0?`${a}d ago`:i>0?`${i}h ago`:r>0?`${r}m ago`:`just now`}function To(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Eo({site:e}){return e.certIssued&&e.dnsVerified?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full border text-green-400 bg-green-500/10 border-green-500/20`,children:[(0,P.jsx)(hi,{size:10}),`Live`]}):e.type===`custom`&&!e.dnsVerified?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full border text-yellow-400 bg-yellow-500/10 border-yellow-500/20`,children:[(0,P.jsx)(yi,{size:10}),`DNS Pending`]}):(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full border text-zinc-500 bg-zinc-800 border-zinc-700`,children:[(0,P.jsx)(ba,{size:10}),`Setup Required`]})}function Do({type:e}){return(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${e===`managed`?`text-cyan-400 bg-cyan-500/10 border-cyan-500/20`:`text-purple-400 bg-purple-500/10 border-purple-500/20`}`,children:e})}var Oo=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;function ko(e){return[...new Set(e.split(/[\s,]+/).map(e=>e.trim().toLowerCase()).filter(Boolean))]}function Ao({domain:e,onClose:t}){let n=F(),r=G(),i=z(),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(`managed`),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(!1),[v,y]=(0,g.useState)({}),[b,x]=(0,g.useState)(null),S=L({mutationFn:e=>i.createSite(e),onSuccess:e=>{n.invalidateQueries({queryKey:[`sites`]}),r(`Site ${e.site.fqdn} created`),t()},onError:e=>{x(K(e))}}),C=(0,g.useCallback)(e=>{e.preventDefault(),x(null);let t={};if(a?Oo.test(a)||(t.name=`Lowercase letters, numbers, and hyphens only`):t.name=`Name is required`,s===`custom`&&!l&&(t.customDomain=`Domain is required for custom sites`),Object.keys(t).length>0){y(t);return}y({});let n={name:a,type:s,spaMode:p,autheliaProtected:h};if(s===`custom`){n.customDomain=l.toLowerCase();let e=ko(d);e.length>0&&(n.aliases=e)}S.mutate(n)},[a,s,l,d,p,h,S]);return(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-5 mb-6`,children:[(0,P.jsxs)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4 flex items-center gap-2`,children:[(0,P.jsx)(ea,{size:14,className:`text-cyan-400`}),`Add Static Site`]}),(0,P.jsxs)(`form`,{onSubmit:C,className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-2`,children:`Domain Type`}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>c(`managed`),className:`px-3 py-1.5 text-sm rounded border ${s===`managed`?`border-cyan-400 text-cyan-400 bg-cyan-500/10`:`border-zinc-700 text-zinc-400 bg-zinc-800 hover:border-zinc-600`}`,children:`Managed Subdomain`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>c(`custom`),className:`px-3 py-1.5 text-sm rounded border ${s===`custom`?`border-cyan-400 text-cyan-400 bg-cyan-500/10`:`border-zinc-700 text-zinc-400 bg-zinc-800 hover:border-zinc-600`}`,children:`Custom Domain`})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Name`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,P.jsx)(`input`,{type:`text`,value:a,onChange:e=>{o(e.target.value.toLowerCase()),y(e=>({...e,name:void 0}))},disabled:S.isPending,placeholder:`blog`,className:`flex-1 ${s===`managed`?`rounded-l`:`rounded`} bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder:text-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),s===`managed`&&(0,P.jsxs)(`span`,{className:`rounded-r bg-zinc-800/60 border border-l-0 border-zinc-700 px-3 py-2 text-sm text-zinc-500 font-mono`,children:[`.`,e]})]}),v.name&&(0,P.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:v.name})]}),s===`custom`&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Custom Domain`}),(0,P.jsx)(`input`,{type:`text`,value:l,onChange:e=>{u(e.target.value.toLowerCase()),y(e=>({...e,customDomain:void 0}))},disabled:S.isPending,placeholder:`example.com`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder:text-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),v.customDomain&&(0,P.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:v.customDomain}),(0,P.jsxs)(`label`,{className:`block text-xs text-zinc-400 mt-3 mb-1`,children:[`Redirect aliases `,(0,P.jsx)(`span`,{className:`text-zinc-600`,children:`(optional)`})]}),(0,P.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),disabled:S.isPending,placeholder:l?`www.${l}`:`www.example.com`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder:text-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),(0,P.jsx)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:`These hostnames redirect to the site and share its certificate. Each needs its own A record.`})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,P.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-zinc-400 cursor-pointer`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked),disabled:S.isPending,className:`rounded border-zinc-700 bg-zinc-800 text-cyan-400 focus:ring-cyan-400`}),`SPA Mode`,(0,P.jsx)(`span`,{className:`text-zinc-600 text-xs`,children:`(fallback to index.html)`})]}),(0,P.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-zinc-400 cursor-pointer`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>_(e.target.checked),disabled:S.isPending,className:`rounded border-zinc-700 bg-zinc-800 text-cyan-400 focus:ring-cyan-400`}),`Authelia Protected`,(0,P.jsx)(`span`,{className:`text-zinc-600 text-xs`,children:`(require login)`})]})]}),b&&(0,P.jsx)(`div`,{className:`rounded bg-red-500/10 border border-red-500/20 px-3 py-2 text-sm text-red-400`,children:b}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(`button`,{type:`submit`,disabled:S.isPending,className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed`,children:S.isPending?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:14,className:`animate-spin`}),`Creating site...`]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(ea,{size:14}),`Create Site`]})}),(0,P.jsx)(`button`,{type:`button`,onClick:t,disabled:S.isPending,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`})]})]})]})}function jo({site:e,onClose:t}){let n=F(),r=G(),i=z(),[a,o]=(0,g.useState)(null),s=L({mutationFn:()=>i.verifySiteDns(e.id),onSuccess:e=>{o(e),e.ok&&(n.invalidateQueries({queryKey:[`sites`]}),r(`DNS verified and site is now live!`))},onError:e=>{o({ok:!1,message:K(e)})}});return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-6 max-w-lg w-full mx-4 shadow-xl`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:`DNS Verification`}),(0,P.jsxs)(`p`,{className:`text-zinc-400 text-sm mb-4`,children:[`Add an A record pointing`,` `,[e.fqdn,...e.aliases||[]].map((e,t,n)=>(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:e}),t<n.length-1?`, `:``]},e)),` `,`to your server IP.`]}),(0,P.jsx)(`div`,{className:`bg-zinc-800 rounded-lg p-4 mb-4`,children:(0,P.jsx)(`table`,{className:`w-full text-sm`,children:(0,P.jsxs)(`tbody`,{children:[(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{className:`text-zinc-500 py-1 pr-4`,children:`Type`}),(0,P.jsx)(`td`,{className:`text-zinc-200 font-mono`,children:`A`})]}),(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{className:`text-zinc-500 py-1 pr-4`,children:`Name`}),(0,P.jsx)(`td`,{className:`text-zinc-200 font-mono`,children:[e.fqdn,...e.aliases||[]].join(`, `)})]}),(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{className:`text-zinc-500 py-1 pr-4`,children:`Value`}),(0,P.jsx)(`td`,{className:`text-zinc-200 font-mono`,children:`(your server IP)`})]})]})})}),a&&(0,P.jsx)(`div`,{className:`rounded px-3 py-2 text-sm mb-4 ${a.ok?`bg-green-500/10 border border-green-500/20 text-green-400`:`bg-yellow-500/10 border border-yellow-500/20 text-yellow-400`}`,children:a.message}),(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:t,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:a?.ok?`Done`:`Cancel`}),!a?.ok&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>s.mutate(),disabled:s.isPending,className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:s.isPending?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:14,className:`animate-spin`}),`Verifying...`]}):`Verify DNS`})]})]})})}function Mo({site:e,onConfirm:t,onCancel:n,isPending:r}){return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:`Delete Site`}),(0,P.jsxs)(`p`,{className:`text-zinc-400 text-sm mb-6`,children:[`Are you sure you want to delete`,` `,(0,P.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:e.fqdn}),`? This will remove all files, the nginx configuration, and certificate mapping.`]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,onClick:t,disabled:r,className:`flex items-center gap-2 rounded bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-500 disabled:opacity-50`,children:r?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:14,className:`animate-spin`}),`Deleting...`]}):`Delete`})]})]})})}function No({site:e,onClose:t}){let n=F(),r=G(),i=z(),[a,o]=(0,g.useState)(e.spaMode),[s,c]=(0,g.useState)(e.autheliaProtected),[l,u]=(0,g.useState)(e.allowedUsers||[]),[d,f]=(0,g.useState)((e.aliases||[]).join(`, `)),p=ko(d),m=JSON.stringify(p.slice().sort())!==JSON.stringify((e.aliases||[]).slice().sort()),h=I({queryKey:[`users`],queryFn:()=>i.getUsers()}),_=L({mutationFn:t=>i.updateSite(e.id,t),onSuccess:i=>{n.invalidateQueries({queryKey:[`sites`]}),r(`Site ${e.fqdn} settings updated`),i?.warning&&r(i.warning,`error`),t()},onError:e=>{r(K(e),`error`)}}),v=e.allowedUsers||[],y=a!==e.spaMode||s!==e.autheliaProtected||m||JSON.stringify(l.slice().sort())!==JSON.stringify(v.slice().sort()),b=(h.data?.users||[]).filter(e=>!l.includes(e.username)),x=e=>{u(t=>[...t,e])},S=e=>{u(t=>t.filter(t=>t!==e))};return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-1`,children:`Site Settings`}),(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm mb-5 font-mono`,children:e.fqdn}),(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`label`,{className:`flex items-center justify-between gap-3 cursor-pointer`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-sm text-zinc-200`,children:`SPA Mode`}),(0,P.jsx)(`p`,{className:`text-xs text-zinc-500 mt-0.5`,children:`Fallback to index.html for client-side routing`})]}),(0,P.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),disabled:_.isPending,className:`rounded border-zinc-700 bg-zinc-800 text-cyan-400 focus:ring-cyan-400 h-5 w-5`})]}),(0,P.jsxs)(`label`,{className:`flex items-center justify-between gap-3 cursor-pointer`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-sm text-zinc-200`,children:`Authelia Protected`}),(0,P.jsx)(`p`,{className:`text-xs text-zinc-500 mt-0.5`,children:`Require login to access this site`})]}),(0,P.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),disabled:_.isPending,className:`rounded border-zinc-700 bg-zinc-800 text-cyan-400 focus:ring-cyan-400 h-5 w-5`})]}),e.type===`custom`&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-sm text-zinc-200`,children:`Redirect aliases`}),(0,P.jsxs)(`p`,{className:`text-xs text-zinc-500 mt-0.5 mb-2`,children:[`Hostnames that redirect to `,e.fqdn,`. On a live site each new alias must already resolve to this server; the certificate is re-issued to cover it.`]}),(0,P.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),disabled:_.isPending,placeholder:`www.${e.fqdn}`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder:text-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-50`})]}),s&&(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,P.jsx)(ma,{size:14,className:`text-cyan-400`}),(0,P.jsx)(`span`,{className:`text-sm text-zinc-200`,children:`Allowed Users`})]}),(0,P.jsx)(`p`,{className:`text-xs text-zinc-500 mb-3`,children:l.length===0?`All authenticated users can access this site.`:`Only the selected users can access this site.`}),l.length>0&&(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-3`,children:l.map(e=>(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-1 rounded-full border border-cyan-500/20 bg-cyan-500/10 text-cyan-400`,children:[e,(0,P.jsx)(`button`,{type:`button`,onClick:()=>S(e),disabled:_.isPending,className:`hover:text-red-400`,children:(0,P.jsx)(Na,{size:12})})]},e))}),b.length>0&&(0,P.jsxs)(`select`,{onChange:e=>{e.target.value&&(x(e.target.value),e.target.value=``)},disabled:_.isPending,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:outline-none focus:border-cyan-400 disabled:opacity-50`,children:[(0,P.jsx)(`option`,{value:``,children:`Add user...`}),b.map(e=>(0,P.jsxs)(`option`,{value:e.username,children:[e.username,` (`,e.displayname,`)`]},e.username))]}),h.isLoading&&(0,P.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Loading users...`})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-3 mt-6`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:t,disabled:_.isPending,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>_.mutate({spaMode:a,autheliaProtected:s,allowedUsers:l,...m?{aliases:p}:{}}),disabled:_.isPending||!y,className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed`,children:_.isPending?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:14,className:`animate-spin`}),`Saving...`]}):`Save Changes`})]})]})})}function Po({sites:e,onDelete:t,onFiles:n,onVerifyDns:r,onSettings:i}){return(0,P.jsx)(`div`,{className:`hidden md:block overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700`,children:[(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Name`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Domain`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Type`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Status`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Size`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Created`}),(0,P.jsx)(`th`,{className:`text-right text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Actions`})]})}),(0,P.jsx)(`tbody`,{children:e.map(e=>(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800/50`,children:[(0,P.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-200 font-mono`,children:e.name}),(0,P.jsxs)(`td`,{className:`py-3 px-4 text-sm`,children:[e.certIssued?(0,P.jsxs)(`a`,{href:`https://${e.fqdn}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-cyan-400 hover:text-cyan-300 inline-flex items-center gap-1`,children:[e.fqdn,(0,P.jsx)(Ti,{size:12})]}):(0,P.jsx)(`span`,{className:`text-zinc-400 font-mono`,children:e.fqdn}),(e.aliases||[]).length>0&&(0,P.jsxs)(`p`,{className:`text-xs text-zinc-500 font-mono mt-0.5`,children:[`also `,e.aliases.join(`, `)]})]}),(0,P.jsx)(`td`,{className:`py-3 px-4`,children:(0,P.jsx)(Do,{type:e.type})}),(0,P.jsx)(`td`,{className:`py-3 px-4`,children:(0,P.jsx)(Eo,{site:e})}),(0,P.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-400 font-mono`,children:To(e.totalSize||0)}),(0,P.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-500`,children:wo(e.createdAt)}),(0,P.jsx)(`td`,{className:`py-3 px-4 text-right`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[e.type===`custom`&&!e.dnsVerified&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-yellow-400 hover:bg-yellow-600/20 hover:text-yellow-300`,children:[(0,P.jsx)(Pi,{size:12}),`Verify DNS`]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-400 hover:bg-zinc-600 hover:text-zinc-300`,children:[(0,P.jsx)(da,{size:12}),`Settings`]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-cyan-400 hover:bg-cyan-600/20 hover:text-cyan-300`,children:[(0,P.jsx)(ji,{size:12}),`Files`]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-red-400 hover:bg-red-600/20 hover:text-red-300`,children:[(0,P.jsx)(ya,{size:12}),`Delete`]})]})})]},e.id))})]})})}function Fo({sites:e,onDelete:t,onFiles:n,onVerifyDns:r,onSettings:i}){return(0,P.jsx)(`div`,{className:`md:hidden space-y-3`,children:e.map(e=>(0,P.jsxs)(`div`,{className:`bg-zinc-800/50 border border-zinc-700 rounded-lg p-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,P.jsx)(`span`,{className:`text-sm font-semibold text-zinc-200 font-mono`,children:e.name}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(Do,{type:e.type}),(0,P.jsx)(Eo,{site:e})]})]}),e.certIssued?(0,P.jsxs)(`a`,{href:`https://${e.fqdn}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-cyan-400 hover:text-cyan-300 text-sm inline-flex items-center gap-1 mb-1`,children:[e.fqdn,(0,P.jsx)(Ti,{size:12})]}):(0,P.jsx)(`span`,{className:`text-zinc-400 text-sm font-mono`,children:e.fqdn}),(e.aliases||[]).length>0&&(0,P.jsxs)(`p`,{className:`text-xs text-zinc-500 font-mono mb-1`,children:[`also `,e.aliases.join(`, `)]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-zinc-500 mt-2`,children:[(0,P.jsx)(`span`,{children:To(e.totalSize||0)}),(0,P.jsx)(`span`,{children:wo(e.createdAt)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[e.type===`custom`&&!e.dnsVerified&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:`inline-flex items-center gap-1 text-xs text-yellow-400 hover:text-yellow-300`,children:[(0,P.jsx)(Pi,{size:12}),`Verify DNS`]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`inline-flex items-center gap-1 text-xs text-zinc-400 hover:text-zinc-300`,children:[(0,P.jsx)(da,{size:12}),`Settings`]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:`inline-flex items-center gap-1 text-xs text-cyan-400 hover:text-cyan-300`,children:[(0,P.jsx)(ji,{size:12}),`Files`]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`inline-flex items-center gap-1 text-xs text-red-400 hover:text-red-300`,children:[(0,P.jsx)(ya,{size:12}),`Delete`]})]})]},e.id))})}function Io({domain:e}){let t=F(),n=G(),r=z(),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(null),m=I({queryKey:[`sites`],queryFn:()=>r.getSites(),refetchInterval:1e4}),h=L({mutationFn:e=>r.deleteSite(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`sites`]}),n(`Site ${o.fqdn} deleted`),s(null)},onError:e=>{n(K(e),`error`),s(null)}}),_=(0,g.useCallback)(e=>s(e),[]),v=(0,g.useCallback)(e=>l(e),[]),y=(0,g.useCallback)(e=>d(e),[]),b=(0,g.useCallback)(e=>p(e),[]),x=(0,g.useCallback)(()=>{o&&h.mutate(o.id)},[o,h]),S=m.data?.sites||[];return c?(0,P.jsx)(oo,{site:c,onBack:()=>l(null)}):(0,P.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,P.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Static Sites`}),(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Host static websites, landing pages, and SPAs`})]}),!i&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>a(!0),className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,P.jsx)(ea,{size:14}),`Add Site`]})]}),i&&e&&(0,P.jsx)(Ao,{domain:e,onClose:()=>a(!1)}),m.isLoading?(0,P.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,P.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):m.isError?(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load sites`})}):S.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-12 text-center`,children:[(0,P.jsx)(Oi,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No static sites yet. Create your first site to get started.`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Po,{sites:S,onDelete:_,onFiles:v,onVerifyDns:y,onSettings:b}),(0,P.jsx)(Fo,{sites:S,onDelete:_,onFiles:v,onVerifyDns:y,onSettings:b})]}),u&&(0,P.jsx)(jo,{site:u,onClose:()=>d(null)}),f&&(0,P.jsx)(No,{site:f,onClose:()=>p(null)}),o&&(0,P.jsx)(Mo,{site:o,onConfirm:x,onCancel:()=>s(null),isPending:h.isPending})]})}var Lo=Object.defineProperty,Ro=Object.getOwnPropertySymbols,zo=Object.prototype.hasOwnProperty,Bo=Object.prototype.propertyIsEnumerable,Vo=(e,t,n)=>t in e?Lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ho=(e,t)=>{for(var n in t||={})zo.call(t,n)&&Vo(e,n,t[n]);if(Ro)for(var n of Ro(t))Bo.call(t,n)&&Vo(e,n,t[n]);return e},Uo=(e,t)=>{var n={};for(var r in e)zo.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ro)for(var r of Ro(e))t.indexOf(r)<0&&Bo.call(e,r)&&(n[r]=e[r]);return n},Wo;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(Wo||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(Wo||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(Wo||={});var Go=Wo,Ko={L:Go.QrCode.Ecc.LOW,M:Go.QrCode.Ecc.MEDIUM,Q:Go.QrCode.Ecc.QUARTILE,H:Go.QrCode.Ecc.HIGH},qo=128,Jo=`L`,Yo=`#FFFFFF`,Xo=`#000000`,Zo=!1,Qo=1,$o=4,es=0,ts=.1;function ns(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function rs(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function is(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*ts),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function as(e,t){return t==null?e?$o:es:Math.max(Math.floor(t),0)}function os({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=g.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...Go.QrSegment.makeSegments(t)),e),[]);return Go.QrCode.encodeSegments(r,Ko[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=g.useMemo(()=>{let e=c.getModules(),t=as(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:is(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var ss=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),cs=g.forwardRef(function(e,t){let n=e,{value:r,size:i=qo,level:a=Jo,bgColor:o=Yo,fgColor:s=Xo,includeMargin:c=Zo,minVersion:l=Qo,boostLevel:u,marginSize:d,imageSettings:f}=n,p=Uo(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=Uo(p,[`style`]),_=f?.src,v=g.useRef(null),y=g.useRef(null),b=g.useCallback(e=>{v.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=g.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=os({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});g.useEffect(()=>{if(v.current!=null){let e=v.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=rs(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,ss?t.fill(new Path2D(ns(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),g.useEffect(()=>{S(!1)},[_]);let D=Ho({height:i,width:i},m),O=null;return _!=null&&(O=g.createElement(`img`,{src:_,key:_,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:E?.crossOrigin})),g.createElement(g.Fragment,null,g.createElement(`canvas`,Ho({style:D,height:i,width:i,ref:b,role:`img`},h)),O)});cs.displayName=`QRCodeCanvas`;var ls=g.forwardRef(function(e,t){let n=e,{value:r,size:i=qo,level:a=Jo,bgColor:o=Yo,fgColor:s=Xo,includeMargin:c=Zo,minVersion:l=Qo,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=Uo(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:_,numCells:v,calculatedImageSettings:y}=os({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),b=_,x=null;p!=null&&y!=null&&(y.excavation!=null&&(b=rs(_,y.excavation)),x=g.createElement(`image`,{href:p.src,height:y.h,width:y.w,x:y.x+h,y:y.y+h,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=ns(b,h);return g.createElement(`svg`,Ho({height:i,width:i,viewBox:`0 0 ${v} ${v}`,ref:t,role:`img`},m),!!d&&g.createElement(`title`,null,d),g.createElement(`path`,{fill:o,d:`M0,0 h${v}v${v}H0z`,shapeRendering:`crispEdges`}),g.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});ls.displayName=`QRCodeSVG`;var us=`admins`,ds={displayName:`display name`,email:`email address`};function fs(e){return ds[e]??String(e)}function ps(e){return typeof e==`string`&&e.length>8?`${e.slice(0,8)}…`:e??``}function ms(e){return typeof e==`string`?e:e&&typeof e==`object`&&typeof e.message==`string`?e.step?`${e.step}: ${e.message}`:e.message:String(e)}function hs(e,t){let n=e=>Array.isArray(e?.groups)&&e.groups.includes(us)&&e.disabled!==!0;return n(e)?t.filter(n).length<=1:!1}function gs(e){if(!e)return{ready:!1,text:`Unknown`};if(e.ready)return{ready:!0,text:`Users reach its application`};let t=e.version?`version ${e.version}`:`the installed version`;switch(e.reason){case`not_installed`:return{ready:!1,text:`The plugin is not installed`};case`no_identity`:return{ready:!1,text:`${_s(t)} declares no identity`};case`not_approved`:return{ready:!1,text:`${_s(t)} waits for approval — approve it under Lifecycle hooks`};case`not_hosted`:return{ready:!1,text:`The plugin is not hosted on an agent, or its hosting is not active yet`};case`not_answered`:return{ready:!1,text:`Its agent half has not answered the identity feed for ${t} yet — it is sent its users first`};default:return{ready:!1,text:e.reason?String(e.reason):`Not ready`}}}function _s(e){return e.charAt(0).toUpperCase()+e.slice(1)}function vs(e){switch(e){case null:case void 0:return`served — users reach its application here`;case`not_installed`:return`no installed plugin holds this route`;case`no_identity`:return`its installed version declares no identity — requests go down the tunnel until one does`;case`not_approved`:return`its installed version waits for approval — requests go down the tunnel until then`;case`not_hosting_agent`:return`the agent carrying this tunnel does not host the plugin (moved, revoked, or hosted elsewhere) — nothing of it is served here; requests go down the tunnel`;default:return String(e)}}function ys(e){return e.exposure===`internal`||!e.subdomain||(e.type??`app`)!==`app`?{eligible:!1,reason:`Only an app tunnel's host serves a plugin's user surface`}:e.enabled===!1?{eligible:!1,reason:`Enable the tunnel first`}:e.agentLabel?(e.accessMode??`restricted`)===`public`?{eligible:!1,reason:`A public tunnel has no signed-in user to vouch for — make it authenticated or restricted first`}:{eligible:!0,reason:null}:{eligible:!1,reason:`Assign the tunnel to an agent first`}}function bs(e,t,n){if(n.has(e.route))return`served on ${n.get(e.route)}`;let r=e.agentHosting?.agentLabel??null;return r===null?`not hosted on an agent`:r===t.agentLabel?null:`hosted on ${r}, not on ${t.agentLabel}`}function xs(e){return Array.isArray(e?.userSurface?.routes)?e.userSurface.routes:[]}function Ss(e,t){return(e?.userSurfaceStatus??[]).find(e=>e.route===t)??null}function Cs(e){let t=e.change,n=e=>({username:e?.username??null,displayName:e?.displayName??null,email:e?.email??null}),r={userId:e.userId,seq:e.seq,version:e.version,updatedAt:e.updatedAt,member:!1,...n(null),roles:[],status:`unknown`,reason:null};if(t?.kind===`upsert`&&t.member){let e=t.member;return{...r,member:!0,...n(e),roles:Array.isArray(e.roles)?e.roles:[],status:e.status===`disabled`?`disabled`:`active`}}return t?.kind===`remove`?{...r,...n(t.last),status:t.reason===`erased`?`erased`:`removed`,reason:t.reason??null}:r}function ws(e){switch(e){case`deleted`:return`deleted`;case`unentitled`:return`no longer entitled`;case`erased`:return`erased`;default:return e?String(e):`removed`}}function Ts(e,t,n){let r=new Set(e);return n?r.add(t):r.delete(t),[...r].sort()}function Es(e){if(!(`grantsAffected`in e)||!Array.isArray(e.rolesRemoved)||e.rolesRemoved.length===0)return[];let t=e.grantsAffected;if(t===null)return[`not known — Gatekeeper could not be read`];let n=[];return t.revoked>0&&n.push(`${t.revoked} revoked`),t.rewritten>0&&n.push(`${t.rewritten} narrowed to the roles that stay`),n.length>0?n:[`none`]}function Ds(e){if(!e||typeof e!=`object`)return null;let t=e=>Array.isArray(e)?e.map(String):[],n=(e,t)=>e?.roles?.find(e=>e.id===t)?.label??null,r=e=>t=>{let r=n(e,t);return r?`${t} (${r})`:t},i=[{label:`roles added`,entries:t(e.rolesAdded).map(r(e.after)),approval:!0},{label:`roles removed`,entries:t(e.rolesRemoved).map(r(e.before)),approval:!0},{label:`receives more about its users`,entries:t(e.attributesAdded).map(fs),approval:!0},{label:`receives less about its users`,entries:t(e.attributesRemoved).map(fs),approval:!1},{label:`role labels changed`,entries:t(e.labelsChanged).map(r(e.after)),approval:!1}].filter(e=>e.entries.length>0),a=Es(e);a.length>0&&i.push({label:`role grants affected`,entries:a,approval:!0});let o=e.before!=null,s=e.after!=null;return i.length===0&&o===s?null:{rows:i,declaredBefore:o,declaredAfter:s}}function Os({id:e,missing:t=`not in the directory yet`,full:n=!1}){let[r,i]=(0,g.useState)(!1);return e?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`font-mono text-xs text-zinc-400`,title:e,children:n?e:ps(e)}),(0,P.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch{}},title:`Copy the full id`,"aria-label":`Copy the full id`,className:`text-zinc-500 hover:text-zinc-300`,children:r?(0,P.jsx)(li,{size:11,className:`text-green-400`}):(0,P.jsx)(bi,{size:11})})]}):(0,P.jsx)(`span`,{className:`text-zinc-600`,title:t,children:`—`})}function ks(e){e.invalidateQueries({queryKey:[`users`]}),e.invalidateQueries({queryKey:[`user-directory`]}),e.invalidateQueries({queryKey:[`plugin-identity`]}),e.invalidateQueries({queryKey:[`plugin-audience`]})}function As(e,t){for(let n of t?.warnings??[])e(ms(n),`error`)}function js({children:e,onClose:t}){return(0,P.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-black/50`,children:(0,P.jsxs)(`div`,{className:`relative max-h-[90vh] w-full max-w-lg overflow-y-auto rounded-lg bg-zinc-800 p-6 shadow-xl`,onClick:e=>e.stopPropagation(),children:[(0,P.jsx)(`button`,{type:`button`,onClick:t,className:`absolute right-4 top-4 text-zinc-500 hover:text-zinc-300`,children:(0,P.jsx)(Na,{size:18})}),e]})})}function Ms({totpUri:e,onClose:t}){let[n,r]=(0,g.useState)(!1),i=e.match(/secret=([A-Z2-7]+)/),a=i?i[1]:``,o=a.replace(/(.{4})/g,`$1 `).trim();function s(){navigator.clipboard.writeText(a).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)}).catch(()=>{})}return(0,P.jsxs)(js,{onClose:t,children:[(0,P.jsx)(`h2`,{className:`mb-4 text-lg font-bold text-white`,children:`Two-Factor Authentication Setup`}),(0,P.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)`}),(0,P.jsx)(`div`,{className:`mb-4 flex justify-center`,children:(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 p-4`,children:(0,P.jsx)(ls,{value:e,size:200,bgColor:`transparent`,fgColor:`#ffffff`})})}),(0,P.jsx)(`p`,{className:`mb-2 text-sm text-zinc-400`,children:`Or enter this code manually:`}),(0,P.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg bg-zinc-900 px-4 py-3`,children:[(0,P.jsx)(`code`,{className:`flex-1 font-mono text-sm text-cyan-400 tracking-wider`,children:o}),(0,P.jsx)(`button`,{type:`button`,onClick:s,className:`text-zinc-500 hover:text-zinc-300`,title:`Copy secret`,children:n?(0,P.jsx)(li,{size:16,className:`text-green-400`}):(0,P.jsx)(bi,{size:16})})]}),(0,P.jsx)(`p`,{className:`mb-6 text-xs text-yellow-400`,children:`This code will only be shown once. Make sure the user scans it before closing.`}),(0,P.jsx)(`button`,{type:`button`,onClick:t,className:`w-full rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:`Done`})]})}function Ns({user:e,onClose:t,onSuccess:n}){let r=!!e,i=G(),a=F(),o=z(),[s,c]=(0,g.useState)({username:e?.username||``,displayname:e?.displayname||``,email:e?.email||``,password:``,groups:e?.groups?.join(`, `)||``}),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``),p=L({mutationFn:e=>o.createUser(e),onSuccess:e=>{ks(a),As(i,e)}}),m=L({mutationFn:({username:e,...t})=>o.updateUser(e,t),onSuccess:e=>{ks(a),As(i,e)}}),h=r?m:p;function _(e,t){c(n=>({...n,[e]:t})),f(``)}async function v(a){if(a.preventDefault(),f(``),!r){if(!s.username||!s.displayname||!s.email||!s.password){f(`All required fields must be filled`);return}if(!/^[a-z0-9_-]+$/.test(s.username)){f(`Username must contain only lowercase alphanumeric characters, underscores, and hyphens`);return}if(s.username.length<2){f(`Username must be at least 2 characters`);return}if(s.password.length<8){f(`Password must be at least 8 characters`);return}}if(r&&s.password&&s.password.length<8){f(`Password must be at least 8 characters`);return}let o=s.groups.split(`,`).map(e=>e.trim()).filter(Boolean);try{if(r){let n={username:e.username};s.displayname!==e.displayname&&(n.displayname=s.displayname),s.email!==e.email&&(n.email=s.email),s.password&&(n.password=s.password);let r=(e.groups||[]).join(`, `);if(s.groups!==r&&(n.groups=o),Object.keys(n).length<=1){f(`No changes detected`);return}await h.mutateAsync(n),i(`User updated successfully`),t()}else{let e=await h.mutateAsync({username:s.username,displayname:s.displayname,email:s.email,password:s.password,groups:o});i(`User created successfully`),n(e.user.username)}}catch(e){f(K(e))}}let y=h.isPending;return(0,P.jsxs)(js,{onClose:t,children:[(0,P.jsx)(`h2`,{className:`mb-4 text-lg font-bold text-white`,children:r?`Edit User`:`Add User`}),(0,P.jsxs)(`form`,{onSubmit:v,className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Username`}),(0,P.jsx)(`input`,{type:`text`,value:s.username,onChange:e=>_(`username`,e.target.value),disabled:r,placeholder:`johndoe`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none disabled:text-zinc-500`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Display Name`}),(0,P.jsx)(`input`,{type:`text`,value:s.displayname,onChange:e=>_(`displayname`,e.target.value),placeholder:`John Doe`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Email`}),(0,P.jsx)(`input`,{type:`email`,value:s.email,onChange:e=>_(`email`,e.target.value),placeholder:`john@example.com`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:[`Password`,r?` (leave blank to keep current)`:``]}),(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(`input`,{type:l?`text`:`password`,value:s.password,onChange:e=>_(`password`,e.target.value),placeholder:r?`Leave blank to keep current password`:`Minimum 8 characters`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 pr-10 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>u(!l),className:`absolute right-3 top-1/2 -translate-y-1/2 text-zinc-500 hover:text-zinc-300`,children:l?(0,P.jsx)(Ei,{size:16}):(0,P.jsx)(Di,{size:16})})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Groups (comma-separated)`}),(0,P.jsx)(`input`,{type:`text`,value:s.groups,onChange:e=>_(`groups`,e.target.value),placeholder:`admins, users`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),d&&(0,P.jsx)(`p`,{className:`text-sm text-red-400`,children:d}),(0,P.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:t,className:`flex-1 rounded-lg border border-zinc-700 px-4 py-2 text-sm text-zinc-400 hover:text-white`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`submit`,disabled:y,className:`flex-1 rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:y?`Saving...`:r?`Save Changes`:`Create User`})]})]})]})}function Ps({onClose:e,onSuccess:t}){let n=G(),r=F(),i=z(),[a,o]=(0,g.useState)({username:``,email:``,groups:``}),[s,c]=(0,g.useState)(``),l=L({mutationFn:e=>i.createInvitation(e),onSuccess:()=>r.invalidateQueries({queryKey:[`invitations`]})});function u(e,t){o(n=>({...n,[e]:t})),c(``)}async function d(e){if(e.preventDefault(),c(``),!a.username||!a.email){c(`Username and email are required`);return}if(!/^[a-z0-9_-]+$/.test(a.username)){c(`Username must contain only lowercase alphanumeric characters, underscores, and hyphens`);return}if(a.username.length<2){c(`Username must be at least 2 characters`);return}let r=a.groups.split(`,`).map(e=>e.trim()).filter(Boolean);try{let e=await l.mutateAsync({username:a.username,email:a.email,groups:r});n(`Invitation created`),t(e)}catch(e){c(K(e))}}return(0,P.jsxs)(js,{onClose:e,children:[(0,P.jsx)(`h2`,{className:`mb-4 text-lg font-bold text-white`,children:`Invite User`}),(0,P.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Generate an invitation link. The invited user will set their own password and TOTP.`}),(0,P.jsxs)(`form`,{onSubmit:d,className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Username`}),(0,P.jsx)(`input`,{type:`text`,value:a.username,onChange:e=>u(`username`,e.target.value),placeholder:`johndoe`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Email`}),(0,P.jsx)(`input`,{type:`email`,value:a.email,onChange:e=>u(`email`,e.target.value),placeholder:`john@example.com`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Groups (comma-separated, optional)`}),(0,P.jsx)(`input`,{type:`text`,value:a.groups,onChange:e=>u(`groups`,e.target.value),placeholder:`users`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),s&&(0,P.jsx)(`p`,{className:`text-sm text-red-400`,children:s}),(0,P.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:e,className:`flex-1 rounded-lg border border-zinc-700 px-4 py-2 text-sm text-zinc-400 hover:text-white`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`submit`,disabled:l.isPending,className:`flex-1 rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:l.isPending?`Creating...`:`Create Invitation`})]})]})]})}function Fs({inviteUrl:e,token:t,onClose:n}){let[r,i]=(0,g.useState)(!1),a=e||`(Domain not configured — token: ${t})`;function o(){let n=e||t;navigator.clipboard.writeText(n).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)}).catch(()=>{})}return(0,P.jsxs)(js,{onClose:n,children:[(0,P.jsx)(`h2`,{className:`mb-4 text-lg font-bold text-white`,children:`Invitation Created`}),(0,P.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Share this link with the invited user. It expires in 7 days.`}),(0,P.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg bg-zinc-900 px-4 py-3`,children:[(0,P.jsx)(`code`,{className:`flex-1 text-sm text-cyan-400 break-all`,children:a}),(0,P.jsx)(`button`,{type:`button`,onClick:o,className:`flex-shrink-0 text-zinc-500 hover:text-zinc-300`,title:`Copy link`,children:r?(0,P.jsx)(li,{size:16,className:`text-green-400`}):(0,P.jsx)(bi,{size:16})})]}),!e&&(0,P.jsx)(`p`,{className:`mb-4 text-xs text-yellow-400`,children:`Domain is not configured. The invitation token has been created but cannot generate a full URL.`}),(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`w-full rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:`Done`})]})}function Is({confirmLabel:e,destructive:t,disabled:n=!1,isPending:r,onConfirm:i,onCancel:a}){return(0,P.jsxs)(`div`,{className:`flex gap-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:a,className:`flex-1 rounded-lg border border-zinc-700 px-4 py-2 text-sm text-zinc-400 hover:text-white`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,onClick:i,disabled:r||n,className:`flex-1 rounded-lg px-4 py-2 text-sm font-semibold text-white disabled:opacity-50 ${t?`bg-red-600 hover:bg-red-500`:`bg-cyan-600 hover:bg-cyan-500`}`,children:r?`Please wait...`:e})]})}function Ls({title:e,message:t,confirmLabel:n,destructive:r,onConfirm:i,onCancel:a,isPending:o}){return(0,P.jsxs)(js,{onClose:a,children:[(0,P.jsx)(`h2`,{className:`mb-2 text-lg font-bold text-white`,children:e}),(0,P.jsx)(`p`,{className:`mb-6 text-sm text-zinc-400`,children:t}),(0,P.jsx)(Is,{confirmLabel:n,destructive:r,isPending:o,onConfirm:i,onCancel:a})]})}function Rs({username:e,typed:t,onType:n}){return(0,P.jsxs)(`div`,{className:`mb-4 space-y-3 rounded-lg border border-red-500/30 bg-red-500/5 p-3`,children:[(0,P.jsxs)(`ul`,{className:`list-disc space-y-1 pl-5 text-xs text-zinc-400`,children:[(0,P.jsx)(`li`,{children:`The directory keeps the bare user id; the username, name and address it last had are scrubbed.`}),(0,P.jsx)(`li`,{children:`Their invitations and Gatekeeper's access-request log entries are deleted.`}),(0,P.jsx)(`li`,{children:`Every plugin that had them is sent the erasure: its agent half scrubs its record to the id and runs the plugin's anonymiser. The panel shows it pending until each acknowledges.`}),(0,P.jsx)(`li`,{children:`Authelia's own authentication log is outside Lamaste's reach and is not erased.`}),(0,P.jsx)(`li`,{className:`text-red-400`,children:`This cannot be undone.`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`label`,{className:`mb-1 block text-xs text-zinc-400`,children:[`Type `,(0,P.jsx)(`span`,{className:`font-mono text-zinc-200`,children:e}),` to confirm`]}),(0,P.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),autoComplete:`off`,spellCheck:!1,className:`w-full rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 font-mono text-sm text-white focus:border-red-500 focus:outline-none`})]})]})}function zs({user:e,onConfirm:t,onCancel:n,isPending:r}){let[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(``),c=!i||o===e.username;return(0,P.jsxs)(js,{onClose:n,children:[(0,P.jsx)(`h2`,{className:`mb-2 text-lg font-bold text-white`,children:`Delete User`}),(0,P.jsxs)(`p`,{className:`mb-3 text-sm text-zinc-400`,children:[`Delete `,(0,P.jsx)(`span`,{className:`font-mono text-cyan-400`,children:e.username}),`? They can no longer sign in, their grants and group memberships are removed, and every plugin they used is told they were deleted.`]}),(0,P.jsx)(`p`,{className:`mb-4 text-xs text-zinc-500`,children:`The user directory keeps a tombstone — their user id with the name and address they last had — so what plugins recorded about them stays readable. A user created later under the same username is a new user with a new id.`}),(0,P.jsxs)(`label`,{className:`mb-3 flex items-start gap-2 text-sm text-zinc-300`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>{a(e.target.checked),s(``)},className:`mt-1`}),(0,P.jsx)(`span`,{children:`Also erase their personal data`})]}),i&&(0,P.jsx)(Rs,{username:e.username,typed:o,onType:s}),(0,P.jsx)(Is,{confirmLabel:i?`Delete and erase`:`Delete`,destructive:!0,disabled:!c,isPending:r,onConfirm:()=>t(i),onCancel:n})]})}function Bs({user:e,onConfirm:t,onCancel:n,isPending:r}){let[i,a]=(0,g.useState)(``);return(0,P.jsxs)(js,{onClose:n,children:[(0,P.jsx)(`h2`,{className:`mb-2 text-lg font-bold text-white`,children:`Erase Deleted User`}),(0,P.jsxs)(`p`,{className:`mb-3 text-sm text-zinc-400`,children:[`Erase what Lamaste keeps of `,(0,P.jsx)(`span`,{className:`font-mono text-cyan-400`,children:e.username}),` `,`(`,(0,P.jsx)(`span`,{className:`font-mono text-xs`,children:e.userId}),`)?`]}),(0,P.jsx)(Rs,{username:e.username,typed:i,onType:a}),(0,P.jsx)(Is,{confirmLabel:`Erase`,destructive:!0,disabled:i!==e.username,isPending:r,onConfirm:t,onCancel:n})]})}function Vs({status:e}){let t=e===`disabled`;return(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${t?`text-yellow-400 bg-yellow-500/10 border-yellow-500/20`:`text-green-400 bg-green-500/10 border-green-500/20`}`,title:t?`Cannot sign in; every plugin audience shows them disabled; plugins’ user surfaces refuse them`:void 0,children:t?`disabled`:`active`})}function Hs(e){return e.removedReason===`deleted-outside`?`gone from Authelia’s users file (not deleted through Lamaste)`:`deleted`}function Us(){let e=z(),t=F(),n=G(),[r,i]=(0,g.useState)(null),a=I({queryKey:[`user-directory`],queryFn:()=>e.getUserDirectory(),refetchInterval:3e4}),o=L({mutationFn:t=>e.eraseDirectoryUser(t),onSuccess:e=>{ks(t),t.invalidateQueries({queryKey:[`invitations`]}),n(`Erased — ${e.invitationsPurged} invitation(s) and ${e.accessLogPurged} access-log entr${e.accessLogPurged===1?`y`:`ies`} deleted; plugins are being told`),i(null)},onError:e=>{n(K(e),`error`),i(null)}}),s=a.dataUpdatedAt,c=(a.data?.users??[]).filter(e=>e.status===`removed`);return(0,P.jsxs)(`div`,{className:`mt-8`,children:[(0,P.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-end justify-between gap-2`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`h2`,{className:`flex items-center gap-2 text-lg font-bold text-white`,children:[(0,P.jsx)(ni,{size:16,className:`text-zinc-400`}),`Deleted Users`]}),(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm`,children:`Tombstones the directory keeps until they are erased, so plugins' history stays readable.`})]}),a.data?.directoryId&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-zinc-500`,children:[`directory `,(0,P.jsx)(Os,{id:a.data.directoryId})]})]}),(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800 bg-zinc-900`,children:a.isLoading?(0,P.jsx)(`div`,{className:`p-6 text-center`,children:(0,P.jsx)(`div`,{className:`mx-auto h-6 w-6 animate-spin rounded-full border-2 border-zinc-600 border-t-cyan-400`})}):a.isError?(0,P.jsxs)(`div`,{className:`p-6 text-center text-red-400 text-sm`,children:[`Failed to load the user directory: `,K(a.error)]}):c.length===0?(0,P.jsx)(`div`,{className:`p-6 text-center text-zinc-500 text-sm`,children:`No deleted users.`}):(0,P.jsxs)(`table`,{className:`w-full text-left`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700`,children:[(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`User`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`User ID`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 hidden sm:table-cell`,children:`Removed`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`State`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 text-right`,children:`Actions`})]})}),(0,P.jsx)(`tbody`,{children:c.map(e=>{let t=e.erasedAt!==null,n=e.principalClearedAt===null&&!t;return(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 last:border-b-0 align-top`,children:[(0,P.jsx)(`td`,{className:`px-4 py-3 text-sm`,children:t?(0,P.jsx)(`span`,{className:`text-zinc-600`,children:`erased`}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.username}),e.displayName&&(0,P.jsx)(`span`,{className:`block text-xs text-zinc-500`,children:e.displayName})]})}),(0,P.jsx)(`td`,{className:`px-4 py-3`,children:(0,P.jsx)(Os,{id:e.userId})}),(0,P.jsxs)(`td`,{className:`px-4 py-3 text-xs text-zinc-500 hidden sm:table-cell`,children:[Hs(e),e.removedAt&&(0,P.jsx)(`span`,{className:`block`,title:new Date(e.removedAt).toLocaleString(),children:gr(e.removedAt,s)})]}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-xs`,children:t?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`span`,{className:`text-zinc-400`,children:[`erased `,gr(e.erasedAt,s),e.erasure?.requestedBy?` by ${e.erasure.requestedBy}`:``]}),e.pendingErasures.length>0?(0,P.jsxs)(`span`,{className:`mt-0.5 flex items-start gap-1 text-amber-400`,children:[(0,P.jsx)(wi,{size:11,className:`mt-0.5 shrink-0`}),(0,P.jsxs)(`span`,{children:[`waiting for`,` `,e.pendingErasures.map(t=>(e.pendingErasuresInactive??[]).includes(t)?`${t} (not taking the feed — an agent keeps its data)`:t).join(`, `),` `,`to acknowledge it`]})]}):(0,P.jsx)(`span`,{className:`block text-zinc-600`,children:`acknowledged by every plugin`})]}):n?(0,P.jsxs)(`span`,{className:`flex items-start gap-1 text-yellow-400`,title:`Until it is done, nothing — no user, grant or group membership — is given to this username again`,children:[(0,P.jsx)(ba,{size:11,className:`mt-0.5 shrink-0`}),(0,P.jsx)(`span`,{children:`Gatekeeper cleanup pending — retried every minute; the username cannot be reused until it is done`})]}):(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`tombstone`})}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-right`,children:!t&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`inline-flex items-center gap-1 rounded p-1.5 text-xs text-zinc-500 hover:bg-zinc-700 hover:text-red-400`,title:`Erase what Lamaste keeps of this user`,children:[(0,P.jsx)(wi,{size:14}),`Erase`]})})]},e.userId)})})]})}),r&&(0,P.jsx)(Bs,{user:r,onConfirm:()=>o.mutate(r.userId),onCancel:()=>i(null),isPending:o.isPending})]})}function Ws(){let e=G(),t=F(),n=z(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),[h,_]=(0,g.useState)(!1),[v,y]=(0,g.useState)(null),[b,x]=(0,g.useState)(null),S=I({queryKey:[`users`],queryFn:()=>n.getUsers(),refetchInterval:3e4}),C=L({mutationFn:({username:e,erase:t})=>n.deleteUser(e,{erase:t}),onSuccess:(n,{username:r,erase:i})=>{ks(t),i&&t.invalidateQueries({queryKey:[`invitations`]}),e(i&&n.erased?`User '${r}' deleted and erased`:`User '${r}' deleted — the directory keeps a tombstone`),n.principalCleared||e(`Gatekeeper has not dropped the grants and groups of '${r}' yet — retried every minute; the username cannot be reused until then`,`error`),As(e,n),c(null)},onError:t=>{e(K(t),`error`),c(null)}}),w=L({mutationFn:({username:e,disabled:t})=>t?n.disableUser(e):n.enableUser(e),onSuccess:(n,{username:r,disabled:i})=>{ks(t),e(i?`User '${r}' disabled — signed out of the desktop, refused by every plugin`:`User '${r}' enabled`),As(e,n),u(null)},onError:t=>{e(K(t),`error`),u(null)}}),T=L({mutationFn:e=>n.resetTotp(e),onSuccess:e=>{m(null),f(e.totpUri)},onError:t=>{e(K(t),`error`),m(null)}}),E=I({queryKey:[`invitations`],queryFn:()=>n.getInvitations()}),D=L({mutationFn:e=>n.revokeInvitation(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`invitations`]}),e(`Invitation revoked`),x(null)},onError:t=>{e(K(t),`error`),x(null)}}),O=S.data?.users||[],ee=E.data?.invitations||[],te=O.length<=1;async function ne(e){i(!1);try{f((await T.mutateAsync(e)).totpUri)}catch{}}function re(e){m(e)}function ie(){p&&T.mutate(p)}function ae(){f(null)}return(0,P.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,P.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Users`}),(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Manage Authelia users, two-factor authentication, and what the user directory keeps of them.`})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>_(!0),className:`flex items-center gap-2 rounded-lg border border-zinc-700 px-4 py-2 text-sm font-semibold text-zinc-300 hover:border-cyan-500 hover:text-white`,children:[(0,P.jsx)(Ki,{size:16}),`Invite User`]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-2 rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,P.jsx)(Ea,{size:16}),`Add User`]})]})]}),(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800 bg-zinc-900`,children:S.isLoading?(0,P.jsx)(`div`,{className:`p-8 text-center`,children:(0,P.jsx)(`div`,{className:`mx-auto h-6 w-6 animate-spin rounded-full border-2 border-zinc-600 border-t-cyan-400`})}):S.isError?(0,P.jsx)(`div`,{className:`p-8 text-center text-red-400 text-sm`,children:`Failed to load users`}):O.length===0?(0,P.jsx)(`div`,{className:`p-8 text-center text-zinc-500 text-sm`,children:`No users configured. Add your first user to get started.`}):(0,P.jsxs)(`table`,{className:`w-full text-left`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700`,children:[(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`Username`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`Display Name`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 hidden sm:table-cell`,children:`Email`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 hidden md:table-cell`,children:`Groups`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`Status`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 hidden lg:table-cell`,children:`User ID`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 text-right`,children:`Actions`})]})}),(0,P.jsx)(`tbody`,{children:O.map(e=>{let t=e.status===`disabled`,n=hs(e,O);return(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 last:border-b-0`,children:[(0,P.jsx)(`td`,{className:`px-4 py-3 font-mono text-sm ${t?`text-zinc-500`:`text-cyan-400`}`,children:e.username}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-sm text-zinc-300`,children:e.displayname}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-sm text-zinc-400 hidden sm:table-cell`,children:e.email}),(0,P.jsx)(`td`,{className:`px-4 py-3 hidden md:table-cell`,children:(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(e.groups||[]).map(e=>(0,P.jsx)(`span`,{className:`rounded bg-zinc-700 px-2 py-0.5 text-xs text-zinc-300`,children:e},e))})}),(0,P.jsx)(`td`,{className:`px-4 py-3`,children:(0,P.jsx)(Vs,{status:e.status})}),(0,P.jsx)(`td`,{className:`px-4 py-3 hidden lg:table-cell`,children:(0,P.jsx)(Os,{id:e.userId,missing:`Not in the user directory yet — it adopts new users within a minute`})}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>o(e),className:`rounded p-1.5 text-zinc-500 hover:bg-zinc-700 hover:text-zinc-300`,title:`Edit user`,children:(0,P.jsx)(Qi,{size:14})}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>re(e.username),className:`rounded p-1.5 text-zinc-500 hover:bg-zinc-700 hover:text-zinc-300`,title:`Reset TOTP`,children:(0,P.jsx)(zi,{size:14})}),t?(0,P.jsx)(`button`,{type:`button`,onClick:()=>w.mutate({username:e.username,disabled:!1}),disabled:w.isPending,className:`rounded p-1.5 text-zinc-500 hover:bg-zinc-700 hover:text-green-400 disabled:opacity-30`,title:`Enable user`,children:(0,P.jsx)(Ta,{size:14})}):(0,P.jsx)(`button`,{type:`button`,onClick:()=>!n&&u(e.username),disabled:n,className:`rounded p-1.5 text-zinc-500 hover:bg-zinc-700 hover:text-yellow-400 disabled:cursor-not-allowed disabled:opacity-30`,title:n?`Cannot disable the last enabled administrator`:`Disable user`,children:(0,P.jsx)(Da,{size:14})}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>!te&&c(e),disabled:te,className:`rounded p-1.5 text-zinc-500 hover:bg-zinc-700 hover:text-red-400 disabled:cursor-not-allowed disabled:opacity-30`,title:te?`Cannot delete the last user`:`Delete user`,children:(0,P.jsx)(ya,{size:14})})]})})]},e.username)})})]})}),(0,P.jsxs)(`div`,{className:`mt-8 mb-6`,children:[(0,P.jsx)(`h2`,{className:`text-lg font-bold text-white mb-1`,children:`Invitations`}),(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm`,children:`Pending and past invitation links.`})]}),(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800 bg-zinc-900`,children:E.isLoading?(0,P.jsx)(`div`,{className:`p-8 text-center`,children:(0,P.jsx)(`div`,{className:`mx-auto h-6 w-6 animate-spin rounded-full border-2 border-zinc-600 border-t-cyan-400`})}):E.isError?(0,P.jsx)(`div`,{className:`p-8 text-center text-red-400 text-sm`,children:`Failed to load invitations`}):ee.length===0?(0,P.jsx)(`div`,{className:`p-8 text-center text-zinc-500 text-sm`,children:`No invitations yet. Click "Invite User" to generate a link.`}):(0,P.jsxs)(`table`,{className:`w-full text-left`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700`,children:[(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`Username`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 hidden sm:table-cell`,children:`Email`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400`,children:`Status`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 hidden md:table-cell`,children:`Expires`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-xs font-semibold uppercase text-zinc-400 text-right`,children:`Actions`})]})}),(0,P.jsx)(`tbody`,{children:ee.map(e=>(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 last:border-b-0`,children:[(0,P.jsx)(`td`,{className:`px-4 py-3 font-mono text-sm text-cyan-400`,children:e.username}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-sm text-zinc-400 hidden sm:table-cell`,children:e.email}),(0,P.jsx)(`td`,{className:`px-4 py-3`,children:(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${e.status===`accepted`?`text-green-400 bg-green-500/10 border-green-500/20`:e.status===`expired`?`text-zinc-500 bg-zinc-800 border-zinc-700`:`text-yellow-400 bg-yellow-500/10 border-yellow-500/20`}`,children:e.status})}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-sm text-zinc-500 hidden md:table-cell`,children:new Date(e.expiresAt).toLocaleDateString()}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-right`,children:e.status===`pending`&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>x(e.id),className:`rounded p-1.5 text-zinc-500 hover:bg-zinc-700 hover:text-red-400`,title:`Revoke invitation`,children:(0,P.jsx)(_i,{size:14})})})]},e.id))})]})}),h&&(0,P.jsx)(Ps,{onClose:()=>_(!1),onSuccess:e=>{_(!1),y(e)}}),v&&(0,P.jsx)(Fs,{inviteUrl:v.inviteUrl,token:v.token,onClose:()=>y(null)}),b&&(0,P.jsx)(Ls,{title:`Revoke Invitation`,message:`Are you sure you want to revoke this invitation? The link will no longer work.`,confirmLabel:`Revoke`,destructive:!0,onConfirm:()=>D.mutate(b),onCancel:()=>x(null),isPending:D.isPending}),r&&(0,P.jsx)(Ns,{onClose:()=>i(!1),onSuccess:ne}),a&&(0,P.jsx)(Ns,{user:a,onClose:()=>o(null)}),s&&(0,P.jsx)(zs,{user:s,onConfirm:e=>C.mutate({username:s.username,erase:e}),onCancel:()=>c(null),isPending:C.isPending}),l&&(0,P.jsx)(Ls,{title:`Disable User`,message:`Disable '${l}'? They can no longer sign in; their desktop sessions and registry tokens end; every plugin's audience shows them disabled and plugins' user surfaces refuse them at once. Nothing is deleted — enable them again at any time.`,confirmLabel:`Disable`,destructive:!0,onConfirm:()=>w.mutate({username:l,disabled:!0}),onCancel:()=>u(null),isPending:w.isPending}),p&&!d&&(0,P.jsx)(Ls,{title:`Reset TOTP`,message:`This will invalidate the current TOTP secret for '${p}'. They will need to re-enroll their authenticator app.`,confirmLabel:`Reset TOTP`,onConfirm:ie,onCancel:()=>m(null),isPending:T.isPending}),d&&(0,P.jsx)(Ms,{totpUri:d,onClose:ae}),(0,P.jsx)(Us,{}),(0,P.jsx)(Gs,{})]})}function Gs(){let e=z(),[t,n]=(0,g.useState)(!1),r=I({queryKey:[`identity-groups`],queryFn:()=>e.getIdentityGroups(),retry:!1,staleTime:6e4}),i=I({queryKey:[`identity-self`],queryFn:()=>e.getIdentitySelf(),retry:!1,staleTime:6e4,enabled:t}),a=r.data?.groups||[];return(0,P.jsxs)(`div`,{className:`mt-8 border-t border-zinc-700 pt-6`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex items-center gap-2 text-lg font-semibold text-white hover:text-zinc-300 w-full text-left`,children:[(0,P.jsx)(Ai,{size:18,className:`text-cyan-400`}),`Identity & Groups`,t?(0,P.jsx)(pi,{size:16,className:`text-zinc-500 ml-auto`}):(0,P.jsx)(ui,{size:16,className:`text-zinc-500 ml-auto`})]}),t&&(0,P.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[i.data&&(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-4`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium text-zinc-400 mb-2`,children:`Your Identity (via Authelia)`}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-sm`,children:[(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`Username:`}),(0,P.jsx)(`span`,{className:`text-zinc-200`,children:i.data.username||`—`}),(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`Display Name:`}),(0,P.jsx)(`span`,{className:`text-zinc-200`,children:i.data.displayName||`—`}),(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`Email:`}),(0,P.jsx)(`span`,{className:`text-zinc-200`,children:i.data.email||`—`}),(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`Groups:`}),(0,P.jsx)(`span`,{className:`text-zinc-200`,children:i.data.groups?.length>0?i.data.groups.join(`, `):`—`})]})]}),i.isError&&(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-4`,children:(0,P.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Identity information is only available when accessing the panel through an Authelia-protected domain.`})}),r.isLoading?(0,P.jsx)(`div`,{className:`h-10 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`}):a.length>0?(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium text-zinc-400 mb-2`,children:`All Groups`}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a.map(e=>(0,P.jsx)(`span`,{className:`text-xs px-2.5 py-1 rounded-full bg-cyan-500/10 text-cyan-400 border border-cyan-500/20`,children:e},e))})]}):(0,P.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No groups defined in Authelia.`})]})]})}function Ks(e){return e.os===`darwin`?`macOS`:e.distro?[e.distro.id,e.distro.versionId].filter(Boolean).join(` `):`Linux`}function qs({facts:e,at:t}){if(!e)return(0,P.jsx)(`span`,{className:`text-xs text-zinc-600`,title:`The agent reports its host on its sync — it has not yet (sync not running, or lamaste-agent too old)`,children:`host not reported`});let n=e.os===`linux`,r=[Ks(e),e.arch,`Node ${e.node}`];return n&&r.push(e.systemd?`systemd`:`no systemd`),(0,P.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-1.5 text-xs text-zinc-500`,children:[(0,P.jsx)(xi,{size:11,className:`shrink-0 text-zinc-600`}),r.map((e,t)=>(0,P.jsxs)(`span`,{className:`whitespace-nowrap`,children:[t>0&&`· `,e]},`${t}-${e}`)),n&&(e.apphost?(0,P.jsxs)(`span`,{className:`whitespace-nowrap text-cyan-400`,title:`The app host helper is enabled: Lamaste can install agent halves here`,children:[`· app host v`,e.apphost.version,e.apphost.relayKid?(0,P.jsxs)(`span`,{className:`text-zinc-500`,title:`The helper runs app jobs signed with relay key ${e.apphost.relayKid}`,children:[` `,`(relay key `,e.apphost.relayKid.slice(0,12),`)`]}):(0,P.jsxs)(`span`,{className:`text-yellow-400`,title:`The helper has no key of this relay pinned and runs none of its app jobs: sudo lamaste-agent apphost pin`,children:[` `,`(no relay key pinned)`]})]}):(0,P.jsx)(`span`,{className:`whitespace-nowrap text-zinc-600`,title:`Enable it on the agent with: sudo lamaste-agent apphost enable`,children:`· app host off`})),t&&(0,P.jsxs)(`span`,{className:`whitespace-nowrap text-zinc-600`,children:[`· reported `,new Date(t).toLocaleString()]})]})}function Js({type:e}){return(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${{letsencrypt:`bg-blue-500/20 text-blue-400`,"mtls-ca":`bg-purple-500/20 text-purple-400`,"mtls-client":`bg-purple-500/20 text-purple-400`}[e]||`bg-zinc-500/20 text-zinc-400`}`,children:{letsencrypt:`Let's Encrypt`,"mtls-ca":`mTLS CA`,"mtls-client":`mTLS Client`}[e]||e})}function Ys({days:e}){let t=`text-green-400`,n=`bg-green-400`;return e<=7?(t=`text-red-400`,n=`bg-red-400`):e<=30&&(t=`text-amber-400`,n=`bg-amber-400`),(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5 ${t}`,children:[(0,P.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full ${n}`}),e,`d`]})}function Xs(e){if(!e)return`N/A`;try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}catch{return e}}function Zs({data:e,isLoading:t}){return t?(0,P.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm text-zinc-500`,children:[(0,P.jsx)(H,{size:14,className:`animate-spin`}),`Checking auto-renewal status...`]}):e?e.active?(0,P.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-zinc-400`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-green-400`}),`Auto-renewal active`]}),e.nextRun&&(0,P.jsxs)(`span`,{children:[`Next run: `,Xs(e.nextRun)]}),e.lastRun&&(0,P.jsxs)(`span`,{children:[`Last renewed: `,Xs(e.lastRun)]})]}):(0,P.jsxs)(`div`,{className:`mb-4 flex items-center gap-1.5 text-sm text-amber-400`,children:[(0,P.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-red-400`}),`Auto-renewal is not active. Certificates may expire.`]}):null}function Qs({certs:e,onRenew:t,renewingDomain:n}){let r=e.filter(e=>e.type===`letsencrypt`);return r.length===0?(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm text-center`,children:`No Let's Encrypt certificates found.`})}):(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Type`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Domain`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Expiry Date`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Days Remaining`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Actions`})]})}),(0,P.jsx)(`tbody`,{children:r.map(e=>(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,P.jsx)(`td`,{className:`px-4 py-3`,children:(0,P.jsx)(Js,{type:e.type})}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-zinc-300 font-mono text-xs`,children:e.domain||`N/A`}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-zinc-400`,children:Xs(e.expiresAt)}),(0,P.jsx)(`td`,{className:`px-4 py-3`,children:(0,P.jsx)(Ys,{days:e.daysUntilExpiry})}),(0,P.jsx)(`td`,{className:`px-4 py-3`,children:(0,P.jsx)(`button`,{type:`button`,disabled:!!n,onClick:()=>t(e.domain),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50 disabled:cursor-not-allowed`,children:n===e.domain?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:12,className:`animate-spin`}),`Renewing...`]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(ra,{size:12}),`Renew`]})})})]},e.domain||e.path))})]})})}function $s({certs:e,onRotate:t,adminAuthMode:n}){let r=e.find(e=>e.type===`mtls-ca`),i=e.find(e=>e.type===`mtls-client`),a=n===`hardware-bound`;return!r&&!i?null:(0,P.jsx)(`div`,{className:`mt-8`,children:(0,P.jsxs)(`div`,{className:`border-t border-zinc-700 pt-6`,children:[(0,P.jsxs)(`h2`,{className:`text-lg font-semibold text-white mb-4 flex items-center gap-2`,children:[(0,P.jsx)(pa,{size:18,className:`text-purple-400`}),`mTLS Certificates`,a&&(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border text-emerald-400 bg-emerald-500/10 border-emerald-500/20`,children:`hardware-bound`})]}),(0,P.jsxs)(`div`,{className:`space-y-4`,children:[r&&(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,P.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,P.jsx)(Js,{type:`mtls-ca`}),(0,P.jsx)(`span`,{className:`text-white font-semibold text-sm`,children:`Certificate Authority`})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-4 text-sm text-zinc-400 mt-2`,children:[(0,P.jsxs)(`span`,{children:[`Expires: `,Xs(r.expiresAt)]}),(0,P.jsx)(Ys,{days:r.daysUntilExpiry})]})]})}),(0,P.jsx)(`p`,{className:`text-xs text-zinc-500 mt-3`,children:`The CA certificate cannot be rotated. It was created during initial setup.`})]}),i&&(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,P.jsx)(Js,{type:`mtls-client`}),(0,P.jsx)(`span`,{className:`text-white font-semibold text-sm`,children:`Client Certificate`})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-4 text-sm text-zinc-400 mt-2`,children:[(0,P.jsxs)(`span`,{children:[`Expires: `,Xs(i.expiresAt)]}),(0,P.jsx)(Ys,{days:i.daysUntilExpiry})]})]}),!a&&(0,P.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-1.5 rounded bg-amber-600 px-3 py-1.5 text-xs text-white hover:bg-amber-500`,children:[(0,P.jsx)(ra,{size:12}),`Rotate`]})]}),a&&(0,P.jsxs)(`p`,{className:`text-xs text-emerald-400/70 mt-3`,children:[`Admin uses a hardware-bound certificate. P12 download and rotation are disabled. To revert, run`,` `,(0,P.jsx)(`code`,{className:`bg-zinc-800 px-1 py-0.5 rounded`,children:`sudo lamaste-reset-admin`}),` `,`on the server.`]})]})]})]})})}function ec({status:e}){return(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${{active:`text-green-400 bg-green-500/10 border-green-500/20`,"expiring-soon":`text-yellow-400 bg-yellow-500/10 border-yellow-500/20`,expired:`text-red-400 bg-red-500/10 border-red-500/20`,revoked:`text-red-400 bg-red-500/10 border-red-500/20`}[e]||`text-zinc-500 bg-zinc-800 border-zinc-700`}`,children:{active:`active`,"expiring-soon":`expiring soon`,expired:`expired`,revoked:`revoked`}[e]||e})}function tc({method:e}){return e===`hardware-bound`?(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border text-emerald-400 bg-emerald-500/10 border-emerald-500/20`,children:`hardware-bound`}):e===`delegated`?(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border text-violet-400 bg-violet-500/10 border-violet-500/20`,children:`delegated`}):(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border text-zinc-500 bg-zinc-800 border-zinc-700`,children:`p12`})}function nc(e){if(!e.startsWith(`plugin-agent:`))return null;let t=e.split(`:`);return t.length>=3?{displayName:t.slice(2).join(`:`),viaAgent:t[1]}:null}function rc({label:e}){let t=nc(e);return t?(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-zinc-200 font-semibold`,children:t.displayName}),(0,P.jsxs)(`span`,{className:`block text-xs text-zinc-500 mt-0.5`,title:e,children:[`via `,t.viaAgent]})]}):(0,P.jsx)(`span`,{className:`text-zinc-200 font-semibold`,children:e})}var ic=[{value:`tunnels:read`,label:`tunnels:read`,description:`List tunnels and download plist`,mandatory:!0},{value:`tunnels:write`,label:`tunnels:write`,description:`Create and delete tunnels`},{value:`services:read`,label:`services:read`,description:`View service status`},{value:`services:write`,label:`services:write`,description:`Start/stop/restart services`},{value:`system:read`,label:`system:read`,description:`View system stats (CPU, RAM, disk)`},{value:`sites:read`,label:`sites:read`,description:`List sites and browse files`},{value:`sites:write`,label:`sites:write`,description:`Create, delete, and deploy to sites`},{value:`panel:expose`,label:`panel:expose`,description:`Expose agent management panel at agent-<label>.<domain>`},{value:`identity:read`,label:`identity:read`,description:`Parse Authelia identity headers on plugin routes`},{value:`identity:query`,label:`identity:query`,description:`Query panel for Authelia user metadata`}];function ac({capabilities:e,onChange:t,disabled:n}){let r=n=>{n!==`tunnels:read`&&(e.includes(n)?t(e.filter(e=>e!==n)):t([...e,n]))};return(0,P.jsx)(`div`,{className:`space-y-2`,children:ic.map(t=>(0,P.jsxs)(`label`,{className:`flex items-start gap-3 rounded border px-3 py-2 cursor-pointer ${e.includes(t.value)?`border-cyan-500/30 bg-cyan-500/5`:`border-zinc-700 bg-zinc-800/50`} ${t.mandatory||n?`opacity-80`:``}`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:e.includes(t.value),onChange:()=>r(t.value),disabled:t.mandatory||n,className:`mt-0.5 accent-cyan-500`}),(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsx)(`span`,{className:`text-sm font-mono text-zinc-200`,children:t.label}),(0,P.jsx)(`p`,{className:`text-xs text-zinc-500`,children:t.description})]})]},t.value))})}function oc({onClose:e}){let t=z(),n=F(),r=G(),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)([`tunnels:read`]),[c,l]=(0,g.useState)([]),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(null),{data:_}=I({queryKey:[`sites`],queryFn:()=>t.getSites()}),v=L({mutationFn:e=>t.generateAgentCert(e),onSuccess:e=>{d(e),n.invalidateQueries({queryKey:[`agent-certs`]})},onError:e=>{h(K(e))}}),y=(0,g.useCallback)(e=>{if(e.preventDefault(),h(null),!i.trim()){h(`Label is required`);return}if(!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(i)){h(`Lowercase letters, numbers, and hyphens only. Cannot start or end with a hyphen.`);return}v.mutate({label:i,capabilities:o,allowedSites:c})},[i,o,c,v]),b=(0,g.useCallback)(async()=>{if(u?.p12Password)try{await navigator.clipboard.writeText(u.p12Password),p(!0),setTimeout(()=>p(!1),2e3)}catch{r(`Failed to copy — please select and copy manually`,`error`)}},[u,r]),x=(0,g.useCallback)(()=>{u?.label&&t.downloadAgentCert(u.label)},[u,t]),S=(0,g.useCallback)(()=>{e()},[e]);return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,P.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg bg-zinc-900 border border-zinc-800 shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between border-b border-zinc-800 px-6 py-4`,children:[(0,P.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[(0,P.jsx)(Bi,{size:20,className:`text-cyan-400`}),u?`Certificate Generated`:`Generate Agent Certificate`]}),!v.isPending&&(0,P.jsx)(`button`,{type:`button`,onClick:S,className:`text-zinc-500 hover:text-zinc-300`,children:(0,P.jsx)(Na,{size:18})})]}),(0,P.jsx)(`div`,{className:`px-6 py-5`,children:u?(0,P.jsxs)(`div`,{className:`space-y-5`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-zinc-300 block mb-2`,children:`Certificate Password:`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:`flex-1 rounded border border-zinc-700 bg-zinc-950 p-3 font-mono text-yellow-400 text-sm break-all select-all`,children:u.p12Password}),(0,P.jsx)(`button`,{type:`button`,onClick:b,className:`rounded bg-zinc-700 p-2 text-zinc-300 hover:bg-zinc-600 shrink-0`,title:`Copy password`,children:f?(0,P.jsx)(li,{size:16,className:`text-green-400`}):(0,P.jsx)(bi,{size:16})})]})]}),(0,P.jsxs)(`div`,{className:`rounded-lg bg-amber-500/10 border border-amber-500/20 p-4 text-sm text-amber-400 space-y-1`,children:[(0,P.jsx)(`p`,{className:`font-semibold`,children:`Save this password — it cannot be retrieved later.`}),(0,P.jsx)(`p`,{children:`Share the .p12 file and password securely with the Mac user.`})]}),(0,P.jsxs)(`button`,{type:`button`,onClick:x,className:`flex w-full items-center justify-center gap-2 rounded bg-cyan-600 py-3 px-6 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,P.jsx)(Ci,{size:16}),`Download `,u.label,`.p12`]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsx)(`button`,{type:`button`,onClick:S,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Done`})})]}):(0,P.jsxs)(`form`,{onSubmit:y,className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Label`}),(0,P.jsx)(`input`,{type:`text`,value:i,onChange:e=>{a(e.target.value.toLowerCase()),h(null)},disabled:v.isPending,placeholder:`e.g. macbook-pro`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder:text-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),(0,P.jsx)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:`Lowercase letters, numbers, and hyphens only.`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-2`,children:`Capabilities`}),(0,P.jsx)(ac,{capabilities:o,onChange:s,disabled:v.isPending})]}),(o.includes(`sites:read`)||o.includes(`sites:write`))&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-2`,children:`Site Access`}),(0,P.jsx)(`p`,{className:`text-xs text-zinc-500 mb-2`,children:`Select which static sites this agent can manage files for.`}),_?.sites?.length>0?(0,P.jsx)(`div`,{className:`space-y-1`,children:_.sites.map(e=>(0,P.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-zinc-300 cursor-pointer`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:c.includes(e.name),onChange:()=>{l(t=>t.includes(e.name)?t.filter(t=>t!==e.name):[...t,e.name])},disabled:v.isPending,className:`rounded border-zinc-600 bg-zinc-800 text-cyan-400 focus:ring-cyan-400`}),(0,P.jsx)(`span`,{className:`font-mono`,children:e.name}),(0,P.jsxs)(`span`,{className:`text-zinc-500 text-xs`,children:[`(`,e.fqdn,`)`]})]},e.id))}):(0,P.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`No sites created yet.`})]}),m&&(0,P.jsx)(`div`,{className:`rounded bg-red-500/10 border border-red-500/20 px-3 py-2 text-sm text-red-400`,children:m}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 justify-end`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:S,disabled:v.isPending,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`submit`,disabled:v.isPending,className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed`,children:v.isPending?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:14,className:`animate-spin`}),`Generating...`]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Bi,{size:14}),`Generate`]})})]})]})})]})})}function sc({label:e,onConfirm:t,onCancel:n,isPending:r}){return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:`Revoke Certificate`}),(0,P.jsxs)(`p`,{className:`text-zinc-400 text-sm mb-6`,children:[`Revoke certificate for ‘`,(0,P.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:e}),`’? The Mac agent using this certificate will immediately lose access.`]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,onClick:t,disabled:r,className:`flex items-center gap-2 rounded bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-500 disabled:opacity-50`,children:r?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:14,className:`animate-spin`}),`Revoking...`]}):`Revoke`})]})]})})}function cc({agent:e,onClose:t}){let n=z(),r=F(),i=G(),[a,o]=(0,g.useState)(e.capabilities||[`tunnels:read`]),s=L({mutationFn:t=>n.updateAgentCapabilities(e.label,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`agent-certs`]}),i(`Capabilities updated for ${e.label}`),t()},onError:e=>{i(K(e),`error`)}});return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,P.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg bg-zinc-900 border border-zinc-800 shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between border-b border-zinc-800 px-6 py-4`,children:[(0,P.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[(0,P.jsx)(da,{size:20,className:`text-cyan-400`}),`Capabilities — `,e.label]}),(0,P.jsx)(`button`,{type:`button`,onClick:t,className:`text-zinc-500 hover:text-zinc-300`,children:(0,P.jsx)(Na,{size:18})})]}),(0,P.jsxs)(`div`,{className:`px-6 py-5 space-y-4`,children:[(0,P.jsx)(ac,{capabilities:a,onChange:o,disabled:s.isPending}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 justify-end`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:t,disabled:s.isPending,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>s.mutate(a),disabled:s.isPending,className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:s.isPending?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:14,className:`animate-spin`}),`Saving...`]}):`Save`})]})]})]})})}function lc({agent:e,onClose:t}){let n=z(),r=F(),i=G(),[a,o]=(0,g.useState)(e.allowedSites||[]),{data:s}=I({queryKey:[`sites`],queryFn:()=>n.getSites()}),c=L({mutationFn:t=>n.updateAgentAllowedSites(e.label,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`agent-certs`]}),i(`Allowed sites updated for ${e.label}`),t()},onError:e=>{i(K(e),`error`)}});return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,P.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg bg-zinc-900 border border-zinc-800 shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between border-b border-zinc-800 px-6 py-4`,children:[(0,P.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[(0,P.jsx)(Pi,{size:20,className:`text-cyan-400`}),`Site Access — `,e.label]}),(0,P.jsx)(`button`,{type:`button`,onClick:t,className:`text-zinc-500 hover:text-zinc-300`,children:(0,P.jsx)(Na,{size:18})})]}),(0,P.jsxs)(`div`,{className:`px-6 py-5 space-y-4`,children:[(0,P.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Select which static sites this agent can manage files for.`}),s?.sites?.length>0?(0,P.jsx)(`div`,{className:`space-y-1`,children:s.sites.map(e=>(0,P.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-zinc-300 cursor-pointer`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:a.includes(e.name),onChange:()=>{o(t=>t.includes(e.name)?t.filter(t=>t!==e.name):[...t,e.name])},disabled:c.isPending,className:`rounded border-zinc-600 bg-zinc-800 text-cyan-400 focus:ring-cyan-400`}),(0,P.jsx)(`span`,{className:`font-mono`,children:e.name}),(0,P.jsxs)(`span`,{className:`text-zinc-500 text-xs`,children:[`(`,e.fqdn,`)`]})]},e.id))}):(0,P.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`No sites created yet.`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 justify-end`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:t,disabled:c.isPending,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>c.mutate(a),disabled:c.isPending,className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:c.isPending?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:14,className:`animate-spin`}),`Saving...`]}):`Save`})]})]})]})})}function uc({onClose:e}){let t=z(),n=F(),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)([`tunnels:read`]),[s,c]=(0,g.useState)([]),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(!1),[v,y]=(0,g.useState)(!1),{data:b}=I({queryKey:[`sites`],queryFn:()=>t.getSites()}),x=L({mutationFn:e=>t.createEnrollmentToken(e),onSuccess:e=>{u(e),n.invalidateQueries({queryKey:[`agent-certs`]})},onError:e=>{f(K(e))}}),S=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(r),C=()=>{f(null),x.mutate({label:r,capabilities:a,allowedSites:s})},w=async()=>{if(l?.token)try{await navigator.clipboard.writeText(l.token),m(!0),setTimeout(()=>m(!1),2e3)}catch{}},T=l?`npx @lamalibre/lamaste-agent setup --token ${l.token} --panel-url <PANEL_URL>`:``;return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,P.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl bg-zinc-900 border border-zinc-700 p-6 shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:l?`Enrollment Token`:`Generate Enrollment Token`}),(0,P.jsx)(`button`,{type:`button`,onClick:e,className:`text-zinc-400 hover:text-white`,children:(0,P.jsx)(Na,{size:20})})]}),l?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Agent Label`}),(0,P.jsx)(`p`,{className:`text-sm text-cyan-400 font-mono`,children:l.label})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Enrollment Token`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`code`,{className:`flex-1 block rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-xs text-yellow-300 font-mono break-all`,children:l.token}),(0,P.jsx)(`button`,{type:`button`,onClick:w,className:`rounded bg-zinc-700 p-2 text-zinc-300 hover:bg-zinc-600`,title:`Copy token`,children:p?(0,P.jsx)(li,{size:14,className:`text-green-400`}):(0,P.jsx)(bi,{size:14})})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Expires`}),(0,P.jsxs)(`p`,{className:`text-sm text-zinc-400`,children:[new Date(l.expiresAt).toLocaleString(),` (10 minutes)`]})]}),(0,P.jsx)(`div`,{className:`rounded bg-amber-500/10 border border-amber-500/20 px-3 py-2`,children:(0,P.jsx)(`p`,{className:`text-sm text-amber-300`,children:`This token is single-use and expires in 10 minutes. Copy and send it to the agent machine now.`})}),d&&(0,P.jsx)(`div`,{className:`rounded bg-red-500/10 border border-red-500/20 px-3 py-2 text-sm text-red-400`,children:d}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Setup Command`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`code`,{className:`flex-1 block rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-xs text-zinc-300 font-mono break-all`,children:T}),(0,P.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(T),_(!0),setTimeout(()=>_(!1),2e3)}catch{}},className:`rounded bg-zinc-700 p-2 text-zinc-300 hover:bg-zinc-600`,title:`Copy command`,children:h?(0,P.jsx)(li,{size:14,className:`text-green-400`}):(0,P.jsx)(bi,{size:14})})]}),(0,P.jsx)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:`Replace <PANEL_URL> with your panel address (e.g. https://1.2.3.4:9292)`})]})]}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-3 mt-6`,children:[(0,P.jsxs)(`button`,{type:`button`,disabled:v,onClick:async()=>{y(!0);try{await t.revokeEnrollmentToken(l.label),n.invalidateQueries({queryKey:[`agent-certs`]}),e()}catch(e){f(K(e)),y(!1)}},className:`rounded bg-red-600/20 px-4 py-2 text-sm text-red-400 hover:bg-red-600/30 disabled:opacity-50`,children:[v?(0,P.jsx)(H,{size:14,className:`animate-spin inline mr-1`}):(0,P.jsx)(ya,{size:14,className:`inline mr-1`}),`Revoke Token`]}),(0,P.jsx)(`button`,{type:`button`,onClick:e,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Done`})]})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`p`,{className:`text-sm text-zinc-400 mb-4`,children:`Generate a one-time token for hardware-bound agent enrollment. The agent will generate a non-exportable keypair in macOS Keychain.`}),(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Agent Label`}),(0,P.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value.toLowerCase()),placeholder:`e.g. macbook-pro`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder:text-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,P.jsx)(ac,{capabilities:a,onChange:o}),(a.includes(`sites:read`)||a.includes(`sites:write`))&&b?.sites?.length>0&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-2`,children:`Allowed Sites`}),(0,P.jsx)(`div`,{className:`space-y-2 max-h-40 overflow-y-auto`,children:b.sites.map(e=>(0,P.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:s.includes(e.name),onChange:()=>c(t=>t.includes(e.name)?t.filter(t=>t!==e.name):[...t,e.name]),className:`accent-cyan-500`}),(0,P.jsx)(`span`,{className:`text-zinc-300`,children:e.name}),e.fqdn&&(0,P.jsx)(`span`,{className:`text-zinc-500 text-xs`,children:e.fqdn})]},e.id))})]}),d&&(0,P.jsx)(`div`,{className:`rounded bg-red-500/10 border border-red-500/20 px-3 py-2 text-sm text-red-400`,children:d})]}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-3 mt-6`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:e,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,P.jsxs)(`button`,{type:`button`,onClick:C,disabled:!S||x.isPending,className:`rounded bg-emerald-600 px-4 py-2 text-sm font-semibold text-white hover:bg-emerald-500 disabled:opacity-50`,children:[x.isPending?(0,P.jsx)(H,{size:14,className:`animate-spin inline mr-1`}):null,`Generate Token`]})]})]})]})})}function dc(){let e=z(),t=F(),n=G(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(`all`),h=I({queryKey:[`agent-certs`],queryFn:()=>e.getAgentCerts(),refetchInterval:3e4}),_=L({mutationFn:t=>e.revokeAgentCert(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`agent-certs`]}),n(`Certificate for ${s} revoked`),c(null)},onError:e=>{n(K(e),`error`),c(null)}}),v=(0,g.useCallback)(e=>{c(e)},[]),y=(0,g.useCallback)(()=>{s&&_.mutate(s)},[s,_]),b=h.data?.agents||[],x=b.some(e=>e.enrollmentMethod===`delegated`),S=b.filter(e=>p===`regular`?e.enrollmentMethod!==`delegated`:p===`delegated`?e.enrollmentMethod===`delegated`:!0);return(0,P.jsxs)(`div`,{className:`mt-8`,children:[(0,P.jsxs)(`div`,{className:`border-t border-zinc-700 pt-6`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,P.jsx)(Bi,{size:18,className:`text-cyan-400`}),`Agent Certificates`]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`flex items-center gap-2 rounded bg-emerald-600 px-4 py-2 text-sm font-semibold text-white hover:bg-emerald-500`,title:`Generate a one-time token for hardware-bound enrollment`,children:[(0,P.jsx)(Bi,{size:14}),`Enrollment Token`]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,title:`Generate a P12 certificate file`,children:[(0,P.jsx)(ea,{size:14}),`Generate P12`]})]})]}),x&&(0,P.jsx)(`div`,{className:`flex items-center gap-1 mb-4`,children:[`all`,`regular`,`delegated`].map(e=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>m(e),className:`rounded px-3 py-1 text-xs font-medium transition-colors ${p===e?`bg-zinc-700 text-zinc-200`:`text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800`}`,children:e===`all`?`All`:e===`regular`?`Regular`:`Delegated`},e))}),h.isLoading?(0,P.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2}).map((e,t)=>(0,P.jsx)(`div`,{className:`h-14 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):h.isError?(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load agent certificates`})}):S.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,P.jsx)(Bi,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No agent certificates. Generate one to connect a Mac tunnel agent.`})]}):(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Label`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Serial`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Created`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Expires`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Capabilities`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Delegated By`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Type`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Status`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Actions`})]})}),(0,P.jsx)(`tbody`,{children:S.map(t=>(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,P.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,P.jsx)(rc,{label:t.label}),!t.revoked&&!nc(t.label)&&(0,P.jsx)(`div`,{className:`mt-0.5 min-w-[16rem]`,children:(0,P.jsx)(qs,{facts:t.hostFacts,at:t.hostFactsAt})})]}),(0,P.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-zinc-600`,children:t.serial?t.serial.slice(0,16):`N/A`}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-zinc-400`,children:Xs(t.createdAt)}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-zinc-400`,children:Xs(t.expiresAt)}),(0,P.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(t.capabilities||[`tunnels:read`]).map(e=>(0,P.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-zinc-700 text-zinc-300 font-mono`,children:e},e))}),t.allowedSites?.length>0&&(0,P.jsxs)(`span`,{className:`text-xs text-zinc-500 mt-1 block`,children:[`Sites: `,t.allowedSites.join(`, `)]})]}),(0,P.jsx)(`td`,{className:`px-4 py-3`,children:t.delegatedBy?(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-violet-400 font-mono`,children:[(0,P.jsx)(Ui,{size:12,className:`text-violet-400/70`}),t.delegatedBy]}):(0,P.jsx)(`span`,{className:`text-xs text-zinc-600`,children:`—`})}),(0,P.jsx)(`td`,{className:`px-4 py-3`,children:(0,P.jsx)(tc,{method:t.enrollmentMethod})}),(0,P.jsx)(`td`,{className:`px-4 py-3`,children:(0,P.jsx)(ec,{status:t.status})}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[t.status!==`revoked`&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>u(t),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600`,title:`Edit capabilities`,children:(0,P.jsx)(da,{size:12})}),t.status!==`revoked`&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>f(t),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600`,title:`Edit site access`,children:(0,P.jsx)(Pi,{size:12})}),t.status!==`revoked`&&t.status!==`expired`&&t.enrollmentMethod!==`hardware-bound`&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>e.downloadAgentCert(t.label),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600`,title:`Download .p12`,children:(0,P.jsx)(Ci,{size:12})}),t.status!==`revoked`&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>v(t.label),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-red-600/20 hover:text-red-400`,title:`Revoke certificate`,children:(0,P.jsx)(ya,{size:12})})]})})]},t.label))})]})})]}),r&&(0,P.jsx)(oc,{onClose:()=>i(!1)}),a&&(0,P.jsx)(uc,{onClose:()=>o(!1)}),s&&(0,P.jsx)(sc,{label:s,onConfirm:y,onCancel:()=>c(null),isPending:_.isPending}),l&&(0,P.jsx)(cc,{agent:l,onClose:()=>u(null)}),d&&(0,P.jsx)(lc,{agent:d,onClose:()=>f(null)})]})}function fc({onClose:e}){let t=z(),n=F(),r=G(),[i,a]=(0,g.useState)(`warning`),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(!1),_=L({mutationFn:()=>t.rotateMtls(),onSuccess:e=>{s(e),a(`success`),n.invalidateQueries({queryKey:[`certs`]})},onError:e=>{l(K(e)),a(`error`)}}),v=(0,g.useCallback)(()=>{a(`rotating`),_.mutate()},[_]),y=(0,g.useCallback)(async()=>{if(o?.p12Password)try{await navigator.clipboard.writeText(o.p12Password),d(!0),setTimeout(()=>d(!1),2e3)}catch{r(`Failed to copy — please select and copy manually`,`error`)}},[o,r]),b=(0,g.useCallback)(async()=>{try{await t.downloadMtls()}catch(e){r(K(e)||`Download failed`,`error`)}},[t,r]),x=(0,g.useCallback)(()=>{if(!m){h(!0);return}e()},[m,e]);return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,P.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg bg-zinc-900 border border-zinc-800 shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between border-b border-zinc-800 px-6 py-4`,children:[(0,P.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[i===`warning`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(ba,{size:20,className:`text-amber-400`}),`Rotate Client Certificate`]}),i===`rotating`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:20,className:`animate-spin text-cyan-400`}),`Generating New Certificate...`]}),i===`success`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(pa,{size:20,className:`text-green-400`}),`New Certificate Ready`]}),i===`error`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(ba,{size:20,className:`text-red-400`}),`Rotation Failed`]})]}),(i===`warning`||i===`error`)&&(0,P.jsx)(`button`,{type:`button`,onClick:e,className:`text-zinc-500 hover:text-zinc-300`,children:(0,P.jsx)(Na,{size:18})})]}),(0,P.jsxs)(`div`,{className:`px-6 py-5`,children:[i===`warning`&&(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{className:`rounded-lg bg-amber-500/10 border border-amber-500/20 p-4 text-sm text-amber-400 space-y-2`,children:[(0,P.jsx)(`p`,{className:`font-semibold`,children:`This will immediately invalidate your current browser certificate.`}),(0,P.jsxs)(`p`,{children:[`You `,(0,P.jsx)(`strong`,{children:`MUST`}),` download and import the new certificate before closing this page or your browser.`]}),(0,P.jsx)(`p`,{children:`If you fail to do this, you will be locked out of the panel and will need SSH access to recover.`})]}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:e,autoFocus:!0,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,onClick:v,className:`rounded bg-red-600 px-4 py-2 text-sm text-white hover:bg-red-500`,children:`I Understand, Rotate`})]})]}),i===`rotating`&&(0,P.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`Generating new certificate...`})}),i===`success`&&o&&(0,P.jsxs)(`div`,{className:`space-y-5`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-zinc-300 block mb-2`,children:`Certificate Password (copy this first):`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:`flex-1 rounded border border-zinc-700 bg-zinc-950 p-3 font-mono text-cyan-400 text-sm break-all select-all`,children:o.p12Password}),(0,P.jsx)(`button`,{type:`button`,onClick:y,className:`rounded bg-zinc-700 p-2 text-zinc-300 hover:bg-zinc-600 shrink-0`,title:`Copy password`,children:u?(0,P.jsx)(li,{size:16,className:`text-green-400`}):(0,P.jsx)(bi,{size:16})})]})]}),(0,P.jsxs)(`button`,{type:`button`,onClick:b,className:`flex w-full items-center justify-center gap-2 rounded bg-cyan-600 py-3 px-6 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,P.jsx)(Ci,{size:16}),`Download Certificate`]}),(0,P.jsxs)(`ol`,{className:`list-decimal list-inside text-sm text-zinc-400 space-y-1.5 pl-1`,children:[(0,P.jsx)(`li`,{children:`Copy the password above`}),(0,P.jsx)(`li`,{children:`Click Download Certificate`}),(0,P.jsx)(`li`,{children:`Double-click the downloaded file to import it into your browser's keychain`}),(0,P.jsx)(`li`,{children:`Enter the password when prompted`}),(0,P.jsx)(`li`,{children:`Restart your browser to use the new certificate`})]}),(0,P.jsxs)(`div`,{className:`border-t border-zinc-700 pt-4`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>p(e=>!e),className:`flex items-center gap-1.5 text-xs text-zinc-500 hover:text-zinc-400`,children:[f?(0,P.jsx)(pi,{size:14}):(0,P.jsx)(ui,{size:14}),`Recovery instructions (if locked out)`]}),f&&(0,P.jsxs)(`div`,{className:`mt-3 rounded border border-zinc-700 bg-zinc-950 p-3`,children:[(0,P.jsx)(`p`,{className:`text-xs text-zinc-400 mb-2`,children:`If you get locked out, connect via SSH and run these commands to restore the backup:`}),(0,P.jsx)(`pre`,{className:`text-xs text-zinc-300 font-mono whitespace-pre-wrap`,children:`sudo cp /etc/lamalibre/lamaste/pki/client.crt.bak /etc/lamalibre/lamaste/pki/client.crt
9
- sudo cp /etc/lamalibre/lamaste/pki/client.key.bak /etc/lamalibre/lamaste/pki/client.key
10
- sudo cp /etc/lamalibre/lamaste/pki/client.p12.bak /etc/lamalibre/lamaste/pki/client.p12
11
- sudo systemctl reload nginx`})]})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:m?(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Have you downloaded and imported the new certificate?`}),(0,P.jsx)(`button`,{type:`button`,onClick:x,className:`rounded bg-green-600 px-4 py-2 text-sm text-white hover:bg-green-500`,children:`Yes, Done`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>h(!1),className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Not yet`})]}):(0,P.jsx)(`button`,{type:`button`,onClick:x,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Done`})})]}),i===`error`&&(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{className:`rounded-lg bg-red-500/10 border border-red-500/20 p-4 text-sm text-red-400`,children:[(0,P.jsx)(`p`,{className:`font-semibold mb-1`,children:`Rotation failed`}),(0,P.jsx)(`p`,{children:c}),(0,P.jsx)(`p`,{className:`mt-2 text-zinc-400`,children:`Your existing certificate is still valid.`})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsx)(`button`,{type:`button`,onClick:e,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Close`})})]})]})]})})}function pc(){let e=z(),t=F(),n=G(),[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(!1),s=I({queryKey:[`certs`],queryFn:()=>e.getCerts(),refetchInterval:3e4}),c=I({queryKey:[`auto-renew-status`],queryFn:()=>e.getAutoRenewStatus()}),l=I({queryKey:[`admin-auth-mode`],queryFn:()=>e.getAuthMode()}).data?.adminAuthMode||`p12`,u=L({mutationFn:t=>e.renewCert(t),onSuccess:e=>{t.invalidateQueries({queryKey:[`certs`]});let r=e.newExpiry?` New expiry: ${Xs(e.newExpiry)}`:``;n(`Certificate for ${e.domain} renewed.${r}`),e.warning&&n(e.warning,`error`),i(null)},onError:e=>{n(K(e),`error`),i(null)}}),d=(0,g.useCallback)(e=>{i(e),u.mutate(e)},[u]),f=s.data?.certs||[];return(0,P.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,P.jsxs)(`div`,{className:`mb-6`,children:[(0,P.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Certificates`}),(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`View and manage TLS and mTLS certificates`})]}),(0,P.jsx)(Zs,{data:c.data,isLoading:c.isLoading}),s.isLoading?(0,P.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,P.jsx)(`div`,{className:`h-14 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):s.isError?(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load certificates`})}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Qs,{certs:f,onRenew:d,renewingDomain:r}),(0,P.jsx)($s,{certs:f,onRotate:()=>o(!0),adminAuthMode:l}),(0,P.jsx)(dc,{})]}),a&&(0,P.jsx)(fc,{onClose:()=>o(!1)})]})}function mc({status:e}){return(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${e===`active`?`bg-green-500/20 text-green-400`:e===`stale`?`bg-yellow-500/20 text-yellow-400`:e===`dead`?`bg-red-500/20 text-red-400`:e===`grace`?`bg-orange-500/20 text-orange-400`:`bg-zinc-500/20 text-zinc-400`}`,children:e})}function hc({ticket:e}){return e.used?(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-zinc-500/20 text-zinc-400`,children:`used`}):new Date(e.expiresAt)<new Date?(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-red-500/20 text-red-400`,children:`expired`}):(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-green-500/20 text-green-400`,children:`pending`})}function gc(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:new Date(e).toLocaleDateString()}var q=[{id:`scopes`,label:`Scopes`},{id:`instances`,label:`Instances`},{id:`assignments`,label:`Assignments`},{id:`tickets`,label:`Tickets`},{id:`sessions`,label:`Sessions`}];function _c(){let e=z(),t=F(),n=G(),{data:r,isLoading:i,isError:a}=I({queryKey:[`ticket-scopes`],queryFn:()=>e.getTicketScopes(),refetchInterval:1e4}),o=L({mutationFn:t=>e.deleteTicketScope(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`ticket-scopes`]}),n(`Scope unregistered`)},onError:e=>n(K(e),`error`)}),[s,c]=(0,g.useState)(null);if(i)return(0,P.jsx)(`div`,{className:`animate-pulse h-32 rounded-lg bg-zinc-900 border border-zinc-800`});if(a)return(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load scopes`})});let l=r?.scopes||[];return l.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,P.jsx)(va,{className:`mx-auto h-8 w-8 text-zinc-600 mb-3`}),(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No ticket scopes registered`}),(0,P.jsx)(`p`,{className:`text-zinc-600 text-xs mt-1`,children:`Install a ticket scope package to get started`})]}):(0,P.jsx)(`div`,{className:`space-y-3`,children:l.map(e=>(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(va,{size:16,className:`text-cyan-400`}),(0,P.jsx)(`span`,{className:`text-white font-semibold`,children:e.name}),(0,P.jsxs)(`span`,{className:`text-zinc-500 text-xs`,children:[`v`,e.version]})]}),s===e.name?(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-zinc-400`,children:`Remove?`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>{o.mutate(e.name),c(null)},className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500`,children:`Yes`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`})]}):(0,P.jsx)(`button`,{type:`button`,onClick:()=>c(e.name),className:`text-zinc-500 hover:text-red-400`,title:`Unregister scope`,children:(0,P.jsx)(ya,{size:14})})]}),(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm mb-2`,children:e.description}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.scopes?.map(e=>(0,P.jsxs)(`span`,{className:`text-xs bg-zinc-800 text-cyan-400 px-2 py-0.5 rounded font-mono`,children:[e.name,e.instanceScoped&&(0,P.jsx)(`span`,{className:`text-zinc-500 ml-1`,children:`(instance-scoped)`})]},e.name))}),(0,P.jsxs)(`div`,{className:`mt-2 flex gap-3 text-xs text-zinc-500`,children:[(0,P.jsxs)(`span`,{children:[`Transport: `,e.transport?.strategies?.join(`, `)]}),(0,P.jsxs)(`span`,{children:[`Protocol: `,e.transport?.protocol]}),(0,P.jsxs)(`span`,{children:[`Installed: `,gc(e.installedAt)]})]})]},e.name))})}function vc(){let e=z(),t=F(),n=G(),[r,i]=(0,g.useState)(null),{data:a,isLoading:o,isError:s}=I({queryKey:[`ticket-instances`],queryFn:()=>e.getTicketInstances(),refetchInterval:1e4}),c=L({mutationFn:t=>e.deleteTicketInstance(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`ticket-instances`]}),n(`Instance deregistered`),i(null)},onError:e=>n(K(e),`error`)});if(o)return(0,P.jsx)(`div`,{className:`animate-pulse h-32 rounded-lg bg-zinc-900 border border-zinc-800`});if(s)return(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load instances`})});let l=a?.instances||[];return l.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,P.jsx)(la,{className:`mx-auto h-8 w-8 text-zinc-600 mb-3`}),(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No instances registered`})]}):(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-800 text-left text-zinc-500`,children:[(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Instance ID`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Scope`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Agent`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Status`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Last Heartbeat`}),(0,P.jsx)(`th`,{className:`pb-2 font-medium`,children:`Actions`})]})}),(0,P.jsx)(`tbody`,{children:l.map(e=>(0,P.jsxs)(`tr`,{className:`border-b border-zinc-800/50`,children:[(0,P.jsxs)(`td`,{className:`py-3 pr-4 font-mono text-cyan-400 text-xs`,children:[e.instanceId.slice(0,12),`...`]}),(0,P.jsx)(`td`,{className:`py-3 pr-4 font-mono text-zinc-300 text-xs`,children:e.scope}),(0,P.jsx)(`td`,{className:`py-3 pr-4 text-zinc-300`,children:e.agentLabel}),(0,P.jsx)(`td`,{className:`py-3 pr-4`,children:(0,P.jsx)(mc,{status:e.status})}),(0,P.jsx)(`td`,{className:`py-3 pr-4 text-zinc-500 text-xs`,children:gc(e.lastHeartbeat)}),(0,P.jsx)(`td`,{className:`py-3`,children:r===e.instanceId?(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-zinc-400`,children:`Remove?`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>c.mutate(e.instanceId),className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500`,children:`Yes`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>i(null),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`})]}):(0,P.jsx)(`button`,{type:`button`,onClick:()=>i(e.instanceId),className:`text-zinc-500 hover:text-red-400`,title:`Deregister instance`,children:(0,P.jsx)(ya,{size:14})})})]},e.instanceId))})]})})}function yc(){let e=z(),t=F(),n=G(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(null),{data:d,isLoading:f,isError:p}=I({queryKey:[`ticket-assignments`],queryFn:()=>e.getTicketAssignments(),refetchInterval:1e4}),{data:m}=I({queryKey:[`ticket-scopes`],queryFn:()=>e.getTicketScopes(),refetchInterval:1e4}),{data:h}=I({queryKey:[`agents-list`],queryFn:()=>e.getAgentCerts(),staleTime:3e4}),_=L({mutationFn:t=>e.createTicketAssignment(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`ticket-assignments`]}),n(`Assignment created`),i(!1),o(``),c(``)},onError:e=>n(K(e),`error`)}),v=L({mutationFn:({agentLabel:t,instanceScope:n})=>e.deleteTicketAssignment(t,n),onSuccess:()=>{t.invalidateQueries({queryKey:[`ticket-assignments`]}),n(`Assignment removed`),u(null)},onError:e=>n(K(e),`error`)});if(f)return(0,P.jsx)(`div`,{className:`animate-pulse h-32 rounded-lg bg-zinc-900 border border-zinc-800`});if(p)return(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load assignments`})});let y=d?.assignments||[],b=m?.instances||[],x=(h?.agents||[]).filter(e=>!e.revoked),S=b.filter(e=>e.status!==`dead`).map(e=>`${e.scope}:${e.instanceId}`);return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`Assign agents to ticket scope instances`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>i(!r),className:`rounded bg-cyan-600 px-3 py-1.5 text-xs text-white hover:bg-cyan-500`,children:r?`Cancel`:`Add Assignment`})]}),r&&(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-4 mb-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 mb-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Agent`}),(0,P.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-1.5 text-sm text-zinc-300 focus:outline-none focus:border-cyan-400`,children:[(0,P.jsx)(`option`,{value:``,children:`Select agent...`}),x.map(e=>(0,P.jsx)(`option`,{value:e.label,children:e.label},e.label))]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Instance Scope`}),(0,P.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-1.5 text-sm text-zinc-300 focus:outline-none focus:border-cyan-400`,children:[(0,P.jsx)(`option`,{value:``,children:`Select instance...`}),S.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>_.mutate({agentLabel:a,instanceScope:s}),disabled:!a||!s||_.isPending,className:`rounded bg-cyan-600 px-4 py-1.5 text-xs text-white hover:bg-cyan-500 disabled:opacity-50`,children:`Assign`})]}),y.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,P.jsx)(Wi,{className:`mx-auto h-8 w-8 text-zinc-600 mb-3`}),(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No assignments`})]}):(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-800 text-left text-zinc-500`,children:[(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Agent`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Instance Scope`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Assigned`}),(0,P.jsx)(`th`,{className:`pb-2 font-medium`,children:`Actions`})]})}),(0,P.jsx)(`tbody`,{children:y.map(e=>(0,P.jsxs)(`tr`,{className:`border-b border-zinc-800/50`,children:[(0,P.jsx)(`td`,{className:`py-3 pr-4 text-zinc-300`,children:e.agentLabel}),(0,P.jsx)(`td`,{className:`py-3 pr-4 font-mono text-cyan-400 text-xs`,children:e.instanceScope}),(0,P.jsx)(`td`,{className:`py-3 pr-4 text-zinc-500 text-xs`,children:gc(e.assignedAt)}),(0,P.jsx)(`td`,{className:`py-3`,children:l===`${e.agentLabel}:${e.instanceScope}`?(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-zinc-400`,children:`Remove?`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>v.mutate({agentLabel:e.agentLabel,instanceScope:e.instanceScope}),className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500`,children:`Yes`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>u(null),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`})]}):(0,P.jsx)(`button`,{type:`button`,onClick:()=>u(`${e.agentLabel}:${e.instanceScope}`),className:`text-zinc-500 hover:text-red-400`,title:`Remove assignment`,children:(0,P.jsx)(ya,{size:14})})})]},`${e.agentLabel}-${e.instanceScope}`))})]})})]})}function bc(){let e=z(),t=F(),n=G(),[r,i]=(0,g.useState)(null),{data:a,isLoading:o,isError:s}=I({queryKey:[`tickets`],queryFn:()=>e.getTickets(),refetchInterval:5e3}),c=L({mutationFn:t=>e.revokeTicket(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`tickets`]}),n(`Ticket revoked`),i(null)},onError:e=>n(K(e),`error`)});if(o)return(0,P.jsx)(`div`,{className:`animate-pulse h-32 rounded-lg bg-zinc-900 border border-zinc-800`});if(s)return(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load tickets`})});let l=a?.tickets||[];return l.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,P.jsx)(yi,{className:`mx-auto h-8 w-8 text-zinc-600 mb-3`}),(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No recent tickets`})]}):(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-800 text-left text-zinc-500`,children:[(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Ticket ID`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Scope`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Source`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Target`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Status`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Created`}),(0,P.jsx)(`th`,{className:`pb-2 font-medium`,children:`Actions`})]})}),(0,P.jsx)(`tbody`,{children:l.map(e=>(0,P.jsxs)(`tr`,{className:`border-b border-zinc-800/50`,children:[(0,P.jsxs)(`td`,{className:`py-3 pr-4 font-mono text-cyan-400 text-xs`,children:[e.id.slice(0,12),`...`]}),(0,P.jsx)(`td`,{className:`py-3 pr-4 font-mono text-zinc-300 text-xs`,children:e.scope}),(0,P.jsx)(`td`,{className:`py-3 pr-4 text-zinc-300`,children:e.source}),(0,P.jsx)(`td`,{className:`py-3 pr-4 text-zinc-300`,children:e.target}),(0,P.jsx)(`td`,{className:`py-3 pr-4`,children:(0,P.jsx)(hc,{ticket:e})}),(0,P.jsx)(`td`,{className:`py-3 pr-4 text-zinc-500 text-xs`,children:gc(e.createdAt)}),(0,P.jsx)(`td`,{className:`py-3`,children:!e.used&&new Date(e.expiresAt)>new Date&&(r===e.id?(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-zinc-400`,children:`Revoke?`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>c.mutate(e.id),className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500`,children:`Yes`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>i(null),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`})]}):(0,P.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),className:`text-zinc-500 hover:text-red-400`,title:`Revoke ticket`,children:(0,P.jsx)(_i,{size:14})}))})]},e.id))})]})})}function xc(){let e=z(),t=F(),n=G(),[r,i]=(0,g.useState)(null),{data:a,isLoading:o,isError:s}=I({queryKey:[`ticket-sessions`],queryFn:()=>e.getTicketSessions(),refetchInterval:5e3}),c=L({mutationFn:t=>e.killTicketSession(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`ticket-sessions`]}),n(`Session terminated`),i(null)},onError:e=>n(K(e),`error`)});if(o)return(0,P.jsx)(`div`,{className:`animate-pulse h-32 rounded-lg bg-zinc-900 border border-zinc-800`});if(s)return(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load sessions`})});let l=a?.sessions||[];return l.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,P.jsx)(la,{className:`mx-auto h-8 w-8 text-zinc-600 mb-3`}),(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No active sessions`})]}):(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-800 text-left text-zinc-500`,children:[(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Session ID`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Scope`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Source`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Target`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Status`}),(0,P.jsx)(`th`,{className:`pb-2 pr-4 font-medium`,children:`Last Activity`}),(0,P.jsx)(`th`,{className:`pb-2 font-medium`,children:`Actions`})]})}),(0,P.jsx)(`tbody`,{children:l.map(e=>(0,P.jsxs)(`tr`,{className:`border-b border-zinc-800/50`,children:[(0,P.jsxs)(`td`,{className:`py-3 pr-4 font-mono text-cyan-400 text-xs`,children:[e.sessionId.slice(0,12),`...`]}),(0,P.jsx)(`td`,{className:`py-3 pr-4 font-mono text-zinc-300 text-xs`,children:e.scope}),(0,P.jsx)(`td`,{className:`py-3 pr-4 text-zinc-300`,children:e.source}),(0,P.jsx)(`td`,{className:`py-3 pr-4 text-zinc-300`,children:e.target}),(0,P.jsx)(`td`,{className:`py-3 pr-4`,children:(0,P.jsx)(mc,{status:e.status})}),(0,P.jsx)(`td`,{className:`py-3 pr-4 text-zinc-500 text-xs`,children:gc(e.lastActivityAt)}),(0,P.jsx)(`td`,{className:`py-3`,children:e.status!==`dead`&&(r===e.sessionId?(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-zinc-400`,children:`Kill?`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>c.mutate(e.sessionId),className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500`,children:`Yes`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>i(null),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`})]}):(0,P.jsx)(`button`,{type:`button`,onClick:()=>i(e.sessionId),className:`text-zinc-500 hover:text-red-400`,title:`Kill session`,children:(0,P.jsx)(_i,{size:14})}))})]},e.sessionId))})]})})}function Sc(){let[e,t]=(0,g.useState)(`scopes`);return(0,P.jsxs)(`div`,{className:`p-6 max-w-5xl mx-auto`,children:[(0,P.jsxs)(`div`,{className:`mb-6`,children:[(0,P.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Tickets & Sessions`}),(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Manage agent-to-agent authorization scopes, instances, and active sessions`})]}),(0,P.jsx)(`div`,{className:`flex gap-1 mb-6 border-b border-zinc-800`,children:q.map(n=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(n.id),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${e===n.id?`border-cyan-400 text-cyan-400`:`border-transparent text-zinc-500 hover:text-zinc-300`}`,children:n.label},n.id))}),e===`scopes`&&(0,P.jsx)(_c,{}),e===`instances`&&(0,P.jsx)(vc,{}),e===`assignments`&&(0,P.jsx)(yc,{}),e===`tickets`&&(0,P.jsx)(bc,{}),e===`sessions`&&(0,P.jsx)(xc,{})]})}var Cc={install:`installs`,update:`updates`,uninstall:`removes`};function wc(e,{agentLabel:t=null,action:n=`install`}={}){let{code:r,reasons:i}=vo(e),a=t?`agent "${t}"`:`the hosting agent`,o=null;return r===`push_install_refused`?o=`Lamaste ${Cc[n]??`changes`} the agent half by push install: push install must be on for this relay and enabled for ${a} with its window open, and the agent's policy must allow "${n}" of the agent package from your address.`:r===`agent_not_eligible`?o=`Each agent reports its host on its sync (about every 30 seconds) — once what the reasons name is fixed on the agent, it becomes eligible.`:r===`hooks_not_approved`&&(o=`Review and approve what the plugin brings under Lifecycle hooks on its card first.`),{message:K(e),code:r,reasons:i,hint:o}}function Tc(e,t){let{message:n,hint:r}=wc(e,t);return r?`${n} — ${r}`:n}function Ec(e){return e?`${e.slice(0,8)}…${e.slice(-6)}`:``}function Dc(e){return e.length>32?`${e.slice(0,17)}…${e.slice(-8)}`:e}var Oc={done:(0,P.jsx)(gi,{size:12,className:`text-green-400`}),failed:(0,P.jsx)(_i,{size:12,className:`text-red-400`}),skipped:(0,P.jsx)(Yi,{size:12,className:`text-zinc-600`}),running:(0,P.jsx)(H,{size:12,className:`text-cyan-400 animate-spin`})},kc={running:`text-cyan-400`,succeeded:`text-green-400`,"rolled-back":`text-yellow-400`,failed:`text-red-400`,interrupted:`text-red-400`},Ac={host:`Hosting`,unhost:`Removing the hosting`,update:`Update`,uninstall:`Uninstall`,"purge-data":`Purging retained data`};function jc({plugin:e}){let t=z(),n=F(),r=I({queryKey:[`plugin-operations`,e],queryFn:()=>t.getPluginOperations(e),refetchInterval:e=>e.state.data?.operations?.[0]?.status===`running`?2e3:15e3}),i=r.data?.operations,a=i?.[0],o=a?.status,s=(0,g.useRef)(o);(0,g.useEffect)(()=>{s.current===`running`&&o!==`running`&&(n.invalidateQueries({queryKey:[`plugins`]}),n.invalidateQueries({queryKey:[`tunnels`]}),n.invalidateQueries({queryKey:[`plugin-hooks`,e]})),s.current=o},[o,e,n]);let c=a?.finishedAt?Date.parse(a.finishedAt):null;return(0,P.jsxs)(P.Fragment,{children:[a!=null&&!(c&&r.dataUpdatedAt-c>10*6e4)&&(0,P.jsx)(Mc,{op:a}),(0,P.jsx)(Nc,{plugin:e,operations:i})]})}function Mc({op:e}){return(0,P.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,P.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:Ac[e.kind]??e.kind}),(0,P.jsx)(`span`,{className:kc[e.status]??`text-zinc-400`,children:e.status===`rolled-back`?`rolled back`:e.status}),(0,P.jsxs)(`span`,{className:`text-zinc-600`,children:[`by `,e.actor]})]}),(0,P.jsxs)(`ul`,{className:`space-y-1`,children:[e.steps.map((e,t)=>(0,P.jsxs)(`li`,{className:`flex items-start gap-1.5`,children:[(0,P.jsx)(`span`,{className:`mt-0.5`,children:Oc[e.status]??(0,P.jsx)(vi,{size:12})}),(0,P.jsxs)(`span`,{className:e.status===`skipped`?`text-zinc-600`:`text-zinc-300`,children:[e.name,(e.error||e.detail)&&(0,P.jsxs)(`span`,{className:`text-zinc-500`,children:[` — `,e.error??e.detail]})]})]},t)),e.status===`running`&&e.steps.every(e=>e.status!==`running`)&&(0,P.jsxs)(`li`,{className:`flex items-center gap-1.5 text-zinc-500`,children:[(0,P.jsx)(H,{size:12,className:`animate-spin`}),` waiting…`]})]}),e.warnings?.length>0&&(0,P.jsx)(`ul`,{className:`mt-2 space-y-1`,children:e.warnings.map((e,t)=>(0,P.jsxs)(`li`,{className:`flex items-start gap-1.5 text-yellow-400`,children:[(0,P.jsx)(ba,{size:12,className:`mt-0.5 shrink-0`}),` `,e]},t))}),e.error&&e.status!==`running`&&(0,P.jsx)(`p`,{className:`mt-2 text-red-400`,children:e.error})]})}function Nc({plugin:e,operations:t}){let n=z(),r=F(),i=G(),{reveal:a,followState:o,claimOperation:s,releaseOperation:c}=Za(),l=(0,g.useMemo)(()=>(t??[]).map(e=>({op:e,action:Wa(e,o(e.id))})).filter(({action:e})=>e!==null),[t,o]),u=(0,g.useCallback)(async(t,{asked:o})=>{if(s(t.id))try{let{operation:s}=await n.getPluginOperation(e,t.id),{secrets:c}=Ua(s);r.setQueryData([`plugin-operations`,e],e=>Ga(e,t.id)),c.length>0?a({plugin:e,cause:t.kind,secrets:c}):o&&i(`Nothing to show — the secrets were shown elsewhere, or waited more than an hour`,`error`)}catch(e){i(`Could not read the client secrets: ${K(e)}`,`error`)}finally{c(t.id),r.invalidateQueries({queryKey:[`plugin-operations`,e]})}},[e,n,r,i,a,s,c]);(0,g.useEffect)(()=>{for(let{op:e,action:t}of l)t===`read`?u(e,{asked:!1}):t===`forget`&&c(e.id)},[l,u,c]);let d=l.filter(({action:e})=>e!==`forget`);return d.length===0?null:d.map(({op:e,action:t})=>(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded border border-amber-500/30 bg-amber-500/5 p-3 mb-4 text-xs`,children:[(0,P.jsx)(zi,{size:12,className:`shrink-0 text-amber-400`}),t===`offer`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`span`,{className:`flex-1 text-amber-400`,children:[Ac[e.kind]??e.kind,e.finishedAt?` (${new Date(e.finishedAt).toLocaleString()})`:``,` created confidential OIDC client secrets that were not shown yet. They are shown once.`]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>u(e,{asked:!0}),className:`rounded bg-amber-600 px-2.5 py-1 text-white hover:bg-amber-500`,children:`Show the secrets`})]}):(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5 text-zinc-400`,children:[(0,P.jsx)(H,{size:12,className:`animate-spin`}),`Reading the new client secrets…`]})]},e.id))}function Pc({relay:e}){return(0,P.jsxs)(`div`,{className:`space-y-1.5 text-zinc-400`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`module `}),e.entry?(0,P.jsxs)(`span`,{className:`font-mono text-zinc-300`,title:e.entrySha256,children:[e.entry,` `,(0,P.jsxs)(`span`,{className:`text-zinc-600`,children:[`sha256 `,Ec(e.entrySha256)]})]}):(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`none — shared hooks only`})]}),e.stages.length>0&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`stages `}),e.stages.map(e=>(0,P.jsxs)(`span`,{className:`mr-2 font-mono text-zinc-300`,children:[e.stage,(0,P.jsxs)(`span`,{className:`text-zinc-600`,children:[` `,e.timeoutMs,` ms`]})]},e.stage))]}),e.request.map(e=>(0,P.jsxs)(`div`,{className:`rounded bg-zinc-900 px-2 py-1.5`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.stage}),(0,P.jsx)(`span`,{className:`text-zinc-500`,children:e.use??`plugin module`}),e.failOpen.length>0&&(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-yellow-500/15 px-1.5 text-yellow-400`,title:`Traffic passes when this hook fails, times out, or cannot see the body`,children:[(0,P.jsx)(fa,{size:11}),` fail-open: `,e.failOpen.join(`, `)]})]}),(0,P.jsx)(`div`,{className:`font-mono text-zinc-400`,children:e.routes.join(`, `)}),(0,P.jsxs)(`div`,{className:`text-zinc-600`,children:[`body `,e.bodyMaxBytes===null?`not seen`:`${e.bodyMaxBytes} B`,` · `,e.timeoutMs,` ms · on error `,e.onError,e.settings&&` · ${e.settings.action}, packs ${e.settings.packs.join(`, `)}, unscannable ${e.settings.onUnscannable}`]}),e.userSurfaceRoutes.length>0&&(0,P.jsxs)(`div`,{className:`text-zinc-600`,children:[`runs on user-surface requests (plugins that declare identity):`,` `,e.userSurfaceRoutes.join(`, `)]})]},e.index)),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`effects `}),(0,P.jsx)(`span`,{className:`text-zinc-300`,children:e.effects.length>0?e.effects.join(`, `):`none`}),e.packs.length>0&&(0,P.jsxs)(`span`,{className:`text-zinc-500`,children:[` · rule packs `,e.packs.join(`, `)]})]})]})}function Fc({integrity:e}){let[t,n]=(0,g.useState)(!1);return(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,title:e,children:Dc(e)}),(0,P.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}},title:`Copy the full integrity`,"aria-label":`Copy the full integrity`,className:`text-zinc-500 hover:text-zinc-300`,children:t?(0,P.jsx)(li,{size:11,className:`text-green-400`}):(0,P.jsx)(bi,{size:11})})]})}function Ic({agentHalf:e}){return(0,P.jsxs)(`div`,{className:`space-y-1 text-zinc-400`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`package `}),(0,P.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[e.package,`@`,e.version]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`integrity `}),(0,P.jsx)(Fc,{integrity:e.integrity})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`entry `}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.entry}),(0,P.jsx)(`span`,{className:`text-zinc-500`,children:` · memory `}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.memoryMax??`not limited`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`runs as `}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.serviceUser}),(0,P.jsx)(`span`,{className:`text-zinc-500`,children:` · unit `}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.unitName})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`data `}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.dataDir}),(0,P.jsx)(`span`,{className:`text-zinc-600`,children:` — kept when it is removed, unless purged`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`system packages `}),e.systemPackages.length>0?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.systemPackages.join(`, `)}),(0,P.jsx)(`span`,{className:`text-zinc-600`,children:` — installed with apt-get once approved`})]}):(0,P.jsx)(`span`,{className:`text-zinc-300`,children:`none`})]})]})}function Lc(e,t){e.invalidateQueries({queryKey:[`plugin-hooks`,t]}),e.invalidateQueries({queryKey:[`plugins`]}),e.invalidateQueries({queryKey:[`plugin-operations`,t]})}function Rc(e,t){return Tc(e,{agentLabel:t.agentHosting?.agentLabel,action:`update`})}function zc(e){return{relay:e.relay??null,agentHalf:e.agentHalf??null,identity:e.identity?.declared?e.identity.block:null}}function Bc(e){return{relay:e.relay??null,agentHalf:e.agentHalf??null,identity:e.identity?.after??null}}function Vc(e){return e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function Hc({relay:e,agentHalf:t,identity:n}){let r=[e&&`relay hooks`,t&&`agent half`,n&&`identity`].filter(Boolean);return r.length===0?{subject:`relay hooks`,plural:!0}:{subject:Vc(r),plural:r.length>1||r[0]===`relay hooks`}}function Uc({relay:e,agentHalf:t,identity:n}){let r=[e&&`run this code on the relay`,t&&(e||n?`install this agent half`:`install this agent half on the hosting agent`),n&&`send it its users with these roles and attributes`].filter(Boolean),i=Vc(r.length>0?r:[`run this code on the relay`]);return`${i.charAt(0).toUpperCase()}${i.slice(1)}?`}function Wc({relay:e,agentHalf:t,identity:n}){let r=[e&&`runs its relay hooks`,t&&`installs its agent half`,n&&`sends it its users (and lets them reach it)`,`hosts the plugin`].filter(Boolean),i=e&&!t&&!n?`they are`:`this is`;return`Lamaste ${Vc(r)} only once ${i} approved.`}var Gc=`settings.secret-to-plain`,J=`digest.unapproved`;function Kc(e){let t=new Set((e.approvalRequired??[]).map(e=>e.code)),n=e.settings?.secretToPlain??[],r=`${n.join(`, `)} into ${n.length===1?`a plain setting`:`plain settings`}`,i=Bc(e);return t.has(J)&&t.has(Gc)?`${Uc(i).replace(/\?$/,``)}, and turn ${r}?`:t.has(Gc)?`Turn ${r} and update?`:Uc(i)}function qc({digest:e,approved:t=!1}){return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`approval digest `}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,title:e,children:Ec(e)}),t&&(0,P.jsx)(`span`,{className:`text-zinc-500`,children:` — unchanged, already approved`})]})}function Jc({reasons:e}){return e.length===0?null:(0,P.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-5`,children:e.map(e=>(0,P.jsxs)(`li`,{className:e.code===Gc?`text-red-400`:`text-yellow-400/90`,children:[e.reason,e.code===`identity.changed`&&(0,P.jsxs)(`span`,{className:`text-zinc-500`,children:[` `,`— who its users are and what it learns about them; auto-approve never covers it`]})]},e.code))})}function Yc({block:e}){return(0,P.jsxs)(`div`,{className:`space-y-1 text-zinc-400`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`roles `}),e.roles.map((e,t)=>(0,P.jsxs)(`span`,{children:[t>0&&(0,P.jsx)(`span`,{className:`text-zinc-600`,children:`, `}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,title:e.description,children:e.id}),(0,P.jsxs)(`span`,{className:`text-zinc-500`,children:[` (`,e.label,`)`]})]},e.id))]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`receives `}),(0,P.jsx)(`span`,{className:`text-zinc-300`,children:[`user id`,`username`,`roles`,`status`,...e.attributes.map(fs)].join(`, `)}),(0,P.jsx)(`span`,{className:`text-zinc-600`,children:` — of the users entitled to it`})]})]})}function Xc({relay:e,agentHalf:t,identity:n}){return(0,P.jsxs)(P.Fragment,{children:[e&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:`Relay hooks — run in a sandbox on the relay (no network, no files of Lamaste's):`}),(0,P.jsx)(Pc,{relay:e})]}),t&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:`Agent half — Lamaste installs it on the hosting agent as a hardened service of its own:`}),(0,P.jsx)(Ic,{agentHalf:t})]}),n&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:`Identity — Lamaste sends its agent half the users entitled to these roles, and lets them reach its application:`}),(0,P.jsx)(Yc,{block:n})]})]})}function Zc({diff:e}){let t=Ds(e);return t?(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:t.declaredBefore?t.declaredAfter?`Identity — what this version changes in it:`:`Identity — this version no longer declares it: its audience is dropped and its user surface is no longer served:`:`Identity — this version declares it for the first time:`}),(0,P.jsx)(`div`,{className:`space-y-0.5 text-zinc-400`,children:t.rows.map(e=>(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`span`,{className:`text-zinc-500`,children:[e.label,` `]}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.entries.join(`, `)}),e.approval&&(0,P.jsx)(`span`,{className:`text-yellow-400`,children:` — waits for approval`})]},e.label))}),t.declaredAfter&&e.after&&(0,P.jsx)(`div`,{className:`mt-1.5`,children:(0,P.jsx)(Yc,{block:e.after})})]}):e?.after?(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:`Identity — unchanged:`}),(0,P.jsx)(Yc,{block:e.after})]}):null}function Qc({diff:e}){let t=Wr(e);return t?(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:`Settings — what this version changes in them:`}),(0,P.jsx)(`div`,{className:`space-y-0.5 text-zinc-400`,children:t.rows.map(e=>(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`span`,{className:`text-zinc-500`,children:[e.label,` `]}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.entries.join(`, `)}),e.note&&(0,P.jsxs)(`span`,{className:`text-yellow-400`,children:[` — `,e.note]})]},e.label))}),t.secretToPlain.length>0&&(0,P.jsxs)(`p`,{className:`mt-1.5 flex items-start gap-1.5 text-red-400`,children:[(0,P.jsx)(ba,{size:12,className:`mt-0.5 shrink-0`}),(0,P.jsxs)(`span`,{children:[`Secrets become plain values:`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:t.secretToPlain.join(`, `)}),`. Their secrets are dropped, but what is typed into them after the update is stored on the relay and shown in clear — never put a credential there.`]})]})]}):null}function $c({reasons:e}){return!Array.isArray(e)||e.length===0?null:(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:`Auto-approve does not cover it:`}),(0,P.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-5 text-yellow-400/90`,children:e.map(e=>(0,P.jsx)(`li`,{children:e},e))})]})}function el({plugin:e,isActing:t}){let n=z(),r=F(),i=G(),{followOperation:a}=Za(),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(null),u=I({queryKey:[`plugin-hooks`,e.name],queryFn:()=>n.getPluginHooks(e.name),refetchInterval:3e4}).data?.hooks,d=()=>Lc(r,e.name),f=L({mutationFn:({digest:t,version:r})=>n.approvePluginHooks(e.name,t,r),onSuccess:t=>{t.operation&&a(t.operation.id),d(),i(t.operation?`Approved — updating ${e.name}`:`${e.name}: approved`)},onError:t=>{d(),i(Rc(t,e),`error`)}}),p=L({mutationFn:t=>n.setPluginHooksAutoApprove(e.name,t),onSuccess:d,onError:e=>i(K(e),`error`)}),m=L({mutationFn:()=>n.discardPluginUpdate(e.name),onSuccess:()=>{d(),i(`Pending update discarded`)},onError:e=>i(K(e),`error`)});if(!u||!u.relay&&!u.agent&&!u.agentHalf&&!u.identity?.declared&&!u.pendingUpdate)return null;let h=t||f.isPending||p.isPending||m.isPending,{approval:_,pendingUpdate:v}=u,y=_.state===`pending`,b=zc(u),{subject:x,plural:S}=Hc(b),C=Array.isArray(v?.approvalRequired)?v.approvalRequired:[],w=(v?.autoApproveWithheld??[]).filter(e=>!C.some(t=>t.reason===e)),T=(e,t,n,r)=>c===e?(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`span`,{className:`text-zinc-400`,children:n}),(0,P.jsx)(`button`,{type:`button`,disabled:h,onClick:()=>{l(null),f.mutate(r)},className:`rounded bg-cyan-600 px-2 py-1 text-white hover:bg-cyan-500 disabled:opacity-50`,children:`Approve`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`Cancel`})]}):(0,P.jsxs)(`button`,{type:`button`,disabled:h,onClick:()=>{s(!0),l(e)},className:`flex items-center gap-1.5 rounded bg-cyan-600 px-2.5 py-1 text-white hover:bg-cyan-500 disabled:opacity-50`,children:[(0,P.jsx)(pa,{size:11}),` `,t]});return(0,P.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex w-full flex-wrap items-center gap-2 text-left`,children:[o?(0,P.jsx)(ui,{size:12}):(0,P.jsx)(fi,{size:12}),(0,P.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:`Lifecycle hooks`}),_.required&&(y?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-yellow-500/15 px-2 py-0.5 text-yellow-400`,children:[(0,P.jsx)(fa,{size:11}),` `,x,` `,S?`wait`:`waits`,` for approval`]}):(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-green-500/15 px-2 py-0.5 text-green-400`,children:[(0,P.jsx)(li,{size:11}),` `,x,` approved`]})),u.relay?.failOpenCount>0&&(0,P.jsxs)(`span`,{className:`text-yellow-400`,children:[u.relay.failOpenCount,` fail-open`]}),v&&(0,P.jsxs)(`span`,{className:`text-yellow-400`,children:[`update `,v.version,` waiting`]})]}),o&&(0,P.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[_.required&&(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`p`,{className:`text-zinc-500`,children:y?Wc(b):`Approved by ${_.approvedBy} ${_.approvedAt?new Date(_.approvedAt).toLocaleString():``} (version ${_.approvedVersion}).`}),(0,P.jsx)(qc,{digest:_.digest}),(0,P.jsx)(Xc,{...b}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[y&&T(`installed`,`Approve`,Uc(b),{digest:_.digest}),(0,P.jsxs)(`label`,{className:`flex items-center gap-1.5 text-zinc-400`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:u.autoApprove,disabled:h,onChange:e=>p.mutate(e.target.checked)}),`Approve what later versions of this plugin bring automatically`]})]})]}),u.agent&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-zinc-500 mb-1`,children:`Agent hooks — run by the agent half on its agent; no approval needed:`}),(0,P.jsx)(`div`,{className:`font-mono text-zinc-300`,children:u.agent.stages.map(e=>e.stage).join(`, `)})]}),v&&(0,P.jsxs)(`div`,{className:`space-y-2 rounded border border-yellow-500/30 p-2`,children:[(0,P.jsxs)(`p`,{className:`text-yellow-400`,children:[`Version `,v.version,` waits for your approval — the installed version stays live until then:`]}),(0,P.jsx)(Jc,{reasons:C}),v.digest&&(0,P.jsx)(qc,{digest:v.digest,approved:v.digest===_.approvedDigest}),(0,P.jsx)(Xc,{relay:v.relay,agentHalf:v.agentHalf}),(0,P.jsx)(Zc,{diff:v.identity}),(0,P.jsx)(Qc,{diff:v.settings}),(0,P.jsx)($c,{reasons:w}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[T(`update`,`Approve and update`,Kc(v),{digest:v.digest,version:v.version}),(0,P.jsxs)(`button`,{type:`button`,disabled:h,onClick:()=>m.mutate(),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:[(0,P.jsx)(Na,{size:11}),` Discard`]})]})]})]})]})}function tl({plugin:e,isActing:t}){let n=z(),r=F(),i=G(),{followOperation:a}=Za(),[o,s]=(0,g.useState)(``),c=L({mutationFn:()=>n.updatePlugin(e.name,o.trim()||void 0),onSuccess:t=>{t.operation&&a(t.operation.id),Lc(r,e.name),t.upToDate?i(`${e.name} is already at ${t.version}`):t.pendingUpdate?i(`${e.name} ${t.pendingUpdate.version} waits for your approval — see why under Lifecycle hooks`):i(`Updating ${e.name}`),s(``)},onError:t=>i(Rc(t,e),`error`)});return(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`latest`,className:`w-20 rounded bg-zinc-800 border border-zinc-700 px-2 py-1 text-xs text-zinc-300 focus:outline-none focus:border-cyan-400`,"aria-label":`Version to update to`}),(0,P.jsxs)(`button`,{type:`button`,disabled:t||c.isPending,onClick:()=>c.mutate(),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,title:`Fetch the version and read it before installing it; relay hooks that changed, a new agent half, secret settings turned plain and roles added or removed or attributes widened wait for approval`,children:[c.isPending?(0,P.jsx)(H,{size:12,className:`animate-spin`}):(0,P.jsx)(Ci,{size:12}),`Update`]})]})}var nl=`push-install`;function rl(){requestAnimationFrame(()=>{document.getElementById(nl)?.scrollIntoView({behavior:`smooth`,block:`start`})})}function il(e,t){return e!=null&&Date.parse(e)>t}var al=30;function ol(e,t){let n=Number(e);return!/^\d+$/.test(e.trim())||n<t.min||n>t.max?`${t.min} to ${t.max} whole minutes`:null}function sl({agent:e,config:t,onDone:n}){let r=z(),i=F(),a=G(),o=t.windowMinutes,[s,c]=(0,g.useState)(String(Math.min(Math.max(al,o.min),o.max))),[l,u]=(0,g.useState)(t.policies.some(t=>t.id===e.pushInstallPolicy)?e.pushInstallPolicy:t.defaultPolicy),d=ol(s,o),f=L({mutationFn:()=>r.enablePushInstall(e.label,{durationMinutes:Number(s),policyId:l}),onSuccess:t=>{i.invalidateQueries({queryKey:[`agent-certs`]}),a(`Push install open for ${e.label} until ${new Date(t.pushInstallEnabledUntil).toLocaleTimeString()}`),n()},onError:e=>a(K(e),`error`)});return(0,P.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),d||f.mutate()},className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,P.jsxs)(`label`,{className:`flex items-center gap-1.5 text-zinc-400`,children:[`for`,(0,P.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:o.min,max:o.max,step:1,value:s,onChange:e=>c(e.target.value),"aria-invalid":d!==null,className:`w-20 rounded border bg-zinc-800 px-2 py-1 text-zinc-200 focus:outline-none ${d?`border-red-500/70`:`border-zinc-700 focus:border-cyan-400`}`}),`minutes`]}),(0,P.jsxs)(`label`,{className:`flex items-center gap-1.5 text-zinc-400`,children:[`policy`,(0,P.jsx)(`select`,{value:l,onChange:e=>u(e.target.value),className:`rounded border border-zinc-700 bg-zinc-800 px-2 py-1 text-zinc-200 focus:border-cyan-400 focus:outline-none`,children:t.policies.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.name,e.id===t.defaultPolicy?` (default)`:``]},e.id))})]}),(0,P.jsxs)(`button`,{type:`submit`,disabled:d!==null||f.isPending,className:`flex items-center gap-1.5 rounded bg-cyan-600 px-2.5 py-1 text-white hover:bg-cyan-500 disabled:opacity-50`,children:[f.isPending?(0,P.jsx)(H,{size:11,className:`animate-spin`}):(0,P.jsx)(U,{size:11}),`Open`]}),(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),d&&(0,P.jsxs)(`span`,{className:`basis-full text-red-400`,children:[`A window is open `,d,`.`]})]})}function cl({children:e}){let t=z(),n=F(),r=G(),[i,a]=(0,g.useState)(null),o=I({queryKey:[`push-install-config`],queryFn:()=>t.getPushInstallConfig(),refetchInterval:3e4}),s=I({queryKey:[`agent-certs`],queryFn:()=>t.getAgentCerts(),refetchInterval:3e4}),c=L({mutationFn:e=>t.updatePushInstallConfig(e),onSuccess:(e,t)=>{n.invalidateQueries({queryKey:[`push-install-config`]}),n.invalidateQueries({queryKey:[`push-install-policies`]}),t.enabled===void 0?r(`Default policy: ${e.defaultPolicy}`):r(e.enabled?`Push install is on — open the window of the agent to push to`:`Push install is off — every push is refused`)},onError:e=>r(K(e),`error`)}),l=L({mutationFn:e=>t.disablePushInstall(e),onSuccess:(e,t)=>{n.invalidateQueries({queryKey:[`agent-certs`]}),r(`Push install closed for ${t}`)},onError:e=>r(K(e),`error`)}),u=o.data,d=(s.data?.agents??[]).filter(e=>!e.revoked&&!e.label.startsWith(`plugin-agent:`)).sort((e,t)=>e.label.localeCompare(t.label)),f=s.dataUpdatedAt,p=e=>il(e.pushInstallEnabledUntil,f),m=e=>u?.policies.find(t=>t.id===e)?.name??e;return(0,P.jsx)(`section`,{id:nl,className:`mt-8 scroll-mt-6`,children:(0,P.jsxs)(`div`,{className:`border-t border-zinc-700 pt-6`,children:[(0,P.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center justify-between gap-3`,children:[(0,P.jsxs)(`h2`,{className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[(0,P.jsx)(ma,{size:18,className:`text-cyan-400`}),`Push Install`,u&&(0,P.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-normal ${u.enabled?`bg-green-500/20 text-green-400`:`bg-zinc-500/20 text-zinc-400`}`,children:u.enabled?`on`:`off`})]}),u&&(0,P.jsxs)(`button`,{type:`button`,disabled:c.isPending,onClick:()=>c.mutate({enabled:!u.enabled}),className:`flex items-center gap-1.5 rounded px-3 py-1.5 text-xs disabled:opacity-50 ${u.enabled?`bg-zinc-700 text-zinc-300 hover:bg-zinc-600`:`bg-cyan-600 text-white hover:bg-cyan-500`}`,children:[u.enabled?(0,P.jsx)(ta,{size:12}):(0,P.jsx)(na,{size:12}),u.enabled?`Turn off`:`Turn on`]})]}),(0,P.jsx)(`p`,{className:`mb-4 text-sm text-zinc-500`,children:`Lets the panel install, update and remove what Lamaste installs on an agent — the agent half of an app plugin — while that agent's window is open, within its policy. Off: every push is refused, open windows included.`}),o.isError?(0,P.jsx)(`p`,{className:`mb-4 text-sm text-red-400`,children:K(o.error)}):u?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`label`,{className:`mb-4 flex flex-wrap items-center gap-2 text-sm text-zinc-400`,children:[`Default policy for a window`,(0,P.jsx)(`select`,{value:u.defaultPolicy,disabled:c.isPending,onChange:e=>c.mutate({defaultPolicy:e.target.value}),className:`rounded border border-zinc-700 bg-zinc-800 px-2 py-1 text-sm text-zinc-200 focus:border-cyan-400 focus:outline-none`,children:u.policies.map(e=>(0,P.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,P.jsx)(`div`,{className:`mb-6 overflow-x-auto rounded-lg border border-zinc-800`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Agent`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Window`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Manage`})]})}),(0,P.jsxs)(`tbody`,{children:[s.isError&&(0,P.jsx)(`tr`,{className:`bg-zinc-800`,children:(0,P.jsx)(`td`,{colSpan:3,className:`px-4 py-3 text-red-400`,children:K(s.error)})}),s.isSuccess&&d.length===0&&(0,P.jsx)(`tr`,{className:`bg-zinc-800`,children:(0,P.jsx)(`td`,{colSpan:3,className:`px-4 py-3 text-zinc-500`,children:`No enrolled machine agent.`})}),d.map(e=>{let t=p(e);return(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,P.jsx)(`td`,{className:`whitespace-nowrap px-4 py-3 align-top font-mono text-zinc-200`,children:e.label}),(0,P.jsxs)(`td`,{className:`px-4 py-3 align-top`,children:[t?(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5 text-green-400`,children:[(0,P.jsx)(yi,{size:12}),`open until `,new Date(e.pushInstallEnabledUntil).toLocaleString(),(0,P.jsxs)(`span`,{className:`text-zinc-500`,children:[`· policy `,m(e.pushInstallPolicy)]})]}):(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`closed`}),i===e.label&&(0,P.jsx)(`div`,{className:`mt-2`,children:(0,P.jsx)(sl,{agent:e,config:u,onDone:()=>a(null)})})]}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-right align-top`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[i!==e.label&&(0,P.jsxs)(`button`,{type:`button`,disabled:!u.enabled,onClick:()=>a(e.label),title:u.enabled?`Open the window for a number of minutes, under a policy`:`Turn push install on first`,className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:[(0,P.jsx)(U,{size:12}),t?`Reopen…`:`Open…`]}),t&&(0,P.jsxs)(`button`,{type:`button`,disabled:l.isPending,onClick:()=>l.mutate(e.label),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-red-600/20 hover:text-red-400 disabled:opacity-50`,children:[(0,P.jsx)(W,{size:12}),`Close`]})]})})]},e.label)})]})]})})]}):(0,P.jsx)(`div`,{className:`mb-4 h-24 animate-pulse rounded-lg border border-zinc-800 bg-zinc-900`}),e]})})}function ll({onClose:e}){return(0,P.jsxs)(`button`,{type:`button`,onClick:()=>{e(),rl()},className:`inline-flex items-center gap-1 text-cyan-400 hover:text-cyan-300 hover:underline`,children:[(0,P.jsx)(ri,{size:11}),`Push install`]})}function ul({until:e,now:t}){return il(e,t)?(0,P.jsxs)(`span`,{className:`text-green-400`,children:[`push install open until `,new Date(e).toLocaleTimeString()]}):(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`push install closed`})}var dl=(0,g.forwardRef)(function({refusal:e,pluginName:t,onClose:n},r){return(0,P.jsxs)(`div`,{ref:r,className:`rounded border border-red-500/30 bg-red-500/5 p-3 text-xs`,children:[(0,P.jsxs)(`p`,{className:`flex items-start gap-1.5 text-red-400`,children:[(0,P.jsx)(ba,{size:12,className:`mt-0.5 shrink-0`}),e.code===`agent_not_eligible`?`Agent "${e.agentLabel}" cannot host ${t}:`:e.message]}),e.code===`agent_not_eligible`&&(0,P.jsx)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-6 text-zinc-300`,children:e.reasons.map(e=>(0,P.jsx)(`li`,{children:e},e))}),e.hint&&(0,P.jsx)(`p`,{className:`mt-1.5 text-zinc-400`,children:e.hint}),e.code===`push_install_refused`&&(0,P.jsx)(`p`,{className:`mt-1.5`,children:(0,P.jsx)(ll,{onClose:n})})]})});function fl({query:e}){let t=e.data?.fields;return(0,P.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3`,children:[(0,P.jsxs)(`p`,{className:`mb-1 flex items-center gap-1.5 font-medium text-zinc-300`,children:[(0,P.jsx)(ha,{size:12,className:`text-cyan-400`}),`Settings it asks for`]}),(0,P.jsx)(`p`,{className:`mb-2 text-zinc-500`,children:`Hosting takes no settings: the agent half starts without them, and you fill them in under Settings on the plugin's card once it is hosted. Secrets are kept by the agent half alone; every other value is also kept on the relay and shown in clear.`}),Array.isArray(t)?(0,P.jsx)(`ul`,{className:`space-y-1`,children:t.map(e=>(0,P.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[e.type===`secret`&&(0,P.jsx)(zi,{size:11,className:`shrink-0 self-center text-cyan-400`}),(0,P.jsx)(`span`,{className:`text-zinc-300`,children:e.label}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-600`,children:e.key}),(0,P.jsx)(`span`,{className:e.type===`secret`?`text-cyan-400`:`text-zinc-500`,children:Ur(e)}),Vr(e)&&(0,P.jsx)(`span`,{className:`w-full text-yellow-400/90`,children:`Stored on the relay and shown in clear — use a secret field for credentials.`})]},e.key))}):e.isError?(0,P.jsx)(`p`,{className:`text-red-400`,children:K(e.error)}):(0,P.jsx)(H,{size:12,className:`animate-spin text-zinc-500`})]})}function pl({plugin:e,onHost:t,onClose:n,isActing:r}){let i=z(),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(!1),d=(0,g.useRef)(null);(0,g.useEffect)(()=>{s&&d.current?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[s]);let f=e.hooks?.agentHalf===!0,p=e.hooks?.approval===`pending`,m=I({queryKey:[`plugin-hosting-eligibility`,e.name],queryFn:()=>i.getPluginHostingEligibility(e.name),refetchInterval:3e4}),h=I({queryKey:[`agent-certs`],queryFn:()=>i.getAgentCerts(),refetchInterval:3e4}),_=I({queryKey:[`push-install-config`],queryFn:()=>i.getPushInstallConfig(),enabled:f}),v=I({queryKey:[`plugin-hooks`,e.name],queryFn:()=>i.getPluginHooks(e.name),enabled:f}),y=e.settings!=null,b=I({queryKey:[`plugin-settings`,e.name],queryFn:()=>i.getPluginSettings(e.name),enabled:y,refetchOnWindowFocus:!1}),x=m.data?.agents??[],S=new Map((h.data?.agents??[]).map(e=>[e.label,e])),C=x.some(e=>e.label===a&&e.eligible)?a:``,w=v.data?.hooks?.agentHalf??null,T=f&&_.data?.enabled===!1,E=h.dataUpdatedAt,D=C?S.get(C):void 0,O=f&&!T&&D!==void 0&&!il(D.pushInstallEnabledUntil,E);return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,P.jsxs)(`div`,{className:`flex max-h-full w-full max-w-2xl flex-col rounded-xl border border-zinc-700 bg-zinc-900 shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between border-b border-zinc-800 px-6 py-4`,children:[(0,P.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-white`,children:[(0,P.jsx)(la,{size:18,className:`text-cyan-400`}),`Host `,e.displayName||e.name]}),(0,P.jsx)(`button`,{type:`button`,onClick:n,disabled:l,"aria-label":`Close`,className:`text-zinc-400 hover:text-white disabled:opacity-50`,children:(0,P.jsx)(Na,{size:20})})]}),(0,P.jsxs)(`div`,{className:`space-y-4 overflow-y-auto px-6 py-4 text-xs`,children:[(0,P.jsx)(`p`,{className:`text-zinc-400`,children:f?`Lamaste installs the agent half on the agent you pick, as a service of its own, and runs the install hooks around creating the internal tunnel, assigning the port and issuing the installation secret.`:`Pick the agent that runs its agent half (installed there by hand): Lamaste runs the install hooks around creating the internal tunnel, assigning the port and issuing the installation secret.`}),f&&(0,P.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3`,children:[(0,P.jsx)(`p`,{className:`mb-2 font-medium text-zinc-300`,children:`What Lamaste installs on the agent`}),w?(0,P.jsx)(Ic,{agentHalf:w}):v.isError?(0,P.jsx)(`p`,{className:`text-red-400`,children:K(v.error)}):(0,P.jsx)(H,{size:12,className:`animate-spin text-zinc-500`})]}),y&&(0,P.jsx)(fl,{query:b}),p&&(0,P.jsxs)(`p`,{className:`flex items-start gap-1.5 text-yellow-400`,children:[(0,P.jsx)(fa,{size:12,className:`mt-0.5 shrink-0`}),f?`Not approved yet — approve what it brings under Lifecycle hooks on the plugin’s card, then host it.`:`Its relay hooks are not approved yet — approve them under Lifecycle hooks on the plugin’s card, then host it.`]}),T&&(0,P.jsxs)(`p`,{className:`flex flex-wrap items-start gap-1.5 text-yellow-400`,children:[(0,P.jsx)(ba,{size:12,className:`mt-0.5 shrink-0`}),(0,P.jsxs)(`span`,{children:[`Push install is off on this relay: Lamaste cannot install the agent half until it is on and the agent's window is open — under `,(0,P.jsx)(ll,{onClose:n}),`.`]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`mb-2 font-medium text-zinc-300`,children:`Agent`}),m.isLoading?(0,P.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:2}).map((e,t)=>(0,P.jsx)(`div`,{className:`h-12 animate-pulse rounded bg-zinc-800`},t))}):m.isError?(0,P.jsx)(`p`,{className:`text-red-400`,children:K(m.error)}):x.length===0?(0,P.jsx)(`p`,{className:`text-zinc-500`,children:`No enrolled machine agent — enroll one under Certificates first.`}):(0,P.jsx)(`ul`,{className:`space-y-1.5`,role:`radiogroup`,"aria-label":`Hosting agent`,children:x.map(t=>{let n=S.get(t.label);return(0,P.jsx)(`li`,{children:(0,P.jsxs)(`label`,{className:`flex items-start gap-2 rounded border px-3 py-2 ${t.eligible?C===t.label?`cursor-pointer border-cyan-500/60 bg-cyan-500/5`:`cursor-pointer border-zinc-800 bg-zinc-950/60 hover:border-zinc-700`:`cursor-not-allowed border-zinc-800 bg-zinc-950/40`}`,children:[(0,P.jsx)(`input`,{type:`radio`,name:`host-${e.name}`,value:t.label,checked:C===t.label,disabled:!t.eligible,onChange:()=>o(t.label),className:`mt-0.5 accent-cyan-500`}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,P.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`font-mono ${t.eligible?`text-zinc-200`:`text-zinc-500`}`,children:t.label}),f&&t.eligible&&n&&(0,P.jsx)(ul,{until:n.pushInstallEnabledUntil,now:E})]}),(0,P.jsx)(`span`,{className:`block`,children:(0,P.jsx)(qs,{facts:n?.hostFacts??null,at:n?.hostFactsAt??null})}),!t.eligible&&(0,P.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4 text-yellow-400/90`,children:t.reasons.map(e=>(0,P.jsx)(`li`,{children:e},e))})]})]})},t.label)})})]}),O&&(0,P.jsxs)(`p`,{className:`flex items-start gap-1.5 text-yellow-400`,children:[(0,P.jsx)(ba,{size:12,className:`mt-0.5 shrink-0`}),(0,P.jsxs)(`span`,{children:[`The push-install window of `,(0,P.jsx)(`span`,{className:`font-mono`,children:C}),` is closed: Lamaste installs the agent half by push install, so open it first — under`,` `,(0,P.jsx)(ll,{onClose:n}),`.`]})]}),s&&(0,P.jsx)(dl,{ref:d,refusal:s,pluginName:e.displayName||e.name,onClose:n})]}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-3 border-t border-zinc-800 px-6 py-4`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:n,disabled:l,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,P.jsxs)(`button`,{type:`button`,disabled:l||r||!C||p,onClick:()=>{c(null),u(!0),t(e.name,C,{onSuccess:n,onError:e=>{u(!1);let t=wc(e,{agentLabel:C,action:`install`});c({...t,agentLabel:C}),t.code===`agent_not_eligible`&&m.refetch()}})},title:p?`Approve what it brings first (Lifecycle hooks)`:void 0,className:`flex items-center gap-1.5 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:[l?(0,P.jsx)(H,{size:14,className:`animate-spin`}):(0,P.jsx)(la,{size:14}),C?`Host on ${C}`:`Host on agent`]})]})]})})}function ml(e,t){e.invalidateQueries({queryKey:[`plugin-identity`,t]}),e.invalidateQueries({queryKey:[`plugin-audience`,t]}),e.invalidateQueries({queryKey:[`plugin-entitlements`,t]}),e.invalidateQueries({queryKey:[`gatekeeper-grants`]})}function hl(e,t){return e?`${new Date(e).toLocaleString()} (${gr(e,t)})`:`—`}function gl({children:e}){return(0,P.jsx)(`p`,{className:`mb-1.5 text-zinc-500`,children:e})}function _l({view:e}){let{declared:t,readiness:n,approval:r}=e,i=gs(n);return(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(gl,{children:`Roles the installed version declares:`}),(0,P.jsx)(`ul`,{className:`space-y-0.5`,children:t.roles.map(e=>(0,P.jsxs)(`li`,{children:[(0,P.jsx)(`span`,{className:`font-mono text-zinc-200`,children:e.id}),(0,P.jsxs)(`span`,{className:`text-zinc-400`,children:[` — `,e.label]}),e.description&&(0,P.jsxs)(`span`,{className:`text-zinc-600`,children:[` · `,e.description]})]},e.id))})]}),(0,P.jsxs)(`p`,{className:`text-zinc-400`,children:[`Each member reaches it with their user id, username, roles and status`,t.attributes.length>0?`, and their ${t.attributes.map(fs).join(` and `)}`:` — nothing else about them`,`.`]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r.approved?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-green-500/15 px-2 py-0.5 text-green-400`,children:[(0,P.jsx)(li,{size:11}),` identity approved`]}):(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-yellow-500/15 px-2 py-0.5 text-yellow-400`,title:`Its users are sent to it, and reach it, only once it is approved`,children:[(0,P.jsx)(fa,{size:11}),` identity waits for approval (Lifecycle hooks)`]}),(0,P.jsx)(`span`,{className:i.ready?`text-green-400`:`text-yellow-400`,children:i.text})]})]})}function vl({entitlement:e,roles:t,onSet:n,onRemove:r,busy:i}){let[a,o]=(0,g.useState)(!1),s=e.roles.filter(e=>t.some(t=>t.id===e));return(0,P.jsx)(`li`,{className:`rounded bg-zinc-900 px-2 py-1.5`,children:(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,P.jsx)(e.principalType===`user`?Oa:Aa,{size:11,className:e.principalType===`user`?`text-blue-400`:`text-purple-400`}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-200`,children:e.principalId}),e.principalType===`group`&&(0,P.jsx)(`span`,{className:`text-zinc-600`,children:`group`})]}),e.principalType===`user`&&(0,P.jsx)(Os,{id:e.userId,missing:`not in the user directory`}),(0,P.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[t.map(t=>{let r=s.includes(t.id),a=r&&s.length===1;return(0,P.jsxs)(`label`,{className:`flex items-center gap-1 text-zinc-300`,title:a?`The last role — remove the entitlement instead`:t.label,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:r,disabled:i||a,onChange:r=>n(e,Ts(s,t.id,r.target.checked))}),(0,P.jsx)(`span`,{className:`font-mono`,children:t.id})]},t.id)}),e.unknownRoles.map(e=>(0,P.jsx)(`span`,{className:`font-mono text-zinc-600 line-through`,title:`The installed version no longer declares this role: it counts for nothing`,children:e},e))]}),(0,P.jsx)(`span`,{className:`ml-auto`,children:a?(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`span`,{className:`text-zinc-400`,children:`Remove every role?`}),(0,P.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>{o(!1),r(e)},className:`rounded bg-red-600 px-2 py-0.5 text-white hover:bg-red-500 disabled:opacity-50`,children:`Remove`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`rounded bg-zinc-700 px-2 py-0.5 text-zinc-300 hover:bg-zinc-600`,children:`Cancel`})]}):(0,P.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>o(!0),title:`Revoke every role this principal holds on the plugin`,className:`text-zinc-500 hover:text-red-400 disabled:opacity-50`,children:(0,P.jsx)(ya,{size:12})})})]})})}function yl({roles:e,taken:t,onSet:n,busy:r}){let i=z(),[a,o]=(0,g.useState)(`user`),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)([]),d=I({queryKey:[`users`],queryFn:()=>i.getUsers()}),f=I({queryKey:[`gatekeeper-groups`],queryFn:()=>i.getGatekeeperGroups(),retry:!1}),p=e=>!t.has(`${a}:${e}`),m=a===`user`?(d.data?.users??[]).filter(e=>p(e.username)).map(e=>({id:e.username,label:`${e.username}${e.status===`disabled`?` (disabled)`:``}`})):(f.data?.groups??[]).filter(e=>p(e.name)).map(e=>({id:e.name,label:e.name})),h=a===`user`?d.isError&&`Users could not be listed`:f.isError&&`Lamaste groups could not be listed: ${K(f.error)}`;return(0,P.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),!(!s||l.length===0)&&n({principalType:a,principalId:s,roles:[...l].sort()},()=>{c(``),u([])})},className:`space-y-2 rounded border border-zinc-800 p-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[[`user`,`group`].map(e=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>{o(e),c(``)},className:`rounded px-2 py-0.5 ${a===e?`bg-cyan-600 text-white`:`bg-zinc-800 text-zinc-400 hover:text-zinc-200`}`,children:e===`user`?`User`:`Group`},e)),(0,P.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),"aria-label":a===`user`?`User`:`Lamaste group`,className:`min-w-40 rounded border border-zinc-700 bg-zinc-800 px-2 py-1 text-zinc-200 focus:border-cyan-400 focus:outline-none`,children:[(0,P.jsx)(`option`,{value:``,children:a===`user`?`Select a user…`:`Select a Lamaste group…`}),m.map(e=>(0,P.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`Roles:`}),e.map(e=>(0,P.jsxs)(`label`,{className:`flex items-center gap-1 text-zinc-300`,title:e.label,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:l.includes(e.id),onChange:t=>u(n=>Ts(n,e.id,t.target.checked))}),(0,P.jsx)(`span`,{className:`font-mono`,children:e.id})]},e.id)),(0,P.jsxs)(`button`,{type:`submit`,disabled:r||!s||l.length===0,className:`ml-auto flex items-center gap-1 rounded bg-cyan-600 px-2.5 py-1 text-white hover:bg-cyan-500 disabled:opacity-50`,children:[(0,P.jsx)(ea,{size:11}),` Give roles`]})]}),h&&(0,P.jsx)(`p`,{className:`text-red-400`,children:h}),a===`group`&&(0,P.jsx)(`p`,{className:`text-zinc-600`,children:`A Lamaste group's members hold its roles while they are in it.`})]})}function bl({plugin:e,roles:t}){let n=z(),r=F(),i=G(),a=I({queryKey:[`plugin-entitlements`,e.name],queryFn:()=>n.getPluginEntitlements(e.name)}),o=e=>{for(let t of e??[])i(ms(t),`error`)},s=L({mutationFn:t=>n.setPluginEntitlement(e.name,t),onSuccess:(t,n)=>{ml(r,e.name),i(t.changed?`${n.principalId}: ${n.roles.join(`, `)}`:`${n.principalId} already holds exactly these roles`),o(t.warnings)},onError:e=>i(K(e),`error`)}),c=L({mutationFn:t=>n.removePluginEntitlement(e.name,t),onSuccess:(t,n)=>{ml(r,e.name),i(`${n.principalId} holds no role on ${e.name} any more`),o(t.warnings)},onError:e=>i(K(e),`error`)}),l=s.isPending||c.isPending,u=a.data?.entitlements??[],d=new Set(u.map(e=>`${e.principalType}:${e.principalId}`));return(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(gl,{children:`Entitlements — who may use it, with which roles:`}),a.isLoading?(0,P.jsx)(H,{size:12,className:`animate-spin text-zinc-500`}):a.isError?(0,P.jsx)(`p`,{className:`text-red-400`,children:K(a.error)}):u.length===0?(0,P.jsx)(`p`,{className:`text-zinc-600`,children:`Nobody yet — give a user or a Lamaste group a role below.`}):(0,P.jsx)(`ul`,{className:`space-y-1`,children:u.map(e=>(0,P.jsx)(vl,{entitlement:e,roles:t,busy:l,onSet:(e,t)=>s.mutate({principalType:e.principalType,principalId:e.principalId,roles:t}),onRemove:e=>c.mutate({principalType:e.principalType,principalId:e.principalId})},`${e.principalType}:${e.principalId}`))}),a.data?.roleless>0&&(0,P.jsxs)(`p`,{className:`text-zinc-600`,children:[a.data.roleless,` grant`,a.data.roleless===1?``:`s`,` on this plugin carr`,a.data.roleless===1?`ies`:`y`,` no roles (desktop installs, migrated grants) — they never make anyone a member.`]}),(0,P.jsx)(yl,{roles:t,taken:d,busy:l,onSet:(e,t)=>s.mutate(e,{onSuccess:t})})]})}var xl={active:`bg-green-500/15 text-green-400`,disabled:`bg-yellow-500/15 text-yellow-400`,removed:`bg-zinc-700/60 text-zinc-400`,erased:`bg-red-500/10 text-red-400`,unknown:`bg-zinc-700/60 text-zinc-500`};function Sl({view:e,now:t}){let n=e.status===`erased`?`erased`:e.displayName&&e.username?`${e.displayName} (${e.username})`:e.username??`—`;return(0,P.jsxs)(`tr`,{className:`border-t border-zinc-800`,children:[(0,P.jsx)(`td`,{className:`py-1 pr-2 ${e.status===`erased`?`text-zinc-600`:`text-zinc-200`}`,children:n}),(0,P.jsx)(`td`,{className:`py-1 pr-2`,children:(0,P.jsx)(Os,{id:e.userId})}),(0,P.jsx)(`td`,{className:`py-1 pr-2 font-mono text-zinc-300`,children:e.roles.join(`, `)||`—`}),(0,P.jsx)(`td`,{className:`py-1 pr-2`,children:(0,P.jsx)(`span`,{className:`rounded-full px-1.5 py-0.5 ${xl[e.status]}`,children:e.status===`removed`?ws(e.reason):e.status})}),(0,P.jsx)(`td`,{className:`py-1 text-zinc-600`,title:`seq ${e.seq} · version ${e.version}`,children:gr(e.updatedAt,t)})]})}function Cl({plugin:e}){let t=z(),[n,r]=(0,g.useState)(!1),i=I({queryKey:[`plugin-audience`,e.name],queryFn:()=>t.getPluginAudience(e.name),refetchInterval:15e3}),a=i.dataUpdatedAt,o=(i.data?.audience??[]).map(Cs),s=o.filter(e=>e.member),c=o.filter(e=>!e.member),l=n?[...s,...c]:s;return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(gl,{children:[`Audience — what its agent half is told`,i.data?` (head seq ${i.data.head})`:``,`:`]}),i.isLoading?(0,P.jsx)(H,{size:12,className:`animate-spin text-zinc-500`}):i.isError?(0,P.jsx)(`p`,{className:`text-red-400`,children:K(i.error)}):o.length===0?(0,P.jsx)(`p`,{className:`text-zinc-600`,children:`No members yet.`}):(0,P.jsxs)(P.Fragment,{children:[l.length>0&&(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-left`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`text-zinc-500`,children:[(0,P.jsx)(`th`,{className:`pb-1 pr-2 font-normal`,children:`User`}),(0,P.jsx)(`th`,{className:`pb-1 pr-2 font-normal`,children:`User id`}),(0,P.jsx)(`th`,{className:`pb-1 pr-2 font-normal`,children:`Roles`}),(0,P.jsx)(`th`,{className:`pb-1 pr-2 font-normal`,children:`Status`}),(0,P.jsx)(`th`,{className:`pb-1 font-normal`,children:`Changed`})]})}),(0,P.jsx)(`tbody`,{children:l.map(e=>(0,P.jsx)(Sl,{view:e,now:a},e.userId))})]})}),s.length===0&&(0,P.jsx)(`p`,{className:`text-zinc-600`,children:`No members.`}),c.length>0&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`mt-1 text-zinc-500 hover:text-zinc-300`,children:n?`Hide the users who left`:`Show the ${c.length} user${c.length===1?``:`s`} who left (kept as tombstones)`})]})]})}function wl({plugin:e,sync:t,now:n}){let r=z(),i=F(),a=G(),o=L({mutationFn:t=>r.syncPluginIdentity(e.name,{reconcile:t}),onSuccess:({result:t},n)=>{ml(i,e.name),t.status===`synced`?a(`${e.name}: ${t.replay?`replayed`:`synced`} up to seq ${t.cursor}`+(n?` — ${t.mismatches??0} out of step`:``)):t.status===`up-to-date`?a(`${e.name}: its agent half is up to date (seq ${t.cursor})`):a(`${e.name}: ${t.error??t.reason??t.status}`,`error`)},onError:e=>a(K(e),`error`)}),s=t.halfDirectoryId!==null&&t.halfDirectoryId!==t.directoryId,c=[[`directory`,(0,P.jsx)(Os,{id:t.directoryId,full:!0},`d`)],[`agent half follows`,t.halfDirectoryId===null?(0,P.jsx)(`span`,{className:`text-zinc-600`,children:`nothing yet`}):s?(0,P.jsxs)(`span`,{className:`text-yellow-400`,children:[`another directory (`,(0,P.jsx)(Os,{id:t.halfDirectoryId}),`) — the next sync replays`]}):`this directory`],[`position`,(0,P.jsxs)(`span`,{children:[`cursor `,(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,children:t.cursor??`—`}),` of head`,` `,(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,children:t.head}),t.behind>0?(0,P.jsxs)(`span`,{className:`text-yellow-400`,children:[` — `,t.behind,` change(s) behind`]}):(0,P.jsx)(`span`,{className:`text-green-400`,children:` — up to date`})]},`p`)],[`answered for version`,t.readyVersion??`—`],[`last sync`,hl(t.lastSyncAt,n)],[`last reconcile`,(0,P.jsxs)(`span`,{children:[hl(t.lastReconcileAt,n),t.lastMismatches!=null&&(0,P.jsxs)(`span`,{className:t.lastMismatches>0?`text-red-400`:`text-zinc-500`,children:[` `,`— `,t.lastMismatches,` out of step`]})]},`r`)]];return(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(gl,{children:`Feed to the agent half:`}),(0,P.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5`,children:c.map(([e,t])=>(0,P.jsxs)(`div`,{className:`contents`,children:[(0,P.jsx)(`dt`,{className:`text-zinc-500`,children:e}),(0,P.jsx)(`dd`,{className:`text-zinc-300`,children:t})]},e))}),t.lastError&&(0,P.jsxs)(`p`,{className:`flex items-start gap-1.5 text-red-400`,children:[(0,P.jsx)(ba,{size:12,className:`mt-0.5 shrink-0`}),` `,t.lastError]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsxs)(`button`,{type:`button`,disabled:o.isPending,onClick:()=>o.mutate(!1),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,title:`Send the agent half what it has not applied`,children:[o.isPending?(0,P.jsx)(H,{size:11,className:`animate-spin`}):(0,P.jsx)(ra,{size:11}),`Sync now`]}),(0,P.jsxs)(`button`,{type:`button`,disabled:o.isPending,onClick:()=>o.mutate(!0),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,title:`Replay the whole audience and count what the agent half held out of step (also runs daily)`,children:[(0,P.jsx)(ra,{size:11}),`Reconcile`]})]})]})}function Tl({ids:e}){return e.length===0?null:(0,P.jsxs)(`div`,{children:[(0,P.jsx)(gl,{children:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-amber-400`,children:[(0,P.jsx)(wi,{size:11}),` Erasures its agent half has not acknowledged yet:`]})}),(0,P.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsx)(Os,{id:e})},e))}),(0,P.jsx)(`p`,{className:`mt-1 text-zinc-600`,children:`Delivered within seconds while its hosting agent is online, on reconnect otherwise.`})]})}function El({plugin:e}){let t=z(),[n,r]=(0,g.useState)(!1),i=I({queryKey:[`plugin-identity`,e.name],queryFn:()=>t.getPluginIdentity(e.name),refetchInterval:n?1e4:6e4}),a=i.data?.identity;if(i.isError)return(0,P.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs text-red-400`,children:[`People: `,K(i.error)]});if(!a?.declared)return null;let o=gs(a.readiness),s=a.audience??{active:0,disabled:0},c=s.active+s.disabled,l=i.dataUpdatedAt;return(0,P.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,className:`flex w-full flex-wrap items-center gap-2 text-left`,children:[n?(0,P.jsx)(ui,{size:12}):(0,P.jsx)(fi,{size:12}),(0,P.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:`People`}),o.ready?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-green-400`,children:[(0,P.jsx)(li,{size:11}),` ready`]}):(0,P.jsx)(`span`,{className:`text-yellow-400`,title:o.text,children:a.readiness.reason?.replace(/_/g,` `)??`not ready`}),(0,P.jsxs)(`span`,{className:`text-zinc-500`,children:[c,` member`,c===1?``:`s`,s.disabled>0?` (${s.disabled} disabled)`:``]}),a.sync?.behind>0&&(0,P.jsxs)(`span`,{className:`text-yellow-400`,children:[a.sync.behind,` to send`]}),a.sync?.lastError&&(0,P.jsx)(`span`,{className:`text-red-400`,title:a.sync.lastError,children:`sync held up`}),a.pendingErasures.length>0&&(0,P.jsxs)(`span`,{className:`text-amber-400`,children:[a.pendingErasures.length,` erasure`,a.pendingErasures.length===1?``:`s`,` `,`pending`]})]}),n&&(0,P.jsxs)(`div`,{className:`mt-3 space-y-4`,children:[(0,P.jsx)(_l,{view:a}),(0,P.jsx)(bl,{plugin:e,roles:a.declared.roles}),(0,P.jsx)(Cl,{plugin:e}),a.sync&&(0,P.jsx)(wl,{plugin:e,sync:a.sync,now:l}),(0,P.jsx)(Tl,{ids:a.pendingErasures})]})]})}var Dl=`w-full rounded bg-zinc-800 border px-2 py-1 text-xs text-zinc-300 placeholder-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-60`,Ol=1e4,kl=Hr(typeof CSS>`u`?void 0:CSS);function Al(e){e.preventDefault()}var jl=`flex items-center gap-1.5 rounded bg-zinc-700 px-2 py-0.5 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`;function Ml(e){return`${Dl} ${e?`border-red-500/70`:`border-zinc-700`}`}function Nl(e){let t=e.missing?.length??0;return t===0?`needs configuration`:`${t} required setting${t>1?`s`:``} not set`}function Pl({summary:e}){if(!e||e.configured!==!1)return null;let t=e.missing??[];return(0,P.jsxs)(`span`,{className:`flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-yellow-500/15 text-yellow-400`,title:t.length>0?`Required settings not set: ${t.join(`, `)}`:`Required settings are not set`,children:[(0,P.jsx)(ha,{size:11}),`Needs configuration`]})}function Fl(e){if(e.default!==void 0){let t=(e.options??[]).find(t=>t.value===e.default);return`Default (${t?t.label:e.default})`}return Cr(e)?`Choose…`:`Not set`}function Il({id:e,field:t,missing:n,error:r,children:i}){return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-baseline gap-x-2`,children:[(0,P.jsx)(`label`,{htmlFor:e,className:`text-zinc-300`,children:t.label}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-600`,children:t.key}),t.required&&(0,P.jsx)(`span`,{className:n?`text-yellow-400`:`text-zinc-500`,children:n?`required — not set`:`required`})]}),t.description&&(0,P.jsx)(`p`,{className:`mb-1 text-zinc-500`,children:t.description}),i,r&&(0,P.jsx)(`p`,{className:`mt-1 text-red-400`,children:r})]})}function Ll({pluginName:e,view:t,readOnly:n,saving:r,errors:i,onEdit:a,onInvalid:o,onSubmit:s,onDiscard:c}){let[l,u]=(0,g.useState)(()=>Er(t)),[d,f]=(0,g.useState)({}),[p,m]=(0,g.useState)(()=>Or(t)),[h,_]=(0,g.useState)({}),v=(0,g.useRef)(new Map),y=Er(t),b=Ir(t,{inputs:l,badInput:d,secretActions:p,secretFilled:h}),x=new Set(t.missing??[]),S=(e,t,n=!1)=>{u(n=>({...n,[e]:t})),f(t=>({...t,[e]:n})),a(e)},C=(e,t)=>{let n=v.current.get(e);n&&(n.value=``),_(t=>({...t,[e]:!1})),m(n=>({...n,[e]:t})),a(e)},w=e=>t=>{t?v.current.set(e,t):v.current.delete(e)},T=e=>{if(e.preventDefault(),n||r)return;let i={};for(let e of t.fields)e.type===`secret`&&(i[e.key]={action:p[e.key],value:v.current.get(e.key)?.value??``});let a=Lr(t,{inputs:l,badInput:d,secrets:i});if(!a.ok){o(a.errors);return}if(a.changed.length!==0){for(let e of v.current.values())e.value=``;_({}),s(a.body)}},E=(e,r)=>{let o=r.key,s=i[o]??null;switch(r.type){case`string`:return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`input`,{id:e,type:`text`,value:l[o],onChange:e=>S(o,e.target.value),placeholder:r.default===void 0?void 0:`Default: ${r.default}`,spellCheck:!1,"aria-invalid":s?!0:void 0,"aria-describedby":Vr(r)?`${e}-hint`:void 0,className:Ml(s)}),Vr(r)&&(0,P.jsxs)(`p`,{id:`${e}-hint`,className:`mt-1 flex items-start gap-1 text-yellow-400/90`,children:[(0,P.jsx)(Ri,{size:11,className:`mt-0.5 shrink-0`}),`Stored on the relay and shown in clear — use a secret field for credentials.`]})]});case`integer`:case`number`:return(0,P.jsx)(`input`,{id:e,type:`number`,inputMode:r.type===`integer`?`numeric`:`decimal`,step:r.type===`integer`?1:`any`,min:r.min,max:r.max,value:l[o],onChange:e=>S(o,e.target.value,e.target.validity.badInput),placeholder:r.default===void 0?void 0:`Default: ${r.default}`,"aria-invalid":s?!0:void 0,className:`${Ml(s)} sm:w-48`});case`boolean`:return(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-zinc-400`,children:[(0,P.jsx)(`input`,{id:e,type:`checkbox`,checked:l[o]===!0,onChange:e=>S(o,e.target.checked),className:`accent-cyan-500`}),l[o]===null?`not set`:l[o]?`on`:`off`]});case`enum`:return(0,P.jsxs)(`select`,{id:e,value:l[o],onChange:e=>S(o,e.target.value),"aria-invalid":s?!0:void 0,className:`${Ml(s)} sm:w-auto`,children:[(wr(r)||y[o]===``||l[o]===``)&&(0,P.jsx)(`option`,{value:``,children:Fl(r)}),(r.options??[]).map(e=>(0,P.jsx)(`option`,{value:e.value,children:e.label},e.value))]});case`secret`:{let i=Dr(t,o),c=p[o];return(0,P.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 ${i.set?`text-zinc-300`:`text-zinc-500`}`,children:[(0,P.jsx)(zi,{size:11}),kr(i)]}),c===`clear`&&(0,P.jsx)(`span`,{className:`text-yellow-400`,children:`cleared when you save`}),!n&&i.set&&c===`keep`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>C(o,`replace`),className:jl,children:[(0,P.jsx)(ra,{size:11}),`Replace`]}),wr(r)&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>C(o,`clear`),className:jl,children:[(0,P.jsx)(wi,{size:11}),`Clear`]})]}),!n&&i.set&&c!==`keep`&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>C(o,`keep`),className:jl,children:[(0,P.jsx)(Sa,{size:11}),`Keep the current one`]})]}),!n&&c===`replace`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`input`,{id:e,ref:w(o),type:`text`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,placeholder:i.set?`New value`:`Value`,onChange:e=>{let t=e.target.value!==``;_(e=>e[o]===t?e:{...e,[o]:t}),a(o)},onCopy:Al,onCut:Al,"aria-invalid":s?!0:void 0,"data-1p-ignore":!0,"data-lpignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,className:`${Ml(s)} [-webkit-text-security:disc]`}),!kl&&(0,P.jsx)(`p`,{className:`text-yellow-400/90`,children:`This browser cannot mask the value: it shows as you type it. Use a current browser to keep it out of sight.`})]})]})}default:return(0,P.jsxs)(`span`,{className:`text-zinc-500`,children:[`Cannot be set here (`,r.type,`)`]})}};return(0,P.jsx)(`form`,{onSubmit:T,autoComplete:`off`,noValidate:!0,children:(0,P.jsxs)(`fieldset`,{disabled:n||r,className:`space-y-3`,children:[t.fields.map(t=>{let n=`plugin-settings-${e}-${t.key}`;return(0,P.jsx)(Il,{id:n,field:t,missing:x.has(t.key),error:i[t.key]??null,children:E(n,t)},t.key)}),!n&&(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsxs)(`button`,{type:`submit`,disabled:b.length===0||r,className:`flex items-center gap-1.5 rounded bg-cyan-600 px-2.5 py-1 text-white hover:bg-cyan-500 disabled:opacity-50`,children:[r?(0,P.jsx)(H,{size:11,className:`animate-spin`}):(0,P.jsx)(oa,{size:11}),`Save`]}),b.length>0&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`button`,{type:`button`,onClick:c,className:jl,children:[(0,P.jsx)(Sa,{size:11}),`Discard changes`]}),(0,P.jsxs)(`span`,{className:`text-zinc-500`,children:[b.length,` change`,b.length>1?`s`:``]})]})]})]})})}function Rl({pluginName:e}){let t=z(),n=F(),r=G(),i=[`plugin-settings`,e],a=I({queryKey:i,queryFn:()=>t.getPluginSettings(e),refetchOnWindowFocus:!1,refetchInterval:e=>e.state.data&&Sr(e.state.data,e.state.dataUpdatedAt)!==null?Ol:!1}),[o,s]=(0,g.useState)({}),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(0),m=(0,g.useRef)(null);(0,g.useEffect)(()=>()=>{m.current=null},[]);let h=()=>n.invalidateQueries({queryKey:i}),_=()=>p(e=>e+1),v=L({mutationFn:()=>{let n=m.current;return m.current=null,n===null?Promise.reject(Error(`Nothing to save`)):t.updatePluginSettings(e,n)},onSuccess:e=>{e&&Array.isArray(e.fields)?n.setQueryData(i,e):h(),_(),n.invalidateQueries({queryKey:[`plugins`]}),r(`Settings saved`)},onError:e=>{let{code:t}=vo(e);if(t===`revision_mismatch`||t===`schema_mismatch`){d(t===`revision_mismatch`?`The settings were changed elsewhere since this form was loaded. It now shows the current values — make your changes again.`:`The agent half runs another version of these settings (an update may be under way). The form was reloaded — try again once the update has finished.`),_(),h();return}if(t===`hosting_offline`||t===`timeout`||t===`unauthenticated`){l(K(e)),h();return}let n=Rr(e);if(n){let e=new Set((a.data?.fields??[]).map(e=>e.key)),t=Object.fromEntries(Object.entries(n).filter(([t])=>e.has(t))),r=Object.entries(n).filter(([t])=>!e.has(t));s(t),l(r.length>0?r.map(([e,t])=>e===`_`?t:`${e}: ${t}`).join(`; `):`Not saved — see the fields above.`);return}l(K(e))}}),y=e=>{s(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})};if(a.isPending)return(0,P.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5 text-zinc-500`,children:[(0,P.jsx)(H,{size:12,className:`animate-spin`}),` Loading settings…`]});if(a.isError)return(0,P.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 text-red-400`,children:[(0,P.jsx)(mi,{size:12}),K(a.error),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>a.refetch(),className:jl,children:[(0,P.jsx)(ra,{size:11}),`Retry`]})]});let b=a.data,x=a.dataUpdatedAt,S=Sr(b,x),C=yr(b.hosting)!==null;return(0,P.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,P.jsx)(`p`,{className:`text-zinc-600`,children:zr(b,x)}),S&&(0,P.jsxs)(`div`,{className:`flex items-start gap-1.5 rounded border p-2 ${C?`border-red-500/30 text-red-400`:`border-zinc-700 text-zinc-400`}`,children:[C?(0,P.jsx)(ja,{size:12,className:`mt-0.5 shrink-0`}):(0,P.jsx)(Ri,{size:12,className:`mt-0.5 shrink-0`}),(0,P.jsxs)(`span`,{children:[S,`.`,` `,(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`Read-only for now: changes go to its agent half, which has to be reachable.`})]})]}),u&&(0,P.jsxs)(`p`,{className:`flex items-start gap-1.5 text-yellow-400`,children:[(0,P.jsx)(ia,{size:12,className:`mt-0.5 shrink-0`}),u]}),(0,P.jsx)(Ll,{pluginName:e,view:b,readOnly:S!==null,saving:v.isPending,errors:o,onEdit:y,onInvalid:e=>{s(e),l(`Not saved — see the fields above.`)},onSubmit:e=>{s({}),l(null),d(null),m.current=e,v.mutate()},onDiscard:()=>{s({}),l(null),_()}},`${b.revision}:${Fr(b.fields)}:${f}`),c&&(0,P.jsxs)(`p`,{className:`flex items-start gap-1.5 text-red-400`,children:[(0,P.jsx)(mi,{size:12,className:`mt-0.5 shrink-0`}),c]})]})}function zl({plugin:e}){let[t,n]=(0,g.useState)(!1),r=e.settings;return(0,P.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),"aria-expanded":t,className:`flex w-full flex-wrap items-center gap-2 text-left`,children:[t?(0,P.jsx)(ui,{size:12}):(0,P.jsx)(fi,{size:12}),(0,P.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:`Settings`}),r.configured?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-green-400`,children:[(0,P.jsx)(li,{size:11}),` configured`]}):(0,P.jsx)(`span`,{className:`text-yellow-400`,children:Nl(r)})]}),t&&(0,P.jsx)(Rl,{pluginName:e.name})]})}function Bl({record:e,isActing:t}){let n=z(),r=F(),i=G(),[a,o]=(0,g.useState)(null),s=()=>{r.invalidateQueries({queryKey:[`plugins`]}),r.invalidateQueries({queryKey:[`plugin-operations`,e.plugin]})},c=L({mutationFn:()=>n.purgePluginRetainedData(e.plugin,e.agentLabel),onSuccess:()=>{s(),i(`Purging what ${e.agentLabel} keeps of "${e.plugin}" — follow the steps under its name`)},onError:t=>i(Tc(t,{agentLabel:e.agentLabel,action:`uninstall`}),`error`)}),l=L({mutationFn:()=>n.forgetPluginRetainedData(e.plugin,e.agentLabel),onSuccess:()=>{s(),i(`Forgot the record — ${e.dataDir} stays on ${e.agentLabel} until it is removed there`)},onError:e=>i(K(e),`error`)}),u=t||c.isPending||l.isPending,d=(e,t,n)=>(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{o(null),t()},className:`rounded px-2 py-1 text-white disabled:opacity-50 ${n?`bg-red-600 hover:bg-red-500`:`bg-zinc-600 hover:bg-zinc-500`}`,children:e}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>o(null),className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`Cancel`})]});return(0,P.jsxs)(`li`,{className:`rounded bg-zinc-900 px-2 py-1.5`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,P.jsx)(`span`,{className:`font-mono text-zinc-200`,children:e.agentLabel}),(0,P.jsxs)(`span`,{className:`text-zinc-500`,children:[`route `,(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,children:e.route})]}),(0,P.jsx)(`span`,{className:`font-mono text-zinc-400`,children:e.package}),(0,P.jsxs)(`span`,{className:`text-zinc-600`,children:[`since `,new Date(e.since).toLocaleString()]})]}),(0,P.jsxs)(`div`,{className:`font-mono text-zinc-500`,children:[e.dataDir,` `,(0,P.jsx)(`span`,{className:`text-zinc-600`,children:`· account`}),` `,e.serviceUser]}),a===`purge`&&(0,P.jsxs)(`div`,{className:`mt-1.5 space-y-1.5`,children:[(0,P.jsxs)(`p`,{className:`flex items-start gap-1 text-red-400`,children:[(0,P.jsx)(ba,{size:11,className:`mt-0.5 shrink-0`}),(0,P.jsxs)(`span`,{children:[`Delete `,(0,P.jsx)(`span`,{className:`font-mono`,children:e.dataDir}),` and the account`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:e.serviceUser}),` on agent`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:e.agentLabel}),` (route`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:e.route}),`)? The agent's app host helper deletes them once push install lets Lamaste remove`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:e.package}),` there — this cannot be undone.`]})]}),d(`Purge`,()=>c.mutate(),!0)]}),a===`forget`&&(0,P.jsxs)(`div`,{className:`mt-1.5 space-y-1.5`,children:[(0,P.jsxs)(`p`,{className:`text-zinc-400`,children:[`Drop only the relay's record? Nothing on`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:e.agentLabel}),` changes:`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:e.dataDir}),` and the account`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:e.serviceUser}),` stay on the machine — remove them there with`,` `,(0,P.jsxs)(`span`,{className:`font-mono`,children:[`sudo lamaste-agent apphost remove `,e.route,` --purge`]}),`. For an agent that is gone, or data already removed by hand.`]}),d(`Forget`,()=>l.mutate(),!1)]}),a===null&&(0,P.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:[(0,P.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>o(`purge`),title:`Delete the data directory and the account on the agent (a push: uninstall)`,className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-red-600/20 hover:text-red-400 disabled:opacity-50`,children:[(0,P.jsx)(ya,{size:11}),`Purge…`]}),(0,P.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>o(`forget`),title:`Drop the relay's record only; the data stays on the agent`,className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:[(0,P.jsx)(wi,{size:11}),`Forget…`]})]})]})}function Vl({records:e,isActing:t}){return(0,P.jsx)(`ul`,{className:`space-y-1.5`,children:e.map(e=>(0,P.jsx)(Bl,{record:e,isActing:t},`${e.agentLabel}/${e.route}`))})}function Hl({plugin:e,isActing:t}){let n=e.retainedData??[];return n.length===0?null:(0,P.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,P.jsx)(ni,{size:12,className:`text-cyan-400`}),(0,P.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:`Retained data`})]}),(0,P.jsx)(`p`,{className:`mb-2 text-zinc-500`,children:`Its agent half was removed without purge: these agents keep its data and account. Hosting the same agent package there again takes the data back; another package is refused until it is purged.`}),(0,P.jsx)(Vl,{records:n,isActing:t})]})}function Ul({records:e,installedNames:t,isActing:n}){let r=new Map;for(let n of e)t.has(n.plugin)||r.set(n.plugin,[...r.get(n.plugin)??[],n]);return r.size===0?null:(0,P.jsxs)(`section`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5 mt-8 text-xs`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,P.jsx)(ni,{size:14,className:`text-cyan-400`}),(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-300`,children:`Retained data of uninstalled plugins`})]}),(0,P.jsx)(`p`,{className:`mb-4 text-zinc-500`,children:`These plugins are uninstalled, but agents keep the data and account of their agent halves. Purge it, or forget the record once it is gone from the agent.`}),(0,P.jsx)(`div`,{className:`space-y-4`,children:[...r.entries()].map(([e,t])=>(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`mb-2 font-mono text-sm text-zinc-200`,children:e}),(0,P.jsx)(jc,{plugin:e}),(0,P.jsx)(Vl,{records:t,isActing:n})]},e))})]})}function Wl({status:e}){return(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${e===`enabled`?`bg-green-500/20 text-green-400`:`bg-zinc-500/20 text-zinc-400`}`,children:e===`enabled`?`Enabled`:`Disabled`})}function Gl(){return(0,P.jsxs)(`span`,{className:`flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-cyan-500/10 text-cyan-400`,title:`The application runs on its own agent. Lamaste never loads its code.`,children:[(0,P.jsx)(Xi,{size:11}),`Agent-hosted`]})}function Kl({health:e}){let t=e?.state??`unknown`,n=t===`up`?`bg-green-500/20 text-green-400`:t===`down`?`bg-red-500/20 text-red-400`:`bg-zinc-500/20 text-zinc-400`,r=t===`up`?`reachable`:t===`down`?`down (${e.reason??`?`})`:`unknown`,i=[e?.since?`since ${new Date(e.since).toLocaleString()}`:null,e?.checkedAt?`checked ${new Date(e.checkedAt).toLocaleTimeString()}`:null,t!==`up`&&e?.lastError?e.lastError:null].filter(Boolean).join(` · `);return(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full ${n}`,title:i,children:[(0,P.jsx)(ti,{size:11}),r]})}function ql({hosting:e,dataDir:t,checked:n,onChange:r}){return(0,P.jsxs)(`span`,{className:`flex basis-full flex-col gap-1`,children:[(0,P.jsxs)(`label`,{className:`flex items-center gap-1 text-zinc-500`,title:`Kept by default: hosting the plugin on this agent again finds its data`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked)}),`also delete the agent half's data (purge)`]}),n&&(0,P.jsxs)(`span`,{className:`flex items-start gap-1 text-red-400`,children:[(0,P.jsx)(ba,{size:11,className:`mt-0.5 shrink-0`}),(0,P.jsxs)(`span`,{children:[`Deletes `,t?(0,P.jsx)(`span`,{className:`font-mono`,children:t}):`its data directory`,` `,`and the agent half's service account on`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:e.agentLabel}),` — this cannot be undone.`]})]})]})}function Jl({plugin:e,dataDir:t,now:n,onHost:r,onUnhost:i,onRotate:a,isActing:o}){let[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(!1),[p,m]=(0,g.useState)(!1),h=e.agentHosting,_=e.hooks?.agentHalf===!0,v=e.hooks?.approval===`pending`,y=h&&(!h.phase||h.phase===`active`)?vr(h):null;return h?(0,P.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mb-2`,children:[(0,P.jsx)(la,{size:12,className:`text-cyan-400`}),(0,P.jsxs)(`span`,{className:`text-zinc-300`,children:[`Hosted on `,(0,P.jsx)(`span`,{className:`font-mono text-zinc-200`,children:h.agentLabel})]}),(0,P.jsxs)(`span`,{className:`text-zinc-500`,children:[`port `,(0,P.jsx)(`span`,{className:`font-mono`,children:h.port})]}),h.phase&&h.phase!==`active`?(0,P.jsxs)(`span`,{className:`text-cyan-400`,children:[h.phase,`…`]}):(0,P.jsx)(Kl,{health:h.health}),!h.secretAcknowledged&&(0,P.jsx)(`span`,{className:`text-zinc-500`,title:`The agent fetches it on its next sync`,children:`secret not yet fetched`}),h.rotationPending&&(0,P.jsx)(`span`,{className:`text-yellow-400`,children:`rotation pending`})]}),y&&(0,P.jsx)(`p`,{className:`mb-2 text-red-400`,children:br(y,n)}),h.agentHalf&&(0,P.jsxs)(`p`,{className:`mb-2 text-zinc-500`,children:[`Agent half `,(0,P.jsx)(`span`,{className:`font-mono text-zinc-300`,children:h.agentHalf.version}),` `,`installed by Lamaste `,new Date(h.agentHalf.installedAt).toLocaleString()]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>a(e.name),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,title:`Issue a new installation secret; the previous one stays accepted until the agent acknowledges the new one`,children:[(0,P.jsx)(ra,{size:11}),`Rotate secret`]}),l?(0,P.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,P.jsx)(`span`,{className:`text-zinc-400`,children:_?`Run its uninstall hooks, then remove the agent half, tunnel, secret and capability?`:`Run its uninstall hooks, then remove tunnel, secret and capability?`}),(0,P.jsxs)(`label`,{className:`flex items-center gap-1 text-zinc-500`,title:`Go on when a pre-teardown hook fails or the agent does not answer (reported, audited)`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),`force`]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>{u(!1),i(e.name,{force:d,purge:_&&p},h),f(!1),m(!1)},className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500`,children:`Yes`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>{u(!1),f(!1),m(!1)},className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`}),_&&(0,P.jsx)(ql,{hosting:h,dataDir:t,checked:p,onChange:m})]}):(0,P.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>u(!0),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:[(0,P.jsx)(Na,{size:11}),`Clear hosting`]})]})]}):(0,P.jsxs)(`div`,{className:`rounded border border-zinc-800 bg-zinc-950/60 p-3 mb-4 text-xs`,children:[(0,P.jsx)(`p`,{className:`text-zinc-400 mb-2`,children:_?`Not hosted yet. Pick the agent it runs on: Lamaste installs the agent half there and runs the install hooks around creating the internal tunnel, assigning the port and issuing the installation secret.`:`Not hosted yet. Pick the agent that runs its agent half: Lamaste runs the plugin’s install hooks around creating the internal tunnel, assigning the port and issuing the installation secret.`}),(0,P.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>c(!0),title:v?`What it brings waits for approval (Lifecycle hooks)`:void 0,className:`flex items-center gap-1.5 rounded bg-cyan-600 px-3 py-1 text-white hover:bg-cyan-500 disabled:opacity-50`,children:[(0,P.jsx)(la,{size:11}),`Host on an agent…`]}),s&&(0,P.jsx)(pl,{plugin:e,onHost:r,onClose:()=>c(!1),isActing:o})]})}function Yl({plugin:e,now:t,onEnable:n,onDisable:r,onUninstall:i,onHost:a,onUnhost:o,onRotate:s,isActing:c}){let l=z(),u=e.hosting===`agent`,d=u&&e.agent!=null,f=e.agentHosting!=null&&e.hooks?.agentHalf===!0,p=I({queryKey:[`plugin-hooks`,e.name],queryFn:()=>l.getPluginHooks(e.name),enabled:e.hooks?.agentHalf===!0}).data?.hooks?.agentHalf?.dataDir??null,[m,h]=(0,g.useState)(!1),[_,v]=(0,g.useState)(!1),y=()=>{if(!m){h(!0);return}h(!1),i(e.name,{purge:f&&_},e.agentHosting),v(!1)};return(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(Zi,{size:16,className:`text-cyan-400`}),(0,P.jsx)(`span`,{className:`text-white font-semibold`,children:e.displayName||e.name}),(0,P.jsxs)(`span`,{className:`text-zinc-500 text-xs`,children:[`v`,e.version]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,P.jsx)(Pl,{summary:e.settings}),u&&(0,P.jsx)(Gl,{}),(0,P.jsx)(Wl,{status:e.status})]})]}),e.displayName&&(0,P.jsx)(`p`,{className:`text-zinc-500 text-xs font-mono mb-1`,children:e.name}),e.description&&(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm mb-2`,children:e.description}),u&&!d&&(0,P.jsx)(`p`,{className:`text-zinc-500 text-xs mb-2`,children:`Runs on its own agent. Lamaste registers its OIDC clients and capabilities; it mounts no routes and serves no pages for it.`}),d&&(0,P.jsx)(`p`,{className:`text-zinc-500 text-xs mb-2`,children:`Runs on an agent; the panel forwards its admin API and pages to the agent half over an internal tunnel.`}),(0,P.jsxs)(`p`,{className:`text-zinc-500 text-xs mb-4`,children:[e.packageName,e.installedAt&&(0,P.jsxs)(`span`,{children:[` · Installed `,new Date(e.installedAt).toLocaleDateString()]}),e.panel?.pages?.length>0&&(0,P.jsxs)(`span`,{children:[` `,`· `,e.panel.pages.length,` page`,e.panel.pages.length>1?`s`:``]})]}),e.capabilities&&e.capabilities.length>0&&(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-4`,children:e.capabilities.map(e=>(0,P.jsx)(`span`,{className:`text-xs bg-zinc-800 text-zinc-400 px-2 py-0.5 rounded`,children:e},e))}),u&&(0,P.jsx)(jc,{plugin:e.name}),(e.hooks?.relay||e.hooks?.agent||e.hooks?.agentHalf||e.identity||e.hooks?.pendingUpdate)&&(0,P.jsx)(el,{plugin:e,isActing:c}),d&&(0,P.jsx)(Jl,{plugin:e,dataDir:p,now:t,onHost:a,onUnhost:o,onRotate:s,isActing:c}),e.settings&&(0,P.jsx)(zl,{plugin:e}),e.identity&&(0,P.jsx)(El,{plugin:e}),u&&(0,P.jsx)(Hl,{plugin:e,isActing:c}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.status===`disabled`?(0,P.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>n(e.name),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,P.jsx)(na,{size:12}),`Enable`]}):(0,P.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>r(e.name),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,P.jsx)(ta,{size:12}),`Disable`]}),u&&(0,P.jsx)(tl,{plugin:e,isActing:c}),m?(0,P.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-zinc-400`,children:f?`Remove its hosting and agent half, then uninstall?`:`Uninstall?`}),(0,P.jsx)(`button`,{type:`button`,onClick:y,disabled:e.status===`enabled`,className:`rounded bg-red-600 px-2 py-1 text-white hover:bg-red-500 disabled:opacity-50 disabled:cursor-not-allowed`,children:`Yes`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>{h(!1),v(!1)},className:`rounded bg-zinc-700 px-2 py-1 text-zinc-300 hover:bg-zinc-600`,children:`No`}),f&&(0,P.jsx)(ql,{hosting:e.agentHosting,dataDir:p,checked:_,onChange:v})]}):(0,P.jsxs)(`button`,{type:`button`,disabled:c||e.status===`enabled`,onClick:y,title:e.status===`enabled`?`Disable before uninstalling`:`Uninstall plugin`,className:`flex items-center gap-1.5 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,P.jsx)(ya,{size:12}),`Uninstall`]})]})]})}function Xl({onInstall:e,isInstalling:t}){let[n,r]=(0,g.useState)(``);return(0,P.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),n.trim()&&(e(n.trim()),r(``))},className:`flex items-end gap-3`,children:[(0,P.jsxs)(`div`,{className:`flex-1`,children:[(0,P.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,htmlFor:`package-name`,children:`Package name`}),(0,P.jsx)(`input`,{id:`package-name`,type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`@lamalibre/...`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-1.5 text-sm text-zinc-300 placeholder-zinc-600 focus:outline-none focus:border-cyan-400`})]}),(0,P.jsxs)(`button`,{type:`submit`,disabled:t||!n.trim(),className:`flex items-center gap-1.5 rounded bg-cyan-600 px-4 py-1.5 text-sm text-white hover:bg-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,P.jsx)(Ci,{size:14}),`Install`]})]})}var Zl=[`install`,`update`,`uninstall`,`check-prerequisites`];function Ql({policy:e,onClose:t}){let n=z(),r=F(),i=G(),[a,o]=(0,g.useState)(e.name||``),[s,c]=(0,g.useState)(e.description||``),[l,u]=(0,g.useState)((e.allowedIps||[]).join(`
12
- `)),[d,f]=(0,g.useState)((e.deniedIps||[]).join(`
13
- `)),[p,m]=(0,g.useState)((e.allowedPlugins||[]).join(`
14
- `)),[h,_]=(0,g.useState)(e.allowedActions||Zl.slice(0,3)),v=L({mutationFn:t=>n.updatePushInstallPolicy(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`push-install-policies`]}),r.invalidateQueries({queryKey:[`push-install-config`]}),i(`Policy updated`),t()},onError:e=>i(K(e),`error`)}),y=e=>{e.preventDefault();let t=e=>e.split(`
15
- `).map(e=>e.trim()).filter(Boolean);v.mutate({name:a,description:s,allowedIps:t(l),deniedIps:t(d),allowedPlugins:t(p),allowedActions:h})},b=e=>{_(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,P.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl bg-zinc-900 border border-zinc-700 p-6 shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Edit Policy`}),(0,P.jsx)(`button`,{type:`button`,onClick:t,className:`text-zinc-400 hover:text-white`,children:(0,P.jsx)(Na,{size:20})})]}),(0,P.jsxs)(`form`,{onSubmit:y,className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Name`}),(0,P.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Description`}),(0,P.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Allowed IPs (one per line)`}),(0,P.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),rows:3,placeholder:`192.168.1.0/24`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Denied IPs (one per line)`}),(0,P.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),rows:2,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:border-cyan-500 focus:outline-none`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Allowed Plugins (one per line)`}),(0,P.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),rows:2,placeholder:`@lamalibre/lamaste-herd-plugin`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`}),(0,P.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:[`For an agent half Lamaste installs, name its agent package (the manifest's`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:`agent.package`}),`). Empty allows every package.`]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-2`,children:`Allowed Actions`}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:Zl.map(e=>(0,P.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:h.includes(e),onChange:()=>b(e),className:`accent-cyan-500`}),(0,P.jsx)(`span`,{className:`text-zinc-300`,children:e})]},e))})]}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-3 pt-2`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:t,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,P.jsxs)(`button`,{type:`submit`,disabled:!a.trim()||v.isPending,className:`rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:[v.isPending?(0,P.jsx)(H,{size:14,className:`animate-spin inline mr-1`}):null,`Save Changes`]})]})]})]})})}function $l(){let e=z(),t=F(),n=G(),[r,i]=(0,g.useState)(null),a=I({queryKey:[`push-install-policies`],queryFn:()=>e.getPushInstallPolicies(),refetchInterval:3e4}),o=L({mutationFn:t=>e.deletePushInstallPolicy(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`push-install-policies`]}),t.invalidateQueries({queryKey:[`push-install-config`]}),n(`Policy deleted`)},onError:e=>n(K(e),`error`)}),s=a.data?.policies||[];return a.isLoading||s.length===0?null:(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,P.jsx)(ma,{size:14,className:`text-cyan-400`}),(0,P.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300`,children:`Policies`})]}),(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Name`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden md:table-cell`,children:`Description`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden lg:table-cell`,children:`Actions`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Manage`})]})}),(0,P.jsx)(`tbody`,{children:s.map(e=>(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,P.jsx)(`td`,{className:`px-4 py-3 text-zinc-200 font-semibold`,children:e.name}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-zinc-400 hidden md:table-cell`,children:e.description||`—`}),(0,P.jsx)(`td`,{className:`px-4 py-3 hidden lg:table-cell`,children:(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(e.allowedActions||[]).map(e=>(0,P.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-zinc-700 text-zinc-300`,children:e},e))})}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600`,title:`Edit policy`,children:(0,P.jsx)(Qi,{size:12})}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>o.mutate(e.id),disabled:o.isPending,className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-red-600/20 hover:text-red-400`,title:`Delete policy`,children:(0,P.jsx)(ya,{size:12})})]})})]},e.id))})]})}),r&&(0,P.jsx)(Ql,{policy:r,onClose:()=>i(null)})]})}function eu(){let e=z(),t=F(),n=G(),{reveal:r}=Za(),i=I({queryKey:[`plugins`],queryFn:()=>e.getPlugins(),refetchInterval:1e4}),a=L({mutationFn:async t=>{let{result:n,secrets:i}=Ua(await e.installPlugin(t));return r({plugin:n.plugin?.name??t,cause:`install`,secrets:i}),n},onSuccess:e=>{t.invalidateQueries({queryKey:[`plugins`]}),n(`Plugin "${e.plugin?.name||`unknown`}" installed`)},onError:e=>n(K(e),`error`)}),o=L({mutationFn:async t=>{let{result:n,secrets:i}=Ua(await e.enablePlugin(t));return r({plugin:t,cause:`enable`,secrets:i}),n},onSuccess:e=>{let r=i.data?.plugins?.find(t=>t.name===e.name);t.invalidateQueries({queryKey:[`plugins`]}),n(r?.hosting===`agent`?`Plugin "${e.name}" enabled (agent-hosted — nothing to mount)`:`Plugin "${e.name}" enabled (restart panel to mount routes)`)},onError:e=>n(K(e),`error`)}),s=L({mutationFn:t=>e.disablePlugin(t),onSuccess:e=>{t.invalidateQueries({queryKey:[`plugins`]}),n(`Plugin "${e.name}" disabled`)},onError:e=>n(K(e),`error`)}),c=(e,{hosting:t})=>n(Tc(e,{agentLabel:t?.agentLabel,action:`uninstall`}),`error`),l=L({mutationFn:({name:t,purge:n})=>e.uninstallPlugin(t,{purge:n}),onSuccess:(e,{name:r,purge:i})=>{t.invalidateQueries({queryKey:[`plugins`]}),e.operation?(t.invalidateQueries({queryKey:[`plugin-operations`,r]}),n(`Uninstalling "${r}": its hosting is removed first${i?`, with its agent half’s data`:``} — follow the steps on its card`)):n(`Plugin "${e.name}" uninstalled`)},onError:c}),u=L({mutationFn:({name:t,agentLabel:n})=>e.setPluginHosting(t,n),onSuccess:(e,{name:r,agentLabel:i})=>{t.invalidateQueries({queryKey:[`plugin-operations`,r]}),n(`Hosting "${r}" on ${i} — follow the steps on its card`)}}),d=L({mutationFn:({name:t,force:n,purge:r})=>e.clearPluginHosting(t,{force:n,purge:r}),onSuccess:(e,{name:r,purge:i})=>{t.invalidateQueries({queryKey:[`plugin-operations`,r]}),n(`Removing the hosting of "${r}"${i?` and its agent half’s data`:``} — follow the steps on its card`)},onError:c}),f=L({mutationFn:t=>e.rotatePluginHostingSecret(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`plugins`]}),n(`New installation secret issued — the agent picks it up on its next sync`)},onError:e=>n(K(e),`error`)}),p=a.isPending||o.isPending||s.isPending||l.isPending||u.isPending||d.isPending||f.isPending,m=(0,g.useCallback)(e=>a.mutate(e),[a]),h=(0,g.useCallback)(e=>o.mutate(e),[o]),_=(0,g.useCallback)(e=>s.mutate(e),[s]),v=(0,g.useCallback)((e,t={},n=null)=>l.mutate({name:e,purge:t.purge===!0,hosting:n}),[l]),y=(0,g.useCallback)((e,t,n)=>u.mutate({name:e,agentLabel:t},n),[u]),b=(0,g.useCallback)((e,t={},n=null)=>d.mutate({name:e,force:t.force===!0,purge:t.purge===!0,hosting:n}),[d]),x=(0,g.useCallback)(e=>f.mutate(e),[f]),S=i.data?.plugins,C=i.data?.retainedData??[],w=new Set((S??[]).map(e=>e.name));return(0,P.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,P.jsxs)(`div`,{className:`mb-6`,children:[(0,P.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Plugins`}),(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Install, enable, and manage plugins`})]}),(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5 mb-8`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4`,children:`Install Plugin`}),(0,P.jsx)(Xl,{onInstall:m,isInstalling:a.isPending}),a.isPending&&(0,P.jsx)(`p`,{className:`text-xs text-zinc-500 mt-2`,children:`Installing...`})]}),i.isLoading?(0,P.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:Array.from({length:2}).map((e,t)=>(0,P.jsx)(`div`,{className:`h-40 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):i.isError?(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,P.jsx)(mi,{size:16}),`Failed to load plugins`]})}):S?.length===0?(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm text-center`,children:`No plugins installed. Use the form above to install one.`})}):(0,P.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:S?.map(e=>(0,P.jsx)(Yl,{plugin:e,now:i.dataUpdatedAt,onEnable:h,onDisable:_,onUninstall:v,onHost:y,onUnhost:b,onRotate:x,isActing:p},e.name))}),(0,P.jsx)(Ul,{records:C,installedNames:w,isActing:p}),(0,P.jsx)(cl,{children:(0,P.jsx)($l,{})})]})}function tu(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return a>30?new Date(e).toLocaleDateString():a>0?`${a}d ago`:i>0?`${i}h ago`:r>0?`${r}m ago`:`just now`}var nu=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;function ru(e){return e?e.length>63?`Max 63 characters`:nu.test(e)?null:`Lowercase letters, numbers, and hyphens only. Cannot start or end with a hyphen.`:`Subdomain is required`}var iu={default:10,min:1,max:10240};function au(e){let t=Number(e);return e===``||!Number.isInteger(t)?`Must be a whole number of MiB`:t<iu.min?`Minimum ${iu.min}`:t>iu.max?`Maximum ${iu.max}`:null}function ou(e){return e.maxBodySizeMb??1}var su=[{value:`restricted`,label:`Restricted`,desc:`Only granted users and groups`},{value:`authenticated`,label:`All Authelia Users`,desc:`Any authenticated user can access`},{value:`public`,label:`Public`,desc:`No authentication required`}],cu=[3100,9090,9091,9292,9294];function lu(e){let t=Number(e);return!e&&e!==0?`Port is required`:Number.isInteger(t)?t<1024?`Minimum 1024`:t>65535?`Maximum 65535`:cu.includes(t)?`Reserved for a Lamaste service on the relay`:null:`Must be an integer`}function uu(){let e=z(),t=I({queryKey:[`admin-agents`],queryFn:()=>e.getAgents()});return{agents:(t.data?.agents||[]).filter(e=>!e.revoked&&e.certType!==`plugin-agent`).map(e=>e.label).sort(),isLoading:t.isLoading}}function du({domain:e,onClose:t}){let n=z(),r=F(),i=G(),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(`restricted`),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(String(iu.default)),{agents:v,isLoading:y}=uu(),[b,x]=(0,g.useState)({}),[S,C]=(0,g.useState)(null),w=L({mutationFn:e=>n.createTunnel(e),onSuccess:e=>{r.invalidateQueries({queryKey:[`tunnels`]}),i(`Tunnel ${e.tunnel.fqdn} created`),t()},onError:e=>{C(K(e))}}),T=(0,g.useCallback)(e=>{e.preventDefault(),C(null);let t=ru(a),n=lu(s),r={};t&&(r.subdomain=t),n&&(r.port=n),p||(r.agentLabel=`Choose the agent that carries this tunnel`);let i=au(h);if(i&&(r.maxBody=i),Object.keys(r).length>0){x(r);return}x({}),w.mutate({subdomain:a,port:Number(s),description:l||void 0,accessMode:d,agentLabel:p,maxBodySizeMb:Number(h)})},[a,s,l,d,p,h,w]);return(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-5 mb-6`,children:[(0,P.jsxs)(`h2`,{className:`text-sm font-semibold text-zinc-300 mb-4 flex items-center gap-2`,children:[(0,P.jsx)(ea,{size:14,className:`text-cyan-400`}),`Add Tunnel`]}),(0,P.jsxs)(`form`,{onSubmit:T,className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Subdomain`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,P.jsx)(`input`,{type:`text`,value:a,onChange:e=>{o(e.target.value.toLowerCase()),x(e=>({...e,subdomain:void 0}))},disabled:w.isPending,placeholder:`myapp`,className:`flex-1 rounded-l bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder:text-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),(0,P.jsxs)(`span`,{className:`rounded-r bg-zinc-800/60 border border-l-0 border-zinc-700 px-3 py-2 text-sm text-zinc-500 font-mono`,children:[`.`,e]})]}),b.subdomain&&(0,P.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:b.subdomain})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Port`}),(0,P.jsx)(`input`,{type:`number`,value:s,onChange:e=>{c(e.target.value),x(e=>({...e,port:void 0}))},disabled:w.isPending,placeholder:`8080`,min:1024,max:65535,className:`w-40 rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono placeholder:text-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),b.port&&(0,P.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:b.port})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Agent`}),(0,P.jsxs)(`select`,{value:p,onChange:e=>{m(e.target.value),x(e=>({...e,agentLabel:void 0}))},disabled:w.isPending||y,className:`w-64 rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:outline-none focus:border-cyan-400 disabled:opacity-50`,children:[(0,P.jsx)(`option`,{value:``,children:y?`Loading agents…`:`Select an agent`}),v.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]}),(0,P.jsx)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:`Only this agent forwards the port. It starts carrying the tunnel within 30 seconds.`}),!y&&v.length===0&&(0,P.jsx)(`p`,{className:`text-yellow-400 text-xs mt-1`,children:`No agents enrolled yet — enroll one under Certificates first.`}),b.agentLabel&&(0,P.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:b.agentLabel})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Largest request body (MiB)`}),(0,P.jsx)(`input`,{type:`number`,value:h,onChange:e=>{_(e.target.value),x(e=>({...e,maxBody:void 0}))},disabled:w.isPending,min:iu.min,max:iu.max,className:`w-40 rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),(0,P.jsx)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:`Larger uploads are rejected with 413. Raise it for apps that accept big files.`}),b.maxBody&&(0,P.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:b.maxBody})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:[`Description `,(0,P.jsx)(`span`,{className:`text-zinc-600`,children:`(optional)`})]}),(0,P.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),disabled:w.isPending,placeholder:`My web application`,maxLength:200,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder:text-zinc-600 focus:outline-none focus:border-cyan-400 disabled:opacity-50`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-2`,children:`Access`}),(0,P.jsx)(`div`,{className:`space-y-2`,children:su.map(e=>(0,P.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,P.jsx)(`input`,{type:`radio`,name:`accessMode`,value:e.value,checked:d===e.value,onChange:e=>f(e.target.value),disabled:w.isPending,className:`mt-1 text-cyan-500 focus:ring-cyan-500 bg-zinc-800 border-zinc-700`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-sm text-zinc-200`,children:e.label}),(0,P.jsx)(`p`,{className:`text-xs text-zinc-500`,children:e.desc})]})]},e.value))})]}),S&&(0,P.jsx)(`div`,{className:`rounded bg-red-500/10 border border-red-500/20 px-3 py-2 text-sm text-red-400`,children:S}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(`button`,{type:`submit`,disabled:w.isPending,className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed`,children:w.isPending?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:14,className:`animate-spin`}),`Setting up tunnel...`]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(ea,{size:14}),`Add Tunnel`]})}),(0,P.jsx)(`button`,{type:`button`,onClick:t,disabled:w.isPending,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`})]})]})]})}function fu({tunnel:e,onConfirm:t,onCancel:n,isPending:r}){return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:`Delete Tunnel`}),(0,P.jsxs)(`p`,{className:`text-zinc-400 text-sm mb-6`,children:[`Are you sure you want to delete`,` `,(0,P.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:e.fqdn}),`? This will remove the nginx configuration and TLS certificate mapping.`]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,onClick:t,disabled:r,className:`flex items-center gap-2 rounded bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-500 disabled:opacity-50`,children:r?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:14,className:`animate-spin`}),`Deleting...`]}):`Delete`})]})]})})}function pu({tunnel:e,onConfirm:t,onCancel:n,isPending:r}){let{agents:i,isLoading:a}=uu(),[o,s]=(0,g.useState)(e.agentLabel||``),[c,l]=(0,g.useState)(e.accessMode||`restricted`),u=ou(e),[d,f]=(0,g.useState)(String(u)),p=au(d),m={};o&&o!==e.agentLabel&&(m.agentLabel=o),c!==(e.accessMode||`restricted`)&&(m.accessMode=c),!p&&Number(d)!==u&&(m.maxBodySizeMb=Number(d));let h=Object.keys(m).length>0,_=xs(e);return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-1`,children:`Edit Tunnel`}),(0,P.jsx)(`p`,{className:`text-cyan-400 font-mono text-sm mb-5`,children:e.fqdn}),(0,P.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:`Agent`}),(0,P.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),disabled:r||a,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:outline-none focus:border-cyan-400 disabled:opacity-50`,children:[!e.agentLabel&&(0,P.jsx)(`option`,{value:``,children:`Unassigned — select an agent`}),i.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]}),m.agentLabel&&(0,P.jsxs)(`p`,{className:`text-xs text-zinc-500 mt-1`,children:[e.agentLabel?`Both agents pick`:`${m.agentLabel} picks`,` the change up within 30 seconds.`]}),(0,P.jsx)(`label`,{className:`block text-xs text-zinc-400 mt-4 mb-2`,children:`Access`}),(0,P.jsx)(`div`,{className:`space-y-2`,children:su.map(e=>{let t=e.value===`public`&&_.length>0;return(0,P.jsxs)(`label`,{className:`flex items-start gap-2 ${t?`cursor-not-allowed opacity-50`:`cursor-pointer`}`,children:[(0,P.jsx)(`input`,{type:`radio`,name:`editAccessMode`,value:e.value,checked:c===e.value,onChange:e=>l(e.target.value),disabled:r||t,className:`mt-1 text-cyan-500 focus:ring-cyan-500 bg-zinc-800 border-zinc-700`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-sm text-zinc-200`,children:e.label}),(0,P.jsx)(`p`,{className:`text-xs text-zinc-500`,children:t?`Not while it serves the user surface of ${_.join(`, `)} — unbind it first`:e.desc})]})]},e.value)})}),(0,P.jsx)(`label`,{className:`block text-xs text-zinc-400 mt-4 mb-1`,children:`Largest request body (MiB)`}),(0,P.jsx)(`input`,{type:`number`,value:d,onChange:e=>f(e.target.value),disabled:r,min:iu.min,max:iu.max,className:`w-40 rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:outline-none focus:border-cyan-400 disabled:opacity-50`}),p&&(0,P.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:p}),(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-3 mt-6`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(m),disabled:r||!h||!!p,className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:r?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(H,{size:14,className:`animate-spin`}),`Saving...`]}):`Save`})]})]})})}function mu({tunnel:e}){let t=xs(e);return t.length===0?null:(0,P.jsx)(`span`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:t.map(t=>{let n=Ss(e,t),r=n?.served===!0;return(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs ${r?`bg-cyan-500/10 text-cyan-400`:`bg-yellow-500/10 text-yellow-400`}`,title:`User surface of ${t}: ${n?vs(n.reason):`status unknown`}`,children:[(0,P.jsx)(ka,{size:11}),t,!r&&n?.reason&&(0,P.jsxs)(`span`,{className:`text-yellow-400/70`,children:[`(`,n.reason.replace(/_/g,` `),`)`]})]},t)})})}function hu({tunnelId:e,tunnels:t,onClose:n}){let r=z(),i=F(),a=G(),[o,s]=(0,g.useState)(``),c=t.find(t=>t.id===e),l=I({queryKey:[`plugins`],queryFn:()=>r.getPlugins()}),u=()=>{i.invalidateQueries({queryKey:[`tunnels`]}),i.invalidateQueries({queryKey:[`plugin-identity`]})},d=L({mutationFn:t=>r.bindTunnelUserSurface(e,t),onSuccess:(e,t)=>{u(),s(``);let n=Ss(e.tunnel,t);a(n?.served?`Users reach ${t} at https://${e.tunnel.fqdn}/api/${t}/app/`:`Bound ${t} — ${vs(n?.reason??null)}`)},onError:e=>a(K(e),`error`)}),f=L({mutationFn:t=>r.unbindTunnelUserSurface(e,t),onSuccess:(e,t)=>{u(),a(`${t}: its requests go down the tunnel again`)},onError:e=>a(K(e),`error`)});if(!c)return null;let p=d.isPending||f.isPending,m=xs(c),h=ys(c),_=new Map;for(let e of t)if(e.id!==c.id)for(let t of xs(e))_.set(t,e.fqdn??e.subdomain);let v=(l.data?.plugins??[]).filter(e=>e.hosting===`agent`&&e.route&&!m.includes(e.route)).sort((e,t)=>e.route.localeCompare(t.route));return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,P.jsxs)(`div`,{className:`bg-zinc-900 border border-zinc-800 rounded-lg p-6 max-w-lg w-full mx-4 shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`User Surface`}),(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`text-zinc-500 hover:text-zinc-300`,children:(0,P.jsx)(Na,{size:18})})]}),(0,P.jsx)(`p`,{className:`text-cyan-400 font-mono text-sm mb-3`,children:c.fqdn}),(0,P.jsxs)(`p`,{className:`text-xs text-zinc-500 mb-4`,children:[`Agent-hosted plugins bound here are reached at`,` `,(0,P.jsx)(`span`,{className:`font-mono text-zinc-400`,children:`/api/<route>/app/`}),` on this host by signed-in users: Gatekeeper vouches for the session, the panel passes the user's id and roles to the plugin's agent half. Only a plugin hosted on this tunnel's agent (`,c.agentLabel??`none`,`) is served here. Until a plugin's installed, approved version declares identity, those requests still go down the tunnel.`]}),(0,P.jsx)(`p`,{className:`text-xs text-zinc-400 mb-1`,children:`Bound here`}),m.length===0?(0,P.jsx)(`p`,{className:`text-xs text-zinc-600 mb-4`,children:`No plugin yet.`}):(0,P.jsx)(`ul`,{className:`mb-4 space-y-1`,children:m.map(e=>{let t=Ss(c,e);return(0,P.jsxs)(`li`,{className:`flex items-start justify-between gap-2 rounded bg-zinc-800/60 px-2 py-1.5 text-xs`,children:[(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`font-mono text-zinc-200`,children:e}),` `,(0,P.jsxs)(`span`,{className:t?.served?`text-green-400`:`text-yellow-400`,children:[`— `,vs(t?.reason??null)]})]}),(0,P.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>f.mutate(e),className:`shrink-0 rounded bg-zinc-700 px-2 py-0.5 text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Unbind`})]},e)})}),h.eligible?(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),disabled:p||l.isLoading,"aria-label":`Agent-hosted plugin`,className:`flex-1 rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:outline-none focus:border-cyan-400 disabled:opacity-50`,children:[(0,P.jsx)(`option`,{value:``,children:l.isLoading?`Loading plugins…`:`Select an agent-hosted plugin`}),v.map(e=>{let t=bs(e,c,_);return(0,P.jsxs)(`option`,{value:e.route,disabled:t!==null,children:[e.route,t===null?e.identity?``:` — declares no identity yet`:` — ${t}`]},e.route)})]}),(0,P.jsxs)(`button`,{type:`button`,disabled:p||!o,onClick:()=>d.mutate(o),className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:[d.isPending?(0,P.jsx)(H,{size:14,className:`animate-spin`}):(0,P.jsx)(ea,{size:14}),`Bind`]}),!l.isLoading&&v.length===0&&(0,P.jsx)(`p`,{className:`basis-full text-xs text-zinc-500`,children:`No other agent-hosted plugin is installed.`})]}):(0,P.jsxs)(`p`,{className:`text-xs text-yellow-400`,children:[`This tunnel cannot serve a user surface: `,h.reason,`.`]})]})})}function gu({tunnel:e}){return(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-cyan-500/10 text-cyan-400`,title:`Internal tunnel of an agent-hosted plugin: no hostname, no certificate, reachable only by the panel's forwarder`,children:[`plugin:`,e.pluginRoute||`?`]})}function _u({tunnel:e}){return e.agentLabel?(0,P.jsx)(`span`,{className:`text-sm text-zinc-300 font-mono`,children:e.agentLabel}):(0,P.jsx)(`span`,{className:`inline-block px-2 py-0.5 rounded text-xs bg-red-500/10 text-red-400`,title:`No agent carries this tunnel. Move it to an agent to bring it back.`,children:`unassigned`})}function vu({tunnels:e,onDelete:t,onToggle:n,onEdit:r,onUserSurface:i}){return(0,P.jsx)(`div`,{className:`hidden md:block overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700`,children:[(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Status`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Subdomain`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`FQDN`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Port`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Agent`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Access`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Body limit`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Description`}),(0,P.jsx)(`th`,{className:`text-left text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Created`}),(0,P.jsx)(`th`,{className:`text-right text-zinc-400 text-xs uppercase font-semibold py-3 px-4`,children:`Actions`})]})}),(0,P.jsx)(`tbody`,{children:e.map(e=>{let a=e.enabled!==!1,o=e.exposure===`internal`;return(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 ${a?`bg-zinc-800/50`:`bg-zinc-800/20 opacity-60`}`,children:[(0,P.jsx)(`td`,{className:`py-3 px-4`,children:(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${a?`text-green-400 bg-green-500/10 border-green-500/20`:`text-zinc-500 bg-zinc-800 border-zinc-700`}`,children:a?`active`:`disabled`})}),(0,P.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-200 font-mono`,children:o?(0,P.jsx)(gu,{tunnel:e}):e.subdomain}),(0,P.jsx)(`td`,{className:`py-3 px-4 text-sm`,children:o?(0,P.jsx)(`span`,{className:`text-zinc-500`,children:`relay loopback only`}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`a`,{href:`https://${e.fqdn}`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 ${a?`text-cyan-400 hover:text-cyan-300`:`text-zinc-500`}`,children:[e.fqdn,(0,P.jsx)(Ti,{size:12})]}),(0,P.jsx)(mu,{tunnel:e})]})}),(0,P.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-200 font-mono`,children:e.port}),(0,P.jsx)(`td`,{className:`py-3 px-4`,children:(0,P.jsx)(_u,{tunnel:e})}),(0,P.jsxs)(`td`,{className:`py-3 px-4 text-sm`,children:[o&&(0,P.jsx)(`span`,{className:`inline-block px-2 py-0.5 rounded text-xs bg-zinc-700/60 text-zinc-300`,children:`Internal`}),e.type!==`panel`&&!o&&(0,P.jsx)(`span`,{className:`inline-block px-2 py-0.5 rounded text-xs ${e.accessMode===`public`?`bg-green-500/10 text-green-400`:e.accessMode===`authenticated`?`bg-blue-500/10 text-blue-400`:`bg-orange-500/10 text-orange-400`}`,children:e.accessMode===`public`?`Public`:e.accessMode===`authenticated`?`All Users`:`Restricted`})]}),(0,P.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-400 font-mono`,children:e.type===`panel`?`—`:`${ou(e)} MiB`}),(0,P.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-400`,children:e.description||`—`}),(0,P.jsx)(`td`,{className:`py-3 px-4 text-sm text-zinc-500`,children:tu(e.createdAt)}),(0,P.jsx)(`td`,{className:`py-3 px-4 text-right`,children:o?(0,P.jsx)(`span`,{className:`text-xs text-zinc-500`,title:`Managed with the plugin's hosting`,children:`managed by plugin hosting`}):(0,P.jsxs)(`div`,{className:`inline-flex items-center gap-2`,children:[e.type!==`panel`&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600`,title:`Agent, access mode, body limit`,children:[(0,P.jsx)(ua,{size:12}),`Edit`]}),(e.type??`app`)===`app`&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600`,title:`Serve agent-hosted plugins' user surfaces on this host`,children:[(0,P.jsx)(ka,{size:12}),`Users`]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs hover:bg-zinc-600 ${a?`text-yellow-400`:`text-green-400`}`,title:a?`Disable tunnel`:`Enable tunnel`,children:[(0,P.jsx)(na,{size:12}),a?`Disable`:`Enable`]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-red-400 hover:bg-red-600/20 hover:text-red-300`,children:[(0,P.jsx)(ya,{size:12}),`Delete`]})]})})]},e.id)})})]})})}function yu({tunnels:e,onDelete:t,onToggle:n,onEdit:r,onUserSurface:i}){return(0,P.jsx)(`div`,{className:`md:hidden space-y-3`,children:e.map(e=>{let a=e.enabled!==!1,o=e.exposure===`internal`;return(0,P.jsxs)(`div`,{className:`border border-zinc-700 rounded-lg p-4 ${a?`bg-zinc-800/50`:`bg-zinc-800/20 opacity-60`}`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full border ${a?`text-green-400 bg-green-500/10 border-green-500/20`:`text-zinc-500 bg-zinc-800 border-zinc-700`}`,children:a?`active`:`disabled`}),(0,P.jsx)(`span`,{className:`text-sm font-semibold text-zinc-200 font-mono`,children:o?(0,P.jsx)(gu,{tunnel:e}):e.subdomain})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.type!==`panel`&&!o&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`text-xs text-zinc-300`,title:`Agent, access mode, body limit`,children:(0,P.jsx)(ua,{size:14})}),(e.type??`app`)===`app`&&!o&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`text-xs text-zinc-300`,title:`Serve agent-hosted plugins' user surfaces on this host`,children:(0,P.jsx)(ka,{size:14})}),!o&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:`text-xs ${a?`text-yellow-400`:`text-green-400`}`,children:(0,P.jsx)(na,{size:14})}),!o&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(e),className:`inline-flex items-center gap-1 text-xs text-red-400 hover:text-red-300`,children:(0,P.jsx)(ya,{size:12})})]})]}),o?(0,P.jsx)(`p`,{className:`text-sm text-zinc-500 mb-1`,children:`Relay loopback only — managed by plugin hosting`}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`a`,{href:`https://${e.fqdn}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm inline-flex items-center gap-1 mb-1 ${a?`text-cyan-400 hover:text-cyan-300`:`text-zinc-500`}`,children:[e.fqdn,(0,P.jsx)(Ti,{size:12})]}),(0,P.jsx)(mu,{tunnel:e})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-zinc-500 mt-2`,children:[(0,P.jsxs)(`span`,{children:[`Port: `,(0,P.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:e.port})]}),(0,P.jsxs)(`span`,{children:[`Agent: `,(0,P.jsx)(_u,{tunnel:e})]}),(0,P.jsx)(`span`,{children:tu(e.createdAt)})]}),e.description&&(0,P.jsx)(`p`,{className:`text-xs text-zinc-400 mt-2`,children:e.description})]},e.id)})})}function bu(){let e=z(),t=F(),n=G(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),d=I({queryKey:[`tunnels`],queryFn:()=>e.getTunnels(),refetchInterval:1e4}),f=I({queryKey:[`tunnel-agent-config`],queryFn:()=>e.getTunnelAgentConfig()}).data?.domain,p=L({mutationFn:t=>e.deleteTunnel(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`tunnels`]}),n(`Tunnel ${a.fqdn} deleted`),o(null)},onError:e=>{n(K(e),`error`),o(null)}}),m=L({mutationFn:({id:t,enabled:n})=>e.updateTunnel(t,{enabled:n}),onSuccess:e=>{t.invalidateQueries({queryKey:[`tunnels`]});let r=e.tunnel;n(`Tunnel ${r.fqdn} ${r.enabled?`enabled`:`disabled`}`)},onError:e=>{n(K(e),`error`)}}),h=L({mutationFn:({id:t,changes:n})=>e.updateTunnel(t,n),onSuccess:e=>{t.invalidateQueries({queryKey:[`tunnels`]}),n(`Tunnel ${e.tunnel.fqdn} updated`),c(null)},onError:e=>{n(K(e),`error`),c(null)}}),_=(0,g.useCallback)(e=>{c(e)},[]),v=(0,g.useCallback)(e=>{u(e.id)},[]),y=(0,g.useCallback)(e=>{o(e)},[]),b=(0,g.useCallback)(e=>{let t=e.enabled!==!1;m.mutate({id:e.id,enabled:!t})},[m]),x=(0,g.useCallback)(()=>{a&&p.mutate(a.id)},[a,p]),S=d.data?.tunnels||[];return(0,P.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,P.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Tunnels`}),(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Manage reverse tunnel configurations`})]}),!r&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,P.jsx)(ea,{size:14}),`Add Tunnel`]})]}),r&&f&&(0,P.jsx)(du,{domain:f,onClose:()=>i(!1)}),d.isLoading?(0,P.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,P.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):d.isError?(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsx)(`p`,{className:`text-red-400 text-sm`,children:`Failed to load tunnels`})}):S.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-12 text-center`,children:[(0,P.jsx)(Xi,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No tunnels yet. Add your first tunnel to get started.`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(vu,{tunnels:S,onDelete:y,onToggle:b,onEdit:_,onUserSurface:v}),(0,P.jsx)(yu,{tunnels:S,onDelete:y,onToggle:b,onEdit:_,onUserSurface:v})]}),l&&(0,P.jsx)(hu,{tunnelId:l,tunnels:S,onClose:()=>u(null)}),s&&(0,P.jsx)(pu,{tunnel:s,onConfirm:e=>h.mutate({id:s.id,changes:e}),onCancel:()=>c(null),isPending:h.isPending}),a&&(0,P.jsx)(fu,{tunnel:a,onConfirm:x,onCancel:()=>o(null),isPending:p.isPending})]})}function xu({hasDomain:e}){let t=z(),n=G(),r=F(),i=I({queryKey:[`settings-2fa`],queryFn:()=>t.get2faStatus()}),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(!1),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(!1),v=i.data||{enabled:!1,setupComplete:!1},y=L({mutationFn:()=>t.setup2fa(),onSuccess:e=>o(e)}),b=L({mutationFn:e=>t.confirm2fa(e),onSuccess:()=>{r.invalidateQueries(),o(null),c(``),n(`Two-factor authentication enabled`)}}),x=L({mutationFn:e=>t.disable2fa(e),onSuccess:()=>{r.invalidateQueries(),u(``),n(`Two-factor authentication disabled`)}}),S=L({mutationFn:e=>t.triggerPanelUpdate(e),onSuccess:()=>{n(`Update initiated. The panel will restart shortly.`),m(``),_(!1)},onError:e=>n(K(e),`error`)}),C=/^\d+\.\d+\.\d+$/.test(p);function w(){a?.manualKey&&navigator.clipboard.writeText(a.manualKey).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)},()=>{n(`Failed to copy to clipboard`,`error`)})}function T(e){e.preventDefault(),s.length===6&&b.mutate(s)}function E(e){e.preventDefault(),l.length===6&&x.mutate(l)}if(i.isLoading)return(0,P.jsx)(`div`,{className:`p-6`,children:(0,P.jsx)(`div`,{className:`mx-auto h-6 w-6 animate-spin rounded-full border-2 border-zinc-600 border-t-cyan-400`})});if(i.isError)return(0,P.jsxs)(`div`,{className:`mx-auto max-w-2xl p-6`,children:[(0,P.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Settings`}),(0,P.jsx)(`p`,{className:`mt-4 text-sm text-red-400`,children:`Failed to load settings. Please try again.`})]});let D=b.error?.message,O=x.error?.message,ee=y.error?.message;return(0,P.jsxs)(`div`,{className:`mx-auto max-w-2xl p-6`,children:[(0,P.jsxs)(`div`,{className:`mb-6`,children:[(0,P.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Settings`}),(0,P.jsx)(`p`,{className:`mt-1 text-sm text-zinc-500`,children:`Configure panel security settings.`})]}),(0,P.jsxs)(`div`,{className:`rounded-lg border border-zinc-800 bg-zinc-900 p-6`,children:[(0,P.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,P.jsx)(pa,{className:`h-5 w-5 text-cyan-400`}),(0,P.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:`Two-Factor Authentication`}),v.enabled&&(0,P.jsx)(`span`,{className:`rounded-full border border-green-500/20 bg-green-500/10 px-2 py-0.5 text-xs text-green-400`,children:`Enabled`})]}),!v.enabled&&!a&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Add a second layer of protection to the admin panel. When enabled, you will need both your mTLS certificate and a TOTP code from your authenticator app to access the panel.`}),!e&&(0,P.jsxs)(`div`,{className:`mb-4 flex items-start gap-2 rounded-lg border border-yellow-500/20 bg-yellow-500/5 p-3`,children:[(0,P.jsx)(ba,{className:`mt-0.5 h-4 w-4 flex-shrink-0 text-yellow-400`}),(0,P.jsx)(`p`,{className:`text-sm text-yellow-400`,children:`A domain must be configured before enabling 2FA. Enabling 2FA disables IP:9292 access.`})]}),ee&&(0,P.jsx)(`p`,{className:`mb-3 text-sm text-red-400`,children:ee}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>y.mutate(),disabled:!e||y.isPending,className:`rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:cursor-not-allowed disabled:opacity-50`,children:y.isPending?`Setting up...`:`Enable Two-Factor Authentication`}),e&&(0,P.jsx)(`p`,{className:`mt-3 text-xs text-zinc-600`,children:`This will disable IP:9292 access. The panel will only be accessible via domain.`})]}),!v.enabled&&a&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)`}),(0,P.jsx)(`div`,{className:`mb-4 flex justify-center`,children:(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-950 p-4`,children:(0,P.jsx)(ls,{value:a.uri,size:200,bgColor:`transparent`,fgColor:`#ffffff`})})}),(0,P.jsx)(`p`,{className:`mb-2 text-sm text-zinc-400`,children:`Or enter this code manually:`}),(0,P.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg bg-zinc-950 px-4 py-3`,children:[(0,P.jsx)(`code`,{className:`flex-1 font-mono text-sm tracking-wider text-cyan-400`,children:a.manualKey?.replace(/(.{4})/g,`$1 `).trim()}),(0,P.jsx)(`button`,{type:`button`,onClick:w,className:`text-zinc-500 hover:text-zinc-300`,title:`Copy secret`,children:d?(0,P.jsx)(li,{size:16,className:`text-green-400`}):(0,P.jsx)(bi,{size:16})})]}),(0,P.jsxs)(`form`,{onSubmit:T,className:`space-y-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Enter the code from your authenticator to confirm`}),(0,P.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,value:s,onChange:e=>c(e.target.value.replace(/\D/g,``).slice(0,6)),placeholder:`000000`,maxLength:6,className:`w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 font-mono text-center text-lg tracking-[0.2em] text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),D&&(0,P.jsx)(`p`,{className:`text-sm text-red-400`,children:D}),(0,P.jsxs)(`div`,{className:`flex gap-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>{o(null),c(``),b.reset()},className:`flex-1 rounded-lg border border-zinc-700 px-4 py-2 text-sm text-zinc-400 hover:text-white`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`submit`,disabled:b.isPending||s.length!==6,className:`flex-1 rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:b.isPending?`Confirming...`:`Confirm & Enable`})]})]})]}),v.enabled&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Two-factor authentication is active. The panel requires both your mTLS certificate and a TOTP code.`}),(0,P.jsx)(`div`,{className:`mb-4 rounded-lg border border-zinc-700 bg-zinc-950 p-3`,children:(0,P.jsxs)(`p`,{className:`text-xs text-zinc-500`,children:[`Recovery: if you lose access to your authenticator, run`,` `,(0,P.jsx)(`code`,{className:`text-zinc-400`,children:`sudo lamaste-reset-admin`}),` on the server via the DigitalOcean console. This will reset admin auth to P12 and disable 2FA.`]})}),(0,P.jsxs)(`form`,{onSubmit:E,className:`space-y-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,children:`Enter a TOTP code to disable 2FA`}),(0,P.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,value:l,onChange:e=>u(e.target.value.replace(/\D/g,``).slice(0,6)),placeholder:`000000`,maxLength:6,className:`w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 font-mono text-center text-lg tracking-[0.2em] text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),O&&(0,P.jsx)(`p`,{className:`text-sm text-red-400`,children:O}),(0,P.jsx)(`button`,{type:`submit`,disabled:x.isPending||l.length!==6,className:`rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm font-semibold text-red-400 hover:bg-red-500/20 disabled:opacity-50`,children:x.isPending?`Disabling...`:`Disable Two-Factor Authentication`})]})]})]}),(0,P.jsxs)(`div`,{className:`mt-6 rounded-lg border border-zinc-800 bg-zinc-900 p-6`,children:[(0,P.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,P.jsx)(ra,{className:`h-5 w-5 text-cyan-400`}),(0,P.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:`Panel Update`})]}),(0,P.jsx)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:`Trigger an update of the panel server to a specific version. The server will restart automatically after the update completes.`}),(0,P.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,P.jsxs)(`div`,{className:`flex-1`,children:[(0,P.jsx)(`label`,{className:`mb-1 block text-sm text-zinc-400`,htmlFor:`update-version`,children:`Version`}),(0,P.jsx)(`input`,{id:`update-version`,type:`text`,value:p,onChange:e=>m(e.target.value.trim()),placeholder:`1.0.43`,className:`w-full rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:border-cyan-500 focus:outline-none font-mono`})]}),(0,P.jsx)(`button`,{type:`button`,disabled:!C||S.isPending,onClick:()=>_(!0),className:`rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:cursor-not-allowed disabled:opacity-50`,children:`Update Panel`})]}),!C&&p.length>0&&(0,P.jsx)(`p`,{className:`mt-2 text-xs text-red-400`,children:`Version must be in semver format (e.g. 1.0.43)`}),S.error&&(0,P.jsx)(`p`,{className:`mt-2 text-sm text-red-400`,children:S.error.message}),h&&(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,P.jsxs)(`div`,{className:`w-full max-w-sm rounded-xl border border-zinc-700 bg-zinc-900 p-6 shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,P.jsx)(ba,{className:`h-5 w-5 text-amber-400`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Confirm Update`})]}),(0,P.jsxs)(`p`,{className:`mb-4 text-sm text-zinc-400`,children:[`This will update the panel server to version`,` `,(0,P.jsx)(`strong`,{className:`text-white`,children:p}),` and restart the service. The panel will be unavailable for 1-2 minutes.`]}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>_(!1),className:`rounded-lg border border-zinc-700 px-4 py-2 text-sm text-zinc-400 hover:text-white`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,disabled:S.isPending,onClick:()=>S.mutate({version:p}),className:`rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:S.isPending?`Updating...`:`Update Now`})]})]})})]})]})}function Su({onClose:e}){let t=z(),n=F(),r=G(),[i,a]=(0,g.useState)({id:crypto.randomUUID(),label:``,provider:`digitalocean-spaces`,region:``,bucket:``,endpoint:``,accessKey:``,secretKey:``}),o=L({mutationFn:e=>t.registerStorageServer(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`storage-servers`]}),r(`Storage server registered`),e()},onError:e=>r(K(e),`error`)}),s=(e,t)=>a(n=>({...n,[e]:t})),c=i.label&&i.region&&i.bucket&&i.endpoint&&i.accessKey&&i.secretKey;return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,P.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl bg-zinc-900 border border-zinc-700 p-6 shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Register Storage Server`}),(0,P.jsx)(`button`,{type:`button`,onClick:e,className:`text-zinc-400 hover:text-white`,children:(0,P.jsx)(Na,{size:20})})]}),(0,P.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),o.mutate(i)},className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Label`}),(0,P.jsx)(`input`,{type:`text`,value:i.label,onChange:e=>s(`label`,e.target.value),placeholder:`my-storage`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Provider`}),(0,P.jsxs)(`select`,{value:i.provider,onChange:e=>s(`provider`,e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`,children:[(0,P.jsx)(`option`,{value:`digitalocean-spaces`,children:`DigitalOcean Spaces`}),(0,P.jsx)(`option`,{value:`s3`,children:`Amazon S3`})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Region`}),(0,P.jsx)(`input`,{type:`text`,value:i.region,onChange:e=>s(`region`,e.target.value),placeholder:`nyc3`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Bucket`}),(0,P.jsx)(`input`,{type:`text`,value:i.bucket,onChange:e=>s(`bucket`,e.target.value),placeholder:`my-bucket`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Endpoint URL`}),(0,P.jsx)(`input`,{type:`url`,value:i.endpoint,onChange:e=>s(`endpoint`,e.target.value),placeholder:`https://nyc3.digitaloceanspaces.com`,className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600 focus:border-cyan-500 focus:outline-none`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Access Key`}),(0,P.jsx)(`input`,{type:`password`,value:i.accessKey,onChange:e=>s(`accessKey`,e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:border-cyan-500 focus:outline-none`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Secret Key`}),(0,P.jsx)(`input`,{type:`password`,value:i.secretKey,onChange:e=>s(`secretKey`,e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 font-mono focus:border-cyan-500 focus:outline-none`})]}),(0,P.jsx)(`div`,{className:`rounded bg-amber-500/10 border border-amber-500/20 px-3 py-2`,children:(0,P.jsx)(`p`,{className:`text-xs text-amber-300`,children:`Credentials are encrypted at rest using AES-256-GCM. They never leave the server.`})}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-3 pt-2`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:e,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,P.jsxs)(`button`,{type:`submit`,disabled:!c||o.isPending,className:`rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:[o.isPending?(0,P.jsx)(H,{size:14,className:`animate-spin inline mr-1`}):null,`Register`]})]})]})]})})}function Cu({servers:e,onClose:t}){let n=z(),r=F(),i=G(),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(e[0]?.id||``),l=I({queryKey:[`plugins`],queryFn:()=>n.getPlugins()}),u=L({mutationFn:e=>n.createStorageBinding(e),onSuccess:()=>{r.invalidateQueries({queryKey:[`storage-bindings`]}),i(`Plugin bound to storage`),t()},onError:e=>i(K(e),`error`)}),d=l.data?.plugins||[];return(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,P.jsxs)(`div`,{className:`w-full max-w-md rounded-xl bg-zinc-900 border border-zinc-700 p-6 shadow-xl`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:`Bind Plugin to Storage`}),(0,P.jsx)(`button`,{type:`button`,onClick:t,className:`text-zinc-400 hover:text-white`,children:(0,P.jsx)(Na,{size:20})})]}),(0,P.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u.mutate({pluginName:a,storageServerId:s})},className:`space-y-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Plugin`}),(0,P.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`,children:[(0,P.jsx)(`option`,{value:``,children:`Select a plugin...`}),d.map(e=>(0,P.jsx)(`option`,{value:e.name,children:e.displayName||e.name},e.name))]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`block text-sm font-medium text-zinc-300 mb-1`,children:`Storage Server`}),(0,P.jsx)(`select`,{value:s,onChange:e=>c(e.target.value),className:`w-full rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-zinc-200 focus:border-cyan-500 focus:outline-none`,children:e.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.label,` (`,e.provider,` / `,e.region,`)`]},e.id))})]}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-3 pt-2`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:t,className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,P.jsxs)(`button`,{type:`submit`,disabled:!a||!s||u.isPending,className:`rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50`,children:[u.isPending?(0,P.jsx)(H,{size:14,className:`animate-spin inline mr-1`}):null,`Bind`]})]})]})]})})}function wu(){let e=z(),t=F(),n=G(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),d=I({queryKey:[`storage-servers`],queryFn:()=>e.getStorageServers(),refetchInterval:1e4}),f=I({queryKey:[`storage-bindings`],queryFn:()=>e.getStorageBindings(),refetchInterval:1e4}),p=L({mutationFn:t=>e.deleteStorageServer(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`storage-servers`]}),t.invalidateQueries({queryKey:[`storage-bindings`]}),n(`Storage server removed`),c(null)},onError:e=>{n(K(e),`error`),c(null)}}),m=L({mutationFn:t=>e.deleteStorageBinding(t),onSuccess:()=>{t.invalidateQueries({queryKey:[`storage-bindings`]}),n(`Plugin unbound from storage`),u(null)},onError:e=>{n(K(e),`error`),u(null)}}),h=d.data?.servers||[],_=f.data?.bindings||[];return(0,P.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,P.jsxs)(`div`,{className:`mb-6`,children:[(0,P.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Storage`}),(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`Manage S3-compatible storage servers and bind them to plugins.`})]}),(0,P.jsxs)(`div`,{className:`mb-8`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,P.jsx)(Fi,{size:18,className:`text-cyan-400`}),`Storage Servers`]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,P.jsx)(ea,{size:14}),`Register Server`]})]}),d.isLoading?(0,P.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2}).map((e,t)=>(0,P.jsx)(`div`,{className:`h-14 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):d.isError?(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,P.jsx)(mi,{size:16}),`Failed to load storage servers`]})}):h.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,P.jsx)(Fi,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,P.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:`No storage servers registered. Register one to enable plugin storage.`})]}):(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Label`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Provider`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden md:table-cell`,children:`Region`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden lg:table-cell`,children:`Bucket`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden lg:table-cell`,children:`Registered`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Actions`})]})}),(0,P.jsx)(`tbody`,{children:h.map(e=>(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,P.jsx)(`td`,{className:`px-4 py-3 text-zinc-200 font-semibold`,children:e.label}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-zinc-400`,children:e.provider}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-zinc-400 hidden md:table-cell`,children:e.region}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-zinc-400 font-mono text-xs hidden lg:table-cell`,children:e.bucket}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-zinc-500 hidden lg:table-cell`,children:e.registeredAt?gr(e.registeredAt):`—`}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,P.jsx)(`button`,{type:`button`,onClick:()=>c(e),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-red-600/20 hover:text-red-400`,title:`Remove server`,children:(0,P.jsx)(ya,{size:12})})})]},e.id))})]})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,P.jsx)(Ui,{size:18,className:`text-cyan-400`}),`Plugin Bindings`]}),h.length>0&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`flex items-center gap-2 rounded bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500`,children:[(0,P.jsx)(ea,{size:14}),`Bind Plugin`]})]}),f.isLoading?(0,P.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2}).map((e,t)=>(0,P.jsx)(`div`,{className:`h-14 animate-pulse rounded-lg bg-zinc-900 border border-zinc-800`},t))}):f.isError?(0,P.jsx)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-6`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,P.jsx)(mi,{size:16}),`Failed to load bindings`]})}):_.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-8 text-center`,children:[(0,P.jsx)(Ui,{size:32,className:`mx-auto text-zinc-600 mb-3`}),(0,P.jsxs)(`p`,{className:`text-zinc-400 text-sm`,children:[`No plugins bound to storage.`,` `,h.length===0?`Register a storage server first.`:`Use the button above to bind one.`]})]}):(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-zinc-800`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-900`,children:[(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Plugin`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400`,children:`Storage Server`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium uppercase text-zinc-400 hidden md:table-cell`,children:`Bound`}),(0,P.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium uppercase text-zinc-400`,children:`Actions`})]})}),(0,P.jsx)(`tbody`,{children:_.map(e=>{let t=h.find(t=>t.id===e.storageServerId);return(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800`,children:[(0,P.jsx)(`td`,{className:`px-4 py-3 text-zinc-200 font-semibold`,children:e.pluginName}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-zinc-400`,children:t?.label||e.storageServerId.slice(0,8)}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-zinc-500 hidden md:table-cell`,children:e.boundAt?gr(e.boundAt):`—`}),(0,P.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,P.jsx)(`button`,{type:`button`,onClick:()=>u(e.pluginName),className:`inline-flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1.5 text-xs text-zinc-300 hover:bg-red-600/20 hover:text-red-400`,title:`Unbind plugin`,children:(0,P.jsx)(Ca,{size:12})})})]},e.pluginName)})})]})})]}),r&&(0,P.jsx)(Su,{onClose:()=>i(!1)}),a&&(0,P.jsx)(Cu,{servers:h,onClose:()=>o(!1)}),s&&(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,P.jsxs)(`div`,{className:`w-full max-w-sm rounded-xl border border-zinc-700 bg-zinc-900 p-6 shadow-xl`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-3`,children:`Remove Storage Server`}),(0,P.jsxs)(`p`,{className:`text-sm text-zinc-400 mb-2`,children:[`Are you sure you want to remove`,` `,(0,P.jsx)(`strong`,{className:`text-white`,children:s.label}),`?`]}),(0,P.jsx)(`p`,{className:`text-xs text-amber-400 mb-4`,children:`All plugin bindings to this server will also be removed.`}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,disabled:p.isPending,onClick:()=>p.mutate(s.id),className:`rounded bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-500 disabled:opacity-50`,children:p.isPending?`Removing...`:`Remove`})]})]})}),l&&(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70`,children:(0,P.jsxs)(`div`,{className:`w-full max-w-sm rounded-xl border border-zinc-700 bg-zinc-900 p-6 shadow-xl`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-3`,children:`Unbind Plugin`}),(0,P.jsxs)(`p`,{className:`text-sm text-zinc-400 mb-4`,children:[`Remove storage binding for `,(0,P.jsx)(`strong`,{className:`text-white`,children:l}),`?`]}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>u(null),className:`rounded bg-zinc-700 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-600`,children:`Cancel`}),(0,P.jsx)(`button`,{type:`button`,disabled:m.isPending,onClick:()=>m.mutate(l),className:`rounded bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-500 disabled:opacity-50`,children:m.isPending?`Unbinding...`:`Unbind`})]})]})})]})}var Tu=50,Eu={info:`text-cyan-400`,warning:`text-yellow-400`,critical:`text-red-400`};function Du(){let e=z(),t=F(),n=G(),r=I({queryKey:[`notifications`],queryFn:()=>e.getNotifications({limit:50}),refetchInterval:3e4}),i=L({mutationFn:()=>e.markNotificationsRead({all:!0}),onSuccess:()=>t.invalidateQueries({queryKey:[`notifications`]}),onError:e=>n(K(e),`error`)}),a=r.data?.notifications??[],o=r.data?.unread??0;return(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5 mb-6`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,P.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-zinc-300`,children:[(0,P.jsx)(oi,{size:14,className:`text-cyan-400`}),` Notifications`,o>0&&(0,P.jsx)(`span`,{className:`rounded-full bg-cyan-500/20 px-2 text-xs text-cyan-400`,children:o})]}),o>0&&(0,P.jsxs)(`button`,{type:`button`,disabled:i.isPending,onClick:()=>i.mutate(),className:`flex items-center gap-1.5 rounded bg-zinc-700 px-2.5 py-1 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:[(0,P.jsx)(ci,{size:12}),` Mark all read`]})]}),a.length===0?(0,P.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Nothing to report.`}):(0,P.jsx)(`ul`,{className:`space-y-1.5 text-xs`,children:a.map(e=>(0,P.jsxs)(`li`,{className:`flex gap-3 ${e.read?`opacity-60`:``}`,children:[(0,P.jsx)(`span`,{className:`shrink-0 text-zinc-500`,children:new Date(e.at).toLocaleString()}),(0,P.jsx)(`span`,{className:`shrink-0 ${Eu[e.level]??`text-zinc-400`}`,children:e.level}),(0,P.jsx)(`span`,{className:`shrink-0 font-mono text-zinc-500`,children:e.source}),(0,P.jsx)(`span`,{className:`text-zinc-300 break-words`,children:e.message})]},e.id))})]})}function Ou(e){return Object.entries(e??{}).map(([e,t])=>`${e}=${typeof t==`object`&&t?JSON.stringify(t):t}`).join(` `)}function ku(){let e=z(),[t,n]=(0,g.useState)(``),[r,i]=(0,g.useState)(``),a={plugin:t.trim()||void 0,action:r.trim()||void 0},o=pr({queryKey:[`audit`,a],queryFn:({pageParam:t})=>e.getAuditLog({...a,limit:Tu,...t?{before:t}:{}}),initialPageParam:void 0,getNextPageParam:e=>e.entries.length===Tu?e.entries[e.entries.length-1].id:void 0,refetchInterval:3e4}),s=o.data?.pages.flatMap(e=>e.entries)??[];return(0,P.jsxs)(`div`,{className:`p-6 max-w-5xl mx-auto`,children:[(0,P.jsxs)(`div`,{className:`mb-6`,children:[(0,P.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`Audit`}),(0,P.jsx)(`p`,{className:`text-zinc-500 text-sm mt-1`,children:`What administrators decided and what plugins' hooks reported — metadata only, never a request or response body.`})]}),(0,P.jsx)(Du,{}),(0,P.jsxs)(`div`,{className:`rounded-lg bg-zinc-900 border border-zinc-800 p-5`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mb-4`,children:[(0,P.jsx)(sa,{size:14,className:`text-cyan-400`}),(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-300 mr-4`,children:`Audit log`}),(0,P.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:`plugin`,className:`w-36 rounded bg-zinc-800 border border-zinc-700 px-2 py-1 text-xs text-zinc-300 focus:outline-none focus:border-cyan-400`}),(0,P.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`action, or prefix ending in .`,className:`w-56 rounded bg-zinc-800 border border-zinc-700 px-2 py-1 text-xs text-zinc-300 focus:outline-none focus:border-cyan-400`})]}),o.isError?(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,P.jsx)(mi,{size:16}),` Failed to load the audit log`]}):s.length===0?(0,P.jsx)(`p`,{className:`text-xs text-zinc-500`,children:o.isLoading?`Loading…`:`No entries.`}):(0,P.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`text-left text-zinc-500`,children:[(0,P.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`When`}),(0,P.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`Action`}),(0,P.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`Actor`}),(0,P.jsx)(`th`,{className:`pb-2 pr-3 font-normal`,children:`Plugin`}),(0,P.jsx)(`th`,{className:`pb-2 font-normal`,children:`Details`})]})}),(0,P.jsx)(`tbody`,{children:s.map(e=>(0,P.jsxs)(`tr`,{className:`border-t border-zinc-800 align-top`,children:[(0,P.jsx)(`td`,{className:`py-1.5 pr-3 whitespace-nowrap text-zinc-500`,children:new Date(e.at).toLocaleString()}),(0,P.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-cyan-400`,children:e.action}),(0,P.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-zinc-300`,children:e.actor}),(0,P.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-zinc-300`,children:e.plugin??``}),(0,P.jsx)(`td`,{className:`py-1.5 font-mono text-zinc-500 break-all`,children:Ou(e.details)})]},e.id))})]}),o.hasNextPage&&(0,P.jsx)(`button`,{type:`button`,disabled:o.isFetchingNextPage,onClick:()=>o.fetchNextPage(),className:`mt-3 rounded bg-zinc-700 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-600 disabled:opacity-50`,children:`Load older`})]})]})}function Y(e,t){return t===void 0?R(e,{method:`POST`}):R(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}function Au(e,t){return R(e,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}function ju(e,t){return R(e,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}function X(e,t){let n={method:`DELETE`};return t&&(n.headers={"Content-Type":`application/json`},n.body=JSON.stringify(t)),R(e,n)}function Mu(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!=null&&r!==``&&t.set(n,String(r));let n=t.toString();return n?`?${n}`:``}function Nu({force:e=!1,purge:t=!1}={}){return Mu({force:e?`true`:void 0,purge:t?`true`:void 0})}function Pu(e,t){return`/api/plugins/${encodeURIComponent(e)}/${t}`}var Fu={getUsers:()=>R(`/api/users`),createUser:e=>Y(`/api/users`,e),updateUser:(e,t)=>Au(`/api/users/${encodeURIComponent(e)}`,t),disableUser:e=>Au(`/api/users/${encodeURIComponent(e)}`,{disabled:!0}),enableUser:e=>Au(`/api/users/${encodeURIComponent(e)}`,{disabled:!1}),deleteUser:(e,{erase:t=!1}={})=>X(`/api/users/${encodeURIComponent(e)}${Mu({erase:t?`true`:void 0})}`),resetTotp:e=>Y(`/api/users/${encodeURIComponent(e)}/reset-totp`),getUserDirectory:()=>R(`/api/identity/directory`),eraseDirectoryUser:e=>Y(`/api/identity/directory/${encodeURIComponent(e)}/erase`),getInvitations:()=>R(`/api/invitations`),createInvitation:e=>Y(`/api/invitations`,e),revokeInvitation:e=>X(`/api/invitations/${encodeURIComponent(e)}`),getSites:()=>R(`/api/sites`),createSite:e=>Y(`/api/sites`,e),deleteSite:e=>X(`/api/sites/${encodeURIComponent(e)}`),updateSite:(e,t)=>ju(`/api/sites/${encodeURIComponent(e)}`,t),getSiteFiles:(e,t)=>{let n=t&&t!==`.`?`?path=${encodeURIComponent(t)}`:``;return R(`/api/sites/${encodeURIComponent(e)}/files${n}`)},uploadSiteFiles:(e,t,n)=>{let r=new FormData;for(let e of n)r.append(`files`,e);let i=t&&t!==`.`?`?path=${encodeURIComponent(t)}`:``;return R(`/api/sites/${encodeURIComponent(e)}/files${i}`,{method:`POST`,body:r})},deleteSiteFile:(e,t)=>X(`/api/sites/${encodeURIComponent(e)}/files`,{path:t}),verifySiteDns:e=>Y(`/api/sites/${encodeURIComponent(e)}/verify-dns`),getCerts:()=>R(`/api/certs`),renewCert:e=>Y(`/api/certs/${encodeURIComponent(e)}/renew`),rotateMtls:()=>Y(`/api/certs/mtls/rotate`),downloadMtls:async()=>{let e=await fetch(`/api/certs/mtls/download`,{credentials:`same-origin`});if(!e.ok)throw Error(`Download failed`);let t=await e.blob(),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`client.p12`,r.click(),URL.revokeObjectURL(n)},getAuthMode:()=>R(`/api/certs/admin/auth-mode`),getAutoRenewStatus:()=>R(`/api/certs/auto-renew-status`),getAgentCerts:()=>R(`/api/certs/agent`),generateAgentCert:e=>Y(`/api/certs/agent`,e),revokeAgentCert:e=>X(`/api/certs/agent/${encodeURIComponent(e)}`),createEnrollmentToken:e=>Y(`/api/certs/agent/enroll`,e),revokeEnrollmentToken:e=>X(`/api/certs/agent/enroll/${encodeURIComponent(e)}`),updateAgentCapabilities:(e,t)=>ju(`/api/certs/agent/${encodeURIComponent(e)}/capabilities`,{capabilities:t}),updateAgentAllowedSites:(e,t)=>ju(`/api/certs/agent/${encodeURIComponent(e)}/allowed-sites`,{allowedSites:t}),downloadAgentCert:async e=>{let t=await fetch(`/api/certs/agent/${encodeURIComponent(e)}/download`,{credentials:`same-origin`});if(!t.ok)throw Error(`Download failed`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e}.p12`,i.click(),URL.revokeObjectURL(r)},getServices:()=>R(`/api/services`),serviceAction:(e,t)=>Y(`/api/services/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),getSystemStats:()=>R(`/api/system/stats`),triggerPanelUpdate:e=>Y(`/api/system/update`,e),startLogStream:(e,t)=>{let n=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/api/services/${encodeURIComponent(e)}/logs`,r=new WebSocket(n);return r.onmessage=e=>{try{t(JSON.parse(e.data))}catch{t({message:e.data,timestamp:new Date().toISOString()})}},r.onerror=()=>{},r.onclose=()=>{},()=>r.close()},getTicketScopes:()=>R(`/api/tickets/scopes`),createTicketScope:e=>Y(`/api/tickets/scopes`,e),deleteTicketScope:e=>X(`/api/tickets/scopes/${encodeURIComponent(e)}`),getTicketInstances:()=>R(`/api/tickets/instances`),deleteTicketInstance:e=>X(`/api/tickets/instances/${encodeURIComponent(e)}`),getTicketAssignments:()=>R(`/api/tickets/assignments`),createTicketAssignment:e=>Y(`/api/tickets/assignments`,e),deleteTicketAssignment:(e,t)=>X(`/api/tickets/assignments/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),getTickets:()=>R(`/api/tickets`),revokeTicket:e=>X(`/api/tickets/${encodeURIComponent(e)}`),getTicketSessions:()=>R(`/api/tickets/sessions`),killTicketSession:e=>X(`/api/tickets/sessions/${encodeURIComponent(e)}`),getPlugins:()=>R(`/api/plugins`),installPlugin:e=>Y(`/api/plugins/install`,{packageName:e}),enablePlugin:e=>Y(`/api/plugins/${encodeURIComponent(e)}/enable`),disablePlugin:e=>Y(`/api/plugins/${encodeURIComponent(e)}/disable`),uninstallPlugin:(e,t={})=>X(`/api/plugins/${encodeURIComponent(e)}${Nu(t)}`),getPluginHosting:e=>R(`/api/plugins/${encodeURIComponent(e)}/hosting`),getPluginHostingEligibility:e=>R(`/api/plugins/${encodeURIComponent(e)}/hosting/eligibility`),setPluginHosting:(e,t)=>Y(`/api/plugins/${encodeURIComponent(e)}/hosting`,{agentLabel:t}),clearPluginHosting:(e,t={})=>X(`/api/plugins/${encodeURIComponent(e)}/hosting${Nu(t)}`),rotatePluginHostingSecret:e=>Y(`/api/plugins/${encodeURIComponent(e)}/hosting/rotate-secret`),getPluginRetainedData:e=>R(`/api/plugins/${encodeURIComponent(e)}/retained-data`),purgePluginRetainedData:(e,t)=>X(`/api/plugins/${encodeURIComponent(e)}/retained-data${Mu({agentLabel:t})}`),forgetPluginRetainedData:(e,t)=>X(`/api/plugins/${encodeURIComponent(e)}/retained-data${Mu({agentLabel:t,forget:`true`})}`),getPluginSettings:e=>R(`/api/plugins/${encodeURIComponent(e)}/settings`),updatePluginSettings:(e,t)=>Au(`/api/plugins/${encodeURIComponent(e)}/settings`,t),getPluginOperations:e=>R(`/api/plugins/${encodeURIComponent(e)}/operations`),getPluginOperation:(e,t)=>R(`/api/plugins/${encodeURIComponent(e)}/operations/${encodeURIComponent(t)}`),getPluginHooks:e=>R(`/api/plugins/${encodeURIComponent(e)}/hooks`),approvePluginHooks:(e,t,n)=>Y(`/api/plugins/${encodeURIComponent(e)}/hooks/approve`,{digest:t,...n?{version:n}:{}}),setPluginHooksAutoApprove:(e,t)=>Au(`/api/plugins/${encodeURIComponent(e)}/hooks/auto-approve`,{enabled:t}),updatePlugin:(e,t)=>Y(`/api/plugins/${encodeURIComponent(e)}/update`,t?{version:t}:{}),discardPluginUpdate:e=>X(`/api/plugins/${encodeURIComponent(e)}/update`),getPluginIdentity:e=>R(Pu(e,`identity`)),getPluginAudience:e=>R(Pu(e,`audience`)),getPluginEntitlements:e=>R(Pu(e,`entitlements`)),setPluginEntitlement:(e,{principalType:t,principalId:n,roles:r})=>Au(Pu(e,`entitlements`),{principalType:t,principalId:n,roles:r}),removePluginEntitlement:(e,{principalType:t,principalId:n})=>X(`${Pu(e,`entitlements`)}${Mu({principalType:t,principalId:n})}`),syncPluginIdentity:(e,{reconcile:t=!1}={})=>Y(Pu(e,`identity/sync`),{reconcile:t}),fetchPluginBundle:async e=>{let t=await fetch(`/api/${encodeURIComponent(e)}/panel.js`);if(!t.ok)throw Error(`Failed to load plugin bundle for "${e}"`);return t.text()},getPushInstallConfig:()=>R(`/api/plugins/push-install/config`),updatePushInstallConfig:e=>ju(`/api/plugins/push-install/config`,e),getPushInstallPolicies:()=>R(`/api/plugins/push-install/policies`),createPushInstallPolicy:e=>Y(`/api/plugins/push-install/policies`,e),deletePushInstallPolicy:e=>X(`/api/plugins/push-install/policies/${encodeURIComponent(e)}`),updatePushInstallPolicy:(e,t)=>ju(`/api/plugins/push-install/policies/${encodeURIComponent(e)}`,t),enablePushInstall:(e,t)=>Y(`/api/plugins/push-install/enable/${encodeURIComponent(e)}`,t),disablePushInstall:e=>X(`/api/plugins/push-install/enable/${encodeURIComponent(e)}`),pushInstallCommand:(e,t)=>Y(`/api/plugins/push-install/${encodeURIComponent(e)}`,t),getPushInstallSessions:()=>R(`/api/plugins/push-install/sessions`),getAuditLog:(e={})=>R(`/api/audit${Mu(e)}`),getNotifications:(e={})=>R(`/api/notifications${Mu(e)}`),markNotificationsRead:e=>Y(`/api/notifications/read`,e),registerStorageServer:e=>Y(`/api/storage/servers`,e),getStorageServers:()=>R(`/api/storage/servers`),deleteStorageServer:e=>X(`/api/storage/servers/${encodeURIComponent(e)}`),createStorageBinding:e=>Y(`/api/storage/bindings`,e),getStorageBindings:()=>R(`/api/storage/bindings`),getStorageBinding:e=>R(`/api/storage/bindings/${encodeURIComponent(e)}`),deleteStorageBinding:e=>X(`/api/storage/bindings/${encodeURIComponent(e)}`),getIdentitySelf:()=>R(`/api/identity/self`),getIdentityUsers:()=>R(`/api/identity/users`),getIdentityUser:e=>R(`/api/identity/users/${encodeURIComponent(e)}`),getIdentityGroups:()=>R(`/api/identity/groups`),get2faStatus:()=>R(`/api/settings/2fa`),setup2fa:()=>Y(`/api/settings/2fa/setup`),confirm2fa:e=>Y(`/api/settings/2fa/confirm`,{code:e}),verify2fa:e=>Y(`/api/settings/2fa/verify`,{code:e}),disable2fa:e=>Y(`/api/settings/2fa/disable`,{code:e}),getAgents:()=>R(`/api/certs/agent`),getUserAccessGrants:()=>R(`/api/user-access/grants`),createUserAccessGrant:e=>Y(`/api/user-access/grants`,e),revokeUserAccessGrant:e=>X(`/api/user-access/grants/${encodeURIComponent(e)}`),getTunnels:()=>R(`/api/tunnels`),createTunnel:e=>Y(`/api/tunnels`,e),updateTunnel:(e,t)=>ju(`/api/tunnels/${encodeURIComponent(e)}`,t),deleteTunnel:e=>X(`/api/tunnels/${encodeURIComponent(e)}`),getTunnelAgentConfig:()=>R(`/api/tunnels/agent-config`),bindTunnelUserSurface:(e,t)=>Au(`/api/tunnels/${encodeURIComponent(e)}/user-surface`,{route:t}),unbindTunnelUserSurface:(e,t)=>X(`/api/tunnels/${encodeURIComponent(e)}/user-surface/${encodeURIComponent(t)}`),getGatekeeperGroups:()=>R(`/api/gatekeeper/groups`),createGatekeeperGroup:e=>Y(`/api/gatekeeper/groups`,e),updateGatekeeperGroup:(e,t)=>ju(`/api/gatekeeper/groups/${encodeURIComponent(e)}`,t),deleteGatekeeperGroup:e=>X(`/api/gatekeeper/groups/${encodeURIComponent(e)}`),addGatekeeperGroupMembers:(e,t)=>Y(`/api/gatekeeper/groups/${encodeURIComponent(e)}/members`,t),removeGatekeeperGroupMember:(e,t)=>X(`/api/gatekeeper/groups/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`),getGatekeeperGrants:e=>R(`/api/gatekeeper/grants${Mu(e??{})}`),createGatekeeperGrant:e=>Y(`/api/gatekeeper/grants`,e),revokeGatekeeperGrant:e=>X(`/api/gatekeeper/grants/${encodeURIComponent(e)}`),checkGatekeeperAccess:(e,t,n)=>R(`/api/gatekeeper/access/check${Mu({username:e,resourceType:t,resourceId:n})}`),bustGatekeeperCache:()=>Y(`/api/gatekeeper/cache/bust`),getGatekeeperSettings:()=>R(`/api/gatekeeper/settings`),updateGatekeeperSettings:e=>ju(`/api/gatekeeper/settings`,e),getAccessRequestLog:(e=100,t=0)=>R(`/api/gatekeeper/access-log${Mu({limit:e,offset:t})}`),clearAccessRequestLog:()=>X(`/api/gatekeeper/access-log`)};function Iu({to:e,icon:t,label:n,offline:r=null,onClick:i}){return(0,P.jsxs)(Pt,{to:e,end:e===`/`,onClick:i,title:r??void 0,className:({isActive:e})=>[`flex items-center gap-3 px-3 py-2 rounded-md text-sm font-medium transition-colors`,e?`text-cyan-400 bg-zinc-800/50`:`text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800`].join(` `),children:[(0,P.jsx)(t,{className:`h-5 w-5`}),n,r&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-red-500`,"aria-hidden":`true`}),(0,P.jsxs)(`span`,{className:`sr-only`,children:[`(offline: `,r,`)`]})]})]})}var Lu=`4.5.0`,Ru={activity:ti,"bar-chart-3":ai,"book-open":si,box:V,cpu:xi,database:Si,"file-text":Oi,folder:Mi,"git-branch":Ni,globe:Pi,"hard-drive":Fi,heart:Ii,layers:Vi,"layout-dashboard":Hi,list:Gi,map:qi,package:Zi,server:la,settings:da,shield:ma,"shield-check":pa,terminal:_a,ticket:va,truck:xa,users:Aa,wifi:Ma,zap:Pa};function zu(e){return e&&Object.hasOwn(Ru,e)&&Ru[e]||Zi}var Bu=[{type:`link`,to:`/`,icon:Hi,label:`Dashboard`},{type:`link`,to:`/tunnels`,icon:Pi,label:`Tunnels`},{type:`link`,to:`/sites`,icon:Oi,label:`Static Sites`},{type:`link`,to:`/users`,icon:Aa,label:`Users`},{type:`link`,to:`/certificates`,icon:pa,label:`Certificates`},{type:`link`,to:`/services`,icon:la,label:`Services`},{type:`link`,to:`/tickets`,icon:va,label:`Tickets`},{type:`link`,to:`/plugins`,icon:Zi,label:`Plugins`},{type:`link`,to:`/storage`,icon:Fi,label:`Storage`},{type:`link`,to:`/audit`,icon:sa,label:`Audit`},{type:`link`,to:`/settings`,icon:da,label:`Settings`},{type:`link`,to:`/docs`,icon:si,label:`Documentation`}];function Vu({onLinkClick:e}){let t=z(),n=I({queryKey:[`plugins`],queryFn:()=>t.getPlugins(),select:e=>(e.plugins||[]).filter(e=>e.status===`enabled`&&(e.panel?.label||e.panel?.pages?.length)),refetchInterval:3e4,staleTime:15e3}),r=n.data,i=e=>{let t=e.hosting===`agent`?vr(e.agentHosting):null;return t?br(t,n.dataUpdatedAt):null},a=(r||[]).flatMap(e=>{let t=i(e);return e.panel?.pages?.length?[{type:`section-header`,label:e.displayName||e.name,key:`section-${e.name}`},...e.panel.pages.map(n=>({type:`link`,to:`/plugins/${e.name}${n.path}`,icon:zu(n.icon),label:n.title,offline:t}))]:e.panel?.label?[{type:`link`,to:`/plugins/${e.name}`,icon:zu(e.panel?.icon),label:e.panel.label,offline:t}]:[]}),o=[...Bu,...a];return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`border-b border-zinc-800 px-4 py-5`,children:(0,P.jsx)(`span`,{className:`font-mono text-lg font-bold text-cyan-400`,children:`Lamaste`})}),(0,P.jsx)(`nav`,{className:`flex-1 space-y-1 px-2 py-4`,children:o.map(t=>t.type===`section-header`?(0,P.jsx)(`div`,{className:`px-3 pt-4 pb-1`,children:(0,P.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-600`,children:t.label})},t.key):(0,P.jsx)(Iu,{to:t.to,icon:t.icon,label:t.label,offline:t.offline??null,onClick:e},t.to))}),(0,P.jsx)(`div`,{className:`border-t border-zinc-800 px-4 py-3`,children:(0,P.jsxs)(`span`,{className:`font-mono text-xs text-zinc-600`,children:[`v`,Lu]})})]})}function Hu(){let[e,t]=(0,g.useState)(!1),n=()=>t(!1);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(!0),className:`fixed left-4 top-4 z-40 rounded-md bg-zinc-900 p-2 text-zinc-400 hover:text-zinc-100 lg:hidden`,"aria-label":`Open sidebar`,children:(0,P.jsx)(Ji,{className:`h-5 w-5`})}),e&&(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 lg:hidden`,children:[(0,P.jsx)(`div`,{className:`fixed inset-0 bg-black/50`,onClick:n}),(0,P.jsxs)(`div`,{className:`relative flex h-screen w-64 flex-col bg-zinc-900`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`absolute right-3 top-4 rounded-md p-1 text-zinc-400 hover:text-zinc-100`,"aria-label":`Close sidebar`,children:(0,P.jsx)(Na,{className:`h-5 w-5`})}),(0,P.jsx)(Vu,{onLinkClick:n})]})]}),(0,P.jsx)(`div`,{className:`sticky top-0 hidden h-screen w-64 flex-col border-r border-zinc-800 bg-zinc-900 lg:flex`,children:(0,P.jsx)(Vu,{})})]})}function Uu(){return(0,P.jsxs)(`div`,{className:`flex min-h-screen`,children:[(0,P.jsx)(Hu,{}),(0,P.jsx)(`main`,{className:`flex-1 overflow-y-auto bg-zinc-950 p-6 lg:p-8`,children:(0,P.jsx)(ht,{})})]})}function Wu(){return(0,P.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-zinc-950`,children:(0,P.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,P.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-zinc-700 border-t-cyan-400`}),(0,P.jsx)(`p`,{className:`mt-4 text-sm text-zinc-500`,children:`Connecting to panel server...`})]})})}function Gu({onRetry:e}){return(0,P.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-zinc-950`,children:(0,P.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,P.jsx)(mi,{className:`mb-4 h-12 w-12 text-red-400`}),(0,P.jsx)(`h1`,{className:`mb-2 font-mono text-xl font-bold text-zinc-100`,children:`Unable to connect`}),(0,P.jsx)(`p`,{className:`mb-6 max-w-md text-center text-zinc-400`,children:`Could not reach the Lamaste panel server. Make sure the server is running and try again.`}),(0,P.jsx)(`button`,{type:`button`,onClick:e,className:`rounded-md bg-cyan-400 px-4 py-2 font-medium text-zinc-900 transition-colors hover:bg-cyan-300`,children:`Retry`})]})})}var Ku=/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,qu=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Ju({domain:e,onComplete:t}){let[n,r]=(0,g.useState)(e??``),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)({}),c=F(),l=L({mutationFn:async e=>{let t=await fetch(`/api/onboarding/domain`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();throw Error(e.error||`Request failed`)}return t.json()},onSuccess:()=>{c.invalidateQueries({queryKey:[`onboarding`,`status`]}),t()}});function u(){let e={};return Ku.test(n)||(e.domain=`Enter a valid domain name (e.g. example.com)`),qu.test(i)||(e.email=`Enter a valid email address`),s(e),Object.keys(e).length===0}function d(e){e.preventDefault(),u()&&l.mutate({domain:n.trim(),email:i.trim()})}return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`mb-2 text-xl font-semibold text-white`,children:`Configure your domain`}),(0,P.jsx)(`p`,{className:`mb-6 text-sm text-zinc-400`,children:`Enter the domain you want to use for Lamaste. You will need to configure DNS records in the next step.`}),l.isError&&(0,P.jsx)(`div`,{className:`mb-4 rounded-md bg-red-500/10 border border-red-500/20 px-4 py-3 text-sm text-red-400`,children:l.error.message}),(0,P.jsxs)(`form`,{onSubmit:d,className:`space-y-5`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{htmlFor:`domain`,className:`mb-1.5 block text-sm font-medium text-zinc-300`,children:`Domain`}),(0,P.jsx)(`input`,{id:`domain`,type:`text`,placeholder:`example.com`,value:n,onChange:e=>{r(e.target.value),s(e=>({...e,domain:void 0}))},className:`w-full rounded-md border border-zinc-600 bg-zinc-900 px-3 py-2 font-mono text-sm text-white placeholder-zinc-500 focus:border-cyan-400 focus:outline-none focus:ring-1 focus:ring-cyan-400`}),o.domain&&(0,P.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:o.domain})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{htmlFor:`email`,className:`mb-1.5 block text-sm font-medium text-zinc-300`,children:`Email`}),(0,P.jsx)(`input`,{id:`email`,type:`email`,placeholder:`you@example.com`,value:i,onChange:e=>{a(e.target.value),s(e=>({...e,email:void 0}))},className:`w-full rounded-md border border-zinc-600 bg-zinc-900 px-3 py-2 font-mono text-sm text-white placeholder-zinc-500 focus:border-cyan-400 focus:outline-none focus:ring-1 focus:ring-cyan-400`}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:`Used for Let's Encrypt certificate registration`}),o.email&&(0,P.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:o.email})]}),(0,P.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,P.jsxs)(`button`,{type:`submit`,disabled:l.isPending,className:`flex items-center gap-2 rounded-md bg-cyan-500 px-6 py-2 font-medium text-white transition-colors hover:bg-cyan-600 disabled:opacity-50`,children:[l.isPending&&(0,P.jsx)(H,{size:16,className:`animate-spin`}),l.isPending?`Saving...`:`Save & Continue`]})})]})]})}function Yu({text:e}){let[t,n]=(0,g.useState)(!1);function r(){navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})}return(0,P.jsxs)(`button`,{type:`button`,onClick:r,className:`ml-2 inline-flex items-center text-zinc-500 transition-colors hover:text-zinc-300`,title:`Copy to clipboard`,children:[(0,P.jsx)(bi,{size:14}),t&&(0,P.jsx)(`span`,{className:`ml-1 text-xs text-green-400`,children:`Copied`})]})}function Xu({type:e,name:t,value:n}){return(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 last:border-b-0`,children:[(0,P.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-sm text-cyan-400`,children:e}),(0,P.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-sm text-zinc-300`,children:t}),(0,P.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-sm text-zinc-300`,children:(0,P.jsxs)(`span`,{className:`inline-flex items-center`,children:[n,(0,P.jsx)(Yu,{text:n})]})})]})}function Zu({name:e,ok:t,resolvedIps:n,expectedIp:r}){return(0,P.jsxs)(`div`,{className:`flex items-start gap-2`,children:[t?(0,P.jsx)(gi,{size:18,className:`mt-0.5 shrink-0 text-green-400`}):(0,P.jsx)(_i,{size:18,className:`mt-0.5 shrink-0 text-red-400`}),(0,P.jsxs)(`div`,{className:`text-sm`,children:[(0,P.jsx)(`span`,{className:t?`text-green-400`:`text-red-400`,children:e}),t?(0,P.jsxs)(`span`,{className:`text-zinc-400`,children:[` resolves to `,r]}):n.length>0?(0,P.jsxs)(`span`,{className:`text-zinc-400`,children:[` `,`resolves to `,n.join(`, `),` (expected `,r,`)`]}):(0,P.jsx)(`span`,{className:`text-zinc-400`,children:` does not resolve`})]})]})}function Qu({name:e,ok:t,expectedIp:n,missingText:r}){return(0,P.jsxs)(`div`,{className:`flex items-start gap-2`,children:[t?(0,P.jsx)(gi,{size:18,className:`mt-0.5 shrink-0 text-green-400`}):(0,P.jsx)(ba,{size:18,className:`mt-0.5 shrink-0 text-yellow-400`}),(0,P.jsxs)(`div`,{className:`text-sm`,children:[(0,P.jsx)(`span`,{className:t?`text-green-400`:`text-yellow-400`,children:e}),t?(0,P.jsxs)(`span`,{className:`text-zinc-400`,children:[` resolves to `,n]}):(0,P.jsxs)(`span`,{className:`text-zinc-400`,children:[` `,r]})]})]})}function $u({result:e}){return e?(0,P.jsxs)(`div`,{className:`mt-5 space-y-3 rounded-md border border-zinc-700 bg-zinc-900 p-4`,children:[e.records.map(t=>(0,P.jsx)(Zu,{name:t.name,ok:t.ok,resolvedIps:t.resolvedIps,expectedIp:e.expectedIp},t.name)),(0,P.jsx)(Qu,{name:`*.${e.domain}`,ok:e.wildcardOk,expectedIp:e.expectedIp,missingText:`not configured — you can add individual subdomain records later`}),(0,P.jsx)(Qu,{name:e.domain,ok:e.apexOk,expectedIp:e.expectedIp,missingText:`does not point here — only needed to serve a site on the domain itself`}),(0,P.jsx)(`p`,{className:`text-sm text-zinc-400`,children:e.message})]}):null}function ed({domain:e,ip:t,onComplete:n,onBack:r}){let[i,a]=(0,g.useState)(null),o=F(),s=L({mutationFn:async()=>{let e=await fetch(`/api/onboarding/verify-dns`,{method:`POST`});if(!e.ok){let t=await e.json();throw Error(t.error||`Verification failed`)}return e.json()},onSuccess:e=>{a(e),e.ok&&o.invalidateQueries({queryKey:[`onboarding`,`status`]})}});function c(){s.mutate()}function l(){n()}return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`mb-2 text-xl font-semibold text-white`,children:`Configure DNS records`}),(0,P.jsx)(`p`,{className:`mb-5 text-sm text-zinc-400`,children:`Add these DNS records at your domain registrar or DNS provider.`}),s.isError&&(0,P.jsx)(`div`,{className:`mb-4 rounded-md bg-red-500/10 border border-red-500/20 px-4 py-3 text-sm text-red-400`,children:s.error.message}),(0,P.jsx)(`div`,{className:`overflow-hidden rounded-md border border-zinc-700`,children:(0,P.jsxs)(`table`,{className:`w-full text-left`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-zinc-700 bg-zinc-800/50`,children:[(0,P.jsx)(`th`,{className:`px-3 py-2 text-xs font-medium uppercase tracking-wider text-zinc-500`,children:`Type`}),(0,P.jsx)(`th`,{className:`px-3 py-2 text-xs font-medium uppercase tracking-wider text-zinc-500`,children:`Name`}),(0,P.jsx)(`th`,{className:`px-3 py-2 text-xs font-medium uppercase tracking-wider text-zinc-500`,children:`Value`})]})}),(0,P.jsxs)(`tbody`,{className:`bg-zinc-900`,children:[(0,P.jsx)(Xu,{type:`A`,name:`*.${e}`,value:t}),(0,P.jsx)(Xu,{type:`A`,name:e,value:t})]})]})}),(0,P.jsx)(`p`,{className:`mt-3 text-xs italic text-zinc-500`,children:`DNS propagation can take up to 48 hours, but usually completes within a few minutes.`}),(0,P.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:[`The wildcard record (*.`,e,`) covers the panel, auth and tunnel subdomains Lamaste needs and every tunnel you create later. Without it, add an A record for each of panel.`,e,`, auth.`,e,` and tunnel.`,e,`.`]}),(0,P.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:[`The record for `,e,` itself is optional — it is only needed to serve a site on the domain, and can stay with another host until then.`]}),(0,P.jsx)($u,{result:i}),(0,P.jsxs)(`div`,{className:`mt-6 flex items-center justify-between`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:r,className:`text-sm text-zinc-400 transition-colors hover:text-zinc-200`,children:`Back`}),(0,P.jsxs)(`div`,{className:`flex gap-3`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:c,disabled:s.isPending,className:`flex items-center gap-2 rounded-md bg-cyan-500 px-6 py-2 font-medium text-white transition-colors hover:bg-cyan-600 disabled:opacity-50`,children:[s.isPending&&(0,P.jsx)(H,{size:16,className:`animate-spin`}),s.isPending?`Verifying...`:`Verify DNS`]}),i?.ok&&(0,P.jsx)(`button`,{type:`button`,onClick:l,className:`rounded-md bg-green-600 px-6 py-2 font-medium text-white transition-colors hover:bg-green-700`,children:`Continue`})]})]})]})}var td=1e4;function nd(){let[e,t]=(0,g.useState)([]),[n,r]=(0,g.useState)(!1),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)({current:0,total:0}),[f,p]=(0,g.useState)([]),m=(0,g.useRef)(null),h=(0,g.useRef)(0),_=(0,g.useRef)(null),v=(0,g.useRef)(!1),y=(0,g.useRef)(null);return(0,g.useEffect)(()=>{v.current=!1;function e(){if(v.current)return;let n=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/api/onboarding/provision/stream`,i=new WebSocket(n);m.current=i,i.onopen=()=>{h.current=0},i.onmessage=e=>{let n;try{n=JSON.parse(e.data)}catch{return}if(n.type===`state`){n.tasks&&t(n.tasks),n.error&&(a(!0),s(n.error)),n.result&&(l(n.result),r(!0));return}if(n.task===`complete`&&n.status===`done`){r(!0),n.result&&l(n.result);return}n.status===`error`&&(a(!0),s({task:n.task,message:n.error||n.message})),n.progress&&d(n.progress),n.log&&p(e=>[...e.slice(-500),n.log]),n.message&&p(e=>[...e.slice(-500),n.message]),t(e=>{let t=e.findIndex(e=>e.id===n.task);if(t!==-1){let r=[...e];return r[t]={...r[t],status:n.status,message:n.message,log:n.log},r}return[...e,{id:n.task,title:n.title||n.task,status:n.status,message:n.message,log:n.log}]})},i.onclose=()=>{if(v.current)return;let t=h.current,n=Math.min(1e3*2**t,td);h.current=t+1,_.current=setTimeout(()=>{v.current||e()},n)},i.onerror=()=>{}}return y.current=e,e(),()=>{v.current=!0,_.current&&clearTimeout(_.current),m.current&&m.current.close()}},[]),{tasks:e,isComplete:n,isError:i,error:o,result:c,progress:u,logs:f,retry:(0,g.useCallback)(async()=>{a(!1),s(null),r(!1),l(null),t([]),p([]),d({current:0,total:0});let e=await fetch(`/api/onboarding/provision`,{method:`POST`});if(!e.ok){let t=await e.json();throw Error(t.error||`Failed to start provisioning`)}},[])}}function rd({status:e}){switch(e){case`done`:return(0,P.jsx)(gi,{size:18,className:`shrink-0 text-green-400`});case`error`:return(0,P.jsx)(_i,{size:18,className:`shrink-0 text-red-400`});case`running`:return(0,P.jsx)(H,{size:18,className:`shrink-0 animate-spin text-cyan-400`});default:return(0,P.jsx)(vi,{size:18,className:`shrink-0 text-zinc-600`})}}function id({task:e,isLast:t}){let n=e.status===`pending`?`text-zinc-500`:`text-white`;return(0,P.jsxs)(`div`,{className:`flex gap-3`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,P.jsx)(rd,{status:e.status}),!t&&(0,P.jsx)(`div`,{className:`mt-1 w-px flex-1 bg-zinc-700`})]}),(0,P.jsxs)(`div`,{className:`pb-4`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium ${n}`,children:e.title}),e.message&&e.status!==`pending`&&(0,P.jsx)(`p`,{className:`mt-0.5 text-xs text-zinc-400`,children:e.message})]})]})}function ad({onComplete:e}){let{tasks:t,isComplete:n,isError:r,error:i,result:a,progress:o,logs:s,retry:c}=nd(),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(!1),p=(0,g.useRef)(null);(0,g.useEffect)(()=>{l||(u(!0),fetch(`/api/onboarding/provision`,{method:`POST`}).catch(()=>{}))},[l]),(0,g.useEffect)(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},[s]),(0,g.useEffect)(()=>{if(n&&e){let t=setTimeout(()=>{e(a)},1e3);return()=>clearTimeout(t)}},[n,e,a]);async function m(){f(!0);try{await c()}catch{}finally{f(!1)}}return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`mb-2 text-xl font-semibold text-white`,children:`Setting up your Lamaste`}),(0,P.jsx)(`div`,{className:`mb-5 rounded-md border border-amber-700 bg-amber-900/30 px-4 py-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(ba,{size:16,className:`shrink-0 text-amber-300`}),(0,P.jsx)(`p`,{className:`text-sm text-amber-300`,children:`Do not close this page while provisioning is in progress`})]})}),(0,P.jsx)(`div`,{className:`mb-4`,children:t.map((e,n)=>(0,P.jsx)(id,{task:e,isLast:n===t.length-1},e.id))}),(0,P.jsx)(`div`,{ref:p,className:`mb-3 max-h-48 overflow-y-auto rounded border border-zinc-800 bg-zinc-950 p-3 font-mono text-sm text-zinc-400`,children:s.length===0?(0,P.jsx)(`p`,{className:`italic text-zinc-600`,children:`Waiting for provisioning to start...`}):s.map((e,t)=>(0,P.jsx)(`p`,{className:`leading-relaxed`,children:e},t))}),o.total>0&&(0,P.jsxs)(`p`,{className:`mb-4 text-sm text-zinc-500`,children:[`Step `,o.current,` of `,o.total]}),r&&i&&(0,P.jsxs)(`div`,{className:`mb-4 rounded-md border border-red-700 bg-red-900/30 px-4 py-3`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium text-red-300`,children:`Provisioning failed`}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:i.message}),(0,P.jsxs)(`button`,{type:`button`,onClick:m,disabled:d,className:`mt-3 flex items-center gap-2 rounded-md bg-cyan-500 px-6 py-2 font-medium text-white transition-colors hover:bg-cyan-600 disabled:opacity-50`,children:[d&&(0,P.jsx)(H,{size:16,className:`animate-spin`}),d?`Retrying...`:`Retry`]})]}),n&&(0,P.jsx)(`div`,{className:`text-center`,children:(0,P.jsx)(`p`,{className:`text-sm text-green-400`,children:`Provisioning complete. Continuing...`})})]})}function od({text:e}){let[t,n]=(0,g.useState)(!1);function r(){navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})}return(0,P.jsxs)(`button`,{type:`button`,onClick:r,className:`ml-2 inline-flex items-center text-zinc-500 transition-colors hover:text-zinc-300`,title:`Copy to clipboard`,children:[(0,P.jsx)(bi,{size:14}),t&&(0,P.jsx)(`span`,{className:`ml-1 text-xs text-green-400`,children:`Copied`})]})}function sd(e){try{let t=new URL(e);if(t.protocol===`https:`)return t.href}catch{}return``}function cd({result:e,ip:t}){let[n,r]=(0,g.useState)(!1),i=e?.adminUsername||`admin`,a=e?.adminPassword||``,o=sd(e?.panelUrl||``),s=sd(e?.authUrl||``),c=`https://${t}:9292`;return(0,P.jsxs)(`div`,{className:`animate-fade-in`,children:[(0,P.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,P.jsx)(pa,{size:48,className:`mx-auto mb-3 text-green-400`}),(0,P.jsx)(`h2`,{className:`text-2xl font-bold text-white`,children:`Lamaste is ready!`}),(0,P.jsx)(`p`,{className:`mt-1 text-sm text-zinc-400`,children:`Your stack is fully configured and operational.`})]}),(0,P.jsxs)(`div`,{className:`mb-5 rounded-lg border border-zinc-700 bg-zinc-800 p-6`,children:[(0,P.jsx)(`h3`,{className:`mb-1 font-semibold text-white`,children:`Admin Credentials`}),(0,P.jsx)(`p`,{className:`mb-4 text-sm text-amber-400`,children:`Save these credentials — they won't be shown again.`}),(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Username`}),(0,P.jsxs)(`span`,{className:`inline-flex items-center font-mono text-sm text-white`,children:[i,(0,P.jsx)(od,{text:i})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Password`}),(0,P.jsxs)(`span`,{className:`inline-flex items-center font-mono text-sm text-white`,children:[n?a:`•`.repeat(16),(0,P.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`ml-2 text-zinc-500 transition-colors hover:text-zinc-300`,title:n?`Hide password`:`Show password`,children:n?(0,P.jsx)(Ei,{size:14}):(0,P.jsx)(Di,{size:14})}),(0,P.jsx)(od,{text:a})]})]})]})]}),(0,P.jsxs)(`div`,{className:`mb-5 space-y-2`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300`,children:`Access URLs`}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-zinc-700 bg-zinc-900 px-3 py-2`,children:[(0,P.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Panel`}),(0,P.jsxs)(`a`,{href:o,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-sm text-cyan-400 hover:underline`,children:[o,(0,P.jsx)(Ti,{size:12})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-zinc-700 bg-zinc-900 px-3 py-2`,children:[(0,P.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`Auth Portal`}),(0,P.jsxs)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-sm text-cyan-400 hover:underline`,children:[s,(0,P.jsx)(Ti,{size:12})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-zinc-700 bg-zinc-900 px-3 py-2`,children:[(0,P.jsx)(`span`,{className:`text-sm text-zinc-400`,children:`IP Access`}),(0,P.jsxs)(`span`,{className:`text-sm text-zinc-400`,children:[c,` `,(0,P.jsx)(`span`,{className:`text-xs text-zinc-500`,children:`(requires client certificate)`})]})]})]}),(0,P.jsxs)(`p`,{className:`mb-6 text-xs text-zinc-400`,children:[`On your first login to `,s?new URL(s).hostname:`the auth portal`,`, you will be prompted to set up two-factor authentication (TOTP). Use an authenticator app like Google Authenticator or Authy.`]}),(0,P.jsx)(`div`,{className:`flex justify-center`,children:(0,P.jsx)(`a`,{href:`/`,className:`rounded-md bg-cyan-500 px-8 py-2.5 font-medium text-white transition-colors hover:bg-cyan-600`,children:`Go to Dashboard`})})]})}var ld=4;function ud(e){switch(e){case`FRESH`:return 1;case`DOMAIN_SET`:return 2;case`DNS_READY`:case`PROVISIONING`:return 3;case`COMPLETED`:return 4;default:return 1}}function dd({current:e}){return(0,P.jsxs)(`div`,{className:`mb-6 flex items-center gap-3`,children:[(0,P.jsxs)(`span`,{className:`text-sm text-zinc-400`,children:[`Step `,e,` of `,ld]}),(0,P.jsx)(`div`,{className:`flex gap-1.5`,children:Array.from({length:ld},(t,n)=>{let r=n+1,i=`h-2 w-2 rounded-full`;return r<e?i+=` bg-cyan-400`:r===e?i+=` border-2 border-cyan-400 bg-transparent`:i+=` bg-zinc-600`,(0,P.jsx)(`div`,{className:i},r)})})]})}function fd(){let{status:e,domain:t,ip:n,isLoading:r,isError:i,refetch:a}=Jr(),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=ud(e),d=o!==null&&o<u?o:u;if(r)return(0,P.jsx)(Wu,{});if(i)return(0,P.jsx)(Gu,{onRetry:a});function f(){a(),s(null)}function p(){a(),s(null)}function m(){s(1)}function h(e){l(e),s(4),a()}let _;return d===1?_=(0,P.jsx)(Ju,{domain:t,onComplete:f}):d===2?_=(0,P.jsx)(ed,{domain:t,ip:n,onComplete:p,onBack:m}):d===3?_=(0,P.jsx)(ad,{onComplete:h}):d===4&&(_=(0,P.jsx)(cd,{result:c,ip:n})),(0,P.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-zinc-950`,children:(0,P.jsxs)(`div`,{className:`mx-4 w-full max-w-xl rounded-lg border border-zinc-800 bg-zinc-900 p-8`,children:[(0,P.jsx)(`h1`,{className:`mb-2 font-mono text-2xl font-bold text-cyan-400`,children:`Lamaste`}),(0,P.jsx)(dd,{current:d}),_]})})}function pd(){let{pluginName:e,"*":t}=Ye();return(0,P.jsx)(mo,{pluginName:e,subPath:t||``,basePath:`/plugins/${e}`,panelUrl:window.location.origin})}function md(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var hd=md();function gd(e){hd=e}var _d={exec:()=>null};function Z(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(yd.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var vd=(()=>{try{return!0}catch{return!1}})(),yd={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},bd=/^(?:[ \t]*(?:\n|$))+/,xd=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Sd=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Cd=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,wd=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Td=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ed=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Dd=Z(Ed).replace(/bull/g,Td).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Od=Z(Ed).replace(/bull/g,Td).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),kd=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ad=/^[^\n]+/,jd=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Md=Z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,jd).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Nd=Z(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Td).getRegex(),Pd=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Fd=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Id=Z(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Fd).replace(`tag`,Pd).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ld=Z(kd).replace(`hr`,Cd).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Pd).getRegex(),Rd={blockquote:Z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Ld).getRegex(),code:xd,def:Md,fences:Sd,heading:wd,hr:Cd,html:Id,lheading:Dd,list:Nd,newline:bd,paragraph:Ld,table:_d,text:Ad},zd=Z(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Cd).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Pd).getRegex(),Bd={...Rd,lheading:Od,table:zd,paragraph:Z(kd).replace(`hr`,Cd).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,zd).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Pd).getRegex()},Vd={...Rd,html:Z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Fd).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:_d,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Z(kd).replace(`hr`,Cd).replace(`heading`,` *#{1,6} *[^
16
- ]`).replace(`lheading`,Dd).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Hd=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ud=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Wd=/^( {2,}|\\)\n(?!\s*$)/,Gd=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Kd=/[\p{P}\p{S}]/u,qd=/[\s\p{P}\p{S}]/u,Jd=/[^\s\p{P}\p{S}]/u,Yd=Z(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,qd).getRegex(),Xd=/(?!~)[\p{P}\p{S}]/u,Zd=/(?!~)[\s\p{P}\p{S}]/u,Qd=/(?:[^\s\p{P}\p{S}]|~)/u,$d=Z(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,vd?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),ef=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,tf=Z(ef,`u`).replace(/punct/g,Kd).getRegex(),nf=Z(ef,`u`).replace(/punct/g,Xd).getRegex(),rf=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,af=Z(rf,`gu`).replace(/notPunctSpace/g,Jd).replace(/punctSpace/g,qd).replace(/punct/g,Kd).getRegex(),of=Z(rf,`gu`).replace(/notPunctSpace/g,Qd).replace(/punctSpace/g,Zd).replace(/punct/g,Xd).getRegex(),sf=Z(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Jd).replace(/punctSpace/g,qd).replace(/punct/g,Kd).getRegex(),cf=Z(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Kd).getRegex(),lf=Z(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Jd).replace(/punctSpace/g,qd).replace(/punct/g,Kd).getRegex(),uf=Z(/\\(punct)/,`gu`).replace(/punct/g,Kd).getRegex(),df=Z(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ff=Z(Fd).replace(`(?:-->|$)`,`-->`).getRegex(),pf=Z(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,ff).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),mf=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,hf=Z(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,mf).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),gf=Z(/^!?\[(label)\]\[(ref)\]/).replace(`label`,mf).replace(`ref`,jd).getRegex(),_f=Z(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,jd).getRegex(),vf=Z(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,gf).replace(`nolink`,_f).getRegex(),yf=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,bf={_backpedal:_d,anyPunctuation:uf,autolink:df,blockSkip:$d,br:Wd,code:Ud,del:_d,delLDelim:_d,delRDelim:_d,emStrongLDelim:tf,emStrongRDelimAst:af,emStrongRDelimUnd:sf,escape:Hd,link:hf,nolink:_f,punctuation:Yd,reflink:gf,reflinkSearch:vf,tag:pf,text:Gd,url:_d},xf={...bf,link:Z(/^!?\[(label)\]\((.*?)\)/).replace(`label`,mf).getRegex(),reflink:Z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,mf).getRegex()},Sf={...bf,emStrongRDelimAst:of,emStrongLDelim:nf,delLDelim:cf,delRDelim:lf,url:Z(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,yf).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Z(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,yf).getRegex()},Cf={...Sf,br:Z(Wd).replace(`{2,}`,`*`).getRegex(),text:Z(Sf.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},wf={normal:Rd,gfm:Bd,pedantic:Vd},Tf={normal:bf,gfm:Sf,breaks:Cf,pedantic:xf},Ef={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},Df=e=>Ef[e];function Of(e,t){if(t){if(yd.escapeTest.test(e))return e.replace(yd.escapeReplace,Df)}else if(yd.escapeTestNoEncode.test(e))return e.replace(yd.escapeReplaceNoEncode,Df);return e}function kf(e){try{e=encodeURI(e).replace(yd.percentDecode,`%`)}catch{return null}return e}function Af(e,t){let n=e.replace(yd.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(yd.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(yd.slashPipe,`|`);return n}function jf(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Mf(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Nf(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Pf(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function Ff(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
17
- `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
18
- `)}var If=class{options;rules;lexer;constructor(e){this.options=e||hd}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:jf(e,`
19
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Ff(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=jf(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:jf(t[0],`
20
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=jf(t[0],`
21
- `).split(`
22
- `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
23
- `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
24
- $1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
25
- ${s}`:s,r=r?`${r}
26
- ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
27
- `+e.join(`
28
- `),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
29
- `+e.join(`
30
- `),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
31
- `);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=Nf(t[2].split(`
32
- `,1)[0],t[1].length),l=e.split(`
33
- `,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
34
- `,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
35
- `,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
36
- `+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
37
- `+l}u=!l.trim(),r+=p+`
38
- `,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,``),e.tokens[0]?.type===`text`||e.tokens[0]?.type===`paragraph`){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,``),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:`checkbox`,raw:t[0]+` `,checked:t[0]!==`[ ]`};e.checked=n.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:`paragraph`,raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Af(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
39
- `):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Af(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
40
- `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=jf(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Mf(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Pf(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Pf(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},Lf=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||hd,this.options.tokenizer=this.options.tokenizer||new If,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:yd,block:wf.normal,inline:Tf.normal};this.options.pedantic?(t.block=wf.pedantic,t.inline=Tf.pedantic):this.options.gfm&&(t.block=wf.gfm,this.options.breaks?t.inline=Tf.breaks:t.inline=Tf.gfm),this.tokenizer.rules=t}static get rules(){return{block:wf,inline:Tf}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(yd.carriageReturn,`
41
- `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(yd.tabCharGlobal,` `).replace(yd.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
42
- `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
43
- `)?``:`
44
- `)+r.raw,n.text+=`
45
- `+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
46
- `)?``:`
47
- `)+r.raw,n.text+=`
48
- `+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=t.at(-1);n&&a?.type===`paragraph`?(a.raw+=(a.raw.endsWith(`
49
- `)?``:`
50
- `)+r.raw,a.text+=`
51
- `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
52
- `)?``:`
53
- `)+r.raw,n.text+=`
54
- `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},Rf=class{options;parser;constructor(e){this.options=e||hd}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(yd.notSpaceStart)?.[0],i=e.replace(yd.endingNewline,``)+`
55
- `;return r?`<pre><code class="language-`+Of(r)+`">`+(n?i:Of(i,!0))+`</code></pre>
56
- `:`<pre><code>`+(n?i:Of(i,!0))+`</code></pre>
57
- `}blockquote({tokens:e}){return`<blockquote>
58
- ${this.parser.parse(e)}</blockquote>
59
- `}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
60
- `}hr(e){return`<hr>
61
- `}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
62
- `+r+`</`+i+`>
63
- `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
64
- `}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
65
- `}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
66
- <thead>
67
- `+t+`</thead>
68
- `+r+`</table>
69
- `}tablerow({text:e}){return`<tr>
70
- ${e}</tr>
71
- `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
72
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Of(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=kf(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+Of(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=kf(e);if(i===null)return Of(n);e=i;let a=`<img src="${e}" alt="${Of(n)}"`;return t&&(a+=` title="${Of(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Of(e.text)}},zf=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Bf=class e{options;renderer;textRenderer;constructor(e){this.options=e||hd,this.options.renderer=this.options.renderer||new Rf,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new zf}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Vf=class{options;block;constructor(e){this.options=e||hd}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Lf.lex:Lf.lexInline}provideParser(e=this.block){return e?Bf.parse:Bf.parseInline}},Hf=new class{defaults=md();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Bf;Renderer=Rf;TextRenderer=zf;Lexer=Lf;Tokenizer=If;Hooks=Vf;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Rf(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new If(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Vf;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];Vf.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&Vf.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Lf.lex(e,t??this.defaults)}parser(e,t){return Bf.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Lf.lex:Lf.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Bf.parse:Bf.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Lf.lex:Lf.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Bf.parse:Bf.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
73
- Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Of(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Q(e,t){return Hf.parse(e,t)}Q.options=Q.setOptions=function(e){return Hf.setOptions(e),Q.defaults=Hf.defaults,gd(Q.defaults),Q},Q.getDefaults=md,Q.defaults=hd,Q.use=function(...e){return Hf.use(...e),Q.defaults=Hf.defaults,gd(Q.defaults),Q},Q.walkTokens=function(e,t){return Hf.walkTokens(e,t)},Q.parseInline=Hf.parseInline,Q.Parser=Bf,Q.parser=Bf.parse,Q.Renderer=Rf,Q.TextRenderer=zf,Q.Lexer=Lf,Q.lexer=Lf.lex,Q.Tokenizer=If,Q.Hooks=Vf,Q.parse=Q,Q.options,Q.setOptions,Q.use,Q.walkTokens,Q.parseInline,Bf.parse,Lf.lex;var{entries:Uf,setPrototypeOf:Wf,isFrozen:Gf,getPrototypeOf:Kf,getOwnPropertyDescriptor:qf}=Object,{freeze:Jf,seal:Yf,create:Xf}=Object,{apply:Zf,construct:Qf}=typeof Reflect<`u`&&Reflect;Jf||=function(e){return e},Yf||=function(e){return e},Zf||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},Qf||=function(e){return new e(...[...arguments].slice(1))};var $f=yp(Array.prototype.forEach),ep=yp(Array.prototype.lastIndexOf),tp=yp(Array.prototype.pop),np=yp(Array.prototype.push),rp=yp(Array.prototype.splice),ip=Array.isArray,ap=yp(String.prototype.toLowerCase),op=yp(String.prototype.toString),sp=yp(String.prototype.match),cp=yp(String.prototype.replace),lp=yp(String.prototype.indexOf),up=yp(String.prototype.trim),dp=yp(Number.prototype.toString),fp=yp(Boolean.prototype.toString),pp=typeof BigInt>`u`?null:yp(BigInt.prototype.toString),mp=typeof Symbol>`u`?null:yp(Symbol.prototype.toString),hp=yp(Object.prototype.hasOwnProperty),gp=yp(Object.prototype.toString),_p=yp(RegExp.prototype.test),vp=bp(TypeError);function yp(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return Zf(e,t,n)}}function bp(e){return function(){return Qf(e,[...arguments])}}function $(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ap;if(Wf&&Wf(e,null),!ip(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(Gf(t)||(t[r]=e),i=e)}e[i]=!0}return e}function xp(e){for(let t=0;t<e.length;t++)hp(e,t)||(e[t]=null);return e}function Sp(e){let t=Xf(null);for(let[n,r]of Uf(e))hp(e,n)&&(ip(r)?t[n]=xp(r):r&&typeof r==`object`&&r.constructor===Object?t[n]=Sp(r):t[n]=r);return t}function Cp(e){switch(typeof e){case`string`:return e;case`number`:return dp(e);case`boolean`:return fp(e);case`bigint`:return pp?pp(e):`0`;case`symbol`:return mp?mp(e):`Symbol()`;case`undefined`:return gp(e);case`function`:case`object`:{if(e===null)return gp(e);let t=e,n=wp(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:gp(e)}return gp(e)}default:return gp(e)}}function wp(e,t){for(;e!==null;){let n=qf(e,t);if(n){if(n.get)return yp(n.get);if(typeof n.value==`function`)return yp(n.value)}e=Kf(e)}function n(){return null}return n}function Tp(e){try{return _p(e,``),!0}catch{return!1}}var Ep=Jf(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Dp=Jf(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Op=Jf([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),kp=Jf([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Ap=Jf(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),jp=Jf([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Mp=Jf([`#text`]),Np=Jf(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Pp=Jf(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Fp=Jf(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Ip=Jf([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Lp=Yf(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Rp=Yf(/<%[\w\W]*|[\w\W]*%>/gm),zp=Yf(/\$\{[\w\W]*/gm),Bp=Yf(/^data-[\-\w.\u00B7-\uFFFF]+$/),Vp=Yf(/^aria-[\-\w]+$/),Hp=Yf(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Up=Yf(/^(?:\w+script|data):/i),Wp=Yf(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Gp=Yf(/^html$/i),Kp=Yf(/^[a-z][.\w]*(-[.\w]+)+$/i),qp=Object.freeze({__proto__:null,ARIA_ATTR:Vp,ATTR_WHITESPACE:Wp,CUSTOM_ELEMENT:Kp,DATA_ATTR:Bp,DOCTYPE_NAME:Gp,ERB_EXPR:Rp,IS_ALLOWED_URI:Hp,IS_SCRIPT_OR_DATA:Up,MUSTACHE_EXPR:Lp,TMPLIT_EXPR:zp}),Jp={element:1,text:3,progressingInstruction:7,comment:8,document:9},Yp=function(){return typeof window>`u`?null:window},Xp=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Zp=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Qp(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Yp(),t=e=>Qp(e);if(t.version=`3.4.2`,t.removed=[],!e||!e.document||e.document.nodeType!==Jp.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e,r=n,i=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:s,Element:c,NodeFilter:l,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:f,trustedTypes:p}=e,m=c.prototype,h=wp(m,`cloneNode`),g=wp(m,`remove`),_=wp(m,`nextSibling`),v=wp(m,`childNodes`),y=wp(m,`parentNode`);if(typeof o==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let b,x=``,{implementation:S,createNodeIterator:C,createDocumentFragment:w,getElementsByTagName:T}=n,{importNode:E}=r,D=Zp();t.isSupported=typeof Uf==`function`&&typeof y==`function`&&S&&S.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:O,ERB_EXPR:ee,TMPLIT_EXPR:te,DATA_ATTR:ne,ARIA_ATTR:re,IS_SCRIPT_OR_DATA:ie,ATTR_WHITESPACE:ae,CUSTOM_ELEMENT:oe}=qp,{IS_ALLOWED_URI:se}=qp,ce=null,le=$({},[...Ep,...Dp,...Op,...Ap,...Mp]),k=null,ue=$({},[...Np,...Pp,...Fp,...Ip]),A=Object.seal(Xf(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),de=null,fe=null,pe=Object.seal(Xf(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),me=!0,he=!0,ge=!1,_e=!0,ve=!1,ye=!0,be=!1,xe=!1,Se=!1,Ce=!1,we=!1,Te=!1,Ee=!0,De=!1,Oe=`user-content-`,ke=!0,Ae=!1,je={},Me=null,Ne=$({},[`annotation-xml`,`audio`,`colgroup`,`desc`,`foreignobject`,`head`,`iframe`,`math`,`mi`,`mn`,`mo`,`ms`,`mtext`,`noembed`,`noframes`,`noscript`,`plaintext`,`script`,`style`,`svg`,`template`,`thead`,`title`,`video`,`xmp`]),Pe=null,Fe=$({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ie=null,Le=$({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Re=`http://www.w3.org/1998/Math/MathML`,ze=`http://www.w3.org/2000/svg`,Be=`http://www.w3.org/1999/xhtml`,Ve=Be,He=!1,Ue=null,We=$({},[Re,ze,Be],op),Ge=$({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Ke=$({},[`annotation-xml`]),qe=$({},[`title`,`style`,`font`,`a`,`script`]),Je=null,Ye=[`application/xhtml+xml`,`text/html`],j=null,Xe=null,Ze=n.createElement(`form`),Qe=function(e){return e instanceof RegExp||e instanceof Function},$e=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Xe&&Xe===e)return;(!e||typeof e!=`object`)&&(e={}),e=Sp(e),Je=Ye.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,j=Je===`application/xhtml+xml`?op:ap,ce=hp(e,`ALLOWED_TAGS`)&&ip(e.ALLOWED_TAGS)?$({},e.ALLOWED_TAGS,j):le,k=hp(e,`ALLOWED_ATTR`)&&ip(e.ALLOWED_ATTR)?$({},e.ALLOWED_ATTR,j):ue,Ue=hp(e,`ALLOWED_NAMESPACES`)&&ip(e.ALLOWED_NAMESPACES)?$({},e.ALLOWED_NAMESPACES,op):We,Ie=hp(e,`ADD_URI_SAFE_ATTR`)&&ip(e.ADD_URI_SAFE_ATTR)?$(Sp(Le),e.ADD_URI_SAFE_ATTR,j):Le,Pe=hp(e,`ADD_DATA_URI_TAGS`)&&ip(e.ADD_DATA_URI_TAGS)?$(Sp(Fe),e.ADD_DATA_URI_TAGS,j):Fe,Me=hp(e,`FORBID_CONTENTS`)&&ip(e.FORBID_CONTENTS)?$({},e.FORBID_CONTENTS,j):Ne,de=hp(e,`FORBID_TAGS`)&&ip(e.FORBID_TAGS)?$({},e.FORBID_TAGS,j):Sp({}),fe=hp(e,`FORBID_ATTR`)&&ip(e.FORBID_ATTR)?$({},e.FORBID_ATTR,j):Sp({}),je=hp(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Sp(e.USE_PROFILES):e.USE_PROFILES:!1,me=e.ALLOW_ARIA_ATTR!==!1,he=e.ALLOW_DATA_ATTR!==!1,ge=e.ALLOW_UNKNOWN_PROTOCOLS||!1,_e=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ve=e.SAFE_FOR_TEMPLATES||!1,ye=e.SAFE_FOR_XML!==!1,be=e.WHOLE_DOCUMENT||!1,Ce=e.RETURN_DOM||!1,we=e.RETURN_DOM_FRAGMENT||!1,Te=e.RETURN_TRUSTED_TYPE||!1,Se=e.FORCE_BODY||!1,Ee=e.SANITIZE_DOM!==!1,De=e.SANITIZE_NAMED_PROPS||!1,ke=e.KEEP_CONTENT!==!1,Ae=e.IN_PLACE||!1,se=Tp(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Hp,Ve=typeof e.NAMESPACE==`string`?e.NAMESPACE:Be,Ge=hp(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?Sp(e.MATHML_TEXT_INTEGRATION_POINTS):$({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Ke=hp(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?Sp(e.HTML_INTEGRATION_POINTS):$({},[`annotation-xml`]);let t=hp(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?Sp(e.CUSTOM_ELEMENT_HANDLING):Xf(null);if(A=Xf(null),hp(t,`tagNameCheck`)&&Qe(t.tagNameCheck)&&(A.tagNameCheck=t.tagNameCheck),hp(t,`attributeNameCheck`)&&Qe(t.attributeNameCheck)&&(A.attributeNameCheck=t.attributeNameCheck),hp(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(A.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),ve&&(he=!1),we&&(Ce=!0),je&&(ce=$({},Mp),k=Xf(null),je.html===!0&&($(ce,Ep),$(k,Np)),je.svg===!0&&($(ce,Dp),$(k,Pp),$(k,Ip)),je.svgFilters===!0&&($(ce,Op),$(k,Pp),$(k,Ip)),je.mathMl===!0&&($(ce,Ap),$(k,Fp),$(k,Ip))),pe.tagCheck=null,pe.attributeCheck=null,hp(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?pe.tagCheck=e.ADD_TAGS:ip(e.ADD_TAGS)&&(ce===le&&(ce=Sp(ce)),$(ce,e.ADD_TAGS,j))),hp(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?pe.attributeCheck=e.ADD_ATTR:ip(e.ADD_ATTR)&&(k===ue&&(k=Sp(k)),$(k,e.ADD_ATTR,j))),hp(e,`ADD_URI_SAFE_ATTR`)&&ip(e.ADD_URI_SAFE_ATTR)&&$(Ie,e.ADD_URI_SAFE_ATTR,j),hp(e,`FORBID_CONTENTS`)&&ip(e.FORBID_CONTENTS)&&(Me===Ne&&(Me=Sp(Me)),$(Me,e.FORBID_CONTENTS,j)),hp(e,`ADD_FORBID_CONTENTS`)&&ip(e.ADD_FORBID_CONTENTS)&&(Me===Ne&&(Me=Sp(Me)),$(Me,e.ADD_FORBID_CONTENTS,j)),ke&&(ce[`#text`]=!0),be&&$(ce,[`html`,`head`,`body`]),ce.table&&($(ce,[`tbody`]),delete de.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw vp(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw vp(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);b=e.TRUSTED_TYPES_POLICY,x=b.createHTML(``)}else b===void 0&&(b=Xp(p,i)),b!==null&&typeof x==`string`&&(x=b.createHTML(``));Jf&&Jf(e),Xe=e},et=$({},[...Dp,...Op,...kp]),tt=$({},[...Ap,...jp]),nt=function(e){let t=y(e);(!t||!t.tagName)&&(t={namespaceURI:Ve,tagName:`template`});let n=ap(e.tagName),r=ap(t.tagName);return Ue[e.namespaceURI]?e.namespaceURI===ze?t.namespaceURI===Be?n===`svg`:t.namespaceURI===Re?n===`svg`&&(r===`annotation-xml`||Ge[r]):!!et[n]:e.namespaceURI===Re?t.namespaceURI===Be?n===`math`:t.namespaceURI===ze?n===`math`&&Ke[r]:!!tt[n]:e.namespaceURI===Be?t.namespaceURI===ze&&!Ke[r]||t.namespaceURI===Re&&!Ge[r]?!1:!tt[n]&&(qe[n]||!et[n]):!!(Je===`application/xhtml+xml`&&Ue[e.namespaceURI]):!1},rt=function(e){np(t.removed,{element:e});try{y(e).removeChild(e)}catch{g(e)}},it=function(e,n){try{np(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{np(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Ce||we)try{rt(n)}catch{}else try{n.setAttribute(e,``)}catch{}},at=function(e){let t=null,r=null;if(Se)e=`<remove></remove>`+e;else{let t=sp(e,/^[\r\n\t ]+/);r=t&&t[0]}Je===`application/xhtml+xml`&&Ve===Be&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=b?b.createHTML(e):e;if(Ve===Be)try{t=new f().parseFromString(i,Je)}catch{}if(!t||!t.documentElement){t=S.createDocument(Ve,`template`,null);try{t.documentElement.innerHTML=He?x:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ve===Be?T.call(t,be?`html`:`body`)[0]:be?t.documentElement:a},ot=function(e){return C.call(e.ownerDocument||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},st=function(e){return e instanceof d&&(typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||!(e.attributes instanceof u)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`)},ct=function(e){return typeof s==`function`&&e instanceof s};function lt(e,n,r){$f(e,e=>{e.call(t,n,r,Xe)})}let ut=function(e){let n=null;if(lt(D.beforeSanitizeElements,e,null),st(e))return rt(e),!0;let r=j(e.nodeName);if(lt(D.uponSanitizeElement,e,{tagName:r,allowedTags:ce}),ye&&e.hasChildNodes()&&!ct(e.firstElementChild)&&_p(/<[/\w!]/g,e.innerHTML)&&_p(/<[/\w!]/g,e.textContent)||ye&&e.namespaceURI===Be&&r===`style`&&ct(e.firstElementChild)||e.nodeType===Jp.progressingInstruction||ye&&e.nodeType===Jp.comment&&_p(/<[/\w]/g,e.data))return rt(e),!0;if(de[r]||!(pe.tagCheck instanceof Function&&pe.tagCheck(r))&&!ce[r]){if(!de[r]&&pt(r)&&(A.tagNameCheck instanceof RegExp&&_p(A.tagNameCheck,r)||A.tagNameCheck instanceof Function&&A.tagNameCheck(r)))return!1;if(ke&&!Me[r]){let t=y(e)||e.parentNode,n=v(e)||e.childNodes;if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=h(n[i],!0);t.insertBefore(r,_(e))}}}return rt(e),!0}return e instanceof c&&!nt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&_p(/<\/no(script|embed|frames)/i,e.innerHTML)?(rt(e),!0):(ve&&e.nodeType===Jp.text&&(n=e.textContent,$f([O,ee,te],e=>{n=cp(n,e,` `)}),e.textContent!==n&&(np(t.removed,{element:e.cloneNode()}),e.textContent=n)),lt(D.afterSanitizeElements,e,null),!1)},dt=function(e,t,r){if(fe[t]||Ee&&(t===`id`||t===`name`)&&(r in n||r in Ze))return!1;let i=k[t]||pe.attributeCheck instanceof Function&&pe.attributeCheck(t,e);if(!(he&&!fe[t]&&_p(ne,t))&&!(me&&_p(re,t))){if(!i||fe[t]){if(!(pt(e)&&(A.tagNameCheck instanceof RegExp&&_p(A.tagNameCheck,e)||A.tagNameCheck instanceof Function&&A.tagNameCheck(e))&&(A.attributeNameCheck instanceof RegExp&&_p(A.attributeNameCheck,t)||A.attributeNameCheck instanceof Function&&A.attributeNameCheck(t,e))||t===`is`&&A.allowCustomizedBuiltInElements&&(A.tagNameCheck instanceof RegExp&&_p(A.tagNameCheck,r)||A.tagNameCheck instanceof Function&&A.tagNameCheck(r))))return!1}else if(!Ie[t]&&!_p(se,cp(r,ae,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&lp(r,`data:`)===0&&Pe[e])&&!(ge&&!_p(ie,cp(r,ae,``)))&&r)return!1}return!0},ft=$({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),pt=function(e){return!ft[ap(e)]&&_p(oe,e)},mt=function(e){lt(D.beforeSanitizeAttributes,e,null);let{attributes:n}=e;if(!n||st(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:k,forceKeepAttr:void 0},i=n.length;for(;i--;){let{name:a,namespaceURI:o,value:s}=n[i],c=j(a),l=s,u=a===`value`?l:up(l);if(r.attrName=c,r.attrValue=u,r.keepAttr=!0,r.forceKeepAttr=void 0,lt(D.uponSanitizeAttribute,e,r),u=r.attrValue,De&&(c===`id`||c===`name`)&&lp(u,Oe)!==0&&(it(a,e),u=Oe+u),ye&&_p(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)){it(a,e);continue}if(c===`attributename`&&sp(u,`href`)){it(a,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){it(a,e);continue}if(!_e&&_p(/\/>/i,u)){it(a,e);continue}ve&&$f([O,ee,te],e=>{u=cp(u,e,` `)});let d=j(e.nodeName);if(!dt(d,c,u)){it(a,e);continue}if(b&&typeof p==`object`&&typeof p.getAttributeType==`function`&&!o)switch(p.getAttributeType(d,c)){case`TrustedHTML`:u=b.createHTML(u);break;case`TrustedScriptURL`:u=b.createScriptURL(u);break}if(u!==l)try{o?e.setAttributeNS(o,a,u):e.setAttribute(a,u),st(e)?rt(e):tp(t.removed)}catch{it(a,e)}}lt(D.afterSanitizeAttributes,e,null)},ht=function(e){let t=null,n=ot(e);for(lt(D.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)lt(D.uponSanitizeShadowNode,t,null),ut(t),mt(t),t.content instanceof a&&ht(t.content);lt(D.afterSanitizeShadowDOM,e,null)};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,o=null,c=null,l=null;if(He=!e,He&&(e=`<!-->`),typeof e!=`string`&&!ct(e)&&(e=Cp(e),typeof e!=`string`))throw vp(`dirty is not a string, aborting`);if(!t.isSupported)return e;if(xe||$e(n),t.removed=[],typeof e==`string`&&(Ae=!1),Ae){let t=e.nodeName;if(typeof t==`string`){let e=j(t);if(!ce[e]||de[e])throw vp(`root node is forbidden and cannot be sanitized in-place`)}}else if(e instanceof s)i=at(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===Jp.element&&o.nodeName===`BODY`||o.nodeName===`HTML`?i=o:i.appendChild(o);else{if(!Ce&&!ve&&!be&&e.indexOf(`<`)===-1)return b&&Te?b.createHTML(e):e;if(i=at(e),!i)return Ce?null:Te?x:``}i&&Se&&rt(i.firstChild);let u=ot(Ae?e:i);for(;c=u.nextNode();)ut(c),mt(c),c.content instanceof a&&ht(c.content);if(Ae)return e;if(Ce){if(ve){i.normalize();let e=i.innerHTML;$f([O,ee,te],t=>{e=cp(e,t,` `)}),i.innerHTML=e}if(we)for(l=w.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(k.shadowroot||k.shadowrootmode)&&(l=E.call(r,l,!0)),l}let d=be?i.outerHTML:i.innerHTML;return be&&ce[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&_p(Gp,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
74
- `+d),ve&&$f([O,ee,te],e=>{d=cp(d,e,` `)}),b&&Te?b.createHTML(d):d},t.setConfig=function(){$e(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),xe=!0},t.clearConfig=function(){Xe=null,xe=!1},t.isValidAttribute=function(e,t,n){return Xe||$e({}),dt(j(e),j(t),n)},t.addHook=function(e,t){typeof t==`function`&&np(D[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=ep(D[e],t);return n===-1?void 0:rp(D[e],n,1)[0]}return tp(D[e])},t.removeHooks=function(e){D[e]=[]},t.removeAllHooks=function(){D=Zp()},t}var $p=Qp(),em=new Q.Renderer;function tm(e){let t=e,n;do n=t,t=t.replace(/<[^>]*>/g,``);while(t!==n);return t}em.heading=({text:e,depth:t})=>`<h${t} id="${tm(e).toLowerCase().replace(/[^\w\s-]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``)}">${e}</h${t}>`,Q.setOptions({renderer:em});function nm(e){let t=[],n=/^(#{2,3})\s+(.+)$/gm,r;for(;(r=n.exec(e))!==null;){let e=r[1].length,n=r[2].replace(/`([^`]+)`/g,`$1`),i=tm(n).toLowerCase().replace(/[^\w\s-]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``);t.push({depth:e,text:n,id:i})}return t}function rm({index:e,currentSlug:t,sidebarOpen:n,onClose:r}){return(0,P.jsxs)(P.Fragment,{children:[n&&(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 lg:hidden`,children:[(0,P.jsx)(`div`,{className:`fixed inset-0 bg-black/50`,onClick:r}),(0,P.jsxs)(`div`,{className:`relative flex h-screen w-72 flex-col overflow-y-auto bg-zinc-900 border-r border-zinc-800`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between border-b border-zinc-800 px-4 py-4`,children:[(0,P.jsx)(`span`,{className:`text-sm font-semibold text-zinc-300`,children:`Documentation`}),(0,P.jsx)(`button`,{type:`button`,onClick:r,className:`text-zinc-400 hover:text-zinc-100`,children:(0,P.jsx)(Na,{className:`h-4 w-4`})})]}),(0,P.jsx)(im,{index:e,currentSlug:t,onLinkClick:r})]})]}),(0,P.jsxs)(`div`,{className:`sticky top-0 hidden h-screen w-72 flex-shrink-0 flex-col overflow-y-auto border-r border-zinc-800 bg-zinc-900/50 lg:flex`,children:[(0,P.jsx)(`div`,{className:`border-b border-zinc-800 px-4 py-4`,children:(0,P.jsxs)(Nt,{to:`/docs`,className:`text-sm font-semibold text-zinc-300 hover:text-cyan-400 flex items-center gap-2`,children:[(0,P.jsx)(si,{size:14,className:`text-cyan-400`}),`Documentation`]})}),(0,P.jsx)(im,{index:e,currentSlug:t})]})]})}function im({index:e,currentSlug:t,onLinkClick:n}){return(0,P.jsx)(`nav`,{className:`flex-1 px-3 py-4 space-y-5`,children:e.sections.map(e=>(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`px-2 mb-1 text-xs font-semibold uppercase tracking-wider text-zinc-500`,children:e.title}),(0,P.jsx)(`ul`,{className:`space-y-0.5`,children:e.pages.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsx)(Nt,{to:`/docs/${e.slug}`,onClick:n,className:[`block rounded-md px-2 py-1.5 text-sm transition-colors`,t===e.slug?`text-cyan-400 bg-zinc-800/50 font-medium`:`text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800/30`].join(` `),children:e.title})},e.slug))})]},e.title))})}function am({toc:e,activeId:t}){return e.length===0?null:(0,P.jsxs)(`div`,{className:`sticky top-6 hidden xl:block w-56 flex-shrink-0`,children:[(0,P.jsxs)(`h4`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-zinc-500 flex items-center gap-1.5`,children:[(0,P.jsx)(Gi,{size:12}),`On this page`]}),(0,P.jsx)(`ul`,{className:`space-y-1 border-l border-zinc-800`,children:e.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsx)(`a`,{href:`#${e.id}`,className:[`block border-l-2 -ml-px text-xs transition-colors py-1`,e.depth===3?`pl-5`:`pl-3`,t===e.id?`border-cyan-400 text-cyan-400`:`border-transparent text-zinc-500 hover:text-zinc-300 hover:border-zinc-600`].join(` `),children:e.text})},e.id))})]})}function om({prevPage:e,nextPage:t}){return!e&&!t?null:(0,P.jsxs)(`div`,{className:`mt-12 flex items-stretch gap-4 border-t border-zinc-800 pt-6`,children:[e?(0,P.jsxs)(Nt,{to:`/docs/${e.slug}`,className:`flex-1 group rounded-lg border border-zinc-800 p-4 hover:border-zinc-700 transition-colors`,children:[(0,P.jsxs)(`span`,{className:`text-xs text-zinc-500 flex items-center gap-1`,children:[(0,P.jsx)(di,{size:12}),`Previous`]}),(0,P.jsx)(`span`,{className:`mt-1 block text-sm text-zinc-300 group-hover:text-cyan-400 transition-colors`,children:e.title})]}):(0,P.jsx)(`div`,{className:`flex-1`}),t?(0,P.jsxs)(Nt,{to:`/docs/${t.slug}`,className:`flex-1 group rounded-lg border border-zinc-800 p-4 hover:border-zinc-700 transition-colors text-right`,children:[(0,P.jsxs)(`span`,{className:`text-xs text-zinc-500 flex items-center justify-end gap-1`,children:[`Next`,(0,P.jsx)(fi,{size:12})]}),(0,P.jsx)(`span`,{className:`mt-1 block text-sm text-zinc-300 group-hover:text-cyan-400 transition-colors`,children:t.title})]}):(0,P.jsx)(`div`,{className:`flex-1`})]})}function sm(){let{"*":e}=Ye(),t=Ge(),n=(0,g.useRef)(null),[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useReducer)((e,t)=>{switch(t.type){case`fetch`:return{content:``,loading:!0,error:null};case`success`:return{content:t.content,loading:!1,error:null};case`error`:return{content:``,loading:!1,error:t.error};default:return e}},{content:``,loading:!0,error:null}),{content:d,loading:f,error:p}=l;(0,g.useEffect)(()=>{fetch(`/docs/_index.json`).then(e=>e.json()).then(i).catch(e=>u({type:`error`,error:`Failed to load docs index: ${e.message}`}))},[]);let m=(0,g.useMemo)(()=>r?r.sections.flatMap(e=>e.pages):[],[r]),h=e||m[0]?.slug;(0,g.useEffect)(()=>{!e&&m.length>0&&t(`/docs/${m[0].slug}`,{replace:!0})},[e,m,t]);let _=(0,g.useMemo)(()=>m.find(e=>e.slug===h),[m,h]),v=m.indexOf(_),y=v>0?m[v-1]:null,b=v<m.length-1?m[v+1]:null,x=(0,g.useMemo)(()=>!r||!_?null:r.sections.find(e=>e.pages.some(e=>e.slug===h)),[r,_,h]);(0,g.useEffect)(()=>{if(!_)return;let e=!1;return u({type:`fetch`}),fetch(`/docs/${_.file}`).then(e=>{if(!e.ok)throw Error(`Document not found (${e.status})`);return e.text()}).then(t=>{e||u({type:`success`,content:t})}).catch(t=>{e||u({type:`error`,error:t.message})}),()=>{e=!0}},[_]),(0,g.useEffect)(()=>{n.current?.scrollTo(0,0)},[h]);let S=(0,g.useMemo)(()=>nm(d),[d]),C=(0,g.useMemo)(()=>d?Q.parse(d):``,[d]),w=(0,g.useCallback)(()=>{if(!n.current)return;let e=n.current.querySelectorAll(`h2[id], h3[id]`),t=``;for(let n of e)n.getBoundingClientRect().top<=100&&(t=n.id);c(t)},[]);return(0,g.useEffect)(()=>{let e=n.current;if(e)return e.addEventListener(`scroll`,w),()=>e.removeEventListener(`scroll`,w)},[w]),r?(0,P.jsxs)(`div`,{className:`flex h-screen bg-zinc-950`,children:[(0,P.jsx)(rm,{index:r,currentSlug:h,sidebarOpen:a,onClose:()=>o(!1)}),(0,P.jsxs)(`div`,{ref:n,className:`flex-1 overflow-y-auto`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`sticky top-4 left-4 z-40 rounded-md bg-zinc-900 border border-zinc-800 p-2 text-zinc-400 hover:text-zinc-100 lg:hidden m-4`,"aria-label":`Open docs navigation`,children:(0,P.jsx)(Ji,{className:`h-4 w-4`})}),(0,P.jsxs)(`div`,{className:`flex gap-8 max-w-5xl mx-auto px-6 py-8 lg:px-8`,children:[(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[x&&_&&(0,P.jsxs)(`div`,{className:`mb-6 flex items-center gap-2 text-xs text-zinc-500`,children:[(0,P.jsx)(Nt,{to:`/docs`,className:`hover:text-zinc-300`,children:`Docs`}),(0,P.jsx)(fi,{size:10}),(0,P.jsx)(`span`,{children:x.title}),(0,P.jsx)(fi,{size:10}),(0,P.jsx)(`span`,{className:`text-zinc-400`,children:_.title})]}),f&&(0,P.jsx)(`div`,{className:`text-zinc-500 text-sm py-12`,children:`Loading...`}),p&&(0,P.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/20 bg-yellow-500/5 p-6 text-sm text-yellow-400`,children:[(0,P.jsx)(`p`,{className:`font-semibold mb-2`,children:`Page Not Available`}),(0,P.jsx)(`p`,{className:`text-yellow-500/80`,children:p}),(0,P.jsx)(Nt,{to:`/docs/what-is-lamaste`,className:`mt-4 inline-block text-cyan-400 hover:underline`,children:`Go to Introduction`})]}),!f&&!p&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`article`,{className:`prose prose-invert prose-zinc max-w-none
75
- prose-headings:font-mono prose-headings:scroll-mt-20
76
- prose-a:text-cyan-400 prose-a:no-underline hover:prose-a:underline
77
- prose-code:text-cyan-300 prose-code:before:content-none prose-code:after:content-none
78
- prose-code:rounded prose-code:bg-zinc-800 prose-code:px-1.5 prose-code:py-0.5
79
- prose-pre:bg-zinc-900 prose-pre:border prose-pre:border-zinc-800
80
- prose-blockquote:border-cyan-400/30 prose-blockquote:text-zinc-400
81
- prose-strong:text-zinc-200
82
- prose-th:text-zinc-300 prose-td:text-zinc-400
83
- prose-hr:border-zinc-800
84
- prose-img:rounded-lg`,dangerouslySetInnerHTML:{__html:$p.sanitize(C)}}),(0,P.jsx)(om,{prevPage:y,nextPage:b})]})]}),(0,P.jsx)(am,{toc:S,activeId:s})]})]})]}):(0,P.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-zinc-950`,children:(0,P.jsx)(`div`,{className:`text-zinc-500 text-sm`,children:`Loading documentation...`})})}var cm=new Xn({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});function lm(){let{status:e,domain:t,isLoading:n,isError:r,refetch:i}=Jr();return n?(0,P.jsx)(Wu,{}):r?(0,P.jsx)(Gu,{onRetry:i}):e===`COMPLETED`?(0,P.jsx)(vt,{children:(0,P.jsxs)(gt,{element:(0,P.jsx)(Uu,{}),children:[(0,P.jsx)(gt,{path:`/`,element:(0,P.jsx)(_o,{})}),(0,P.jsx)(gt,{path:`/tunnels`,element:(0,P.jsx)(bu,{})}),(0,P.jsx)(gt,{path:`/sites`,element:(0,P.jsx)(Io,{domain:t})}),(0,P.jsx)(gt,{path:`/users`,element:(0,P.jsx)(Ws,{})}),(0,P.jsx)(gt,{path:`/certificates`,element:(0,P.jsx)(pc,{})}),(0,P.jsx)(gt,{path:`/services`,element:(0,P.jsx)(Co,{})}),(0,P.jsx)(gt,{path:`/tickets`,element:(0,P.jsx)(Sc,{})}),(0,P.jsx)(gt,{path:`/plugins`,element:(0,P.jsx)(eu,{})}),(0,P.jsx)(gt,{path:`/storage`,element:(0,P.jsx)(wu,{})}),(0,P.jsx)(gt,{path:`/audit`,element:(0,P.jsx)(ku,{})}),(0,P.jsx)(gt,{path:`/plugins/:pluginName/*`,element:(0,P.jsx)(pd,{})}),(0,P.jsx)(gt,{path:`/settings`,element:(0,P.jsx)(xu,{hasDomain:!!t})}),(0,P.jsx)(gt,{path:`/docs/*`,element:(0,P.jsx)(sm,{})})]})}):(0,P.jsx)(fd,{})}function um(){return(0,P.jsx)($n,{client:cm,children:(0,P.jsx)(Xr,{client:Fu,children:(0,P.jsx)(Va,{children:(0,P.jsx)(Qa,{children:(0,P.jsx)(Ra,{children:(0,P.jsx)(At,{children:(0,P.jsx)(lm,{})})})})})})})}_.createRoot(document.getElementById(`root`)).render((0,P.jsx)(g.StrictMode,{children:(0,P.jsx)(um,{})}));