the-campfire 0.1.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 (180) hide show
  1. package/bin/cli.ts +182 -0
  2. package/dist/apple-touch-icon.png +0 -0
  3. package/dist/assets/MermaidDiagram-By1J3Whj.js +2 -0
  4. package/dist/assets/_basePickBy-Dq6gnD-p.js +1 -0
  5. package/dist/assets/_baseUniq-SpgN6cGc.js +1 -0
  6. package/dist/assets/arc-D9SEA8dX.js +1 -0
  7. package/dist/assets/architectureDiagram-VXUJARFQ-CoTcwLeR.js +36 -0
  8. package/dist/assets/blockDiagram-VD42YOAC-Dvc63voV.js +122 -0
  9. package/dist/assets/c4Diagram-YG6GDRKO-tuDcG4_4.js +10 -0
  10. package/dist/assets/channel-CxhcHn7S.js +1 -0
  11. package/dist/assets/chunk-4BX2VUAB-x1hChYu9.js +1 -0
  12. package/dist/assets/chunk-55IACEB6-BX6HWnWP.js +1 -0
  13. package/dist/assets/chunk-B4BG7PRW-B4IlF03G.js +165 -0
  14. package/dist/assets/chunk-DI55MBZ5-TpYb5rLg.js +220 -0
  15. package/dist/assets/chunk-FMBD7UC4-DZX4LUPx.js +15 -0
  16. package/dist/assets/chunk-QN33PNHL-CuQs0NDY.js +1 -0
  17. package/dist/assets/chunk-QZHKN3VN-CygWwVx8.js +1 -0
  18. package/dist/assets/chunk-TZMSLE5B-CtI-IdKV.js +1 -0
  19. package/dist/assets/classDiagram-2ON5EDUG-BM0LptJF.js +1 -0
  20. package/dist/assets/classDiagram-v2-WZHVMYZB-BM0LptJF.js +1 -0
  21. package/dist/assets/clone-C6kt1rE7.js +1 -0
  22. package/dist/assets/cose-bilkent-S5V4N54A-PdySs991.js +1 -0
  23. package/dist/assets/cytoscape.esm-BQaXIfA_.js +331 -0
  24. package/dist/assets/dagre-6UL2VRFP-J0SxEiEu.js +4 -0
  25. package/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  26. package/dist/assets/diagram-PSM6KHXK-CW0HLXaH.js +24 -0
  27. package/dist/assets/diagram-QEK2KX5R-DADHF-k4.js +43 -0
  28. package/dist/assets/diagram-S2PKOQOG-9S0-PC3S.js +24 -0
  29. package/dist/assets/erDiagram-Q2GNP2WA-BEHAiY_q.js +60 -0
  30. package/dist/assets/flowDiagram-NV44I4VS-Cu6n9Xnd.js +162 -0
  31. package/dist/assets/ganttDiagram-JELNMOA3-Cr_BHryu.js +267 -0
  32. package/dist/assets/gitGraphDiagram-V2S2FVAM-D5pT35v5.js +65 -0
  33. package/dist/assets/graph-DKRbrxcs.js +1 -0
  34. package/dist/assets/index-Byjg9zgI.css +32 -0
  35. package/dist/assets/index-Cwj3m0hT.js +284 -0
  36. package/dist/assets/infoDiagram-HS3SLOUP-BaJlrgKV.js +2 -0
  37. package/dist/assets/init-Gi6I4Gst.js +1 -0
  38. package/dist/assets/journeyDiagram-XKPGCS4Q-CXC4-DJv.js +139 -0
  39. package/dist/assets/kanban-definition-3W4ZIXB7-BtHBu9cx.js +89 -0
  40. package/dist/assets/katex-BlHpptmG.js +261 -0
  41. package/dist/assets/layout-DnxSwLDJ.js +1 -0
  42. package/dist/assets/linear-CWbbIT8l.js +1 -0
  43. package/dist/assets/mermaid.core-DXn1cFAK.js +256 -0
  44. package/dist/assets/mindmap-definition-VGOIOE7T-BR8br1hs.js +68 -0
  45. package/dist/assets/ordinal-BENe2yWM.js +1 -0
  46. package/dist/assets/pieDiagram-ADFJNKIX-B7RmXV7I.js +30 -0
  47. package/dist/assets/quadrantDiagram-AYHSOK5B-DK0FhyV_.js +7 -0
  48. package/dist/assets/requirementDiagram-UZGBJVZJ-3zAGxSpL.js +64 -0
  49. package/dist/assets/sankeyDiagram-TZEHDZUN-DZppKtjc.js +10 -0
  50. package/dist/assets/sequenceDiagram-WL72ISMW-D1x3r3wV.js +145 -0
  51. package/dist/assets/stateDiagram-FKZM4ZOC-2ByD08Vq.js +1 -0
  52. package/dist/assets/stateDiagram-v2-4FDKWEC3-Vm1cYjgV.js +1 -0
  53. package/dist/assets/timeline-definition-IT6M3QCI-l5S35biR.js +61 -0
  54. package/dist/assets/treemap-GDKQZRPO-DIPadPiF.js +162 -0
  55. package/dist/assets/xychartDiagram-PRI3JC2R-9GUvwS2b.js +7 -0
  56. package/dist/favicon.svg +3 -0
  57. package/dist/fonts/Geist-Variable.woff2 +0 -0
  58. package/dist/fonts/GeistMono-Variable.woff2 +0 -0
  59. package/dist/icon-192.png +0 -0
  60. package/dist/icon-512.png +0 -0
  61. package/dist/index.html +33 -0
  62. package/dist/logo-codex.svg +14 -0
  63. package/dist/logo.svg +3 -0
  64. package/dist/manifest.json +26 -0
  65. package/dist/og-image.png +0 -0
  66. package/dist/sw.js +130 -0
  67. package/package.json +92 -0
  68. package/server/ADAPTERS.md +121 -0
  69. package/server/adapter-registry-types.ts +28 -0
  70. package/server/adapter-registry.ts +293 -0
  71. package/server/adapter-types.ts +51 -0
  72. package/server/agent-executor.ts +249 -0
  73. package/server/agent-mcp-bridge.ts +148 -0
  74. package/server/agent-mcp-stdio.ts +171 -0
  75. package/server/agent-mcp-tools.ts +76 -0
  76. package/server/agent-store.ts +183 -0
  77. package/server/agent-types.ts +79 -0
  78. package/server/aider-adapter.ts +525 -0
  79. package/server/auth.ts +153 -0
  80. package/server/auto-namer.ts +132 -0
  81. package/server/capability-discovery.ts +431 -0
  82. package/server/claude-container-auth.ts +40 -0
  83. package/server/claude-stdio-adapter.ts +452 -0
  84. package/server/clawhub-export.ts +218 -0
  85. package/server/cli-launcher.ts +1613 -0
  86. package/server/codex-adapter.ts +1987 -0
  87. package/server/codex-container-auth.ts +40 -0
  88. package/server/codex-home.ts +26 -0
  89. package/server/collective-intelligence.ts +401 -0
  90. package/server/commands-discovery.ts +160 -0
  91. package/server/constants.ts +5 -0
  92. package/server/container-manager.ts +328 -0
  93. package/server/cron-scheduler.ts +243 -0
  94. package/server/cron-store.ts +149 -0
  95. package/server/cron-types.ts +63 -0
  96. package/server/deliberation-engine.ts +323 -0
  97. package/server/embedding.ts +89 -0
  98. package/server/env-manager.ts +146 -0
  99. package/server/environment-detector.ts +106 -0
  100. package/server/environment-rules.ts +106 -0
  101. package/server/gallery-store.ts +216 -0
  102. package/server/gallery-types.ts +52 -0
  103. package/server/gallery-votes.ts +101 -0
  104. package/server/git-utils.ts +384 -0
  105. package/server/github-pr.ts +379 -0
  106. package/server/goose-adapter.ts +929 -0
  107. package/server/image-pull-manager.ts +144 -0
  108. package/server/index.ts +363 -0
  109. package/server/linear-project-manager.ts +78 -0
  110. package/server/moltbook-client.ts +160 -0
  111. package/server/openclaw-adapter.ts +916 -0
  112. package/server/openclaw-channel/channel.ts +188 -0
  113. package/server/openclaw-channel/index.ts +68 -0
  114. package/server/openclaw-channel/package.json +19 -0
  115. package/server/openclaw-channel/types.ts +93 -0
  116. package/server/opencode-adapter.ts +951 -0
  117. package/server/openhands-adapter.ts +775 -0
  118. package/server/orchestrator-executor.ts +184 -0
  119. package/server/orchestrator-store.ts +106 -0
  120. package/server/orchestrator-types.ts +86 -0
  121. package/server/path-resolver.ts +168 -0
  122. package/server/pr-poller.ts +162 -0
  123. package/server/proactive-keepalive.ts +121 -0
  124. package/server/prompt-manager.ts +103 -0
  125. package/server/protocol-monitor.ts +197 -0
  126. package/server/race-controller.ts +295 -0
  127. package/server/race-store.ts +82 -0
  128. package/server/recorder.ts +359 -0
  129. package/server/recording-hub/compat-validator.ts +122 -0
  130. package/server/recording-hub/diagnostics.ts +289 -0
  131. package/server/recording-hub/hub-routes.ts +146 -0
  132. package/server/recording-hub/hub-store.ts +224 -0
  133. package/server/replay.ts +78 -0
  134. package/server/routes/adapter-routes.ts +31 -0
  135. package/server/routes/agent-mcp-routes.ts +35 -0
  136. package/server/routes/agent-routes.ts +185 -0
  137. package/server/routes/auth-routes.ts +101 -0
  138. package/server/routes/ci-routes.ts +165 -0
  139. package/server/routes/commands-routes.ts +94 -0
  140. package/server/routes/cron-routes.ts +100 -0
  141. package/server/routes/env-routes.ts +50 -0
  142. package/server/routes/folder-routes.ts +56 -0
  143. package/server/routes/fs-routes.ts +403 -0
  144. package/server/routes/gallery-routes.ts +410 -0
  145. package/server/routes/git-routes.ts +108 -0
  146. package/server/routes/index.ts +62 -0
  147. package/server/routes/linear-routes.ts +254 -0
  148. package/server/routes/monitor-routes.ts +11 -0
  149. package/server/routes/orchestrator-routes.ts +210 -0
  150. package/server/routes/prompt-routes.ts +47 -0
  151. package/server/routes/race-routes.ts +103 -0
  152. package/server/routes/recording-routes.ts +101 -0
  153. package/server/routes/route-deps.ts +32 -0
  154. package/server/routes/session-routes.ts +560 -0
  155. package/server/routes/settings-routes.ts +108 -0
  156. package/server/routes/skills-routes.ts +52 -0
  157. package/server/routes/system-routes.ts +243 -0
  158. package/server/routes/webhook-routes.ts +135 -0
  159. package/server/routes.ts +44 -0
  160. package/server/security-middleware.ts +100 -0
  161. package/server/semantic-memory.ts +389 -0
  162. package/server/service.ts +733 -0
  163. package/server/session-folders.ts +107 -0
  164. package/server/session-git-info.ts +89 -0
  165. package/server/session-linear-issues.ts +94 -0
  166. package/server/session-names.ts +67 -0
  167. package/server/session-store.ts +169 -0
  168. package/server/session-types.ts +415 -0
  169. package/server/settings-manager.ts +120 -0
  170. package/server/shared-context.ts +401 -0
  171. package/server/skills-manager.ts +250 -0
  172. package/server/sub-session-manager.ts +263 -0
  173. package/server/terminal-manager.ts +185 -0
  174. package/server/update-checker.ts +114 -0
  175. package/server/usage-limits.ts +192 -0
  176. package/server/webhook-manager.ts +228 -0
  177. package/server/webhook-store.ts +168 -0
  178. package/server/webhook-types.ts +66 -0
  179. package/server/worktree-tracker.ts +84 -0
  180. package/server/ws-bridge.ts +2322 -0
@@ -0,0 +1,284 @@
1
+ (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&n(c)}).observe(document,{childList:!0,subtree:!0});function s(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function n(a){if(a.ep)return;a.ep=!0;const l=s(a);fetch(a.href,l)}})();function p0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function FH(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var s=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};s.prototype=t.prototype}else s={};return Object.defineProperty(s,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(s,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}),s}var fm={exports:{}},ql={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var iy;function O4(){if(iy)return ql;iy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function s(n,a,l){var c=null;if(l!==void 0&&(c=""+l),a.key!==void 0&&(c=""+a.key),"key"in a){l={};for(var d in a)d!=="key"&&(l[d]=a[d])}else l=a;return a=l.ref,{$$typeof:e,type:n,key:c,ref:a!==void 0?a:null,props:l}}return ql.Fragment=t,ql.jsx=s,ql.jsxs=s,ql}var ay;function z4(){return ay||(ay=1,fm.exports=O4()),fm.exports}var r=z4(),pm={exports:{}},Ke={};/**
10
+ * @license React
11
+ * react.production.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var oy;function P4(){if(oy)return Ke;oy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),_=Symbol.iterator;function v(P){return P===null||typeof P!="object"?null:(P=_&&P[_]||P["@@iterator"],typeof P=="function"?P:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,j={};function k(P,z,T){this.props=P,this.context=z,this.refs=j,this.updater=T||y}k.prototype.isReactComponent={},k.prototype.setState=function(P,z){if(typeof P!="object"&&typeof P!="function"&&P!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,P,z,"setState")},k.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function N(){}N.prototype=k.prototype;function E(P,z,T){this.props=P,this.context=z,this.refs=j,this.updater=T||y}var B=E.prototype=new N;B.constructor=E,S(B,k.prototype),B.isPureReactComponent=!0;var F=Array.isArray;function $(){}var K={H:null,A:null,T:null,S:null},Y=Object.prototype.hasOwnProperty;function W(P,z,T){var oe=T.ref;return{$$typeof:e,type:P,key:z,ref:oe!==void 0?oe:null,props:T}}function L(P,z){return W(P.type,z,P.props)}function Q(P){return typeof P=="object"&&P!==null&&P.$$typeof===e}function V(P){var z={"=":"=0",":":"=2"};return"$"+P.replace(/[=:]/g,function(T){return z[T]})}var X=/\/+/g;function q(P,z){return typeof P=="object"&&P!==null&&P.key!=null?V(""+P.key):z.toString(36)}function A(P){switch(P.status){case"fulfilled":return P.value;case"rejected":throw P.reason;default:switch(typeof P.status=="string"?P.then($,$):(P.status="pending",P.then(function(z){P.status==="pending"&&(P.status="fulfilled",P.value=z)},function(z){P.status==="pending"&&(P.status="rejected",P.reason=z)})),P.status){case"fulfilled":return P.value;case"rejected":throw P.reason}}throw P}function M(P,z,T,oe,be){var re=typeof P;(re==="undefined"||re==="boolean")&&(P=null);var ve=!1;if(P===null)ve=!0;else switch(re){case"bigint":case"string":case"number":ve=!0;break;case"object":switch(P.$$typeof){case e:case t:ve=!0;break;case m:return ve=P._init,M(ve(P._payload),z,T,oe,be)}}if(ve)return be=be(P),ve=oe===""?"."+q(P,0):oe,F(be)?(T="",ve!=null&&(T=ve.replace(X,"$&/")+"/"),M(be,z,T,"",function(je){return je})):be!=null&&(Q(be)&&(be=L(be,T+(be.key==null||P&&P.key===be.key?"":(""+be.key).replace(X,"$&/")+"/")+ve)),z.push(be)),1;ve=0;var Te=oe===""?".":oe+":";if(F(P))for(var Re=0;Re<P.length;Re++)oe=P[Re],re=Te+q(oe,Re),ve+=M(oe,z,T,re,be);else if(Re=v(P),typeof Re=="function")for(P=Re.call(P),Re=0;!(oe=P.next()).done;)oe=oe.value,re=Te+q(oe,Re++),ve+=M(oe,z,T,re,be);else if(re==="object"){if(typeof P.then=="function")return M(A(P),z,T,oe,be);throw z=String(P),Error("Objects are not valid as a React child (found: "+(z==="[object Object]"?"object with keys {"+Object.keys(P).join(", ")+"}":z)+"). If you meant to render a collection of children, use an array instead.")}return ve}function O(P,z,T){if(P==null)return P;var oe=[],be=0;return M(P,oe,"","",function(re){return z.call(T,re,be++)}),oe}function U(P){if(P._status===-1){var z=P._result;z=z(),z.then(function(T){(P._status===0||P._status===-1)&&(P._status=1,P._result=T)},function(T){(P._status===0||P._status===-1)&&(P._status=2,P._result=T)}),P._status===-1&&(P._status=0,P._result=z)}if(P._status===1)return P._result.default;throw P._result}var I=typeof reportError=="function"?reportError:function(P){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof P=="object"&&P!==null&&typeof P.message=="string"?String(P.message):String(P),error:P});if(!window.dispatchEvent(z))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",P);return}console.error(P)},R={map:O,forEach:function(P,z,T){O(P,function(){z.apply(this,arguments)},T)},count:function(P){var z=0;return O(P,function(){z++}),z},toArray:function(P){return O(P,function(z){return z})||[]},only:function(P){if(!Q(P))throw Error("React.Children.only expected to receive a single React element child.");return P}};return Ke.Activity=g,Ke.Children=R,Ke.Component=k,Ke.Fragment=s,Ke.Profiler=a,Ke.PureComponent=E,Ke.StrictMode=n,Ke.Suspense=f,Ke.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=K,Ke.__COMPILER_RUNTIME={__proto__:null,c:function(P){return K.H.useMemoCache(P)}},Ke.cache=function(P){return function(){return P.apply(null,arguments)}},Ke.cacheSignal=function(){return null},Ke.cloneElement=function(P,z,T){if(P==null)throw Error("The argument must be a React element, but you passed "+P+".");var oe=S({},P.props),be=P.key;if(z!=null)for(re in z.key!==void 0&&(be=""+z.key),z)!Y.call(z,re)||re==="key"||re==="__self"||re==="__source"||re==="ref"&&z.ref===void 0||(oe[re]=z[re]);var re=arguments.length-2;if(re===1)oe.children=T;else if(1<re){for(var ve=Array(re),Te=0;Te<re;Te++)ve[Te]=arguments[Te+2];oe.children=ve}return W(P.type,be,oe)},Ke.createContext=function(P){return P={$$typeof:c,_currentValue:P,_currentValue2:P,_threadCount:0,Provider:null,Consumer:null},P.Provider=P,P.Consumer={$$typeof:l,_context:P},P},Ke.createElement=function(P,z,T){var oe,be={},re=null;if(z!=null)for(oe in z.key!==void 0&&(re=""+z.key),z)Y.call(z,oe)&&oe!=="key"&&oe!=="__self"&&oe!=="__source"&&(be[oe]=z[oe]);var ve=arguments.length-2;if(ve===1)be.children=T;else if(1<ve){for(var Te=Array(ve),Re=0;Re<ve;Re++)Te[Re]=arguments[Re+2];be.children=Te}if(P&&P.defaultProps)for(oe in ve=P.defaultProps,ve)be[oe]===void 0&&(be[oe]=ve[oe]);return W(P,re,be)},Ke.createRef=function(){return{current:null}},Ke.forwardRef=function(P){return{$$typeof:d,render:P}},Ke.isValidElement=Q,Ke.lazy=function(P){return{$$typeof:m,_payload:{_status:-1,_result:P},_init:U}},Ke.memo=function(P,z){return{$$typeof:h,type:P,compare:z===void 0?null:z}},Ke.startTransition=function(P){var z=K.T,T={};K.T=T;try{var oe=P(),be=K.S;be!==null&&be(T,oe),typeof oe=="object"&&oe!==null&&typeof oe.then=="function"&&oe.then($,I)}catch(re){I(re)}finally{z!==null&&T.types!==null&&(z.types=T.types),K.T=z}},Ke.unstable_useCacheRefresh=function(){return K.H.useCacheRefresh()},Ke.use=function(P){return K.H.use(P)},Ke.useActionState=function(P,z,T){return K.H.useActionState(P,z,T)},Ke.useCallback=function(P,z){return K.H.useCallback(P,z)},Ke.useContext=function(P){return K.H.useContext(P)},Ke.useDebugValue=function(){},Ke.useDeferredValue=function(P,z){return K.H.useDeferredValue(P,z)},Ke.useEffect=function(P,z){return K.H.useEffect(P,z)},Ke.useEffectEvent=function(P){return K.H.useEffectEvent(P)},Ke.useId=function(){return K.H.useId()},Ke.useImperativeHandle=function(P,z,T){return K.H.useImperativeHandle(P,z,T)},Ke.useInsertionEffect=function(P,z){return K.H.useInsertionEffect(P,z)},Ke.useLayoutEffect=function(P,z){return K.H.useLayoutEffect(P,z)},Ke.useMemo=function(P,z){return K.H.useMemo(P,z)},Ke.useOptimistic=function(P,z){return K.H.useOptimistic(P,z)},Ke.useReducer=function(P,z,T){return K.H.useReducer(P,z,T)},Ke.useRef=function(P){return K.H.useRef(P)},Ke.useState=function(P){return K.H.useState(P)},Ke.useSyncExternalStore=function(P,z,T){return K.H.useSyncExternalStore(P,z,T)},Ke.useTransition=function(){return K.H.useTransition()},Ke.version="19.2.4",Ke}var ly;function m0(){return ly||(ly=1,pm.exports=P4()),pm.exports}var w=m0();const xr=p0(w);var mm={exports:{}},Gl={},gm={exports:{}},xm={};/**
18
+ * @license React
19
+ * scheduler.production.js
20
+ *
21
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */var cy;function $4(){return cy||(cy=1,(function(e){function t(M,O){var U=M.length;M.push(O);e:for(;0<U;){var I=U-1>>>1,R=M[I];if(0<a(R,O))M[I]=O,M[U]=R,U=I;else break e}}function s(M){return M.length===0?null:M[0]}function n(M){if(M.length===0)return null;var O=M[0],U=M.pop();if(U!==O){M[0]=U;e:for(var I=0,R=M.length,P=R>>>1;I<P;){var z=2*(I+1)-1,T=M[z],oe=z+1,be=M[oe];if(0>a(T,U))oe<R&&0>a(be,T)?(M[I]=be,M[oe]=U,I=oe):(M[I]=T,M[z]=U,I=z);else if(oe<R&&0>a(be,U))M[I]=be,M[oe]=U,I=oe;else break e}}return O}function a(M,O){var U=M.sortIndex-O.sortIndex;return U!==0?U:M.id-O.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var f=[],h=[],m=1,g=null,_=3,v=!1,y=!1,S=!1,j=!1,k=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function B(M){for(var O=s(h);O!==null;){if(O.callback===null)n(h);else if(O.startTime<=M)n(h),O.sortIndex=O.expirationTime,t(f,O);else break;O=s(h)}}function F(M){if(S=!1,B(M),!y)if(s(f)!==null)y=!0,$||($=!0,V());else{var O=s(h);O!==null&&A(F,O.startTime-M)}}var $=!1,K=-1,Y=5,W=-1;function L(){return j?!0:!(e.unstable_now()-W<Y)}function Q(){if(j=!1,$){var M=e.unstable_now();W=M;var O=!0;try{e:{y=!1,S&&(S=!1,N(K),K=-1),v=!0;var U=_;try{t:{for(B(M),g=s(f);g!==null&&!(g.expirationTime>M&&L());){var I=g.callback;if(typeof I=="function"){g.callback=null,_=g.priorityLevel;var R=I(g.expirationTime<=M);if(M=e.unstable_now(),typeof R=="function"){g.callback=R,B(M),O=!0;break t}g===s(f)&&n(f),B(M)}else n(f);g=s(f)}if(g!==null)O=!0;else{var P=s(h);P!==null&&A(F,P.startTime-M),O=!1}}break e}finally{g=null,_=U,v=!1}O=void 0}}finally{O?V():$=!1}}}var V;if(typeof E=="function")V=function(){E(Q)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,q=X.port2;X.port1.onmessage=Q,V=function(){q.postMessage(null)}}else V=function(){k(Q,0)};function A(M,O){K=k(function(){M(e.unstable_now())},O)}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(M){M.callback=null},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Y=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return _},e.unstable_next=function(M){switch(_){case 1:case 2:case 3:var O=3;break;default:O=_}var U=_;_=O;try{return M()}finally{_=U}},e.unstable_requestPaint=function(){j=!0},e.unstable_runWithPriority=function(M,O){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var U=_;_=M;try{return O()}finally{_=U}},e.unstable_scheduleCallback=function(M,O,U){var I=e.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?I+U:I):U=I,M){case 1:var R=-1;break;case 2:R=250;break;case 5:R=1073741823;break;case 4:R=1e4;break;default:R=5e3}return R=U+R,M={id:m++,callback:O,priorityLevel:M,startTime:U,expirationTime:R,sortIndex:-1},U>I?(M.sortIndex=U,t(h,M),s(f)===null&&M===s(h)&&(S?(N(K),K=-1):S=!0,A(F,U-I))):(M.sortIndex=R,t(f,M),y||v||(y=!0,$||($=!0,V()))),M},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(M){var O=_;return function(){var U=_;_=O;try{return M.apply(this,arguments)}finally{_=U}}}})(xm)),xm}var uy;function I4(){return uy||(uy=1,gm.exports=$4()),gm.exports}var vm={exports:{}},Us={};/**
26
+ * @license React
27
+ * react-dom.production.js
28
+ *
29
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var dy;function F4(){if(dy)return Us;dy=1;var e=m0();function t(f){var h="https://react.dev/errors/"+f;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var m=2;m<arguments.length;m++)h+="&args[]="+encodeURIComponent(arguments[m])}return"Minified React error #"+f+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var n={d:{f:s,r:function(){throw Error(t(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},a=Symbol.for("react.portal");function l(f,h,m){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:g==null?null:""+g,children:f,containerInfo:h,implementation:m}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(f,h){if(f==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Us.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=n,Us.createPortal=function(f,h){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return l(f,h,null,m)},Us.flushSync=function(f){var h=c.T,m=n.p;try{if(c.T=null,n.p=2,f)return f()}finally{c.T=h,n.p=m,n.d.f()}},Us.preconnect=function(f,h){typeof f=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,n.d.C(f,h))},Us.prefetchDNS=function(f){typeof f=="string"&&n.d.D(f)},Us.preinit=function(f,h){if(typeof f=="string"&&h&&typeof h.as=="string"){var m=h.as,g=d(m,h.crossOrigin),_=typeof h.integrity=="string"?h.integrity:void 0,v=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;m==="style"?n.d.S(f,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:g,integrity:_,fetchPriority:v}):m==="script"&&n.d.X(f,{crossOrigin:g,integrity:_,fetchPriority:v,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Us.preinitModule=function(f,h){if(typeof f=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var m=d(h.as,h.crossOrigin);n.d.M(f,{crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&n.d.M(f)},Us.preload=function(f,h){if(typeof f=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var m=h.as,g=d(m,h.crossOrigin);n.d.L(f,m,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Us.preloadModule=function(f,h){if(typeof f=="string")if(h){var m=d(h.as,h.crossOrigin);n.d.m(f,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else n.d.m(f)},Us.requestFormReset=function(f){n.d.r(f)},Us.unstable_batchedUpdates=function(f,h){return f(h)},Us.useFormState=function(f,h,m){return c.H.useFormState(f,h,m)},Us.useFormStatus=function(){return c.H.useHostTransitionStatus()},Us.version="19.2.4",Us}var hy;function pS(){if(hy)return vm.exports;hy=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),vm.exports=F4(),vm.exports}/**
34
+ * @license React
35
+ * react-dom-client.production.js
36
+ *
37
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
38
+ *
39
+ * This source code is licensed under the MIT license found in the
40
+ * LICENSE file in the root directory of this source tree.
41
+ */var fy;function H4(){if(fy)return Gl;fy=1;var e=I4(),t=m0(),s=pS();function n(i){var o="https://react.dev/errors/"+i;if(1<arguments.length){o+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)o+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+i+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function l(i){var o=i,u=i;if(i.alternate)for(;o.return;)o=o.return;else{i=o;do o=i,(o.flags&4098)!==0&&(u=o.return),i=o.return;while(i)}return o.tag===3?u:null}function c(i){if(i.tag===13){var o=i.memoizedState;if(o===null&&(i=i.alternate,i!==null&&(o=i.memoizedState)),o!==null)return o.dehydrated}return null}function d(i){if(i.tag===31){var o=i.memoizedState;if(o===null&&(i=i.alternate,i!==null&&(o=i.memoizedState)),o!==null)return o.dehydrated}return null}function f(i){if(l(i)!==i)throw Error(n(188))}function h(i){var o=i.alternate;if(!o){if(o=l(i),o===null)throw Error(n(188));return o!==i?null:i}for(var u=i,p=o;;){var x=u.return;if(x===null)break;var b=x.alternate;if(b===null){if(p=x.return,p!==null){u=p;continue}break}if(x.child===b.child){for(b=x.child;b;){if(b===u)return f(x),i;if(b===p)return f(x),o;b=b.sibling}throw Error(n(188))}if(u.return!==p.return)u=x,p=b;else{for(var C=!1,D=x.child;D;){if(D===u){C=!0,u=x,p=b;break}if(D===p){C=!0,p=x,u=b;break}D=D.sibling}if(!C){for(D=b.child;D;){if(D===u){C=!0,u=b,p=x;break}if(D===p){C=!0,p=b,u=x;break}D=D.sibling}if(!C)throw Error(n(189))}}if(u.alternate!==p)throw Error(n(190))}if(u.tag!==3)throw Error(n(188));return u.stateNode.current===u?i:o}function m(i){var o=i.tag;if(o===5||o===26||o===27||o===6)return i;for(i=i.child;i!==null;){if(o=m(i),o!==null)return o;i=i.sibling}return null}var g=Object.assign,_=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),E=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),K=Symbol.for("react.memo"),Y=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),L=Symbol.for("react.memo_cache_sentinel"),Q=Symbol.iterator;function V(i){return i===null||typeof i!="object"?null:(i=Q&&i[Q]||i["@@iterator"],typeof i=="function"?i:null)}var X=Symbol.for("react.client.reference");function q(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===X?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case S:return"Fragment";case k:return"Profiler";case j:return"StrictMode";case F:return"Suspense";case $:return"SuspenseList";case W:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case y:return"Portal";case E:return i.displayName||"Context";case N:return(i._context.displayName||"Context")+".Consumer";case B:var o=i.render;return i=i.displayName,i||(i=o.displayName||o.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case K:return o=i.displayName||null,o!==null?o:q(i.type)||"Memo";case Y:o=i._payload,i=i._init;try{return q(i(o))}catch{}}return null}var A=Array.isArray,M=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U={pending:!1,data:null,method:null,action:null},I=[],R=-1;function P(i){return{current:i}}function z(i){0>R||(i.current=I[R],I[R]=null,R--)}function T(i,o){R++,I[R]=i.current,i.current=o}var oe=P(null),be=P(null),re=P(null),ve=P(null);function Te(i,o){switch(T(re,o),T(be,i),T(oe,null),o.nodeType){case 9:case 11:i=(i=o.documentElement)&&(i=i.namespaceURI)?E_(i):0;break;default:if(i=o.tagName,o=o.namespaceURI)o=E_(o),i=M_(o,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(oe),T(oe,i)}function Re(){z(oe),z(be),z(re)}function je(i){i.memoizedState!==null&&T(ve,i);var o=oe.current,u=M_(o,i.type);o!==u&&(T(be,i),T(oe,u))}function Ye(i){be.current===i&&(z(oe),z(be)),ve.current===i&&(z(ve),Hl._currentValue=U)}var Xe,Pe;function ye(i){if(Xe===void 0)try{throw Error()}catch(u){var o=u.stack.trim().match(/\n( *(at )?)/);Xe=o&&o[1]||"",Pe=-1<u.stack.indexOf(`
42
+ at`)?" (<anonymous>)":-1<u.stack.indexOf("@")?"@unknown:0:0":""}return`
43
+ `+Xe+i+Pe}var Ze=!1;function ft(i,o){if(!i||Ze)return"";Ze=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var p={DetermineComponentFrameRoot:function(){try{if(o){var ge=function(){throw Error()};if(Object.defineProperty(ge.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ge,[])}catch(ue){var le=ue}Reflect.construct(i,[],ge)}else{try{ge.call()}catch(ue){le=ue}i.call(ge.prototype)}}else{try{throw Error()}catch(ue){le=ue}(ge=i())&&typeof ge.catch=="function"&&ge.catch(function(){})}}catch(ue){if(ue&&le&&typeof ue.stack=="string")return[ue.stack,le.stack]}return[null,null]}};p.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var x=Object.getOwnPropertyDescriptor(p.DetermineComponentFrameRoot,"name");x&&x.configurable&&Object.defineProperty(p.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var b=p.DetermineComponentFrameRoot(),C=b[0],D=b[1];if(C&&D){var J=C.split(`
44
+ `),ae=D.split(`
45
+ `);for(x=p=0;p<J.length&&!J[p].includes("DetermineComponentFrameRoot");)p++;for(;x<ae.length&&!ae[x].includes("DetermineComponentFrameRoot");)x++;if(p===J.length||x===ae.length)for(p=J.length-1,x=ae.length-1;1<=p&&0<=x&&J[p]!==ae[x];)x--;for(;1<=p&&0<=x;p--,x--)if(J[p]!==ae[x]){if(p!==1||x!==1)do if(p--,x--,0>x||J[p]!==ae[x]){var pe=`
46
+ `+J[p].replace(" at new "," at ");return i.displayName&&pe.includes("<anonymous>")&&(pe=pe.replace("<anonymous>",i.displayName)),pe}while(1<=p&&0<=x);break}}}finally{Ze=!1,Error.prepareStackTrace=u}return(u=i?i.displayName||i.name:"")?ye(u):""}function mt(i,o){switch(i.tag){case 26:case 27:case 5:return ye(i.type);case 16:return ye("Lazy");case 13:return i.child!==o&&o!==null?ye("Suspense Fallback"):ye("Suspense");case 19:return ye("SuspenseList");case 0:case 15:return ft(i.type,!1);case 11:return ft(i.type.render,!1);case 1:return ft(i.type,!0);case 31:return ye("Activity");default:return""}}function ts(i){try{var o="",u=null;do o+=mt(i,u),u=i,i=i.return;while(i);return o}catch(p){return`
47
+ Error generating stack: `+p.message+`
48
+ `+p.stack}}var Kt=Object.prototype.hasOwnProperty,Ft=e.unstable_scheduleCallback,Rt=e.unstable_cancelCallback,Hs=e.unstable_shouldYield,gs=e.unstable_requestPaint,vt=e.unstable_now,rr=e.unstable_getCurrentPriorityLevel,de=e.unstable_ImmediatePriority,_e=e.unstable_UserBlockingPriority,Be=e.unstable_NormalPriority,qe=e.unstable_LowPriority,Je=e.unstable_IdlePriority,Yt=e.log,xs=e.unstable_setDisableYieldValue,se=null,fe=null;function H(i){if(typeof Yt=="function"&&xs(i),fe&&typeof fe.setStrictMode=="function")try{fe.setStrictMode(se,i)}catch{}}var ee=Math.clz32?Math.clz32:Bt,Ie=Math.log,We=Math.LN2;function Bt(i){return i>>>=0,i===0?32:31-(Ie(i)/We|0)|0}var ss=256,ir=262144,oi=4194304;function Cr(i){var o=i&42;if(o!==0)return o;switch(i&-i){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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Qi(i,o,u){var p=i.pendingLanes;if(p===0)return 0;var x=0,b=i.suspendedLanes,C=i.pingedLanes;i=i.warmLanes;var D=p&134217727;return D!==0?(p=D&~b,p!==0?x=Cr(p):(C&=D,C!==0?x=Cr(C):u||(u=D&~i,u!==0&&(x=Cr(u))))):(D=p&~b,D!==0?x=Cr(D):C!==0?x=Cr(C):u||(u=p&~i,u!==0&&(x=Cr(u)))),x===0?0:o!==0&&o!==x&&(o&b)===0&&(b=x&-x,u=o&-o,b>=u||b===32&&(u&4194048)!==0)?o:x}function ce(i,o){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&o)===0}function $e(i,o){switch(i){case 1:case 2:case 4:case 8:case 64:return o+250;case 16:case 32: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 o+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function wt(){var i=oi;return oi<<=1,(oi&62914560)===0&&(oi=4194304),i}function Xt(i){for(var o=[],u=0;31>u;u++)o.push(i);return o}function Ot(i,o){i.pendingLanes|=o,o!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function pt(i,o,u,p,x,b){var C=i.pendingLanes;i.pendingLanes=u,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=u,i.entangledLanes&=u,i.errorRecoveryDisabledLanes&=u,i.shellSuspendCounter=0;var D=i.entanglements,J=i.expirationTimes,ae=i.hiddenUpdates;for(u=C&~u;0<u;){var pe=31-ee(u),ge=1<<pe;D[pe]=0,J[pe]=-1;var le=ae[pe];if(le!==null)for(ae[pe]=null,pe=0;pe<le.length;pe++){var ue=le[pe];ue!==null&&(ue.lane&=-536870913)}u&=~ge}p!==0&&Oa(i,p,0),b!==0&&x===0&&i.tag!==0&&(i.suspendedLanes|=b&~(C&~o))}function Oa(i,o,u){i.pendingLanes|=o,i.suspendedLanes&=~o;var p=31-ee(o);i.entangledLanes|=o,i.entanglements[p]=i.entanglements[p]|1073741824|u&261930}function ar(i,o){var u=i.entangledLanes|=o;for(i=i.entanglements;u;){var p=31-ee(u),x=1<<p;x&o|i[p]&o&&(i[p]|=o),u&=~x}}function hv(i,o){var u=o&-o;return u=(u&42)!==0?1:tf(u),(u&(i.suspendedLanes|o))!==0?0:u}function tf(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;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:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function sf(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function fv(){var i=O.p;return i!==0?i:(i=window.event,i===void 0?32:Q_(i.type))}function pv(i,o){var u=O.p;try{return O.p=i,o()}finally{O.p=u}}var li=Math.random().toString(36).slice(2),Rs="__reactFiber$"+li,rn="__reactProps$"+li,za="__reactContainer$"+li,nf="__reactEvents$"+li,kN="__reactListeners$"+li,CN="__reactHandles$"+li,mv="__reactResources$"+li,nl="__reactMarker$"+li;function rf(i){delete i[Rs],delete i[rn],delete i[nf],delete i[kN],delete i[CN]}function Pa(i){var o=i[Rs];if(o)return o;for(var u=i.parentNode;u;){if(o=u[za]||u[Rs]){if(u=o.alternate,o.child!==null||u!==null&&u.child!==null)for(i=O_(i);i!==null;){if(u=i[Rs])return u;i=O_(i)}return o}i=u,u=i.parentNode}return null}function $a(i){if(i=i[Rs]||i[za]){var o=i.tag;if(o===5||o===6||o===13||o===31||o===26||o===27||o===3)return i}return null}function rl(i){var o=i.tag;if(o===5||o===26||o===27||o===6)return i.stateNode;throw Error(n(33))}function Ia(i){var o=i[mv];return o||(o=i[mv]={hoistableStyles:new Map,hoistableScripts:new Map}),o}function js(i){i[nl]=!0}var gv=new Set,xv={};function Zi(i,o){Fa(i,o),Fa(i+"Capture",o)}function Fa(i,o){for(xv[i]=o,i=0;i<o.length;i++)gv.add(o[i])}var NN=RegExp("^[: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]*$"),vv={},bv={};function EN(i){return Kt.call(bv,i)?!0:Kt.call(vv,i)?!1:NN.test(i)?bv[i]=!0:(vv[i]=!0,!1)}function xu(i,o,u){if(EN(o))if(u===null)i.removeAttribute(o);else{switch(typeof u){case"undefined":case"function":case"symbol":i.removeAttribute(o);return;case"boolean":var p=o.toLowerCase().slice(0,5);if(p!=="data-"&&p!=="aria-"){i.removeAttribute(o);return}}i.setAttribute(o,""+u)}}function vu(i,o,u){if(u===null)i.removeAttribute(o);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(o);return}i.setAttribute(o,""+u)}}function Nr(i,o,u,p){if(p===null)i.removeAttribute(u);else{switch(typeof p){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(u);return}i.setAttributeNS(o,u,""+p)}}function Dn(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function _v(i){var o=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function MN(i,o,u){var p=Object.getOwnPropertyDescriptor(i.constructor.prototype,o);if(!i.hasOwnProperty(o)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var x=p.get,b=p.set;return Object.defineProperty(i,o,{configurable:!0,get:function(){return x.call(this)},set:function(C){u=""+C,b.call(this,C)}}),Object.defineProperty(i,o,{enumerable:p.enumerable}),{getValue:function(){return u},setValue:function(C){u=""+C},stopTracking:function(){i._valueTracker=null,delete i[o]}}}}function af(i){if(!i._valueTracker){var o=_v(i)?"checked":"value";i._valueTracker=MN(i,o,""+i[o])}}function yv(i){if(!i)return!1;var o=i._valueTracker;if(!o)return!0;var u=o.getValue(),p="";return i&&(p=_v(i)?i.checked?"true":"false":i.value),i=p,i!==u?(o.setValue(i),!0):!1}function bu(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var TN=/[\n"\\]/g;function Ln(i){return i.replace(TN,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function of(i,o,u,p,x,b,C,D){i.name="",C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?i.type=C:i.removeAttribute("type"),o!=null?C==="number"?(o===0&&i.value===""||i.value!=o)&&(i.value=""+Dn(o)):i.value!==""+Dn(o)&&(i.value=""+Dn(o)):C!=="submit"&&C!=="reset"||i.removeAttribute("value"),o!=null?lf(i,C,Dn(o)):u!=null?lf(i,C,Dn(u)):p!=null&&i.removeAttribute("value"),x==null&&b!=null&&(i.defaultChecked=!!b),x!=null&&(i.checked=x&&typeof x!="function"&&typeof x!="symbol"),D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"?i.name=""+Dn(D):i.removeAttribute("name")}function wv(i,o,u,p,x,b,C,D){if(b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(i.type=b),o!=null||u!=null){if(!(b!=="submit"&&b!=="reset"||o!=null)){af(i);return}u=u!=null?""+Dn(u):"",o=o!=null?""+Dn(o):u,D||o===i.value||(i.value=o),i.defaultValue=o}p=p??x,p=typeof p!="function"&&typeof p!="symbol"&&!!p,i.checked=D?i.checked:!!p,i.defaultChecked=!!p,C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"&&(i.name=C),af(i)}function lf(i,o,u){o==="number"&&bu(i.ownerDocument)===i||i.defaultValue===""+u||(i.defaultValue=""+u)}function Ha(i,o,u,p){if(i=i.options,o){o={};for(var x=0;x<u.length;x++)o["$"+u[x]]=!0;for(u=0;u<i.length;u++)x=o.hasOwnProperty("$"+i[u].value),i[u].selected!==x&&(i[u].selected=x),x&&p&&(i[u].defaultSelected=!0)}else{for(u=""+Dn(u),o=null,x=0;x<i.length;x++){if(i[x].value===u){i[x].selected=!0,p&&(i[x].defaultSelected=!0);return}o!==null||i[x].disabled||(o=i[x])}o!==null&&(o.selected=!0)}}function Sv(i,o,u){if(o!=null&&(o=""+Dn(o),o!==i.value&&(i.value=o),u==null)){i.defaultValue!==o&&(i.defaultValue=o);return}i.defaultValue=u!=null?""+Dn(u):""}function jv(i,o,u,p){if(o==null){if(p!=null){if(u!=null)throw Error(n(92));if(A(p)){if(1<p.length)throw Error(n(93));p=p[0]}u=p}u==null&&(u=""),o=u}u=Dn(o),i.defaultValue=u,p=i.textContent,p===u&&p!==""&&p!==null&&(i.value=p),af(i)}function Ua(i,o){if(o){var u=i.firstChild;if(u&&u===i.lastChild&&u.nodeType===3){u.nodeValue=o;return}}i.textContent=o}var AN=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function kv(i,o,u){var p=o.indexOf("--")===0;u==null||typeof u=="boolean"||u===""?p?i.setProperty(o,""):o==="float"?i.cssFloat="":i[o]="":p?i.setProperty(o,u):typeof u!="number"||u===0||AN.has(o)?o==="float"?i.cssFloat=u:i[o]=(""+u).trim():i[o]=u+"px"}function Cv(i,o,u){if(o!=null&&typeof o!="object")throw Error(n(62));if(i=i.style,u!=null){for(var p in u)!u.hasOwnProperty(p)||o!=null&&o.hasOwnProperty(p)||(p.indexOf("--")===0?i.setProperty(p,""):p==="float"?i.cssFloat="":i[p]="");for(var x in o)p=o[x],o.hasOwnProperty(x)&&u[x]!==p&&kv(i,x,p)}else for(var b in o)o.hasOwnProperty(b)&&kv(i,b,o[b])}function cf(i){if(i.indexOf("-")===-1)return!1;switch(i){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 RN=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),DN=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function _u(i){return DN.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Er(){}var uf=null;function df(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Va=null,Wa=null;function Nv(i){var o=$a(i);if(o&&(i=o.stateNode)){var u=i[rn]||null;e:switch(i=o.stateNode,o.type){case"input":if(of(i,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name),o=u.name,u.type==="radio"&&o!=null){for(u=i;u.parentNode;)u=u.parentNode;for(u=u.querySelectorAll('input[name="'+Ln(""+o)+'"][type="radio"]'),o=0;o<u.length;o++){var p=u[o];if(p!==i&&p.form===i.form){var x=p[rn]||null;if(!x)throw Error(n(90));of(p,x.value,x.defaultValue,x.defaultValue,x.checked,x.defaultChecked,x.type,x.name)}}for(o=0;o<u.length;o++)p=u[o],p.form===i.form&&yv(p)}break e;case"textarea":Sv(i,u.value,u.defaultValue);break e;case"select":o=u.value,o!=null&&Ha(i,!!u.multiple,o,!1)}}}var hf=!1;function Ev(i,o,u){if(hf)return i(o,u);hf=!0;try{var p=i(o);return p}finally{if(hf=!1,(Va!==null||Wa!==null)&&(od(),Va&&(o=Va,i=Wa,Wa=Va=null,Nv(o),i)))for(o=0;o<i.length;o++)Nv(i[o])}}function il(i,o){var u=i.stateNode;if(u===null)return null;var p=u[rn]||null;if(p===null)return null;u=p[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(p=!p.disabled)||(i=i.type,p=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!p;break e;default:i=!1}if(i)return null;if(u&&typeof u!="function")throw Error(n(231,o,typeof u));return u}var Mr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ff=!1;if(Mr)try{var al={};Object.defineProperty(al,"passive",{get:function(){ff=!0}}),window.addEventListener("test",al,al),window.removeEventListener("test",al,al)}catch{ff=!1}var ci=null,pf=null,yu=null;function Mv(){if(yu)return yu;var i,o=pf,u=o.length,p,x="value"in ci?ci.value:ci.textContent,b=x.length;for(i=0;i<u&&o[i]===x[i];i++);var C=u-i;for(p=1;p<=C&&o[u-p]===x[b-p];p++);return yu=x.slice(i,1<p?1-p:void 0)}function wu(i){var o=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&o===13&&(i=13)):i=o,i===10&&(i=13),32<=i||i===13?i:0}function Su(){return!0}function Tv(){return!1}function an(i){function o(u,p,x,b,C){this._reactName=u,this._targetInst=x,this.type=p,this.nativeEvent=b,this.target=C,this.currentTarget=null;for(var D in i)i.hasOwnProperty(D)&&(u=i[D],this[D]=u?u(b):b[D]);return this.isDefaultPrevented=(b.defaultPrevented!=null?b.defaultPrevented:b.returnValue===!1)?Su:Tv,this.isPropagationStopped=Tv,this}return g(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var u=this.nativeEvent;u&&(u.preventDefault?u.preventDefault():typeof u.returnValue!="unknown"&&(u.returnValue=!1),this.isDefaultPrevented=Su)},stopPropagation:function(){var u=this.nativeEvent;u&&(u.stopPropagation?u.stopPropagation():typeof u.cancelBubble!="unknown"&&(u.cancelBubble=!0),this.isPropagationStopped=Su)},persist:function(){},isPersistent:Su}),o}var ea={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ju=an(ea),ol=g({},ea,{view:0,detail:0}),LN=an(ol),mf,gf,ll,ku=g({},ol,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:vf,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==ll&&(ll&&i.type==="mousemove"?(mf=i.screenX-ll.screenX,gf=i.screenY-ll.screenY):gf=mf=0,ll=i),mf)},movementY:function(i){return"movementY"in i?i.movementY:gf}}),Av=an(ku),BN=g({},ku,{dataTransfer:0}),ON=an(BN),zN=g({},ol,{relatedTarget:0}),xf=an(zN),PN=g({},ea,{animationName:0,elapsedTime:0,pseudoElement:0}),$N=an(PN),IN=g({},ea,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),FN=an(IN),HN=g({},ea,{data:0}),Rv=an(HN),UN={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},VN={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"},WN={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function qN(i){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(i):(i=WN[i])?!!o[i]:!1}function vf(){return qN}var GN=g({},ol,{key:function(i){if(i.key){var o=UN[i.key]||i.key;if(o!=="Unidentified")return o}return i.type==="keypress"?(i=wu(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?VN[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:vf,charCode:function(i){return i.type==="keypress"?wu(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?wu(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),KN=an(GN),YN=g({},ku,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Dv=an(YN),XN=g({},ol,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:vf}),JN=an(XN),QN=g({},ea,{propertyName:0,elapsedTime:0,pseudoElement:0}),ZN=an(QN),e3=g({},ku,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),t3=an(e3),s3=g({},ea,{newState:0,oldState:0}),n3=an(s3),r3=[9,13,27,32],bf=Mr&&"CompositionEvent"in window,cl=null;Mr&&"documentMode"in document&&(cl=document.documentMode);var i3=Mr&&"TextEvent"in window&&!cl,Lv=Mr&&(!bf||cl&&8<cl&&11>=cl),Bv=" ",Ov=!1;function zv(i,o){switch(i){case"keyup":return r3.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pv(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var qa=!1;function a3(i,o){switch(i){case"compositionend":return Pv(o);case"keypress":return o.which!==32?null:(Ov=!0,Bv);case"textInput":return i=o.data,i===Bv&&Ov?null:i;default:return null}}function o3(i,o){if(qa)return i==="compositionend"||!bf&&zv(i,o)?(i=Mv(),yu=pf=ci=null,qa=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return Lv&&o.locale!=="ko"?null:o.data;default:return null}}var l3={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 $v(i){var o=i&&i.nodeName&&i.nodeName.toLowerCase();return o==="input"?!!l3[i.type]:o==="textarea"}function Iv(i,o,u,p){Va?Wa?Wa.push(p):Wa=[p]:Va=p,o=pd(o,"onChange"),0<o.length&&(u=new ju("onChange","change",null,u,p),i.push({event:u,listeners:o}))}var ul=null,dl=null;function c3(i){w_(i,0)}function Cu(i){var o=rl(i);if(yv(o))return i}function Fv(i,o){if(i==="change")return o}var Hv=!1;if(Mr){var _f;if(Mr){var yf="oninput"in document;if(!yf){var Uv=document.createElement("div");Uv.setAttribute("oninput","return;"),yf=typeof Uv.oninput=="function"}_f=yf}else _f=!1;Hv=_f&&(!document.documentMode||9<document.documentMode)}function Vv(){ul&&(ul.detachEvent("onpropertychange",Wv),dl=ul=null)}function Wv(i){if(i.propertyName==="value"&&Cu(dl)){var o=[];Iv(o,dl,i,df(i)),Ev(c3,o)}}function u3(i,o,u){i==="focusin"?(Vv(),ul=o,dl=u,ul.attachEvent("onpropertychange",Wv)):i==="focusout"&&Vv()}function d3(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Cu(dl)}function h3(i,o){if(i==="click")return Cu(o)}function f3(i,o){if(i==="input"||i==="change")return Cu(o)}function p3(i,o){return i===o&&(i!==0||1/i===1/o)||i!==i&&o!==o}var bn=typeof Object.is=="function"?Object.is:p3;function hl(i,o){if(bn(i,o))return!0;if(typeof i!="object"||i===null||typeof o!="object"||o===null)return!1;var u=Object.keys(i),p=Object.keys(o);if(u.length!==p.length)return!1;for(p=0;p<u.length;p++){var x=u[p];if(!Kt.call(o,x)||!bn(i[x],o[x]))return!1}return!0}function qv(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Gv(i,o){var u=qv(i);i=0;for(var p;u;){if(u.nodeType===3){if(p=i+u.textContent.length,i<=o&&p>=o)return{node:u,offset:o-i};i=p}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=qv(u)}}function Kv(i,o){return i&&o?i===o?!0:i&&i.nodeType===3?!1:o&&o.nodeType===3?Kv(i,o.parentNode):"contains"in i?i.contains(o):i.compareDocumentPosition?!!(i.compareDocumentPosition(o)&16):!1:!1}function Yv(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var o=bu(i.document);o instanceof i.HTMLIFrameElement;){try{var u=typeof o.contentWindow.location.href=="string"}catch{u=!1}if(u)i=o.contentWindow;else break;o=bu(i.document)}return o}function wf(i){var o=i&&i.nodeName&&i.nodeName.toLowerCase();return o&&(o==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||o==="textarea"||i.contentEditable==="true")}var m3=Mr&&"documentMode"in document&&11>=document.documentMode,Ga=null,Sf=null,fl=null,jf=!1;function Xv(i,o,u){var p=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;jf||Ga==null||Ga!==bu(p)||(p=Ga,"selectionStart"in p&&wf(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),fl&&hl(fl,p)||(fl=p,p=pd(Sf,"onSelect"),0<p.length&&(o=new ju("onSelect","select",null,o,u),i.push({event:o,listeners:p}),o.target=Ga)))}function ta(i,o){var u={};return u[i.toLowerCase()]=o.toLowerCase(),u["Webkit"+i]="webkit"+o,u["Moz"+i]="moz"+o,u}var Ka={animationend:ta("Animation","AnimationEnd"),animationiteration:ta("Animation","AnimationIteration"),animationstart:ta("Animation","AnimationStart"),transitionrun:ta("Transition","TransitionRun"),transitionstart:ta("Transition","TransitionStart"),transitioncancel:ta("Transition","TransitionCancel"),transitionend:ta("Transition","TransitionEnd")},kf={},Jv={};Mr&&(Jv=document.createElement("div").style,"AnimationEvent"in window||(delete Ka.animationend.animation,delete Ka.animationiteration.animation,delete Ka.animationstart.animation),"TransitionEvent"in window||delete Ka.transitionend.transition);function sa(i){if(kf[i])return kf[i];if(!Ka[i])return i;var o=Ka[i],u;for(u in o)if(o.hasOwnProperty(u)&&u in Jv)return kf[i]=o[u];return i}var Qv=sa("animationend"),Zv=sa("animationiteration"),e1=sa("animationstart"),g3=sa("transitionrun"),x3=sa("transitionstart"),v3=sa("transitioncancel"),t1=sa("transitionend"),s1=new Map,Cf="abort auxClick beforeToggle 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(" ");Cf.push("scrollEnd");function Jn(i,o){s1.set(i,o),Zi(o,[i])}var Nu=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var o=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(o))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Bn=[],Ya=0,Nf=0;function Eu(){for(var i=Ya,o=Nf=Ya=0;o<i;){var u=Bn[o];Bn[o++]=null;var p=Bn[o];Bn[o++]=null;var x=Bn[o];Bn[o++]=null;var b=Bn[o];if(Bn[o++]=null,p!==null&&x!==null){var C=p.pending;C===null?x.next=x:(x.next=C.next,C.next=x),p.pending=x}b!==0&&n1(u,x,b)}}function Mu(i,o,u,p){Bn[Ya++]=i,Bn[Ya++]=o,Bn[Ya++]=u,Bn[Ya++]=p,Nf|=p,i.lanes|=p,i=i.alternate,i!==null&&(i.lanes|=p)}function Ef(i,o,u,p){return Mu(i,o,u,p),Tu(i)}function na(i,o){return Mu(i,null,null,o),Tu(i)}function n1(i,o,u){i.lanes|=u;var p=i.alternate;p!==null&&(p.lanes|=u);for(var x=!1,b=i.return;b!==null;)b.childLanes|=u,p=b.alternate,p!==null&&(p.childLanes|=u),b.tag===22&&(i=b.stateNode,i===null||i._visibility&1||(x=!0)),i=b,b=b.return;return i.tag===3?(b=i.stateNode,x&&o!==null&&(x=31-ee(u),i=b.hiddenUpdates,p=i[x],p===null?i[x]=[o]:p.push(o),o.lane=u|536870912),b):null}function Tu(i){if(50<Bl)throw Bl=0,zp=null,Error(n(185));for(var o=i.return;o!==null;)i=o,o=i.return;return i.tag===3?i.stateNode:null}var Xa={};function b3(i,o,u,p){this.tag=i,this.key=u,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=p,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _n(i,o,u,p){return new b3(i,o,u,p)}function Mf(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Tr(i,o){var u=i.alternate;return u===null?(u=_n(i.tag,o,i.key,i.mode),u.elementType=i.elementType,u.type=i.type,u.stateNode=i.stateNode,u.alternate=i,i.alternate=u):(u.pendingProps=o,u.type=i.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=i.flags&65011712,u.childLanes=i.childLanes,u.lanes=i.lanes,u.child=i.child,u.memoizedProps=i.memoizedProps,u.memoizedState=i.memoizedState,u.updateQueue=i.updateQueue,o=i.dependencies,u.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},u.sibling=i.sibling,u.index=i.index,u.ref=i.ref,u.refCleanup=i.refCleanup,u}function r1(i,o){i.flags&=65011714;var u=i.alternate;return u===null?(i.childLanes=0,i.lanes=o,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=u.childLanes,i.lanes=u.lanes,i.child=u.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=u.memoizedProps,i.memoizedState=u.memoizedState,i.updateQueue=u.updateQueue,i.type=u.type,o=u.dependencies,i.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),i}function Au(i,o,u,p,x,b){var C=0;if(p=i,typeof i=="function")Mf(i)&&(C=1);else if(typeof i=="string")C=j4(i,u,oe.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case W:return i=_n(31,u,o,x),i.elementType=W,i.lanes=b,i;case S:return ra(u.children,x,b,o);case j:C=8,x|=24;break;case k:return i=_n(12,u,o,x|2),i.elementType=k,i.lanes=b,i;case F:return i=_n(13,u,o,x),i.elementType=F,i.lanes=b,i;case $:return i=_n(19,u,o,x),i.elementType=$,i.lanes=b,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case E:C=10;break e;case N:C=9;break e;case B:C=11;break e;case K:C=14;break e;case Y:C=16,p=null;break e}C=29,u=Error(n(130,i===null?"null":typeof i,"")),p=null}return o=_n(C,u,o,x),o.elementType=i,o.type=p,o.lanes=b,o}function ra(i,o,u,p){return i=_n(7,i,p,o),i.lanes=u,i}function Tf(i,o,u){return i=_n(6,i,null,o),i.lanes=u,i}function i1(i){var o=_n(18,null,null,0);return o.stateNode=i,o}function Af(i,o,u){return o=_n(4,i.children!==null?i.children:[],i.key,o),o.lanes=u,o.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},o}var a1=new WeakMap;function On(i,o){if(typeof i=="object"&&i!==null){var u=a1.get(i);return u!==void 0?u:(o={value:i,source:o,stack:ts(o)},a1.set(i,o),o)}return{value:i,source:o,stack:ts(o)}}var Ja=[],Qa=0,Ru=null,pl=0,zn=[],Pn=0,ui=null,or=1,lr="";function Ar(i,o){Ja[Qa++]=pl,Ja[Qa++]=Ru,Ru=i,pl=o}function o1(i,o,u){zn[Pn++]=or,zn[Pn++]=lr,zn[Pn++]=ui,ui=i;var p=or;i=lr;var x=32-ee(p)-1;p&=~(1<<x),u+=1;var b=32-ee(o)+x;if(30<b){var C=x-x%5;b=(p&(1<<C)-1).toString(32),p>>=C,x-=C,or=1<<32-ee(o)+x|u<<x|p,lr=b+i}else or=1<<b|u<<x|p,lr=i}function Rf(i){i.return!==null&&(Ar(i,1),o1(i,1,0))}function Df(i){for(;i===Ru;)Ru=Ja[--Qa],Ja[Qa]=null,pl=Ja[--Qa],Ja[Qa]=null;for(;i===ui;)ui=zn[--Pn],zn[Pn]=null,lr=zn[--Pn],zn[Pn]=null,or=zn[--Pn],zn[Pn]=null}function l1(i,o){zn[Pn++]=or,zn[Pn++]=lr,zn[Pn++]=ui,or=o.id,lr=o.overflow,ui=i}var Ds=null,zt=null,dt=!1,di=null,$n=!1,Lf=Error(n(519));function hi(i){var o=Error(n(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ml(On(o,i)),Lf}function c1(i){var o=i.stateNode,u=i.type,p=i.memoizedProps;switch(o[Rs]=i,o[rn]=p,u){case"dialog":it("cancel",o),it("close",o);break;case"iframe":case"object":case"embed":it("load",o);break;case"video":case"audio":for(u=0;u<zl.length;u++)it(zl[u],o);break;case"source":it("error",o);break;case"img":case"image":case"link":it("error",o),it("load",o);break;case"details":it("toggle",o);break;case"input":it("invalid",o),wv(o,p.value,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name,!0);break;case"select":it("invalid",o);break;case"textarea":it("invalid",o),jv(o,p.value,p.defaultValue,p.children)}u=p.children,typeof u!="string"&&typeof u!="number"&&typeof u!="bigint"||o.textContent===""+u||p.suppressHydrationWarning===!0||C_(o.textContent,u)?(p.popover!=null&&(it("beforetoggle",o),it("toggle",o)),p.onScroll!=null&&it("scroll",o),p.onScrollEnd!=null&&it("scrollend",o),p.onClick!=null&&(o.onclick=Er),o=!0):o=!1,o||hi(i,!0)}function u1(i){for(Ds=i.return;Ds;)switch(Ds.tag){case 5:case 31:case 13:$n=!1;return;case 27:case 3:$n=!0;return;default:Ds=Ds.return}}function Za(i){if(i!==Ds)return!1;if(!dt)return u1(i),dt=!0,!1;var o=i.tag,u;if((u=o!==3&&o!==27)&&((u=o===5)&&(u=i.type,u=!(u!=="form"&&u!=="button")||Qp(i.type,i.memoizedProps)),u=!u),u&&zt&&hi(i),u1(i),o===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));zt=B_(i)}else if(o===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));zt=B_(i)}else o===27?(o=zt,Ci(i.type)?(i=nm,nm=null,zt=i):zt=o):zt=Ds?Fn(i.stateNode.nextSibling):null;return!0}function ia(){zt=Ds=null,dt=!1}function Bf(){var i=di;return i!==null&&(un===null?un=i:un.push.apply(un,i),di=null),i}function ml(i){di===null?di=[i]:di.push(i)}var Of=P(null),aa=null,Rr=null;function fi(i,o,u){T(Of,o._currentValue),o._currentValue=u}function Dr(i){i._currentValue=Of.current,z(Of)}function zf(i,o,u){for(;i!==null;){var p=i.alternate;if((i.childLanes&o)!==o?(i.childLanes|=o,p!==null&&(p.childLanes|=o)):p!==null&&(p.childLanes&o)!==o&&(p.childLanes|=o),i===u)break;i=i.return}}function Pf(i,o,u,p){var x=i.child;for(x!==null&&(x.return=i);x!==null;){var b=x.dependencies;if(b!==null){var C=x.child;b=b.firstContext;e:for(;b!==null;){var D=b;b=x;for(var J=0;J<o.length;J++)if(D.context===o[J]){b.lanes|=u,D=b.alternate,D!==null&&(D.lanes|=u),zf(b.return,u,i),p||(C=null);break e}b=D.next}}else if(x.tag===18){if(C=x.return,C===null)throw Error(n(341));C.lanes|=u,b=C.alternate,b!==null&&(b.lanes|=u),zf(C,u,i),C=null}else C=x.child;if(C!==null)C.return=x;else for(C=x;C!==null;){if(C===i){C=null;break}if(x=C.sibling,x!==null){x.return=C.return,C=x;break}C=C.return}x=C}}function eo(i,o,u,p){i=null;for(var x=o,b=!1;x!==null;){if(!b){if((x.flags&524288)!==0)b=!0;else if((x.flags&262144)!==0)break}if(x.tag===10){var C=x.alternate;if(C===null)throw Error(n(387));if(C=C.memoizedProps,C!==null){var D=x.type;bn(x.pendingProps.value,C.value)||(i!==null?i.push(D):i=[D])}}else if(x===ve.current){if(C=x.alternate,C===null)throw Error(n(387));C.memoizedState.memoizedState!==x.memoizedState.memoizedState&&(i!==null?i.push(Hl):i=[Hl])}x=x.return}i!==null&&Pf(o,i,u,p),o.flags|=262144}function Du(i){for(i=i.firstContext;i!==null;){if(!bn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function oa(i){aa=i,Rr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Ls(i){return d1(aa,i)}function Lu(i,o){return aa===null&&oa(i),d1(i,o)}function d1(i,o){var u=o._currentValue;if(o={context:o,memoizedValue:u,next:null},Rr===null){if(i===null)throw Error(n(308));Rr=o,i.dependencies={lanes:0,firstContext:o},i.flags|=524288}else Rr=Rr.next=o;return u}var _3=typeof AbortController<"u"?AbortController:function(){var i=[],o=this.signal={aborted:!1,addEventListener:function(u,p){i.push(p)}};this.abort=function(){o.aborted=!0,i.forEach(function(u){return u()})}},y3=e.unstable_scheduleCallback,w3=e.unstable_NormalPriority,os={$$typeof:E,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function $f(){return{controller:new _3,data:new Map,refCount:0}}function gl(i){i.refCount--,i.refCount===0&&y3(w3,function(){i.controller.abort()})}var xl=null,If=0,to=0,so=null;function S3(i,o){if(xl===null){var u=xl=[];If=0,to=Up(),so={status:"pending",value:void 0,then:function(p){u.push(p)}}}return If++,o.then(h1,h1),o}function h1(){if(--If===0&&xl!==null){so!==null&&(so.status="fulfilled");var i=xl;xl=null,to=0,so=null;for(var o=0;o<i.length;o++)(0,i[o])()}}function j3(i,o){var u=[],p={status:"pending",value:null,reason:null,then:function(x){u.push(x)}};return i.then(function(){p.status="fulfilled",p.value=o;for(var x=0;x<u.length;x++)(0,u[x])(o)},function(x){for(p.status="rejected",p.reason=x,x=0;x<u.length;x++)(0,u[x])(void 0)}),p}var f1=M.S;M.S=function(i,o){Xb=vt(),typeof o=="object"&&o!==null&&typeof o.then=="function"&&S3(i,o),f1!==null&&f1(i,o)};var la=P(null);function Ff(){var i=la.current;return i!==null?i:Mt.pooledCache}function Bu(i,o){o===null?T(la,la.current):T(la,o.pool)}function p1(){var i=Ff();return i===null?null:{parent:os._currentValue,pool:i}}var no=Error(n(460)),Hf=Error(n(474)),Ou=Error(n(542)),zu={then:function(){}};function m1(i){return i=i.status,i==="fulfilled"||i==="rejected"}function g1(i,o,u){switch(u=i[u],u===void 0?i.push(o):u!==o&&(o.then(Er,Er),o=u),o.status){case"fulfilled":return o.value;case"rejected":throw i=o.reason,v1(i),i;default:if(typeof o.status=="string")o.then(Er,Er);else{if(i=Mt,i!==null&&100<i.shellSuspendCounter)throw Error(n(482));i=o,i.status="pending",i.then(function(p){if(o.status==="pending"){var x=o;x.status="fulfilled",x.value=p}},function(p){if(o.status==="pending"){var x=o;x.status="rejected",x.reason=p}})}switch(o.status){case"fulfilled":return o.value;case"rejected":throw i=o.reason,v1(i),i}throw ua=o,no}}function ca(i){try{var o=i._init;return o(i._payload)}catch(u){throw u!==null&&typeof u=="object"&&typeof u.then=="function"?(ua=u,no):u}}var ua=null;function x1(){if(ua===null)throw Error(n(459));var i=ua;return ua=null,i}function v1(i){if(i===no||i===Ou)throw Error(n(483))}var ro=null,vl=0;function Pu(i){var o=vl;return vl+=1,ro===null&&(ro=[]),g1(ro,i,o)}function bl(i,o){o=o.props.ref,i.ref=o!==void 0?o:null}function $u(i,o){throw o.$$typeof===_?Error(n(525)):(i=Object.prototype.toString.call(o),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":i)))}function b1(i){function o(te,Z){if(i){var ie=te.deletions;ie===null?(te.deletions=[Z],te.flags|=16):ie.push(Z)}}function u(te,Z){if(!i)return null;for(;Z!==null;)o(te,Z),Z=Z.sibling;return null}function p(te){for(var Z=new Map;te!==null;)te.key!==null?Z.set(te.key,te):Z.set(te.index,te),te=te.sibling;return Z}function x(te,Z){return te=Tr(te,Z),te.index=0,te.sibling=null,te}function b(te,Z,ie){return te.index=ie,i?(ie=te.alternate,ie!==null?(ie=ie.index,ie<Z?(te.flags|=67108866,Z):ie):(te.flags|=67108866,Z)):(te.flags|=1048576,Z)}function C(te){return i&&te.alternate===null&&(te.flags|=67108866),te}function D(te,Z,ie,me){return Z===null||Z.tag!==6?(Z=Tf(ie,te.mode,me),Z.return=te,Z):(Z=x(Z,ie),Z.return=te,Z)}function J(te,Z,ie,me){var Fe=ie.type;return Fe===S?pe(te,Z,ie.props.children,me,ie.key):Z!==null&&(Z.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===Y&&ca(Fe)===Z.type)?(Z=x(Z,ie.props),bl(Z,ie),Z.return=te,Z):(Z=Au(ie.type,ie.key,ie.props,null,te.mode,me),bl(Z,ie),Z.return=te,Z)}function ae(te,Z,ie,me){return Z===null||Z.tag!==4||Z.stateNode.containerInfo!==ie.containerInfo||Z.stateNode.implementation!==ie.implementation?(Z=Af(ie,te.mode,me),Z.return=te,Z):(Z=x(Z,ie.children||[]),Z.return=te,Z)}function pe(te,Z,ie,me,Fe){return Z===null||Z.tag!==7?(Z=ra(ie,te.mode,me,Fe),Z.return=te,Z):(Z=x(Z,ie),Z.return=te,Z)}function ge(te,Z,ie){if(typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint")return Z=Tf(""+Z,te.mode,ie),Z.return=te,Z;if(typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case v:return ie=Au(Z.type,Z.key,Z.props,null,te.mode,ie),bl(ie,Z),ie.return=te,ie;case y:return Z=Af(Z,te.mode,ie),Z.return=te,Z;case Y:return Z=ca(Z),ge(te,Z,ie)}if(A(Z)||V(Z))return Z=ra(Z,te.mode,ie,null),Z.return=te,Z;if(typeof Z.then=="function")return ge(te,Pu(Z),ie);if(Z.$$typeof===E)return ge(te,Lu(te,Z),ie);$u(te,Z)}return null}function le(te,Z,ie,me){var Fe=Z!==null?Z.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint")return Fe!==null?null:D(te,Z,""+ie,me);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case v:return ie.key===Fe?J(te,Z,ie,me):null;case y:return ie.key===Fe?ae(te,Z,ie,me):null;case Y:return ie=ca(ie),le(te,Z,ie,me)}if(A(ie)||V(ie))return Fe!==null?null:pe(te,Z,ie,me,null);if(typeof ie.then=="function")return le(te,Z,Pu(ie),me);if(ie.$$typeof===E)return le(te,Z,Lu(te,ie),me);$u(te,ie)}return null}function ue(te,Z,ie,me,Fe){if(typeof me=="string"&&me!==""||typeof me=="number"||typeof me=="bigint")return te=te.get(ie)||null,D(Z,te,""+me,Fe);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case v:return te=te.get(me.key===null?ie:me.key)||null,J(Z,te,me,Fe);case y:return te=te.get(me.key===null?ie:me.key)||null,ae(Z,te,me,Fe);case Y:return me=ca(me),ue(te,Z,ie,me,Fe)}if(A(me)||V(me))return te=te.get(ie)||null,pe(Z,te,me,Fe,null);if(typeof me.then=="function")return ue(te,Z,ie,Pu(me),Fe);if(me.$$typeof===E)return ue(te,Z,ie,Lu(Z,me),Fe);$u(Z,me)}return null}function De(te,Z,ie,me){for(var Fe=null,gt=null,Oe=Z,et=Z=0,ct=null;Oe!==null&&et<ie.length;et++){Oe.index>et?(ct=Oe,Oe=null):ct=Oe.sibling;var xt=le(te,Oe,ie[et],me);if(xt===null){Oe===null&&(Oe=ct);break}i&&Oe&&xt.alternate===null&&o(te,Oe),Z=b(xt,Z,et),gt===null?Fe=xt:gt.sibling=xt,gt=xt,Oe=ct}if(et===ie.length)return u(te,Oe),dt&&Ar(te,et),Fe;if(Oe===null){for(;et<ie.length;et++)Oe=ge(te,ie[et],me),Oe!==null&&(Z=b(Oe,Z,et),gt===null?Fe=Oe:gt.sibling=Oe,gt=Oe);return dt&&Ar(te,et),Fe}for(Oe=p(Oe);et<ie.length;et++)ct=ue(Oe,te,et,ie[et],me),ct!==null&&(i&&ct.alternate!==null&&Oe.delete(ct.key===null?et:ct.key),Z=b(ct,Z,et),gt===null?Fe=ct:gt.sibling=ct,gt=ct);return i&&Oe.forEach(function(Ai){return o(te,Ai)}),dt&&Ar(te,et),Fe}function Ve(te,Z,ie,me){if(ie==null)throw Error(n(151));for(var Fe=null,gt=null,Oe=Z,et=Z=0,ct=null,xt=ie.next();Oe!==null&&!xt.done;et++,xt=ie.next()){Oe.index>et?(ct=Oe,Oe=null):ct=Oe.sibling;var Ai=le(te,Oe,xt.value,me);if(Ai===null){Oe===null&&(Oe=ct);break}i&&Oe&&Ai.alternate===null&&o(te,Oe),Z=b(Ai,Z,et),gt===null?Fe=Ai:gt.sibling=Ai,gt=Ai,Oe=ct}if(xt.done)return u(te,Oe),dt&&Ar(te,et),Fe;if(Oe===null){for(;!xt.done;et++,xt=ie.next())xt=ge(te,xt.value,me),xt!==null&&(Z=b(xt,Z,et),gt===null?Fe=xt:gt.sibling=xt,gt=xt);return dt&&Ar(te,et),Fe}for(Oe=p(Oe);!xt.done;et++,xt=ie.next())xt=ue(Oe,te,et,xt.value,me),xt!==null&&(i&&xt.alternate!==null&&Oe.delete(xt.key===null?et:xt.key),Z=b(xt,Z,et),gt===null?Fe=xt:gt.sibling=xt,gt=xt);return i&&Oe.forEach(function(B4){return o(te,B4)}),dt&&Ar(te,et),Fe}function Nt(te,Z,ie,me){if(typeof ie=="object"&&ie!==null&&ie.type===S&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case v:e:{for(var Fe=ie.key;Z!==null;){if(Z.key===Fe){if(Fe=ie.type,Fe===S){if(Z.tag===7){u(te,Z.sibling),me=x(Z,ie.props.children),me.return=te,te=me;break e}}else if(Z.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===Y&&ca(Fe)===Z.type){u(te,Z.sibling),me=x(Z,ie.props),bl(me,ie),me.return=te,te=me;break e}u(te,Z);break}else o(te,Z);Z=Z.sibling}ie.type===S?(me=ra(ie.props.children,te.mode,me,ie.key),me.return=te,te=me):(me=Au(ie.type,ie.key,ie.props,null,te.mode,me),bl(me,ie),me.return=te,te=me)}return C(te);case y:e:{for(Fe=ie.key;Z!==null;){if(Z.key===Fe)if(Z.tag===4&&Z.stateNode.containerInfo===ie.containerInfo&&Z.stateNode.implementation===ie.implementation){u(te,Z.sibling),me=x(Z,ie.children||[]),me.return=te,te=me;break e}else{u(te,Z);break}else o(te,Z);Z=Z.sibling}me=Af(ie,te.mode,me),me.return=te,te=me}return C(te);case Y:return ie=ca(ie),Nt(te,Z,ie,me)}if(A(ie))return De(te,Z,ie,me);if(V(ie)){if(Fe=V(ie),typeof Fe!="function")throw Error(n(150));return ie=Fe.call(ie),Ve(te,Z,ie,me)}if(typeof ie.then=="function")return Nt(te,Z,Pu(ie),me);if(ie.$$typeof===E)return Nt(te,Z,Lu(te,ie),me);$u(te,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint"?(ie=""+ie,Z!==null&&Z.tag===6?(u(te,Z.sibling),me=x(Z,ie),me.return=te,te=me):(u(te,Z),me=Tf(ie,te.mode,me),me.return=te,te=me),C(te)):u(te,Z)}return function(te,Z,ie,me){try{vl=0;var Fe=Nt(te,Z,ie,me);return ro=null,Fe}catch(Oe){if(Oe===no||Oe===Ou)throw Oe;var gt=_n(29,Oe,null,te.mode);return gt.lanes=me,gt.return=te,gt}finally{}}}var da=b1(!0),_1=b1(!1),pi=!1;function Uf(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Vf(i,o){i=i.updateQueue,o.updateQueue===i&&(o.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function mi(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function gi(i,o,u){var p=i.updateQueue;if(p===null)return null;if(p=p.shared,(bt&2)!==0){var x=p.pending;return x===null?o.next=o:(o.next=x.next,x.next=o),p.pending=o,o=Tu(i),n1(i,null,u),o}return Mu(i,p,o,u),Tu(i)}function _l(i,o,u){if(o=o.updateQueue,o!==null&&(o=o.shared,(u&4194048)!==0)){var p=o.lanes;p&=i.pendingLanes,u|=p,o.lanes=u,ar(i,u)}}function Wf(i,o){var u=i.updateQueue,p=i.alternate;if(p!==null&&(p=p.updateQueue,u===p)){var x=null,b=null;if(u=u.firstBaseUpdate,u!==null){do{var C={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};b===null?x=b=C:b=b.next=C,u=u.next}while(u!==null);b===null?x=b=o:b=b.next=o}else x=b=o;u={baseState:p.baseState,firstBaseUpdate:x,lastBaseUpdate:b,shared:p.shared,callbacks:p.callbacks},i.updateQueue=u;return}i=u.lastBaseUpdate,i===null?u.firstBaseUpdate=o:i.next=o,u.lastBaseUpdate=o}var qf=!1;function yl(){if(qf){var i=so;if(i!==null)throw i}}function wl(i,o,u,p){qf=!1;var x=i.updateQueue;pi=!1;var b=x.firstBaseUpdate,C=x.lastBaseUpdate,D=x.shared.pending;if(D!==null){x.shared.pending=null;var J=D,ae=J.next;J.next=null,C===null?b=ae:C.next=ae,C=J;var pe=i.alternate;pe!==null&&(pe=pe.updateQueue,D=pe.lastBaseUpdate,D!==C&&(D===null?pe.firstBaseUpdate=ae:D.next=ae,pe.lastBaseUpdate=J))}if(b!==null){var ge=x.baseState;C=0,pe=ae=J=null,D=b;do{var le=D.lane&-536870913,ue=le!==D.lane;if(ue?(lt&le)===le:(p&le)===le){le!==0&&le===to&&(qf=!0),pe!==null&&(pe=pe.next={lane:0,tag:D.tag,payload:D.payload,callback:null,next:null});e:{var De=i,Ve=D;le=o;var Nt=u;switch(Ve.tag){case 1:if(De=Ve.payload,typeof De=="function"){ge=De.call(Nt,ge,le);break e}ge=De;break e;case 3:De.flags=De.flags&-65537|128;case 0:if(De=Ve.payload,le=typeof De=="function"?De.call(Nt,ge,le):De,le==null)break e;ge=g({},ge,le);break e;case 2:pi=!0}}le=D.callback,le!==null&&(i.flags|=64,ue&&(i.flags|=8192),ue=x.callbacks,ue===null?x.callbacks=[le]:ue.push(le))}else ue={lane:le,tag:D.tag,payload:D.payload,callback:D.callback,next:null},pe===null?(ae=pe=ue,J=ge):pe=pe.next=ue,C|=le;if(D=D.next,D===null){if(D=x.shared.pending,D===null)break;ue=D,D=ue.next,ue.next=null,x.lastBaseUpdate=ue,x.shared.pending=null}}while(!0);pe===null&&(J=ge),x.baseState=J,x.firstBaseUpdate=ae,x.lastBaseUpdate=pe,b===null&&(x.shared.lanes=0),yi|=C,i.lanes=C,i.memoizedState=ge}}function y1(i,o){if(typeof i!="function")throw Error(n(191,i));i.call(o)}function w1(i,o){var u=i.callbacks;if(u!==null)for(i.callbacks=null,i=0;i<u.length;i++)y1(u[i],o)}var io=P(null),Iu=P(0);function S1(i,o){i=Hr,T(Iu,i),T(io,o),Hr=i|o.baseLanes}function Gf(){T(Iu,Hr),T(io,io.current)}function Kf(){Hr=Iu.current,z(io),z(Iu)}var yn=P(null),In=null;function xi(i){var o=i.alternate;T(ns,ns.current&1),T(yn,i),In===null&&(o===null||io.current!==null||o.memoizedState!==null)&&(In=i)}function Yf(i){T(ns,ns.current),T(yn,i),In===null&&(In=i)}function j1(i){i.tag===22?(T(ns,ns.current),T(yn,i),In===null&&(In=i)):vi()}function vi(){T(ns,ns.current),T(yn,yn.current)}function wn(i){z(yn),In===i&&(In=null),z(ns)}var ns=P(0);function Fu(i){for(var o=i;o!==null;){if(o.tag===13){var u=o.memoizedState;if(u!==null&&(u=u.dehydrated,u===null||tm(u)||sm(u)))return o}else if(o.tag===19&&(o.memoizedProps.revealOrder==="forwards"||o.memoizedProps.revealOrder==="backwards"||o.memoizedProps.revealOrder==="unstable_legacy-backwards"||o.memoizedProps.revealOrder==="together")){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===i)break;for(;o.sibling===null;){if(o.return===null||o.return===i)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Lr=0,Qe=null,kt=null,ls=null,Hu=!1,ao=!1,ha=!1,Uu=0,Sl=0,oo=null,k3=0;function Jt(){throw Error(n(321))}function Xf(i,o){if(o===null)return!1;for(var u=0;u<o.length&&u<i.length;u++)if(!bn(i[u],o[u]))return!1;return!0}function Jf(i,o,u,p,x,b){return Lr=b,Qe=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,M.H=i===null||i.memoizedState===null?ob:hp,ha=!1,b=u(p,x),ha=!1,ao&&(b=C1(o,u,p,x)),k1(i),b}function k1(i){M.H=Cl;var o=kt!==null&&kt.next!==null;if(Lr=0,ls=kt=Qe=null,Hu=!1,Sl=0,oo=null,o)throw Error(n(300));i===null||cs||(i=i.dependencies,i!==null&&Du(i)&&(cs=!0))}function C1(i,o,u,p){Qe=i;var x=0;do{if(ao&&(oo=null),Sl=0,ao=!1,25<=x)throw Error(n(301));if(x+=1,ls=kt=null,i.updateQueue!=null){var b=i.updateQueue;b.lastEffect=null,b.events=null,b.stores=null,b.memoCache!=null&&(b.memoCache.index=0)}M.H=lb,b=o(u,p)}while(ao);return b}function C3(){var i=M.H,o=i.useState()[0];return o=typeof o.then=="function"?jl(o):o,i=i.useState()[0],(kt!==null?kt.memoizedState:null)!==i&&(Qe.flags|=1024),o}function Qf(){var i=Uu!==0;return Uu=0,i}function Zf(i,o,u){o.updateQueue=i.updateQueue,o.flags&=-2053,i.lanes&=~u}function ep(i){if(Hu){for(i=i.memoizedState;i!==null;){var o=i.queue;o!==null&&(o.pending=null),i=i.next}Hu=!1}Lr=0,ls=kt=Qe=null,ao=!1,Sl=Uu=0,oo=null}function Gs(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ls===null?Qe.memoizedState=ls=i:ls=ls.next=i,ls}function rs(){if(kt===null){var i=Qe.alternate;i=i!==null?i.memoizedState:null}else i=kt.next;var o=ls===null?Qe.memoizedState:ls.next;if(o!==null)ls=o,kt=i;else{if(i===null)throw Qe.alternate===null?Error(n(467)):Error(n(310));kt=i,i={memoizedState:kt.memoizedState,baseState:kt.baseState,baseQueue:kt.baseQueue,queue:kt.queue,next:null},ls===null?Qe.memoizedState=ls=i:ls=ls.next=i}return ls}function Vu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function jl(i){var o=Sl;return Sl+=1,oo===null&&(oo=[]),i=g1(oo,i,o),o=Qe,(ls===null?o.memoizedState:ls.next)===null&&(o=o.alternate,M.H=o===null||o.memoizedState===null?ob:hp),i}function Wu(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return jl(i);if(i.$$typeof===E)return Ls(i)}throw Error(n(438,String(i)))}function tp(i){var o=null,u=Qe.updateQueue;if(u!==null&&(o=u.memoCache),o==null){var p=Qe.alternate;p!==null&&(p=p.updateQueue,p!==null&&(p=p.memoCache,p!=null&&(o={data:p.data.map(function(x){return x.slice()}),index:0})))}if(o==null&&(o={data:[],index:0}),u===null&&(u=Vu(),Qe.updateQueue=u),u.memoCache=o,u=o.data[o.index],u===void 0)for(u=o.data[o.index]=Array(i),p=0;p<i;p++)u[p]=L;return o.index++,u}function Br(i,o){return typeof o=="function"?o(i):o}function qu(i){var o=rs();return sp(o,kt,i)}function sp(i,o,u){var p=i.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=u;var x=i.baseQueue,b=p.pending;if(b!==null){if(x!==null){var C=x.next;x.next=b.next,b.next=C}o.baseQueue=x=b,p.pending=null}if(b=i.baseState,x===null)i.memoizedState=b;else{o=x.next;var D=C=null,J=null,ae=o,pe=!1;do{var ge=ae.lane&-536870913;if(ge!==ae.lane?(lt&ge)===ge:(Lr&ge)===ge){var le=ae.revertLane;if(le===0)J!==null&&(J=J.next={lane:0,revertLane:0,gesture:null,action:ae.action,hasEagerState:ae.hasEagerState,eagerState:ae.eagerState,next:null}),ge===to&&(pe=!0);else if((Lr&le)===le){ae=ae.next,le===to&&(pe=!0);continue}else ge={lane:0,revertLane:ae.revertLane,gesture:null,action:ae.action,hasEagerState:ae.hasEagerState,eagerState:ae.eagerState,next:null},J===null?(D=J=ge,C=b):J=J.next=ge,Qe.lanes|=le,yi|=le;ge=ae.action,ha&&u(b,ge),b=ae.hasEagerState?ae.eagerState:u(b,ge)}else le={lane:ge,revertLane:ae.revertLane,gesture:ae.gesture,action:ae.action,hasEagerState:ae.hasEagerState,eagerState:ae.eagerState,next:null},J===null?(D=J=le,C=b):J=J.next=le,Qe.lanes|=ge,yi|=ge;ae=ae.next}while(ae!==null&&ae!==o);if(J===null?C=b:J.next=D,!bn(b,i.memoizedState)&&(cs=!0,pe&&(u=so,u!==null)))throw u;i.memoizedState=b,i.baseState=C,i.baseQueue=J,p.lastRenderedState=b}return x===null&&(p.lanes=0),[i.memoizedState,p.dispatch]}function np(i){var o=rs(),u=o.queue;if(u===null)throw Error(n(311));u.lastRenderedReducer=i;var p=u.dispatch,x=u.pending,b=o.memoizedState;if(x!==null){u.pending=null;var C=x=x.next;do b=i(b,C.action),C=C.next;while(C!==x);bn(b,o.memoizedState)||(cs=!0),o.memoizedState=b,o.baseQueue===null&&(o.baseState=b),u.lastRenderedState=b}return[b,p]}function N1(i,o,u){var p=Qe,x=rs(),b=dt;if(b){if(u===void 0)throw Error(n(407));u=u()}else u=o();var C=!bn((kt||x).memoizedState,u);if(C&&(x.memoizedState=u,cs=!0),x=x.queue,ap(T1.bind(null,p,x,i),[i]),x.getSnapshot!==o||C||ls!==null&&ls.memoizedState.tag&1){if(p.flags|=2048,lo(9,{destroy:void 0},M1.bind(null,p,x,u,o),null),Mt===null)throw Error(n(349));b||(Lr&127)!==0||E1(p,o,u)}return u}function E1(i,o,u){i.flags|=16384,i={getSnapshot:o,value:u},o=Qe.updateQueue,o===null?(o=Vu(),Qe.updateQueue=o,o.stores=[i]):(u=o.stores,u===null?o.stores=[i]:u.push(i))}function M1(i,o,u,p){o.value=u,o.getSnapshot=p,A1(o)&&R1(i)}function T1(i,o,u){return u(function(){A1(o)&&R1(i)})}function A1(i){var o=i.getSnapshot;i=i.value;try{var u=o();return!bn(i,u)}catch{return!0}}function R1(i){var o=na(i,2);o!==null&&dn(o,i,2)}function rp(i){var o=Gs();if(typeof i=="function"){var u=i;if(i=u(),ha){H(!0);try{u()}finally{H(!1)}}}return o.memoizedState=o.baseState=i,o.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Br,lastRenderedState:i},o}function D1(i,o,u,p){return i.baseState=u,sp(i,kt,typeof p=="function"?p:Br)}function N3(i,o,u,p,x){if(Yu(i))throw Error(n(485));if(i=o.action,i!==null){var b={payload:x,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(C){b.listeners.push(C)}};M.T!==null?u(!0):b.isTransition=!1,p(b),u=o.pending,u===null?(b.next=o.pending=b,L1(o,b)):(b.next=u.next,o.pending=u.next=b)}}function L1(i,o){var u=o.action,p=o.payload,x=i.state;if(o.isTransition){var b=M.T,C={};M.T=C;try{var D=u(x,p),J=M.S;J!==null&&J(C,D),B1(i,o,D)}catch(ae){ip(i,o,ae)}finally{b!==null&&C.types!==null&&(b.types=C.types),M.T=b}}else try{b=u(x,p),B1(i,o,b)}catch(ae){ip(i,o,ae)}}function B1(i,o,u){u!==null&&typeof u=="object"&&typeof u.then=="function"?u.then(function(p){O1(i,o,p)},function(p){return ip(i,o,p)}):O1(i,o,u)}function O1(i,o,u){o.status="fulfilled",o.value=u,z1(o),i.state=u,o=i.pending,o!==null&&(u=o.next,u===o?i.pending=null:(u=u.next,o.next=u,L1(i,u)))}function ip(i,o,u){var p=i.pending;if(i.pending=null,p!==null){p=p.next;do o.status="rejected",o.reason=u,z1(o),o=o.next;while(o!==p)}i.action=null}function z1(i){i=i.listeners;for(var o=0;o<i.length;o++)(0,i[o])()}function P1(i,o){return o}function $1(i,o){if(dt){var u=Mt.formState;if(u!==null){e:{var p=Qe;if(dt){if(zt){t:{for(var x=zt,b=$n;x.nodeType!==8;){if(!b){x=null;break t}if(x=Fn(x.nextSibling),x===null){x=null;break t}}b=x.data,x=b==="F!"||b==="F"?x:null}if(x){zt=Fn(x.nextSibling),p=x.data==="F!";break e}}hi(p)}p=!1}p&&(o=u[0])}}return u=Gs(),u.memoizedState=u.baseState=o,p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:P1,lastRenderedState:o},u.queue=p,u=rb.bind(null,Qe,p),p.dispatch=u,p=rp(!1),b=dp.bind(null,Qe,!1,p.queue),p=Gs(),x={state:o,dispatch:null,action:i,pending:null},p.queue=x,u=N3.bind(null,Qe,x,b,u),x.dispatch=u,p.memoizedState=i,[o,u,!1]}function I1(i){var o=rs();return F1(o,kt,i)}function F1(i,o,u){if(o=sp(i,o,P1)[0],i=qu(Br)[0],typeof o=="object"&&o!==null&&typeof o.then=="function")try{var p=jl(o)}catch(C){throw C===no?Ou:C}else p=o;o=rs();var x=o.queue,b=x.dispatch;return u!==o.memoizedState&&(Qe.flags|=2048,lo(9,{destroy:void 0},E3.bind(null,x,u),null)),[p,b,i]}function E3(i,o){i.action=o}function H1(i){var o=rs(),u=kt;if(u!==null)return F1(o,u,i);rs(),o=o.memoizedState,u=rs();var p=u.queue.dispatch;return u.memoizedState=i,[o,p,!1]}function lo(i,o,u,p){return i={tag:i,create:u,deps:p,inst:o,next:null},o=Qe.updateQueue,o===null&&(o=Vu(),Qe.updateQueue=o),u=o.lastEffect,u===null?o.lastEffect=i.next=i:(p=u.next,u.next=i,i.next=p,o.lastEffect=i),i}function U1(){return rs().memoizedState}function Gu(i,o,u,p){var x=Gs();Qe.flags|=i,x.memoizedState=lo(1|o,{destroy:void 0},u,p===void 0?null:p)}function Ku(i,o,u,p){var x=rs();p=p===void 0?null:p;var b=x.memoizedState.inst;kt!==null&&p!==null&&Xf(p,kt.memoizedState.deps)?x.memoizedState=lo(o,b,u,p):(Qe.flags|=i,x.memoizedState=lo(1|o,b,u,p))}function V1(i,o){Gu(8390656,8,i,o)}function ap(i,o){Ku(2048,8,i,o)}function M3(i){Qe.flags|=4;var o=Qe.updateQueue;if(o===null)o=Vu(),Qe.updateQueue=o,o.events=[i];else{var u=o.events;u===null?o.events=[i]:u.push(i)}}function W1(i){var o=rs().memoizedState;return M3({ref:o,nextImpl:i}),function(){if((bt&2)!==0)throw Error(n(440));return o.impl.apply(void 0,arguments)}}function q1(i,o){return Ku(4,2,i,o)}function G1(i,o){return Ku(4,4,i,o)}function K1(i,o){if(typeof o=="function"){i=i();var u=o(i);return function(){typeof u=="function"?u():o(null)}}if(o!=null)return i=i(),o.current=i,function(){o.current=null}}function Y1(i,o,u){u=u!=null?u.concat([i]):null,Ku(4,4,K1.bind(null,o,i),u)}function op(){}function X1(i,o){var u=rs();o=o===void 0?null:o;var p=u.memoizedState;return o!==null&&Xf(o,p[1])?p[0]:(u.memoizedState=[i,o],i)}function J1(i,o){var u=rs();o=o===void 0?null:o;var p=u.memoizedState;if(o!==null&&Xf(o,p[1]))return p[0];if(p=i(),ha){H(!0);try{i()}finally{H(!1)}}return u.memoizedState=[p,o],p}function lp(i,o,u){return u===void 0||(Lr&1073741824)!==0&&(lt&261930)===0?i.memoizedState=o:(i.memoizedState=u,i=Qb(),Qe.lanes|=i,yi|=i,u)}function Q1(i,o,u,p){return bn(u,o)?u:io.current!==null?(i=lp(i,u,p),bn(i,o)||(cs=!0),i):(Lr&42)===0||(Lr&1073741824)!==0&&(lt&261930)===0?(cs=!0,i.memoizedState=u):(i=Qb(),Qe.lanes|=i,yi|=i,o)}function Z1(i,o,u,p,x){var b=O.p;O.p=b!==0&&8>b?b:8;var C=M.T,D={};M.T=D,dp(i,!1,o,u);try{var J=x(),ae=M.S;if(ae!==null&&ae(D,J),J!==null&&typeof J=="object"&&typeof J.then=="function"){var pe=j3(J,p);kl(i,o,pe,kn(i))}else kl(i,o,p,kn(i))}catch(ge){kl(i,o,{then:function(){},status:"rejected",reason:ge},kn())}finally{O.p=b,C!==null&&D.types!==null&&(C.types=D.types),M.T=C}}function T3(){}function cp(i,o,u,p){if(i.tag!==5)throw Error(n(476));var x=eb(i).queue;Z1(i,x,o,U,u===null?T3:function(){return tb(i),u(p)})}function eb(i){var o=i.memoizedState;if(o!==null)return o;o={memoizedState:U,baseState:U,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Br,lastRenderedState:U},next:null};var u={};return o.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Br,lastRenderedState:u},next:null},i.memoizedState=o,i=i.alternate,i!==null&&(i.memoizedState=o),o}function tb(i){var o=eb(i);o.next===null&&(o=i.alternate.memoizedState),kl(i,o.next.queue,{},kn())}function up(){return Ls(Hl)}function sb(){return rs().memoizedState}function nb(){return rs().memoizedState}function A3(i){for(var o=i.return;o!==null;){switch(o.tag){case 24:case 3:var u=kn();i=mi(u);var p=gi(o,i,u);p!==null&&(dn(p,o,u),_l(p,o,u)),o={cache:$f()},i.payload=o;return}o=o.return}}function R3(i,o,u){var p=kn();u={lane:p,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Yu(i)?ib(o,u):(u=Ef(i,o,u,p),u!==null&&(dn(u,i,p),ab(u,o,p)))}function rb(i,o,u){var p=kn();kl(i,o,u,p)}function kl(i,o,u,p){var x={lane:p,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(Yu(i))ib(o,x);else{var b=i.alternate;if(i.lanes===0&&(b===null||b.lanes===0)&&(b=o.lastRenderedReducer,b!==null))try{var C=o.lastRenderedState,D=b(C,u);if(x.hasEagerState=!0,x.eagerState=D,bn(D,C))return Mu(i,o,x,0),Mt===null&&Eu(),!1}catch{}finally{}if(u=Ef(i,o,x,p),u!==null)return dn(u,i,p),ab(u,o,p),!0}return!1}function dp(i,o,u,p){if(p={lane:2,revertLane:Up(),gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},Yu(i)){if(o)throw Error(n(479))}else o=Ef(i,u,p,2),o!==null&&dn(o,i,2)}function Yu(i){var o=i.alternate;return i===Qe||o!==null&&o===Qe}function ib(i,o){ao=Hu=!0;var u=i.pending;u===null?o.next=o:(o.next=u.next,u.next=o),i.pending=o}function ab(i,o,u){if((u&4194048)!==0){var p=o.lanes;p&=i.pendingLanes,u|=p,o.lanes=u,ar(i,u)}}var Cl={readContext:Ls,use:Wu,useCallback:Jt,useContext:Jt,useEffect:Jt,useImperativeHandle:Jt,useLayoutEffect:Jt,useInsertionEffect:Jt,useMemo:Jt,useReducer:Jt,useRef:Jt,useState:Jt,useDebugValue:Jt,useDeferredValue:Jt,useTransition:Jt,useSyncExternalStore:Jt,useId:Jt,useHostTransitionStatus:Jt,useFormState:Jt,useActionState:Jt,useOptimistic:Jt,useMemoCache:Jt,useCacheRefresh:Jt};Cl.useEffectEvent=Jt;var ob={readContext:Ls,use:Wu,useCallback:function(i,o){return Gs().memoizedState=[i,o===void 0?null:o],i},useContext:Ls,useEffect:V1,useImperativeHandle:function(i,o,u){u=u!=null?u.concat([i]):null,Gu(4194308,4,K1.bind(null,o,i),u)},useLayoutEffect:function(i,o){return Gu(4194308,4,i,o)},useInsertionEffect:function(i,o){Gu(4,2,i,o)},useMemo:function(i,o){var u=Gs();o=o===void 0?null:o;var p=i();if(ha){H(!0);try{i()}finally{H(!1)}}return u.memoizedState=[p,o],p},useReducer:function(i,o,u){var p=Gs();if(u!==void 0){var x=u(o);if(ha){H(!0);try{u(o)}finally{H(!1)}}}else x=o;return p.memoizedState=p.baseState=x,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:x},p.queue=i,i=i.dispatch=R3.bind(null,Qe,i),[p.memoizedState,i]},useRef:function(i){var o=Gs();return i={current:i},o.memoizedState=i},useState:function(i){i=rp(i);var o=i.queue,u=rb.bind(null,Qe,o);return o.dispatch=u,[i.memoizedState,u]},useDebugValue:op,useDeferredValue:function(i,o){var u=Gs();return lp(u,i,o)},useTransition:function(){var i=rp(!1);return i=Z1.bind(null,Qe,i.queue,!0,!1),Gs().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,o,u){var p=Qe,x=Gs();if(dt){if(u===void 0)throw Error(n(407));u=u()}else{if(u=o(),Mt===null)throw Error(n(349));(lt&127)!==0||E1(p,o,u)}x.memoizedState=u;var b={value:u,getSnapshot:o};return x.queue=b,V1(T1.bind(null,p,b,i),[i]),p.flags|=2048,lo(9,{destroy:void 0},M1.bind(null,p,b,u,o),null),u},useId:function(){var i=Gs(),o=Mt.identifierPrefix;if(dt){var u=lr,p=or;u=(p&~(1<<32-ee(p)-1)).toString(32)+u,o="_"+o+"R_"+u,u=Uu++,0<u&&(o+="H"+u.toString(32)),o+="_"}else u=k3++,o="_"+o+"r_"+u.toString(32)+"_";return i.memoizedState=o},useHostTransitionStatus:up,useFormState:$1,useActionState:$1,useOptimistic:function(i){var o=Gs();o.memoizedState=o.baseState=i;var u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return o.queue=u,o=dp.bind(null,Qe,!0,u),u.dispatch=o,[i,o]},useMemoCache:tp,useCacheRefresh:function(){return Gs().memoizedState=A3.bind(null,Qe)},useEffectEvent:function(i){var o=Gs(),u={impl:i};return o.memoizedState=u,function(){if((bt&2)!==0)throw Error(n(440));return u.impl.apply(void 0,arguments)}}},hp={readContext:Ls,use:Wu,useCallback:X1,useContext:Ls,useEffect:ap,useImperativeHandle:Y1,useInsertionEffect:q1,useLayoutEffect:G1,useMemo:J1,useReducer:qu,useRef:U1,useState:function(){return qu(Br)},useDebugValue:op,useDeferredValue:function(i,o){var u=rs();return Q1(u,kt.memoizedState,i,o)},useTransition:function(){var i=qu(Br)[0],o=rs().memoizedState;return[typeof i=="boolean"?i:jl(i),o]},useSyncExternalStore:N1,useId:sb,useHostTransitionStatus:up,useFormState:I1,useActionState:I1,useOptimistic:function(i,o){var u=rs();return D1(u,kt,i,o)},useMemoCache:tp,useCacheRefresh:nb};hp.useEffectEvent=W1;var lb={readContext:Ls,use:Wu,useCallback:X1,useContext:Ls,useEffect:ap,useImperativeHandle:Y1,useInsertionEffect:q1,useLayoutEffect:G1,useMemo:J1,useReducer:np,useRef:U1,useState:function(){return np(Br)},useDebugValue:op,useDeferredValue:function(i,o){var u=rs();return kt===null?lp(u,i,o):Q1(u,kt.memoizedState,i,o)},useTransition:function(){var i=np(Br)[0],o=rs().memoizedState;return[typeof i=="boolean"?i:jl(i),o]},useSyncExternalStore:N1,useId:sb,useHostTransitionStatus:up,useFormState:H1,useActionState:H1,useOptimistic:function(i,o){var u=rs();return kt!==null?D1(u,kt,i,o):(u.baseState=i,[i,u.queue.dispatch])},useMemoCache:tp,useCacheRefresh:nb};lb.useEffectEvent=W1;function fp(i,o,u,p){o=i.memoizedState,u=u(p,o),u=u==null?o:g({},o,u),i.memoizedState=u,i.lanes===0&&(i.updateQueue.baseState=u)}var pp={enqueueSetState:function(i,o,u){i=i._reactInternals;var p=kn(),x=mi(p);x.payload=o,u!=null&&(x.callback=u),o=gi(i,x,p),o!==null&&(dn(o,i,p),_l(o,i,p))},enqueueReplaceState:function(i,o,u){i=i._reactInternals;var p=kn(),x=mi(p);x.tag=1,x.payload=o,u!=null&&(x.callback=u),o=gi(i,x,p),o!==null&&(dn(o,i,p),_l(o,i,p))},enqueueForceUpdate:function(i,o){i=i._reactInternals;var u=kn(),p=mi(u);p.tag=2,o!=null&&(p.callback=o),o=gi(i,p,u),o!==null&&(dn(o,i,u),_l(o,i,u))}};function cb(i,o,u,p,x,b,C){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(p,b,C):o.prototype&&o.prototype.isPureReactComponent?!hl(u,p)||!hl(x,b):!0}function ub(i,o,u,p){i=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(u,p),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(u,p),o.state!==i&&pp.enqueueReplaceState(o,o.state,null)}function fa(i,o){var u=o;if("ref"in o){u={};for(var p in o)p!=="ref"&&(u[p]=o[p])}if(i=i.defaultProps){u===o&&(u=g({},u));for(var x in i)u[x]===void 0&&(u[x]=i[x])}return u}function db(i){Nu(i)}function hb(i){console.error(i)}function fb(i){Nu(i)}function Xu(i,o){try{var u=i.onUncaughtError;u(o.value,{componentStack:o.stack})}catch(p){setTimeout(function(){throw p})}}function pb(i,o,u){try{var p=i.onCaughtError;p(u.value,{componentStack:u.stack,errorBoundary:o.tag===1?o.stateNode:null})}catch(x){setTimeout(function(){throw x})}}function mp(i,o,u){return u=mi(u),u.tag=3,u.payload={element:null},u.callback=function(){Xu(i,o)},u}function mb(i){return i=mi(i),i.tag=3,i}function gb(i,o,u,p){var x=u.type.getDerivedStateFromError;if(typeof x=="function"){var b=p.value;i.payload=function(){return x(b)},i.callback=function(){pb(o,u,p)}}var C=u.stateNode;C!==null&&typeof C.componentDidCatch=="function"&&(i.callback=function(){pb(o,u,p),typeof x!="function"&&(wi===null?wi=new Set([this]):wi.add(this));var D=p.stack;this.componentDidCatch(p.value,{componentStack:D!==null?D:""})})}function D3(i,o,u,p,x){if(u.flags|=32768,p!==null&&typeof p=="object"&&typeof p.then=="function"){if(o=u.alternate,o!==null&&eo(o,u,x,!0),u=yn.current,u!==null){switch(u.tag){case 31:case 13:return In===null?ld():u.alternate===null&&Qt===0&&(Qt=3),u.flags&=-257,u.flags|=65536,u.lanes=x,p===zu?u.flags|=16384:(o=u.updateQueue,o===null?u.updateQueue=new Set([p]):o.add(p),Ip(i,p,x)),!1;case 22:return u.flags|=65536,p===zu?u.flags|=16384:(o=u.updateQueue,o===null?(o={transitions:null,markerInstances:null,retryQueue:new Set([p])},u.updateQueue=o):(u=o.retryQueue,u===null?o.retryQueue=new Set([p]):u.add(p)),Ip(i,p,x)),!1}throw Error(n(435,u.tag))}return Ip(i,p,x),ld(),!1}if(dt)return o=yn.current,o!==null?((o.flags&65536)===0&&(o.flags|=256),o.flags|=65536,o.lanes=x,p!==Lf&&(i=Error(n(422),{cause:p}),ml(On(i,u)))):(p!==Lf&&(o=Error(n(423),{cause:p}),ml(On(o,u))),i=i.current.alternate,i.flags|=65536,x&=-x,i.lanes|=x,p=On(p,u),x=mp(i.stateNode,p,x),Wf(i,x),Qt!==4&&(Qt=2)),!1;var b=Error(n(520),{cause:p});if(b=On(b,u),Ll===null?Ll=[b]:Ll.push(b),Qt!==4&&(Qt=2),o===null)return!0;p=On(p,u),u=o;do{switch(u.tag){case 3:return u.flags|=65536,i=x&-x,u.lanes|=i,i=mp(u.stateNode,p,i),Wf(u,i),!1;case 1:if(o=u.type,b=u.stateNode,(u.flags&128)===0&&(typeof o.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(wi===null||!wi.has(b))))return u.flags|=65536,x&=-x,u.lanes|=x,x=mb(x),gb(x,i,u,p),Wf(u,x),!1}u=u.return}while(u!==null);return!1}var gp=Error(n(461)),cs=!1;function Bs(i,o,u,p){o.child=i===null?_1(o,null,u,p):da(o,i.child,u,p)}function xb(i,o,u,p,x){u=u.render;var b=o.ref;if("ref"in p){var C={};for(var D in p)D!=="ref"&&(C[D]=p[D])}else C=p;return oa(o),p=Jf(i,o,u,C,b,x),D=Qf(),i!==null&&!cs?(Zf(i,o,x),Or(i,o,x)):(dt&&D&&Rf(o),o.flags|=1,Bs(i,o,p,x),o.child)}function vb(i,o,u,p,x){if(i===null){var b=u.type;return typeof b=="function"&&!Mf(b)&&b.defaultProps===void 0&&u.compare===null?(o.tag=15,o.type=b,bb(i,o,b,p,x)):(i=Au(u.type,null,p,o,o.mode,x),i.ref=o.ref,i.return=o,o.child=i)}if(b=i.child,!jp(i,x)){var C=b.memoizedProps;if(u=u.compare,u=u!==null?u:hl,u(C,p)&&i.ref===o.ref)return Or(i,o,x)}return o.flags|=1,i=Tr(b,p),i.ref=o.ref,i.return=o,o.child=i}function bb(i,o,u,p,x){if(i!==null){var b=i.memoizedProps;if(hl(b,p)&&i.ref===o.ref)if(cs=!1,o.pendingProps=p=b,jp(i,x))(i.flags&131072)!==0&&(cs=!0);else return o.lanes=i.lanes,Or(i,o,x)}return xp(i,o,u,p,x)}function _b(i,o,u,p){var x=p.children,b=i!==null?i.memoizedState:null;if(i===null&&o.stateNode===null&&(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.mode==="hidden"){if((o.flags&128)!==0){if(b=b!==null?b.baseLanes|u:u,i!==null){for(p=o.child=i.child,x=0;p!==null;)x=x|p.lanes|p.childLanes,p=p.sibling;p=x&~b}else p=0,o.child=null;return yb(i,o,b,u,p)}if((u&536870912)!==0)o.memoizedState={baseLanes:0,cachePool:null},i!==null&&Bu(o,b!==null?b.cachePool:null),b!==null?S1(o,b):Gf(),j1(o);else return p=o.lanes=536870912,yb(i,o,b!==null?b.baseLanes|u:u,u,p)}else b!==null?(Bu(o,b.cachePool),S1(o,b),vi(),o.memoizedState=null):(i!==null&&Bu(o,null),Gf(),vi());return Bs(i,o,x,u),o.child}function Nl(i,o){return i!==null&&i.tag===22||o.stateNode!==null||(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.sibling}function yb(i,o,u,p,x){var b=Ff();return b=b===null?null:{parent:os._currentValue,pool:b},o.memoizedState={baseLanes:u,cachePool:b},i!==null&&Bu(o,null),Gf(),j1(o),i!==null&&eo(i,o,p,!0),o.childLanes=x,null}function Ju(i,o){return o=Zu({mode:o.mode,children:o.children},i.mode),o.ref=i.ref,i.child=o,o.return=i,o}function wb(i,o,u){return da(o,i.child,null,u),i=Ju(o,o.pendingProps),i.flags|=2,wn(o),o.memoizedState=null,i}function L3(i,o,u){var p=o.pendingProps,x=(o.flags&128)!==0;if(o.flags&=-129,i===null){if(dt){if(p.mode==="hidden")return i=Ju(o,p),o.lanes=536870912,Nl(null,i);if(Yf(o),(i=zt)?(i=L_(i,$n),i=i!==null&&i.data==="&"?i:null,i!==null&&(o.memoizedState={dehydrated:i,treeContext:ui!==null?{id:or,overflow:lr}:null,retryLane:536870912,hydrationErrors:null},u=i1(i),u.return=o,o.child=u,Ds=o,zt=null)):i=null,i===null)throw hi(o);return o.lanes=536870912,null}return Ju(o,p)}var b=i.memoizedState;if(b!==null){var C=b.dehydrated;if(Yf(o),x)if(o.flags&256)o.flags&=-257,o=wb(i,o,u);else if(o.memoizedState!==null)o.child=i.child,o.flags|=128,o=null;else throw Error(n(558));else if(cs||eo(i,o,u,!1),x=(u&i.childLanes)!==0,cs||x){if(p=Mt,p!==null&&(C=hv(p,u),C!==0&&C!==b.retryLane))throw b.retryLane=C,na(i,C),dn(p,i,C),gp;ld(),o=wb(i,o,u)}else i=b.treeContext,zt=Fn(C.nextSibling),Ds=o,dt=!0,di=null,$n=!1,i!==null&&l1(o,i),o=Ju(o,p),o.flags|=4096;return o}return i=Tr(i.child,{mode:p.mode,children:p.children}),i.ref=o.ref,o.child=i,i.return=o,i}function Qu(i,o){var u=o.ref;if(u===null)i!==null&&i.ref!==null&&(o.flags|=4194816);else{if(typeof u!="function"&&typeof u!="object")throw Error(n(284));(i===null||i.ref!==u)&&(o.flags|=4194816)}}function xp(i,o,u,p,x){return oa(o),u=Jf(i,o,u,p,void 0,x),p=Qf(),i!==null&&!cs?(Zf(i,o,x),Or(i,o,x)):(dt&&p&&Rf(o),o.flags|=1,Bs(i,o,u,x),o.child)}function Sb(i,o,u,p,x,b){return oa(o),o.updateQueue=null,u=C1(o,p,u,x),k1(i),p=Qf(),i!==null&&!cs?(Zf(i,o,b),Or(i,o,b)):(dt&&p&&Rf(o),o.flags|=1,Bs(i,o,u,b),o.child)}function jb(i,o,u,p,x){if(oa(o),o.stateNode===null){var b=Xa,C=u.contextType;typeof C=="object"&&C!==null&&(b=Ls(C)),b=new u(p,b),o.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,b.updater=pp,o.stateNode=b,b._reactInternals=o,b=o.stateNode,b.props=p,b.state=o.memoizedState,b.refs={},Uf(o),C=u.contextType,b.context=typeof C=="object"&&C!==null?Ls(C):Xa,b.state=o.memoizedState,C=u.getDerivedStateFromProps,typeof C=="function"&&(fp(o,u,C,p),b.state=o.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof b.getSnapshotBeforeUpdate=="function"||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(C=b.state,typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount(),C!==b.state&&pp.enqueueReplaceState(b,b.state,null),wl(o,p,b,x),yl(),b.state=o.memoizedState),typeof b.componentDidMount=="function"&&(o.flags|=4194308),p=!0}else if(i===null){b=o.stateNode;var D=o.memoizedProps,J=fa(u,D);b.props=J;var ae=b.context,pe=u.contextType;C=Xa,typeof pe=="object"&&pe!==null&&(C=Ls(pe));var ge=u.getDerivedStateFromProps;pe=typeof ge=="function"||typeof b.getSnapshotBeforeUpdate=="function",D=o.pendingProps!==D,pe||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(D||ae!==C)&&ub(o,b,p,C),pi=!1;var le=o.memoizedState;b.state=le,wl(o,p,b,x),yl(),ae=o.memoizedState,D||le!==ae||pi?(typeof ge=="function"&&(fp(o,u,ge,p),ae=o.memoizedState),(J=pi||cb(o,u,J,p,le,ae,C))?(pe||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount()),typeof b.componentDidMount=="function"&&(o.flags|=4194308)):(typeof b.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=p,o.memoizedState=ae),b.props=p,b.state=ae,b.context=C,p=J):(typeof b.componentDidMount=="function"&&(o.flags|=4194308),p=!1)}else{b=o.stateNode,Vf(i,o),C=o.memoizedProps,pe=fa(u,C),b.props=pe,ge=o.pendingProps,le=b.context,ae=u.contextType,J=Xa,typeof ae=="object"&&ae!==null&&(J=Ls(ae)),D=u.getDerivedStateFromProps,(ae=typeof D=="function"||typeof b.getSnapshotBeforeUpdate=="function")||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(C!==ge||le!==J)&&ub(o,b,p,J),pi=!1,le=o.memoizedState,b.state=le,wl(o,p,b,x),yl();var ue=o.memoizedState;C!==ge||le!==ue||pi||i!==null&&i.dependencies!==null&&Du(i.dependencies)?(typeof D=="function"&&(fp(o,u,D,p),ue=o.memoizedState),(pe=pi||cb(o,u,pe,p,le,ue,J)||i!==null&&i.dependencies!==null&&Du(i.dependencies))?(ae||typeof b.UNSAFE_componentWillUpdate!="function"&&typeof b.componentWillUpdate!="function"||(typeof b.componentWillUpdate=="function"&&b.componentWillUpdate(p,ue,J),typeof b.UNSAFE_componentWillUpdate=="function"&&b.UNSAFE_componentWillUpdate(p,ue,J)),typeof b.componentDidUpdate=="function"&&(o.flags|=4),typeof b.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof b.componentDidUpdate!="function"||C===i.memoizedProps&&le===i.memoizedState||(o.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||C===i.memoizedProps&&le===i.memoizedState||(o.flags|=1024),o.memoizedProps=p,o.memoizedState=ue),b.props=p,b.state=ue,b.context=J,p=pe):(typeof b.componentDidUpdate!="function"||C===i.memoizedProps&&le===i.memoizedState||(o.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||C===i.memoizedProps&&le===i.memoizedState||(o.flags|=1024),p=!1)}return b=p,Qu(i,o),p=(o.flags&128)!==0,b||p?(b=o.stateNode,u=p&&typeof u.getDerivedStateFromError!="function"?null:b.render(),o.flags|=1,i!==null&&p?(o.child=da(o,i.child,null,x),o.child=da(o,null,u,x)):Bs(i,o,u,x),o.memoizedState=b.state,i=o.child):i=Or(i,o,x),i}function kb(i,o,u,p){return ia(),o.flags|=256,Bs(i,o,u,p),o.child}var vp={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function bp(i){return{baseLanes:i,cachePool:p1()}}function _p(i,o,u){return i=i!==null?i.childLanes&~u:0,o&&(i|=jn),i}function Cb(i,o,u){var p=o.pendingProps,x=!1,b=(o.flags&128)!==0,C;if((C=b)||(C=i!==null&&i.memoizedState===null?!1:(ns.current&2)!==0),C&&(x=!0,o.flags&=-129),C=(o.flags&32)!==0,o.flags&=-33,i===null){if(dt){if(x?xi(o):vi(),(i=zt)?(i=L_(i,$n),i=i!==null&&i.data!=="&"?i:null,i!==null&&(o.memoizedState={dehydrated:i,treeContext:ui!==null?{id:or,overflow:lr}:null,retryLane:536870912,hydrationErrors:null},u=i1(i),u.return=o,o.child=u,Ds=o,zt=null)):i=null,i===null)throw hi(o);return sm(i)?o.lanes=32:o.lanes=536870912,null}var D=p.children;return p=p.fallback,x?(vi(),x=o.mode,D=Zu({mode:"hidden",children:D},x),p=ra(p,x,u,null),D.return=o,p.return=o,D.sibling=p,o.child=D,p=o.child,p.memoizedState=bp(u),p.childLanes=_p(i,C,u),o.memoizedState=vp,Nl(null,p)):(xi(o),yp(o,D))}var J=i.memoizedState;if(J!==null&&(D=J.dehydrated,D!==null)){if(b)o.flags&256?(xi(o),o.flags&=-257,o=wp(i,o,u)):o.memoizedState!==null?(vi(),o.child=i.child,o.flags|=128,o=null):(vi(),D=p.fallback,x=o.mode,p=Zu({mode:"visible",children:p.children},x),D=ra(D,x,u,null),D.flags|=2,p.return=o,D.return=o,p.sibling=D,o.child=p,da(o,i.child,null,u),p=o.child,p.memoizedState=bp(u),p.childLanes=_p(i,C,u),o.memoizedState=vp,o=Nl(null,p));else if(xi(o),sm(D)){if(C=D.nextSibling&&D.nextSibling.dataset,C)var ae=C.dgst;C=ae,p=Error(n(419)),p.stack="",p.digest=C,ml({value:p,source:null,stack:null}),o=wp(i,o,u)}else if(cs||eo(i,o,u,!1),C=(u&i.childLanes)!==0,cs||C){if(C=Mt,C!==null&&(p=hv(C,u),p!==0&&p!==J.retryLane))throw J.retryLane=p,na(i,p),dn(C,i,p),gp;tm(D)||ld(),o=wp(i,o,u)}else tm(D)?(o.flags|=192,o.child=i.child,o=null):(i=J.treeContext,zt=Fn(D.nextSibling),Ds=o,dt=!0,di=null,$n=!1,i!==null&&l1(o,i),o=yp(o,p.children),o.flags|=4096);return o}return x?(vi(),D=p.fallback,x=o.mode,J=i.child,ae=J.sibling,p=Tr(J,{mode:"hidden",children:p.children}),p.subtreeFlags=J.subtreeFlags&65011712,ae!==null?D=Tr(ae,D):(D=ra(D,x,u,null),D.flags|=2),D.return=o,p.return=o,p.sibling=D,o.child=p,Nl(null,p),p=o.child,D=i.child.memoizedState,D===null?D=bp(u):(x=D.cachePool,x!==null?(J=os._currentValue,x=x.parent!==J?{parent:J,pool:J}:x):x=p1(),D={baseLanes:D.baseLanes|u,cachePool:x}),p.memoizedState=D,p.childLanes=_p(i,C,u),o.memoizedState=vp,Nl(i.child,p)):(xi(o),u=i.child,i=u.sibling,u=Tr(u,{mode:"visible",children:p.children}),u.return=o,u.sibling=null,i!==null&&(C=o.deletions,C===null?(o.deletions=[i],o.flags|=16):C.push(i)),o.child=u,o.memoizedState=null,u)}function yp(i,o){return o=Zu({mode:"visible",children:o},i.mode),o.return=i,i.child=o}function Zu(i,o){return i=_n(22,i,null,o),i.lanes=0,i}function wp(i,o,u){return da(o,i.child,null,u),i=yp(o,o.pendingProps.children),i.flags|=2,o.memoizedState=null,i}function Nb(i,o,u){i.lanes|=o;var p=i.alternate;p!==null&&(p.lanes|=o),zf(i.return,o,u)}function Sp(i,o,u,p,x,b){var C=i.memoizedState;C===null?i.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:p,tail:u,tailMode:x,treeForkCount:b}:(C.isBackwards=o,C.rendering=null,C.renderingStartTime=0,C.last=p,C.tail=u,C.tailMode=x,C.treeForkCount=b)}function Eb(i,o,u){var p=o.pendingProps,x=p.revealOrder,b=p.tail;p=p.children;var C=ns.current,D=(C&2)!==0;if(D?(C=C&1|2,o.flags|=128):C&=1,T(ns,C),Bs(i,o,p,u),p=dt?pl:0,!D&&i!==null&&(i.flags&128)!==0)e:for(i=o.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Nb(i,u,o);else if(i.tag===19)Nb(i,u,o);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===o)break e;for(;i.sibling===null;){if(i.return===null||i.return===o)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(x){case"forwards":for(u=o.child,x=null;u!==null;)i=u.alternate,i!==null&&Fu(i)===null&&(x=u),u=u.sibling;u=x,u===null?(x=o.child,o.child=null):(x=u.sibling,u.sibling=null),Sp(o,!1,x,u,b,p);break;case"backwards":case"unstable_legacy-backwards":for(u=null,x=o.child,o.child=null;x!==null;){if(i=x.alternate,i!==null&&Fu(i)===null){o.child=x;break}i=x.sibling,x.sibling=u,u=x,x=i}Sp(o,!0,u,null,b,p);break;case"together":Sp(o,!1,null,null,void 0,p);break;default:o.memoizedState=null}return o.child}function Or(i,o,u){if(i!==null&&(o.dependencies=i.dependencies),yi|=o.lanes,(u&o.childLanes)===0)if(i!==null){if(eo(i,o,u,!1),(u&o.childLanes)===0)return null}else return null;if(i!==null&&o.child!==i.child)throw Error(n(153));if(o.child!==null){for(i=o.child,u=Tr(i,i.pendingProps),o.child=u,u.return=o;i.sibling!==null;)i=i.sibling,u=u.sibling=Tr(i,i.pendingProps),u.return=o;u.sibling=null}return o.child}function jp(i,o){return(i.lanes&o)!==0?!0:(i=i.dependencies,!!(i!==null&&Du(i)))}function B3(i,o,u){switch(o.tag){case 3:Te(o,o.stateNode.containerInfo),fi(o,os,i.memoizedState.cache),ia();break;case 27:case 5:je(o);break;case 4:Te(o,o.stateNode.containerInfo);break;case 10:fi(o,o.type,o.memoizedProps.value);break;case 31:if(o.memoizedState!==null)return o.flags|=128,Yf(o),null;break;case 13:var p=o.memoizedState;if(p!==null)return p.dehydrated!==null?(xi(o),o.flags|=128,null):(u&o.child.childLanes)!==0?Cb(i,o,u):(xi(o),i=Or(i,o,u),i!==null?i.sibling:null);xi(o);break;case 19:var x=(i.flags&128)!==0;if(p=(u&o.childLanes)!==0,p||(eo(i,o,u,!1),p=(u&o.childLanes)!==0),x){if(p)return Eb(i,o,u);o.flags|=128}if(x=o.memoizedState,x!==null&&(x.rendering=null,x.tail=null,x.lastEffect=null),T(ns,ns.current),p)break;return null;case 22:return o.lanes=0,_b(i,o,u,o.pendingProps);case 24:fi(o,os,i.memoizedState.cache)}return Or(i,o,u)}function Mb(i,o,u){if(i!==null)if(i.memoizedProps!==o.pendingProps)cs=!0;else{if(!jp(i,u)&&(o.flags&128)===0)return cs=!1,B3(i,o,u);cs=(i.flags&131072)!==0}else cs=!1,dt&&(o.flags&1048576)!==0&&o1(o,pl,o.index);switch(o.lanes=0,o.tag){case 16:e:{var p=o.pendingProps;if(i=ca(o.elementType),o.type=i,typeof i=="function")Mf(i)?(p=fa(i,p),o.tag=1,o=jb(null,o,i,p,u)):(o.tag=0,o=xp(null,o,i,p,u));else{if(i!=null){var x=i.$$typeof;if(x===B){o.tag=11,o=xb(null,o,i,p,u);break e}else if(x===K){o.tag=14,o=vb(null,o,i,p,u);break e}}throw o=q(i)||i,Error(n(306,o,""))}}return o;case 0:return xp(i,o,o.type,o.pendingProps,u);case 1:return p=o.type,x=fa(p,o.pendingProps),jb(i,o,p,x,u);case 3:e:{if(Te(o,o.stateNode.containerInfo),i===null)throw Error(n(387));p=o.pendingProps;var b=o.memoizedState;x=b.element,Vf(i,o),wl(o,p,null,u);var C=o.memoizedState;if(p=C.cache,fi(o,os,p),p!==b.cache&&Pf(o,[os],u,!0),yl(),p=C.element,b.isDehydrated)if(b={element:p,isDehydrated:!1,cache:C.cache},o.updateQueue.baseState=b,o.memoizedState=b,o.flags&256){o=kb(i,o,p,u);break e}else if(p!==x){x=On(Error(n(424)),o),ml(x),o=kb(i,o,p,u);break e}else{switch(i=o.stateNode.containerInfo,i.nodeType){case 9:i=i.body;break;default:i=i.nodeName==="HTML"?i.ownerDocument.body:i}for(zt=Fn(i.firstChild),Ds=o,dt=!0,di=null,$n=!0,u=_1(o,null,p,u),o.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling}else{if(ia(),p===x){o=Or(i,o,u);break e}Bs(i,o,p,u)}o=o.child}return o;case 26:return Qu(i,o),i===null?(u=I_(o.type,null,o.pendingProps,null))?o.memoizedState=u:dt||(u=o.type,i=o.pendingProps,p=md(re.current).createElement(u),p[Rs]=o,p[rn]=i,Os(p,u,i),js(p),o.stateNode=p):o.memoizedState=I_(o.type,i.memoizedProps,o.pendingProps,i.memoizedState),null;case 27:return je(o),i===null&&dt&&(p=o.stateNode=z_(o.type,o.pendingProps,re.current),Ds=o,$n=!0,x=zt,Ci(o.type)?(nm=x,zt=Fn(p.firstChild)):zt=x),Bs(i,o,o.pendingProps.children,u),Qu(i,o),i===null&&(o.flags|=4194304),o.child;case 5:return i===null&&dt&&((x=p=zt)&&(p=d4(p,o.type,o.pendingProps,$n),p!==null?(o.stateNode=p,Ds=o,zt=Fn(p.firstChild),$n=!1,x=!0):x=!1),x||hi(o)),je(o),x=o.type,b=o.pendingProps,C=i!==null?i.memoizedProps:null,p=b.children,Qp(x,b)?p=null:C!==null&&Qp(x,C)&&(o.flags|=32),o.memoizedState!==null&&(x=Jf(i,o,C3,null,null,u),Hl._currentValue=x),Qu(i,o),Bs(i,o,p,u),o.child;case 6:return i===null&&dt&&((i=u=zt)&&(u=h4(u,o.pendingProps,$n),u!==null?(o.stateNode=u,Ds=o,zt=null,i=!0):i=!1),i||hi(o)),null;case 13:return Cb(i,o,u);case 4:return Te(o,o.stateNode.containerInfo),p=o.pendingProps,i===null?o.child=da(o,null,p,u):Bs(i,o,p,u),o.child;case 11:return xb(i,o,o.type,o.pendingProps,u);case 7:return Bs(i,o,o.pendingProps,u),o.child;case 8:return Bs(i,o,o.pendingProps.children,u),o.child;case 12:return Bs(i,o,o.pendingProps.children,u),o.child;case 10:return p=o.pendingProps,fi(o,o.type,p.value),Bs(i,o,p.children,u),o.child;case 9:return x=o.type._context,p=o.pendingProps.children,oa(o),x=Ls(x),p=p(x),o.flags|=1,Bs(i,o,p,u),o.child;case 14:return vb(i,o,o.type,o.pendingProps,u);case 15:return bb(i,o,o.type,o.pendingProps,u);case 19:return Eb(i,o,u);case 31:return L3(i,o,u);case 22:return _b(i,o,u,o.pendingProps);case 24:return oa(o),p=Ls(os),i===null?(x=Ff(),x===null&&(x=Mt,b=$f(),x.pooledCache=b,b.refCount++,b!==null&&(x.pooledCacheLanes|=u),x=b),o.memoizedState={parent:p,cache:x},Uf(o),fi(o,os,x)):((i.lanes&u)!==0&&(Vf(i,o),wl(o,null,null,u),yl()),x=i.memoizedState,b=o.memoizedState,x.parent!==p?(x={parent:p,cache:p},o.memoizedState=x,o.lanes===0&&(o.memoizedState=o.updateQueue.baseState=x),fi(o,os,p)):(p=b.cache,fi(o,os,p),p!==x.cache&&Pf(o,[os],u,!0))),Bs(i,o,o.pendingProps.children,u),o.child;case 29:throw o.pendingProps}throw Error(n(156,o.tag))}function zr(i){i.flags|=4}function kp(i,o,u,p,x){if((o=(i.mode&32)!==0)&&(o=!1),o){if(i.flags|=16777216,(x&335544128)===x)if(i.stateNode.complete)i.flags|=8192;else if(s_())i.flags|=8192;else throw ua=zu,Hf}else i.flags&=-16777217}function Tb(i,o){if(o.type!=="stylesheet"||(o.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!W_(o))if(s_())i.flags|=8192;else throw ua=zu,Hf}function ed(i,o){o!==null&&(i.flags|=4),i.flags&16384&&(o=i.tag!==22?wt():536870912,i.lanes|=o,fo|=o)}function El(i,o){if(!dt)switch(i.tailMode){case"hidden":o=i.tail;for(var u=null;o!==null;)o.alternate!==null&&(u=o),o=o.sibling;u===null?i.tail=null:u.sibling=null;break;case"collapsed":u=i.tail;for(var p=null;u!==null;)u.alternate!==null&&(p=u),u=u.sibling;p===null?o||i.tail===null?i.tail=null:i.tail.sibling=null:p.sibling=null}}function Pt(i){var o=i.alternate!==null&&i.alternate.child===i.child,u=0,p=0;if(o)for(var x=i.child;x!==null;)u|=x.lanes|x.childLanes,p|=x.subtreeFlags&65011712,p|=x.flags&65011712,x.return=i,x=x.sibling;else for(x=i.child;x!==null;)u|=x.lanes|x.childLanes,p|=x.subtreeFlags,p|=x.flags,x.return=i,x=x.sibling;return i.subtreeFlags|=p,i.childLanes=u,o}function O3(i,o,u){var p=o.pendingProps;switch(Df(o),o.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Pt(o),null;case 1:return Pt(o),null;case 3:return u=o.stateNode,p=null,i!==null&&(p=i.memoizedState.cache),o.memoizedState.cache!==p&&(o.flags|=2048),Dr(os),Re(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(i===null||i.child===null)&&(Za(o)?zr(o):i===null||i.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,Bf())),Pt(o),null;case 26:var x=o.type,b=o.memoizedState;return i===null?(zr(o),b!==null?(Pt(o),Tb(o,b)):(Pt(o),kp(o,x,null,p,u))):b?b!==i.memoizedState?(zr(o),Pt(o),Tb(o,b)):(Pt(o),o.flags&=-16777217):(i=i.memoizedProps,i!==p&&zr(o),Pt(o),kp(o,x,i,p,u)),null;case 27:if(Ye(o),u=re.current,x=o.type,i!==null&&o.stateNode!=null)i.memoizedProps!==p&&zr(o);else{if(!p){if(o.stateNode===null)throw Error(n(166));return Pt(o),null}i=oe.current,Za(o)?c1(o):(i=z_(x,p,u),o.stateNode=i,zr(o))}return Pt(o),null;case 5:if(Ye(o),x=o.type,i!==null&&o.stateNode!=null)i.memoizedProps!==p&&zr(o);else{if(!p){if(o.stateNode===null)throw Error(n(166));return Pt(o),null}if(b=oe.current,Za(o))c1(o);else{var C=md(re.current);switch(b){case 1:b=C.createElementNS("http://www.w3.org/2000/svg",x);break;case 2:b=C.createElementNS("http://www.w3.org/1998/Math/MathML",x);break;default:switch(x){case"svg":b=C.createElementNS("http://www.w3.org/2000/svg",x);break;case"math":b=C.createElementNS("http://www.w3.org/1998/Math/MathML",x);break;case"script":b=C.createElement("div"),b.innerHTML="<script><\/script>",b=b.removeChild(b.firstChild);break;case"select":b=typeof p.is=="string"?C.createElement("select",{is:p.is}):C.createElement("select"),p.multiple?b.multiple=!0:p.size&&(b.size=p.size);break;default:b=typeof p.is=="string"?C.createElement(x,{is:p.is}):C.createElement(x)}}b[Rs]=o,b[rn]=p;e:for(C=o.child;C!==null;){if(C.tag===5||C.tag===6)b.appendChild(C.stateNode);else if(C.tag!==4&&C.tag!==27&&C.child!==null){C.child.return=C,C=C.child;continue}if(C===o)break e;for(;C.sibling===null;){if(C.return===null||C.return===o)break e;C=C.return}C.sibling.return=C.return,C=C.sibling}o.stateNode=b;e:switch(Os(b,x,p),x){case"button":case"input":case"select":case"textarea":p=!!p.autoFocus;break e;case"img":p=!0;break e;default:p=!1}p&&zr(o)}}return Pt(o),kp(o,o.type,i===null?null:i.memoizedProps,o.pendingProps,u),null;case 6:if(i&&o.stateNode!=null)i.memoizedProps!==p&&zr(o);else{if(typeof p!="string"&&o.stateNode===null)throw Error(n(166));if(i=re.current,Za(o)){if(i=o.stateNode,u=o.memoizedProps,p=null,x=Ds,x!==null)switch(x.tag){case 27:case 5:p=x.memoizedProps}i[Rs]=o,i=!!(i.nodeValue===u||p!==null&&p.suppressHydrationWarning===!0||C_(i.nodeValue,u)),i||hi(o,!0)}else i=md(i).createTextNode(p),i[Rs]=o,o.stateNode=i}return Pt(o),null;case 31:if(u=o.memoizedState,i===null||i.memoizedState!==null){if(p=Za(o),u!==null){if(i===null){if(!p)throw Error(n(318));if(i=o.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(557));i[Rs]=o}else ia(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Pt(o),i=!1}else u=Bf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),i=!0;if(!i)return o.flags&256?(wn(o),o):(wn(o),null);if((o.flags&128)!==0)throw Error(n(558))}return Pt(o),null;case 13:if(p=o.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(x=Za(o),p!==null&&p.dehydrated!==null){if(i===null){if(!x)throw Error(n(318));if(x=o.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(n(317));x[Rs]=o}else ia(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Pt(o),x=!1}else x=Bf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=x),x=!0;if(!x)return o.flags&256?(wn(o),o):(wn(o),null)}return wn(o),(o.flags&128)!==0?(o.lanes=u,o):(u=p!==null,i=i!==null&&i.memoizedState!==null,u&&(p=o.child,x=null,p.alternate!==null&&p.alternate.memoizedState!==null&&p.alternate.memoizedState.cachePool!==null&&(x=p.alternate.memoizedState.cachePool.pool),b=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(b=p.memoizedState.cachePool.pool),b!==x&&(p.flags|=2048)),u!==i&&u&&(o.child.flags|=8192),ed(o,o.updateQueue),Pt(o),null);case 4:return Re(),i===null&&Gp(o.stateNode.containerInfo),Pt(o),null;case 10:return Dr(o.type),Pt(o),null;case 19:if(z(ns),p=o.memoizedState,p===null)return Pt(o),null;if(x=(o.flags&128)!==0,b=p.rendering,b===null)if(x)El(p,!1);else{if(Qt!==0||i!==null&&(i.flags&128)!==0)for(i=o.child;i!==null;){if(b=Fu(i),b!==null){for(o.flags|=128,El(p,!1),i=b.updateQueue,o.updateQueue=i,ed(o,i),o.subtreeFlags=0,i=u,u=o.child;u!==null;)r1(u,i),u=u.sibling;return T(ns,ns.current&1|2),dt&&Ar(o,p.treeForkCount),o.child}i=i.sibling}p.tail!==null&&vt()>id&&(o.flags|=128,x=!0,El(p,!1),o.lanes=4194304)}else{if(!x)if(i=Fu(b),i!==null){if(o.flags|=128,x=!0,i=i.updateQueue,o.updateQueue=i,ed(o,i),El(p,!0),p.tail===null&&p.tailMode==="hidden"&&!b.alternate&&!dt)return Pt(o),null}else 2*vt()-p.renderingStartTime>id&&u!==536870912&&(o.flags|=128,x=!0,El(p,!1),o.lanes=4194304);p.isBackwards?(b.sibling=o.child,o.child=b):(i=p.last,i!==null?i.sibling=b:o.child=b,p.last=b)}return p.tail!==null?(i=p.tail,p.rendering=i,p.tail=i.sibling,p.renderingStartTime=vt(),i.sibling=null,u=ns.current,T(ns,x?u&1|2:u&1),dt&&Ar(o,p.treeForkCount),i):(Pt(o),null);case 22:case 23:return wn(o),Kf(),p=o.memoizedState!==null,i!==null?i.memoizedState!==null!==p&&(o.flags|=8192):p&&(o.flags|=8192),p?(u&536870912)!==0&&(o.flags&128)===0&&(Pt(o),o.subtreeFlags&6&&(o.flags|=8192)):Pt(o),u=o.updateQueue,u!==null&&ed(o,u.retryQueue),u=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(u=i.memoizedState.cachePool.pool),p=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(p=o.memoizedState.cachePool.pool),p!==u&&(o.flags|=2048),i!==null&&z(la),null;case 24:return u=null,i!==null&&(u=i.memoizedState.cache),o.memoizedState.cache!==u&&(o.flags|=2048),Dr(os),Pt(o),null;case 25:return null;case 30:return null}throw Error(n(156,o.tag))}function z3(i,o){switch(Df(o),o.tag){case 1:return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 3:return Dr(os),Re(),i=o.flags,(i&65536)!==0&&(i&128)===0?(o.flags=i&-65537|128,o):null;case 26:case 27:case 5:return Ye(o),null;case 31:if(o.memoizedState!==null){if(wn(o),o.alternate===null)throw Error(n(340));ia()}return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 13:if(wn(o),i=o.memoizedState,i!==null&&i.dehydrated!==null){if(o.alternate===null)throw Error(n(340));ia()}return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 19:return z(ns),null;case 4:return Re(),null;case 10:return Dr(o.type),null;case 22:case 23:return wn(o),Kf(),i!==null&&z(la),i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 24:return Dr(os),null;case 25:return null;default:return null}}function Ab(i,o){switch(Df(o),o.tag){case 3:Dr(os),Re();break;case 26:case 27:case 5:Ye(o);break;case 4:Re();break;case 31:o.memoizedState!==null&&wn(o);break;case 13:wn(o);break;case 19:z(ns);break;case 10:Dr(o.type);break;case 22:case 23:wn(o),Kf(),i!==null&&z(la);break;case 24:Dr(os)}}function Ml(i,o){try{var u=o.updateQueue,p=u!==null?u.lastEffect:null;if(p!==null){var x=p.next;u=x;do{if((u.tag&i)===i){p=void 0;var b=u.create,C=u.inst;p=b(),C.destroy=p}u=u.next}while(u!==x)}}catch(D){jt(o,o.return,D)}}function bi(i,o,u){try{var p=o.updateQueue,x=p!==null?p.lastEffect:null;if(x!==null){var b=x.next;p=b;do{if((p.tag&i)===i){var C=p.inst,D=C.destroy;if(D!==void 0){C.destroy=void 0,x=o;var J=u,ae=D;try{ae()}catch(pe){jt(x,J,pe)}}}p=p.next}while(p!==b)}}catch(pe){jt(o,o.return,pe)}}function Rb(i){var o=i.updateQueue;if(o!==null){var u=i.stateNode;try{w1(o,u)}catch(p){jt(i,i.return,p)}}}function Db(i,o,u){u.props=fa(i.type,i.memoizedProps),u.state=i.memoizedState;try{u.componentWillUnmount()}catch(p){jt(i,o,p)}}function Tl(i,o){try{var u=i.ref;if(u!==null){switch(i.tag){case 26:case 27:case 5:var p=i.stateNode;break;case 30:p=i.stateNode;break;default:p=i.stateNode}typeof u=="function"?i.refCleanup=u(p):u.current=p}}catch(x){jt(i,o,x)}}function cr(i,o){var u=i.ref,p=i.refCleanup;if(u!==null)if(typeof p=="function")try{p()}catch(x){jt(i,o,x)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(x){jt(i,o,x)}else u.current=null}function Lb(i){var o=i.type,u=i.memoizedProps,p=i.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":u.autoFocus&&p.focus();break e;case"img":u.src?p.src=u.src:u.srcSet&&(p.srcset=u.srcSet)}}catch(x){jt(i,i.return,x)}}function Cp(i,o,u){try{var p=i.stateNode;i4(p,i.type,u,o),p[rn]=o}catch(x){jt(i,i.return,x)}}function Bb(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Ci(i.type)||i.tag===4}function Np(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Bb(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&Ci(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function Ep(i,o,u){var p=i.tag;if(p===5||p===6)i=i.stateNode,o?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(i,o):(o=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,o.appendChild(i),u=u._reactRootContainer,u!=null||o.onclick!==null||(o.onclick=Er));else if(p!==4&&(p===27&&Ci(i.type)&&(u=i.stateNode,o=null),i=i.child,i!==null))for(Ep(i,o,u),i=i.sibling;i!==null;)Ep(i,o,u),i=i.sibling}function td(i,o,u){var p=i.tag;if(p===5||p===6)i=i.stateNode,o?u.insertBefore(i,o):u.appendChild(i);else if(p!==4&&(p===27&&Ci(i.type)&&(u=i.stateNode),i=i.child,i!==null))for(td(i,o,u),i=i.sibling;i!==null;)td(i,o,u),i=i.sibling}function Ob(i){var o=i.stateNode,u=i.memoizedProps;try{for(var p=i.type,x=o.attributes;x.length;)o.removeAttributeNode(x[0]);Os(o,p,u),o[Rs]=i,o[rn]=u}catch(b){jt(i,i.return,b)}}var Pr=!1,us=!1,Mp=!1,zb=typeof WeakSet=="function"?WeakSet:Set,ks=null;function P3(i,o){if(i=i.containerInfo,Xp=wd,i=Yv(i),wf(i)){if("selectionStart"in i)var u={start:i.selectionStart,end:i.selectionEnd};else e:{u=(u=i.ownerDocument)&&u.defaultView||window;var p=u.getSelection&&u.getSelection();if(p&&p.rangeCount!==0){u=p.anchorNode;var x=p.anchorOffset,b=p.focusNode;p=p.focusOffset;try{u.nodeType,b.nodeType}catch{u=null;break e}var C=0,D=-1,J=-1,ae=0,pe=0,ge=i,le=null;t:for(;;){for(var ue;ge!==u||x!==0&&ge.nodeType!==3||(D=C+x),ge!==b||p!==0&&ge.nodeType!==3||(J=C+p),ge.nodeType===3&&(C+=ge.nodeValue.length),(ue=ge.firstChild)!==null;)le=ge,ge=ue;for(;;){if(ge===i)break t;if(le===u&&++ae===x&&(D=C),le===b&&++pe===p&&(J=C),(ue=ge.nextSibling)!==null)break;ge=le,le=ge.parentNode}ge=ue}u=D===-1||J===-1?null:{start:D,end:J}}else u=null}u=u||{start:0,end:0}}else u=null;for(Jp={focusedElem:i,selectionRange:u},wd=!1,ks=o;ks!==null;)if(o=ks,i=o.child,(o.subtreeFlags&1028)!==0&&i!==null)i.return=o,ks=i;else for(;ks!==null;){switch(o=ks,b=o.alternate,i=o.flags,o.tag){case 0:if((i&4)!==0&&(i=o.updateQueue,i=i!==null?i.events:null,i!==null))for(u=0;u<i.length;u++)x=i[u],x.ref.impl=x.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&b!==null){i=void 0,u=o,x=b.memoizedProps,b=b.memoizedState,p=u.stateNode;try{var De=fa(u.type,x);i=p.getSnapshotBeforeUpdate(De,b),p.__reactInternalSnapshotBeforeUpdate=i}catch(Ve){jt(u,u.return,Ve)}}break;case 3:if((i&1024)!==0){if(i=o.stateNode.containerInfo,u=i.nodeType,u===9)em(i);else if(u===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":em(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(n(163))}if(i=o.sibling,i!==null){i.return=o.return,ks=i;break}ks=o.return}}function Pb(i,o,u){var p=u.flags;switch(u.tag){case 0:case 11:case 15:Ir(i,u),p&4&&Ml(5,u);break;case 1:if(Ir(i,u),p&4)if(i=u.stateNode,o===null)try{i.componentDidMount()}catch(C){jt(u,u.return,C)}else{var x=fa(u.type,o.memoizedProps);o=o.memoizedState;try{i.componentDidUpdate(x,o,i.__reactInternalSnapshotBeforeUpdate)}catch(C){jt(u,u.return,C)}}p&64&&Rb(u),p&512&&Tl(u,u.return);break;case 3:if(Ir(i,u),p&64&&(i=u.updateQueue,i!==null)){if(o=null,u.child!==null)switch(u.child.tag){case 27:case 5:o=u.child.stateNode;break;case 1:o=u.child.stateNode}try{w1(i,o)}catch(C){jt(u,u.return,C)}}break;case 27:o===null&&p&4&&Ob(u);case 26:case 5:Ir(i,u),o===null&&p&4&&Lb(u),p&512&&Tl(u,u.return);break;case 12:Ir(i,u);break;case 31:Ir(i,u),p&4&&Fb(i,u);break;case 13:Ir(i,u),p&4&&Hb(i,u),p&64&&(i=u.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(u=G3.bind(null,u),f4(i,u))));break;case 22:if(p=u.memoizedState!==null||Pr,!p){o=o!==null&&o.memoizedState!==null||us,x=Pr;var b=us;Pr=p,(us=o)&&!b?Fr(i,u,(u.subtreeFlags&8772)!==0):Ir(i,u),Pr=x,us=b}break;case 30:break;default:Ir(i,u)}}function $b(i){var o=i.alternate;o!==null&&(i.alternate=null,$b(o)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(o=i.stateNode,o!==null&&rf(o)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var Ht=null,on=!1;function $r(i,o,u){for(u=u.child;u!==null;)Ib(i,o,u),u=u.sibling}function Ib(i,o,u){if(fe&&typeof fe.onCommitFiberUnmount=="function")try{fe.onCommitFiberUnmount(se,u)}catch{}switch(u.tag){case 26:us||cr(u,o),$r(i,o,u),u.memoizedState?u.memoizedState.count--:u.stateNode&&(u=u.stateNode,u.parentNode.removeChild(u));break;case 27:us||cr(u,o);var p=Ht,x=on;Ci(u.type)&&(Ht=u.stateNode,on=!1),$r(i,o,u),$l(u.stateNode),Ht=p,on=x;break;case 5:us||cr(u,o);case 6:if(p=Ht,x=on,Ht=null,$r(i,o,u),Ht=p,on=x,Ht!==null)if(on)try{(Ht.nodeType===9?Ht.body:Ht.nodeName==="HTML"?Ht.ownerDocument.body:Ht).removeChild(u.stateNode)}catch(b){jt(u,o,b)}else try{Ht.removeChild(u.stateNode)}catch(b){jt(u,o,b)}break;case 18:Ht!==null&&(on?(i=Ht,R_(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,u.stateNode),yo(i)):R_(Ht,u.stateNode));break;case 4:p=Ht,x=on,Ht=u.stateNode.containerInfo,on=!0,$r(i,o,u),Ht=p,on=x;break;case 0:case 11:case 14:case 15:bi(2,u,o),us||bi(4,u,o),$r(i,o,u);break;case 1:us||(cr(u,o),p=u.stateNode,typeof p.componentWillUnmount=="function"&&Db(u,o,p)),$r(i,o,u);break;case 21:$r(i,o,u);break;case 22:us=(p=us)||u.memoizedState!==null,$r(i,o,u),us=p;break;default:$r(i,o,u)}}function Fb(i,o){if(o.memoizedState===null&&(i=o.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{yo(i)}catch(u){jt(o,o.return,u)}}}function Hb(i,o){if(o.memoizedState===null&&(i=o.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{yo(i)}catch(u){jt(o,o.return,u)}}function $3(i){switch(i.tag){case 31:case 13:case 19:var o=i.stateNode;return o===null&&(o=i.stateNode=new zb),o;case 22:return i=i.stateNode,o=i._retryCache,o===null&&(o=i._retryCache=new zb),o;default:throw Error(n(435,i.tag))}}function sd(i,o){var u=$3(i);o.forEach(function(p){if(!u.has(p)){u.add(p);var x=K3.bind(null,i,p);p.then(x,x)}})}function ln(i,o){var u=o.deletions;if(u!==null)for(var p=0;p<u.length;p++){var x=u[p],b=i,C=o,D=C;e:for(;D!==null;){switch(D.tag){case 27:if(Ci(D.type)){Ht=D.stateNode,on=!1;break e}break;case 5:Ht=D.stateNode,on=!1;break e;case 3:case 4:Ht=D.stateNode.containerInfo,on=!0;break e}D=D.return}if(Ht===null)throw Error(n(160));Ib(b,C,x),Ht=null,on=!1,b=x.alternate,b!==null&&(b.return=null),x.return=null}if(o.subtreeFlags&13886)for(o=o.child;o!==null;)Ub(o,i),o=o.sibling}var Qn=null;function Ub(i,o){var u=i.alternate,p=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:ln(o,i),cn(i),p&4&&(bi(3,i,i.return),Ml(3,i),bi(5,i,i.return));break;case 1:ln(o,i),cn(i),p&512&&(us||u===null||cr(u,u.return)),p&64&&Pr&&(i=i.updateQueue,i!==null&&(p=i.callbacks,p!==null&&(u=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=u===null?p:u.concat(p))));break;case 26:var x=Qn;if(ln(o,i),cn(i),p&512&&(us||u===null||cr(u,u.return)),p&4){var b=u!==null?u.memoizedState:null;if(p=i.memoizedState,u===null)if(p===null)if(i.stateNode===null){e:{p=i.type,u=i.memoizedProps,x=x.ownerDocument||x;t:switch(p){case"title":b=x.getElementsByTagName("title")[0],(!b||b[nl]||b[Rs]||b.namespaceURI==="http://www.w3.org/2000/svg"||b.hasAttribute("itemprop"))&&(b=x.createElement(p),x.head.insertBefore(b,x.querySelector("head > title"))),Os(b,p,u),b[Rs]=i,js(b),p=b;break e;case"link":var C=U_("link","href",x).get(p+(u.href||""));if(C){for(var D=0;D<C.length;D++)if(b=C[D],b.getAttribute("href")===(u.href==null||u.href===""?null:u.href)&&b.getAttribute("rel")===(u.rel==null?null:u.rel)&&b.getAttribute("title")===(u.title==null?null:u.title)&&b.getAttribute("crossorigin")===(u.crossOrigin==null?null:u.crossOrigin)){C.splice(D,1);break t}}b=x.createElement(p),Os(b,p,u),x.head.appendChild(b);break;case"meta":if(C=U_("meta","content",x).get(p+(u.content||""))){for(D=0;D<C.length;D++)if(b=C[D],b.getAttribute("content")===(u.content==null?null:""+u.content)&&b.getAttribute("name")===(u.name==null?null:u.name)&&b.getAttribute("property")===(u.property==null?null:u.property)&&b.getAttribute("http-equiv")===(u.httpEquiv==null?null:u.httpEquiv)&&b.getAttribute("charset")===(u.charSet==null?null:u.charSet)){C.splice(D,1);break t}}b=x.createElement(p),Os(b,p,u),x.head.appendChild(b);break;default:throw Error(n(468,p))}b[Rs]=i,js(b),p=b}i.stateNode=p}else V_(x,i.type,i.stateNode);else i.stateNode=H_(x,p,i.memoizedProps);else b!==p?(b===null?u.stateNode!==null&&(u=u.stateNode,u.parentNode.removeChild(u)):b.count--,p===null?V_(x,i.type,i.stateNode):H_(x,p,i.memoizedProps)):p===null&&i.stateNode!==null&&Cp(i,i.memoizedProps,u.memoizedProps)}break;case 27:ln(o,i),cn(i),p&512&&(us||u===null||cr(u,u.return)),u!==null&&p&4&&Cp(i,i.memoizedProps,u.memoizedProps);break;case 5:if(ln(o,i),cn(i),p&512&&(us||u===null||cr(u,u.return)),i.flags&32){x=i.stateNode;try{Ua(x,"")}catch(De){jt(i,i.return,De)}}p&4&&i.stateNode!=null&&(x=i.memoizedProps,Cp(i,x,u!==null?u.memoizedProps:x)),p&1024&&(Mp=!0);break;case 6:if(ln(o,i),cn(i),p&4){if(i.stateNode===null)throw Error(n(162));p=i.memoizedProps,u=i.stateNode;try{u.nodeValue=p}catch(De){jt(i,i.return,De)}}break;case 3:if(vd=null,x=Qn,Qn=gd(o.containerInfo),ln(o,i),Qn=x,cn(i),p&4&&u!==null&&u.memoizedState.isDehydrated)try{yo(o.containerInfo)}catch(De){jt(i,i.return,De)}Mp&&(Mp=!1,Vb(i));break;case 4:p=Qn,Qn=gd(i.stateNode.containerInfo),ln(o,i),cn(i),Qn=p;break;case 12:ln(o,i),cn(i);break;case 31:ln(o,i),cn(i),p&4&&(p=i.updateQueue,p!==null&&(i.updateQueue=null,sd(i,p)));break;case 13:ln(o,i),cn(i),i.child.flags&8192&&i.memoizedState!==null!=(u!==null&&u.memoizedState!==null)&&(rd=vt()),p&4&&(p=i.updateQueue,p!==null&&(i.updateQueue=null,sd(i,p)));break;case 22:x=i.memoizedState!==null;var J=u!==null&&u.memoizedState!==null,ae=Pr,pe=us;if(Pr=ae||x,us=pe||J,ln(o,i),us=pe,Pr=ae,cn(i),p&8192)e:for(o=i.stateNode,o._visibility=x?o._visibility&-2:o._visibility|1,x&&(u===null||J||Pr||us||pa(i)),u=null,o=i;;){if(o.tag===5||o.tag===26){if(u===null){J=u=o;try{if(b=J.stateNode,x)C=b.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none";else{D=J.stateNode;var ge=J.memoizedProps.style,le=ge!=null&&ge.hasOwnProperty("display")?ge.display:null;D.style.display=le==null||typeof le=="boolean"?"":(""+le).trim()}}catch(De){jt(J,J.return,De)}}}else if(o.tag===6){if(u===null){J=o;try{J.stateNode.nodeValue=x?"":J.memoizedProps}catch(De){jt(J,J.return,De)}}}else if(o.tag===18){if(u===null){J=o;try{var ue=J.stateNode;x?D_(ue,!0):D_(J.stateNode,!1)}catch(De){jt(J,J.return,De)}}}else if((o.tag!==22&&o.tag!==23||o.memoizedState===null||o===i)&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===i)break e;for(;o.sibling===null;){if(o.return===null||o.return===i)break e;u===o&&(u=null),o=o.return}u===o&&(u=null),o.sibling.return=o.return,o=o.sibling}p&4&&(p=i.updateQueue,p!==null&&(u=p.retryQueue,u!==null&&(p.retryQueue=null,sd(i,u))));break;case 19:ln(o,i),cn(i),p&4&&(p=i.updateQueue,p!==null&&(i.updateQueue=null,sd(i,p)));break;case 30:break;case 21:break;default:ln(o,i),cn(i)}}function cn(i){var o=i.flags;if(o&2){try{for(var u,p=i.return;p!==null;){if(Bb(p)){u=p;break}p=p.return}if(u==null)throw Error(n(160));switch(u.tag){case 27:var x=u.stateNode,b=Np(i);td(i,b,x);break;case 5:var C=u.stateNode;u.flags&32&&(Ua(C,""),u.flags&=-33);var D=Np(i);td(i,D,C);break;case 3:case 4:var J=u.stateNode.containerInfo,ae=Np(i);Ep(i,ae,J);break;default:throw Error(n(161))}}catch(pe){jt(i,i.return,pe)}i.flags&=-3}o&4096&&(i.flags&=-4097)}function Vb(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var o=i;Vb(o),o.tag===5&&o.flags&1024&&o.stateNode.reset(),i=i.sibling}}function Ir(i,o){if(o.subtreeFlags&8772)for(o=o.child;o!==null;)Pb(i,o.alternate,o),o=o.sibling}function pa(i){for(i=i.child;i!==null;){var o=i;switch(o.tag){case 0:case 11:case 14:case 15:bi(4,o,o.return),pa(o);break;case 1:cr(o,o.return);var u=o.stateNode;typeof u.componentWillUnmount=="function"&&Db(o,o.return,u),pa(o);break;case 27:$l(o.stateNode);case 26:case 5:cr(o,o.return),pa(o);break;case 22:o.memoizedState===null&&pa(o);break;case 30:pa(o);break;default:pa(o)}i=i.sibling}}function Fr(i,o,u){for(u=u&&(o.subtreeFlags&8772)!==0,o=o.child;o!==null;){var p=o.alternate,x=i,b=o,C=b.flags;switch(b.tag){case 0:case 11:case 15:Fr(x,b,u),Ml(4,b);break;case 1:if(Fr(x,b,u),p=b,x=p.stateNode,typeof x.componentDidMount=="function")try{x.componentDidMount()}catch(ae){jt(p,p.return,ae)}if(p=b,x=p.updateQueue,x!==null){var D=p.stateNode;try{var J=x.shared.hiddenCallbacks;if(J!==null)for(x.shared.hiddenCallbacks=null,x=0;x<J.length;x++)y1(J[x],D)}catch(ae){jt(p,p.return,ae)}}u&&C&64&&Rb(b),Tl(b,b.return);break;case 27:Ob(b);case 26:case 5:Fr(x,b,u),u&&p===null&&C&4&&Lb(b),Tl(b,b.return);break;case 12:Fr(x,b,u);break;case 31:Fr(x,b,u),u&&C&4&&Fb(x,b);break;case 13:Fr(x,b,u),u&&C&4&&Hb(x,b);break;case 22:b.memoizedState===null&&Fr(x,b,u),Tl(b,b.return);break;case 30:break;default:Fr(x,b,u)}o=o.sibling}}function Tp(i,o){var u=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(u=i.memoizedState.cachePool.pool),i=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(i=o.memoizedState.cachePool.pool),i!==u&&(i!=null&&i.refCount++,u!=null&&gl(u))}function Ap(i,o){i=null,o.alternate!==null&&(i=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==i&&(o.refCount++,i!=null&&gl(i))}function Zn(i,o,u,p){if(o.subtreeFlags&10256)for(o=o.child;o!==null;)Wb(i,o,u,p),o=o.sibling}function Wb(i,o,u,p){var x=o.flags;switch(o.tag){case 0:case 11:case 15:Zn(i,o,u,p),x&2048&&Ml(9,o);break;case 1:Zn(i,o,u,p);break;case 3:Zn(i,o,u,p),x&2048&&(i=null,o.alternate!==null&&(i=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==i&&(o.refCount++,i!=null&&gl(i)));break;case 12:if(x&2048){Zn(i,o,u,p),i=o.stateNode;try{var b=o.memoizedProps,C=b.id,D=b.onPostCommit;typeof D=="function"&&D(C,o.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(J){jt(o,o.return,J)}}else Zn(i,o,u,p);break;case 31:Zn(i,o,u,p);break;case 13:Zn(i,o,u,p);break;case 23:break;case 22:b=o.stateNode,C=o.alternate,o.memoizedState!==null?b._visibility&2?Zn(i,o,u,p):Al(i,o):b._visibility&2?Zn(i,o,u,p):(b._visibility|=2,co(i,o,u,p,(o.subtreeFlags&10256)!==0||!1)),x&2048&&Tp(C,o);break;case 24:Zn(i,o,u,p),x&2048&&Ap(o.alternate,o);break;default:Zn(i,o,u,p)}}function co(i,o,u,p,x){for(x=x&&((o.subtreeFlags&10256)!==0||!1),o=o.child;o!==null;){var b=i,C=o,D=u,J=p,ae=C.flags;switch(C.tag){case 0:case 11:case 15:co(b,C,D,J,x),Ml(8,C);break;case 23:break;case 22:var pe=C.stateNode;C.memoizedState!==null?pe._visibility&2?co(b,C,D,J,x):Al(b,C):(pe._visibility|=2,co(b,C,D,J,x)),x&&ae&2048&&Tp(C.alternate,C);break;case 24:co(b,C,D,J,x),x&&ae&2048&&Ap(C.alternate,C);break;default:co(b,C,D,J,x)}o=o.sibling}}function Al(i,o){if(o.subtreeFlags&10256)for(o=o.child;o!==null;){var u=i,p=o,x=p.flags;switch(p.tag){case 22:Al(u,p),x&2048&&Tp(p.alternate,p);break;case 24:Al(u,p),x&2048&&Ap(p.alternate,p);break;default:Al(u,p)}o=o.sibling}}var Rl=8192;function uo(i,o,u){if(i.subtreeFlags&Rl)for(i=i.child;i!==null;)qb(i,o,u),i=i.sibling}function qb(i,o,u){switch(i.tag){case 26:uo(i,o,u),i.flags&Rl&&i.memoizedState!==null&&k4(u,Qn,i.memoizedState,i.memoizedProps);break;case 5:uo(i,o,u);break;case 3:case 4:var p=Qn;Qn=gd(i.stateNode.containerInfo),uo(i,o,u),Qn=p;break;case 22:i.memoizedState===null&&(p=i.alternate,p!==null&&p.memoizedState!==null?(p=Rl,Rl=16777216,uo(i,o,u),Rl=p):uo(i,o,u));break;default:uo(i,o,u)}}function Gb(i){var o=i.alternate;if(o!==null&&(i=o.child,i!==null)){o.child=null;do o=i.sibling,i.sibling=null,i=o;while(i!==null)}}function Dl(i){var o=i.deletions;if((i.flags&16)!==0){if(o!==null)for(var u=0;u<o.length;u++){var p=o[u];ks=p,Yb(p,i)}Gb(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)Kb(i),i=i.sibling}function Kb(i){switch(i.tag){case 0:case 11:case 15:Dl(i),i.flags&2048&&bi(9,i,i.return);break;case 3:Dl(i);break;case 12:Dl(i);break;case 22:var o=i.stateNode;i.memoizedState!==null&&o._visibility&2&&(i.return===null||i.return.tag!==13)?(o._visibility&=-3,nd(i)):Dl(i);break;default:Dl(i)}}function nd(i){var o=i.deletions;if((i.flags&16)!==0){if(o!==null)for(var u=0;u<o.length;u++){var p=o[u];ks=p,Yb(p,i)}Gb(i)}for(i=i.child;i!==null;){switch(o=i,o.tag){case 0:case 11:case 15:bi(8,o,o.return),nd(o);break;case 22:u=o.stateNode,u._visibility&2&&(u._visibility&=-3,nd(o));break;default:nd(o)}i=i.sibling}}function Yb(i,o){for(;ks!==null;){var u=ks;switch(u.tag){case 0:case 11:case 15:bi(8,u,o);break;case 23:case 22:if(u.memoizedState!==null&&u.memoizedState.cachePool!==null){var p=u.memoizedState.cachePool.pool;p!=null&&p.refCount++}break;case 24:gl(u.memoizedState.cache)}if(p=u.child,p!==null)p.return=u,ks=p;else e:for(u=i;ks!==null;){p=ks;var x=p.sibling,b=p.return;if($b(p),p===u){ks=null;break e}if(x!==null){x.return=b,ks=x;break e}ks=b}}}var I3={getCacheForType:function(i){var o=Ls(os),u=o.data.get(i);return u===void 0&&(u=i(),o.data.set(i,u)),u},cacheSignal:function(){return Ls(os).controller.signal}},F3=typeof WeakMap=="function"?WeakMap:Map,bt=0,Mt=null,rt=null,lt=0,St=0,Sn=null,_i=!1,ho=!1,Rp=!1,Hr=0,Qt=0,yi=0,ma=0,Dp=0,jn=0,fo=0,Ll=null,un=null,Lp=!1,rd=0,Xb=0,id=1/0,ad=null,wi=null,vs=0,Si=null,po=null,Ur=0,Bp=0,Op=null,Jb=null,Bl=0,zp=null;function kn(){return(bt&2)!==0&&lt!==0?lt&-lt:M.T!==null?Up():fv()}function Qb(){if(jn===0)if((lt&536870912)===0||dt){var i=ir;ir<<=1,(ir&3932160)===0&&(ir=262144),jn=i}else jn=536870912;return i=yn.current,i!==null&&(i.flags|=32),jn}function dn(i,o,u){(i===Mt&&(St===2||St===9)||i.cancelPendingCommit!==null)&&(mo(i,0),ji(i,lt,jn,!1)),Ot(i,u),((bt&2)===0||i!==Mt)&&(i===Mt&&((bt&2)===0&&(ma|=u),Qt===4&&ji(i,lt,jn,!1)),ur(i))}function Zb(i,o,u){if((bt&6)!==0)throw Error(n(327));var p=!u&&(o&127)===0&&(o&i.expiredLanes)===0||ce(i,o),x=p?V3(i,o):$p(i,o,!0),b=p;do{if(x===0){ho&&!p&&ji(i,o,0,!1);break}else{if(u=i.current.alternate,b&&!H3(u)){x=$p(i,o,!1),b=!1;continue}if(x===2){if(b=o,i.errorRecoveryDisabledLanes&b)var C=0;else C=i.pendingLanes&-536870913,C=C!==0?C:C&536870912?536870912:0;if(C!==0){o=C;e:{var D=i;x=Ll;var J=D.current.memoizedState.isDehydrated;if(J&&(mo(D,C).flags|=256),C=$p(D,C,!1),C!==2){if(Rp&&!J){D.errorRecoveryDisabledLanes|=b,ma|=b,x=4;break e}b=un,un=x,b!==null&&(un===null?un=b:un.push.apply(un,b))}x=C}if(b=!1,x!==2)continue}}if(x===1){mo(i,0),ji(i,o,0,!0);break}e:{switch(p=i,b=x,b){case 0:case 1:throw Error(n(345));case 4:if((o&4194048)!==o)break;case 6:ji(p,o,jn,!_i);break e;case 2:un=null;break;case 3:case 5:break;default:throw Error(n(329))}if((o&62914560)===o&&(x=rd+300-vt(),10<x)){if(ji(p,o,jn,!_i),Qi(p,0,!0)!==0)break e;Ur=o,p.timeoutHandle=T_(e_.bind(null,p,u,un,ad,Lp,o,jn,ma,fo,_i,b,"Throttled",-0,0),x);break e}e_(p,u,un,ad,Lp,o,jn,ma,fo,_i,b,null,-0,0)}}break}while(!0);ur(i)}function e_(i,o,u,p,x,b,C,D,J,ae,pe,ge,le,ue){if(i.timeoutHandle=-1,ge=o.subtreeFlags,ge&8192||(ge&16785408)===16785408){ge={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Er},qb(o,b,ge);var De=(b&62914560)===b?rd-vt():(b&4194048)===b?Xb-vt():0;if(De=C4(ge,De),De!==null){Ur=b,i.cancelPendingCommit=De(l_.bind(null,i,o,b,u,p,x,C,D,J,pe,ge,null,le,ue)),ji(i,b,C,!ae);return}}l_(i,o,b,u,p,x,C,D,J)}function H3(i){for(var o=i;;){var u=o.tag;if((u===0||u===11||u===15)&&o.flags&16384&&(u=o.updateQueue,u!==null&&(u=u.stores,u!==null)))for(var p=0;p<u.length;p++){var x=u[p],b=x.getSnapshot;x=x.value;try{if(!bn(b(),x))return!1}catch{return!1}}if(u=o.child,o.subtreeFlags&16384&&u!==null)u.return=o,o=u;else{if(o===i)break;for(;o.sibling===null;){if(o.return===null||o.return===i)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function ji(i,o,u,p){o&=~Dp,o&=~ma,i.suspendedLanes|=o,i.pingedLanes&=~o,p&&(i.warmLanes|=o),p=i.expirationTimes;for(var x=o;0<x;){var b=31-ee(x),C=1<<b;p[b]=-1,x&=~C}u!==0&&Oa(i,u,o)}function od(){return(bt&6)===0?(Ol(0),!1):!0}function Pp(){if(rt!==null){if(St===0)var i=rt.return;else i=rt,Rr=aa=null,ep(i),ro=null,vl=0,i=rt;for(;i!==null;)Ab(i.alternate,i),i=i.return;rt=null}}function mo(i,o){var u=i.timeoutHandle;u!==-1&&(i.timeoutHandle=-1,l4(u)),u=i.cancelPendingCommit,u!==null&&(i.cancelPendingCommit=null,u()),Ur=0,Pp(),Mt=i,rt=u=Tr(i.current,null),lt=o,St=0,Sn=null,_i=!1,ho=ce(i,o),Rp=!1,fo=jn=Dp=ma=yi=Qt=0,un=Ll=null,Lp=!1,(o&8)!==0&&(o|=o&32);var p=i.entangledLanes;if(p!==0)for(i=i.entanglements,p&=o;0<p;){var x=31-ee(p),b=1<<x;o|=i[x],p&=~b}return Hr=o,Eu(),u}function t_(i,o){Qe=null,M.H=Cl,o===no||o===Ou?(o=x1(),St=3):o===Hf?(o=x1(),St=4):St=o===gp?8:o!==null&&typeof o=="object"&&typeof o.then=="function"?6:1,Sn=o,rt===null&&(Qt=1,Xu(i,On(o,i.current)))}function s_(){var i=yn.current;return i===null?!0:(lt&4194048)===lt?In===null:(lt&62914560)===lt||(lt&536870912)!==0?i===In:!1}function n_(){var i=M.H;return M.H=Cl,i===null?Cl:i}function r_(){var i=M.A;return M.A=I3,i}function ld(){Qt=4,_i||(lt&4194048)!==lt&&yn.current!==null||(ho=!0),(yi&134217727)===0&&(ma&134217727)===0||Mt===null||ji(Mt,lt,jn,!1)}function $p(i,o,u){var p=bt;bt|=2;var x=n_(),b=r_();(Mt!==i||lt!==o)&&(ad=null,mo(i,o)),o=!1;var C=Qt;e:do try{if(St!==0&&rt!==null){var D=rt,J=Sn;switch(St){case 8:Pp(),C=6;break e;case 3:case 2:case 9:case 6:yn.current===null&&(o=!0);var ae=St;if(St=0,Sn=null,go(i,D,J,ae),u&&ho){C=0;break e}break;default:ae=St,St=0,Sn=null,go(i,D,J,ae)}}U3(),C=Qt;break}catch(pe){t_(i,pe)}while(!0);return o&&i.shellSuspendCounter++,Rr=aa=null,bt=p,M.H=x,M.A=b,rt===null&&(Mt=null,lt=0,Eu()),C}function U3(){for(;rt!==null;)i_(rt)}function V3(i,o){var u=bt;bt|=2;var p=n_(),x=r_();Mt!==i||lt!==o?(ad=null,id=vt()+500,mo(i,o)):ho=ce(i,o);e:do try{if(St!==0&&rt!==null){o=rt;var b=Sn;t:switch(St){case 1:St=0,Sn=null,go(i,o,b,1);break;case 2:case 9:if(m1(b)){St=0,Sn=null,a_(o);break}o=function(){St!==2&&St!==9||Mt!==i||(St=7),ur(i)},b.then(o,o);break e;case 3:St=7;break e;case 4:St=5;break e;case 7:m1(b)?(St=0,Sn=null,a_(o)):(St=0,Sn=null,go(i,o,b,7));break;case 5:var C=null;switch(rt.tag){case 26:C=rt.memoizedState;case 5:case 27:var D=rt;if(C?W_(C):D.stateNode.complete){St=0,Sn=null;var J=D.sibling;if(J!==null)rt=J;else{var ae=D.return;ae!==null?(rt=ae,cd(ae)):rt=null}break t}}St=0,Sn=null,go(i,o,b,5);break;case 6:St=0,Sn=null,go(i,o,b,6);break;case 8:Pp(),Qt=6;break e;default:throw Error(n(462))}}W3();break}catch(pe){t_(i,pe)}while(!0);return Rr=aa=null,M.H=p,M.A=x,bt=u,rt!==null?0:(Mt=null,lt=0,Eu(),Qt)}function W3(){for(;rt!==null&&!Hs();)i_(rt)}function i_(i){var o=Mb(i.alternate,i,Hr);i.memoizedProps=i.pendingProps,o===null?cd(i):rt=o}function a_(i){var o=i,u=o.alternate;switch(o.tag){case 15:case 0:o=Sb(u,o,o.pendingProps,o.type,void 0,lt);break;case 11:o=Sb(u,o,o.pendingProps,o.type.render,o.ref,lt);break;case 5:ep(o);default:Ab(u,o),o=rt=r1(o,Hr),o=Mb(u,o,Hr)}i.memoizedProps=i.pendingProps,o===null?cd(i):rt=o}function go(i,o,u,p){Rr=aa=null,ep(o),ro=null,vl=0;var x=o.return;try{if(D3(i,x,o,u,lt)){Qt=1,Xu(i,On(u,i.current)),rt=null;return}}catch(b){if(x!==null)throw rt=x,b;Qt=1,Xu(i,On(u,i.current)),rt=null;return}o.flags&32768?(dt||p===1?i=!0:ho||(lt&536870912)!==0?i=!1:(_i=i=!0,(p===2||p===9||p===3||p===6)&&(p=yn.current,p!==null&&p.tag===13&&(p.flags|=16384))),o_(o,i)):cd(o)}function cd(i){var o=i;do{if((o.flags&32768)!==0){o_(o,_i);return}i=o.return;var u=O3(o.alternate,o,Hr);if(u!==null){rt=u;return}if(o=o.sibling,o!==null){rt=o;return}rt=o=i}while(o!==null);Qt===0&&(Qt=5)}function o_(i,o){do{var u=z3(i.alternate,i);if(u!==null){u.flags&=32767,rt=u;return}if(u=i.return,u!==null&&(u.flags|=32768,u.subtreeFlags=0,u.deletions=null),!o&&(i=i.sibling,i!==null)){rt=i;return}rt=i=u}while(i!==null);Qt=6,rt=null}function l_(i,o,u,p,x,b,C,D,J){i.cancelPendingCommit=null;do ud();while(vs!==0);if((bt&6)!==0)throw Error(n(327));if(o!==null){if(o===i.current)throw Error(n(177));if(b=o.lanes|o.childLanes,b|=Nf,pt(i,u,b,C,D,J),i===Mt&&(rt=Mt=null,lt=0),po=o,Si=i,Ur=u,Bp=b,Op=x,Jb=p,(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,Y3(Be,function(){return f_(),null})):(i.callbackNode=null,i.callbackPriority=0),p=(o.flags&13878)!==0,(o.subtreeFlags&13878)!==0||p){p=M.T,M.T=null,x=O.p,O.p=2,C=bt,bt|=4;try{P3(i,o,u)}finally{bt=C,O.p=x,M.T=p}}vs=1,c_(),u_(),d_()}}function c_(){if(vs===1){vs=0;var i=Si,o=po,u=(o.flags&13878)!==0;if((o.subtreeFlags&13878)!==0||u){u=M.T,M.T=null;var p=O.p;O.p=2;var x=bt;bt|=4;try{Ub(o,i);var b=Jp,C=Yv(i.containerInfo),D=b.focusedElem,J=b.selectionRange;if(C!==D&&D&&D.ownerDocument&&Kv(D.ownerDocument.documentElement,D)){if(J!==null&&wf(D)){var ae=J.start,pe=J.end;if(pe===void 0&&(pe=ae),"selectionStart"in D)D.selectionStart=ae,D.selectionEnd=Math.min(pe,D.value.length);else{var ge=D.ownerDocument||document,le=ge&&ge.defaultView||window;if(le.getSelection){var ue=le.getSelection(),De=D.textContent.length,Ve=Math.min(J.start,De),Nt=J.end===void 0?Ve:Math.min(J.end,De);!ue.extend&&Ve>Nt&&(C=Nt,Nt=Ve,Ve=C);var te=Gv(D,Ve),Z=Gv(D,Nt);if(te&&Z&&(ue.rangeCount!==1||ue.anchorNode!==te.node||ue.anchorOffset!==te.offset||ue.focusNode!==Z.node||ue.focusOffset!==Z.offset)){var ie=ge.createRange();ie.setStart(te.node,te.offset),ue.removeAllRanges(),Ve>Nt?(ue.addRange(ie),ue.extend(Z.node,Z.offset)):(ie.setEnd(Z.node,Z.offset),ue.addRange(ie))}}}}for(ge=[],ue=D;ue=ue.parentNode;)ue.nodeType===1&&ge.push({element:ue,left:ue.scrollLeft,top:ue.scrollTop});for(typeof D.focus=="function"&&D.focus(),D=0;D<ge.length;D++){var me=ge[D];me.element.scrollLeft=me.left,me.element.scrollTop=me.top}}wd=!!Xp,Jp=Xp=null}finally{bt=x,O.p=p,M.T=u}}i.current=o,vs=2}}function u_(){if(vs===2){vs=0;var i=Si,o=po,u=(o.flags&8772)!==0;if((o.subtreeFlags&8772)!==0||u){u=M.T,M.T=null;var p=O.p;O.p=2;var x=bt;bt|=4;try{Pb(i,o.alternate,o)}finally{bt=x,O.p=p,M.T=u}}vs=3}}function d_(){if(vs===4||vs===3){vs=0,gs();var i=Si,o=po,u=Ur,p=Jb;(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?vs=5:(vs=0,po=Si=null,h_(i,i.pendingLanes));var x=i.pendingLanes;if(x===0&&(wi=null),sf(u),o=o.stateNode,fe&&typeof fe.onCommitFiberRoot=="function")try{fe.onCommitFiberRoot(se,o,void 0,(o.current.flags&128)===128)}catch{}if(p!==null){o=M.T,x=O.p,O.p=2,M.T=null;try{for(var b=i.onRecoverableError,C=0;C<p.length;C++){var D=p[C];b(D.value,{componentStack:D.stack})}}finally{M.T=o,O.p=x}}(Ur&3)!==0&&ud(),ur(i),x=i.pendingLanes,(u&261930)!==0&&(x&42)!==0?i===zp?Bl++:(Bl=0,zp=i):Bl=0,Ol(0)}}function h_(i,o){(i.pooledCacheLanes&=o)===0&&(o=i.pooledCache,o!=null&&(i.pooledCache=null,gl(o)))}function ud(){return c_(),u_(),d_(),f_()}function f_(){if(vs!==5)return!1;var i=Si,o=Bp;Bp=0;var u=sf(Ur),p=M.T,x=O.p;try{O.p=32>u?32:u,M.T=null,u=Op,Op=null;var b=Si,C=Ur;if(vs=0,po=Si=null,Ur=0,(bt&6)!==0)throw Error(n(331));var D=bt;if(bt|=4,Kb(b.current),Wb(b,b.current,C,u),bt=D,Ol(0,!1),fe&&typeof fe.onPostCommitFiberRoot=="function")try{fe.onPostCommitFiberRoot(se,b)}catch{}return!0}finally{O.p=x,M.T=p,h_(i,o)}}function p_(i,o,u){o=On(u,o),o=mp(i.stateNode,o,2),i=gi(i,o,2),i!==null&&(Ot(i,2),ur(i))}function jt(i,o,u){if(i.tag===3)p_(i,i,u);else for(;o!==null;){if(o.tag===3){p_(o,i,u);break}else if(o.tag===1){var p=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof p.componentDidCatch=="function"&&(wi===null||!wi.has(p))){i=On(u,i),u=mb(2),p=gi(o,u,2),p!==null&&(gb(u,p,o,i),Ot(p,2),ur(p));break}}o=o.return}}function Ip(i,o,u){var p=i.pingCache;if(p===null){p=i.pingCache=new F3;var x=new Set;p.set(o,x)}else x=p.get(o),x===void 0&&(x=new Set,p.set(o,x));x.has(u)||(Rp=!0,x.add(u),i=q3.bind(null,i,o,u),o.then(i,i))}function q3(i,o,u){var p=i.pingCache;p!==null&&p.delete(o),i.pingedLanes|=i.suspendedLanes&u,i.warmLanes&=~u,Mt===i&&(lt&u)===u&&(Qt===4||Qt===3&&(lt&62914560)===lt&&300>vt()-rd?(bt&2)===0&&mo(i,0):Dp|=u,fo===lt&&(fo=0)),ur(i)}function m_(i,o){o===0&&(o=wt()),i=na(i,o),i!==null&&(Ot(i,o),ur(i))}function G3(i){var o=i.memoizedState,u=0;o!==null&&(u=o.retryLane),m_(i,u)}function K3(i,o){var u=0;switch(i.tag){case 31:case 13:var p=i.stateNode,x=i.memoizedState;x!==null&&(u=x.retryLane);break;case 19:p=i.stateNode;break;case 22:p=i.stateNode._retryCache;break;default:throw Error(n(314))}p!==null&&p.delete(o),m_(i,u)}function Y3(i,o){return Ft(i,o)}var dd=null,xo=null,Fp=!1,hd=!1,Hp=!1,ki=0;function ur(i){i!==xo&&i.next===null&&(xo===null?dd=xo=i:xo=xo.next=i),hd=!0,Fp||(Fp=!0,J3())}function Ol(i,o){if(!Hp&&hd){Hp=!0;do for(var u=!1,p=dd;p!==null;){if(i!==0){var x=p.pendingLanes;if(x===0)var b=0;else{var C=p.suspendedLanes,D=p.pingedLanes;b=(1<<31-ee(42|i)+1)-1,b&=x&~(C&~D),b=b&201326741?b&201326741|1:b?b|2:0}b!==0&&(u=!0,b_(p,b))}else b=lt,b=Qi(p,p===Mt?b:0,p.cancelPendingCommit!==null||p.timeoutHandle!==-1),(b&3)===0||ce(p,b)||(u=!0,b_(p,b));p=p.next}while(u);Hp=!1}}function X3(){g_()}function g_(){hd=Fp=!1;var i=0;ki!==0&&o4()&&(i=ki);for(var o=vt(),u=null,p=dd;p!==null;){var x=p.next,b=x_(p,o);b===0?(p.next=null,u===null?dd=x:u.next=x,x===null&&(xo=u)):(u=p,(i!==0||(b&3)!==0)&&(hd=!0)),p=x}vs!==0&&vs!==5||Ol(i),ki!==0&&(ki=0)}function x_(i,o){for(var u=i.suspendedLanes,p=i.pingedLanes,x=i.expirationTimes,b=i.pendingLanes&-62914561;0<b;){var C=31-ee(b),D=1<<C,J=x[C];J===-1?((D&u)===0||(D&p)!==0)&&(x[C]=$e(D,o)):J<=o&&(i.expiredLanes|=D),b&=~D}if(o=Mt,u=lt,u=Qi(i,i===o?u:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),p=i.callbackNode,u===0||i===o&&(St===2||St===9)||i.cancelPendingCommit!==null)return p!==null&&p!==null&&Rt(p),i.callbackNode=null,i.callbackPriority=0;if((u&3)===0||ce(i,u)){if(o=u&-u,o===i.callbackPriority)return o;switch(p!==null&&Rt(p),sf(u)){case 2:case 8:u=_e;break;case 32:u=Be;break;case 268435456:u=Je;break;default:u=Be}return p=v_.bind(null,i),u=Ft(u,p),i.callbackPriority=o,i.callbackNode=u,o}return p!==null&&p!==null&&Rt(p),i.callbackPriority=2,i.callbackNode=null,2}function v_(i,o){if(vs!==0&&vs!==5)return i.callbackNode=null,i.callbackPriority=0,null;var u=i.callbackNode;if(ud()&&i.callbackNode!==u)return null;var p=lt;return p=Qi(i,i===Mt?p:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),p===0?null:(Zb(i,p,o),x_(i,vt()),i.callbackNode!=null&&i.callbackNode===u?v_.bind(null,i):null)}function b_(i,o){if(ud())return null;Zb(i,o,!0)}function J3(){c4(function(){(bt&6)!==0?Ft(de,X3):g_()})}function Up(){if(ki===0){var i=to;i===0&&(i=ss,ss<<=1,(ss&261888)===0&&(ss=256)),ki=i}return ki}function __(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:_u(""+i)}function y_(i,o){var u=o.ownerDocument.createElement("input");return u.name=o.name,u.value=o.value,i.id&&u.setAttribute("form",i.id),o.parentNode.insertBefore(u,o),i=new FormData(i),u.parentNode.removeChild(u),i}function Q3(i,o,u,p,x){if(o==="submit"&&u&&u.stateNode===x){var b=__((x[rn]||null).action),C=p.submitter;C&&(o=(o=C[rn]||null)?__(o.formAction):C.getAttribute("formAction"),o!==null&&(b=o,C=null));var D=new ju("action","action",null,p,x);i.push({event:D,listeners:[{instance:null,listener:function(){if(p.defaultPrevented){if(ki!==0){var J=C?y_(x,C):new FormData(x);cp(u,{pending:!0,data:J,method:x.method,action:b},null,J)}}else typeof b=="function"&&(D.preventDefault(),J=C?y_(x,C):new FormData(x),cp(u,{pending:!0,data:J,method:x.method,action:b},b,J))},currentTarget:x}]})}}for(var Vp=0;Vp<Cf.length;Vp++){var Wp=Cf[Vp],Z3=Wp.toLowerCase(),e4=Wp[0].toUpperCase()+Wp.slice(1);Jn(Z3,"on"+e4)}Jn(Qv,"onAnimationEnd"),Jn(Zv,"onAnimationIteration"),Jn(e1,"onAnimationStart"),Jn("dblclick","onDoubleClick"),Jn("focusin","onFocus"),Jn("focusout","onBlur"),Jn(g3,"onTransitionRun"),Jn(x3,"onTransitionStart"),Jn(v3,"onTransitionCancel"),Jn(t1,"onTransitionEnd"),Fa("onMouseEnter",["mouseout","mouseover"]),Fa("onMouseLeave",["mouseout","mouseover"]),Fa("onPointerEnter",["pointerout","pointerover"]),Fa("onPointerLeave",["pointerout","pointerover"]),Zi("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Zi("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Zi("onBeforeInput",["compositionend","keypress","textInput","paste"]),Zi("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Zi("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Zi("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var zl="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(" "),t4=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(zl));function w_(i,o){o=(o&4)!==0;for(var u=0;u<i.length;u++){var p=i[u],x=p.event;p=p.listeners;e:{var b=void 0;if(o)for(var C=p.length-1;0<=C;C--){var D=p[C],J=D.instance,ae=D.currentTarget;if(D=D.listener,J!==b&&x.isPropagationStopped())break e;b=D,x.currentTarget=ae;try{b(x)}catch(pe){Nu(pe)}x.currentTarget=null,b=J}else for(C=0;C<p.length;C++){if(D=p[C],J=D.instance,ae=D.currentTarget,D=D.listener,J!==b&&x.isPropagationStopped())break e;b=D,x.currentTarget=ae;try{b(x)}catch(pe){Nu(pe)}x.currentTarget=null,b=J}}}}function it(i,o){var u=o[nf];u===void 0&&(u=o[nf]=new Set);var p=i+"__bubble";u.has(p)||(S_(o,i,2,!1),u.add(p))}function qp(i,o,u){var p=0;o&&(p|=4),S_(u,i,p,o)}var fd="_reactListening"+Math.random().toString(36).slice(2);function Gp(i){if(!i[fd]){i[fd]=!0,gv.forEach(function(u){u!=="selectionchange"&&(t4.has(u)||qp(u,!1,i),qp(u,!0,i))});var o=i.nodeType===9?i:i.ownerDocument;o===null||o[fd]||(o[fd]=!0,qp("selectionchange",!1,o))}}function S_(i,o,u,p){switch(Q_(o)){case 2:var x=M4;break;case 8:x=T4;break;default:x=lm}u=x.bind(null,o,u,i),x=void 0,!ff||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(x=!0),p?x!==void 0?i.addEventListener(o,u,{capture:!0,passive:x}):i.addEventListener(o,u,!0):x!==void 0?i.addEventListener(o,u,{passive:x}):i.addEventListener(o,u,!1)}function Kp(i,o,u,p,x){var b=p;if((o&1)===0&&(o&2)===0&&p!==null)e:for(;;){if(p===null)return;var C=p.tag;if(C===3||C===4){var D=p.stateNode.containerInfo;if(D===x)break;if(C===4)for(C=p.return;C!==null;){var J=C.tag;if((J===3||J===4)&&C.stateNode.containerInfo===x)return;C=C.return}for(;D!==null;){if(C=Pa(D),C===null)return;if(J=C.tag,J===5||J===6||J===26||J===27){p=b=C;continue e}D=D.parentNode}}p=p.return}Ev(function(){var ae=b,pe=df(u),ge=[];e:{var le=s1.get(i);if(le!==void 0){var ue=ju,De=i;switch(i){case"keypress":if(wu(u)===0)break e;case"keydown":case"keyup":ue=KN;break;case"focusin":De="focus",ue=xf;break;case"focusout":De="blur",ue=xf;break;case"beforeblur":case"afterblur":ue=xf;break;case"click":if(u.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ue=Av;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ue=ON;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ue=JN;break;case Qv:case Zv:case e1:ue=$N;break;case t1:ue=ZN;break;case"scroll":case"scrollend":ue=LN;break;case"wheel":ue=t3;break;case"copy":case"cut":case"paste":ue=FN;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ue=Dv;break;case"toggle":case"beforetoggle":ue=n3}var Ve=(o&4)!==0,Nt=!Ve&&(i==="scroll"||i==="scrollend"),te=Ve?le!==null?le+"Capture":null:le;Ve=[];for(var Z=ae,ie;Z!==null;){var me=Z;if(ie=me.stateNode,me=me.tag,me!==5&&me!==26&&me!==27||ie===null||te===null||(me=il(Z,te),me!=null&&Ve.push(Pl(Z,me,ie))),Nt)break;Z=Z.return}0<Ve.length&&(le=new ue(le,De,null,u,pe),ge.push({event:le,listeners:Ve}))}}if((o&7)===0){e:{if(le=i==="mouseover"||i==="pointerover",ue=i==="mouseout"||i==="pointerout",le&&u!==uf&&(De=u.relatedTarget||u.fromElement)&&(Pa(De)||De[za]))break e;if((ue||le)&&(le=pe.window===pe?pe:(le=pe.ownerDocument)?le.defaultView||le.parentWindow:window,ue?(De=u.relatedTarget||u.toElement,ue=ae,De=De?Pa(De):null,De!==null&&(Nt=l(De),Ve=De.tag,De!==Nt||Ve!==5&&Ve!==27&&Ve!==6)&&(De=null)):(ue=null,De=ae),ue!==De)){if(Ve=Av,me="onMouseLeave",te="onMouseEnter",Z="mouse",(i==="pointerout"||i==="pointerover")&&(Ve=Dv,me="onPointerLeave",te="onPointerEnter",Z="pointer"),Nt=ue==null?le:rl(ue),ie=De==null?le:rl(De),le=new Ve(me,Z+"leave",ue,u,pe),le.target=Nt,le.relatedTarget=ie,me=null,Pa(pe)===ae&&(Ve=new Ve(te,Z+"enter",De,u,pe),Ve.target=ie,Ve.relatedTarget=Nt,me=Ve),Nt=me,ue&&De)t:{for(Ve=s4,te=ue,Z=De,ie=0,me=te;me;me=Ve(me))ie++;me=0;for(var Fe=Z;Fe;Fe=Ve(Fe))me++;for(;0<ie-me;)te=Ve(te),ie--;for(;0<me-ie;)Z=Ve(Z),me--;for(;ie--;){if(te===Z||Z!==null&&te===Z.alternate){Ve=te;break t}te=Ve(te),Z=Ve(Z)}Ve=null}else Ve=null;ue!==null&&j_(ge,le,ue,Ve,!1),De!==null&&Nt!==null&&j_(ge,Nt,De,Ve,!0)}}e:{if(le=ae?rl(ae):window,ue=le.nodeName&&le.nodeName.toLowerCase(),ue==="select"||ue==="input"&&le.type==="file")var gt=Fv;else if($v(le))if(Hv)gt=f3;else{gt=d3;var Oe=u3}else ue=le.nodeName,!ue||ue.toLowerCase()!=="input"||le.type!=="checkbox"&&le.type!=="radio"?ae&&cf(ae.elementType)&&(gt=Fv):gt=h3;if(gt&&(gt=gt(i,ae))){Iv(ge,gt,u,pe);break e}Oe&&Oe(i,le,ae),i==="focusout"&&ae&&le.type==="number"&&ae.memoizedProps.value!=null&&lf(le,"number",le.value)}switch(Oe=ae?rl(ae):window,i){case"focusin":($v(Oe)||Oe.contentEditable==="true")&&(Ga=Oe,Sf=ae,fl=null);break;case"focusout":fl=Sf=Ga=null;break;case"mousedown":jf=!0;break;case"contextmenu":case"mouseup":case"dragend":jf=!1,Xv(ge,u,pe);break;case"selectionchange":if(m3)break;case"keydown":case"keyup":Xv(ge,u,pe)}var et;if(bf)e:{switch(i){case"compositionstart":var ct="onCompositionStart";break e;case"compositionend":ct="onCompositionEnd";break e;case"compositionupdate":ct="onCompositionUpdate";break e}ct=void 0}else qa?zv(i,u)&&(ct="onCompositionEnd"):i==="keydown"&&u.keyCode===229&&(ct="onCompositionStart");ct&&(Lv&&u.locale!=="ko"&&(qa||ct!=="onCompositionStart"?ct==="onCompositionEnd"&&qa&&(et=Mv()):(ci=pe,pf="value"in ci?ci.value:ci.textContent,qa=!0)),Oe=pd(ae,ct),0<Oe.length&&(ct=new Rv(ct,i,null,u,pe),ge.push({event:ct,listeners:Oe}),et?ct.data=et:(et=Pv(u),et!==null&&(ct.data=et)))),(et=i3?a3(i,u):o3(i,u))&&(ct=pd(ae,"onBeforeInput"),0<ct.length&&(Oe=new Rv("onBeforeInput","beforeinput",null,u,pe),ge.push({event:Oe,listeners:ct}),Oe.data=et)),Q3(ge,i,ae,u,pe)}w_(ge,o)})}function Pl(i,o,u){return{instance:i,listener:o,currentTarget:u}}function pd(i,o){for(var u=o+"Capture",p=[];i!==null;){var x=i,b=x.stateNode;if(x=x.tag,x!==5&&x!==26&&x!==27||b===null||(x=il(i,u),x!=null&&p.unshift(Pl(i,x,b)),x=il(i,o),x!=null&&p.push(Pl(i,x,b))),i.tag===3)return p;i=i.return}return[]}function s4(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function j_(i,o,u,p,x){for(var b=o._reactName,C=[];u!==null&&u!==p;){var D=u,J=D.alternate,ae=D.stateNode;if(D=D.tag,J!==null&&J===p)break;D!==5&&D!==26&&D!==27||ae===null||(J=ae,x?(ae=il(u,b),ae!=null&&C.unshift(Pl(u,ae,J))):x||(ae=il(u,b),ae!=null&&C.push(Pl(u,ae,J)))),u=u.return}C.length!==0&&i.push({event:o,listeners:C})}var n4=/\r\n?/g,r4=/\u0000|\uFFFD/g;function k_(i){return(typeof i=="string"?i:""+i).replace(n4,`
49
+ `).replace(r4,"")}function C_(i,o){return o=k_(o),k_(i)===o}function Ct(i,o,u,p,x,b){switch(u){case"children":typeof p=="string"?o==="body"||o==="textarea"&&p===""||Ua(i,p):(typeof p=="number"||typeof p=="bigint")&&o!=="body"&&Ua(i,""+p);break;case"className":vu(i,"class",p);break;case"tabIndex":vu(i,"tabindex",p);break;case"dir":case"role":case"viewBox":case"width":case"height":vu(i,u,p);break;case"style":Cv(i,p,b);break;case"data":if(o!=="object"){vu(i,"data",p);break}case"src":case"href":if(p===""&&(o!=="a"||u!=="href")){i.removeAttribute(u);break}if(p==null||typeof p=="function"||typeof p=="symbol"||typeof p=="boolean"){i.removeAttribute(u);break}p=_u(""+p),i.setAttribute(u,p);break;case"action":case"formAction":if(typeof p=="function"){i.setAttribute(u,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof b=="function"&&(u==="formAction"?(o!=="input"&&Ct(i,o,"name",x.name,x,null),Ct(i,o,"formEncType",x.formEncType,x,null),Ct(i,o,"formMethod",x.formMethod,x,null),Ct(i,o,"formTarget",x.formTarget,x,null)):(Ct(i,o,"encType",x.encType,x,null),Ct(i,o,"method",x.method,x,null),Ct(i,o,"target",x.target,x,null)));if(p==null||typeof p=="symbol"||typeof p=="boolean"){i.removeAttribute(u);break}p=_u(""+p),i.setAttribute(u,p);break;case"onClick":p!=null&&(i.onclick=Er);break;case"onScroll":p!=null&&it("scroll",i);break;case"onScrollEnd":p!=null&&it("scrollend",i);break;case"dangerouslySetInnerHTML":if(p!=null){if(typeof p!="object"||!("__html"in p))throw Error(n(61));if(u=p.__html,u!=null){if(x.children!=null)throw Error(n(60));i.innerHTML=u}}break;case"multiple":i.multiple=p&&typeof p!="function"&&typeof p!="symbol";break;case"muted":i.muted=p&&typeof p!="function"&&typeof p!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(p==null||typeof p=="function"||typeof p=="boolean"||typeof p=="symbol"){i.removeAttribute("xlink:href");break}u=_u(""+p),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",u);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":p!=null&&typeof p!="function"&&typeof p!="symbol"?i.setAttribute(u,""+p):i.removeAttribute(u);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":p&&typeof p!="function"&&typeof p!="symbol"?i.setAttribute(u,""):i.removeAttribute(u);break;case"capture":case"download":p===!0?i.setAttribute(u,""):p!==!1&&p!=null&&typeof p!="function"&&typeof p!="symbol"?i.setAttribute(u,p):i.removeAttribute(u);break;case"cols":case"rows":case"size":case"span":p!=null&&typeof p!="function"&&typeof p!="symbol"&&!isNaN(p)&&1<=p?i.setAttribute(u,p):i.removeAttribute(u);break;case"rowSpan":case"start":p==null||typeof p=="function"||typeof p=="symbol"||isNaN(p)?i.removeAttribute(u):i.setAttribute(u,p);break;case"popover":it("beforetoggle",i),it("toggle",i),xu(i,"popover",p);break;case"xlinkActuate":Nr(i,"http://www.w3.org/1999/xlink","xlink:actuate",p);break;case"xlinkArcrole":Nr(i,"http://www.w3.org/1999/xlink","xlink:arcrole",p);break;case"xlinkRole":Nr(i,"http://www.w3.org/1999/xlink","xlink:role",p);break;case"xlinkShow":Nr(i,"http://www.w3.org/1999/xlink","xlink:show",p);break;case"xlinkTitle":Nr(i,"http://www.w3.org/1999/xlink","xlink:title",p);break;case"xlinkType":Nr(i,"http://www.w3.org/1999/xlink","xlink:type",p);break;case"xmlBase":Nr(i,"http://www.w3.org/XML/1998/namespace","xml:base",p);break;case"xmlLang":Nr(i,"http://www.w3.org/XML/1998/namespace","xml:lang",p);break;case"xmlSpace":Nr(i,"http://www.w3.org/XML/1998/namespace","xml:space",p);break;case"is":xu(i,"is",p);break;case"innerText":case"textContent":break;default:(!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(u=RN.get(u)||u,xu(i,u,p))}}function Yp(i,o,u,p,x,b){switch(u){case"style":Cv(i,p,b);break;case"dangerouslySetInnerHTML":if(p!=null){if(typeof p!="object"||!("__html"in p))throw Error(n(61));if(u=p.__html,u!=null){if(x.children!=null)throw Error(n(60));i.innerHTML=u}}break;case"children":typeof p=="string"?Ua(i,p):(typeof p=="number"||typeof p=="bigint")&&Ua(i,""+p);break;case"onScroll":p!=null&&it("scroll",i);break;case"onScrollEnd":p!=null&&it("scrollend",i);break;case"onClick":p!=null&&(i.onclick=Er);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!xv.hasOwnProperty(u))e:{if(u[0]==="o"&&u[1]==="n"&&(x=u.endsWith("Capture"),o=u.slice(2,x?u.length-7:void 0),b=i[rn]||null,b=b!=null?b[u]:null,typeof b=="function"&&i.removeEventListener(o,b,x),typeof p=="function")){typeof b!="function"&&b!==null&&(u in i?i[u]=null:i.hasAttribute(u)&&i.removeAttribute(u)),i.addEventListener(o,p,x);break e}u in i?i[u]=p:p===!0?i.setAttribute(u,""):xu(i,u,p)}}}function Os(i,o,u){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":it("error",i),it("load",i);var p=!1,x=!1,b;for(b in u)if(u.hasOwnProperty(b)){var C=u[b];if(C!=null)switch(b){case"src":p=!0;break;case"srcSet":x=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(n(137,o));default:Ct(i,o,b,C,u,null)}}x&&Ct(i,o,"srcSet",u.srcSet,u,null),p&&Ct(i,o,"src",u.src,u,null);return;case"input":it("invalid",i);var D=b=C=x=null,J=null,ae=null;for(p in u)if(u.hasOwnProperty(p)){var pe=u[p];if(pe!=null)switch(p){case"name":x=pe;break;case"type":C=pe;break;case"checked":J=pe;break;case"defaultChecked":ae=pe;break;case"value":b=pe;break;case"defaultValue":D=pe;break;case"children":case"dangerouslySetInnerHTML":if(pe!=null)throw Error(n(137,o));break;default:Ct(i,o,p,pe,u,null)}}wv(i,b,D,J,ae,C,x,!1);return;case"select":it("invalid",i),p=C=b=null;for(x in u)if(u.hasOwnProperty(x)&&(D=u[x],D!=null))switch(x){case"value":b=D;break;case"defaultValue":C=D;break;case"multiple":p=D;default:Ct(i,o,x,D,u,null)}o=b,u=C,i.multiple=!!p,o!=null?Ha(i,!!p,o,!1):u!=null&&Ha(i,!!p,u,!0);return;case"textarea":it("invalid",i),b=x=p=null;for(C in u)if(u.hasOwnProperty(C)&&(D=u[C],D!=null))switch(C){case"value":p=D;break;case"defaultValue":x=D;break;case"children":b=D;break;case"dangerouslySetInnerHTML":if(D!=null)throw Error(n(91));break;default:Ct(i,o,C,D,u,null)}jv(i,p,x,b);return;case"option":for(J in u)if(u.hasOwnProperty(J)&&(p=u[J],p!=null))switch(J){case"selected":i.selected=p&&typeof p!="function"&&typeof p!="symbol";break;default:Ct(i,o,J,p,u,null)}return;case"dialog":it("beforetoggle",i),it("toggle",i),it("cancel",i),it("close",i);break;case"iframe":case"object":it("load",i);break;case"video":case"audio":for(p=0;p<zl.length;p++)it(zl[p],i);break;case"image":it("error",i),it("load",i);break;case"details":it("toggle",i);break;case"embed":case"source":case"link":it("error",i),it("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ae in u)if(u.hasOwnProperty(ae)&&(p=u[ae],p!=null))switch(ae){case"children":case"dangerouslySetInnerHTML":throw Error(n(137,o));default:Ct(i,o,ae,p,u,null)}return;default:if(cf(o)){for(pe in u)u.hasOwnProperty(pe)&&(p=u[pe],p!==void 0&&Yp(i,o,pe,p,u,void 0));return}}for(D in u)u.hasOwnProperty(D)&&(p=u[D],p!=null&&Ct(i,o,D,p,u,null))}function i4(i,o,u,p){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var x=null,b=null,C=null,D=null,J=null,ae=null,pe=null;for(ue in u){var ge=u[ue];if(u.hasOwnProperty(ue)&&ge!=null)switch(ue){case"checked":break;case"value":break;case"defaultValue":J=ge;default:p.hasOwnProperty(ue)||Ct(i,o,ue,null,p,ge)}}for(var le in p){var ue=p[le];if(ge=u[le],p.hasOwnProperty(le)&&(ue!=null||ge!=null))switch(le){case"type":b=ue;break;case"name":x=ue;break;case"checked":ae=ue;break;case"defaultChecked":pe=ue;break;case"value":C=ue;break;case"defaultValue":D=ue;break;case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(n(137,o));break;default:ue!==ge&&Ct(i,o,le,ue,p,ge)}}of(i,C,D,J,ae,pe,b,x);return;case"select":ue=C=D=le=null;for(b in u)if(J=u[b],u.hasOwnProperty(b)&&J!=null)switch(b){case"value":break;case"multiple":ue=J;default:p.hasOwnProperty(b)||Ct(i,o,b,null,p,J)}for(x in p)if(b=p[x],J=u[x],p.hasOwnProperty(x)&&(b!=null||J!=null))switch(x){case"value":le=b;break;case"defaultValue":D=b;break;case"multiple":C=b;default:b!==J&&Ct(i,o,x,b,p,J)}o=D,u=C,p=ue,le!=null?Ha(i,!!u,le,!1):!!p!=!!u&&(o!=null?Ha(i,!!u,o,!0):Ha(i,!!u,u?[]:"",!1));return;case"textarea":ue=le=null;for(D in u)if(x=u[D],u.hasOwnProperty(D)&&x!=null&&!p.hasOwnProperty(D))switch(D){case"value":break;case"children":break;default:Ct(i,o,D,null,p,x)}for(C in p)if(x=p[C],b=u[C],p.hasOwnProperty(C)&&(x!=null||b!=null))switch(C){case"value":le=x;break;case"defaultValue":ue=x;break;case"children":break;case"dangerouslySetInnerHTML":if(x!=null)throw Error(n(91));break;default:x!==b&&Ct(i,o,C,x,p,b)}Sv(i,le,ue);return;case"option":for(var De in u)if(le=u[De],u.hasOwnProperty(De)&&le!=null&&!p.hasOwnProperty(De))switch(De){case"selected":i.selected=!1;break;default:Ct(i,o,De,null,p,le)}for(J in p)if(le=p[J],ue=u[J],p.hasOwnProperty(J)&&le!==ue&&(le!=null||ue!=null))switch(J){case"selected":i.selected=le&&typeof le!="function"&&typeof le!="symbol";break;default:Ct(i,o,J,le,p,ue)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Ve in u)le=u[Ve],u.hasOwnProperty(Ve)&&le!=null&&!p.hasOwnProperty(Ve)&&Ct(i,o,Ve,null,p,le);for(ae in p)if(le=p[ae],ue=u[ae],p.hasOwnProperty(ae)&&le!==ue&&(le!=null||ue!=null))switch(ae){case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(n(137,o));break;default:Ct(i,o,ae,le,p,ue)}return;default:if(cf(o)){for(var Nt in u)le=u[Nt],u.hasOwnProperty(Nt)&&le!==void 0&&!p.hasOwnProperty(Nt)&&Yp(i,o,Nt,void 0,p,le);for(pe in p)le=p[pe],ue=u[pe],!p.hasOwnProperty(pe)||le===ue||le===void 0&&ue===void 0||Yp(i,o,pe,le,p,ue);return}}for(var te in u)le=u[te],u.hasOwnProperty(te)&&le!=null&&!p.hasOwnProperty(te)&&Ct(i,o,te,null,p,le);for(ge in p)le=p[ge],ue=u[ge],!p.hasOwnProperty(ge)||le===ue||le==null&&ue==null||Ct(i,o,ge,le,p,ue)}function N_(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function a4(){if(typeof performance.getEntriesByType=="function"){for(var i=0,o=0,u=performance.getEntriesByType("resource"),p=0;p<u.length;p++){var x=u[p],b=x.transferSize,C=x.initiatorType,D=x.duration;if(b&&D&&N_(C)){for(C=0,D=x.responseEnd,p+=1;p<u.length;p++){var J=u[p],ae=J.startTime;if(ae>D)break;var pe=J.transferSize,ge=J.initiatorType;pe&&N_(ge)&&(J=J.responseEnd,C+=pe*(J<D?1:(D-ae)/(J-ae)))}if(--p,o+=8*(b+C)/(x.duration/1e3),i++,10<i)break}}if(0<i)return o/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Xp=null,Jp=null;function md(i){return i.nodeType===9?i:i.ownerDocument}function E_(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function M_(i,o){if(i===0)switch(o){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&o==="foreignObject"?0:i}function Qp(i,o){return i==="textarea"||i==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.children=="bigint"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var Zp=null;function o4(){var i=window.event;return i&&i.type==="popstate"?i===Zp?!1:(Zp=i,!0):(Zp=null,!1)}var T_=typeof setTimeout=="function"?setTimeout:void 0,l4=typeof clearTimeout=="function"?clearTimeout:void 0,A_=typeof Promise=="function"?Promise:void 0,c4=typeof queueMicrotask=="function"?queueMicrotask:typeof A_<"u"?function(i){return A_.resolve(null).then(i).catch(u4)}:T_;function u4(i){setTimeout(function(){throw i})}function Ci(i){return i==="head"}function R_(i,o){var u=o,p=0;do{var x=u.nextSibling;if(i.removeChild(u),x&&x.nodeType===8)if(u=x.data,u==="/$"||u==="/&"){if(p===0){i.removeChild(x),yo(o);return}p--}else if(u==="$"||u==="$?"||u==="$~"||u==="$!"||u==="&")p++;else if(u==="html")$l(i.ownerDocument.documentElement);else if(u==="head"){u=i.ownerDocument.head,$l(u);for(var b=u.firstChild;b;){var C=b.nextSibling,D=b.nodeName;b[nl]||D==="SCRIPT"||D==="STYLE"||D==="LINK"&&b.rel.toLowerCase()==="stylesheet"||u.removeChild(b),b=C}}else u==="body"&&$l(i.ownerDocument.body);u=x}while(u);yo(o)}function D_(i,o){var u=i;i=0;do{var p=u.nextSibling;if(u.nodeType===1?o?(u._stashedDisplay=u.style.display,u.style.display="none"):(u.style.display=u._stashedDisplay||"",u.getAttribute("style")===""&&u.removeAttribute("style")):u.nodeType===3&&(o?(u._stashedText=u.nodeValue,u.nodeValue=""):u.nodeValue=u._stashedText||""),p&&p.nodeType===8)if(u=p.data,u==="/$"){if(i===0)break;i--}else u!=="$"&&u!=="$?"&&u!=="$~"&&u!=="$!"||i++;u=p}while(u)}function em(i){var o=i.firstChild;for(o&&o.nodeType===10&&(o=o.nextSibling);o;){var u=o;switch(o=o.nextSibling,u.nodeName){case"HTML":case"HEAD":case"BODY":em(u),rf(u);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(u.rel.toLowerCase()==="stylesheet")continue}i.removeChild(u)}}function d4(i,o,u,p){for(;i.nodeType===1;){var x=u;if(i.nodeName.toLowerCase()!==o.toLowerCase()){if(!p&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(p){if(!i[nl])switch(o){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(b=i.getAttribute("rel"),b==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(b!==x.rel||i.getAttribute("href")!==(x.href==null||x.href===""?null:x.href)||i.getAttribute("crossorigin")!==(x.crossOrigin==null?null:x.crossOrigin)||i.getAttribute("title")!==(x.title==null?null:x.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(b=i.getAttribute("src"),(b!==(x.src==null?null:x.src)||i.getAttribute("type")!==(x.type==null?null:x.type)||i.getAttribute("crossorigin")!==(x.crossOrigin==null?null:x.crossOrigin))&&b&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(o==="input"&&i.type==="hidden"){var b=x.name==null?null:""+x.name;if(x.type==="hidden"&&i.getAttribute("name")===b)return i}else return i;if(i=Fn(i.nextSibling),i===null)break}return null}function h4(i,o,u){if(o==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!u||(i=Fn(i.nextSibling),i===null))return null;return i}function L_(i,o){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!o||(i=Fn(i.nextSibling),i===null))return null;return i}function tm(i){return i.data==="$?"||i.data==="$~"}function sm(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function f4(i,o){var u=i.ownerDocument;if(i.data==="$~")i._reactRetry=o;else if(i.data!=="$?"||u.readyState!=="loading")o();else{var p=function(){o(),u.removeEventListener("DOMContentLoaded",p)};u.addEventListener("DOMContentLoaded",p),i._reactRetry=p}}function Fn(i){for(;i!=null;i=i.nextSibling){var o=i.nodeType;if(o===1||o===3)break;if(o===8){if(o=i.data,o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"||o==="F!"||o==="F")break;if(o==="/$"||o==="/&")return null}}return i}var nm=null;function B_(i){i=i.nextSibling;for(var o=0;i;){if(i.nodeType===8){var u=i.data;if(u==="/$"||u==="/&"){if(o===0)return Fn(i.nextSibling);o--}else u!=="$"&&u!=="$!"&&u!=="$?"&&u!=="$~"&&u!=="&"||o++}i=i.nextSibling}return null}function O_(i){i=i.previousSibling;for(var o=0;i;){if(i.nodeType===8){var u=i.data;if(u==="$"||u==="$!"||u==="$?"||u==="$~"||u==="&"){if(o===0)return i;o--}else u!=="/$"&&u!=="/&"||o++}i=i.previousSibling}return null}function z_(i,o,u){switch(o=md(u),i){case"html":if(i=o.documentElement,!i)throw Error(n(452));return i;case"head":if(i=o.head,!i)throw Error(n(453));return i;case"body":if(i=o.body,!i)throw Error(n(454));return i;default:throw Error(n(451))}}function $l(i){for(var o=i.attributes;o.length;)i.removeAttributeNode(o[0]);rf(i)}var Hn=new Map,P_=new Set;function gd(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Vr=O.d;O.d={f:p4,r:m4,D:g4,C:x4,L:v4,m:b4,X:y4,S:_4,M:w4};function p4(){var i=Vr.f(),o=od();return i||o}function m4(i){var o=$a(i);o!==null&&o.tag===5&&o.type==="form"?tb(o):Vr.r(i)}var vo=typeof document>"u"?null:document;function $_(i,o,u){var p=vo;if(p&&typeof o=="string"&&o){var x=Ln(o);x='link[rel="'+i+'"][href="'+x+'"]',typeof u=="string"&&(x+='[crossorigin="'+u+'"]'),P_.has(x)||(P_.add(x),i={rel:i,crossOrigin:u,href:o},p.querySelector(x)===null&&(o=p.createElement("link"),Os(o,"link",i),js(o),p.head.appendChild(o)))}}function g4(i){Vr.D(i),$_("dns-prefetch",i,null)}function x4(i,o){Vr.C(i,o),$_("preconnect",i,o)}function v4(i,o,u){Vr.L(i,o,u);var p=vo;if(p&&i&&o){var x='link[rel="preload"][as="'+Ln(o)+'"]';o==="image"&&u&&u.imageSrcSet?(x+='[imagesrcset="'+Ln(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(x+='[imagesizes="'+Ln(u.imageSizes)+'"]')):x+='[href="'+Ln(i)+'"]';var b=x;switch(o){case"style":b=bo(i);break;case"script":b=_o(i)}Hn.has(b)||(i=g({rel:"preload",href:o==="image"&&u&&u.imageSrcSet?void 0:i,as:o},u),Hn.set(b,i),p.querySelector(x)!==null||o==="style"&&p.querySelector(Il(b))||o==="script"&&p.querySelector(Fl(b))||(o=p.createElement("link"),Os(o,"link",i),js(o),p.head.appendChild(o)))}}function b4(i,o){Vr.m(i,o);var u=vo;if(u&&i){var p=o&&typeof o.as=="string"?o.as:"script",x='link[rel="modulepreload"][as="'+Ln(p)+'"][href="'+Ln(i)+'"]',b=x;switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":b=_o(i)}if(!Hn.has(b)&&(i=g({rel:"modulepreload",href:i},o),Hn.set(b,i),u.querySelector(x)===null)){switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(Fl(b)))return}p=u.createElement("link"),Os(p,"link",i),js(p),u.head.appendChild(p)}}}function _4(i,o,u){Vr.S(i,o,u);var p=vo;if(p&&i){var x=Ia(p).hoistableStyles,b=bo(i);o=o||"default";var C=x.get(b);if(!C){var D={loading:0,preload:null};if(C=p.querySelector(Il(b)))D.loading=5;else{i=g({rel:"stylesheet",href:i,"data-precedence":o},u),(u=Hn.get(b))&&rm(i,u);var J=C=p.createElement("link");js(J),Os(J,"link",i),J._p=new Promise(function(ae,pe){J.onload=ae,J.onerror=pe}),J.addEventListener("load",function(){D.loading|=1}),J.addEventListener("error",function(){D.loading|=2}),D.loading|=4,xd(C,o,p)}C={type:"stylesheet",instance:C,count:1,state:D},x.set(b,C)}}}function y4(i,o){Vr.X(i,o);var u=vo;if(u&&i){var p=Ia(u).hoistableScripts,x=_o(i),b=p.get(x);b||(b=u.querySelector(Fl(x)),b||(i=g({src:i,async:!0},o),(o=Hn.get(x))&&im(i,o),b=u.createElement("script"),js(b),Os(b,"link",i),u.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},p.set(x,b))}}function w4(i,o){Vr.M(i,o);var u=vo;if(u&&i){var p=Ia(u).hoistableScripts,x=_o(i),b=p.get(x);b||(b=u.querySelector(Fl(x)),b||(i=g({src:i,async:!0,type:"module"},o),(o=Hn.get(x))&&im(i,o),b=u.createElement("script"),js(b),Os(b,"link",i),u.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},p.set(x,b))}}function I_(i,o,u,p){var x=(x=re.current)?gd(x):null;if(!x)throw Error(n(446));switch(i){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(o=bo(u.href),u=Ia(x).hoistableStyles,p=u.get(o),p||(p={type:"style",instance:null,count:0,state:null},u.set(o,p)),p):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){i=bo(u.href);var b=Ia(x).hoistableStyles,C=b.get(i);if(C||(x=x.ownerDocument||x,C={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},b.set(i,C),(b=x.querySelector(Il(i)))&&!b._p&&(C.instance=b,C.state.loading=5),Hn.has(i)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},Hn.set(i,u),b||S4(x,i,u,C.state))),o&&p===null)throw Error(n(528,""));return C}if(o&&p!==null)throw Error(n(529,""));return null;case"script":return o=u.async,u=u.src,typeof u=="string"&&o&&typeof o!="function"&&typeof o!="symbol"?(o=_o(u),u=Ia(x).hoistableScripts,p=u.get(o),p||(p={type:"script",instance:null,count:0,state:null},u.set(o,p)),p):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,i))}}function bo(i){return'href="'+Ln(i)+'"'}function Il(i){return'link[rel="stylesheet"]['+i+"]"}function F_(i){return g({},i,{"data-precedence":i.precedence,precedence:null})}function S4(i,o,u,p){i.querySelector('link[rel="preload"][as="style"]['+o+"]")?p.loading=1:(o=i.createElement("link"),p.preload=o,o.addEventListener("load",function(){return p.loading|=1}),o.addEventListener("error",function(){return p.loading|=2}),Os(o,"link",u),js(o),i.head.appendChild(o))}function _o(i){return'[src="'+Ln(i)+'"]'}function Fl(i){return"script[async]"+i}function H_(i,o,u){if(o.count++,o.instance===null)switch(o.type){case"style":var p=i.querySelector('style[data-href~="'+Ln(u.href)+'"]');if(p)return o.instance=p,js(p),p;var x=g({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return p=(i.ownerDocument||i).createElement("style"),js(p),Os(p,"style",x),xd(p,u.precedence,i),o.instance=p;case"stylesheet":x=bo(u.href);var b=i.querySelector(Il(x));if(b)return o.state.loading|=4,o.instance=b,js(b),b;p=F_(u),(x=Hn.get(x))&&rm(p,x),b=(i.ownerDocument||i).createElement("link"),js(b);var C=b;return C._p=new Promise(function(D,J){C.onload=D,C.onerror=J}),Os(b,"link",p),o.state.loading|=4,xd(b,u.precedence,i),o.instance=b;case"script":return b=_o(u.src),(x=i.querySelector(Fl(b)))?(o.instance=x,js(x),x):(p=u,(x=Hn.get(b))&&(p=g({},u),im(p,x)),i=i.ownerDocument||i,x=i.createElement("script"),js(x),Os(x,"link",p),i.head.appendChild(x),o.instance=x);case"void":return null;default:throw Error(n(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(p=o.instance,o.state.loading|=4,xd(p,u.precedence,i));return o.instance}function xd(i,o,u){for(var p=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),x=p.length?p[p.length-1]:null,b=x,C=0;C<p.length;C++){var D=p[C];if(D.dataset.precedence===o)b=D;else if(b!==x)break}b?b.parentNode.insertBefore(i,b.nextSibling):(o=u.nodeType===9?u.head:u,o.insertBefore(i,o.firstChild))}function rm(i,o){i.crossOrigin==null&&(i.crossOrigin=o.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=o.referrerPolicy),i.title==null&&(i.title=o.title)}function im(i,o){i.crossOrigin==null&&(i.crossOrigin=o.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=o.referrerPolicy),i.integrity==null&&(i.integrity=o.integrity)}var vd=null;function U_(i,o,u){if(vd===null){var p=new Map,x=vd=new Map;x.set(u,p)}else x=vd,p=x.get(u),p||(p=new Map,x.set(u,p));if(p.has(i))return p;for(p.set(i,null),u=u.getElementsByTagName(i),x=0;x<u.length;x++){var b=u[x];if(!(b[nl]||b[Rs]||i==="link"&&b.getAttribute("rel")==="stylesheet")&&b.namespaceURI!=="http://www.w3.org/2000/svg"){var C=b.getAttribute(o)||"";C=i+C;var D=p.get(C);D?D.push(b):p.set(C,[b])}}return p}function V_(i,o,u){i=i.ownerDocument||i,i.head.insertBefore(u,o==="title"?i.querySelector("head > title"):null)}function j4(i,o,u){if(u===1||o.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof o.precedence!="string"||typeof o.href!="string"||o.href==="")break;return!0;case"link":if(typeof o.rel!="string"||typeof o.href!="string"||o.href===""||o.onLoad||o.onError)break;switch(o.rel){case"stylesheet":return i=o.disabled,typeof o.precedence=="string"&&i==null;default:return!0}case"script":if(o.async&&typeof o.async!="function"&&typeof o.async!="symbol"&&!o.onLoad&&!o.onError&&o.src&&typeof o.src=="string")return!0}return!1}function W_(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function k4(i,o,u,p){if(u.type==="stylesheet"&&(typeof p.media!="string"||matchMedia(p.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var x=bo(p.href),b=o.querySelector(Il(x));if(b){o=b._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(i.count++,i=bd.bind(i),o.then(i,i)),u.state.loading|=4,u.instance=b,js(b);return}b=o.ownerDocument||o,p=F_(p),(x=Hn.get(x))&&rm(p,x),b=b.createElement("link"),js(b);var C=b;C._p=new Promise(function(D,J){C.onload=D,C.onerror=J}),Os(b,"link",p),u.instance=b}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(u,o),(o=u.state.preload)&&(u.state.loading&3)===0&&(i.count++,u=bd.bind(i),o.addEventListener("load",u),o.addEventListener("error",u))}}var am=0;function C4(i,o){return i.stylesheets&&i.count===0&&yd(i,i.stylesheets),0<i.count||0<i.imgCount?function(u){var p=setTimeout(function(){if(i.stylesheets&&yd(i,i.stylesheets),i.unsuspend){var b=i.unsuspend;i.unsuspend=null,b()}},6e4+o);0<i.imgBytes&&am===0&&(am=62500*a4());var x=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&yd(i,i.stylesheets),i.unsuspend)){var b=i.unsuspend;i.unsuspend=null,b()}},(i.imgBytes>am?50:800)+o);return i.unsuspend=u,function(){i.unsuspend=null,clearTimeout(p),clearTimeout(x)}}:null}function bd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)yd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var _d=null;function yd(i,o){i.stylesheets=null,i.unsuspend!==null&&(i.count++,_d=new Map,o.forEach(N4,i),_d=null,bd.call(i))}function N4(i,o){if(!(o.state.loading&4)){var u=_d.get(i);if(u)var p=u.get(null);else{u=new Map,_d.set(i,u);for(var x=i.querySelectorAll("link[data-precedence],style[data-precedence]"),b=0;b<x.length;b++){var C=x[b];(C.nodeName==="LINK"||C.getAttribute("media")!=="not all")&&(u.set(C.dataset.precedence,C),p=C)}p&&u.set(null,p)}x=o.instance,C=x.getAttribute("data-precedence"),b=u.get(C)||p,b===p&&u.set(null,x),u.set(C,x),this.count++,p=bd.bind(this),x.addEventListener("load",p),x.addEventListener("error",p),b?b.parentNode.insertBefore(x,b.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(x,i.firstChild)),o.state.loading|=4}}var Hl={$$typeof:E,Provider:null,Consumer:null,_currentValue:U,_currentValue2:U,_threadCount:0};function E4(i,o,u,p,x,b,C,D,J){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Xt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xt(0),this.hiddenUpdates=Xt(null),this.identifierPrefix=p,this.onUncaughtError=x,this.onCaughtError=b,this.onRecoverableError=C,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=J,this.incompleteTransitions=new Map}function q_(i,o,u,p,x,b,C,D,J,ae,pe,ge){return i=new E4(i,o,u,C,J,ae,pe,ge,D),o=1,b===!0&&(o|=24),b=_n(3,null,null,o),i.current=b,b.stateNode=i,o=$f(),o.refCount++,i.pooledCache=o,o.refCount++,b.memoizedState={element:p,isDehydrated:u,cache:o},Uf(b),i}function G_(i){return i?(i=Xa,i):Xa}function K_(i,o,u,p,x,b){x=G_(x),p.context===null?p.context=x:p.pendingContext=x,p=mi(o),p.payload={element:u},b=b===void 0?null:b,b!==null&&(p.callback=b),u=gi(i,p,o),u!==null&&(dn(u,i,o),_l(u,i,o))}function Y_(i,o){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var u=i.retryLane;i.retryLane=u!==0&&u<o?u:o}}function om(i,o){Y_(i,o),(i=i.alternate)&&Y_(i,o)}function X_(i){if(i.tag===13||i.tag===31){var o=na(i,67108864);o!==null&&dn(o,i,67108864),om(i,67108864)}}function J_(i){if(i.tag===13||i.tag===31){var o=kn();o=tf(o);var u=na(i,o);u!==null&&dn(u,i,o),om(i,o)}}var wd=!0;function M4(i,o,u,p){var x=M.T;M.T=null;var b=O.p;try{O.p=2,lm(i,o,u,p)}finally{O.p=b,M.T=x}}function T4(i,o,u,p){var x=M.T;M.T=null;var b=O.p;try{O.p=8,lm(i,o,u,p)}finally{O.p=b,M.T=x}}function lm(i,o,u,p){if(wd){var x=cm(p);if(x===null)Kp(i,o,p,Sd,u),Z_(i,p);else if(R4(x,i,o,u,p))p.stopPropagation();else if(Z_(i,p),o&4&&-1<A4.indexOf(i)){for(;x!==null;){var b=$a(x);if(b!==null)switch(b.tag){case 3:if(b=b.stateNode,b.current.memoizedState.isDehydrated){var C=Cr(b.pendingLanes);if(C!==0){var D=b;for(D.pendingLanes|=2,D.entangledLanes|=2;C;){var J=1<<31-ee(C);D.entanglements[1]|=J,C&=~J}ur(b),(bt&6)===0&&(id=vt()+500,Ol(0))}}break;case 31:case 13:D=na(b,2),D!==null&&dn(D,b,2),od(),om(b,2)}if(b=cm(p),b===null&&Kp(i,o,p,Sd,u),b===x)break;x=b}x!==null&&p.stopPropagation()}else Kp(i,o,p,null,u)}}function cm(i){return i=df(i),um(i)}var Sd=null;function um(i){if(Sd=null,i=Pa(i),i!==null){var o=l(i);if(o===null)i=null;else{var u=o.tag;if(u===13){if(i=c(o),i!==null)return i;i=null}else if(u===31){if(i=d(o),i!==null)return i;i=null}else if(u===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;i=null}else o!==i&&(i=null)}}return Sd=i,null}function Q_(i){switch(i){case"beforetoggle":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"toggle":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 2;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"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(rr()){case de:return 2;case _e:return 8;case Be:case qe:return 32;case Je:return 268435456;default:return 32}default:return 32}}var dm=!1,Ni=null,Ei=null,Mi=null,Ul=new Map,Vl=new Map,Ti=[],A4="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".split(" ");function Z_(i,o){switch(i){case"focusin":case"focusout":Ni=null;break;case"dragenter":case"dragleave":Ei=null;break;case"mouseover":case"mouseout":Mi=null;break;case"pointerover":case"pointerout":Ul.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":Vl.delete(o.pointerId)}}function Wl(i,o,u,p,x,b){return i===null||i.nativeEvent!==b?(i={blockedOn:o,domEventName:u,eventSystemFlags:p,nativeEvent:b,targetContainers:[x]},o!==null&&(o=$a(o),o!==null&&X_(o)),i):(i.eventSystemFlags|=p,o=i.targetContainers,x!==null&&o.indexOf(x)===-1&&o.push(x),i)}function R4(i,o,u,p,x){switch(o){case"focusin":return Ni=Wl(Ni,i,o,u,p,x),!0;case"dragenter":return Ei=Wl(Ei,i,o,u,p,x),!0;case"mouseover":return Mi=Wl(Mi,i,o,u,p,x),!0;case"pointerover":var b=x.pointerId;return Ul.set(b,Wl(Ul.get(b)||null,i,o,u,p,x)),!0;case"gotpointercapture":return b=x.pointerId,Vl.set(b,Wl(Vl.get(b)||null,i,o,u,p,x)),!0}return!1}function ey(i){var o=Pa(i.target);if(o!==null){var u=l(o);if(u!==null){if(o=u.tag,o===13){if(o=c(u),o!==null){i.blockedOn=o,pv(i.priority,function(){J_(u)});return}}else if(o===31){if(o=d(u),o!==null){i.blockedOn=o,pv(i.priority,function(){J_(u)});return}}else if(o===3&&u.stateNode.current.memoizedState.isDehydrated){i.blockedOn=u.tag===3?u.stateNode.containerInfo:null;return}}}i.blockedOn=null}function jd(i){if(i.blockedOn!==null)return!1;for(var o=i.targetContainers;0<o.length;){var u=cm(i.nativeEvent);if(u===null){u=i.nativeEvent;var p=new u.constructor(u.type,u);uf=p,u.target.dispatchEvent(p),uf=null}else return o=$a(u),o!==null&&X_(o),i.blockedOn=u,!1;o.shift()}return!0}function ty(i,o,u){jd(i)&&u.delete(o)}function D4(){dm=!1,Ni!==null&&jd(Ni)&&(Ni=null),Ei!==null&&jd(Ei)&&(Ei=null),Mi!==null&&jd(Mi)&&(Mi=null),Ul.forEach(ty),Vl.forEach(ty)}function kd(i,o){i.blockedOn===o&&(i.blockedOn=null,dm||(dm=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,D4)))}var Cd=null;function sy(i){Cd!==i&&(Cd=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Cd===i&&(Cd=null);for(var o=0;o<i.length;o+=3){var u=i[o],p=i[o+1],x=i[o+2];if(typeof p!="function"){if(um(p||u)===null)continue;break}var b=$a(u);b!==null&&(i.splice(o,3),o-=3,cp(b,{pending:!0,data:x,method:u.method,action:p},p,x))}}))}function yo(i){function o(J){return kd(J,i)}Ni!==null&&kd(Ni,i),Ei!==null&&kd(Ei,i),Mi!==null&&kd(Mi,i),Ul.forEach(o),Vl.forEach(o);for(var u=0;u<Ti.length;u++){var p=Ti[u];p.blockedOn===i&&(p.blockedOn=null)}for(;0<Ti.length&&(u=Ti[0],u.blockedOn===null);)ey(u),u.blockedOn===null&&Ti.shift();if(u=(i.ownerDocument||i).$$reactFormReplay,u!=null)for(p=0;p<u.length;p+=3){var x=u[p],b=u[p+1],C=x[rn]||null;if(typeof b=="function")C||sy(u);else if(C){var D=null;if(b&&b.hasAttribute("formAction")){if(x=b,C=b[rn]||null)D=C.formAction;else if(um(x)!==null)continue}else D=C.action;typeof D=="function"?u[p+1]=D:(u.splice(p,3),p-=3),sy(u)}}}function ny(){function i(b){b.canIntercept&&b.info==="react-transition"&&b.intercept({handler:function(){return new Promise(function(C){return x=C})},focusReset:"manual",scroll:"manual"})}function o(){x!==null&&(x(),x=null),p||setTimeout(u,20)}function u(){if(!p&&!navigation.transition){var b=navigation.currentEntry;b&&b.url!=null&&navigation.navigate(b.url,{state:b.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var p=!1,x=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",o),navigation.addEventListener("navigateerror",o),setTimeout(u,100),function(){p=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",o),navigation.removeEventListener("navigateerror",o),x!==null&&(x(),x=null)}}}function hm(i){this._internalRoot=i}Nd.prototype.render=hm.prototype.render=function(i){var o=this._internalRoot;if(o===null)throw Error(n(409));var u=o.current,p=kn();K_(u,p,i,o,null,null)},Nd.prototype.unmount=hm.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var o=i.containerInfo;K_(i.current,2,null,i,null,null),od(),o[za]=null}};function Nd(i){this._internalRoot=i}Nd.prototype.unstable_scheduleHydration=function(i){if(i){var o=fv();i={blockedOn:null,target:i,priority:o};for(var u=0;u<Ti.length&&o!==0&&o<Ti[u].priority;u++);Ti.splice(u,0,i),u===0&&ey(i)}};var ry=t.version;if(ry!=="19.2.4")throw Error(n(527,ry,"19.2.4"));O.findDOMNode=function(i){var o=i._reactInternals;if(o===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=h(o),i=i!==null?m(i):null,i=i===null?null:i.stateNode,i};var L4={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:M,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ed=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ed.isDisabled&&Ed.supportsFiber)try{se=Ed.inject(L4),fe=Ed}catch{}}return Gl.createRoot=function(i,o){if(!a(i))throw Error(n(299));var u=!1,p="",x=db,b=hb,C=fb;return o!=null&&(o.unstable_strictMode===!0&&(u=!0),o.identifierPrefix!==void 0&&(p=o.identifierPrefix),o.onUncaughtError!==void 0&&(x=o.onUncaughtError),o.onCaughtError!==void 0&&(b=o.onCaughtError),o.onRecoverableError!==void 0&&(C=o.onRecoverableError)),o=q_(i,1,!1,null,null,u,p,null,x,b,C,ny),i[za]=o.current,Gp(i),new hm(o)},Gl.hydrateRoot=function(i,o,u){if(!a(i))throw Error(n(299));var p=!1,x="",b=db,C=hb,D=fb,J=null;return u!=null&&(u.unstable_strictMode===!0&&(p=!0),u.identifierPrefix!==void 0&&(x=u.identifierPrefix),u.onUncaughtError!==void 0&&(b=u.onUncaughtError),u.onCaughtError!==void 0&&(C=u.onCaughtError),u.onRecoverableError!==void 0&&(D=u.onRecoverableError),u.formState!==void 0&&(J=u.formState)),o=q_(i,1,!0,o,u??null,p,x,J,b,C,D,ny),o.context=G_(null),u=o.current,p=kn(),p=tf(p),x=mi(p),x.callback=null,gi(u,x,p),u=p,o.current.lanes=u,Ot(o,u),ur(o),i[za]=o.current,Gp(i),new Nd(o)},Gl.version="19.2.4",Gl}var py;function U4(){if(py)return mm.exports;py=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),mm.exports=H4(),mm.exports}var V4=U4();const my=e=>{let t;const s=new Set,n=(h,m)=>{const g=typeof h=="function"?h(t):h;if(!Object.is(g,t)){const _=t;t=m??(typeof g!="object"||g===null)?g:Object.assign({},t,g),s.forEach(v=>v(t,_))}},a=()=>t,d={setState:n,getState:a,getInitialState:()=>f,subscribe:h=>(s.add(h),()=>s.delete(h))},f=t=e(n,a,d);return d},W4=(e=>e?my(e):my),q4=e=>e;function G4(e,t=q4){const s=xr.useSyncExternalStore(e.subscribe,xr.useCallback(()=>t(e.getState()),[e,t]),xr.useCallback(()=>t(e.getInitialState()),[e,t]));return xr.useDebugValue(s),s}const gy=e=>{const t=W4(e),s=n=>G4(t,n);return Object.assign(s,t),s},K4=(e=>e?gy(e):gy);function Y4(){if(typeof window>"u")return new Map;try{return new Map(JSON.parse(localStorage.getItem("cc-session-names")||"[]"))}catch{return new Map}}function X4(){return typeof window>"u"?null:localStorage.getItem("cc-current-session")||null}function J4(){if(typeof window>"u")return!1;const e=localStorage.getItem("cc-dark-mode");return e!==null?e==="true":window.matchMedia("(prefers-color-scheme: dark)").matches}function Q4(){if(typeof window>"u")return!0;const e=localStorage.getItem("cc-notification-sound");return e!==null?e==="true":!0}function Z4(){if(typeof window>"u")return!1;const e=localStorage.getItem("cc-notification-desktop");return e!==null?e==="true":!1}function e6(){return typeof window>"u"?null:localStorage.getItem("cc-update-dismissed")||null}function t6(){if(typeof window>"u")return new Set;try{return new Set(JSON.parse(localStorage.getItem("cc-collapsed-projects")||"[]"))}catch{return new Set}}const G=K4(e=>({sessions:new Map,sdkSessions:[],currentSessionId:X4(),messages:new Map,streaming:new Map,streamingStartedAt:new Map,streamingOutputTokens:new Map,pendingPermissions:new Map,connectionStatus:new Map,cliConnected:new Map,cliLaunching:new Map,sessionStatus:new Map,previousPermissionMode:new Map,sessionTasks:new Map,sessionBackgroundAgents:new Map,completedSubagentSessions:new Map,changedFiles:new Map,sessionNames:Y4(),recentlyRenamed:new Set,prStatus:new Map,mcpServers:new Map,toolProgress:new Map,collapsedProjects:t6(),sessionStartTimes:new Map,sessionViewers:new Map,myRole:new Map,myViewerId:new Map,permissionVotes:new Map,voteResults:new Map,messageQueue:new Map,replaySpeed:1,replayState:"idle",replaySessionId:null,updateInfo:null,updateDismissedVersion:e6(),updateOverlayActive:!1,darkMode:J4(),notificationSound:Q4(),notificationDesktop:Z4(),sidebarOpen:typeof window<"u"?window.innerWidth>=768:!0,taskPanelOpen:typeof window<"u"?window.innerWidth>=1024:!1,homeResetKey:0,activeTab:"chat",diffPanelSelectedFile:new Map,terminalOpen:!1,terminalCwd:null,terminalId:null,sessionCreating:!1,creationProgress:null,creationError:null,setDarkMode:t=>{localStorage.setItem("cc-dark-mode",String(t)),e({darkMode:t})},toggleDarkMode:()=>e(t=>{const s=!t.darkMode;return localStorage.setItem("cc-dark-mode",String(s)),{darkMode:s}}),setNotificationSound:t=>{localStorage.setItem("cc-notification-sound",String(t)),e({notificationSound:t})},toggleNotificationSound:()=>e(t=>{const s=!t.notificationSound;return localStorage.setItem("cc-notification-sound",String(s)),{notificationSound:s}}),setNotificationDesktop:t=>{localStorage.setItem("cc-notification-desktop",String(t)),e({notificationDesktop:t})},toggleNotificationDesktop:()=>e(t=>{const s=!t.notificationDesktop;return localStorage.setItem("cc-notification-desktop",String(s)),{notificationDesktop:s}}),setSidebarOpen:t=>e({sidebarOpen:t}),setTaskPanelOpen:t=>e({taskPanelOpen:t}),newSession:()=>{localStorage.removeItem("cc-current-session"),e(t=>({currentSessionId:null,homeResetKey:t.homeResetKey+1}))},setCurrentSession:t=>{t?localStorage.setItem("cc-current-session",t):localStorage.removeItem("cc-current-session"),e({currentSessionId:t})},addSession:t=>e(s=>{const n=new Map(s.sessions);n.set(t.session_id,t);const a=new Map(s.messages);return a.has(t.session_id)||a.set(t.session_id,[]),{sessions:n,messages:a}}),updateSession:(t,s)=>e(n=>{const a=new Map(n.sessions),l=a.get(t);return l&&a.set(t,{...l,...s}),{sessions:a}}),removeSession:t=>e(s=>{const n=new Map(s.sessions);n.delete(t);const a=new Map(s.messages);a.delete(t);const l=new Map(s.streaming);l.delete(t);const c=new Map(s.streamingStartedAt);c.delete(t);const d=new Map(s.streamingOutputTokens);d.delete(t);const f=new Map(s.connectionStatus);f.delete(t);const h=new Map(s.cliConnected);h.delete(t);const m=new Map(s.sessionStatus);m.delete(t);const g=new Map(s.previousPermissionMode);g.delete(t);const _=new Map(s.pendingPermissions);_.delete(t);const v=new Map(s.sessionTasks);v.delete(t);const y=new Map(s.sessionBackgroundAgents);y.delete(t);const S=new Map(s.completedSubagentSessions);S.delete(t);const j=new Map(s.changedFiles);j.delete(t);const k=new Map(s.sessionNames);k.delete(t);const N=new Set(s.recentlyRenamed);N.delete(t);const E=new Map(s.diffPanelSelectedFile);E.delete(t);const B=new Map(s.mcpServers);B.delete(t);const F=new Map(s.toolProgress);F.delete(t);const $=new Map(s.prStatus);$.delete(t);const K=new Map(s.sessionStartTimes);K.delete(t);const Y=new Map(s.sessionViewers);Y.delete(t);const W=new Map(s.myRole);W.delete(t);const L=new Map(s.myViewerId);L.delete(t);const Q=new Map(s.permissionVotes);Q.delete(t);const V=new Map(s.voteResults);return V.delete(t),localStorage.setItem("cc-session-names",JSON.stringify(Array.from(k.entries()))),s.currentSessionId===t&&localStorage.removeItem("cc-current-session"),{sessions:n,messages:a,streaming:l,streamingStartedAt:c,streamingOutputTokens:d,connectionStatus:f,cliConnected:h,sessionStatus:m,previousPermissionMode:g,pendingPermissions:_,sessionTasks:v,sessionBackgroundAgents:y,completedSubagentSessions:S,changedFiles:j,sessionNames:k,recentlyRenamed:N,diffPanelSelectedFile:E,mcpServers:B,toolProgress:F,prStatus:$,sessionStartTimes:K,sessionViewers:Y,myRole:W,myViewerId:L,permissionVotes:Q,voteResults:V,sdkSessions:s.sdkSessions.filter(X=>X.sessionId!==t),currentSessionId:s.currentSessionId===t?null:s.currentSessionId}}),setSdkSessions:t=>e(s=>{const n=t.filter(f=>f.state==="exited"),a=new Set(n.map(f=>f.sessionId));if(a.size===0)return{sdkSessions:t};const l=new Map(s.cliConnected),c=new Map(s.cliLaunching),d=new Map(s.completedSubagentSessions);for(const f of a)l.set(f,!1),c.delete(f);for(const f of n)(f.orchestrationRole==="subagent"||f.parentSessionId)&&d.set(f.sessionId,d.get(f.sessionId)??"completed");return{sdkSessions:t,cliConnected:l,cliLaunching:c,completedSubagentSessions:d}}),appendMessage:(t,s)=>e(n=>{const a=n.messages.get(t)||[],l=s.id?a.findIndex(d=>d.id===s.id):-1;if(l>=0){const d=a[l],f=[...d.contentBlocks||[],...s.contentBlocks||[]],h=[d.content,s.content].filter(Boolean).join(`
50
+ `),m=[...a];m[l]={...d,content:h,contentBlocks:f,stopReason:s.stopReason||d.stopReason,model:s.model||d.model};const g=new Map(n.messages);return g.set(t,m),{messages:g}}const c=new Map(n.messages);return c.set(t,[...a,s]),{messages:c}}),setMessages:(t,s)=>e(n=>{const a=new Map(n.messages);return a.set(t,s),{messages:a}}),updateLastAssistantMessage:(t,s)=>e(n=>{const a=new Map(n.messages),l=[...a.get(t)||[]];for(let c=l.length-1;c>=0;c--)if(l[c].role==="assistant"){l[c]=s(l[c]);break}return a.set(t,l),{messages:a}}),setStreaming:(t,s)=>e(n=>{const a=new Map(n.streaming);return s===null?a.delete(t):a.set(t,s),{streaming:a}}),setStreamingStats:(t,s)=>e(n=>{const a=new Map(n.streamingStartedAt),l=new Map(n.streamingOutputTokens);return s===null?(a.delete(t),l.delete(t)):(s.startedAt!==void 0&&a.set(t,s.startedAt),s.outputTokens!==void 0&&l.set(t,s.outputTokens)),{streamingStartedAt:a,streamingOutputTokens:l}}),addPermission:(t,s)=>e(n=>{const a=new Map(n.pendingPermissions),l=new Map(a.get(t)||[]);return l.set(s.request_id,s),a.set(t,l),{pendingPermissions:a}}),removePermission:(t,s)=>e(n=>{const a=new Map(n.pendingPermissions),l=a.get(t);if(l){const c=new Map(l);c.delete(s),a.set(t,c)}return{pendingPermissions:a}}),addTask:(t,s)=>e(n=>{const a=new Map(n.sessionTasks),l=[...a.get(t)||[],s];return a.set(t,l),{sessionTasks:a}}),setTasks:(t,s)=>e(n=>{const a=new Map(n.sessionTasks);return a.set(t,s),{sessionTasks:a}}),updateTask:(t,s,n)=>e(a=>{const l=new Map(a.sessionTasks),c=l.get(t);return c&&l.set(t,c.map(d=>d.id===s?{...d,...n}:d)),{sessionTasks:l}}),addBackgroundAgent:(t,s)=>e(n=>{const a=new Map(n.sessionBackgroundAgents),l=[...a.get(t)||[],s];return a.set(t,l),{sessionBackgroundAgents:a}}),updateBackgroundAgent:(t,s,n)=>e(a=>{const l=new Map(a.sessionBackgroundAgents),c=l.get(t);return c&&l.set(t,c.map(d=>d.toolUseId===s?{...d,...n}:d)),{sessionBackgroundAgents:l}}),markSubagentSessionTerminal:(t,s)=>e(n=>{const a=new Map(n.completedSubagentSessions);return a.set(t,s),{completedSubagentSessions:a}}),addChangedFile:(t,s)=>e(n=>{const a=new Map(n.changedFiles),l=new Set(a.get(t)||[]);return l.add(s),a.set(t,l),{changedFiles:a}}),removeChangedFile:(t,s)=>e(n=>{const a=new Map(n.changedFiles),l=a.get(t);if(l!=null&&l.has(s)){const c=new Set(l);return c.delete(s),a.set(t,c),{changedFiles:a}}return n}),clearChangedFiles:t=>e(s=>{const n=new Map(s.changedFiles);return n.delete(t),{changedFiles:n}}),setSessionName:(t,s)=>e(n=>{const a=new Map(n.sessionNames);return a.set(t,s),localStorage.setItem("cc-session-names",JSON.stringify(Array.from(a.entries()))),{sessionNames:a}}),markRecentlyRenamed:t=>e(s=>{const n=new Set(s.recentlyRenamed);return n.add(t),{recentlyRenamed:n}}),clearRecentlyRenamed:t=>e(s=>{const n=new Set(s.recentlyRenamed);return n.delete(t),{recentlyRenamed:n}}),setPRStatus:(t,s)=>e(n=>{const a=new Map(n.prStatus);return a.set(t,s),{prStatus:a}}),setMcpServers:(t,s)=>e(n=>{const a=new Map(n.mcpServers);return a.set(t,s),{mcpServers:a}}),setToolProgress:(t,s,n)=>e(a=>{const l=new Map(a.toolProgress),c=new Map(l.get(t)||[]);return c.set(s,n),l.set(t,c),{toolProgress:l}}),clearToolProgress:(t,s)=>e(n=>{const a=new Map(n.toolProgress);if(s){const l=a.get(t);if(l){const c=new Map(l);c.delete(s),a.set(t,c)}}else a.delete(t);return{toolProgress:a}}),toggleProjectCollapse:t=>e(s=>{const n=new Set(s.collapsedProjects);return n.has(t)?n.delete(t):n.add(t),localStorage.setItem("cc-collapsed-projects",JSON.stringify(Array.from(n))),{collapsedProjects:n}}),setSessionViewers:(t,s)=>e(n=>{const a=new Map(n.sessionViewers);return a.set(t,s),{sessionViewers:a}}),setMyRole:(t,s)=>e(n=>{const a=new Map(n.myRole);return a.set(t,s),{myRole:a}}),setMyViewerId:(t,s)=>e(n=>{const a=new Map(n.myViewerId);return a.set(t,s),{myViewerId:a}}),setPermissionVotes:(t,s,n)=>e(a=>{const l=new Map(a.permissionVotes),c=new Map(l.get(t)||[]);return c.set(s,n),l.set(t,c),{permissionVotes:l}}),setVoteResult:(t,s,n)=>e(a=>{const l=new Map(a.voteResults),c=new Map(l.get(t)||[]);return c.set(s,n),l.set(t,c),{voteResults:l}}),clearVoteState:(t,s)=>e(n=>{const a=new Map(n.permissionVotes),l=a.get(t);if(l){const f=new Map(l);f.delete(s),a.set(t,f)}const c=new Map(n.voteResults),d=c.get(t);if(d){const f=new Map(d);f.delete(s),c.set(t,f)}return{permissionVotes:a,voteResults:c}}),enqueueMessage:(t,s)=>e(n=>{const a=new Map(n.messageQueue),l=a.get(t)||[];return a.set(t,[...l,s]),{messageQueue:a}}),dequeueMessage:t=>{let s;return e(n=>{const a=n.messageQueue.get(t)||[];if(a.length===0)return{};s=a[0];const l=a.slice(1),c=new Map(n.messageQueue);return l.length===0?c.delete(t):c.set(t,l),{messageQueue:c}}),s},clearQueue:t=>e(s=>{const n=new Map(s.messageQueue);return n.delete(t),{messageQueue:n}}),setReplaySpeed:t=>e({replaySpeed:t}),setReplayState:t=>e({replayState:t}),setReplaySessionId:t=>e({replaySessionId:t}),setPreviousPermissionMode:(t,s)=>e(n=>{const a=new Map(n.previousPermissionMode);return a.set(t,s),{previousPermissionMode:a}}),setConnectionStatus:(t,s)=>e(n=>{const a=new Map(n.connectionStatus);return a.set(t,s),{connectionStatus:a}}),setCliConnected:(t,s)=>e(n=>{const a=new Map(n.cliConnected);a.set(t,s);const l=s?new Map(n.cliLaunching):n.cliLaunching;return s&&l.delete(t),{cliConnected:a,cliLaunching:l}}),setCliLaunching:(t,s)=>e(n=>{const a=new Map(n.cliLaunching);return s?a.set(t,!0):a.delete(t),{cliLaunching:a}}),setSessionStatus:(t,s)=>e(n=>{const a=new Map(n.sessionStatus);return a.set(t,s),{sessionStatus:a}}),setUpdateInfo:t=>e({updateInfo:t}),dismissUpdate:t=>{localStorage.setItem("cc-update-dismissed",t),e({updateDismissedVersion:t})},setUpdateOverlayActive:t=>e({updateOverlayActive:t}),setActiveTab:t=>e({activeTab:t}),setDiffPanelSelectedFile:(t,s)=>e(n=>{const a=new Map(n.diffPanelSelectedFile);return s?a.set(t,s):a.delete(t),{diffPanelSelectedFile:a}}),setTerminalOpen:t=>e({terminalOpen:t}),setTerminalCwd:t=>e({terminalCwd:t}),setTerminalId:t=>e({terminalId:t}),openTerminal:t=>e({terminalOpen:!0,terminalCwd:t}),closeTerminal:()=>e({terminalOpen:!1,terminalCwd:null,terminalId:null}),setSessionCreating:t=>e({sessionCreating:t}),setCreationProgress:t=>e({creationProgress:t}),setCreationError:t=>e({creationError:t}),reset:()=>e({sessions:new Map,sdkSessions:[],currentSessionId:null,messages:new Map,streaming:new Map,streamingStartedAt:new Map,streamingOutputTokens:new Map,pendingPermissions:new Map,connectionStatus:new Map,cliConnected:new Map,cliLaunching:new Map,sessionStatus:new Map,previousPermissionMode:new Map,sessionTasks:new Map,sessionBackgroundAgents:new Map,completedSubagentSessions:new Map,changedFiles:new Map,sessionNames:new Map,recentlyRenamed:new Set,mcpServers:new Map,toolProgress:new Map,prStatus:new Map,activeTab:"chat",diffPanelSelectedFile:new Map,terminalOpen:!1,terminalCwd:null,terminalId:null,sessionCreating:!1,creationProgress:null,creationError:null})}));var he=typeof window<"u"?window:void 0,Fs=typeof globalThis<"u"?globalThis:he;typeof self>"u"&&(Fs.self=Fs),typeof File>"u"&&(Fs.File=function(){});var mS=Array.prototype,xy=mS.forEach,vy=mS.indexOf,An=Fs==null?void 0:Fs.navigator,Ne=Fs==null?void 0:Fs.document,$s=Fs==null?void 0:Fs.location,Ag=Fs==null?void 0:Fs.fetch,Rg=Fs!=null&&Fs.XMLHttpRequest&&"withCredentials"in new Fs.XMLHttpRequest?Fs.XMLHttpRequest:void 0,by=Fs==null?void 0:Fs.AbortController,mn=An==null?void 0:An.userAgent,He=he??{},Kr={DEBUG:!1,LIB_VERSION:"1.347.2"};function _y(e,t,s,n,a,l,c){try{var d=e[l](c),f=d.value}catch(h){return void s(h)}d.done?t(f):Promise.resolve(f).then(n,a)}function Do(e){return function(){var t=this,s=arguments;return new Promise((function(n,a){var l=e.apply(t,s);function c(f){_y(l,n,a,c,d,"next",f)}function d(f){_y(l,n,a,c,d,"throw",f)}c(void 0)}))}}function Me(){return Me=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)({}).hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},Me.apply(null,arguments)}function gS(e,t){if(e==null)return{};var s={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;s[n]=e[n]}return s}var s6=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],n6=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],yy=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var s=e.toLowerCase();return n6.concat(t).some((n=>{var a=n.toLowerCase();return s.indexOf(a)!==-1}))};function at(e,t){return e.indexOf(t)!==-1}var $h=function(e){return e.trim()},Dg=function(e){return e.replace(/^\$/,"")},r6=Array.isArray,xS=Object.prototype,vS=xS.hasOwnProperty,Ih=xS.toString,yt=r6||function(e){return Ih.call(e)==="[object Array]"},Wi=e=>typeof e=="function",ys=e=>e===Object(e)&&!yt(e),Lo=e=>{if(ys(e)){for(var t in e)if(vS.call(e,t))return!1;return!0}return!1},Ce=e=>e===void 0,ws=e=>Ih.call(e)=="[object String]",Lg=e=>ws(e)&&e.trim().length===0,nr=e=>e===null,ut=e=>Ce(e)||nr(e),ti=e=>Ih.call(e)=="[object Number]"&&e==e,To=e=>ti(e)&&e>0,ei=e=>Ih.call(e)==="[object Boolean]",i6=e=>e instanceof FormData,a6=e=>at(s6,e);function Bg(e){return e===null||typeof e!="object"}function hh(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function bS(e){return!Ce(Event)&&(function(t,s){try{return t instanceof s}catch{return!1}})(e,Event)}var o6=[!0,"true",1,"1","yes"],bm=e=>at(o6,e),l6=[!1,"false",0,"0","no"];function vr(e,t,s,n,a){return t>s&&(n.warn("min cannot be greater than max."),t=s),ti(e)?e>s?(n.warn(" cannot be greater than max: "+s+". Using max value instead."),s):e<t?(n.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(n.warn(" must be a number. using max or fallback. max: "+s+", fallback: "+a),vr(a||s,t,s,n))}let c6=class{constructor(t){this.t={},this.i=t.i,this.o=vr(t.bucketSize,0,100,t.h),this.m=vr(t.refillRate,0,this.o,t.h),this.$=vr(t.refillInterval,0,864e5,t.h)}S(t,s){var n=s-t.lastAccess,a=Math.floor(n/this.$);if(a>0){var l=a*this.m;t.tokens=Math.min(t.tokens+l,this.o),t.lastAccess=t.lastAccess+a*this.$}}consumeRateLimit(t){var s,n=Date.now(),a=String(t),l=this.t[a];return l?this.S(l,n):(l={tokens:this.o,lastAccess:n},this.t[a]=l),l.tokens===0||(l.tokens--,l.tokens===0&&((s=this.i)==null||s.call(this,t)),l.tokens===0)}stop(){this.t={}}};var Kn="Mobile",fh="iOS",Qr="Android",Hc="Tablet",_S=Qr+" "+Hc,yS="iPad",wS="Apple",SS=wS+" Watch",Uc="Safari",Uo="BlackBerry",jS="Samsung",kS=jS+"Browser",CS=jS+" Internet",Na="Chrome",u6=Na+" OS",NS=Na+" "+fh,g0="Internet Explorer",ES=g0+" "+Kn,x0="Opera",d6=x0+" Mini",v0="Edge",MS="Microsoft "+v0,$o="Firefox",TS=$o+" "+fh,Vc="Nintendo",Wc="PlayStation",Io="Xbox",AS=Qr+" "+Kn,RS=Kn+" "+Uc,xc="Windows",Og=xc+" Phone",wy="Nokia",zg="Ouya",DS="Generic",h6=DS+" "+Kn.toLowerCase(),LS=DS+" "+Hc.toLowerCase(),Pg="Konqueror",Xs="(\\d+(\\.\\d+)?)",_m=new RegExp("Version/"+Xs),f6=new RegExp(Io,"i"),p6=new RegExp(Wc+" \\w+","i"),m6=new RegExp(Vc+" \\w+","i"),b0=new RegExp(Uo+"|PlayBook|BB10","i"),g6={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},Md,Sy,ym,x6=(e,t)=>t&&at(t,wS)||(function(s){return at(s,Uc)&&!at(s,Na)&&!at(s,Qr)})(e),BS=function(e,t){return t=t||"",at(e," OPR/")&&at(e,"Mini")?d6:at(e," OPR/")?x0:b0.test(e)?Uo:at(e,"IE"+Kn)||at(e,"WPDesktop")?ES:at(e,kS)?CS:at(e,v0)||at(e,"Edg/")?MS:at(e,"FBIOS")?"Facebook "+Kn:at(e,"UCWEB")||at(e,"UCBrowser")?"UC Browser":at(e,"CriOS")?NS:at(e,"CrMo")||at(e,Na)?Na:at(e,Qr)&&at(e,Uc)?AS:at(e,"FxiOS")?TS:at(e.toLowerCase(),Pg.toLowerCase())?Pg:x6(e,t)?at(e,Kn)?RS:Uc:at(e,$o)?$o:at(e,"MSIE")||at(e,"Trident/")?g0:at(e,"Gecko")?$o:""},v6={[ES]:[new RegExp("rv:"+Xs)],[MS]:[new RegExp(v0+"?\\/"+Xs)],[Na]:[new RegExp("("+Na+"|CrMo)\\/"+Xs)],[NS]:[new RegExp("CriOS\\/"+Xs)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Xs)],[Uc]:[_m],[RS]:[_m],[x0]:[new RegExp("(Opera|OPR)\\/"+Xs)],[$o]:[new RegExp($o+"\\/"+Xs)],[TS]:[new RegExp("FxiOS\\/"+Xs)],[Pg]:[new RegExp("Konqueror[:/]?"+Xs,"i")],[Uo]:[new RegExp(Uo+" "+Xs),_m],[AS]:[new RegExp("android\\s"+Xs,"i")],[CS]:[new RegExp(kS+"\\/"+Xs)],[g0]:[new RegExp("(rv:|MSIE )"+Xs)],Mozilla:[new RegExp("rv:"+Xs)]},b6=function(e,t){var s=BS(e,t),n=v6[s];if(Ce(n))return null;for(var a=0;a<n.length;a++){var l=n[a],c=e.match(l);if(c)return parseFloat(c[c.length-2])}return null},jy=[[new RegExp(Io+"; "+Io+" (.*?)[);]","i"),e=>[Io,e&&e[1]||""]],[new RegExp(Vc,"i"),[Vc,""]],[new RegExp(Wc,"i"),[Wc,""]],[b0,[Uo,""]],[new RegExp(xc,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Og,""];if(new RegExp(Kn).test(t)&&!/IEMobile\b/.test(t))return[xc+" "+Kn,""];var s=/Windows NT ([0-9.]+)/i.exec(t);if(s&&s[1]){var n=s[1],a=g6[n]||"";return/arm/i.test(t)&&(a="RT"),[xc,a]}return[xc,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[fh,t.join(".")]}return[fh,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=Ce(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Qr+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Qr+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[Qr,t.join(".")]}return[Qr,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var s=[e[1],e[2],e[3]||"0"];t[1]=s.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[u6,""]],[/Linux|debian/i,["Linux",""]]],ky=function(e){return m6.test(e)?Vc:p6.test(e)?Wc:f6.test(e)?Io:new RegExp(zg,"i").test(e)?zg:new RegExp("("+Og+"|WPDesktop)","i").test(e)?Og:/iPad/.test(e)?yS:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?SS:b0.test(e)?Uo:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(wy,"i").test(e)?wy:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(Kn).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Qr:_S:new RegExp("(pda|"+Kn+")","i").test(e)?h6:new RegExp(Hc,"i").test(e)&&!new RegExp(Hc+" pc","i").test(e)?LS:""},_6=e=>e instanceof Error;function y6(e){var t=globalThis._posthogChunkIds;if(t){var s=Object.keys(t);return ym&&s.length===Sy||(Sy=s.length,ym=s.reduce(((n,a)=>{Md||(Md={});var l=Md[a];if(l)n[l[0]]=l[1];else for(var c=e(a),d=c.length-1;d>=0;d--){var f=c[d],h=f==null?void 0:f.filename,m=t[a];if(h&&m){n[h]=m,Md[a]=[h,m];break}}return n}),{})),ym}}let w6=class{constructor(t,s,n){n===void 0&&(n=[]),this.coercers=t,this.stackParser=s,this.modifiers=n}buildFromUnknown(t,s){s===void 0&&(s={});var n=s&&s.mechanism||{handled:!0,type:"generic"},a=this.buildCoercingContext(n,s,0).apply(t),l=this.buildParsingContext(s),c=this.parseStacktrace(a,l);return{$exception_list:this.convertToExceptionList(c,n),$exception_level:"error"}}modifyFrames(t){var s=this;return Do((function*(){for(var n of t)n.stacktrace&&n.stacktrace.frames&&yt(n.stacktrace.frames)&&(n.stacktrace.frames=yield s.applyModifiers(n.stacktrace.frames));return t}))()}coerceFallback(t){var s;return{type:"Error",value:"Unknown error",stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}parseStacktrace(t,s){var n,a;return t.cause!=null&&(n=this.parseStacktrace(t.cause,s)),t.stack!=""&&t.stack!=null&&(a=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?s.skipFirstLines:0),s.chunkIdMap)),Me({},t,{cause:n,stack:a})}applyChunkIds(t,s){return t.map((n=>(n.filename&&s&&(n.chunk_id=s[n.filename]),n)))}applyCoercers(t,s){for(var n of this.coercers)if(n.match(t))return n.coerce(t,s);return this.coerceFallback(s)}applyModifiers(t){var s=this;return Do((function*(){var n=t;for(var a of s.modifiers)n=yield a(n);return n}))()}convertToExceptionList(t,s){var n,a,l,c={type:t.type,value:t.value,mechanism:{type:(n=s.type)!==null&&n!==void 0?n:"generic",handled:(a=s.handled)===null||a===void 0||a,synthetic:(l=t.synthetic)!==null&&l!==void 0&&l}};t.stack&&(c.stacktrace={type:"raw",frames:t.stack});var d=[c];return t.cause!=null&&d.push(...this.convertToExceptionList(t.cause,Me({},s,{handled:!0}))),d}buildParsingContext(t){var s;return{chunkIdMap:y6(this.stackParser),skipFirstLines:(s=t.skipFirstLines)!==null&&s!==void 0?s:1}}buildCoercingContext(t,s,n){n===void 0&&(n=0);var a=(l,c)=>{if(c<=4){var d=this.buildCoercingContext(t,s,c);return this.applyCoercers(l,d)}};return Me({},s,{syntheticException:n==0?s.syntheticException:void 0,mechanism:t,apply:l=>a(l,n),next:l=>a(l,n+1)})}};var Vo="?";function $g(e,t,s,n,a){var l={platform:e,filename:t,function:s==="<anonymous>"?Vo:s,in_app:!0};return Ce(n)||(l.lineno=n),Ce(a)||(l.colno=a),l}var OS=(e,t)=>{var s=e.indexOf("safari-extension")!==-1,n=e.indexOf("safari-web-extension")!==-1;return s||n?[e.indexOf("@")!==-1?e.split("@")[0]:Vo,s?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},S6=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,j6=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,k6=/\((\S*)(?::(\d+))(?::(\d+))\)/,C6=(e,t)=>{var s=S6.exec(e);if(s){var[,n,a,l]=s;return $g(t,n,Vo,+a,+l)}var c=j6.exec(e);if(c){if(c[2]&&c[2].indexOf("eval")===0){var d=k6.exec(c[2]);d&&(c[2]=d[1],c[3]=d[2],c[4]=d[3])}var[f,h]=OS(c[1]||Vo,c[2]);return $g(t,h,f,c[3]?+c[3]:void 0,c[4]?+c[4]:void 0)}},N6=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,E6=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,M6=(e,t)=>{var s=N6.exec(e);if(s){if(s[3]&&s[3].indexOf(" > eval")>-1){var n=E6.exec(s[3]);n&&(s[1]=s[1]||"eval",s[3]=n[1],s[4]=n[2],s[5]="")}var a=s[3],l=s[1]||Vo;return[l,a]=OS(l,a),$g(t,a,l,s[4]?+s[4]:void 0,s[5]?+s[5]:void 0)}},Cy=/\(error: (.*)\)/,Ny=50;function T6(){return(function(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n<t;n++)s[n-1]=arguments[n];return function(a,l){l===void 0&&(l=0);for(var c=[],d=a.split(`
51
+ `),f=l;f<d.length;f++){var h=d[f];if(!(h.length>1024)){var m=Cy.test(h)?h.replace(Cy,"$1"):h;if(!m.match(/\S*Error: /)){for(var g of s){var _=g(m,e);if(_){c.push(_);break}}if(c.length>=Ny)break}}}return(function(v){if(!v.length)return[];var y=Array.from(v);return y.reverse(),y.slice(0,Ny).map((S=>{return Me({},S,{filename:S.filename||(j=y,j[j.length-1]||{}).filename,function:S.function||Vo});var j}))})(c)}})("web:javascript",C6,M6)}let A6=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,s){var n=ws(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:n?t.stack:void 0,cause:t.cause?s.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var s=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?s+": "+t.message:s}isDOMException(t){return hh(t,"DOMException")}isDOMError(t){return hh(t,"DOMError")}},R6=class{match(t){return(s=>s instanceof Error)(t)}coerce(t,s){return{type:this.getType(t),value:this.getMessage(t,s),stack:this.getStack(t),cause:t.cause?s.next(t.cause):void 0,synthetic:!1}}getType(t){return t.name||t.constructor.name}getMessage(t,s){var n=t.message;return n.error&&typeof n.error.message=="string"?String(n.error.message):String(n)}getStack(t){return t.stacktrace||t.stack||void 0}};class D6{constructor(){}match(t){return hh(t,"ErrorEvent")&&t.error!=null}coerce(t,s){var n,a=s.apply(t.error);return a||{type:"ErrorEvent",value:t.message,stack:(n=s.syntheticException)==null?void 0:n.stack,synthetic:!0}}}var L6=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;let B6=class{match(t){return typeof t=="string"}coerce(t,s){var n,[a,l]=this.getInfos(t);return{type:a??"Error",value:l??t,stack:(n=s.syntheticException)==null?void 0:n.stack,synthetic:!0}}getInfos(t){var s="Error",n=t,a=t.match(L6);return a&&(s=a[1],n=a[2]),[s,n]}};var O6=["fatal","error","warning","log","info","debug"];function zS(e,t){t===void 0&&(t=40);var s=Object.keys(e);if(s.sort(),!s.length)return"[object has no keys]";for(var n=s.length;n>0;n--){var a=s.slice(0,n).join(", ");if(!(a.length>t))return n===s.length||a.length<=t?a:a.slice(0,t)+"..."}return""}let z6=class{match(t){return typeof t=="object"&&t!==null}coerce(t,s){var n,a=this.getErrorPropertyFromObject(t);return a?s.apply(a):{type:this.getType(t),value:this.getValue(t),stack:(n=s.syntheticException)==null?void 0:n.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return bS(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){var s="'"+t.name+"' captured as exception";return"message"in t&&typeof t.message=="string"&&(s+=" with message: '"+t.message+"'"),s}if("message"in t&&typeof t.message=="string")return t.message;var n=this.getObjectClassName(t);return(n&&n!=="Object"?"'"+n+"'":"Object")+" captured as exception with keys: "+zS(t)}isSeverityLevel(t){return ws(t)&&!Lg(t)&&O6.indexOf(t)>=0}getErrorPropertyFromObject(t){for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s)){var n=t[s];if(_6(n))return n}}getObjectClassName(t){try{var s=Object.getPrototypeOf(t);return s?s.constructor.name:void 0}catch{return}}},P6=class{match(t){return bS(t)}coerce(t,s){var n,a=t.constructor.name;return{type:a,value:a+" captured as exception with keys: "+zS(t),stack:(n=s.syntheticException)==null?void 0:n.stack,synthetic:!0}}};class $6{match(t){return Bg(t)}coerce(t,s){var n;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:(n=s.syntheticException)==null?void 0:n.stack,synthetic:!0}}}let I6=class{match(t){return hh(t,"PromiseRejectionEvent")}coerce(t,s){var n,a=this.getUnhandledRejectionReason(t);return Bg(a)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(a),stack:(n=s.syntheticException)==null?void 0:n.stack,synthetic:!0}:s.apply(a)}getUnhandledRejectionReason(t){if(Bg(t))return t;try{if("reason"in t)return t.reason;if("detail"in t&&"reason"in t.detail)return t.detail.reason}catch{}return t}};var PS=function(e,t){var{debugEnabled:s}=t===void 0?{}:t,n={k:function(a){if(he&&(Kr.DEBUG||He.POSTHOG_DEBUG||s)&&!Ce(he.console)&&he.console){for(var l=("__rrweb_original__"in he.console[a])?he.console[a].__rrweb_original__:he.console[a],c=arguments.length,d=new Array(c>1?c-1:0),f=1;f<c;f++)d[f-1]=arguments[f];l(e,...d)}},info:function(){for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];n.k("log",...l)},warn:function(){for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];n.k("warn",...l)},error:function(){for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];n.k("error",...l)},critical:function(){for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];console.error(e,...l)},uninitializedWarning:a=>{n.error("You must initialize PostHog before calling "+a)},createLogger:(a,l)=>PS(e+" "+a,l)};return n},Ee=PS("[PostHog.js]"),Gt=Ee.createLogger,F6=Gt("[ExternalScriptsLoader]"),Ey=(e,t,s)=>{if(e.config.disable_external_dependency_loading)return F6.warn(t+" was requested but loading of external scripts is disabled."),s("Loading of external scripts is disabled");var n=Ne==null?void 0:Ne.querySelectorAll("script");if(n){for(var a,l=function(){if(n[c].src===t){var f=n[c];return f.__posthog_loading_callback_fired?{v:s()}:(f.addEventListener("load",(h=>{f.__posthog_loading_callback_fired=!0,s(void 0,h)})),f.onerror=h=>s(h),{v:void 0})}},c=0;c<n.length;c++)if(a=l())return a.v}var d=()=>{if(!Ne)return s("document not found");var f=Ne.createElement("script");if(f.type="text/javascript",f.crossOrigin="anonymous",f.src=t,f.onload=g=>{f.__posthog_loading_callback_fired=!0,s(void 0,g)},f.onerror=g=>s(g),e.config.prepare_external_dependency_script&&(f=e.config.prepare_external_dependency_script(f)),!f)return s("prepare_external_dependency_script returned null");if(e.config.external_scripts_inject_target==="head")Ne.head.appendChild(f);else{var h,m=Ne.querySelectorAll("body > script");m.length>0?(h=m[0].parentNode)==null||h.insertBefore(f,m[0]):Ne.body.appendChild(f)}};Ne!=null&&Ne.body?d():Ne==null||Ne.addEventListener("DOMContentLoaded",d)};He.__PosthogExtensions__=He.__PosthogExtensions__||{},He.__PosthogExtensions__.loadExternalDependency=(e,t,s)=>{var n="/static/"+t+".js?v="+e.version;if(t==="remote-config"&&(n="/array/"+e.config.token+"/config.js"),t==="toolbar"){var a=3e5;n=n+"&t="+Math.floor(Date.now()/a)*a}var l=e.requestRouter.endpointFor("assets",n);Ey(e,l,s)},He.__PosthogExtensions__.loadSiteApp=(e,t,s)=>{var n=e.requestRouter.endpointFor("api",t);Ey(e,n,s)};var ph={};function qi(e,t,s){if(yt(e)){if(xy&&e.forEach===xy)e.forEach(t,s);else if("length"in e&&e.length===+e.length){for(var n=0,a=e.length;n<a;n++)if(n in e&&t.call(s,e[n],n)===ph)return}}}function Lt(e,t,s){if(!ut(e)){if(yt(e))return qi(e,t,s);if(i6(e)){for(var n of e.entries())if(t.call(s,n[1],n[0])===ph)return}else for(var a in e)if(vS.call(e,a)&&t.call(s,e[a],a)===ph)return}}var as=function(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n<t;n++)s[n-1]=arguments[n];return qi(s,(function(a){for(var l in a)a[l]!==void 0&&(e[l]=a[l])})),e},Xo=function(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n<t;n++)s[n-1]=arguments[n];return qi(s,(function(a){qi(a,(function(l){e.push(l)}))})),e};function Zd(e){for(var t=Object.keys(e),s=t.length,n=new Array(s);s--;)n[s]=[t[s],e[t[s]]];return n}var My=function(e){try{return e()}catch{return}},H6=function(e){return function(){try{for(var t=arguments.length,s=new Array(t),n=0;n<t;n++)s[n]=arguments[n];return e.apply(this,s)}catch(a){Ee.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ee.critical(a)}}},_0=function(e){var t={};return Lt(e,(function(s,n){(ws(s)&&s.length>0||ti(s))&&(t[n]=s)})),t};function U6(e,t){return s=e,n=l=>ws(l)&&!nr(t)?l.slice(0,t):l,a=new Set,(function l(c,d){return c!==Object(c)?n?n(c,d):c:a.has(c)?void 0:(a.add(c),yt(c)?(f=[],qi(c,(h=>{f.push(l(h))}))):(f={},Lt(c,((h,m)=>{a.has(h)||(f[m]=l(h,m))}))),f);var f})(s);var s,n,a}var V6=["herokuapp.com","vercel.app","netlify.app"];function W6(e){var t=e==null?void 0:e.hostname;if(!ws(t))return!1;var s=t.split(".").slice(-2).join(".");for(var n of V6)if(s===n)return!1;return!0}function $S(e,t){for(var s=0;s<e.length;s++)if(t(e[s]))return e[s]}function ps(e,t,s,n){var{capture:a=!1,passive:l=!0}=n??{};e==null||e.addEventListener(t,s,{capture:a,passive:l})}var IS="$people_distinct_id",vc="__alias",bc="__timers",Ty="$autocapture_disabled_server_side",Ig="$heatmaps_enabled_server_side",Ay="$exception_capture_enabled_server_side",Fg="$error_tracking_suppression_rules",Ry="$error_tracking_capture_extension_exceptions",Dy="$web_vitals_enabled_server_side",FS="$dead_clicks_enabled_server_side",Ly="$product_tours_enabled_server_side",By="$web_vitals_allowed_metrics",Td="$session_recording_remote_config",mh="$sesid",HS="$session_is_sampled",Bo="$enabled_feature_flags",_c="$early_access_features",Hg="$feature_flag_details",yc="$stored_person_properties",ya="$stored_group_properties",Ug="$surveys",gh="$flag_call_reported",Vg="$feature_flag_errors",Yr="$user_state",Wg="$client_session_props",qg="$capture_rate_limit",Gg="$initial_campaign_params",Kg="$initial_referrer_info",xh="$initial_person_info",vh="$epp",US="__POSTHOG_TOOLBAR__",Kl="$posthog_cookieless",q6=[IS,vc,"__cmpns",bc,"$session_recording_enabled_server_side",Ig,mh,Bo,Fg,Yr,_c,Hg,ya,yc,Ug,gh,Vg,Wg,qg,Gg,Kg,vh,xh,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function Oy(e){return e instanceof Element&&(e.id===US||!(e.closest==null||!e.closest(".toolbar-global-fade-container")))}function Fh(e){return!!e&&e.nodeType===1}function Gi(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function VS(e){return!!e&&e.nodeType===3}function WS(e){return!!e&&e.nodeType===11}function y0(e){return e?$h(e).split(/\s+/):[]}function zy(e){var t=he==null?void 0:he.location.href;return!!(t&&e&&e.some((s=>t.match(s))))}function bh(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return y0(t)}function qS(e){return ut(e)?null:$h(e).split(/(\s+)/).filter((t=>qc(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function su(e){var t="";return Yg(e)&&!JS(e)&&e.childNodes&&e.childNodes.length&&Lt(e.childNodes,(function(s){var n;VS(s)&&s.textContent&&(t+=(n=qS(s.textContent))!==null&&n!==void 0?n:"")})),$h(t)}function GS(e){return Ce(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var w0=["a","button","form","input","select","textarea","label"];function KS(e,t){if(Ce(t))return!0;var s,n=function(l){if(t.some((c=>l.matches(c))))return{v:!0}};for(var a of e)if(s=n(a))return s.v;return!1}function YS(e){var t=e.parentNode;return!(!t||!Fh(t))&&t}var G6=["next","previous","prev",">","<"],Py=10,$y=[".ph-no-rageclick",".ph-no-capture"];function K6(e,t){if(!he||S0(e))return!1;var s,n,a;if(ei(t)?(s=!!t&&$y,n=void 0):(s=(a=t==null?void 0:t.css_selector_ignorelist)!==null&&a!==void 0?a:$y,n=t==null?void 0:t.content_ignorelist),s===!1)return!1;var{targetElementList:l}=XS(e,!1);return!(function(c,d){if(c===!1||Ce(c))return!1;var f;if(c===!0)f=G6;else{if(!yt(c))return!1;if(c.length>Py)return Ee.error("[PostHog] content_ignorelist array cannot exceed "+Py+" items. Use css_selector_ignorelist for more complex matching."),!1;f=c.map((h=>h.toLowerCase()))}return d.some((h=>{var{safeText:m,ariaLabel:g}=h;return f.some((_=>m.includes(_)||g.includes(_)))}))})(n,l.map((c=>{var d;return{safeText:su(c).toLowerCase(),ariaLabel:((d=c.getAttribute("aria-label"))==null?void 0:d.toLowerCase().trim())||""}})))&&!KS(l,s)}var S0=e=>!e||Gi(e,"html")||!Fh(e),XS=(e,t)=>{if(!he||S0(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var s=!1,n=[e],a=e;a.parentNode&&!Gi(a,"body");)if(WS(a.parentNode))n.push(a.parentNode.host),a=a.parentNode.host;else{var l=YS(a);if(!l)break;if(t||w0.indexOf(l.tagName.toLowerCase())>-1)s=!0;else{var c=he.getComputedStyle(l);c&&c.getPropertyValue("cursor")==="pointer"&&(s=!0)}n.push(l),a=l}return{parentIsUsefulElement:s,targetElementList:n}};function Y6(e,t,s,n,a){var l,c,d,f;if(s===void 0&&(s=void 0),!he||S0(e)||(l=s)!=null&&l.url_allowlist&&!zy(s.url_allowlist)||(c=s)!=null&&c.url_ignorelist&&zy(s.url_ignorelist))return!1;if((d=s)!=null&&d.dom_event_allowlist){var h=s.dom_event_allowlist;if(h&&!h.some((y=>t.type===y)))return!1}var{parentIsUsefulElement:m,targetElementList:g}=XS(e,n);if(!(function(y,S){var j=S==null?void 0:S.element_allowlist;if(Ce(j))return!0;var k,N=function(B){if(j.some((F=>B.tagName.toLowerCase()===F)))return{v:!0}};for(var E of y)if(k=N(E))return k.v;return!1})(g,s)||!KS(g,(f=s)==null?void 0:f.css_selector_allowlist))return!1;var _=he.getComputedStyle(e);if(_&&_.getPropertyValue("cursor")==="pointer"&&t.type==="click")return!0;var v=e.tagName.toLowerCase();switch(v){case"html":return!1;case"form":return(a||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(a||["change","click"]).indexOf(t.type)>=0;default:return m?(a||["click"]).indexOf(t.type)>=0:(a||["click"]).indexOf(t.type)>=0&&(w0.indexOf(v)>-1||e.getAttribute("contenteditable")==="true")}}function Yg(e){for(var t=e;t.parentNode&&!Gi(t,"body");t=t.parentNode){var s=bh(t);if(at(s,"ph-sensitive")||at(s,"ph-no-capture"))return!1}if(at(bh(e),"ph-include"))return!0;var n=e.type||"";if(ws(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var a=e.name||e.id||"";return!(ws(a)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(a.replace(/[^a-zA-Z0-9]/g,"")))}function JS(e){return!!(Gi(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Gi(e,"select")||Gi(e,"textarea")||e.getAttribute("contenteditable")==="true")}var QS="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",X6=new RegExp("^(?:"+QS+")$"),J6=new RegExp(QS),ZS="\\d{3}-?\\d{2}-?\\d{4}",Q6=new RegExp("^("+ZS+")$"),Z6=new RegExp("("+ZS+")");function qc(e,t){return t===void 0&&(t=!0),!(ut(e)||ws(e)&&(e=$h(e),(t?X6:J6).test((e||"").replace(/[- ]/g,""))||(t?Q6:Z6).test(e)))}function ej(e){var t=su(e);return qc(t=(t+" "+tj(e)).trim())?t:""}function tj(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Lt(e.childNodes,(function(s){var n;if(s&&((n=s.tagName)==null?void 0:n.toLowerCase())==="span")try{var a=su(s);t=(t+" "+a).trim(),s.childNodes&&s.childNodes.length&&(t=(t+" "+tj(s)).trim())}catch(l){Ee.error("[AutoCapture]",l)}})),t}function eE(e){return(function(t){var s=t.map((n=>{var a,l,c="";if(n.tag_name&&(c+=n.tag_name),n.attr_class)for(var d of(n.attr_class.sort(),n.attr_class))c+="."+d.replace(/"/g,"");var f=Me({},n.text?{text:n.text}:{},{"nth-child":(a=n.nth_child)!==null&&a!==void 0?a:0,"nth-of-type":(l=n.nth_of_type)!==null&&l!==void 0?l:0},n.href?{href:n.href}:{},n.attr_id?{attr_id:n.attr_id}:{},n.attributes),h={};return Zd(f).sort(((m,g)=>{var[_]=m,[v]=g;return _.localeCompare(v)})).forEach((m=>{var[g,_]=m;return h[Iy(g.toString())]=Iy(_.toString())})),c+=":",c+=Zd(h).map((m=>{var[g,_]=m;return g+'="'+_+'"'})).join("")}));return s.join(";")})((function(t){return t.map((s=>{var n,a,l={text:(n=s.$el_text)==null?void 0:n.slice(0,400),tag_name:s.tag_name,href:(a=s.attr__href)==null?void 0:a.slice(0,2048),attr_class:tE(s),attr_id:s.attr__id,nth_child:s.nth_child,nth_of_type:s.nth_of_type,attributes:{}};return Zd(s).filter((c=>{var[d]=c;return d.indexOf("attr__")===0})).forEach((c=>{var[d,f]=c;return l.attributes[d]=f})),l}))})(e))}function Iy(e){return e.replace(/"|\\"/g,'\\"')}function tE(e){var t=e.attr__class;return t?yt(t)?t:y0(t):void 0}let sj=class{constructor(t){this.disabled=t===!1;var s=ys(t)?t:{};this.thresholdPx=s.threshold_px||30,this.timeoutMs=s.timeout_ms||1e3,this.clickCount=s.click_count||3,this.clicks=[]}isRageClick(t,s,n){if(this.disabled)return!1;var a=this.clicks[this.clicks.length-1];if(a&&Math.abs(t-a.x)+Math.abs(s-a.y)<this.thresholdPx&&n-a.timestamp<this.timeoutMs){if(this.clicks.push({x:t,y:s,timestamp:n}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:s,timestamp:n}];return!1}};var _h=e=>{var t=Ne==null?void 0:Ne.createElement("a");return Ce(t)?null:(t.href=e,t)},sE=function(e,t){var s,n;t===void 0&&(t="&");var a=[];return Lt(e,(function(l,c){Ce(l)||Ce(c)||c==="undefined"||(s=encodeURIComponent((d=>d instanceof File)(l)?l.name:l.toString()),n=encodeURIComponent(c),a[a.length]=n+"="+s)})),a.join(t)},yh=function(e,t){for(var s,n=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),a=0;a<n.length;a++){var l=n[a].split("=");if(l[0]===t){s=l;break}}if(!yt(s)||s.length<2)return"";var c=s[1];try{c=decodeURIComponent(c)}catch{Ee.error("Skipping decoding for malformed query param: "+c)}return c.replace(/\+/g," ")},nu=function(e,t,s){if(!e||!t||!t.length)return e;for(var n=e.split("#"),a=n[0]||"",l=n[1],c=a.split("?"),d=c[1],f=c[0],h=(d||"").split("&"),m=[],g=0;g<h.length;g++){var _=h[g].split("=");yt(_)&&(t.includes(_[0])?m.push(_[0]+"="+s):m.push(h[g]))}var v=f;return d!=null&&(v+="?"+m.join("&")),l!=null&&(v+="#"+l),v},wh=function(e,t){var s=e.match(new RegExp(t+"=([^&]*)"));return s?s[1]:null},wm="$copy_autocapture",Fy=Gt("[AutoCapture]");function Sm(e,t){return t.length>e?t.slice(0,e)+"...":t}function nE(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!Fh(t));return t}function rE(e,t,s,n){var a=e.tagName.toLowerCase(),l={tag_name:a};w0.indexOf(a)>-1&&!s&&(a.toLowerCase()==="a"||a.toLowerCase()==="button"?l.$el_text=Sm(1024,ej(e)):l.$el_text=Sm(1024,su(e)));var c=bh(e);c.length>0&&(l.classes=c.filter((function(m){return m!==""}))),Lt(e.attributes,(function(m){var g;if((!JS(e)||["name","id","class","aria-label"].indexOf(m.name)!==-1)&&(n==null||!n.includes(m.name))&&!t&&qc(m.value)&&(g=m.name,!ws(g)||g.substring(0,10)!=="_ngcontent"&&g.substring(0,7)!=="_nghost")){var _=m.value;m.name==="class"&&(_=y0(_).join(" ")),l["attr__"+m.name]=Sm(1024,_)}}));for(var d=1,f=1,h=e;h=nE(h);)d++,h.tagName===e.tagName&&f++;return l.nth_child=d,l.nth_of_type=f,l}function iE(e,t){for(var s,n,{e:a,maskAllElementAttributes:l,maskAllText:c,elementAttributeIgnoreList:d,elementsChainAsString:f}=t,h=[e],m=e;m.parentNode&&!Gi(m,"body");)WS(m.parentNode)?(h.push(m.parentNode.host),m=m.parentNode.host):(h.push(m.parentNode),m=m.parentNode);var g,_=[],v={},y=!1,S=!1;if(Lt(h,(B=>{var F=Yg(B);B.tagName.toLowerCase()==="a"&&(y=B.getAttribute("href"),y=F&&y&&qc(y)&&y),at(bh(B),"ph-no-capture")&&(S=!0),_.push(rE(B,l,c,d));var $=(function(K){if(!Yg(K))return{};var Y={};return Lt(K.attributes,(function(W){if(W.name&&W.name.indexOf("data-ph-capture-attribute")===0){var L=W.name.replace("data-ph-capture-attribute-",""),Q=W.value;L&&Q&&qc(Q)&&(Y[L]=Q)}})),Y})(B);as(v,$)})),S)return{props:{},explicitNoCapture:S};if(c||(e.tagName.toLowerCase()==="a"||e.tagName.toLowerCase()==="button"?_[0].$el_text=ej(e):_[0].$el_text=su(e)),y){var j,k;_[0].attr__href=y;var N=(j=_h(y))==null?void 0:j.host,E=he==null||(k=he.location)==null?void 0:k.host;N&&E&&N!==E&&(g=y)}return{props:as({$event_type:a.type,$ce_version:1},f?{}:{$elements:_},{$elements_chain:eE(_)},(s=_[0])!=null&&s.$el_text?{$el_text:(n=_[0])==null?void 0:n.$el_text}:{},g&&a.type==="click"?{$external_click_url:g}:{},v)}}let aE=class{constructor(t){this.P=!1,this.T=null,this.I=!1,this.instance=t,this.rageclicks=new sj(t.config.rageclick),this.C=null}get R(){var t,s,n=ys(this.instance.config.autocapture)?this.instance.config.autocapture:{};return n.url_allowlist=(t=n.url_allowlist)==null?void 0:t.map((a=>new RegExp(a))),n.url_ignorelist=(s=n.url_ignorelist)==null?void 0:s.map((a=>new RegExp(a))),n}F(){if(this.isBrowserSupported()){if(he&&Ne){var t=n=>{n=n||(he==null?void 0:he.event);try{this.O(n)}catch(a){Fy.error("Failed to capture event",a)}};if(ps(Ne,"submit",t,{capture:!0}),ps(Ne,"change",t,{capture:!0}),ps(Ne,"click",t,{capture:!0}),this.R.capture_copied_text){var s=n=>{n=n||(he==null?void 0:he.event),this.O(n,wm)};ps(Ne,"copy",s,{capture:!0}),ps(Ne,"cut",s,{capture:!0})}}}else Fy.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.P&&(this.F(),this.P=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.I=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ty]:!!t.autocapture_opt_out}),this.T=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.C=t}getElementSelectors(t){var s,n=[];return(s=this.C)==null||s.forEach((a=>{var l=Ne==null?void 0:Ne.querySelectorAll(a);l==null||l.forEach((c=>{t===c&&n.push(a)}))})),n}get isEnabled(){var t,s,n=(t=this.instance.persistence)==null?void 0:t.props[Ty],a=this.T;if(nr(a)&&!ei(n)&&!this.instance.M())return!1;var l=(s=this.T)!==null&&s!==void 0?s:!!n;return!!this.instance.config.autocapture&&!l}O(t,s){if(s===void 0&&(s="$autocapture"),this.isEnabled){var n,a=GS(t);VS(a)&&(a=a.parentNode||null),s==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&K6(a,this.instance.config.rageclick)&&this.O(t,"$rageclick");var l=s===wm;if(a&&Y6(a,t,this.R,l,l?["copy","cut"]:void 0)){var{props:c,explicitNoCapture:d}=iE(a,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.R.element_attribute_ignorelist,elementsChainAsString:this.I});if(d)return!1;var f=this.getElementSelectors(a);if(f&&f.length>0&&(c.$element_selectors=f),s===wm){var h,m=qS(he==null||(h=he.getSelection())==null?void 0:h.toString()),g=t.type||"clipboard";if(!m)return!1;c.$selected_content=m,c.$copy_type=g}return this.instance.capture(s,c),!0}}}isBrowserSupported(){return Wi(Ne==null?void 0:Ne.querySelectorAll)}};Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return ti(e)&&isFinite(e)&&Math.floor(e)===e});var Hy="0123456789abcdef";let oE=class Xg{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,s,n,a){if(!Number.isInteger(t)||!Number.isInteger(s)||!Number.isInteger(n)||!Number.isInteger(a)||t<0||s<0||n<0||a<0||t>0xffffffffffff||s>4095||n>1073741823||a>4294967295)throw new RangeError("invalid field value");var l=new Uint8Array(16);return l[0]=t/Math.pow(2,40),l[1]=t/Math.pow(2,32),l[2]=t/Math.pow(2,24),l[3]=t/Math.pow(2,16),l[4]=t/Math.pow(2,8),l[5]=t,l[6]=112|s>>>8,l[7]=s,l[8]=128|n>>>24,l[9]=n>>>16,l[10]=n>>>8,l[11]=n,l[12]=a>>>24,l[13]=a>>>16,l[14]=a>>>8,l[15]=a,new Xg(l)}toString(){for(var t="",s=0;s<this.bytes.length;s++)t=t+Hy.charAt(this.bytes[s]>>>4)+Hy.charAt(15&this.bytes[s]),s!==3&&s!==5&&s!==7&&s!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new Xg(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(var s=0;s<16;s++){var n=this.bytes[s]-t.bytes[s];if(n!==0)return Math.sign(n)}return 0}},lE=class{constructor(){this.A=0,this.j=0,this.D=new cE}generate(){var t=this.generateOrAbort();if(Ce(t)){this.A=0;var s=this.generateOrAbort();if(Ce(s))throw new Error("Could not generate UUID after timestamp reset");return s}return t}generateOrAbort(){var t=Date.now();if(t>this.A)this.A=t,this.L();else{if(!(t+1e4>this.A))return;this.j++,this.j>4398046511103&&(this.A++,this.L())}return oE.fromFieldsV7(this.A,Math.trunc(this.j/Math.pow(2,30)),this.j&Math.pow(2,30)-1,this.D.nextUint32())}L(){this.j=1024*this.D.nextUint32()+(1023&this.D.nextUint32())}};var Uy,nj=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};he&&!Ce(he.crypto)&&crypto.getRandomValues&&(nj=e=>crypto.getRandomValues(e));let cE=class{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(nj(this.N),this.U=0),this.N[this.U++]}};var Hi=()=>uE().toString(),uE=()=>(Uy||(Uy=new lE)).generate(),Yl="",dE=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function hE(e,t){if(t){var s=(function(a,l){if(l===void 0&&(l=Ne),Yl)return Yl;if(!l||["localhost","127.0.0.1"].includes(a))return"";for(var c=a.split("."),d=Math.min(c.length,8),f="dmn_chk_"+Hi();!Yl&&d--;){var h=c.slice(d).join("."),m=f+"=1;domain=."+h+";path=/";l.cookie=m+";max-age=3",l.cookie.includes(f)&&(l.cookie=m+";max-age=0",Yl=h)}return Yl})(e);if(!s){var n=(a=>{var l=a.match(dE);return l?l[0]:""})(e);n!==s&&Ee.info("Warning: cookie subdomain discovery mismatch",n,s),s=n}return s?"; domain=."+s:""}return""}var gr={H:()=>!!Ne,B:function(e){Ee.error("cookieStore error: "+e)},q:function(e){if(Ne){try{for(var t=e+"=",s=Ne.cookie.split(";").filter((l=>l.length)),n=0;n<s.length;n++){for(var a=s[n];a.charAt(0)==" ";)a=a.substring(1,a.length);if(a.indexOf(t)===0)return decodeURIComponent(a.substring(t.length,a.length))}}catch{}return null}},W:function(e){var t;try{t=JSON.parse(gr.q(e))||{}}catch{}return t},G:function(e,t,s,n,a){if(Ne)try{var l="",c="",d=hE(Ne.location.hostname,n);if(s){var f=new Date;f.setTime(f.getTime()+24*s*60*60*1e3),l="; expires="+f.toUTCString()}a&&(c="; secure");var h=e+"="+encodeURIComponent(JSON.stringify(t))+l+"; SameSite=Lax; path=/"+d+c;return h.length>3686.4&&Ee.warn("cookieStore warning: large cookie, len="+h.length),Ne.cookie=h,h}catch{return}},V:function(e,t){if(Ne!=null&&Ne.cookie)try{gr.G(e,"",-1,t)}catch{return}}},jm=null,qt={H:function(){if(!nr(jm))return jm;var e=!0;if(Ce(he))e=!1;else try{var t="__mplssupport__";qt.G(t,"xyz"),qt.q(t)!=='"xyz"'&&(e=!1),qt.V(t)}catch{e=!1}return e||Ee.error("localStorage unsupported; falling back to cookie store"),jm=e,e},B:function(e){Ee.error("localStorage error: "+e)},q:function(e){try{return he==null?void 0:he.localStorage.getItem(e)}catch(t){qt.B(t)}return null},W:function(e){try{return JSON.parse(qt.q(e))||{}}catch{}return null},G:function(e,t){try{he==null||he.localStorage.setItem(e,JSON.stringify(t))}catch(s){qt.B(s)}},V:function(e){try{he==null||he.localStorage.removeItem(e)}catch(t){qt.B(t)}}},fE=["$device_id","distinct_id",mh,HS,vh,xh],Ad={},pE={H:function(){return!0},B:function(e){Ee.error("memoryStorage error: "+e)},q:function(e){return Ad[e]||null},W:function(e){return Ad[e]||null},G:function(e,t){Ad[e]=t},V:function(e){delete Ad[e]}},ga=null,Ps={H:function(){if(!nr(ga))return ga;if(ga=!0,Ce(he))ga=!1;else try{var e="__support__";Ps.G(e,"xyz"),Ps.q(e)!=='"xyz"'&&(ga=!1),Ps.V(e)}catch{ga=!1}return ga},B:function(e){Ee.error("sessionStorage error: ",e)},q:function(e){try{return he==null?void 0:he.sessionStorage.getItem(e)}catch(t){Ps.B(t)}return null},W:function(e){try{return JSON.parse(Ps.q(e))||null}catch{}return null},G:function(e,t){try{he==null||he.sessionStorage.setItem(e,JSON.stringify(t))}catch(s){Ps.B(s)}},V:function(e){try{he==null||he.sessionStorage.removeItem(e)}catch(t){Ps.B(t)}}},Xr=(function(e){return e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED",e})({});class mE{constructor(t){this._instance=t}get R(){return this._instance.config}get consent(){return this.J()?Xr.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===Xr.DENIED||this.consent===Xr.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Xr.DENIED}optInOut(t){this.Y.G(this.X,t?1:0,this.R.cookie_expiration,this.R.cross_subdomain_cookie,this.R.secure_cookie)}reset(){this.Y.V(this.X,this.R.cross_subdomain_cookie)}get X(){var{token:t,opt_out_capturing_cookie_prefix:s,consent_persistence_name:n}=this._instance.config;return n||(s?s+t:"__ph_opt_in_out_"+t)}get K(){var t=this.Y.q(this.X);return bm(t)?Xr.GRANTED:at(l6,t)?Xr.DENIED:Xr.PENDING}get Y(){if(!this.Z){var t=this.R.opt_out_capturing_persistence_type;this.Z=t==="localStorage"?qt:gr;var s=t==="localStorage"?gr:qt;s.q(this.X)&&(this.Z.q(this.X)||this.optInOut(bm(s.q(this.X))),s.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!$S([An==null?void 0:An.doNotTrack,An==null?void 0:An.msDoNotTrack,He.doNotTrack],(t=>bm(t)))}}var Rd=Gt("[Dead Clicks]"),gE=()=>!0,xE=e=>{var t,s=!((t=e.instance.persistence)==null||!t.get_property(FS)),n=e.instance.config.capture_dead_clicks;return ei(n)?n:!!ys(n)||s};let rj=class{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(t,s,n){this.instance=t,this.isEnabled=s,this.onCapture=n,this.startIfEnabledOrStop()}onRemoteConfig(t){this.instance.persistence&&this.instance.persistence.register({[FS]:t==null?void 0:t.captureDeadClicks}),this.startIfEnabledOrStop()}startIfEnabledOrStop(){this.isEnabled(this)?this.it((()=>{this.et()})):this.stop()}it(t){var s,n;(s=He.__PosthogExtensions__)!=null&&s.initDeadClicksAutocapture&&t(),(n=He.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this.instance,"dead-clicks-autocapture",(a=>{a?Rd.error("failed to load script",a):t()}))}et(){var t;if(Ne){if(!this.tt&&(t=He.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture){var s=ys(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};s.__onCapture=this.onCapture,this.tt=He.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,s),this.tt.start(Ne),Rd.info("starting...")}}else Rd.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,Rd.info("stopping..."))}};var Xl=Gt("[ExceptionAutocapture]");let vE=class{constructor(t){var s,n,a;this.rt=()=>{var l;if(he&&this.isEnabled&&(l=He.__PosthogExtensions__)!=null&&l.errorWrappingFunctions){var c=He.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,d=He.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,f=He.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.R.capture_unhandled_errors&&(this.st=c(this.captureException.bind(this))),!this.nt&&this.R.capture_unhandled_rejections&&(this.nt=d(this.captureException.bind(this))),!this.ot&&this.R.capture_console_errors&&(this.ot=f(this.captureException.bind(this)))}catch(h){Xl.error("failed to start",h),this.ut()}}},this._instance=t,this.ht=!((s=this._instance.persistence)==null||!s.props[Ay]),this.dt=new c6({refillRate:(n=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&n!==void 0?n:1,bucketSize:(a=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&a!==void 0?a:10,refillInterval:1e4,h:Xl}),this.R=this.vt(),this.startIfEnabledOrStop()}vt(){var t=this._instance.config.capture_exceptions,s={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return ys(t)?s=Me({},s,t):(Ce(t)?this.ht:t)&&(s=Me({},s,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),s}get isEnabled(){return this.R.capture_console_errors||this.R.capture_unhandled_errors||this.R.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Xl.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(t){var s,n;(s=He.__PosthogExtensions__)!=null&&s.errorWrappingFunctions&&t(),(n=He.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"exception-autocapture",(a=>{if(a)return Xl.error("failed to load script",a);t()}))}ut(){var t,s,n;(t=this.st)==null||t.call(this),this.st=void 0,(s=this.nt)==null||s.call(this),this.nt=void 0,(n=this.ot)==null||n.call(this),this.ot=void 0}onRemoteConfig(t){var s=t.autocaptureExceptions;this.ht=!!s||!1,this._instance.persistence&&this._instance.persistence.register({[Ay]:this.ht}),this.R=this.vt(),this.startIfEnabledOrStop()}onConfigChange(){this.R=this.vt()}captureException(t){var s,n,a=(s=t==null||(n=t.$exception_list)==null||(n=n[0])==null?void 0:n.type)!==null&&s!==void 0?s:"Exception";this.dt.consumeRateLimit(a)?Xl.info("Skipping exception capture because of client rate limiting.",{exception:a}):this._instance.exceptions.sendExceptionEvent(t)}};function Vy(e,t,s){try{if(!(t in e))return()=>{};var n=e[t],a=s(n);return Wi(a)&&(a.prototype=a.prototype||{},Object.defineProperties(a,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=a,()=>{e[t]=n}}catch{return()=>{}}}let bE=class{constructor(t){var s;this._instance=t,this.ct=(he==null||(s=he.location)==null?void 0:s.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(Ee.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,Ee.info("History API monitoring stopped")}monitorHistoryChanges(){var t,s;if(he&&he.history){var n=this;(t=he.history.pushState)!=null&&t.__posthog_wrapped__||Vy(he.history,"pushState",(a=>function(l,c,d){a.call(this,l,c,d),n._t("pushState")})),(s=he.history.replaceState)!=null&&s.__posthog_wrapped__||Vy(he.history,"replaceState",(a=>function(l,c,d){a.call(this,l,c,d),n._t("replaceState")})),this.bt()}}_t(t){try{var s,n=he==null||(s=he.location)==null?void 0:s.pathname;if(!n)return;n!==this.ct&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:t}),this.ct=n}catch(a){Ee.error("Error capturing "+t+" pageview",a)}}bt(){if(!this.ft){var t=()=>{this._t("popstate")};ps(he,"popstate",t),this.ft=()=>{he&&he.removeEventListener("popstate",t)}}}};var km=Gt("[SegmentIntegration]");function _E(e,t){var s=e.config.segment;if(!s)return t();(function(n,a){var l=n.config.segment;if(!l)return a();var c=f=>{var h=()=>f.anonymousId()||Hi();n.config.get_device_id=h,f.id()&&(n.register({distinct_id:f.id(),$device_id:h()}),n.persistence.set_property(Yr,"identified")),a()},d=l.user();"then"in d&&Wi(d.then)?d.then(c):c(d)})(e,(()=>{s.register((n=>{Promise&&Promise.resolve||km.warn("This browser does not have Promise support, and can not use the segment integration");var a=(l,c)=>{if(!c)return l;l.event.userId||l.event.anonymousId===n.get_distinct_id()||(km.info("No userId set, resetting PostHog"),n.reset()),l.event.userId&&l.event.userId!==n.get_distinct_id()&&(km.info("UserId set, identifying with PostHog"),n.identify(l.event.userId));var d=n.calculateEventProperties(c,l.event.properties);return l.event.properties=Object.assign({},d,l.event.properties),l};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:l=>a(l,l.event.event),page:l=>a(l,"$pageview"),identify:l=>a(l,"$identify"),screen:l=>a(l,"$screen")}})(e)).then((()=>{t()}))}))}var ij="posthog-js";function aj(e,t){var{organization:s,projectId:n,prefix:a,severityAllowList:l=["error"],sendExceptionsToPostHog:c=!0}=t===void 0?{}:t;return d=>{var f,h,m,g,_;if(!(l==="*"||l.includes(d.level))||!e.__loaded)return d;d.tags||(d.tags={});var v=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());d.tags["PostHog Person URL"]=v,e.sessionRecordingStarted()&&(d.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var y=((f=d.exception)==null?void 0:f.values)||[],S=y.map((k=>Me({},k,{stacktrace:k.stacktrace?Me({},k.stacktrace,{type:"raw",frames:(k.stacktrace.frames||[]).map((N=>Me({},N,{platform:"web:javascript"})))}):void 0}))),j={$exception_message:((h=y[0])==null?void 0:h.value)||d.message,$exception_type:(m=y[0])==null?void 0:m.type,$exception_level:d.level,$exception_list:S,$sentry_event_id:d.event_id,$sentry_exception:d.exception,$sentry_exception_message:((g=y[0])==null?void 0:g.value)||d.message,$sentry_exception_type:(_=y[0])==null?void 0:_.type,$sentry_tags:d.tags};return s&&n&&(j.$sentry_url=(a||"https://sentry.io/organizations/")+s+"/issues/?project="+n+"&query="+d.event_id),c&&e.exceptions.sendExceptionEvent(j),d}}let yE=class{constructor(t,s,n,a,l,c){this.name=ij,this.setupOnce=function(d){d(aj(t,{organization:s,projectId:n,prefix:a,severityAllowList:l,sendExceptionsToPostHog:c==null||c}))}}};var wE=he!=null&&he.location?wh(he.location.hash,"__posthog")||wh(location.hash,"state"):null,Wy="_postHogToolbarParams",qy=Gt("[Toolbar]"),$i=(function(e){return e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e})($i||{});let SE=class{constructor(t){this.instance=t}yt(t){He.ph_toolbar_state=t}wt(){var t;return(t=He.ph_toolbar_state)!==null&&t!==void 0?t:$i.UNINITIALIZED}maybeLoadToolbar(t,s,n){if(t===void 0&&(t=void 0),s===void 0&&(s=void 0),n===void 0&&(n=void 0),this.instance.config.name&&this.instance.config.name==="ph_toolbar_internal"||!he||!Ne)return!1;t=t??he.location,n=n??he.history;try{if(!s){try{he.localStorage.setItem("test","test"),he.localStorage.removeItem("test")}catch{return!1}s=he==null?void 0:he.localStorage}var a,l=wE||wh(t.hash,"__posthog")||wh(t.hash,"state"),c=l?My((()=>JSON.parse(atob(decodeURIComponent(l)))))||My((()=>JSON.parse(decodeURIComponent(l)))):null;return c&&c.action==="ph_authorize"?((a=c).source="url",a&&Object.keys(a).length>0&&(c.desiredHash?t.hash=c.desiredHash:n?n.replaceState(n.state,"",t.pathname+t.search):t.hash="")):((a=JSON.parse(s.getItem(Wy)||"{}")).source="localstorage",delete a.userIntent),!(!a.token||this.instance.config.token!==a.token)&&(this.loadToolbar(a),!0)}catch{return!1}}xt(t){var s=He.ph_load_toolbar||He.ph_load_editor;!ut(s)&&Wi(s)?s(t,this.instance):qy.warn("No toolbar load function found")}loadToolbar(t){var s=!(Ne==null||!Ne.getElementById(US));if(!he||s)return!1;var n=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,a=Me({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(he.localStorage.setItem(Wy,JSON.stringify(Me({},a,{source:void 0}))),this.wt()===$i.LOADED)this.xt(a);else if(this.wt()===$i.UNINITIALIZED){var l;this.yt($i.LOADING),(l=He.__PosthogExtensions__)==null||l.loadExternalDependency==null||l.loadExternalDependency(this.instance,"toolbar",(c=>{if(c)return qy.error("[Toolbar] Failed to load",c),void this.yt($i.UNINITIALIZED);this.yt($i.LOADED),this.xt(a)})),ps(he,"turbolinks:load",(()=>{this.yt($i.UNINITIALIZED),this.loadToolbar(a)}))}return!0}Et(t){return this.loadToolbar(t)}maybeLoadEditor(t,s,n){return t===void 0&&(t=void 0),s===void 0&&(s=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(t,s,n)}};var jE=Gt("[TracingHeaders]");class kE{constructor(t){this.$t=void 0,this.St=void 0,this.rt=()=>{var s,n;Ce(this.$t)&&((s=He.__PosthogExtensions__)==null||(s=s.tracingHeadersPatchFns)==null||s._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),Ce(this.St)&&((n=He.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null||n._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=t}it(t){var s,n;(s=He.__PosthogExtensions__)!=null&&s.tracingHeadersPatchFns&&t(),(n=He.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"tracing-headers",(a=>{if(a)return jE.error("failed to load script",a);t()}))}startIfEnabledOrStop(){var t,s;this._instance.config.__add_tracing_headers?this.it(this.rt):((t=this.$t)==null||t.call(this),(s=this.St)==null||s.call(this),this.$t=void 0,this.St=void 0)}}var Dd="https?://(.*)",Jo=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],CE=Xo(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Jo),ru="<masked>",NE=["li_fat_id"];function oj(e,t,s){if(!Ne)return{};var n,a=t?Xo([],Jo,s||[]):[],l=lj(nu(Ne.URL,a,ru),e),c=(n={},Lt(NE,(function(d){var f=gr.q(d);n[d]=f||null})),n);return as(c,l)}function lj(e,t){var s=CE.concat(t||[]),n={};return Lt(s,(function(a){var l=yh(e,a);n[a]=l||null})),n}function cj(e){var t=(function(l){return l?l.search(Dd+"google.([^/?]*)")===0?"google":l.search(Dd+"bing.com")===0?"bing":l.search(Dd+"yahoo.com")===0?"yahoo":l.search(Dd+"duckduckgo.com")===0?"duckduckgo":null:null})(e),s=t!="yahoo"?"q":"p",n={};if(!nr(t)){n.$search_engine=t;var a=Ne?yh(Ne.referrer,s):"";a.length&&(n.ph_keyword=a)}return n}function Gy(){return navigator.language||navigator.userLanguage}function uj(){return(Ne==null?void 0:Ne.referrer)||"$direct"}function dj(e,t){var s=e?Xo([],Jo,t||[]):[],n=$s==null?void 0:$s.href.substring(0,1e3);return{r:uj().substring(0,1e3),u:n?nu(n,s,ru):void 0}}function hj(e){var t,{r:s,u:n}=e,a={$referrer:s,$referring_domain:s==null?void 0:s=="$direct"?"$direct":(t=_h(s))==null?void 0:t.host};if(n){a.$current_url=n;var l=_h(n);a.$host=l==null?void 0:l.host,a.$pathname=l==null?void 0:l.pathname;var c=lj(n);as(a,c)}if(s){var d=cj(s);as(a,d)}return a}function fj(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function EE(){try{return new Date().getTimezoneOffset()}catch{return}}function ME(e,t){if(!mn)return{};var s,n,a,l=e?Xo([],Jo,t||[]):[],[c,d]=(function(f){for(var h=0;h<jy.length;h++){var[m,g]=jy[h],_=m.exec(f),v=_&&(Wi(g)?g(_,f):g);if(v)return v}return["",""]})(mn);return as(_0({$os:c,$os_version:d,$browser:BS(mn,navigator.vendor),$device:ky(mn),$device_type:(n=mn,a=ky(n),a===yS||a===_S||a==="Kobo"||a==="Kindle Fire"||a===LS?Hc:a===Vc||a===Io||a===Wc||a===zg?"Console":a===SS?"Wearable":a?Kn:"Desktop"),$timezone:fj(),$timezone_offset:EE()}),{$current_url:nu($s==null?void 0:$s.href,l,ru),$host:$s==null?void 0:$s.host,$pathname:$s==null?void 0:$s.pathname,$raw_user_agent:mn.length>1e3?mn.substring(0,997)+"...":mn,$browser_version:b6(mn,navigator.vendor),$browser_language:Gy(),$browser_language_prefix:(s=Gy(),typeof s=="string"?s.split("-")[0]:void 0),$screen_height:he==null?void 0:he.screen.height,$screen_width:he==null?void 0:he.screen.width,$viewport_height:he==null?void 0:he.innerHeight,$viewport_width:he==null?void 0:he.innerWidth,$lib:"web",$lib_version:Kr.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var Ri=Gt("[Web Vitals]"),Ky=9e5;let TE=class{constructor(t){var s;this.kt=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Pt=()=>{clearTimeout(this.Tt),this.N.metrics.length!==0&&(this._instance.capture("$web_vitals",this.N.metrics.reduce(((n,a)=>Me({},n,{["$web_vitals_"+a.name+"_event"]:Me({},a),["$web_vitals_"+a.name+"_value"]:a.value})),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.It=n=>{var a,l=(a=this._instance.sessionManager)==null?void 0:a.checkAndGetSessionAndWindowId(!0);if(Ce(l))Ri.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var c=this.Ct();Ce(c)||(ut(n==null?void 0:n.name)||ut(n==null?void 0:n.value)?Ri.error("Invalid metric received",n):this.Rt&&n.value>=this.Rt?Ri.error("Ignoring metric with value >= "+this.Rt,n):(this.N.url!==c&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),Ce(this.N.url)&&(this.N.url=c),this.N.firstMetricTimestamp=Ce(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,n.attribution&&n.attribution.interactionTargetElement&&(n.attribution.interactionTargetElement=void 0),this.N.metrics.push(Me({},n,{$current_url:c,$session_id:l.sessionId,$window_id:l.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.Pt()))}},this.rt=()=>{if(!this.P){var n,a,l,c,d=He.__PosthogExtensions__;Ce(d)||Ce(d.postHogWebVitalsCallbacks)||({onLCP:n,onCLS:a,onFCP:l,onINP:c}=d.postHogWebVitalsCallbacks),n&&a&&l&&c?(this.allowedMetrics.indexOf("LCP")>-1&&n(this.It.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&a(this.It.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&l(this.It.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&c(this.It.bind(this)),this.P=!0):Ri.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.kt=!((s=this._instance.persistence)==null||!s.props[Dy]),this.startIfEnabled()}get allowedMetrics(){var t,s,n=ys(this._instance.config.capture_performance)?(t=this._instance.config.capture_performance)==null?void 0:t.web_vitals_allowed_metrics:void 0;return ut(n)?((s=this._instance.persistence)==null?void 0:s.props[By])||["CLS","FCP","INP","LCP"]:n}get flushToCaptureTimeoutMs(){return(ys(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=ys(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return t!=null&&t}get Rt(){var t=ys(this._instance.config.capture_performance)&&ti(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:Ky;return 0<t&&t<=6e4?Ky:t}get isEnabled(){var t=$s==null?void 0:$s.protocol;if(t!=="http:"&&t!=="https:")return Ri.info("Web Vitals are disabled on non-http/https protocols"),!1;var s=ys(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:ei(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return ei(s)?s:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(Ri.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(t){var s=ys(t.capturePerformance)&&!!t.capturePerformance.web_vitals,n=ys(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Dy]:s}),this._instance.persistence.register({[By]:n})),this.kt=s,this.startIfEnabled()}it(t){var s,n;if((s=He.__PosthogExtensions__)!=null&&s.postHogWebVitalsCallbacks)t();else{var a=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(n=He.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,a,(l=>{l?Ri.error("failed to load script",l):t()}))}}Ct(){var t=he?he.location.href:void 0;if(t){var s=this._instance.config.mask_personal_data_properties,n=this._instance.config.custom_personal_data_properties,a=s?Xo([],Jo,n||[]):[];return nu(t,a,ru)}Ri.error("Could not determine current URL")}};var AE=Gt("[Heatmaps]");function Yy(e){return ys(e)&&"clientX"in e&&"clientY"in e&&ti(e.clientX)&&ti(e.clientY)}let RE=class{constructor(t){var s;this.kt=!1,this.P=!1,this.Ft=null,this.instance=t,this.kt=!((s=this.instance.persistence)==null||!s.props[Ig]),this.rageclicks=new sj(t.config.rageclick)}get flushIntervalMilliseconds(){var t=5e3;return ys(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(t=this.instance.config.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return ut(this.instance.config.capture_heatmaps)?ut(this.instance.config.enable_heatmaps)?this.kt:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.P)return;AE.info("starting..."),this.Ot(),this.Mt()}else{var t;clearInterval((t=this.Ft)!==null&&t!==void 0?t:void 0),this.At(),this.getAndClearBuffer()}}onRemoteConfig(t){var s=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Ig]:s}),this.kt=s,this.startIfEnabled()}getAndClearBuffer(){var t=this.N;return this.N=void 0,t}jt(t){this.Dt(t.originalEvent,"deadclick")}Mt(){this.Ft&&clearInterval(this.Ft),this.Ft=(function(t){return(t==null?void 0:t.visibilityState)==="visible"})(Ne)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Ot(){he&&Ne&&(this.Nt=this.Lt.bind(this),ps(he,"beforeunload",this.Nt),this.Ut=t=>this.Dt(t||(he==null?void 0:he.event)),ps(Ne,"click",this.Ut,{capture:!0}),this.zt=t=>this.Ht(t||(he==null?void 0:he.event)),ps(Ne,"mousemove",this.zt,{capture:!0}),this.Bt=new rj(this.instance,gE,this.jt.bind(this)),this.Bt.startIfEnabledOrStop(),this.qt=this.Mt.bind(this),ps(Ne,"visibilitychange",this.qt),this.P=!0)}At(){var t;he&&Ne&&(this.Nt&&he.removeEventListener("beforeunload",this.Nt),this.Ut&&Ne.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&Ne.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&Ne.removeEventListener("visibilitychange",this.qt),clearTimeout(this.Wt),(t=this.Bt)==null||t.stop(),this.P=!1)}Gt(t,s){var n=this.instance.scrollManager.scrollY(),a=this.instance.scrollManager.scrollX(),l=this.instance.scrollManager.scrollElement(),c=(function(d,f,h){for(var m=d;m&&Fh(m)&&!Gi(m,"body");){if(m===h)return!1;if(at(f,he==null?void 0:he.getComputedStyle(m).position))return!0;m=YS(m)}return!1})(GS(t),["fixed","sticky"],l);return{x:t.clientX+(c?0:a),y:t.clientY+(c?0:n),target_fixed:c,type:s}}Dt(t,s){var n;if(s===void 0&&(s="click"),!Oy(t.target)&&Yy(t)){var a=this.Gt(t,s);(n=this.rageclicks)!=null&&n.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this.Vt(Me({},a,{type:"rageclick"})),this.Vt(a)}}Ht(t){!Oy(t.target)&&Yy(t)&&(clearTimeout(this.Wt),this.Wt=setTimeout((()=>{this.Vt(this.Gt(t,"mousemove"))}),500))}Vt(t){if(he){var s=he.location.href,n=this.instance.config.mask_personal_data_properties,a=this.instance.config.custom_personal_data_properties,l=n?Xo([],Jo,a||[]):[],c=nu(s,l,ru);this.N=this.N||{},this.N[c]||(this.N[c]=[]),this.N[c].push(t)}}Lt(){this.N&&!Lo(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},Xy=class{constructor(t){this.Jt=(s,n,a)=>{a&&(a.noSessionId||a.activityTimeout||a.sessionPastMaximumLength)&&(Ee.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:s,changeReason:a}),this.Kt=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.Yt()}Yt(){var t;this.Xt=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(this.Jt)}destroy(){var t;(t=this.Xt)==null||t.call(this),this.Xt=void 0}doPageView(t,s){var n,a=this.Qt(t,s);return this.Kt={pathname:(n=he==null?void 0:he.location.pathname)!==null&&n!==void 0?n:"",pageViewId:s,timestamp:t},this._instance.scrollManager.resetContext(),a}doPageLeave(t){var s;return this.Qt(t,(s=this.Kt)==null?void 0:s.pageViewId)}doEvent(){var t;return{$pageview_id:(t=this.Kt)==null?void 0:t.pageViewId}}Qt(t,s){var n=this.Kt;if(!n)return{$pageview_id:s};var a={$pageview_id:s,$prev_pageview_id:n.pageViewId},l=this._instance.scrollManager.getContext();if(l&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:c,lastScrollY:d,maxScrollY:f,maxContentHeight:h,lastContentY:m,maxContentY:g}=l;if(!(Ce(c)||Ce(d)||Ce(f)||Ce(h)||Ce(m)||Ce(g))){c=Math.ceil(c),d=Math.ceil(d),f=Math.ceil(f),h=Math.ceil(h),m=Math.ceil(m),g=Math.ceil(g);var _=c<=1?1:vr(d/c,0,1,Ee),v=c<=1?1:vr(f/c,0,1,Ee),y=h<=1?1:vr(m/h,0,1,Ee),S=h<=1?1:vr(g/h,0,1,Ee);a=as(a,{$prev_pageview_last_scroll:d,$prev_pageview_last_scroll_percentage:_,$prev_pageview_max_scroll:f,$prev_pageview_max_scroll_percentage:v,$prev_pageview_last_content:m,$prev_pageview_last_content_percentage:y,$prev_pageview_max_content:g,$prev_pageview_max_content_percentage:S})}}return n.pathname&&(a.$prev_pageview_pathname=n.pathname),n.timestamp&&(a.$prev_pageview_duration=(t.getTime()-n.timestamp.getTime())/1e3),a}};var Jr=(function(e){return e.GZipJS="gzip-js",e.Base64="base64",e})({}),Yn=Uint8Array,gn=Uint16Array,Wo=Uint32Array,j0=new Yn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),k0=new Yn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Jy=new Yn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pj=function(e,t){for(var s=new gn(31),n=0;n<31;++n)s[n]=t+=1<<e[n-1];var a=new Wo(s[30]);for(n=1;n<30;++n)for(var l=s[n];l<s[n+1];++l)a[l]=l-s[n]<<5|n;return[s,a]},mj=pj(j0,2),DE=mj[0],Jg=mj[1];DE[28]=258,Jg[258]=28;for(var Qy=pj(k0,0)[1],gj=new gn(32768),It=0;It<32768;++It){var xa=(43690&It)>>>1|(21845&It)<<1;xa=(61680&(xa=(52428&xa)>>>2|(13107&xa)<<2))>>>4|(3855&xa)<<4,gj[It]=((65280&xa)>>>8|(255&xa)<<8)>>>1}var Bc=function(e,t,s){for(var n=e.length,a=0,l=new gn(t);a<n;++a)++l[e[a]-1];var c,d=new gn(t);for(a=0;a<t;++a)d[a]=d[a-1]+l[a-1]<<1;for(c=new gn(n),a=0;a<n;++a)c[a]=gj[d[e[a]-1]++]>>>15-e[a];return c},Ea=new Yn(288);for(It=0;It<144;++It)Ea[It]=8;for(It=144;It<256;++It)Ea[It]=9;for(It=256;It<280;++It)Ea[It]=7;for(It=280;It<288;++It)Ea[It]=8;var Sh=new Yn(32);for(It=0;It<32;++It)Sh[It]=5;var LE=Bc(Ea,9),BE=Bc(Sh,5),xj=function(e){return(e/8>>0)+(7&e&&1)},vj=function(e,t,s){(s==null||s>e.length)&&(s=e.length);var n=new(e instanceof gn?gn:e instanceof Wo?Wo:Yn)(s-t);return n.set(e.subarray(t,s)),n},Wr=function(e,t,s){s<<=7&t;var n=t/8>>0;e[n]|=s,e[n+1]|=s>>>8},Jl=function(e,t,s){s<<=7&t;var n=t/8>>0;e[n]|=s,e[n+1]|=s>>>8,e[n+2]|=s>>>16},Cm=function(e,t){for(var s=[],n=0;n<e.length;++n)e[n]&&s.push({s:n,f:e[n]});var a=s.length,l=s.slice();if(!a)return[new Yn(0),0];if(a==1){var c=new Yn(s[0].s+1);return c[s[0].s]=1,[c,1]}s.sort((function(F,$){return F.f-$.f})),s.push({s:-1,f:25001});var d=s[0],f=s[1],h=0,m=1,g=2;for(s[0]={s:-1,f:d.f+f.f,l:d,r:f};m!=a-1;)d=s[s[h].f<s[g].f?h++:g++],f=s[h!=m&&s[h].f<s[g].f?h++:g++],s[m++]={s:-1,f:d.f+f.f,l:d,r:f};var _=l[0].s;for(n=1;n<a;++n)l[n].s>_&&(_=l[n].s);var v=new gn(_+1),y=Qg(s[m-1],v,0);if(y>t){n=0;var S=0,j=y-t,k=1<<j;for(l.sort((function(F,$){return v[$.s]-v[F.s]||F.f-$.f}));n<a;++n){var N=l[n].s;if(!(v[N]>t))break;S+=k-(1<<y-v[N]),v[N]=t}for(S>>>=j;S>0;){var E=l[n].s;v[E]<t?S-=1<<t-v[E]++-1:++n}for(;n>=0&&S;--n){var B=l[n].s;v[B]==t&&(--v[B],++S)}y=t}return[new Yn(v),y]},Qg=function(e,t,s){return e.s==-1?Math.max(Qg(e.l,t,s+1),Qg(e.r,t,s+1)):t[e.s]=s},Zy=function(e){for(var t=e.length;t&&!e[--t];);for(var s=new gn(++t),n=0,a=e[0],l=1,c=function(f){s[n++]=f},d=1;d<=t;++d)if(e[d]==a&&d!=t)++l;else{if(!a&&l>2){for(;l>138;l-=138)c(32754);l>2&&(c(l>10?l-11<<5|28690:l-3<<5|12305),l=0)}else if(l>3){for(c(a),--l;l>6;l-=6)c(8304);l>2&&(c(l-3<<5|8208),l=0)}for(;l--;)c(a);l=1,a=e[d]}return[s.subarray(0,n),t]},Ql=function(e,t){for(var s=0,n=0;n<t.length;++n)s+=e[n]*t[n];return s},Zg=function(e,t,s){var n=s.length,a=xj(t+2);e[a]=255&n,e[a+1]=n>>>8,e[a+2]=255^e[a],e[a+3]=255^e[a+1];for(var l=0;l<n;++l)e[a+l+4]=s[l];return 8*(a+4+n)},ew=function(e,t,s,n,a,l,c,d,f,h,m){Wr(t,m++,s),++a[256];for(var g=Cm(a,15),_=g[0],v=g[1],y=Cm(l,15),S=y[0],j=y[1],k=Zy(_),N=k[0],E=k[1],B=Zy(S),F=B[0],$=B[1],K=new gn(19),Y=0;Y<N.length;++Y)K[31&N[Y]]++;for(Y=0;Y<F.length;++Y)K[31&F[Y]]++;for(var W=Cm(K,7),L=W[0],Q=W[1],V=19;V>4&&!L[Jy[V-1]];--V);var X,q,A,M,O=h+5<<3,U=Ql(a,Ea)+Ql(l,Sh)+c,I=Ql(a,_)+Ql(l,S)+c+14+3*V+Ql(K,L)+(2*K[16]+3*K[17]+7*K[18]);if(O<=U&&O<=I)return Zg(t,m,e.subarray(f,f+h));if(Wr(t,m,1+(I<U)),m+=2,I<U){X=Bc(_,v),q=_,A=Bc(S,j),M=S;var R=Bc(L,Q);for(Wr(t,m,E-257),Wr(t,m+5,$-1),Wr(t,m+10,V-4),m+=14,Y=0;Y<V;++Y)Wr(t,m+3*Y,L[Jy[Y]]);m+=3*V;for(var P=[N,F],z=0;z<2;++z){var T=P[z];for(Y=0;Y<T.length;++Y){var oe=31&T[Y];Wr(t,m,R[oe]),m+=L[oe],oe>15&&(Wr(t,m,T[Y]>>>5&127),m+=T[Y]>>>12)}}}else X=LE,q=Ea,A=BE,M=Sh;for(Y=0;Y<d;++Y)if(n[Y]>255){oe=n[Y]>>>18&31,Jl(t,m,X[oe+257]),m+=q[oe+257],oe>7&&(Wr(t,m,n[Y]>>>23&31),m+=j0[oe]);var be=31&n[Y];Jl(t,m,A[be]),m+=M[be],be>3&&(Jl(t,m,n[Y]>>>5&8191),m+=k0[be])}else Jl(t,m,X[n[Y]]),m+=q[n[Y]];return Jl(t,m,X[256]),m+q[256]},OE=new Wo([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),zE=(function(){for(var e=new Wo(256),t=0;t<256;++t){for(var s=t,n=9;--n;)s=(1&s&&3988292384)^s>>>1;e[t]=s}return e})(),PE=function(e,t,s,n,a){return(function(l,c,d,f,h,m){var g=l.length,_=new Yn(f+g+5*(1+Math.floor(g/7e3))+h),v=_.subarray(f,_.length-h),y=0;if(!c||g<8)for(var S=0;S<=g;S+=65535){var j=S+65535;j<g?y=Zg(v,y,l.subarray(S,j)):(v[S]=m,y=Zg(v,y,l.subarray(S,g)))}else{for(var k=OE[c-1],N=k>>>13,E=8191&k,B=(1<<d)-1,F=new gn(32768),$=new gn(B+1),K=Math.ceil(d/3),Y=2*K,W=function(mt){return(l[mt]^l[mt+1]<<K^l[mt+2]<<Y)&B},L=new Wo(25e3),Q=new gn(288),V=new gn(32),X=0,q=0,A=(S=0,0),M=0,O=0;S<g;++S){var U=W(S),I=32767&S,R=$[U];if(F[I]=R,$[U]=I,M<=S){var P=g-S;if((X>7e3||A>24576)&&P>423){y=ew(l,v,0,L,Q,V,q,A,O,S-O,y),A=X=q=0,O=S;for(var z=0;z<286;++z)Q[z]=0;for(z=0;z<30;++z)V[z]=0}var T=2,oe=0,be=E,re=I-R&32767;if(P>2&&U==W(S-re))for(var ve=Math.min(N,P)-1,Te=Math.min(32767,S),Re=Math.min(258,P);re<=Te&&--be&&I!=R;){if(l[S+T]==l[S+T-re]){for(var je=0;je<Re&&l[S+je]==l[S+je-re];++je);if(je>T){if(T=je,oe=re,je>ve)break;var Ye=Math.min(re,je-2),Xe=0;for(z=0;z<Ye;++z){var Pe=S-re+z+32768&32767,ye=Pe-F[Pe]+32768&32767;ye>Xe&&(Xe=ye,R=Pe)}}}re+=(I=R)-(R=F[I])+32768&32767}if(oe){L[A++]=268435456|Jg[T]<<18|Qy[oe];var Ze=31&Jg[T],ft=31&Qy[oe];q+=j0[Ze]+k0[ft],++Q[257+Ze],++V[ft],M=S+T,++X}else L[A++]=l[S],++Q[l[S]]}}y=ew(l,v,m,L,Q,V,q,A,O,S-O,y)}return vj(_,0,f+xj(y)+h)})(e,t.level==null?6:t.level,t.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,s,n,!0)},Nm=function(e,t,s){for(;s;++t)e[t]=s,s>>>=8};function $E(e,t){t===void 0&&(t={});var s=(function(){var d=4294967295;return{p:function(f){for(var h=d,m=0;m<f.length;++m)h=zE[255&h^f[m]]^h>>>8;d=h},d:function(){return 4294967295^d}}})(),n=e.length;s.p(e);var a,l=PE(e,t,10+((a=t).filename&&a.filename.length+1||0),8),c=l.length;return(function(d,f){var h=f.filename;if(d[0]=31,d[1]=139,d[2]=8,d[8]=f.level<2?4:f.level==9?2:0,d[9]=3,f.mtime!=0&&Nm(d,4,Math.floor(new Date(f.mtime||Date.now())/1e3)),h){d[3]=8;for(var m=0;m<=h.length;++m)d[m+10]=h.charCodeAt(m)}})(l,t),Nm(l,c-8,s.d()),Nm(l,c-4,n),l}var IE=function(e){var t,s,n,a,l="";for(t=s=0,n=(e=(e+"").replace(/\r\n/g,`
52
+ `).replace(/\r/g,`
53
+ `)).length,a=0;a<n;a++){var c=e.charCodeAt(a),d=null;c<128?s++:d=c>127&&c<2048?String.fromCharCode(c>>6|192,63&c|128):String.fromCharCode(c>>12|224,c>>6&63|128,63&c|128),nr(d)||(s>t&&(l+=e.substring(t,s)),l+=d,t=s=a+1)}return s>t&&(l+=e.substring(t,e.length)),l},FE=!!Rg||!!Ag,tw="text/plain",jh=function(e,t,s){var n;s===void 0&&(s=!0);var[a,l]=e.split("?"),c=Me({},t),d=(n=l==null?void 0:l.split("&").map((h=>{var m,[g,_]=h.split("="),v=s&&(m=c[g])!==null&&m!==void 0?m:_;return delete c[g],g+"="+v})))!==null&&n!==void 0?n:[],f=sE(c);return f&&d.push(f),a+"?"+d.join("&")},wc=(e,t)=>JSON.stringify(e,((s,n)=>typeof n=="bigint"?n.toString():n),t),Em=e=>{var{data:t,compression:s}=e;if(t){if(s===Jr.GZipJS){var n=$E((function(f,h){var m=f.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(f);for(var g=new Yn(f.length+(f.length>>>1)),_=0,v=function(k){g[_++]=k},y=0;y<m;++y){if(_+5>g.length){var S=new Yn(_+8+(m-y<<1));S.set(g),g=S}var j=f.charCodeAt(y);j<128||h?v(j):j<2048?(v(192|j>>>6),v(128|63&j)):j>55295&&j<57344?(v(240|(j=65536+(1047552&j)|1023&f.charCodeAt(++y))>>>18),v(128|j>>>12&63),v(128|j>>>6&63),v(128|63&j)):(v(224|j>>>12),v(128|j>>>6&63),v(128|63&j))}return vj(g,0,_)})(wc(t)),{mtime:0}),a=new Blob([n],{type:tw});return{contentType:tw,body:a,estimatedSize:a.size}}if(s===Jr.Base64){var l=(function(f){var h,m,g,_,v,y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",S=0,j=0,k="",N=[];if(!f)return f;f=IE(f);do h=(v=f.charCodeAt(S++)<<16|f.charCodeAt(S++)<<8|f.charCodeAt(S++))>>18&63,m=v>>12&63,g=v>>6&63,_=63&v,N[j++]=y.charAt(h)+y.charAt(m)+y.charAt(g)+y.charAt(_);while(S<f.length);switch(k=N.join(""),f.length%3){case 1:k=k.slice(0,-2)+"==";break;case 2:k=k.slice(0,-1)+"="}return k})(wc(t)),c=(f=>"data="+encodeURIComponent(typeof f=="string"?f:wc(f)))(l);return{contentType:"application/x-www-form-urlencoded",body:c,estimatedSize:new Blob([c]).size}}var d=wc(t);return{contentType:"application/json",body:d,estimatedSize:new Blob([d]).size}}},eh=[];Ag&&eh.push({transport:"fetch",method:e=>{var t,s,{contentType:n,body:a,estimatedSize:l}=(t=Em(e))!==null&&t!==void 0?t:{},c=new Headers;Lt(e.headers,(function(m,g){c.append(g,m)})),n&&c.append("Content-Type",n);var d=e.url,f=null;if(by){var h=new by;f={signal:h.signal,timeout:setTimeout((()=>h.abort()),e.timeout)}}Ag(d,Me({method:(e==null?void 0:e.method)||"GET",headers:c,keepalive:e.method==="POST"&&(l||0)<52428.8,body:a,signal:(s=f)==null?void 0:s.signal},e.fetchOptions)).then((m=>m.text().then((g=>{var _={statusCode:m.status,text:g};if(m.status===200)try{_.json=JSON.parse(g)}catch(v){Ee.error(v)}e.callback==null||e.callback(_)})))).catch((m=>{Ee.error(m),e.callback==null||e.callback({statusCode:0,error:m})})).finally((()=>f?clearTimeout(f.timeout):null))}}),Rg&&eh.push({transport:"XHR",method:e=>{var t,s=new Rg;s.open(e.method||"GET",e.url,!0);var{contentType:n,body:a}=(t=Em(e))!==null&&t!==void 0?t:{};Lt(e.headers,(function(l,c){s.setRequestHeader(c,l)})),n&&s.setRequestHeader("Content-Type",n),e.timeout&&(s.timeout=e.timeout),e.disableXHRCredentials||(s.withCredentials=!0),s.onreadystatechange=()=>{if(s.readyState===4){var l={statusCode:s.status,text:s.responseText};if(s.status===200)try{l.json=JSON.parse(s.responseText)}catch{}e.callback==null||e.callback(l)}},s.send(a)}}),An!=null&&An.sendBeacon&&eh.push({transport:"sendBeacon",method:e=>{var t=jh(e.url,{beacon:"1"});try{var s,{contentType:n,body:a}=(s=Em(e))!==null&&s!==void 0?s:{},l=typeof a=="string"?new Blob([a],{type:n}):a;An.sendBeacon(t,l)}catch{}}});var kh=function(e,t){if(!(function(s){try{new RegExp(s)}catch{return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}};function sw(e,t,s){return wc({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:s})}var bj={exact:(e,t)=>t.some((s=>e.some((n=>s===n)))),is_not:(e,t)=>t.every((s=>e.every((n=>s!==n)))),regex:(e,t)=>t.some((s=>e.some((n=>kh(s,n))))),not_regex:(e,t)=>t.every((s=>e.every((n=>!kh(s,n))))),icontains:(e,t)=>t.map(Ld).some((s=>e.map(Ld).some((n=>s.includes(n))))),not_icontains:(e,t)=>t.map(Ld).every((s=>e.map(Ld).every((n=>!s.includes(n))))),gt:(e,t)=>t.some((s=>{var n=parseFloat(s);return!isNaN(n)&&e.some((a=>n>parseFloat(a)))})),lt:(e,t)=>t.some((s=>{var n=parseFloat(s);return!isNaN(n)&&e.some((a=>n<parseFloat(a)))}))},Ld=e=>e.toLowerCase();function _j(e,t){return!e||Object.entries(e).every((s=>{var[n,a]=s,l=t==null?void 0:t[n];if(Ce(l)||nr(l))return!1;var c=[String(l)],d=bj[a.operator];return!!d&&d(a.values,c)}))}var Mm=Gt("[Error tracking]");let HE=class{constructor(t){var s,n;this.Zt=[],this.ti=new w6([new A6,new I6,new D6,new R6,new P6,new z6,new B6,new $6],T6()),this._instance=t,this.Zt=(s=(n=this._instance.persistence)==null?void 0:n.get_property(Fg))!==null&&s!==void 0?s:[]}onRemoteConfig(t){var s,n,a,l=(s=(n=t.errorTracking)==null?void 0:n.suppressionRules)!==null&&s!==void 0?s:[],c=(a=t.errorTracking)==null?void 0:a.captureExtensionExceptions;this.Zt=l,this._instance.persistence&&this._instance.persistence.register({[Fg]:this.Zt,[Ry]:c})}get ii(){var t,s=!!this._instance.get_property(Ry),n=this._instance.config.error_tracking.captureExtensionExceptions;return(t=n??s)!==null&&t!==void 0&&t}buildProperties(t,s){return this.ti.buildFromUnknown(t,{syntheticException:s==null?void 0:s.syntheticException,mechanism:{handled:s==null?void 0:s.handled}})}sendExceptionEvent(t){var s=t.$exception_list;if(this.ei(s)){if(this.ri(s))return void Mm.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(s))return void Mm.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(s))return void Mm.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent"})}ri(t){if(t.length===0)return!1;var s=t.reduce(((n,a)=>{var{type:l,value:c}=a;return ws(l)&&l.length>0&&n.$exception_types.push(l),ws(c)&&c.length>0&&n.$exception_values.push(c),n}),{$exception_types:[],$exception_values:[]});return this.Zt.some((n=>{var a=n.values.map((l=>{var c,d=bj[l.operator],f=yt(l.value)?l.value:[l.value],h=(c=s[l.key])!==null&&c!==void 0?c:[];return f.length>0&&d(f,h)}));return n.type==="OR"?a.some(Boolean):a.every(Boolean)}))}si(t){return t.flatMap((s=>{var n,a;return(n=(a=s.stacktrace)==null?void 0:a.frames)!==null&&n!==void 0?n:[]})).some((s=>s.filename&&s.filename.startsWith("chrome-extension://")))}ni(t){if(t.length>0){var s,n,a,l,c=(s=(n=t[0].stacktrace)==null?void 0:n.frames)!==null&&s!==void 0?s:[],d=c[c.length-1];return(a=d==null||(l=d.filename)==null?void 0:l.includes("posthog.com/static"))!==null&&a!==void 0&&a}return!1}ei(t){return!ut(t)&&yt(t)}};var En=Gt("[FeatureFlags]"),Zl=Gt("[FeatureFlags]",{debugEnabled:!0}),UE="errors_while_computing_flags",VE="flag_missing",WE="quota_limited",qE="timeout",GE="connection_error",KE="unknown_error",YE=e=>"api_error_"+e,Tm="$active_feature_flags",wo="$override_feature_flags",nw="$feature_flag_payloads",ec="$override_feature_flag_payloads",rw="$feature_flag_request_id",iw="$feature_flag_evaluated_at",aw=e=>{var t={};for(var[s,n]of Zd(e||{}))n&&(t[s]=n);return t},XE=e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((s=>{var n;return[s,(n=t[s].variant)!==null&&n!==void 0?n:t[s].enabled]}))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((s=>t[s].enabled)).filter((s=>{var n;return(n=t[s].metadata)==null?void 0:n.payload})).map((s=>{var n;return[s,(n=t[s].metadata)==null?void 0:n.payload]})))):En.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e},JE=(function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e})({});class QE{constructor(t){this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.ci=!1,this._instance=t,this.featureFlagEventHandlers=[]}fi(){var t,s=(t=this._instance.config.evaluation_contexts)!==null&&t!==void 0?t:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(En.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),s!=null&&s.length?s.filter((n=>{var a=n&&typeof n=="string"&&n.trim().length>0;return a||En.error("Invalid evaluation context found:",n,"Expected non-empty string"),a})):[]}pi(){return this.fi().length>0}flags(){if(this._instance.config.__preview_remote_config)this.di=!0;else{var t=!this.gi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.mi({disableFlags:t})}}get hasLoadedFlags(){return this.ai}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this._instance.get_property(Hg),s=this._instance.get_property(wo),n=this._instance.get_property(ec);if(!n&&!s)return t||{};var a=as({},t||{}),l=[...new Set([...Object.keys(n||{}),...Object.keys(s||{})])];for(var c of l){var d,f,h=a[c],m=s==null?void 0:s[c],g=Ce(m)?(d=h==null?void 0:h.enabled)!==null&&d!==void 0&&d:!!m,_=Ce(m)?h.variant:typeof m=="string"?m:void 0,v=n==null?void 0:n[c],y=Me({},h,{enabled:g,variant:g?_??(h==null?void 0:h.variant):void 0});g!==(h==null?void 0:h.enabled)&&(y.original_enabled=h==null?void 0:h.enabled),_!==(h==null?void 0:h.variant)&&(y.original_variant=h==null?void 0:h.variant),v&&(y.metadata=Me({},h==null?void 0:h.metadata,{payload:v,original_payload:h==null||(f=h.metadata)==null?void 0:f.payload})),a[c]=y}return this.oi||(En.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:n,finalDetails:a}),this.oi=!0),a}getFlagVariants(){var t=this._instance.get_property(Bo),s=this._instance.get_property(wo);if(!s)return t||{};for(var n=as({},t),a=Object.keys(s),l=0;l<a.length;l++)n[a[l]]=s[a[l]];return this.oi||(En.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:s,finalFlags:n}),this.oi=!0),n}getFlagPayloads(){var t=this._instance.get_property(nw),s=this._instance.get_property(ec);if(!s)return t||{};for(var n=as({},t||{}),a=Object.keys(s),l=0;l<a.length;l++)n[a[l]]=s[a[l]];return this.oi||(En.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:s,finalPayloads:n}),this.oi=!0),n}reloadFeatureFlags(){this.ui||this._instance.config.advanced_disable_feature_flags||this.gi||(this._instance.bi.emit("featureFlagsReloading",!0),this.gi=setTimeout((()=>{this.mi()}),5))}yi(){clearTimeout(this.gi),this.gi=void 0}ensureFlagsLoaded(){this.ai||this.li||this.gi||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.ui=t}mi(t){var s;if(this.yi(),!this._instance.M())if(this.li)this.hi=!0;else{var n=this._instance.config.token,a=this._instance.get_property("$device_id"),l={token:n,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:Me({},((s=this._instance.persistence)==null?void 0:s.get_initial_props())||{},this._instance.get_property(yc)||{}),group_properties:this._instance.get_property(ya)};nr(a)||Ce(a)||(l.$device_id=a),(t!=null&&t.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(l.disable_flags=!0),this.pi()&&(l.evaluation_contexts=this.fi());var c=this._instance.config.__preview_remote_config,d=c?"/flags/?v=2":"/flags/?v=2&config=true",f=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",h=this._instance.requestRouter.endpointFor("flags",d+f);c&&(l.timezone=fj()),this.li=!0,this._instance._send_request({method:"POST",url:h,data:l,compression:this._instance.config.disable_compression?void 0:Jr.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:m=>{var g,_,v,y,S=!0;if(m.statusCode===200&&(this.hi||(this.$anon_distinct_id=void 0),S=!1),this.li=!1,this.di||(this.di=!0,this._instance.wi((y=m.json)!==null&&y!==void 0?y:{})),!l.disable_flags||this.hi){this.vi=!S;var j=[];m.error?m.error instanceof Error?j.push(m.error.name==="AbortError"?qE:GE):j.push(KE):m.statusCode!==200&&j.push(YE(m.statusCode)),(g=m.json)!=null&&g.errorsWhileComputingFlags&&j.push(UE);var k=!((_=m.json)==null||(_=_.quotaLimited)==null||!_.includes(JE.FeatureFlags));if(k&&j.push(WE),(v=this._instance.persistence)==null||v.register({[Vg]:j}),k)En.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var N;l.disable_flags||this.receivedFeatureFlags((N=m.json)!==null&&N!==void 0?N:{},S),this.hi&&(this.hi=!1,this.mi())}}}})}}getFeatureFlag(t,s){var n;if(s===void 0&&(s={}),this.ai||this.getFlags()&&this.getFlags().length>0){var a=this.getFeatureFlagResult(t,s);return(n=a==null?void 0:a.variant)!==null&&n!==void 0?n:a==null?void 0:a.enabled}En.warn('getFeatureFlag for key "'+t+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var s=this.getFeatureFlagResult(t,{send_event:!1});return s==null?void 0:s.payload}getFeatureFlagResult(t,s){if(s===void 0&&(s={}),this.ai||this.getFlags()&&this.getFlags().length>0){var n=this.getFlagVariants(),a=t in n,l=n[t],c=this.getFlagPayloads()[t],d=String(l),f=this._instance.get_property(rw)||void 0,h=this._instance.get_property(iw)||void 0,m=this._instance.get_property(gh)||{};if((s.send_event||!("send_event"in s))&&(!(t in m)||!m[t].includes(d))){var g,_,v,y,S,j,k,N,E,B;yt(m[t])?m[t].push(d):m[t]=[d],(g=this._instance.persistence)==null||g.register({[gh]:m});var F=this.getFeatureFlagDetails(t),$=[...(_=this._instance.get_property(Vg))!==null&&_!==void 0?_:[]];Ce(l)&&$.push(VE);var K={$feature_flag:t,$feature_flag_response:l,$feature_flag_payload:c||null,$feature_flag_request_id:f,$feature_flag_evaluated_at:h,$feature_flag_bootstrapped_response:((v=this._instance.config.bootstrap)==null||(v=v.featureFlags)==null?void 0:v[t])||null,$feature_flag_bootstrapped_payload:((y=this._instance.config.bootstrap)==null||(y=y.featureFlagPayloads)==null?void 0:y[t])||null,$used_bootstrap_value:!this.vi};Ce(F==null||(S=F.metadata)==null?void 0:S.version)||(K.$feature_flag_version=F.metadata.version);var Y,W=(j=F==null||(k=F.reason)==null?void 0:k.description)!==null&&j!==void 0?j:F==null||(N=F.reason)==null?void 0:N.code;W&&(K.$feature_flag_reason=W),F!=null&&(E=F.metadata)!=null&&E.id&&(K.$feature_flag_id=F.metadata.id),Ce(F==null?void 0:F.original_variant)&&Ce(F==null?void 0:F.original_enabled)||(K.$feature_flag_original_response=Ce(F.original_variant)?F.original_enabled:F.original_variant),F!=null&&(B=F.metadata)!=null&&B.original_payload&&(K.$feature_flag_original_payload=F==null||(Y=F.metadata)==null?void 0:Y.original_payload),$.length&&(K.$feature_flag_error=$.join(",")),this._instance.capture("$feature_flag_called",K)}if(a){var L=c;if(!Ce(c))try{L=JSON.parse(c)}catch{}return{key:t,enabled:!!l,variant:typeof l=="string"?l:void 0,payload:L}}}else En.warn('getFeatureFlagResult for key "'+t+`" failed. Feature flags didn't load in time.`)}getRemoteConfigPayload(t,s){var n=this._instance.config.token,a={distinct_id:this._instance.get_distinct_id(),token:n};this.pi()&&(a.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:a,compression:this._instance.config.disable_compression?void 0:Jr.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:l=>{var c,d=(c=l.json)==null?void 0:c.featureFlagPayloads;s((d==null?void 0:d[t])||void 0)}})}isFeatureEnabled(t,s){if(s===void 0&&(s={}),this.ai||this.getFlags()&&this.getFlags().length>0){var n=this.getFeatureFlag(t,s);return Ce(n)?void 0:!!n}En.warn('isFeatureEnabled for key "'+t+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((s=>s!==t))}receivedFeatureFlags(t,s){if(this._instance.persistence){this.ai=!0;var n=this.getFlagVariants(),a=this.getFlagPayloads(),l=this.getFlagsWithDetails();(function(c,d,f,h,m){f===void 0&&(f={}),h===void 0&&(h={}),m===void 0&&(m={});var g=XE(c),_=g.flags,v=g.featureFlags,y=g.featureFlagPayloads;if(v){var S=c.requestId,j=c.evaluatedAt;if(yt(v)){En.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var k={};if(v)for(var N=0;N<v.length;N++)k[v[N]]=!0;d&&d.register({[Tm]:v,[Bo]:k})}else{var E=v,B=y,F=_;if(c.errorsWhileComputingFlags)if(_){var $=new Set(Object.keys(_).filter((K=>{var Y;return!((Y=_[K])!=null&&Y.failed)})));E=Me({},f,Object.fromEntries(Object.entries(E).filter((K=>{var[Y]=K;return $.has(Y)})))),B=Me({},h,Object.fromEntries(Object.entries(B||{}).filter((K=>{var[Y]=K;return $.has(Y)})))),F=Me({},m,Object.fromEntries(Object.entries(F||{}).filter((K=>{var[Y]=K;return $.has(Y)}))))}else E=Me({},f,E),B=Me({},h,B),F=Me({},m,F);d&&d.register(Me({[Tm]:Object.keys(aw(E)),[Bo]:E||{},[nw]:B||{},[Hg]:F||{}},S?{[rw]:S}:{},j?{[iw]:j}:{}))}}})(t,this._instance.persistence,n,a,l),this.xi(s)}}override(t,s){s===void 0&&(s=!1),En.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:s})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this._instance.persistence)return En.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this._instance.persistence.unregister(wo),this._instance.persistence.unregister(ec),this.xi(),Zl.info("All overrides cleared");if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var s,n=t;if(this.oi=!!((s=n.suppressWarning)!==null&&s!==void 0&&s),"flags"in n){if(n.flags===!1)this._instance.persistence.unregister(wo),Zl.info("Flag overrides cleared");else if(n.flags){if(yt(n.flags)){for(var a={},l=0;l<n.flags.length;l++)a[n.flags[l]]=!0;this._instance.persistence.register({[wo]:a})}else this._instance.persistence.register({[wo]:n.flags});Zl.info("Flag overrides set",{flags:n.flags})}}return"payloads"in n&&(n.payloads===!1?(this._instance.persistence.unregister(ec),Zl.info("Payload overrides cleared")):n.payloads&&(this._instance.persistence.register({[ec]:n.payloads}),Zl.info("Payload overrides set",{payloads:n.payloads}))),void this.xi()}this.xi()}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.ai){var{flags:s,flagVariants:n}=this.Ei();t(s,n)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,s,n){var a,l=(this._instance.get_property(_c)||[]).find((h=>h.flagKey===t)),c={["$feature_enrollment/"+t]:s},d={$feature_flag:t,$feature_enrollment:s,$set:c};l&&(d.$early_access_feature_name=l.name),n&&(d.$feature_enrollment_stage=n),this._instance.capture("$feature_enrollment_update",d),this.setPersonPropertiesForFlags(c,!1);var f=Me({},this.getFlagVariants(),{[t]:s});(a=this._instance.persistence)==null||a.register({[Tm]:Object.keys(aw(f)),[Bo]:f}),this.xi()}getEarlyAccessFeatures(t,s,n){s===void 0&&(s=!1);var a=this._instance.get_property(_c),l=n?"&"+n.map((c=>"stage="+c)).join("&"):"";if(a&&!s)return t(a);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+l),method:"GET",callback:c=>{var d,f;if(c.json){var h=c.json.earlyAccessFeatures;return(d=this._instance.persistence)==null||d.unregister(_c),(f=this._instance.persistence)==null||f.register({[_c]:h}),t(h)}}})}Ei(){var t=this.getFlags(),s=this.getFlagVariants();return{flags:t.filter((n=>s[n])),flagVariants:Object.keys(s).filter((n=>s[n])).reduce(((n,a)=>(n[a]=s[a],n)),{})}}xi(t){var{flags:s,flagVariants:n}=this.Ei();this.featureFlagEventHandlers.forEach((a=>a(s,n,{errorsLoading:t})))}setPersonPropertiesForFlags(t,s){s===void 0&&(s=!0);var n=this._instance.get_property(yc)||{};this._instance.register({[yc]:Me({},n,t)}),s&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(yc)}setGroupPropertiesForFlags(t,s){s===void 0&&(s=!0);var n=this._instance.get_property(ya)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((a=>{n[a]=Me({},n[a],t[a]),delete t[a]})),this._instance.register({[ya]:Me({},n,t)}),s&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var s=this._instance.get_property(ya)||{};this._instance.register({[ya]:Me({},s,{[t]:{}})})}else this._instance.unregister(ya)}reset(){this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.$anon_distinct_id=void 0,this.yi(),this.oi=!1}}var ZE=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];let Am=class{constructor(t,s){this.R=t,this.props={},this.$i=!1,this.Si=(n=>{var a="";return n.token&&(a=n.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),n.persistence_name?"ph_"+n.persistence_name:"ph_"+a+"_posthog"})(t),this.Y=this.ki(t),this.load(),t.debug&&Ee.info("Persistence loaded",t.persistence,Me({},this.props)),this.update_config(t,t,s),this.save()}isDisabled(){return!!this.Pi}ki(t){ZE.indexOf(t.persistence.toLowerCase())===-1&&(Ee.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var s=(function(a){a===void 0&&(a=[]);var l=[...fE,...a];return Me({},qt,{W:function(c){try{var d={};try{d=gr.W(c)||{}}catch{}var f=as(d,JSON.parse(qt.q(c)||"{}"));return qt.G(c,f),f}catch{}return null},G:function(c,d,f,h,m,g){try{qt.G(c,d,void 0,void 0,g);var _={};l.forEach((v=>{d[v]&&(_[v]=d[v])})),Object.keys(_).length&&gr.G(c,_,f,h,m,g)}catch(v){qt.B(v)}},V:function(c,d){try{he==null||he.localStorage.removeItem(c),gr.V(c,d)}catch(f){qt.B(f)}}})})(t.cookie_persisted_properties||[]),n=t.persistence.toLowerCase();return n==="localstorage"&&qt.H()?qt:n==="localstorage+cookie"&&s.H()?s:n==="sessionstorage"&&Ps.H()?Ps:n==="memory"?pE:n==="cookie"?gr:s.H()?s:gr}properties(){var t={};return Lt(this.props,(function(s,n){if(n===Bo&&ys(s))for(var a=Object.keys(s),l=0;l<a.length;l++)t["$feature/"+a[l]]=s[a[l]];else d=n,f=!1,(nr(c=q6)?f:vy&&c.indexOf===vy?c.indexOf(d)!=-1:(Lt(c,(function(h){if(f||(f=h===d))return ph})),f))||(t[n]=s);var c,d,f})),t}load(){if(!this.Pi){var t=this.Y.W(this.Si);t&&(this.props=as({},t))}}save(){this.Pi||this.Y.G(this.Si,this.props,this.Ti,this.Ii,this.Ci,this.R.debug)}remove(){this.Y.V(this.Si,!1),this.Y.V(this.Si,!0)}clear(){this.remove(),this.props={}}register_once(t,s,n){if(ys(t)){Ce(s)&&(s="None"),this.Ti=Ce(n)?this.Ri:n;var a=!1;if(Lt(t,((l,c)=>{this.props.hasOwnProperty(c)&&this.props[c]!==s||(this.props[c]=l,a=!0)})),a)return this.save(),!0}return!1}register(t,s){if(ys(t)){this.Ti=Ce(s)?this.Ri:s;var n=!1;if(Lt(t,((a,l)=>{t.hasOwnProperty(l)&&this.props[l]!==a&&(this.props[l]=a,n=!0)})),n)return this.save(),!0}return!1}unregister(t){t in this.props&&(delete this.props[t],this.save())}update_campaign_params(){if(!this.$i){var t=oj(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);Lo(_0(t))||this.register(t),this.$i=!0}}update_search_keyword(){var t;this.register((t=Ne==null?void 0:Ne.referrer)?cj(t):{})}update_referrer_info(){var t;this.register_once({$referrer:uj(),$referring_domain:Ne!=null&&Ne.referrer&&((t=_h(Ne.referrer))==null?void 0:t.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Gg]||this.props[Kg]||this.register_once({[xh]:dj(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var t={};Lt([Kg,Gg],(c=>{var d=this.props[c];d&&Lt(d,(function(f,h){t["$initial_"+Dg(h)]=f}))}));var s,n,a=this.props[xh];if(a){var l=(s=hj(a),n={},Lt(s,(function(c,d){n["$initial_"+Dg(d)]=c})),n);as(t,l)}return t}safe_merge(t){return Lt(this.props,(function(s,n){n in t||(t[n]=s)})),t}update_config(t,s,n){if(this.Ri=this.Ti=t.cookie_expiration,this.set_disabled(t.disable_persistence||!!n),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),t.persistence!==s.persistence||!((c,d)=>{if(c.length!==d.length)return!1;var f=[...c].sort(),h=[...d].sort();return f.every(((m,g)=>m===h[g]))})(t.cookie_persisted_properties||[],s.cookie_persisted_properties||[])){var a=this.ki(t),l=this.props;this.clear(),this.Y=a,this.props=l,this.save()}}set_disabled(t){this.Pi=t,this.Pi?this.remove():this.save()}set_cross_subdomain(t){t!==this.Ii&&(this.Ii=t,this.remove(),this.save())}set_secure(t){t!==this.Ci&&(this.Ci=t,this.remove(),this.save())}set_event_timer(t,s){var n=this.props[bc]||{};n[t]=s,this.props[bc]=n,this.save()}remove_event_timer(t){var s=(this.props[bc]||{})[t];return Ce(s)||(delete this.props[bc][t],this.save()),s}get_property(t){return this.props[t]}set_property(t,s){this.props[t]=s,this.save()}};var ow=Gt("[Product Tours]"),Rm="ph_product_tours";let eM=class{constructor(t){this.Fi=null,this.Oi=null,this._instance=t}onRemoteConfig(t){this._instance.persistence&&this._instance.persistence.register({[Ly]:!(t==null||!t.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var t,s;this.Fi||(t=this._instance).config.disable_product_tours||(s=t.persistence)==null||!s.get_property(Ly)||this.it((()=>this.Mi()))}it(t){var s,n;(s=He.__PosthogExtensions__)!=null&&s.generateProductTours?t():(n=He.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"product-tours",(a=>{a?ow.error("Could not load product tours script",a):t()}))}Mi(){var t;!this.Fi&&(t=He.__PosthogExtensions__)!=null&&t.generateProductTours&&(this.Fi=He.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,s){if(s===void 0&&(s=!1),!yt(this.Oi)||s){var n=this._instance.persistence;if(n){var a=n.props[Rm];if(yt(a)&&!s)return this.Oi=a,void t(a,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:l=>{var c=l.statusCode;if(c!==200||!l.json){var d="Product Tours API could not be loaded, status: "+c;return ow.error(d),void t([],{isLoaded:!1,error:d})}var f=yt(l.json.product_tours)?l.json.product_tours:[];this.Oi=f,n&&n.register({[Rm]:f}),t(f,{isLoaded:!0})}})}else t(this.Oi,{isLoaded:!0})}getActiveProductTours(t){ut(this.Fi)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Fi.getActiveProductTours(t)}showProductTour(t){var s;(s=this.Fi)==null||s.showTourById(t)}previewTour(t){this.Fi?this.Fi.previewTour(t):this.it((()=>{var s;this.Mi(),(s=this.Fi)==null||s.previewTour(t)}))}dismissProductTour(){var t;(t=this.Fi)==null||t.dismissTour("user_clicked_skip")}nextStep(){var t;(t=this.Fi)==null||t.nextStep()}previousStep(){var t;(t=this.Fi)==null||t.previousStep()}clearCache(){var t;this.Oi=null,(t=this._instance.persistence)==null||t.unregister(Rm)}resetTour(t){var s;(s=this.Fi)==null||s.resetTour(t)}resetAllTours(){var t;(t=this.Fi)==null||t.resetAllTours()}cancelPendingTour(t){var s;(s=this.Fi)==null||s.cancelPendingTour(t)}};var tc=(function(e){return e.Activation="events",e.Cancellation="cancelEvents",e})({});(function(e){return e.Button="button",e.Tab="tab",e.Selector="selector",e})({});(function(e){return e.TopLeft="top_left",e.TopRight="top_right",e.TopCenter="top_center",e.MiddleLeft="middle_left",e.MiddleRight="middle_right",e.MiddleCenter="middle_center",e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger",e})({});(function(e){return e.Top="top",e.Left="left",e.Right="right",e.Bottom="bottom",e})({});var Dm=(function(e){return e.Popover="popover",e.API="api",e.Widget="widget",e.ExternalSurvey="external_survey",e})({});(function(e){return e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link",e})({});(function(e){return e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question",e})({});(function(e){return e.Once="once",e.Recurring="recurring",e.Always="always",e})({});var Sc=(function(e){return e.SHOWN="survey shown",e.DISMISSED="survey dismissed",e.SENT="survey sent",e.ABANDONED="survey abandoned",e})({}),Lm=(function(e){return e.SURVEY_ID="$survey_id",e.SURVEY_NAME="$survey_name",e.SURVEY_RESPONSE="$survey_response",e.SURVEY_ITERATION="$survey_iteration",e.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",e.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",e.SURVEY_SUBMISSION_ID="$survey_submission_id",e.SURVEY_QUESTIONS="$survey_questions",e.SURVEY_COMPLETED="$survey_completed",e.PRODUCT_TOUR_ID="$product_tour_id",e.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",e})({}),ex=(function(e){return e.Popover="popover",e.Inline="inline",e})({}),Tt=Gt("[Surveys]"),yj="seenSurvey_",tM=(e,t)=>{var s="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(s="$survey_"+t+"/"+e.id+"/"+e.current_iteration),s},lw=e=>((t,s)=>{var n=""+t+s.id;return s.current_iteration&&s.current_iteration>0&&(n=""+t+s.id+"_"+s.current_iteration),n})(yj,e),sM=[Dm.Popover,Dm.Widget,Dm.API],nM={ignoreConditions:!1,ignoreDelay:!1,displayType:ex.Popover};class C0{constructor(){this.Ai={},this.Ai={}}on(t,s){return this.Ai[t]||(this.Ai[t]=[]),this.Ai[t].push(s),()=>{this.Ai[t]=this.Ai[t].filter((n=>n!==s))}}emit(t,s){for(var n of this.Ai[t]||[])n(s);for(var a of this.Ai["*"]||[])a(t,s)}}function So(e,t,s){if(ut(e))return!1;switch(s){case"exact":return e===t;case"contains":var n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(n,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}let rM=class{constructor(t){this.ji=new C0,this.Di=(s,n)=>this.Li(s,n)&&this.Ni(s,n)&&this.Ui(s,n)&&this.zi(s,n),this.Li=(s,n)=>n==null||!n.event||(s==null?void 0:s.event)===(n==null?void 0:n.event),this._instance=t,this.Hi=new Set,this.Bi=new Set}init(){var t;if(!Ce((t=this._instance)==null?void 0:t._addCaptureHook)){var s;(s=this._instance)==null||s._addCaptureHook(((n,a)=>{this.on(n,a)}))}}register(t){var s,n;if(!Ce((s=this._instance)==null?void 0:s._addCaptureHook)&&(t.forEach((c=>{var d,f;(d=this.Bi)==null||d.add(c),(f=c.steps)==null||f.forEach((h=>{var m;(m=this.Hi)==null||m.add((h==null?void 0:h.event)||"")}))})),(n=this._instance)!=null&&n.autocapture)){var a,l=new Set;t.forEach((c=>{var d;(d=c.steps)==null||d.forEach((f=>{f!=null&&f.selector&&l.add(f==null?void 0:f.selector)}))})),(a=this._instance)==null||a.autocapture.setElementSelectors(l)}}on(t,s){var n;s!=null&&t.length!=0&&(this.Hi.has(t)||this.Hi.has(s==null?void 0:s.event))&&this.Bi&&((n=this.Bi)==null?void 0:n.size)>0&&this.Bi.forEach((a=>{this.qi(s,a)&&this.ji.emit("actionCaptured",a.name)}))}Wi(t){this.onAction("actionCaptured",(s=>t(s)))}qi(t,s){if((s==null?void 0:s.steps)==null)return!1;for(var n of s.steps)if(this.Di(t,n))return!0;return!1}onAction(t,s){return this.ji.on(t,s)}Ni(t,s){if(s!=null&&s.url){var n,a=t==null||(n=t.properties)==null?void 0:n.$current_url;if(!a||typeof a!="string"||!So(a,s.url,s.url_matching||"contains"))return!1}return!0}Ui(t,s){return!!this.Gi(t,s)&&!!this.Vi(t,s)&&!!this.Ji(t,s)}Gi(t,s){var n;if(s==null||!s.href)return!0;var a=this.Ki(t);if(a.length>0)return a.some((d=>So(d.href,s.href,s.href_matching||"exact")));var l,c=(t==null||(n=t.properties)==null?void 0:n.$elements_chain)||"";return!!c&&So((l=c.match(/(?::|")href="(.*?)"/))?l[1]:"",s.href,s.href_matching||"exact")}Vi(t,s){var n;if(s==null||!s.text)return!0;var a=this.Ki(t);if(a.length>0)return a.some((h=>So(h.text,s.text,s.text_matching||"exact")||So(h.$el_text,s.text,s.text_matching||"exact")));var l,c,d,f=(t==null||(n=t.properties)==null?void 0:n.$elements_chain)||"";return!!f&&(l=(function(h){for(var m,g=[],_=/(?::|")text="(.*?)"/g;!ut(m=_.exec(h));)g.includes(m[1])||g.push(m[1]);return g})(f),c=s.text,d=s.text_matching||"exact",l.some((h=>So(h,c,d))))}Ji(t,s){var n,a;if(s==null||!s.selector)return!0;var l=t==null||(n=t.properties)==null?void 0:n.$element_selectors;if(l!=null&&l.includes(s.selector))return!0;var c=(t==null||(a=t.properties)==null?void 0:a.$elements_chain)||"";if(s.selector_regex&&c)try{return new RegExp(s.selector_regex).test(c)}catch{return!1}return!1}Ki(t){var s;return(t==null||(s=t.properties)==null?void 0:s.$elements)==null?[]:t==null?void 0:t.properties.$elements}zi(t,s){return s==null||!s.properties||s.properties.length===0||_j(s.properties.reduce(((n,a)=>{var l=yt(a.value)?a.value.map(String):a.value!=null?[String(a.value)]:[];return n[a.key]={values:l,operator:a.operator||"exact"},n}),{}),t==null?void 0:t.properties)}},iM=class{constructor(t){this._instance=t,this.Yi=new Map,this.Xi=new Map,this.Qi=new Map}Zi(t,s){return!!t&&_j(t.propertyFilters,s==null?void 0:s.properties)}te(t,s){var n=new Map;return t.forEach((a=>{var l;(l=a.conditions)==null||(l=l[s])==null||(l=l.values)==null||l.forEach((c=>{if(c!=null&&c.name){var d=n.get(c.name)||[];d.push(a.id),n.set(c.name,d)}}))})),n}ie(t,s,n){var a=(n===tc.Activation?this.Yi:this.Xi).get(t),l=[];return this.ee((c=>{l=c.filter((d=>a==null?void 0:a.includes(d.id)))})),l.filter((c=>{var d,f=(d=c.conditions)==null||(d=d[n])==null||(d=d.values)==null?void 0:d.find((h=>h.name===t));return this.Zi(f,s)}))}register(t){var s;Ce((s=this._instance)==null?void 0:s._addCaptureHook)||(this.re(t),this.se(t))}se(t){var s=t.filter((n=>{var a,l;return((a=n.conditions)==null?void 0:a.actions)&&((l=n.conditions)==null||(l=l.actions)==null||(l=l.values)==null?void 0:l.length)>0}));s.length!==0&&(this.ne==null&&(this.ne=new rM(this._instance),this.ne.init(),this.ne.Wi((n=>{this.onAction(n)}))),s.forEach((n=>{var a,l,c,d,f;n.conditions&&(a=n.conditions)!=null&&a.actions&&(l=n.conditions)!=null&&(l=l.actions)!=null&&l.values&&((c=n.conditions)==null||(c=c.actions)==null||(c=c.values)==null?void 0:c.length)>0&&((d=this.ne)==null||d.register(n.conditions.actions.values),(f=n.conditions)==null||(f=f.actions)==null||(f=f.values)==null||f.forEach((h=>{if(h&&h.name){var m=this.Qi.get(h.name);m&&m.push(n.id),this.Qi.set(h.name,m||[n.id])}})))})))}re(t){var s,n=t.filter((l=>{var c,d;return((c=l.conditions)==null?void 0:c.events)&&((d=l.conditions)==null||(d=d.events)==null||(d=d.values)==null?void 0:d.length)>0})),a=t.filter((l=>{var c,d;return((c=l.conditions)==null?void 0:c.cancelEvents)&&((d=l.conditions)==null||(d=d.cancelEvents)==null||(d=d.values)==null?void 0:d.length)>0}));(n.length!==0||a.length!==0)&&((s=this._instance)==null||s._addCaptureHook(((l,c)=>{this.onEvent(l,c)})),this.Yi=this.te(t,tc.Activation),this.Xi=this.te(t,tc.Cancellation))}onEvent(t,s){var n,a=this.oe(),l=this.ae(),c=this.le(),d=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[l])||[];if(c===t&&s&&d.length>0){var f,h;a.info("event matched, removing item from activated items",{event:t,eventPayload:s,existingActivatedItems:d});var m=(s==null||(f=s.properties)==null?void 0:f.$survey_id)||(s==null||(h=s.properties)==null?void 0:h.$product_tour_id);if(m){var g=d.indexOf(m);g>=0&&(d.splice(g,1),this.ue(d))}}else{if(this.Xi.has(t)){var _=this.ie(t,s,tc.Cancellation);_.length>0&&(a.info("cancel event matched, cancelling items",{event:t,itemsToCancel:_.map((y=>y.id))}),_.forEach((y=>{var S=d.indexOf(y.id);S>=0&&d.splice(S,1),this.he(y.id)})),this.ue(d))}if(this.Yi.has(t)){a.info("event name matched",{event:t,eventPayload:s,items:this.Yi.get(t)});var v=this.ie(t,s,tc.Activation);this.ue(d.concat(v.map((y=>y.id))||[]))}}}onAction(t){var s,n=this.ae(),a=((s=this._instance)==null||(s=s.persistence)==null?void 0:s.props[n])||[];this.Qi.has(t)&&this.ue(a.concat(this.Qi.get(t)||[]))}ue(t){var s,n=this.oe(),a=this.ae(),l=[...new Set(t)].filter((c=>!this.de(c)));n.info("updating activated items",{activatedItems:l}),(s=this._instance)==null||(s=s.persistence)==null||s.register({[a]:l})}getActivatedIds(){var t,s=this.ae(),n=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[s];return n||[]}getEventToItemsMap(){return this.Yi}ve(){return this.ne}};class aM extends iM{constructor(t){super(t)}ae(){return"$surveys_activated"}le(){return Sc.SHOWN}ee(t){var s;(s=this._instance)==null||s.getSurveys(t)}he(t){var s;(s=this._instance)==null||s.cancelPendingSurvey(t)}oe(){return Tt}de(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class oM{constructor(t){this.ce=void 0,this._surveyManager=null,this.fe=!1,this.pe=[],this.ge=null,this._instance=t,this._surveyEventReceiver=null}onRemoteConfig(t){if(!this._instance.config.disable_surveys){var s=t.surveys;if(ut(s))return Tt.warn("Flags not loaded yet. Not loading surveys.");var n=yt(s);this.ce=n?s.length>0:s,Tt.info("flags response received, isSurveysEnabled: "+this.ce),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var t=[],s=0;s<localStorage.length;s++){var n=localStorage.key(s);(n!=null&&n.startsWith(yj)||n!=null&&n.startsWith("inProgressSurvey_"))&&t.push(n)}t.forEach((a=>localStorage.removeItem(a)))}loadIfEnabled(){if(!this._surveyManager)if(this.fe)Tt.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)Tt.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())Tt.info("Not loading surveys in cookieless mode without consent.");else{var t=He==null?void 0:He.__PosthogExtensions__;if(t){if(!Ce(this.ce)||this._instance.config.advanced_enable_surveys){var s=this.ce||this._instance.config.advanced_enable_surveys;this.fe=!0;try{var n=t.generateSurveys;if(n)return void this._e(n,s);var a=t.loadExternalDependency;if(!a)return void this.me("PostHog loadExternalDependency extension not found.");a(this._instance,"surveys",(l=>{l||!t.generateSurveys?this.me("Could not load surveys script",l):this._e(t.generateSurveys,s)}))}catch(l){throw this.me("Error initializing surveys",l),l}finally{this.fe=!1}}}else Tt.error("PostHog Extensions not found.")}}_e(t,s){this._surveyManager=t(this._instance,s),this._surveyEventReceiver=new aM(this._instance),Tt.info("Surveys loaded successfully"),this.be({isLoaded:!0})}me(t,s){Tt.error(t,s),this.be({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.pe.push(t),this._surveyManager&&this.be({isLoaded:!0}),()=>{this.pe=this.pe.filter((s=>s!==t))}}getSurveys(t,s){if(s===void 0&&(s=!1),this._instance.config.disable_surveys)return Tt.info("Disabled. Not loading surveys."),t([]);var n,a=this._instance.get_property(Ug);if(a&&!s)return t(a,{isLoaded:!0});typeof Promise<"u"&&this.ge?this.ge.then((l=>{var{surveys:c,context:d}=l;return t(c,d)})):(typeof Promise<"u"&&(this.ge=new Promise((l=>{n=l}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:l=>{var c;this.ge=null;var d=l.statusCode;if(d!==200||!l.json){var f="Surveys API could not be loaded, status: "+d;Tt.error(f);var h={isLoaded:!1,error:f};return t([],h),void(n==null||n({surveys:[],context:h}))}var m,g=l.json.surveys||[],_=g.filter((y=>(function(S){return!(!S.start_date||S.end_date)})(y)&&((function(S){var j;return!((j=S.conditions)==null||(j=j.events)==null||(j=j.values)==null||!j.length)})(y)||(function(S){var j;return!((j=S.conditions)==null||(j=j.actions)==null||(j=j.values)==null||!j.length)})(y))));_.length>0&&((m=this._surveyEventReceiver)==null||m.register(_)),(c=this._instance.persistence)==null||c.register({[Ug]:g});var v={isLoaded:!0};t(g,v),n==null||n({surveys:g,context:v})}}))}be(t){for(var s of this.pe)try{if(!t.isLoaded)return s([],t);this.getSurveys(s)}catch(n){Tt.error("Error in survey callback",n)}}getActiveMatchingSurveys(t,s){if(s===void 0&&(s=!1),!ut(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,s);Tt.warn("init was not called")}ye(t){var s=null;return this.getSurveys((n=>{var a;s=(a=n.find((l=>l.id===t)))!==null&&a!==void 0?a:null})),s}we(t){if(ut(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var s=typeof t=="string"?this.ye(t):t;return s?this._surveyManager.checkSurveyEligibility(s):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(ut(this._surveyManager))return Tt.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var s=this.we(t);return{visible:s.eligible,disabledReason:s.reason}}canRenderSurveyAsync(t,s){return ut(this._surveyManager)?(Tt.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((n=>{this.getSurveys((a=>{var l,c=(l=a.find((f=>f.id===t)))!==null&&l!==void 0?l:null;if(c){var d=this.we(c);n({visible:d.eligible,disabledReason:d.reason})}else n({visible:!1,disabledReason:"Survey not found"})}),s)}))}renderSurvey(t,s,n){var a;if(ut(this._surveyManager))Tt.warn("init was not called");else{var l=typeof t=="string"?this.ye(t):t;if(l!=null&&l.id)if(sM.includes(l.type)){var c=Ne==null?void 0:Ne.querySelector(s);if(c)return(a=l.appearance)!=null&&a.surveyPopupDelaySeconds?(Tt.info("Rendering survey "+l.id+" with delay of "+l.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var d,f;Tt.info("Rendering survey "+l.id+" with delay of "+((d=l.appearance)==null?void 0:d.surveyPopupDelaySeconds)+" seconds"),(f=this._surveyManager)==null||f.renderSurvey(l,c,n),Tt.info("Survey "+l.id+" rendered")}),1e3*l.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(l,c,n);Tt.warn("Survey element not found")}else Tt.warn("Surveys of type "+l.type+" cannot be rendered in the app");else Tt.warn("Survey not found")}}displaySurvey(t,s){var n;if(ut(this._surveyManager))Tt.warn("init was not called");else{var a=this.ye(t);if(a){var l=a;if((n=a.appearance)!=null&&n.surveyPopupDelaySeconds&&s.ignoreDelay&&(l=Me({},a,{appearance:Me({},a.appearance,{surveyPopupDelaySeconds:0})})),s.displayType!==ex.Popover&&s.initialResponses&&Tt.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),s.ignoreConditions===!1){var c=this.canRenderSurvey(a);if(!c.visible)return void Tt.warn("Survey is not eligible to be displayed: ",c.disabledReason)}s.displayType!==ex.Inline?this._surveyManager.handlePopoverSurvey(l,s):this.renderSurvey(l,s.selector,s.properties)}else Tt.warn("Survey not found")}}cancelPendingSurvey(t){ut(this._surveyManager)?Tt.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;(t=this._surveyManager)==null||t.handlePageUnload()}}var qr=Gt("[Conversations]");class lM{constructor(t){this.xe=void 0,this._conversationsManager=null,this.Ee=!1,this.$e=null,this._instance=t}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var s=t.conversations;ut(s)||(ei(s)?this.xe=s:(this.xe=s.enabled,this.$e=s),this.loadIfEnabled())}}reset(){var t;(t=this._conversationsManager)==null||t.reset(),this._conversationsManager=null,this.xe=void 0,this.$e=null}loadIfEnabled(){if(!this._conversationsManager&&!this.Ee&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=He==null?void 0:He.__PosthogExtensions__;if(t&&!Ce(this.xe)&&this.xe)if(this.$e&&this.$e.token){this.Ee=!0;try{var s=t.initConversations;if(s)return this.Se(s),void(this.Ee=!1);var n=t.loadExternalDependency;if(!n)return void this.ke("PostHog loadExternalDependency extension not found.");n(this._instance,"conversations",(a=>{a||!t.initConversations?this.ke("Could not load conversations script",a):this.Se(t.initConversations),this.Ee=!1}))}catch(a){this.ke("Error initializing conversations",a),this.Ee=!1}}else qr.error("Conversations enabled but missing token in remote config.")}}Se(t){if(this.$e)try{this._conversationsManager=t(this.$e,this._instance),qr.info("Conversations loaded successfully")}catch(s){this.ke("Error completing conversations initialization",s)}else qr.error("Cannot complete initialization: remote config is null")}ke(t,s){qr.error(t,s),this._conversationsManager=null,this.Ee=!1}show(){this._conversationsManager?this._conversationsManager.show():qr.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.xe===!0&&!nr(this._conversationsManager)}isVisible(){var t,s;return(t=(s=this._conversationsManager)==null?void 0:s.isVisible())!==null&&t!==void 0&&t}sendMessage(t,s,n){var a=this;return Do((function*(){return a._conversationsManager?a._conversationsManager.sendMessage(t,s,n):(qr.warn("Conversations not available yet."),null)}))()}getMessages(t,s){var n=this;return Do((function*(){return n._conversationsManager?n._conversationsManager.getMessages(t,s):(qr.warn("Conversations not available yet."),null)}))()}markAsRead(t){var s=this;return Do((function*(){return s._conversationsManager?s._conversationsManager.markAsRead(t):(qr.warn("Conversations not available yet."),null)}))()}getTickets(t){var s=this;return Do((function*(){return s._conversationsManager?s._conversationsManager.getTickets(t):(qr.warn("Conversations not available yet."),null)}))()}getCurrentTicketId(){var t,s;return(t=(s=this._conversationsManager)==null?void 0:s.getCurrentTicketId())!==null&&t!==void 0?t:null}getWidgetSessionId(){var t,s;return(t=(s=this._conversationsManager)==null?void 0:s.getWidgetSessionId())!==null&&t!==void 0?t:null}}class cM{constructor(t){var s;this.Pe=!1,this.Te=!1,this._instance=t,this._instance&&(s=this._instance.config.logs)!=null&&s.captureConsoleLogs&&(this.Pe=!0)}onRemoteConfig(t){var s,n=(s=t.logs)==null?void 0:s.captureConsoleLogs;!ut(n)&&n&&(this.Pe=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Pe&&!this.Te){var t=Gt("[logs]"),s=He==null?void 0:He.__PosthogExtensions__;if(s){var n=s.loadExternalDependency;n?n(this._instance,"logs",(a=>{var l;a||(l=s.logs)==null||!l.initializeLogs?t.error("Could not load logs script",a):(s.logs.initializeLogs(this._instance),this.Te=!0)})):t.error("PostHog loadExternalDependency extension not found.")}else t.error("PostHog Extensions not found.")}}}var cw=Gt("[RateLimiter]");let uM=class{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=s=>{var n=s.text;if(n&&n.length)try{(JSON.parse(n).quota_limited||[]).forEach((a=>{cw.info((a||"events")+" is quota limited."),this.serverLimits[a]=new Date().getTime()+6e4}))}catch(a){return void cw.warn('could not rate limit - continuing. Error: "'+(a==null?void 0:a.message)+'"',{text:n})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return((t=this.instance.config.rate_limiting)==null?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max(((t=this.instance.config.rate_limiting)==null?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var s,n,a;t===void 0&&(t=!1);var{captureEventsBurstLimit:l,captureEventsPerSecond:c}=this,d=new Date().getTime(),f=(s=(n=this.instance.persistence)==null?void 0:n.get_property(qg))!==null&&s!==void 0?s:{tokens:l,last:d};f.tokens+=(d-f.last)/1e3*c,f.last=d,f.tokens>l&&(f.tokens=l);var h=f.tokens<1;return h||t||(f.tokens=Math.max(0,f.tokens-1)),!h||this.lastEventRateLimited||t||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+c+" events per second and "+l+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=h,(a=this.instance.persistence)==null||a.set_property(qg,f),{isRateLimited:h,remainingTokens:f.tokens}}isServerRateLimited(t){var s=this.serverLimits[t||"events"]||!1;return s!==!1&&new Date().getTime()<s}};var va=Gt("[RemoteConfig]");let wj=class{constructor(t){this._instance=t}get remoteConfig(){var t;return(t=He._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.config}Ie(t){var s,n;(s=He.__PosthogExtensions__)!=null&&s.loadExternalDependency?(n=He.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):(va.error("PostHog Extensions not found. Cannot load remote config."),t())}Ce(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:s=>{t(s.json)}})}load(){try{if(this.remoteConfig)return va.info("Using preloaded remote config",this.remoteConfig),void this.wi(this.remoteConfig);if(this._instance.M())return void va.warn("Remote config is disabled. Falling back to local config.");this.Ie((t=>{if(!t)return va.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ce((s=>{this.wi(s)}));this.wi(t)}))}catch(t){va.error("Error loading remote config",t)}}wi(t){t?this._instance.config.__preview_remote_config?(this._instance.wi(t),t.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):va.info("__preview_remote_config is disabled. Logging config instead",t):va.error("Failed to fetch remote config from PostHog.")}};var tx=3e3;class dM{constructor(t,s){this.Re=!0,this.Fe=[],this.Oe=vr((s==null?void 0:s.flush_interval_ms)||tx,250,5e3,Ee.createLogger("flush interval"),tx),this.Me=t}enqueue(t){this.Fe.push(t),this.Ae||this.je()}unload(){this.De();var t=this.Fe.length>0?this.Le():{},s=Object.values(t);[...s.filter((n=>n.url.indexOf("/e")===0)),...s.filter((n=>n.url.indexOf("/e")!==0))].map((n=>{this.Me(Me({},n,{transport:"sendBeacon"}))}))}enable(){this.Re=!1,this.je()}je(){var t=this;this.Re||(this.Ae=setTimeout((()=>{if(this.De(),this.Fe.length>0){var s=this.Le(),n=function(){var l=s[a],c=new Date().getTime();l.data&&yt(l.data)&&Lt(l.data,(d=>{d.offset=Math.abs(d.timestamp-c),delete d.timestamp})),t.Me(l)};for(var a in s)n()}}),this.Oe))}De(){clearTimeout(this.Ae),this.Ae=void 0}Le(){var t={};return Lt(this.Fe,(s=>{var n,a=s,l=(a?a.batchKey:null)||a.url;Ce(t[l])&&(t[l]=Me({},a,{data:[]})),(n=t[l].data)==null||n.push(a.data)})),this.Fe=[],t}}var hM=["retriesPerformedSoFar"];let fM=class{constructor(t){this.Ne=!1,this.Ue=3e3,this.Fe=[],this._instance=t,this.Fe=[],this.ze=!0,!Ce(he)&&"onLine"in he.navigator&&(this.ze=he.navigator.onLine,this.He=()=>{this.ze=!0,this.Lt()},this.Be=()=>{this.ze=!1},ps(he,"online",this.He),ps(he,"offline",this.Be))}get length(){return this.Fe.length}retriableRequest(t){var{retriesPerformedSoFar:s}=t,n=gS(t,hM);To(s)&&(n.url=jh(n.url,{retry_count:s})),this._instance._send_request(Me({},n,{callback:a=>{a.statusCode!==200&&(a.statusCode<400||a.statusCode>=500)&&(s??0)<10?this.qe(Me({retriesPerformedSoFar:s},n)):n.callback==null||n.callback(a)}}))}qe(t){var s=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=s+1;var n=(function(c){var d=3e3*Math.pow(2,c),f=d/2,h=Math.min(18e5,d),m=(Math.random()-.5)*(h-f);return Math.ceil(h+m)})(s),a=Date.now()+n;this.Fe.push({retryAt:a,requestOptions:t});var l="Enqueued failed request for retry in "+n;navigator.onLine||(l+=" (Browser is offline)"),Ee.warn(l),this.Ne||(this.Ne=!0,this.We())}We(){if(this.Ge&&clearTimeout(this.Ge),this.Fe.length===0)return this.Ne=!1,void(this.Ge=void 0);this.Ge=setTimeout((()=>{this.ze&&this.Fe.length>0&&this.Lt(),this.We()}),this.Ue)}Lt(){var t=Date.now(),s=[],n=this.Fe.filter((l=>l.retryAt<t||(s.push(l),!1)));if(this.Fe=s,n.length>0)for(var{requestOptions:a}of n)this.retriableRequest(a)}unload(){for(var{requestOptions:t}of(this.Ge&&(clearTimeout(this.Ge),this.Ge=void 0),this.Ne=!1,Ce(he)||(this.He&&(he.removeEventListener("online",this.He),this.He=void 0),this.Be&&(he.removeEventListener("offline",this.Be),this.Be=void 0)),this.Fe))try{this._instance._send_request(Me({},t,{transport:"sendBeacon"}))}catch(s){Ee.error(s)}this.Fe=[]}};class pM{constructor(t){this.Ve=()=>{var s,n,a,l;this.Je||(this.Je={});var c=this.scrollElement(),d=this.scrollY(),f=c?Math.max(0,c.scrollHeight-c.clientHeight):0,h=d+((c==null?void 0:c.clientHeight)||0),m=(c==null?void 0:c.scrollHeight)||0;this.Je.lastScrollY=Math.ceil(d),this.Je.maxScrollY=Math.max(d,(s=this.Je.maxScrollY)!==null&&s!==void 0?s:0),this.Je.maxScrollHeight=Math.max(f,(n=this.Je.maxScrollHeight)!==null&&n!==void 0?n:0),this.Je.lastContentY=h,this.Je.maxContentY=Math.max(h,(a=this.Je.maxContentY)!==null&&a!==void 0?a:0),this.Je.maxContentHeight=Math.max(m,(l=this.Je.maxContentHeight)!==null&&l!==void 0?l:0)},this._instance=t}getContext(){return this.Je}resetContext(){var t=this.Je;return setTimeout(this.Ve,0),t}startMeasuringScrollPosition(){ps(he,"scroll",this.Ve,{capture:!0}),ps(he,"scrollend",this.Ve,{capture:!0}),ps(he,"resize",this.Ve)}scrollElement(){if(!this._instance.config.scroll_root_selector)return he==null?void 0:he.document.documentElement;var t=yt(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var s of t){var n=he==null?void 0:he.document.querySelector(s);if(n)return n}}scrollY(){if(this._instance.config.scroll_root_selector){var t=this.scrollElement();return t&&t.scrollTop||0}return he&&(he.scrollY||he.pageYOffset||he.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var t=this.scrollElement();return t&&t.scrollLeft||0}return he&&(he.scrollX||he.pageXOffset||he.document.documentElement.scrollLeft)||0}}var mM=e=>dj(e==null?void 0:e.config.mask_personal_data_properties,e==null?void 0:e.config.custom_personal_data_properties);let uw=class{constructor(t,s,n,a){this.Ke=l=>{var c=this.Ye();if(!c||c.sessionId!==l){var d={sessionId:l,props:this.Xe(this._instance)};this.Qe.register({[Wg]:d})}},this._instance=t,this.Ze=s,this.Qe=n,this.Xe=a||mM,this.Ze.onSessionId(this.Ke)}Ye(){return this.Qe.props[Wg]}getSetOnceProps(){var t,s=(t=this.Ye())==null?void 0:t.props;return s?"r"in s?hj(s):{$referring_domain:s.referringDomain,$pathname:s.initialPathName,utm_source:s.utm_source,utm_campaign:s.utm_campaign,utm_medium:s.utm_medium,utm_content:s.utm_content,utm_term:s.utm_term}:{}}getSessionProps(){var t={};return Lt(_0(this.getSetOnceProps()),((s,n)=>{n==="$current_url"&&(n="url"),t["$session_entry_"+Dg(n)]=s})),t}};var Bm=Gt("[SessionId]");class dw{on(t,s){return this.tr.on(t,s)}constructor(t,s,n){var a;if(this.ir=[],this.er=void 0,this.tr=new C0,this.rr=(m,g)=>!(!To(m)||!To(g))&&Math.abs(m-g)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.R=t.config,this.Qe=t.persistence,this.sr=void 0,this.nr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.ar=s||Hi,this.lr=n||Hi;var l=this.R.persistence_name||this.R.token,c=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*vr(c,60,36e3,Bm.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ur(),this.hr="ph_"+l+"_window_id",this.dr="ph_"+l+"_primary_window_exists",this.vr()){var d=Ps.W(this.hr),f=Ps.W(this.dr);d&&!f?this.sr=d:Ps.V(this.hr),Ps.G(this.dr,!0)}if((a=this.R.bootstrap)!=null&&a.sessionID)try{var h=(m=>{var g=m.replace(/-/g,"");if(g.length!==32)throw new Error("Not a valid UUID");if(g[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(g.substring(0,12),16)})(this.R.bootstrap.sessionID);this.cr(this.R.bootstrap.sessionID,new Date().getTime(),h)}catch(m){Bm.error("Invalid sessionID in bootstrap",m)}this.pr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return Ce(this.ir)&&(this.ir=[]),this.ir.push(t),this.nr&&t(this.nr,this.sr),()=>{this.ir=this.ir.filter((s=>s!==t))}}vr(){return this.R.persistence!=="memory"&&!this.Qe.Pi&&Ps.H()}gr(t){t!==this.sr&&(this.sr=t,this.vr()&&Ps.G(this.hr,t))}_r(){return this.sr?this.sr:this.vr()?Ps.W(this.hr):null}cr(t,s,n){t===this.nr&&s===this._sessionActivityTimestamp&&n===this._sessionStartTimestamp||(this._sessionStartTimestamp=n,this._sessionActivityTimestamp=s,this.nr=t,this.Qe.register({[mh]:[s,t,n]}))}mr(){var t=this.Qe.props[mh];return yt(t)&&t.length===2&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.cr(null,null,null)}destroy(){clearTimeout(this.br),this.br=void 0,this.er&&he&&(he.removeEventListener("beforeunload",this.er,{capture:!1}),this.er=void 0),this.ir=[]}pr(){this.er=()=>{this.vr()&&Ps.V(this.dr)},ps(he,"beforeunload",this.er,{capture:!1})}checkAndGetSessionAndWindowId(t,s){if(t===void 0&&(t=!1),s===void 0&&(s=null),this.R.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var n=s||new Date().getTime(),[a,l,c]=this.mr(),d=this._r(),f=To(c)&&Math.abs(n-c)>864e5,h=!1,m=!l,g=!m&&!t&&this.rr(n,a);m||g||f?(l=this.ar(),d=this.lr(),Bm.info("new session ID generated",{sessionId:l,windowId:d,changeReason:{noSessionId:m,activityTimeout:g,sessionPastMaximumLength:f}}),c=n,h=!0):d||(d=this.lr(),h=!0);var _=To(a)&&t&&!f?a:n,v=To(c)?c:new Date().getTime();return this.gr(d),this.cr(l,_,v),t||this.ur(),h&&this.ir.forEach((y=>y(l,d,h?{noSessionId:m,activityTimeout:g,sessionPastMaximumLength:f}:void 0))),{sessionId:l,windowId:d,sessionStartTimestamp:v,changeReason:h?{noSessionId:m,activityTimeout:g,sessionPastMaximumLength:f}:void 0,lastActivityTimestamp:a}}ur(){clearTimeout(this.br),this.br=setTimeout((()=>{var[t]=this.mr();if(this.rr(new Date().getTime(),t)){var s=this.nr;this.resetSessionId(),this.tr.emit("forcedIdleReset",{idleSessionId:s})}}),1.1*this.sessionTimeoutMs)}}var gM=["$set_once","$set"],Di=Gt("[SiteApps]");let xM=class{constructor(t){this._instance=t,this.yr=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}wr(t,s){if(s){var n=this.globalsForEvent(s);this.yr.push(n),this.yr.length>1e3&&(this.yr=this.yr.slice(10))}}get siteAppLoaders(){var t;return(t=He._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.siteApps}init(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.wr.bind(this));this.Er=()=>{t(),this.yr=[],this.Er=void 0}}}globalsForEvent(t){var s,n,a,l,c,d,f;if(!t)throw new Error("Event payload is required");var h={},m=this._instance.get_property("$groups")||[],g=this._instance.get_property("$stored_group_properties")||{};for(var[_,v]of Object.entries(g))h[_]={id:m[_],type:_,properties:v};var{$set_once:y,$set:S}=t;return{event:Me({},gS(t,gM),{properties:Me({},t.properties,S?{$set:Me({},(s=(n=t.properties)==null?void 0:n.$set)!==null&&s!==void 0?s:{},S)}:{},y?{$set_once:Me({},(a=(l=t.properties)==null?void 0:l.$set_once)!==null&&a!==void 0?a:{},y)}:{}),elements_chain:(c=(d=t.properties)==null?void 0:d.$elements_chain)!==null&&c!==void 0?c:"",distinct_id:(f=t.properties)==null?void 0:f.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:h}}setupSiteApp(t){var s=this.apps[t.id],n=()=>{var d;!s.errored&&this.yr.length&&(Di.info("Processing "+this.yr.length+" events for site app with id "+t.id),this.yr.forEach((f=>s.processEvent==null?void 0:s.processEvent(f))),s.processedBuffer=!0),Object.values(this.apps).every((f=>f.processedBuffer||f.errored))&&((d=this.Er)==null||d.call(this))},a=!1,l=d=>{s.errored=!d,s.loaded=!0,Di.info("Site app with id "+t.id+" "+(d?"loaded":"errored")),a&&n()};try{var{processEvent:c}=t.init({posthog:this._instance,callback:d=>{l(d)}});c&&(s.processEvent=c),a=!0}catch(d){Di.error("Error while initializing PostHog app with config id "+t.id,d),l(!1)}if(a&&s.loaded)try{n()}catch(d){Di.error("Error while processing buffered events PostHog app with config id "+t.id,d),s.errored=!0}}$r(){var t=this.siteAppLoaders||[];for(var s of t)this.apps[s.id]={id:s.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of t)this.setupSiteApp(n)}Sr(t){if(Object.keys(this.apps).length!==0){var s=this.globalsForEvent(t);for(var n of Object.values(this.apps))try{n.processEvent==null||n.processEvent(s)}catch(a){Di.error("Error while processing event "+t.event+" for site app "+n.id,a)}}}onRemoteConfig(t){var s,n,a,l=this;if((s=this.siteAppLoaders)!=null&&s.length)return this.isEnabled?(this.$r(),void this._instance.on("eventCaptured",(h=>this.Sr(h)))):void Di.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((n=this.Er)==null||n.call(this),(a=t.siteApps)!=null&&a.length)if(this.isEnabled){var c=function(h){var m;He["__$$ph_site_app_"+h]=l._instance,(m=He.__PosthogExtensions__)==null||m.loadSiteApp==null||m.loadSiteApp(l._instance,f,(g=>{if(g)return Di.error("Error while initializing PostHog app with config id "+h,g)}))};for(var{id:d,url:f}of t.siteApps)c(d)}else Di.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}};var Sj=function(e,t){if(!e)return!1;var s=e.userAgent;if(s&&yy(s,t))return!0;try{var n=e==null?void 0:e.userAgentData;if(n!=null&&n.brands&&n.brands.some((a=>yy(a==null?void 0:a.brand,t))))return!0}catch{}return!!e.webdriver},jc=(function(e){return e.US="us",e.EU="eu",e.CUSTOM="custom",e})({}),hw="i.posthog.com";let vM=class{constructor(t){this.kr={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return t==="https://app.posthog.com"?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,s=(t=this.instance.config.ui_host)==null?void 0:t.replace(/\/$/,"");return s||(s=this.apiHost.replace("."+hw,".posthog.com")),s==="https://app.posthog.com"?"https://us.posthog.com":s}get region(){return this.kr[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.kr[this.apiHost]=jc.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.kr[this.apiHost]=jc.EU:this.kr[this.apiHost]=jc.CUSTOM),this.kr[this.apiHost]}endpointFor(t,s){if(s===void 0&&(s=""),s&&(s=s[0]==="/"?s:"/"+s),t==="ui")return this.uiHost+s;if(t==="flags")return this.flagsApiHost+s;if(this.region===jc.CUSTOM)return this.apiHost+s;var n=hw+s;switch(t){case"assets":return"https://"+this.region+"-assets."+n;case"api":return"https://"+this.region+"."+n}}};var bM={icontains:(e,t)=>!!he&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!he&&t.href.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>!!he&&kh(t.href,e),not_regex:(e,t)=>!!he&&!kh(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};let _M=class Js{constructor(t){var s=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(n){n===void 0&&(n=!1),s.getWebExperiments((a=>{Js.Pr("retrieved web experiments from the server"),s.Tr=new Map,a.forEach((l=>{if(l.feature_flag_key){var c;s.Tr&&(Js.Pr("setting flag key ",l.feature_flag_key," to web experiment ",l),(c=s.Tr)==null||c.set(l.feature_flag_key,l));var d=s._instance.getFeatureFlag(l.feature_flag_key);ws(d)&&l.variants[d]&&s.Ir(l.name,d,l.variants[d].transforms)}else if(l.variants)for(var f in l.variants){var h=l.variants[f];Js.Cr(h)&&s.Ir(l.name,f,h.transforms)}}))}),n)},this._instance=t,this._instance.onFeatureFlags((n=>{this.onFeatureFlags(n)}))}onFeatureFlags(t){if(this._is_bot())Js.Pr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(ut(this.Tr))return this.Tr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Js.Pr("applying feature flags",t),t.forEach((s=>{var n;if(this.Tr&&(n=this.Tr)!=null&&n.has(s)){var a,l=this._instance.getFeatureFlag(s),c=(a=this.Tr)==null?void 0:a.get(s);l&&c!=null&&c.variants[l]&&this.Ir(c.name,l,c.variants[l].transforms)}}))}}previewWebExperiment(){var t=Js.getWindowLocation();if(t!=null&&t.search){var s=yh(t==null?void 0:t.search,"__experiment_id"),n=yh(t==null?void 0:t.search,"__experiment_variant");s&&n&&(Js.Pr("previewing web experiments "+s+" && "+n),this.getWebExperiments((a=>{this.Rr(parseInt(s),n,a)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,s,n){if(this._instance.config.disable_web_experiments&&!n)return t([]);var a=this._instance.get_property("$web_experiments");if(a&&!s)return t(a);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:l=>{if(l.statusCode!==200||!l.json)return t([]);var c=l.json.experiments||[];return t(c)}})}Rr(t,s,n){var a=n.filter((l=>l.id===t));a&&a.length>0&&(Js.Pr("Previewing web experiment ["+a[0].name+"] with variant ["+s+"]"),this.Ir(a[0].name,s,a[0].variants[s].transforms))}static Cr(t){return!ut(t.conditions)&&Js.Fr(t)&&Js.Or(t)}static Fr(t){var s;if(ut(t.conditions)||ut((s=t.conditions)==null?void 0:s.url))return!0;var n,a,l,c=Js.getWindowLocation();return!!c&&((n=t.conditions)==null||!n.url||bM[(a=(l=t.conditions)==null?void 0:l.urlMatchType)!==null&&a!==void 0?a:"icontains"](t.conditions.url,c))}static getWindowLocation(){return he==null?void 0:he.location}static Or(t){var s;if(ut(t.conditions)||ut((s=t.conditions)==null?void 0:s.utm))return!0;var n=oj();if(n.utm_source){var a,l,c,d,f,h,m,g,_=(a=t.conditions)==null||(a=a.utm)==null||!a.utm_campaign||((l=t.conditions)==null||(l=l.utm)==null?void 0:l.utm_campaign)==n.utm_campaign,v=(c=t.conditions)==null||(c=c.utm)==null||!c.utm_source||((d=t.conditions)==null||(d=d.utm)==null?void 0:d.utm_source)==n.utm_source,y=(f=t.conditions)==null||(f=f.utm)==null||!f.utm_medium||((h=t.conditions)==null||(h=h.utm)==null?void 0:h.utm_medium)==n.utm_medium,S=(m=t.conditions)==null||(m=m.utm)==null||!m.utm_term||((g=t.conditions)==null||(g=g.utm)==null?void 0:g.utm_term)==n.utm_term;return _&&y&&S&&v}return!1}static Pr(t){for(var s=arguments.length,n=new Array(s>1?s-1:0),a=1;a<s;a++)n[a-1]=arguments[a];Ee.info("[WebExperiments] "+t,n)}Ir(t,s,n){this._is_bot()?Js.Pr("Refusing to render web experiment since the viewer is a likely bot"):s!=="control"?n.forEach((a=>{if(a.selector){var l;Js.Pr("applying transform of variant "+s+" for experiment "+t+" ",a);var c=(l=document)==null?void 0:l.querySelectorAll(a.selector);c==null||c.forEach((d=>{var f=d;a.html&&(f.innerHTML=a.html),a.css&&f.setAttribute("style",a.css)}))}})):Js.Pr("Control variants leave the page unmodified.")}_is_bot(){return An&&this._instance?Sj(An,this._instance.config.custom_blocked_useragents):void 0}};var yM=Gt("[PostHog ExternalIntegrations]"),wM={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class SM{constructor(t){this._instance=t}it(t,s){var n;(n=He.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,t,(a=>{if(a)return yM.error("failed to load script",a);s()}))}startIfEnabledOrStop(){var t=this,s=function(c){var d,f,h;!a||(d=He.__PosthogExtensions__)!=null&&(d=d.integrations)!=null&&d[c]||t.it(wM[c],(()=>{var m;(m=He.__PosthogExtensions__)==null||(m=m.integrations)==null||(m=m[c])==null||m.start(t._instance)})),!a&&(f=He.__PosthogExtensions__)!=null&&(f=f.integrations)!=null&&f[c]&&((h=He.__PosthogExtensions__)==null||(h=h.integrations)==null||(h=h[c])==null||h.stop())};for(var[n,a]of Object.entries((l=this._instance.config.integrations)!==null&&l!==void 0?l:{})){var l;s(n)}}}Gt("[SessionRecording]");var sx="[SessionRecording]",jo=Gt(sx);let fw=class{get started(){var t;return!((t=this.Mr)==null||!t.isStarted)}get status(){return this.Mr?this.Mr.status:this.Ar&&!this.jr?"disabled":"lazy_loading"}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.Ar=!1,this.Dr=!1,this.Lr=void 0,this._instance=t,!this._instance.sessionManager)throw jo.error("started without valid sessionManager"),new Error(sx+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(sx+' cannot be used with cookieless_mode="always"')}get jr(){var t,s=!((t=this._instance.get_property(Td))==null||!t.enabled),n=!this._instance.config.disable_session_recording,a=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return he&&s&&n&&!a}startIfEnabledOrStop(t){var s;if(!this.jr||(s=this.Mr)==null||!s.isStarted){var n=!Ce(Object.assign)&&!Ce(Array.from);this.jr&&n?(this.Nr(t),jo.info("starting")):this.stopRecording()}}Nr(t){var s,n,a;this.jr&&(He!=null&&(s=He.__PosthogExtensions__)!=null&&(s=s.rrweb)!=null&&s.record&&(n=He.__PosthogExtensions__)!=null&&n.initSessionRecording?this.Ur(t):(a=He.__PosthogExtensions__)==null||a.loadExternalDependency==null||a.loadExternalDependency(this._instance,this.zr,(l=>{if(l)return jo.error("could not load recorder",l);this.Ur(t)})))}stopRecording(){var t,s;(t=this.Lr)==null||t.call(this),this.Lr=void 0,(s=this.Mr)==null||s.stop()}Hr(){var t;(t=this._instance.persistence)==null||t.unregister(HS)}Br(t){if(this._instance.persistence){var s,n,a=this._instance.persistence,l=()=>{var c=t.sessionRecording===!1?void 0:t.sessionRecording,d=c==null?void 0:c.sampleRate,f=ut(d)?null:parseFloat(d);ut(f)&&this.Hr();var h=c==null?void 0:c.minimumDurationMilliseconds;a.register({[Td]:Me({cache_timestamp:Date.now(),enabled:!!c},c,{networkPayloadCapture:Me({capturePerformance:t.capturePerformance},c==null?void 0:c.networkPayloadCapture),canvasRecording:{enabled:c==null?void 0:c.recordCanvas,fps:c==null?void 0:c.canvasFps,quality:c==null?void 0:c.canvasQuality},sampleRate:f,minimumDurationMilliseconds:Ce(h)?null:h,endpoint:c==null?void 0:c.endpoint,triggerMatchType:c==null?void 0:c.triggerMatchType,masking:c==null?void 0:c.masking,urlTriggers:c==null?void 0:c.urlTriggers})})};l(),(s=this.Lr)==null||s.call(this),this.Lr=(n=this._instance.sessionManager)==null?void 0:n.onSessionId(l)}}onRemoteConfig(t){"sessionRecording"in t?t.sessionRecording!==!1?(this.Dr=!1,this.Br(t),this.Ar=!0,this.startIfEnabledOrStop()):this.Ar=!0:jo.info("skipping remote config with no sessionRecording",t)}log(t,s){var n;s===void 0&&(s="log"),(n=this.Mr)!=null&&n.log?this.Mr.log(t,s):jo.warn("log called before recorder was ready")}get zr(){var t,s,n=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.get_property(Td);return(n==null||(s=n.scriptConfig)==null?void 0:s.script)||"lazy-recorder"}qr(){var t,s=this._instance.get_property(Td);if(!s)return!1;var n=(t=(typeof s=="object"?s:JSON.parse(s)).cache_timestamp)!==null&&t!==void 0?t:Date.now();return Date.now()-n<=3e5}Ur(t){var s,n;if((s=He.__PosthogExtensions__)==null||!s.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Mr||(this.Mr=(n=He.__PosthogExtensions__)==null?void 0:n.initSessionRecording(this._instance),this.Mr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.qr()?this.Mr.start(t):this.Dr||(this.Dr=!0,jo.info("persisted remote config is stale, requesting fresh config before starting"),new wj(this._instance).load())}onRRwebEmit(t){var s;(s=this.Mr)==null||s.onRRwebEmit==null||s.onRRwebEmit(t)}overrideLinkedFlag(){var t,s;this.Mr||(s=this._instance.persistence)==null||s.register({$replay_override_linked_flag:!0}),(t=this.Mr)==null||t.overrideLinkedFlag()}overrideSampling(){var t,s;this.Mr||(s=this._instance.persistence)==null||s.register({$replay_override_sampling:!0}),(t=this.Mr)==null||t.overrideSampling()}overrideTrigger(t){var s,n;this.Mr||(n=this._instance.persistence)==null||n.register({[t==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(s=this.Mr)==null||s.overrideTrigger(t)}get sdkDebugProperties(){var t;return((t=this.Mr)==null?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,s){var n;return!((n=this.Mr)==null||!n.tryAddCustomEvent(t,s))}};var Oc={},nx=()=>{},Ao="posthog",jj=!FE&&(mn==null?void 0:mn.indexOf("MSIE"))===-1&&(mn==null?void 0:mn.indexOf("Mozilla"))===-1,pw=e=>{var t;return Me({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:W6(Ne==null?void 0:Ne.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:nx,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:e??"unset",__preview_deferred_init_extensions:!1,debug:$s&&ws($s==null?void 0:$s.search)&&$s.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(he==null||(t=he.location)==null?void 0:t.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:s=>{var n="Bad HTTP status: "+s.statusCode+" "+s.text;Ee.error(n)},get_device_id:s=>s,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:tx},error_tracking:{},_onCapture:nx,__preview_eager_load_replay:!1},(s=>({rageclick:!(s&&s>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(s&&s>="2025-05-24")||"history_change",session_recording:s&&s>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:s&&s>="2026-01-30"?"head":"body",internal_or_test_user_hostname:s&&s>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(e))},mw=e=>{var t={};Ce(e.process_person)||(t.person_profiles=e.process_person),Ce(e.xhr_headers)||(t.request_headers=e.xhr_headers),Ce(e.cookie_name)||(t.persistence_name=e.cookie_name),Ce(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),Ce(e.store_google)||(t.save_campaign_params=e.store_google),Ce(e.verbose)||(t.debug=e.verbose);var s=as({},t,e);return yt(e.property_blacklist)&&(Ce(e.property_denylist)?s.property_denylist=e.property_blacklist:yt(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:Ee.error("Invalid value for property_denylist config: "+e.property_denylist)),s};let jM=class{constructor(){this.__forceAllowLocalhost=!1}get Wr(){return this.__forceAllowLocalhost}set Wr(t){Ee.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}},kj=class Cj{get decideEndpointWasHit(){var t,s;return(t=(s=this.featureFlags)==null?void 0:s.hasLoadedFlags)!==null&&t!==void 0&&t}get flagsEndpointWasHit(){var t,s;return(t=(s=this.featureFlags)==null?void 0:s.hasLoadedFlags)!==null&&t!==void 0&&t}constructor(){this.webPerformance=new jM,this.Gr=!1,this.version=Kr.LIB_VERSION,this.bi=new C0,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=pw(),this.SentryIntegration=yE,this.sentryIntegration=t=>(function(s,n){var a=aj(s,n);return{name:ij,processEvent:l=>a(l)}})(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Vr=!1,this.Jr=null,this.Kr=null,this.Yr=null,this.featureFlags=new QE(this),this.toolbar=new SE(this),this.scrollManager=new pM(this),this.pageViewManager=new Xy(this),this.surveys=new oM(this),this.conversations=new lM(this),this.logs=new cM(this),this.experiments=new _M(this),this.exceptions=new HE(this),this.rateLimiter=new uM(this),this.requestRouter=new vM(this),this.consent=new mE(this),this.externalIntegrations=new SM(this),this.people={set:(t,s,n)=>{var a=ws(t)?{[t]:s}:t;this.setPersonProperties(a),n==null||n({})},set_once:(t,s,n)=>{var a=ws(t)?{[t]:s}:t;this.setPersonProperties(void 0,a),n==null||n({})}},this.on("eventCaptured",(t=>Ee.info('send "'+(t==null?void 0:t.event)+'"',t)))}init(t,s,n){if(n&&n!==Ao){var a,l=(a=Oc[n])!==null&&a!==void 0?a:new Cj;return l._init(t,s,n),Oc[n]=l,Oc[Ao][n]=l,l}return this._init(t,s,n)}_init(t,s,n){var a;if(s===void 0&&(s={}),Ce(t)||Lg(t))return Ee.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},s.debug=this.Xr(s.debug),this.Qr=s,this.Zr=[],s.person_profiles&&(this.Kr=s.person_profiles),this.set_config(as({},pw(s.defaults),mw(s),{name:n,token:t})),this.config.on_xhr_error&&Ee.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=s.disable_compression?void 0:Jr.GZipJS;var l=this.ts();this.persistence=new Am(this.config,l),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Am(Me({},this.config,{persistence:"sessionStorage"}),l);var c=Me({},this.persistence.props),d=Me({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.es=new dM((N=>this.rs(N)),this.config.request_queue_config),this.ss=new fM(this),this.__request_queue=[];var f=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(f||(this.sessionManager=new dw(this),this.sessionPropsManager=new uw(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(Ee.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.ns(f)}),0)):(Ee.info("Initializing extensions synchronously"),this.ns(f)),Kr.DEBUG=Kr.DEBUG||this.config.debug,Kr.DEBUG&&Ee.info("Starting in debug mode",{this:this,config:s,thisC:Me({},this.config),p:c,s:d}),((a=s.bootstrap)==null?void 0:a.distinctID)!==void 0){var h,m,g=this.config.get_device_id(Hi()),_=(h=s.bootstrap)!=null&&h.isIdentifiedID?g:s.bootstrap.distinctID;this.persistence.set_property(Yr,(m=s.bootstrap)!=null&&m.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:s.bootstrap.distinctID,$device_id:_})}if(this.os()){var v,y,S=Object.keys(((v=s.bootstrap)==null?void 0:v.featureFlags)||{}).filter((N=>{var E;return!((E=s.bootstrap)==null||(E=E.featureFlags)==null||!E[N])})).reduce(((N,E)=>{var B;return N[E]=((B=s.bootstrap)==null||(B=B.featureFlags)==null?void 0:B[E])||!1,N}),{}),j=Object.keys(((y=s.bootstrap)==null?void 0:y.featureFlagPayloads)||{}).filter((N=>S[N])).reduce(((N,E)=>{var B,F;return(B=s.bootstrap)!=null&&(B=B.featureFlagPayloads)!=null&&B[E]&&(N[E]=(F=s.bootstrap)==null||(F=F.featureFlagPayloads)==null?void 0:F[E]),N}),{});this.featureFlags.receivedFeatureFlags({featureFlags:S,featureFlagPayloads:j})}if(f)this.register_once({distinct_id:Kl,$device_id:null},"");else if(!this.get_distinct_id()){var k=this.config.get_device_id(Hi());this.register_once({distinct_id:k,$device_id:k},""),this.persistence.set_property(Yr,"anonymous")}return ps(he,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),s.segment?_E(this,(()=>this.ls())):this.ls(),Wi(this.config._onCapture)&&this.config._onCapture!==nx&&(Ee.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(N=>this.config._onCapture(N.event,N)))),this.config.ip&&Ee.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}ns(t){var s=performance.now();this.historyAutocapture=new bE(this),this.historyAutocapture.startIfEnabled();var n=[];n.push((()=>{new kE(this).startIfEnabledOrStop()})),n.push((()=>{var a;this.siteApps=new xM(this),(a=this.siteApps)==null||a.init()})),t||n.push((()=>{this.sessionRecording=new fw(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||n.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),n.push((()=>{this.autocapture=new aE(this),this.autocapture.startIfEnabled()})),n.push((()=>{this.surveys.loadIfEnabled()})),n.push((()=>{this.logs.loadIfEnabled()})),n.push((()=>{this.conversations.loadIfEnabled()})),n.push((()=>{this.productTours=new eM(this),this.productTours.loadIfEnabled()})),n.push((()=>{this.heatmaps=new RE(this),this.heatmaps.startIfEnabled()})),n.push((()=>{this.webVitalsAutocapture=new TE(this)})),n.push((()=>{this.exceptionObserver=new vE(this),this.exceptionObserver.startIfEnabledOrStop()})),n.push((()=>{this.deadClicksAutocapture=new rj(this,xE),this.deadClicksAutocapture.startIfEnabledOrStop()})),n.push((()=>{if(this.us){var a=this.us;this.us=void 0,this.wi(a)}})),this.hs(n,s)}hs(t,s){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-s>=30&&t.length>0)return void setTimeout((()=>{this.hs(t,s)}),0);var n=t.shift();if(n)try{n()}catch(l){Ee.error("Error initializing extension:",l)}}var a=Math.round(performance.now()-s);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:a}),this.config.__preview_deferred_init_extensions&&Ee.info("PostHog extensions initialized ("+a+"ms)")}wi(t){var s,n,a,l,c,d,f,h,m;if(!Ne||!Ne.body)return Ee.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.wi(t)}),500);this.config.__preview_deferred_init_extensions&&(this.us=t),this.compression=void 0,t.supportedCompression&&!this.config.disable_compression&&(this.compression=at(t.supportedCompression,Jr.GZipJS)?Jr.GZipJS:at(t.supportedCompression,Jr.Base64)?Jr.Base64:void 0),(s=t.analytics)!=null&&s.endpoint&&(this.analyticsDefaultEndpoint=t.analytics.endpoint),this.set_config({person_profiles:this.Kr?this.Kr:"identified_only"}),(n=this.siteApps)==null||n.onRemoteConfig(t),(a=this.sessionRecording)==null||a.onRemoteConfig(t),(l=this.autocapture)==null||l.onRemoteConfig(t),(c=this.heatmaps)==null||c.onRemoteConfig(t),this.surveys.onRemoteConfig(t),this.logs.onRemoteConfig(t),this.conversations.onRemoteConfig(t),(d=this.productTours)==null||d.onRemoteConfig(t),(f=this.webVitalsAutocapture)==null||f.onRemoteConfig(t),(h=this.exceptionObserver)==null||h.onRemoteConfig(t),this.exceptions.onRemoteConfig(t),(m=this.deadClicksAutocapture)==null||m.onRemoteConfig(t)}ls(){try{this.config.loaded(this)}catch(n){Ee.critical("`loaded` function failed",n)}if(this.ds(),this.config.internal_or_test_user_hostname&&$s!=null&&$s.hostname){var t=$s.hostname,s=this.config.internal_or_test_user_hostname;(typeof s=="string"?t===s:s.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.vs()}),1),new wj(this).load(),this.featureFlags.flags()}ds(){var t;this.is_capturing()&&this.config.request_batching&&((t=this.es)==null||t.enable())}_dom_loaded(){this.is_capturing()&&qi(this.__request_queue,(t=>this.rs(t))),this.__request_queue=[],this.ds()}_handle_unload(){var t,s;this.surveys.handlePageUnload(),this.config.request_batching?(this.cs()&&this.capture("$pageleave"),(t=this.es)==null||t.unload(),(s=this.ss)==null||s.unload()):this.cs()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(t){this.__loaded&&(jj?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)||(t.transport=t.transport||this.config.api_transport,t.url=jh(t.url,{ip:this.config.ip?1:0}),t.headers=Me({},this.config.request_headers,t.headers),t.compression=t.compression==="best-available"?this.compression:t.compression,t.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(s=>{var n,a,l,c=Me({},s);c.timeout=c.timeout||6e4,c.url=jh(c.url,{_:new Date().getTime().toString(),ver:Kr.LIB_VERSION,compression:c.compression});var d=(n=c.transport)!==null&&n!==void 0?n:"fetch",f=eh.filter((m=>!c.disableTransport||!m.transport||!c.disableTransport.includes(m.transport))),h=(a=(l=$S(f,(m=>m.transport===d)))==null?void 0:l.method)!==null&&a!==void 0?a:f[0].method;if(!h)throw new Error("No available transport method");h(c)})(Me({},t,{callback:s=>{var n,a;this.rateLimiter.checkForLimiting(s),s.statusCode>=400&&((n=(a=this.config).on_request_error)==null||n.call(a,s)),t.callback==null||t.callback(s)}}))))}rs(t){this.ss?this.ss.retriableRequest(t):this._send_request(t)}_execute_array(t){var s,n=[],a=[],l=[];qi(t,(d=>{d&&(s=d[0],yt(s)?l.push(d):Wi(d)?d.call(this):yt(d)&&s==="alias"?n.push(d):yt(d)&&s.indexOf("capture")!==-1&&Wi(this[s])?l.push(d):a.push(d))}));var c=function(d,f){qi(d,(function(h){if(yt(h[0])){var m=f;Lt(h,(function(g){m=m[g[0]].apply(m,g.slice(1))}))}else this[h[0]].apply(this,h.slice(1))}),f)};c(n,this),c(a,this),c(l,this)}os(){var t,s;return((t=this.config.bootstrap)==null?void 0:t.featureFlags)&&Object.keys((s=this.config.bootstrap)==null?void 0:s.featureFlags).length>0||!1}push(t){this._execute_array([t])}capture(t,s,n){var a;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.es){if(this.is_capturing())if(!Ce(t)&&ws(t)){var l=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(l&&!this.config.__preview_capture_bot_pageviews)){var c=n!=null&&n.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(c==null||!c.isRateLimited){s!=null&&s.$current_url&&!ws(s==null?void 0:s.$current_url)&&(Ee.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),s==null||delete s.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var d=new Date,f=(n==null?void 0:n.timestamp)||d,h=Hi(),m={uuid:h,event:t,properties:this.calculateEventProperties(t,s||{},f,h)};t==="$pageview"&&this.config.__preview_capture_bot_pageviews&&l&&(m.event="$bot_pageview",m.properties.$browser_type="bot"),c&&(m.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),n!=null&&n.$set&&(m.$set=n==null?void 0:n.$set);var g,_=t!=="$groupidentify",v=this.fs(n==null?void 0:n.$set_once,_);if(v&&(m.$set_once=v),(m=U6(m,n!=null&&n._noTruncate?null:this.config.properties_string_max_length)).timestamp=f,Ce(n==null?void 0:n.timestamp)||(m.properties.$event_time_override_provided=!0,m.properties.$event_time_override_system_time=d),t===Sc.DISMISSED||t===Sc.SENT){var y=s==null?void 0:s[Lm.SURVEY_ID],S=s==null?void 0:s[Lm.SURVEY_ITERATION];g={id:y,current_iteration:S},localStorage.getItem(lw(g))||localStorage.setItem(lw(g),"true"),m.$set=Me({},m.$set,{[tM({id:y,current_iteration:S},t===Sc.SENT?"responded":"dismissed")]:!0})}else t===Sc.SHOWN&&(m.$set=Me({},m.$set,{[Lm.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var j=Me({},m.properties.$set,m.$set);if(Lo(j)||this.setPersonPropertiesForFlags(j),!ut(this.config.before_send)){var k=this.ps(m);if(!k)return;m=k}this.bi.emit("eventCaptured",m);var N={method:"POST",url:(a=n==null?void 0:n._url)!==null&&a!==void 0?a:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:m,compression:"best-available",batchKey:n==null?void 0:n._batchKey};return!this.config.request_batching||n&&(n==null||!n._batchKey)||n!=null&&n.send_instantly?this.rs(N):this.es.enqueue(N),m}Ee.critical("This capture call is ignored due to client rate limiting.")}}else Ee.error("No event name provided to posthog.capture")}else Ee.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",(s=>t(s.event,s)))}calculateEventProperties(t,s,n,a,l){if(n=n||new Date,!this.persistence||!this.sessionPersistence)return s;var c=l?void 0:this.persistence.remove_event_timer(t),d=Me({},s);if(d.token=this.config.token,d.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(d.$cookieless_mode=!0),t==="$snapshot"){var f=Me({},this.persistence.properties(),this.sessionPersistence.properties());return d.distinct_id=f.distinct_id,(!ws(d.distinct_id)&&!ti(d.distinct_id)||Lg(d.distinct_id))&&Ee.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),d}var h,m=ME(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:g,windowId:_}=this.sessionManager.checkAndGetSessionAndWindowId(l,n.getTime());d.$session_id=g,d.$window_id=_}this.sessionPropsManager&&as(d,this.sessionPropsManager.getSessionProps());try{var v;this.sessionRecording&&as(d,this.sessionRecording.sdkDebugProperties),d.$sdk_debug_retry_queue_size=(v=this.ss)==null?void 0:v.length}catch(k){d.$sdk_debug_error_capturing_properties=String(k)}if(this.requestRouter.region===jc.CUSTOM&&(d.$lib_custom_api_host=this.config.api_host),h=t!=="$pageview"||l?t!=="$pageleave"||l?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,a),d=as(d,h),t==="$pageview"&&Ne&&(d.title=Ne.title),!Ce(c)){var y=n.getTime()-c;d.$duration=parseFloat((y/1e3).toFixed(3))}mn&&this.config.opt_out_useragent_filter&&(d.$browser_type=this._is_bot()?"bot":"browser"),(d=as({},m,this.persistence.properties(),this.sessionPersistence.properties(),d)).$is_identified=this._isIdentified(),yt(this.config.property_denylist)?Lt(this.config.property_denylist,(function(k){delete d[k]})):Ee.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var S=this.config.sanitize_properties;S&&(Ee.error("sanitize_properties is deprecated. Use before_send instead"),d=S(d,t));var j=this.gs();return d.$process_person_profile=j,j&&!l&&this._s("_calculate_event_properties"),d}fs(t,s){var n;if(s===void 0&&(s=!0),!this.persistence||!this.gs()||this.Gr)return t;var a=this.persistence.get_initial_props(),l=(n=this.sessionPropsManager)==null?void 0:n.getSetOnceProps(),c=as({},a,l||{},t||{}),d=this.config.sanitize_properties;return d&&(Ee.error("sanitize_properties is deprecated. Use before_send instead"),c=d(c,"$set_once")),s&&(this.Gr=!0),Lo(c)?void 0:c}register(t,s){var n;(n=this.persistence)==null||n.register(t,s)}register_once(t,s,n){var a;(a=this.persistence)==null||a.register_once(t,s,n)}register_for_session(t){var s;(s=this.sessionPersistence)==null||s.register(t)}unregister(t){var s;(s=this.persistence)==null||s.unregister(t)}unregister_for_session(t){var s;(s=this.sessionPersistence)==null||s.unregister(t)}bs(t,s){this.register({[t]:s})}getFeatureFlag(t,s){return this.featureFlags.getFeatureFlag(t,s)}getFeatureFlagPayload(t){return this.featureFlags.getFeatureFlagPayload(t)}getFeatureFlagResult(t,s){return this.featureFlags.getFeatureFlagResult(t,s)}isFeatureEnabled(t,s){return this.featureFlags.isFeatureEnabled(t,s)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(t,s,n){var a=n!=null&&n.merge?this.featureFlags.getFlagVariants():{},l=n!=null&&n.merge?this.featureFlags.getFlagPayloads():{},c=Me({},a,t),d=Me({},l,s),f={};for(var[h,m]of Object.entries(c)){var g=typeof m=="string";f[h]={key:h,enabled:!!g||!!m,variant:g?m:void 0,reason:void 0,metadata:Ce(d==null?void 0:d[h])?void 0:{id:0,version:void 0,description:void 0,payload:d[h]}}}this.featureFlags.receivedFeatureFlags({flags:f})}updateEarlyAccessFeatureEnrollment(t,s,n){this.featureFlags.updateEarlyAccessFeatureEnrollment(t,s,n)}getEarlyAccessFeatures(t,s,n){return s===void 0&&(s=!1),this.featureFlags.getEarlyAccessFeatures(t,s,n)}on(t,s){return this.bi.on(t,s)}onFeatureFlags(t){return this.featureFlags.onFeatureFlags(t)}onSurveysLoaded(t){return this.surveys.onSurveysLoaded(t)}onSessionId(t){var s,n;return(s=(n=this.sessionManager)==null?void 0:n.onSessionId(t))!==null&&s!==void 0?s:()=>{}}getSurveys(t,s){s===void 0&&(s=!1),this.surveys.getSurveys(t,s)}getActiveMatchingSurveys(t,s){s===void 0&&(s=!1),this.surveys.getActiveMatchingSurveys(t,s)}renderSurvey(t,s){this.surveys.renderSurvey(t,s)}displaySurvey(t,s){s===void 0&&(s=nM),this.surveys.displaySurvey(t,s)}cancelPendingSurvey(t){this.surveys.cancelPendingSurvey(t)}canRenderSurvey(t){return this.surveys.canRenderSurvey(t)}canRenderSurveyAsync(t,s){return s===void 0&&(s=!1),this.surveys.canRenderSurveyAsync(t,s)}identify(t,s,n){if(!this.__loaded||!this.persistence)return Ee.uninitializedWarning("posthog.identify");if(ti(t)&&(t=t.toString(),Ee.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),t)if(["distinct_id","distinctid"].includes(t.toLowerCase()))Ee.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(t!==Kl){if(this._s("posthog.identify")){var a=this.get_distinct_id();if(this.register({$user_id:t}),!this.get_property("$device_id")){var l=a;this.register_once({$had_persisted_distinct_id:!0,$device_id:l},"")}t!==a&&t!==this.get_property(vc)&&(this.unregister(vc),this.register({distinct_id:t}));var c=(this.persistence.get_property(Yr)||"anonymous")==="anonymous";t!==a&&c?(this.persistence.set_property(Yr,"identified"),this.setPersonPropertiesForFlags(Me({},n||{},s||{}),!1),this.capture("$identify",{distinct_id:t,$anon_distinct_id:a},{$set:s||{},$set_once:n||{}}),this.Yr=sw(t,s,n),this.featureFlags.setAnonymousDistinctId(a)):(s||n)&&this.setPersonProperties(s,n),t!==a&&(this.reloadFeatureFlags(),this.unregister(gh))}}else Ee.critical('The string "'+Kl+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else Ee.error("Unique user id has not been set in posthog.identify")}setPersonProperties(t,s){if((t||s)&&this._s("posthog.setPersonProperties")){var n=sw(this.get_distinct_id(),t,s);this.Yr!==n?(this.setPersonPropertiesForFlags(Me({},s||{},t||{})),this.capture("$set",{$set:t||{},$set_once:s||{}}),this.Yr=n):Ee.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(t,s,n){if(t&&s){var a=this.getGroups();a[t]!==s&&this.resetGroupPropertiesForFlags(t),this.register({$groups:Me({},a,{[t]:s})}),n&&(this.capture("$groupidentify",{$group_type:t,$group_key:s,$group_set:n}),this.setGroupPropertiesForFlags({[t]:n})),a[t]===s||n||this.reloadFeatureFlags()}else Ee.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,s){s===void 0&&(s=!0),this.featureFlags.setPersonPropertiesForFlags(t,s)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(t,s){s===void 0&&(s=!0),this._s("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(t,s)}resetGroupPropertiesForFlags(t){this.featureFlags.resetGroupPropertiesForFlags(t)}reset(t){var s,n,a,l;if(Ee.info("reset"),!this.__loaded)return Ee.uninitializedWarning("posthog.reset");var c=this.get_property("$device_id");if(this.consent.reset(),(s=this.persistence)==null||s.clear(),(n=this.sessionPersistence)==null||n.clear(),this.surveys.reset(),this.featureFlags.reset(),(a=this.persistence)==null||a.set_property(Yr,"anonymous"),(l=this.sessionManager)==null||l.resetSessionId(),this.Yr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:Kl,$device_id:null},"");else{var d=this.config.get_device_id(Hi());this.register_once({distinct_id:d,$device_id:t?d:c},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,s;return(t=(s=this.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&t!==void 0?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var{sessionId:s,sessionStartTimestamp:n}=this.sessionManager.checkAndGetSessionAndWindowId(!0),a=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+s);if(t!=null&&t.withTimestamp&&n){var l,c=(l=t.timestampLookBack)!==null&&l!==void 0?l:10;if(!n)return a;a+="?t="+Math.max(Math.floor((new Date().getTime()-n)/1e3)-c,0)}return a}alias(t,s){return t===this.get_property(IS)?(Ee.critical("Attempting to create alias for existing People user - aborting."),-2):this._s("posthog.alias")?(Ce(s)&&(s=this.get_distinct_id()),t!==s?(this.bs(vc,t),this.capture("$create_alias",{alias:t,distinct_id:s})):(Ee.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var s=Me({},this.config);if(ys(t)){var n,a,l,c,d,f,h,m;as(this.config,mw(t));var g=this.ts();(n=this.persistence)==null||n.update_config(this.config,s,g),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Am(Me({},this.config,{persistence:"sessionStorage"}),g);var _=this.Xr(this.config.debug);ei(_)&&(this.config.debug=_),ei(this.config.debug)&&(this.config.debug?(Kr.DEBUG=!0,qt.H()&&qt.G("ph_debug","true"),Ee.info("set_config",{config:t,oldConfig:s,newConfig:Me({},this.config)})):(Kr.DEBUG=!1,qt.H()&&qt.V("ph_debug"))),(a=this.exceptionObserver)==null||a.onConfigChange(),(l=this.sessionRecording)==null||l.startIfEnabledOrStop(),(c=this.autocapture)==null||c.startIfEnabled(),(d=this.heatmaps)==null||d.startIfEnabled(),(f=this.exceptionObserver)==null||f.startIfEnabledOrStop(),(h=this.deadClicksAutocapture)==null||h.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this.ys(),(m=this.externalIntegrations)==null||m.startIfEnabledOrStop()}}startSessionRecording(t){var s=t===!0,n={sampling:s||!(t==null||!t.sampling),linked_flag:s||!(t==null||!t.linked_flag),url_trigger:s||!(t==null||!t.url_trigger),event_trigger:s||!(t==null||!t.event_trigger)};if(Object.values(n).some(Boolean)){var a,l,c,d,f;(a=this.sessionManager)==null||a.checkAndGetSessionAndWindowId(),n.sampling&&((l=this.sessionRecording)==null||l.overrideSampling()),n.linked_flag&&((c=this.sessionRecording)==null||c.overrideLinkedFlag()),n.url_trigger&&((d=this.sessionRecording)==null||d.overrideTrigger("url")),n.event_trigger&&((f=this.sessionRecording)==null||f.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!((t=this.sessionRecording)==null||!t.started)}captureException(t,s){var n=new Error("PostHog syntheticException"),a=this.exceptions.buildProperties(t,{handled:!0,syntheticException:n});return this.exceptions.sendExceptionEvent(Me({},a,s))}startExceptionAutocapture(t){this.set_config({capture_exceptions:t==null||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){return this.toolbar.loadToolbar(t)}get_property(t){var s;return(s=this.persistence)==null?void 0:s.props[t]}getSessionProperty(t){var s;return(s=this.sessionPersistence)==null?void 0:s.props[t]}toString(){var t,s=(t=this.config.name)!==null&&t!==void 0?t:Ao;return s!==Ao&&(s=Ao+"."+s),s}_isIdentified(){var t,s;return((t=this.persistence)==null?void 0:t.get_property(Yr))==="identified"||((s=this.sessionPersistence)==null?void 0:s.get_property(Yr))==="identified"}gs(){var t,s;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Lo(this.getGroups())&&((t=this.persistence)==null||(t=t.props)==null||!t[vc])&&((s=this.persistence)==null||(s=s.props)==null||!s[vh]))}cs(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.gs()||this._s("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this._s("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}_s(t){return this.config.person_profiles==="never"?(Ee.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.bs(vh,!0),!0)}ts(){if(this.config.cookieless_mode==="always")return!0;var t=this.consent.isOptedOut(),s=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||t&&!!s}ys(){var t,s,n,a,l=this.ts();return((t=this.persistence)==null?void 0:t.Pi)!==l&&((n=this.persistence)==null||n.set_disabled(l)),((s=this.sessionPersistence)==null?void 0:s.Pi)!==l&&((a=this.sessionPersistence)==null||a.set_disabled(l)),l}opt_in_capturing(t){var s;if(this.config.cookieless_mode!=="always"){var n,a,l;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(n=this.sessionManager)==null||n.destroy(),(a=this.pageViewManager)==null||a.destroy(),this.sessionManager=new dw(this),this.pageViewManager=new Xy(this),this.persistence&&(this.sessionPropsManager=new uw(this,this.sessionManager,this.persistence)),this.sessionRecording=new fw(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this.ys(),this.ds(),(s=this.sessionRecording)==null||s.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(Ce(t==null?void 0:t.captureEventName)||t!=null&&t.captureEventName)&&this.capture((l=t==null?void 0:t.captureEventName)!==null&&l!==void 0?l:"$opt_in",t==null?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.vs()}else Ee.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var t,s,n;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.ys(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:Kl,$device_id:null}),(t=this.sessionManager)==null||t.destroy(),(s=this.pageViewManager)==null||s.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(n=this.sessionRecording)==null||n.stopRecording(),this.sessionRecording=void 0,this.vs())):Ee.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return t===Xr.GRANTED?"granted":t===Xr.DENIED?"denied":"pending"}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.ys()}_is_bot(){return An?Sj(An,this.config.custom_blocked_useragents):void 0}vs(){Ne&&(Ne.visibilityState==="visible"?this.Vr||(this.Vr=!0,this.capture("$pageview",{title:Ne.title},{send_instantly:!0}),this.Jr&&(Ne.removeEventListener("visibilitychange",this.Jr),this.Jr=null)):this.Jr||(this.Jr=this.vs.bind(this),ps(Ne,"visibilitychange",this.Jr)))}debug(t){t===!1?(he==null||he.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(he==null||he.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}M(){var t,s,n,a,l,c,d,f=this.Qr||{};return"advanced_disable_flags"in f?!!f.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(Ee.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(n="advanced_disable_decide",a=!1,l=Ee,c=(s="advanced_disable_flags")in(t=f)&&!ut(t[s]),d=n in t&&!ut(t[n]),c?t[s]:d?(l&&l.warn("Config field '"+n+"' is deprecated. Please use '"+s+"' instead. The old field will be removed in a future major version."),t[n]):a)}ps(t){if(ut(this.config.before_send))return t;var s=yt(this.config.before_send)?this.config.before_send:[this.config.before_send],n=t;for(var a of s){if(n=a(n),ut(n)){var l="Event '"+t.event+"' was rejected in beforeSend function";return a6(t.event)?Ee.warn(l+". This can cause unexpected behavior."):Ee.info(l),null}n.properties&&!Lo(n.properties)||Ee.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}return n}getPageViewId(){var t;return(t=this.pageViewManager.Kt)==null?void 0:t.pageViewId}captureTraceFeedback(t,s){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:s})}captureTraceMetric(t,s,n){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:s,$ai_metric_value:String(n)})}Xr(t){var s=ei(t)&&!t,n=qt.H()&&qt.q("ph_debug")==="true";return!s&&(!!n||t)}};(function(e,t){for(var s=0;s<t.length;s++)e.prototype[t[s]]=H6(e.prototype[t[s]])})(kj,["identify"]);var gw,Gc=(gw=Oc[Ao]=new kj,(function(){function e(){e.done||(e.done=!0,jj=!1,Lt(Oc,(function(t){t._dom_loaded()})))}Ne!=null&&Ne.addEventListener?Ne.readyState==="complete"?e():ps(Ne,"DOMContentLoaded",e,{capture:!1}):he&&Ee.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),gw);const kM="https://us.i.posthog.com",Nj="cc-telemetry-enabled";let rx=!1,Kc=!1;function CM(){return kM}function Ej(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(Nj);return e===null?!0:e==="true"}function Mj(e){rx&&(e?(Gc.opt_in_capturing({captureEventName:null}),Kc=!0):(Gc.opt_out_capturing(),Kc=!1))}function NM(e){typeof localStorage<"u"&&localStorage.setItem(Nj,String(e)),Mj(e)}function EM(){const e=void 0;return e?(Gc.init(e,{api_host:CM(),defaults:"2026-01-30",capture_pageview:!1,capture_pageleave:!0,capture_exceptions:!0,autocapture:!0,respect_dnt:!0}),rx=!0,Mj(Ej()),!0):(rx=!1,Kc=!1,!1)}function N0(e,t){Kc&&Gc.capture(e,t)}function Tj(e,t){Kc&&Gc.captureException(e,t)}function MM(e){N0("$pageview",{$current_url:e})}const Qo="/api",E0="campfire-auth-token";function Hh(){try{return localStorage.getItem(E0)}catch{return null}}function Aj(e){try{localStorage.setItem(E0,e)}catch{}}function TM(){try{localStorage.removeItem(E0)}catch{}}function iu(){const e=Hh();return e?{Authorization:`Bearer ${e}`}:{}}function ms(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function au(e,t,s,n){N0("api_request_succeeded",{method:e,path:t,status:n,duration_ms:Math.round(s)})}function wr(e,t,s,n,a){N0("api_request_failed",{method:e,path:t,status:a,duration_ms:Math.round(s),error:n instanceof Error?n.message:String(n)}),Tj(n,{method:e,path:t,status:a})}async function ze(e,t){const s=ms();let n=!1;try{const a=await fetch(`${Qo}${e}`,{method:"POST",headers:{"Content-Type":"application/json",...iu()},body:t?JSON.stringify(t):void 0});if(!a.ok){const l=await a.json().catch(()=>({error:a.statusText})),c=new Error(l.error||a.statusText);throw wr("POST",e,ms()-s,c,a.status),n=!0,c}return au("POST",e,ms()-s,a.status),a.json()}catch(a){throw n||wr("POST",e,ms()-s,a),a}}async function Se(e){const t=ms();let s=!1;try{const n=await fetch(`${Qo}${e}`,{headers:iu()});if(!n.ok){const a=new Error(n.statusText);throw wr("GET",e,ms()-t,a,n.status),s=!0,a}return au("GET",e,ms()-t,n.status),n.json()}catch(n){throw s||wr("GET",e,ms()-t,n),n}}async function Un(e,t){const s=ms();let n=!1;try{const a=await fetch(`${Qo}${e}`,{method:"PUT",headers:{"Content-Type":"application/json",...iu()},body:t?JSON.stringify(t):void 0});if(!a.ok){const l=await a.json().catch(()=>({error:a.statusText})),c=new Error(l.error||a.statusText);throw wr("PUT",e,ms()-s,c,a.status),n=!0,c}return au("PUT",e,ms()-s,a.status),a.json()}catch(a){throw n||wr("PUT",e,ms()-s,a),a}}async function xw(e,t){const s=ms();let n=!1;try{const a=await fetch(`${Qo}${e}`,{method:"PATCH",headers:{"Content-Type":"application/json",...iu()},body:t?JSON.stringify(t):void 0});if(!a.ok){const l=await a.json().catch(()=>({error:a.statusText})),c=new Error(l.error||a.statusText);throw wr("PATCH",e,ms()-s,c,a.status),n=!0,c}return au("PATCH",e,ms()-s,a.status),a.json()}catch(a){throw n||wr("PATCH",e,ms()-s,a),a}}async function Ks(e,t){const s=ms();let n=!1;try{const a=await fetch(`${Qo}${e}`,{method:"DELETE",headers:{...t?{"Content-Type":"application/json"}:{},...iu()},body:t?JSON.stringify(t):void 0});if(!a.ok){const l=await a.json().catch(()=>({error:a.statusText})),c=new Error(l.error||a.statusText);throw wr("DELETE",e,ms()-s,c,a.status),n=!0,c}return au("DELETE",e,ms()-s,a.status),a.json()}catch(a){throw n||wr("DELETE",e,ms()-s,a),a}}const ne={getAuthStatus:()=>Se("/auth/status"),login:e=>ze("/auth/login",{password:e}),logout:()=>ze("/auth/logout"),setupAuth:e=>ze("/auth/setup",{password:e}),disableAuth:()=>ze("/auth/disable"),createSession:e=>ze("/sessions/create",e),listSessions:()=>Se("/sessions"),killSession:e=>ze(`/sessions/${encodeURIComponent(e)}/kill`),deleteSession:e=>Ks(`/sessions/${encodeURIComponent(e)}`),relaunchSession:e=>ze(`/sessions/${encodeURIComponent(e)}/relaunch`),archiveSession:(e,t)=>ze(`/sessions/${encodeURIComponent(e)}/archive`,t),unarchiveSession:e=>ze(`/sessions/${encodeURIComponent(e)}/unarchive`),renameSession:(e,t)=>xw(`/sessions/${encodeURIComponent(e)}/name`,{name:t}),listDirs:e=>Se(`/fs/list${e?`?path=${encodeURIComponent(e)}`:""}`),getHome:()=>Se("/fs/home"),listEntries:(e,t)=>Se(`/fs/list-entries?path=${encodeURIComponent(e)}${t?"&hidden=1":""}`),listEnvs:()=>Se("/envs"),getEnv:e=>Se(`/envs/${encodeURIComponent(e)}`),createEnv:(e,t)=>ze("/envs",{name:e,variables:t}),updateEnv:(e,t)=>Un(`/envs/${encodeURIComponent(e)}`,t),deleteEnv:e=>Ks(`/envs/${encodeURIComponent(e)}`),getSettings:()=>Se("/settings"),updateSettings:e=>Un("/settings",e),getProviderAuthStatus:()=>Se("/settings/auth-status"),getRepoInfo:e=>Se(`/git/repo-info?path=${encodeURIComponent(e)}`),listBranches:e=>Se(`/git/branches?repoRoot=${encodeURIComponent(e)}`),listWorktrees:e=>Se(`/git/worktrees?repoRoot=${encodeURIComponent(e)}`),createWorktree:(e,t,s)=>ze("/git/worktree",{repoRoot:e,branch:t,...s}),removeWorktree:(e,t,s)=>Ks("/git/worktree",{repoRoot:e,worktreePath:t,force:s}),gitFetch:e=>ze("/git/fetch",{repoRoot:e}),gitPull:e=>ze("/git/pull",{cwd:e}),getPRStatus:(e,t)=>Se(`/git/pr-status?cwd=${encodeURIComponent(e)}&branch=${encodeURIComponent(t)}`),listPlugins:()=>Se("/skills"),getPlugin:e=>Se(`/skills/${encodeURIComponent(e)}`),readSkillContent:(e,t)=>Se(`/skills/${encodeURIComponent(e)}/skill/${encodeURIComponent(t)}`),readCommandContent:(e,t)=>Se(`/skills/${encodeURIComponent(e)}/command/${encodeURIComponent(t)}`),togglePlugin:(e,t)=>ze(`/skills/${encodeURIComponent(e)}/toggle`,{disabled:t}),listFolders:()=>Se("/folders"),createFolder:(e,t)=>ze("/folders",{name:e,color:t}),updateFolder:(e,t)=>xw(`/folders/${encodeURIComponent(e)}`,t),deleteFolder:e=>Ks(`/folders/${encodeURIComponent(e)}`),addSessionToFolder:(e,t)=>ze(`/folders/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}`),removeSessionFromFolder:e=>Ks(`/folders/sessions/${encodeURIComponent(e)}`),getBackends:()=>Se("/backends"),getBackendModels:e=>Se(`/backends/${encodeURIComponent(e)}/models`),getContainerStatus:()=>Se("/containers/status"),getContainerImages:()=>Se("/containers/images"),listContainers:()=>Se("/containers/list"),stopContainer:e=>ze(`/containers/${encodeURIComponent(e)}/stop`),getCloudProviderPlan:(e,t,s)=>Se(`/cloud/providers/${encodeURIComponent(e)}/plan?cwd=${encodeURIComponent(t)}&sessionId=${encodeURIComponent(s)}`),startEditor:e=>ze(`/sessions/${encodeURIComponent(e)}/editor/start`),getFileTree:e=>Se(`/fs/tree?path=${encodeURIComponent(e)}`),readFile:e=>Se(`/fs/read?path=${encodeURIComponent(e)}`),writeFile:(e,t)=>Un("/fs/write",{path:e,content:t}),getFileDiff:(e,t)=>Se(`/fs/diff?path=${encodeURIComponent(e)}${t!=null&&t.base?`&base=${encodeURIComponent(t.base)}`:""}${t!=null&&t.knownChanged?"&known_changed=1":""}${t!=null&&t.sessionId?`&session_id=${encodeURIComponent(t.sessionId)}`:""}`),getClaudeMdFiles:e=>Se(`/fs/claude-md?cwd=${encodeURIComponent(e)}`),saveClaudeMd:(e,t)=>Un("/fs/claude-md",{path:e,content:t}),getUsageLimits:()=>Se("/usage-limits"),getSessionUsageLimits:e=>Se(`/sessions/${encodeURIComponent(e)}/usage-limits`),spawnTerminal:(e,t,s)=>ze("/terminal/spawn",{cwd:e,cols:t,rows:s}),killTerminal:()=>ze("/terminal/kill"),getTerminal:()=>Se("/terminal"),checkForUpdate:()=>Se("/update-check"),forceCheckForUpdate:()=>ze("/update-check"),triggerUpdate:()=>ze("/update"),listCronJobs:()=>Se("/cron/jobs"),getCronJob:e=>Se(`/cron/jobs/${encodeURIComponent(e)}`),createCronJob:e=>ze("/cron/jobs",e),updateCronJob:(e,t)=>Un(`/cron/jobs/${encodeURIComponent(e)}`,t),deleteCronJob:e=>Ks(`/cron/jobs/${encodeURIComponent(e)}`),toggleCronJob:e=>ze(`/cron/jobs/${encodeURIComponent(e)}/toggle`),runCronJob:e=>ze(`/cron/jobs/${encodeURIComponent(e)}/run`),getCronJobExecutions:e=>Se(`/cron/jobs/${encodeURIComponent(e)}/executions`),listAgents:()=>Se("/agents"),getAgentProfile:e=>Se(`/agents/${encodeURIComponent(e)}`),createAgent:e=>ze("/agents",e),updateAgentProfile:(e,t)=>Un(`/agents/${encodeURIComponent(e)}`,t),deleteAgent:e=>Ks(`/agents/${encodeURIComponent(e)}`),toggleAgent:e=>ze(`/agents/${encodeURIComponent(e)}/toggle`),runAgent:(e,t)=>ze(`/agents/${encodeURIComponent(e)}/run`,{input:t}),getAgentExecutions:e=>Se(`/agents/${encodeURIComponent(e)}/executions`),exportAgent:e=>Se(`/agents/${encodeURIComponent(e)}/export`),importAgent:e=>ze("/agents/import",e),discoverCommands:e=>Se(`/commands${e?`?cwd=${encodeURIComponent(e)}`:""}`),readCommand:e=>Se(`/commands/read?path=${encodeURIComponent(e)}`),getSlashCommands:()=>Se("/commands/slash"),getMonitorStats:()=>Se("/monitor/stats"),listHubRecordings:()=>Se("/hub/recordings"),getHubRecording:e=>Se(`/hub/recordings/${encodeURIComponent(e)}`),getHubSummary:e=>Se(`/hub/recordings/${encodeURIComponent(e)}/summary`),updateHubTags:(e,t)=>Un(`/hub/recordings/${encodeURIComponent(e)}/tags`,{tags:t}),deleteHubRecording:e=>Ks(`/hub/recordings/${encodeURIComponent(e)}`),uploadHubRecording:(e,t)=>ze("/hub/recordings/upload",{content:e,filename:t}),importHubRecording:e=>ze("/hub/recordings/import",{filename:e}),indexAllRecordings:()=>ze("/hub/recordings/index-all"),validateRecording:e=>Se(`/hub/recordings/${encodeURIComponent(e)}/validate`),getRecordingDiagnostics:e=>Se(`/hub/recordings/${encodeURIComponent(e)}/diagnostics`),getVotingPolicy:()=>Se("/voting-policy"),setVotingPolicy:e=>Un("/voting-policy",{policy:e}),listRecordings:()=>Se("/recordings"),getRecording:e=>Se(`/recordings/${encodeURIComponent(e)}`),getSessionHistory:e=>Se(`/sessions/${encodeURIComponent(e)}/history`),forkSession:(e,t)=>ze(`/sessions/${encodeURIComponent(e)}/fork`,t),createInviteLink:(e,t="collaborator")=>ze(`/sessions/${encodeURIComponent(e)}/invite`,{role:t}),joinSession:e=>Se(`/sessions/join/${encodeURIComponent(e)}`),listGalleryEntries:e=>{var n;const t=new URLSearchParams;e!=null&&e.backend&&t.set("backend",e.backend),(e==null?void 0:e.minCost)!=null&&t.set("minCost",String(e.minCost)),(e==null?void 0:e.maxCost)!=null&&t.set("maxCost",String(e.maxCost)),(n=e==null?void 0:e.tags)!=null&&n.length&&t.set("tags",e.tags.join(",")),e!=null&&e.featured&&t.set("featured","true"),e!=null&&e.sortBy&&t.set("sortBy",e.sortBy),e!=null&&e.sortOrder&&t.set("sortOrder",e.sortOrder);const s=t.toString();return Se(`/gallery${s?`?${s}`:""}`)},getGalleryEntry:e=>Se(`/gallery/${encodeURIComponent(e)}`),createGalleryEntry:e=>ze("/gallery",e),updateGalleryEntry:(e,t)=>Un(`/gallery/${encodeURIComponent(e)}`,t),deleteGalleryEntry:e=>Ks(`/gallery/${encodeURIComponent(e)}`),voteGalleryEntry:(e,t)=>ze(`/gallery/${encodeURIComponent(e)}/vote`,{direction:t}),featureGalleryEntry:e=>ze(`/gallery/${encodeURIComponent(e)}/feature`),getClawHubStatus:()=>Se("/clawhub/status"),exportToClawHub:(e,t)=>ze(`/gallery/${encodeURIComponent(e)}/export-clawhub`,t||{}),previewSkillMd:(e,t)=>Se(`/gallery/${encodeURIComponent(e)}/skill-preview${t?`?baseUrl=${encodeURIComponent(t)}`:""}`),searchClawHub:e=>Se(`/clawhub/search?q=${encodeURIComponent(e)}`),installClawHubSkill:e=>ze("/clawhub/install",{slug:e}),getMoltbookStatus:()=>Se("/moltbook/status"),postToMoltbook:(e,t)=>ze(`/gallery/${encodeURIComponent(e)}/post-moltbook`,t||{}),createPublicReplayLink:e=>ze(`/gallery/${encodeURIComponent(e)}/public-link`),getPublicReplay:e=>Se(`/public-replay/${encodeURIComponent(e)}`),listWebhooks:()=>Se("/webhooks"),getWebhook:e=>Se(`/webhooks/${encodeURIComponent(e)}`),createWebhook:e=>ze("/webhooks",e),updateWebhook:(e,t)=>Un(`/webhooks/${encodeURIComponent(e)}`,t),deleteWebhook:e=>Ks(`/webhooks/${encodeURIComponent(e)}`),toggleWebhook:e=>ze(`/webhooks/${encodeURIComponent(e)}/toggle`),testWebhook:e=>ze(`/webhooks/${encodeURIComponent(e)}/test`),listAdapters:()=>Se("/adapters"),installAdapter:e=>ze("/adapters/install",{npmPackage:e}),uninstallAdapter:e=>Ks(`/adapters/${encodeURIComponent(e)}`),listPrompts:e=>Se(`/prompts${e!=null&&e.cwd?`?cwd=${encodeURIComponent(e.cwd)}`:""}`),getPrompt:e=>Se(`/prompts/${encodeURIComponent(e)}`),createPrompt:e=>ze("/prompts",e),updatePrompt:(e,t)=>Un(`/prompts/${encodeURIComponent(e)}`,t),deletePrompt:e=>Ks(`/prompts/${encodeURIComponent(e)}`),getLinearConnection:()=>Se("/linear/connection"),searchLinearIssues:(e,t)=>Se(`/linear/issues?query=${encodeURIComponent(e)}${t?`&limit=${t}`:""}`),getSessionMemory:e=>Se(`/sessions/${encodeURIComponent(e)}/memory`),queryMemory:(e,t,s=10)=>Se(`/sessions/${encodeURIComponent(e)}/memory/query?q=${encodeURIComponent(t)}&limit=${s}`),storeMemory:(e,t)=>ze(`/sessions/${encodeURIComponent(e)}/memory`,t),consolidateMemory:e=>ze(`/sessions/${encodeURIComponent(e)}/memory/consolidate`),getGlobalMemory:e=>Se(`/memory/global${e?`?tag=${encodeURIComponent(e)}`:""}`),getDeliberations:e=>Se(`/sessions/${encodeURIComponent(e)}/deliberations`),getDeliberation:(e,t)=>Se(`/sessions/${encodeURIComponent(e)}/deliberations/${encodeURIComponent(t)}`),respondToDeliberation:(e,t,s)=>ze(`/sessions/${encodeURIComponent(e)}/deliberations/${encodeURIComponent(t)}/respond`,s),resolveDeliberation:(e,t)=>ze(`/sessions/${encodeURIComponent(e)}/deliberations/${encodeURIComponent(t)}/resolve`),routeTask:e=>ze("/sessions/route-task",e),getCapabilities:()=>Se("/capabilities"),getCapabilityHistory:e=>{const t=new URLSearchParams;e!=null&&e.backendType&&t.set("backendType",e.backendType),e!=null&&e.taskType&&t.set("taskType",e.taskType);const s=t.toString();return Se(`/capabilities/history${s?`?${s}`:""}`)},submitCapabilityFeedback:(e,t,s)=>ze("/capabilities/feedback",{sessionId:e,taskId:t,feedback:s}),getContextStream:e=>Se(`/sessions/${encodeURIComponent(e)}/context/stream`),getConsensusState:e=>Se(`/sessions/${encodeURIComponent(e)}/context/consensus`),getContextThread:(e,t)=>Se(`/sessions/${encodeURIComponent(e)}/context/thread/${encodeURIComponent(t)}`),getLinearTeams:()=>Se("/linear/teams"),getLinearTeamStates:e=>Se(`/linear/team/${encodeURIComponent(e)}/states`),getLinearProjectMapping:e=>Se(`/linear/project-mapping${e?`?repoRoot=${encodeURIComponent(e)}`:""}`),setLinearProjectMapping:e=>ze("/linear/project-mapping",e),linkLinearIssue:(e,t)=>ze(`/linear/session/${encodeURIComponent(e)}/link-issue`,t),getLinkedIssue:e=>Se(`/linear/session/${encodeURIComponent(e)}/issue`),transitionLinearIssue:(e,t)=>ze(`/linear/issues/${encodeURIComponent(e)}/transition`,{stateId:t}),createSessionWithProgress:async(e,t)=>{const s=await fetch(`${Qo}/sessions/create-with-progress`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!s.ok){const d=await s.json().catch(()=>({error:s.statusText}));throw new Error(d.error||s.statusText)}if(!s.body)throw new Error("No response body");const n=s.body.getReader(),a=new TextDecoder;let l="",c=null;for(;;){const{done:d,value:f}=await n.read();if(d)break;l+=a.decode(f,{stream:!0});const h=l.split(`
54
+ `);l=h.pop()||"";let m="";for(const g of h)if(g.startsWith("event: "))m=g.slice(7).trim();else if(g.startsWith("data: "))try{const _=JSON.parse(g.slice(6));if(t({type:m,data:_}),m==="done"&&_.sessionId&&(c={sessionId:_.sessionId,session:_.session}),m==="error")throw new Error(_.error||"Session creation failed")}catch(_){if(!(_ instanceof Error&&_.message!=="Session creation failed"))throw _}}return c},listPipelines:()=>Se("/orchestrator/pipelines"),getPipeline:e=>Se(`/orchestrator/pipelines/${encodeURIComponent(e)}`),createPipeline:e=>ze("/orchestrator/pipelines",e),updatePipeline:(e,t)=>Un(`/orchestrator/pipelines/${encodeURIComponent(e)}`,t),deletePipeline:e=>Ks(`/orchestrator/pipelines/${encodeURIComponent(e)}`),listRuns:e=>Se(`/orchestrator/runs${e?`?pipeline_id=${encodeURIComponent(e)}`:""}`),getRun:e=>Se(`/orchestrator/runs/${encodeURIComponent(e)}`),deleteRun:e=>Ks(`/orchestrator/runs/${encodeURIComponent(e)}`),runPipeline:e=>ze(`/orchestrator/pipelines/${encodeURIComponent(e)}/run`),cancelRun:e=>ze(`/orchestrator/runs/${encodeURIComponent(e)}/cancel`),listRaces:()=>Se("/races"),getRace:e=>Se(`/races/${encodeURIComponent(e)}`),getRaceEntryDiff:(e,t)=>Se(`/races/${encodeURIComponent(e)}/entries/${encodeURIComponent(t)}/diff`),createRace:e=>ze("/races",e),pickRaceWinner:(e,t)=>ze(`/races/${encodeURIComponent(e)}/pick`,{sessionId:t}),cancelRace:e=>ze(`/races/${encodeURIComponent(e)}/cancel`),deleteRace:e=>Ks(`/races/${encodeURIComponent(e)}`)},vw=["Swift","Calm","Bold","Bright","Warm","Keen","Vast","Crisp","Agile","Noble","Vivid","Lucid","Brisk","Deft","Fleet","Grand","Lush","Prime","Sage","True","Clear","Deep","Fair","Firm","Glad","Kind","Pure","Rich","Safe","Wise","Fresh","Sharp","Steady","Quick","Gentle","Silent","Golden","Radiant","Serene","Verdant"],bw=["Falcon","River","Cedar","Stone","Ember","Frost","Bloom","Ridge","Crane","Birch","Coral","Dawn","Flint","Grove","Heron","Lark","Maple","Opal","Pearl","Quartz","Reef","Sage","Tide","Vale","Wren","Aspen","Brook","Cliff","Delta","Eagle","Fern","Harbor","Iris","Jade","Lotus","Mesa","Nova","Orbit","Pebble","Summit"];function _w(){const e=vw[Math.floor(Math.random()*vw.length)],t=bw[Math.floor(Math.random()*bw.length)];return`${e} ${t}`}function Rj(e){for(let t=0;t<100;t++){const s=_w();if(!e.has(s))return s}return _w()}let Om=null;function AM(){return Om||(Om=new AudioContext),Om}function RM(){try{const e=AM();e.state==="suspended"&&e.resume();const t=e.currentTime,s=e.createOscillator(),n=e.createGain();s.type="sine",s.frequency.setValueAtTime(659.25,t),n.gain.setValueAtTime(.3,t),n.gain.exponentialRampToValueAtTime(.001,t+.3),s.connect(n),n.connect(e.destination),s.start(t),s.stop(t+.3);const a=e.createOscillator(),l=e.createGain();a.type="sine",a.frequency.setValueAtTime(783.99,t+.15),l.gain.setValueAtTime(.001,t),l.gain.setValueAtTime(.3,t+.15),l.gain.exponentialRampToValueAtTime(.001,t+.5),a.connect(l),l.connect(e.destination),a.start(t+.15),a.stop(t+.5)}catch{}}const tr=new Map,ka=new Map,ix=new Map,th=new Map,ax=new Map,ox=new Map,kc=new Map;function sh(e){const t=e.startsWith("/"),s=e.split("/"),n=[];for(const a of s)if(!(!a||a===".")){if(a===".."){n.length>0&&n.pop();continue}n.push(a)}return`${t?"/":""}${n.join("/")}`}function Uh(e,t){return e.startsWith("/")||!t?sh(e):sh(`${t}/${e}`)}function DM(e,t){if(!t)return!0;const s=sh(t);return e===s||e.startsWith(`${s}/`)}function LM(e){let t=ax.get(e);return t||(t=new Set,ax.set(e,t)),t}function zm(e,t){const s=G.getState(),n=LM(e);for(const a of t){if(a.type!=="tool_use")continue;const{name:l,input:c,id:d}=a;if(d){if(n.has(d))continue;n.add(d)}if(l==="TodoWrite"){const f=c.todos;if(Array.isArray(f)){const h=f.map((m,g)=>({id:String(g+1),subject:m.content||"Task",description:"",activeForm:m.activeForm,status:m.status||"pending"}));s.setTasks(e,h),th.set(e,h.length)}continue}if(l==="TaskCreate"){const f=(th.get(e)||0)+1;th.set(e,f);const h={id:String(f),subject:c.subject||"Task",description:c.description||"",activeForm:c.activeForm,status:"pending"};s.addTask(e,h);continue}if(l==="TaskUpdate"){const f=c.taskId;if(f){const h={};c.status&&(h.status=c.status),c.owner&&(h.owner=c.owner),c.activeForm!==void 0&&(h.activeForm=c.activeForm),c.addBlockedBy&&(h.blockedBy=c.addBlockedBy),s.updateTask(e,f,h)}}}}function Pm(e,t){var a,l;const s=G.getState(),n=((a=s.sessions.get(e))==null?void 0:a.cwd)||((l=s.sdkSessions.find(c=>c.sessionId===e))==null?void 0:l.cwd);for(const c of t){if(c.type!=="tool_use")continue;const{name:d,input:f}=c;if((d==="Edit"||d==="Write")&&typeof f.file_path=="string"){const h=Uh(f.file_path,n);DM(h,n)&&s.addChangedFile(e,h)}}}function $m(e,t){const s=G.getState();let n=ox.get(e);n||(n=new Set,ox.set(e,n));for(const a of t){if(a.type==="tool_use"&&a.name==="Agent"){if(a.id&&n.has(a.id))continue;const l=a.input;if(l.run_in_background===!0){a.id&&n.add(a.id);let c=kc.get(e);c||(c=new Map,kc.set(e,c));const d={toolUseId:a.id,name:l.name||l.description||"Background agent",description:l.description||"",agentType:l.subagent_type||"general-purpose",status:"running",startedAt:Date.now()};c.set(a.id,{name:d.name,description:d.description,agentType:d.agentType,startedAt:d.startedAt}),s.addBackgroundAgent(e,d)}}if(a.type==="tool_result"){const l=a.tool_use_id,c=kc.get(e),d=c==null?void 0:c.get(l);if(c&&d){const f=typeof a.content=="string"?a.content:Array.isArray(a.content)?a.content.map(m=>typeof m.text=="string"?m.text:"").join(""):"",h=a.is_error===!0;s.updateBackgroundAgent(e,l,{status:h?"failed":"completed",completedAt:Date.now(),summary:f.length>200?f.slice(0,200)+"...":f}),c.delete(l),c.size===0&&kc.delete(e)}}}}function BM(e,t){const s=G.getState();t.sessionId&&(t.status==="completed"||t.status==="failed"||t.status==="timeout")&&s.markSubagentSessionTerminal(t.sessionId,t.status);const a=(s.sessionBackgroundAgents.get(e)||[]).find(c=>c.toolUseId===t.toolUseId),l={toolUseId:t.toolUseId,name:t.name,description:t.description,agentType:t.backendType,backendType:t.backendType,sessionId:t.sessionId,status:t.status==="timeout"?"timeout":t.status,startedAt:t.startedAt,completedAt:t.completedAt,summary:t.summary,costUsd:t.costUsd,durationMs:t.durationMs,filesChanged:t.filesChanged,error:t.error};a?s.updateBackgroundAgent(e,t.toolUseId,l):s.addBackgroundAgent(e,l)}function yw(e,t,s){typeof Notification>"u"||Notification.permission==="granted"&&new Notification(e,{body:t,tag:s})}function ww(e){return G.getState().sdkSessions.some(t=>t.sessionId===e&&t.state==="exited")}function Sw(e){const t=G.getState();return t.completedSubagentSessions.has(e)||t.sdkSessions.some(s=>s.sessionId===e&&s.state==="exited"&&(s.orchestrationRole==="subagent"||!!s.parentSessionId))}let OM=0,zM=0;function sc(){return`msg-${Date.now()}-${++OM}`}function PM(){return`cmsg-${Date.now()}-${++zM}`}const $M=new Set(["user_message","permission_response","interrupt","set_model","set_permission_mode","mcp_get_status","mcp_toggle","mcp_reconnect","mcp_set_servers"]),Oo=new Map;let Dj=!1;function nh(e){Dj=e}function Lj(e,t){t?Oo.set(t,e):Oo.set("__pending__",e)}function IM(e){let s=`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}/ws/browser/${e}`;const n=new URLSearchParams;let a=Oo.get(e);a||(a=Oo.get("__pending__")||void 0,a&&(Oo.delete("__pending__"),Oo.set(e,a))),a&&n.set("token",a);const l=Hh();l&&n.set("auth_token",l);const c=n.toString();return c&&(s+=`?${c}`),s}function Bj(e){return`campfire:last-seq:${e}`}function lx(e){const t=ix.get(e);if(typeof t=="number")return t;try{const s=localStorage.getItem(Bj(e)),n=s?Number(s):0,a=Number.isFinite(n)?Math.max(0,Math.floor(n)):0;return ix.set(e,a),a}catch{return 0}}function jw(e,t){const s=Math.max(0,Math.floor(t));ix.set(e,s);try{localStorage.setItem(Bj(e),String(s))}catch{}}function kw(e,t){en(e,{type:"session_ack",last_seq:t})}function Cw(e){return e.map(t=>t.type==="text"?t.text:t.type==="thinking"?t.thinking:"").filter(Boolean).join(`
55
+ `)}function FM(e,t){let s;try{s=JSON.parse(t.data)}catch{return}Oj(e,s)}function Oj(e,t,s={}){var c,d,f,h,m,g,_,v,y,S;const{processSeq:n=!0,ackSeqMessage:a=!0}=s,l=G.getState();if(n&&typeof t.seq=="number"){const j=lx(e);if(t.seq<=j)return;jw(e,t.seq),a&&kw(e,t.seq)}switch(t.type){case"session_init":{const j=l.sessions.get(e);if(l.addSession(t.session),l.setCliConnected(e,!ww(e)&&!Sw(e)),j||l.setSessionStatus(e,"idle"),!G.getState().sessionStartTimes.has(e)){const k=new Map(G.getState().sessionStartTimes);k.set(e,Date.now()),G.setState({sessionStartTimes:k})}if(!l.sessionNames.has(e)){const k=new Set(l.sessionNames.values()),N=Rj(k);l.setSessionName(e,N)}break}case"session_update":{l.updateSession(e,t.session);break}case"assistant":{const j=t.message,k=Cw(j.content),N={id:j.id,role:"assistant",content:k,contentBlocks:j.content,timestamp:t.timestamp||Date.now(),parentToolUseId:t.parent_tool_use_id,model:j.model,stopReason:j.stop_reason};if(l.appendMessage(e,N),l.setStreaming(e,null),(c=j.content)!=null&&c.length)for(const E of j.content)E.type==="tool_result"&&l.clearToolProgress(e,E.tool_use_id);l.setSessionStatus(e,"running"),l.streamingStartedAt.has(e)||l.setStreamingStats(e,{startedAt:Date.now()}),(d=j.content)!=null&&d.length&&(zm(e,j.content),Pm(e,j.content),$m(e,j.content));break}case"stream_event":{const j=t.event;if(j&&typeof j=="object"){if(j.type==="message_start"&&(l.streamingStartedAt.has(e)||l.setStreamingStats(e,{startedAt:Date.now(),outputTokens:0})),j.type==="content_block_delta"){const k=j.delta;if((k==null?void 0:k.type)==="text_delta"&&typeof k.text=="string"){const N=l.streaming.get(e)||"";l.setStreaming(e,N+k.text)}}if(j.type==="message_delta"){const k=j.usage;k!=null&&k.output_tokens&&l.setStreamingStats(e,{outputTokens:k.output_tokens})}}break}case"result":{const j=t.data,k=((f=l.sessions.get(e))==null?void 0:f.total_cost_usd)||0,N={total_cost_usd:typeof j.total_cost_usd=="number"&&j.total_cost_usd>k?j.total_cost_usd:k,num_turns:j.num_turns};if(typeof j.total_lines_added=="number"&&(N.total_lines_added=j.total_lines_added),typeof j.total_lines_removed=="number"&&(N.total_lines_removed=j.total_lines_removed),j.modelUsage){let E=0,B=0,F=0,$=0,K=0,Y=0;for(const W of Object.values(j.modelUsage))if(E+=W.inputTokens,B+=W.outputTokens,F+=W.cacheReadInputTokens,$+=W.cacheCreationInputTokens,Y+=W.costUSD??0,W.contextWindow>0){K=W.contextWindow;const L=Math.round((W.inputTokens+W.outputTokens)/W.contextWindow*100);N.context_used_percent=Math.max(0,Math.min(L,100))}N.claude_token_details={inputTokens:E,outputTokens:B,cacheReadInputTokens:F,cacheCreationInputTokens:$,contextWindow:K,costUsd:Y}}l.updateSession(e,N),l.setStreaming(e,null),l.setStreamingStats(e,null),l.clearToolProgress(e),l.setSessionStatus(e,"idle"),!document.hasFocus()&&l.notificationSound&&RM(),!document.hasFocus()&&l.notificationDesktop&&yw("Session completed","Claude finished the task",e),j.is_error&&((h=j.errors)!=null&&h.length)&&l.appendMessage(e,{id:sc(),role:"system",content:`Error: ${j.errors.join(", ")}`,timestamp:Date.now()});break}case"permission_request":{if(l.addPermission(e,t.request),!document.hasFocus()&&l.notificationDesktop){const k=t.request;yw("Permission needed",`${k.tool_name}: approve or deny`,k.request_id)}const j=t.request;if(j.tool_name&&j.input){const k=[{type:"tool_use",id:j.tool_use_id,name:j.tool_name,input:j.input}];zm(e,k),Pm(e,k),$m(e,k)}break}case"permission_cancelled":{const j=(m=l.pendingPermissions.get(e))==null?void 0:m.get(t.request_id);if(j&&(j.tool_name==="Write"||j.tool_name==="Edit")&&typeof((g=j.input)==null?void 0:g.file_path)=="string"){const k=((_=l.sessions.get(e))==null?void 0:_.cwd)||((v=l.sdkSessions.find(E=>E.sessionId===e))==null?void 0:v.cwd),N=Uh(j.input.file_path,k);l.removeChangedFile(e,N)}l.removePermission(e,t.request_id);break}case"sub_agent_update":{BM(e,t.agent);break}case"tool_progress":{l.setToolProgress(e,t.tool_use_id,{toolName:t.tool_name,elapsedSeconds:t.elapsed_time_seconds});break}case"tool_use_summary":{l.appendMessage(e,{id:sc(),role:"system",content:t.summary,timestamp:Date.now()});break}case"status_change":{t.status==="compacting"?l.setSessionStatus(e,"compacting"):l.setSessionStatus(e,t.status);break}case"auth_status":{t.error&&l.appendMessage(e,{id:sc(),role:"system",content:`Auth error: ${t.error}`,timestamp:Date.now()});break}case"error":{l.appendMessage(e,{id:sc(),role:"system",content:t.message,timestamp:Date.now()});break}case"cli_disconnected":{l.setCliConnected(e,!1),l.setCliLaunching(e,!1),l.setSessionStatus(e,null);break}case"cli_connected":{ww(e)||Sw(e)?l.setCliConnected(e,!1):l.setCliConnected(e,!0);break}case"cli_launching":{l.setCliLaunching(e,!0);break}case"session_name_update":{const j=l.sessionNames.get(e),k=j&&/^[A-Z][a-z]+ [A-Z][a-z]+$/.test(j);(!j||k)&&(l.setSessionName(e,t.name),l.markRecentlyRenamed(e));break}case"pr_status_update":{l.setPRStatus(e,{available:t.available,pr:t.pr});break}case"mcp_status":{l.setMcpServers(e,t.servers);break}case"presence_update":{l.setSessionViewers(e,t.viewers);break}case"role_assigned":{l.setMyRole(e,t.role),l.setMyViewerId(e,t.viewerId);break}case"vote_update":{l.setPermissionVotes(e,t.request_id,{votes:t.votes,votersTotal:t.voters_total,deadline:t.deadline});break}case"vote_resolved":{l.setVoteResult(e,t.request_id,{result:t.result,policy:t.policy}),setTimeout(()=>{l.clearVoteState(e,t.request_id)},3e3);break}case"message_history":{const j=[];for(let k=0;k<t.messages.length;k++){const N=t.messages[k];if(N.type==="user_message")j.push({id:N.id||sc(),role:"user",content:N.content,timestamp:N.timestamp});else if(N.type==="assistant"){const E=N.message,B=Cw(E.content);j.push({id:E.id,role:"assistant",content:B,contentBlocks:E.content,timestamp:N.timestamp||Date.now(),parentToolUseId:N.parent_tool_use_id,model:E.model,stopReason:E.stop_reason}),(y=E.content)!=null&&y.length&&(zm(e,E.content),Pm(e,E.content),$m(e,E.content))}else if(N.type==="result"){const E=N.data;E.is_error&&((S=E.errors)!=null&&S.length)&&j.push({id:`hist-error-${k}`,role:"system",content:`Error: ${E.errors.join(", ")}`,timestamp:Date.now()})}}if(j.length>0){const k=l.messages.get(e)||[];if(k.length===0)l.setMessages(e,j);else{const N=new Set(k.map(B=>B.id)),E=j.filter(B=>!N.has(B.id));if(E.length>0){const B=[...E,...k].sort((F,$)=>(F.timestamp??0)-($.timestamp??0));l.setMessages(e,B)}}}break}case"event_replay":{let j;for(const k of t.events){const N=lx(e);k.seq<=N||(jw(e,k.seq),j=k.seq,Oj(e,k.message,{processSeq:!1,ackSeqMessage:!1}))}typeof j=="number"&&kw(e,j);break}}}function Sr(e){const t=tr.get(e);if(t){if(t.readyState===WebSocket.CONNECTING||t.readyState===WebSocket.OPEN)return;t.onclose=null,t.onerror=null,tr.delete(e);try{t.close()}catch{}}G.getState().setConnectionStatus(e,"connecting");const n=new WebSocket(IM(e));tr.set(e,n),n.onopen=()=>{G.getState().setConnectionStatus(e,"connected");const a=lx(e);n.send(JSON.stringify({type:"session_subscribe",last_seq:a}));const l=ka.get(e);l&&(clearTimeout(l),ka.delete(e))},n.onmessage=a=>FM(e,a),n.onclose=()=>{tr.get(e)===n&&(tr.delete(e),G.getState().setConnectionStatus(e,"disconnected"),HM(e))},n.onerror=()=>{tr.get(e)===n&&n.close()}}function HM(e){if(ka.has(e))return;const t=setTimeout(()=>{ka.delete(e);const n=G.getState().sdkSessions.find(a=>a.sessionId===e);n&&!n.archived&&n.state!=="exited"&&Sr(e)},2e3);ka.set(e,t)}function qo(e){const t=ka.get(e);t&&(clearTimeout(t),ka.delete(e));const s=tr.get(e);s&&(tr.delete(e),s.onclose=null,s.onerror=null,s.close()),ax.delete(e),th.delete(e),ox.delete(e),kc.delete(e)}function UM(){for(const[e]of tr)qo(e)}function zj(e){if(!Dj)for(const t of e)!t.archived&&t.state!=="exited"&&Sr(t.sessionId)}function Pj(e){return new Promise((t,s)=>{const n=setInterval(()=>{const l=tr.get(e);(l==null?void 0:l.readyState)===WebSocket.OPEN&&(clearInterval(n),clearTimeout(a),t())},50),a=setTimeout(()=>{clearInterval(n),s(new Error("Connection timeout"))},1e4)})}function en(e,t){const s=tr.get(e);let n=t;if($M.has(t.type))switch(t.type){case"user_message":case"permission_response":case"interrupt":case"set_model":case"set_permission_mode":case"mcp_get_status":case"mcp_toggle":case"mcp_reconnect":case"mcp_set_servers":t.client_msg_id||(n={...t,client_msg_id:PM()});break}(s==null?void 0:s.readyState)===WebSocket.OPEN&&s.send(JSON.stringify(n))}function cx(e){en(e,{type:"mcp_get_status"})}function $j(e,t,s){en(e,{type:"mcp_toggle",serverName:t,enabled:s})}function Ij(e,t){en(e,{type:"mcp_reconnect",serverName:t})}function Fj(e,t){en(e,{type:"mcp_set_servers",servers:t})}const Hj=Object.freeze(Object.defineProperty({__proto__:null,connectAllSessions:zj,connectSession:Sr,disconnectAll:UM,disconnectSession:qo,resolveSessionFilePath:Uh,sendMcpGetStatus:cx,sendMcpReconnect:Ij,sendMcpSetServers:Fj,sendMcpToggle:$j,sendToSession:en,setInviteJoinInProgress:nh,setInviteToken:Lj,waitForConnection:Pj},Symbol.toStringTag,{value:"Module"}));function VM({onLogin:e}){const[t,s]=w.useState(""),[n,a]=w.useState(""),[l,c]=w.useState(!1);async function d(f){if(f.preventDefault(),!!t.trim()){c(!0),a("");try{const{token:h}=await ne.login(t);Aj(h),e()}catch(h){a(h instanceof Error?h.message:"Login failed")}finally{c(!1)}}}return r.jsx("div",{className:"h-[100dvh] flex items-center justify-center bg-cc-bg text-cc-fg px-4",children:r.jsxs("div",{className:"w-full max-w-sm",children:[r.jsxs("div",{className:"text-center mb-8",children:[r.jsx("img",{src:"/logo.svg",alt:"",className:"w-8 h-8 mx-auto mb-3 opacity-60"}),r.jsx("h1",{className:"text-[16px] font-semibold",children:"Campfire"}),r.jsx("p",{className:"text-[12px] text-cc-muted mt-1",children:"Enter password to continue"})]}),r.jsxs("form",{onSubmit:d,className:"space-y-4",children:[r.jsx("div",{children:r.jsx("input",{type:"password",value:t,onChange:f=>s(f.target.value),placeholder:"Password",autoFocus:!0,className:"w-full px-3 py-2 rounded-lg border border-cc-border bg-cc-input-bg text-cc-fg text-[13px] placeholder:text-cc-muted/50 focus:outline-none focus:border-cc-primary transition-colors"})}),n&&r.jsx("p",{className:"text-[12px] text-cc-error",children:n}),r.jsx("button",{type:"submit",disabled:l||!t.trim(),className:"w-full px-3 py-2 rounded-lg bg-cc-primary text-white text-[13px] font-medium hover:bg-cc-primary-hover disabled:opacity-50 transition-colors cursor-pointer",children:l?"Signing in...":"Sign In"})]}),r.jsx("p",{className:"text-[10px] text-cc-muted/40 text-center mt-6",children:"Set via CAMPFIRE_PASSWORD env var or Settings"})]})})}function WM(e,t){return e?e.includes("opus")?"Opus":e.includes("sonnet")?"Sonnet":e.includes("haiku")?"Haiku":e.includes("codex")||t==="codex"?"Codex":t==="goose"?"Goose":t==="aider"?"Aider":t==="openhands"?"OpenHands":"Claude":t==="codex"?"Codex":"Claude"}function Im({session:e,isActive:t,isArchived:s,sessionName:n,permCount:a,isRecentlyRenamed:l,onSelect:c,onStartRename:d,onArchive:f,onUnarchive:h,onDelete:m,onClearRecentlyRenamed:g,editingSessionId:_,editingName:v,setEditingName:y,onConfirmRename:S,onCancelRename:j,editInputRef:k}){const N=e.id.slice(0,8),E=n||e.model||N,B=e.status==="running",F=e.status==="compacting",$=_===e.id,K=e.orchestrationRole==="subagent"||!!e.parentSessionId,Y=!!e.subagentTerminalStatus||K&&!e.isConnected&&e.sdkState==="exited",W=s?"bg-cc-muted/30":a>0?"bg-cc-warning":Y?"bg-cc-muted/40":e.sdkState==="exited"?"bg-cc-muted/30":B?"bg-cc-success":F?"bg-cc-warning":"bg-cc-success/60",L=!s&&(a>0||B&&e.isConnected),Q=e.gitAhead>0||e.gitBehind>0||e.linesAdded>0||e.linesRemoved>0;return r.jsxs("div",{className:`relative group ${s?"opacity-40":""}`,children:[r.jsxs("button",{onClick:()=>c(e.id),onDoubleClick:V=>{V.preventDefault(),d(e.id,E)},className:`w-full pl-3 pr-7 py-1.5 ${s?"pr-14":""} text-left rounded transition-all duration-100 cursor-pointer ${t?"bg-cc-active":"hover:bg-cc-hover"}`,children:[r.jsx("span",{className:`absolute left-0 top-2 bottom-2 w-[2px] rounded-full ${W} transition-colors ${L?"animate-[pulse-dot_1.5s_ease-in-out_infinite]":""} ${t?"opacity-100":"opacity-50 group-hover:opacity-80"}`}),r.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-1.5",children:$?r.jsx("input",{ref:k,value:v,onChange:V=>y(V.target.value),onKeyDown:V=>{V.key==="Enter"?(V.preventDefault(),S()):V.key==="Escape"&&(V.preventDefault(),j()),V.stopPropagation()},onBlur:S,onClick:V=>V.stopPropagation(),onDoubleClick:V=>V.stopPropagation(),className:"text-[13px] font-medium flex-1 min-w-0 text-cc-fg bg-transparent border border-cc-border rounded px-1 py-0 outline-none focus:border-cc-primary/50"}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`text-[12px] font-medium truncate text-cc-fg leading-snug ${l?"animate-name-appear":""}`,onAnimationEnd:()=>g(e.id),children:E}),r.jsx("span",{className:"text-[9px] font-mono-code text-cc-muted/50 shrink-0",children:WM(e.model,e.backendType).toLowerCase()}),e.cronJobId&&r.jsx("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-violet-500 bg-violet-500/10",children:"Cron"}),Y&&r.jsx("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-cc-muted bg-cc-hover",title:"Subagent reached a terminal state and is offline",children:e.subagentTerminalStatus??"completed"})]})}),e.gitBranch&&r.jsxs("div",{className:"flex items-center gap-1 text-[10.5px] text-cc-muted leading-tight truncate",children:[e.isWorktree?r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-2.5 h-2.5 shrink-0 opacity-50",children:r.jsx("path",{d:"M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v5.256a2.25 2.25 0 101.5 0V5.372zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5zm7.5-9.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122V7A2.5 2.5 0 0110 9.5H6a1 1 0 000 2h4a2.5 2.5 0 012.5 2.5v.628a2.25 2.25 0 11-1.5 0V14a1 1 0 00-1-1H6a2.5 2.5 0 01-2.5-2.5V10a2.5 2.5 0 012.5-2.5h4a1 1 0 001-1V5.372a2.25 2.25 0 01-1.5-2.122z"})}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-2.5 h-2.5 shrink-0 opacity-50",children:r.jsx("path",{d:"M11.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.116.862a2.25 2.25 0 10-.862.862A4.48 4.48 0 007.25 7.5h-1.5A2.25 2.25 0 003.5 9.75v.318a2.25 2.25 0 101.5 0V9.75a.75.75 0 01.75-.75h1.5a5.98 5.98 0 003.884-1.435A2.25 2.25 0 109.634 3.362zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5z"})}),r.jsx("span",{className:"truncate",children:e.gitBranch}),e.isWorktree&&r.jsx("span",{className:"text-[8px] bg-cc-hover text-cc-muted px-0.5 rounded shrink-0",children:"wt"})]}),Q&&r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-cc-muted opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity",children:[(e.gitAhead>0||e.gitBehind>0)&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[e.gitAhead>0&&r.jsxs("span",{className:"text-green-500",children:[e.gitAhead,"↑"]}),e.gitBehind>0&&r.jsxs("span",{className:"text-cc-warning",children:[e.gitBehind,"↓"]})]}),(e.linesAdded>0||e.linesRemoved>0)&&r.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[r.jsxs("span",{className:"text-green-500",children:["+",e.linesAdded]}),r.jsxs("span",{className:"text-red-400",children:["-",e.linesRemoved]})]})]})]})]}),!s&&a>0&&r.jsx("span",{className:"absolute right-8 sm:right-2 top-1/2 -translate-y-1/2 min-w-[18px] h-[18px] flex items-center justify-center rounded-full bg-cc-warning text-white text-[10px] font-bold leading-none px-1 sm:group-hover:opacity-0 transition-opacity pointer-events-none",children:a}),s?r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:V=>h(V,e.id),className:"absolute right-8 top-1/2 -translate-y-1/2 p-1.5 sm:p-1 rounded-md opacity-100 sm:opacity-0 sm:group-hover:opacity-100 hover:bg-cc-border text-cc-muted hover:text-cc-fg transition-all cursor-pointer",title:"Restore session",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:[r.jsx("path",{d:"M8 10V3M5 5l3-3 3 3",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M3 13h10",strokeLinecap:"round"})]})}),r.jsx("button",{onClick:V=>m(V,e.id),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 sm:p-1 rounded-md opacity-100 sm:opacity-0 sm:group-hover:opacity-100 hover:bg-cc-border text-cc-muted hover:text-red-400 transition-all cursor-pointer",title:"Delete permanently",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})})})]}):r.jsx("button",{onClick:V=>f(V,e.id),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 sm:p-1 rounded-md opacity-100 sm:opacity-0 sm:group-hover:opacity-100 hover:bg-cc-border text-cc-muted hover:text-cc-fg transition-all cursor-pointer",title:"Archive session",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:[r.jsx("path",{d:"M3 3h10v2H3zM4 5v7a1 1 0 001 1h6a1 1 0 001-1V5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M6.5 8h3",strokeLinecap:"round"})]})})]})}function qM(e){if(!e)return"Older";const t=new Date,s=new Date(e);if(s.toDateString()===t.toDateString())return"Today";const n=new Date(t);return n.setDate(n.getDate()-1),s.toDateString()===n.toDateString()?"Yesterday":Date.now()-e<7*864e5?"Previous 7 Days":"Older"}const GM=["Today","Yesterday","Previous 7 Days","Older"],KM=[{label:"Terminal",hash:"#/terminal",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M2 3a1 1 0 011-1h10a1 1 0 011 1v10a1 1 0 01-1 1H3a1 1 0 01-1-1V3zm2 1.5l3 2.5-3 2.5V4.5zM8.5 10h3v1h-3v-1z"})})},{label:"Orchestrator",hash:"#/orchestrator",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M1.5 3A1.5 1.5 0 013 1.5h10A1.5 1.5 0 0114.5 3v1.5h-13V3zM1.5 6h13v1.5h-13V6zM1.5 9h13v1.5h-13V9zM1.5 12v1A1.5 1.5 0 003 14.5h10a1.5 1.5 0 001.5-1.5v-1h-13z"})})},{label:"Races",hash:"#/races",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M3 2.5A1.5 1.5 0 014.5 1h1A1.5 1.5 0 017 2.5v1A1.5 1.5 0 015.5 5h-1A1.5 1.5 0 013 3.5v-1zM9 2.5A1.5 1.5 0 0110.5 1h1A1.5 1.5 0 0113 2.5v1A1.5 1.5 0 0111.5 5h-1A1.5 1.5 0 019 3.5v-1zM3 12.5A1.5 1.5 0 014.5 11h1A1.5 1.5 0 017 12.5v1A1.5 1.5 0 015.5 15h-1A1.5 1.5 0 013 13.5v-1zM9 12.5a1.5 1.5 0 011.5-1.5h1a1.5 1.5 0 011.5 1.5v1a1.5 1.5 0 01-1.5 1.5h-1A1.5 1.5 0 019 13.5v-1zM5 6h1v1.5h4V6h1v4h-1V8.5H6V10H5V6z"})})},{label:"Kanban",hash:"#/kanban",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M1.5 2h4v12h-4V2zm.75.75v10.5h2.5V2.75h-2.5zM6 2h4v8H6V2zm.75.75v6.5h2.5v-6.5h-2.5zM10.5 2h4v10h-4V2zm.75.75v8.5h2.5v-8.5h-2.5z"})})},{label:"Monitor",hash:"#/monitor",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M1 3.5A1.5 1.5 0 012.5 2h11A1.5 1.5 0 0115 3.5v6a1.5 1.5 0 01-1.5 1.5H10v1.5h1.5a.5.5 0 010 1h-7a.5.5 0 010-1H6V11H2.5A1.5 1.5 0 011 9.5v-6zM2.5 3a.5.5 0 00-.5.5v6a.5.5 0 00.5.5h11a.5.5 0 00.5-.5v-6a.5.5 0 00-.5-.5h-11z"})})}],YM=[{label:"Environments",hash:"#/environments",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M8 1a2 2 0 012 2v1h2a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6a2 2 0 012-2h2V3a2 2 0 012-2zm0 1.5a.5.5 0 00-.5.5v1h1V3a.5.5 0 00-.5-.5zM4 5.5a.5.5 0 00-.5.5v6a.5.5 0 00.5.5h8a.5.5 0 00.5-.5V6a.5.5 0 00-.5-.5H4z"})})},{label:"Scheduled",hash:"#/scheduled",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M8 2a6 6 0 100 12A6 6 0 008 2zM0 8a8 8 0 1116 0A8 8 0 010 8zm9-3a1 1 0 10-2 0v3a1 1 0 00.293.707l2 2a1 1 0 001.414-1.414L9 7.586V5z"})})},{label:"Gallery",hash:"#/gallery",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M2 3a1 1 0 011-1h10a1 1 0 011 1v1H2V3zm0 2.5h12v7a1 1 0 01-1 1H3a1 1 0 01-1-1v-7zM4 7v3h3V7H4zm5 0v1h3V7H9zm3 2.5H9V11h3V9.5z"})})},{label:"Webhooks",hash:"#/webhooks",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M5.5 1a.5.5 0 01.5.5v2a2.5 2.5 0 005 0v-2a.5.5 0 011 0v2a3.5 3.5 0 01-3 3.465V8.5h2a.5.5 0 010 1H9v2.035A3.5 3.5 0 0112 15a.5.5 0 010-1 2.5 2.5 0 01-2.5-2.5V9.5h-3v2A2.5 2.5 0 014 14a.5.5 0 010 1 3.5 3.5 0 003-3.465V9.5H5a.5.5 0 010-1h2V6.965A3.5 3.5 0 014 3.5v-2a.5.5 0 01.5-.5 .5.5 0 01.5.5v2a2.5 2.5 0 005 0v-2a.5.5 0 01.5-.5z"})})},{label:"Recordings",hash:"#/hub",icon:r.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}),r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]})}],XM=[{label:"Adapters",hash:"#/adapters",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M2 4a2 2 0 012-2h1.5a.5.5 0 010 1H4a1 1 0 00-1 1v2.5a.5.5 0 01-1 0V4zm0 8a2 2 0 002 2h1.5a.5.5 0 000-1H4a1 1 0 01-1-1V9.5a.5.5 0 00-1 0V12zm12-8a2 2 0 00-2-2h-1.5a.5.5 0 000 1H12a1 1 0 011 1v2.5a.5.5 0 001 0V4zm0 8a2 2 0 01-2 2h-1.5a.5.5 0 010-1H12a1 1 0 001-1V9.5a.5.5 0 011 0V12zM6 8a2 2 0 114 0 2 2 0 01-4 0z"})})},{label:"Commands",hash:"#/commands",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M6.646 5.646a.5.5 0 01.708 0l2.5 2.5a.5.5 0 010 .708l-2.5 2.5a.5.5 0 01-.708-.708L8.793 8.5H1.5a.5.5 0 010-1h7.293L6.646 5.354a.5.5 0 010-.708zM12.5 2a.5.5 0 01.5.5v11a.5.5 0 01-1 0v-11a.5.5 0 01.5-.5z"})})},{label:"Agents",hash:"#/agents",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M8 8a3 3 0 100-6 3 3 0 000 6zm-5 6s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H3z"})})},{label:"Prompts",hash:"#/prompts",icon:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:[r.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),r.jsx("path",{d:"M5 5h6M5 8h6M5 11h4",strokeLinecap:"round"})]})},{label:"Skills",hash:"#/skills",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M7.657 6.247c.11-.33.576-.33.686 0l.645 1.937a2.89 2.89 0 001.829 1.828l1.936.645c.33.11.33.576 0 .686l-1.937.645a2.89 2.89 0 00-1.828 1.829l-.645 1.936a.361.361 0 01-.686 0l-.645-1.937a2.89 2.89 0 00-1.828-1.828l-1.937-.645a.361.361 0 010-.686l1.937-.645a2.89 2.89 0 001.828-1.829l.645-1.936zM3.794 1.148a.217.217 0 01.412 0l.387 1.162c.173.518.579.924 1.097 1.097l1.162.387a.217.217 0 010 .412l-1.162.387A1.734 1.734 0 004.593 5.69l-.387 1.162a.217.217 0 01-.412 0L3.407 5.69a1.734 1.734 0 00-1.097-1.097l-1.162-.387a.217.217 0 010-.412l1.162-.387A1.734 1.734 0 003.407 2.31l.387-1.162z"})})},{label:"Integrations",hash:"#/integrations",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M4.5 2a2.5 2.5 0 100 5 2.5 2.5 0 000-5zm0 1.5a1 1 0 110 2 1 1 0 010-2zM11.5 9a2.5 2.5 0 100 5 2.5 2.5 0 000-5zm0 1.5a1 1 0 110 2 1 1 0 010-2zM7.5 4.5a.5.5 0 01.5.5v2.5h1a.5.5 0 010 1H8V11a.5.5 0 01-1 0V8.5H5.5a.5.5 0 010-1H7V5a.5.5 0 01.5-.5z"})})},{label:"Memory",hash:"#/memory",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M3 2a1 1 0 00-1 1v10a1 1 0 001 1h10a1 1 0 001-1V3a1 1 0 00-1-1H3zm2 2h6a.5.5 0 010 1H5a.5.5 0 010-1zm0 2h6a.5.5 0 010 1H5a.5.5 0 010-1zm0 2h4a.5.5 0 010 1H5a.5.5 0 010-1z"})})},{label:"Router",hash:"#/router",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{fillRule:"evenodd",d:"M11.3 1.046A1 1 0 0112 2v5h4a1 1 0 01.82 1.573l-7 10A1 1 0 018 18v-5H4a1 1 0 01-.82-1.573l7-10a1 1 0 011.12-.38z",clipRule:"evenodd"})})},{label:"Collective",hash:"#/collective",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M8 0a8 8 0 110 16A8 8 0 018 0zM4.5 7.5a.5.5 0 000 1h7a.5.5 0 000-1h-7zM4 5.5a.5.5 0 01.5-.5h3a.5.5 0 010 1h-3a.5.5 0 01-.5-.5zm4.5 5a.5.5 0 000 1h3a.5.5 0 000-1h-3z"})})},{label:"ClawHub",hash:"#/clawhub",icon:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M8 0a8 8 0 100 16A8 8 0 008 0zm3.5 4.5a1 1 0 11-2 0 1 1 0 012 0zM8 13a5 5 0 01-4.33-2.5.5.5 0 01.87-.5A4 4 0 008 12a4 4 0 003.46-2 .5.5 0 01.87.5A5 5 0 018 13zm-3.5-8.5a1 1 0 110 2 1 1 0 010-2z"})})}],Bd=5;function JM(){const[e,t]=w.useState(null),[s,n]=w.useState(""),[a,l]=w.useState(!1),[c,d]=w.useState(null),[f,h]=w.useState(()=>typeof window<"u"?window.location.hash:""),[m,g]=w.useState(""),[_,v]=w.useState(!1),[y,S]=w.useState(()=>{try{const se=localStorage.getItem("cc-collapsed-nav-sections");return se?new Set(JSON.parse(se)):new Set(["Tools","Data","Config"])}catch{return new Set(["Tools","Data","Config"])}}),j=w.useRef(null),k=w.useRef(null),N=G(se=>se.sessions),E=G(se=>se.sdkSessions),B=G(se=>se.currentSessionId),F=G(se=>se.setCurrentSession),$=G(se=>se.cliConnected),K=G(se=>se.sessionStatus),Y=G(se=>se.completedSubagentSessions),W=G(se=>se.removeSession),L=G(se=>se.sessionNames),Q=G(se=>se.recentlyRenamed),V=G(se=>se.clearRecentlyRenamed),X=G(se=>se.pendingPermissions);G(se=>se.collapsedProjects),G(se=>se.toggleProjectCollapse);const[q,A]=w.useState([]),[M,O]=w.useState(!1),[U,I]=w.useState(""),[R,P]=w.useState(()=>{try{const se=localStorage.getItem("cc-collapsed-folders");return se?new Set(JSON.parse(se)):new Set}catch{return new Set}});w.useEffect(()=>{let se=!0;async function fe(){try{const ee=await ne.listSessions();if(se){G.getState().setSdkSessions(ee),zj(ee);const Ie=G.getState();for(const We of ee)if(We.name&&(!Ie.sessionNames.has(We.sessionId)||/^[A-Z][a-z]+ [A-Z][a-z]+$/.test(Ie.sessionNames.get(We.sessionId)))){const Bt=Ie.sessionNames.get(We.sessionId),ss=!!Bt&&/^[A-Z][a-z]+ [A-Z][a-z]+$/.test(Bt);Bt!==We.name&&(Ie.setSessionName(We.sessionId,We.name),ss&&Ie.markRecentlyRenamed(We.sessionId))}}}catch{}}fe();const H=setInterval(fe,5e3);return()=>{se=!1,clearInterval(H)}},[]),w.useEffect(()=>{ne.listFolders().then(A).catch(()=>{})},[]),w.useEffect(()=>{function se(fe){var H;(fe.metaKey||fe.ctrlKey)&&fe.key==="k"&&(fe.preventDefault(),(H=k.current)==null||H.focus())}return document.addEventListener("keydown",se),()=>document.removeEventListener("keydown",se)},[]);function z(se){S(fe=>{const H=new Set(fe);return H.has(se)?H.delete(se):H.add(se),localStorage.setItem("cc-collapsed-nav-sections",JSON.stringify([...H])),H})}function T(se){P(fe=>{const H=new Set(fe);return H.has(se)?H.delete(se):H.add(se),localStorage.setItem("cc-collapsed-folders",JSON.stringify([...H])),H})}async function oe(){if(U.trim())try{const se=await ne.createFolder(U.trim());A(fe=>[...fe,se]),I(""),O(!1)}catch{}}async function be(se){try{await ne.deleteFolder(se),A(fe=>fe.filter(H=>H.id!==se))}catch{}}w.useEffect(()=>{const se=()=>h(window.location.hash);return window.addEventListener("hashchange",se),()=>window.removeEventListener("hashchange",se)},[]);function re(se){G.getState().closeTerminal(),window.location.hash="",B!==se&&(F(se),Sr(se),window.innerWidth<768&&G.getState().setSidebarOpen(!1))}function ve(){G.getState().closeTerminal(),window.location.hash="",G.getState().newSession(),window.innerWidth<768&&G.getState().setSidebarOpen(!1)}w.useEffect(()=>{e&&j.current&&(j.current.focus(),j.current.select())},[e]);function Te(){e&&s.trim()&&(G.getState().setSessionName(e,s.trim()),ne.renameSession(e,s.trim()).catch(()=>{})),t(null),n("")}function Re(){t(null),n("")}function je(se,fe){t(se),n(fe)}const Ye=w.useCallback(async(se,fe)=>{se.stopPropagation();try{qo(fe),await ne.deleteSession(fe)}catch{}W(fe)},[W]),Xe=w.useCallback((se,fe)=>{se.stopPropagation();const H=E.find(We=>We.sessionId===fe),ee=N.get(fe);if((ee==null?void 0:ee.is_worktree)||(H==null?void 0:H.isWorktree)||!1){d(fe);return}Pe(fe)},[E,N]),Pe=w.useCallback(async(se,fe)=>{try{qo(se),await ne.archiveSession(se,fe?{force:!0}:void 0)}catch{}G.getState().currentSessionId===se&&G.getState().newSession();try{const H=await ne.listSessions();G.getState().setSdkSessions(H)}catch{}},[]),ye=w.useCallback(()=>{c&&(Pe(c,!0),d(null))},[c,Pe]),Ze=w.useCallback(()=>{d(null)},[]),ft=w.useCallback(async(se,fe)=>{se.stopPropagation();try{await ne.unarchiveSession(fe)}catch{}try{const H=await ne.listSessions();G.getState().setSdkSessions(H)}catch{}},[]),mt=new Set;for(const se of N.keys())mt.add(se);for(const se of E)mt.add(se.sessionId);const ts=Array.from(mt).map(se=>{var ee;const fe=N.get(se),H=E.find(Ie=>Ie.sessionId===se);return{id:se,model:(fe==null?void 0:fe.model)||(H==null?void 0:H.model)||"",cwd:(fe==null?void 0:fe.cwd)||(H==null?void 0:H.cwd)||"",gitBranch:(fe==null?void 0:fe.git_branch)||(H==null?void 0:H.gitBranch)||"",isWorktree:(fe==null?void 0:fe.is_worktree)||(H==null?void 0:H.isWorktree)||!1,gitAhead:(fe==null?void 0:fe.git_ahead)||(H==null?void 0:H.gitAhead)||0,gitBehind:(fe==null?void 0:fe.git_behind)||(H==null?void 0:H.gitBehind)||0,linesAdded:(fe==null?void 0:fe.total_lines_added)||(H==null?void 0:H.totalLinesAdded)||0,linesRemoved:(fe==null?void 0:fe.total_lines_removed)||(H==null?void 0:H.totalLinesRemoved)||0,isConnected:$.get(se)??!1,status:K.get(se)??null,sdkState:(H==null?void 0:H.state)??null,createdAt:(H==null?void 0:H.createdAt)??0,archived:(H==null?void 0:H.archived)??!1,backendType:(fe==null?void 0:fe.backend_type)||(H==null?void 0:H.backendType)||"claude",repoRoot:(fe==null?void 0:fe.repo_root)||(H==null?void 0:H.repoRoot)||"",permCount:((ee=X.get(se))==null?void 0:ee.size)??0,cronJobId:(fe==null?void 0:fe.cronJobId)||(H==null?void 0:H.cronJobId),cronJobName:(fe==null?void 0:fe.cronJobName)||(H==null?void 0:H.cronJobName),parentSessionId:(fe==null?void 0:fe.parent_session_id)||(H==null?void 0:H.parentSessionId),orchestrationRole:(fe==null?void 0:fe.orchestration_role)||(H==null?void 0:H.orchestrationRole),subagentTerminalStatus:Y.get(se)}}).sort((se,fe)=>fe.createdAt-se.createdAt),Kt=ts.filter(se=>!se.archived),Ft=ts.filter(se=>se.archived),Rt=w.useMemo(()=>{if(!m.trim())return Kt;const se=m.toLowerCase();return Kt.filter(fe=>((L==null?void 0:L.get(fe.id))||fe.id).toLowerCase().includes(se))},[Kt,m,L]),Hs=w.useMemo(()=>{const se=new Set;for(const fe of q)for(const H of fe.sessionIds)se.add(H);return se},[q]),gs=w.useMemo(()=>{const se=Rt.filter(H=>!Hs.has(H.id)),fe={};for(const H of se){const ee=qM(H.createdAt);fe[ee]||(fe[ee]=[]),fe[ee].push(H)}return GM.filter(H=>{var ee;return(ee=fe[H])==null?void 0:ee.length}).map(H=>({label:H,sessions:fe[H]}))},[Rt,Hs]),vt=w.useMemo(()=>q.map(se=>{const fe=new Set(se.sessionIds),H=Rt.filter(ee=>fe.has(ee.id));return{folder:se,sessions:H}}).filter(se=>se.sessions.length>0),[q,Rt]),de=w.useMemo(()=>{const se=[];for(const{sessions:fe}of vt)se.push(...fe);for(const{sessions:fe}of gs)se.push(...fe);return se},[vt,gs]).length,_e=!m&&!_&&de>Bd,Be=w.useMemo(()=>{if(!_e)return gs;let se=Bd;for(const{sessions:fe}of vt)se-=fe.length;return se<=0?[]:gs.map(({label:fe,sessions:H})=>{if(se<=0)return null;const ee=H.slice(0,se);return se-=ee.length,{label:fe,sessions:ee}}).filter(Boolean)},[_e,gs,vt]),qe={onSelect:re,onStartRename:je,onArchive:Xe,onUnarchive:ft,onDelete:Ye,onClearRecentlyRenamed:V,editingSessionId:e,editingName:s,setEditingName:n,onConfirmRename:Te,onCancelRename:Re,editInputRef:j};function Je(se){G.getState().closeTerminal(),window.location.hash=se,window.innerWidth<768&&G.getState().setSidebarOpen(!1)}function Yt(se){return se.hash==="#/integrations"?f.startsWith("#/integrations"):f===se.hash}function xs(se,fe){const H=y.has(se);return r.jsxs("div",{className:"mb-0.5",children:[r.jsxs("button",{onClick:()=>z(se),className:"w-[calc(100%-12px)] mx-1.5 flex items-center gap-2 px-2.5 py-2 rounded-lg text-[10px] font-semibold text-cc-fg/50 uppercase tracking-widest hover:text-cc-fg/70 hover:bg-cc-hover/40 cursor-pointer transition-colors",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 transition-transform duration-200 ${H?"":"rotate-90"}`,children:r.jsx("path",{d:"M6 3l5 5-5 5V3z"})}),se]}),!H&&r.jsx("div",{className:"space-y-0.5",children:fe.map(ee=>r.jsxs("button",{onClick:()=>Je(ee.hash),className:`w-[calc(100%-12px)] flex items-center gap-2.5 rounded-lg mx-1.5 px-2.5 py-[7px] text-[12px] font-medium transition-all duration-150 cursor-pointer ${Yt(ee)?"bg-cc-primary/10 text-cc-primary":"text-cc-fg/70 hover:text-cc-fg hover:bg-cc-hover/60"}`,"aria-current":Yt(ee)?"page":void 0,children:[r.jsx("span",{className:"w-6 h-6 rounded-md bg-cc-hover/50 flex items-center justify-center shrink-0",children:ee.icon}),ee.label]},ee.hash))})]})}return r.jsxs("aside",{className:"w-[240px] h-full flex flex-col bg-cc-sidebar",role:"navigation",children:[r.jsx("div",{className:"px-3 pt-3 pb-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("img",{src:"/logo.svg",alt:"",className:"w-5 h-5 opacity-80"}),r.jsx("span",{className:"text-[13px] font-semibold text-cc-fg tracking-tight",children:"Campfire"})]}),r.jsxs("button",{onClick:ve,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium bg-cc-primary text-white hover:opacity-90 shadow-sm transition-all duration-200 cursor-pointer",title:"New Session",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"w-3 h-3",children:r.jsx("path",{d:"M8 3v10M3 8h10"})}),"New"]})]})}),r.jsx("div",{className:"px-3 pt-1 pb-2",role:"search",children:r.jsxs("div",{className:"relative",children:[r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-cc-muted pointer-events-none",children:[r.jsx("circle",{cx:"7",cy:"7",r:"4.5"}),r.jsx("path",{d:"M10.5 10.5L14 14",strokeLinecap:"round"})]}),r.jsx("input",{ref:k,type:"text",placeholder:"Search...",value:m,onChange:se=>g(se.target.value),className:"w-full pl-7 pr-14 py-1.5 text-[11px] rounded-lg border border-transparent bg-cc-hover/50 text-cc-fg placeholder:text-cc-fg/50 focus:outline-none focus:bg-cc-bg focus:border-cc-border focus:ring-1 focus:ring-cc-primary/30 transition-all duration-200","aria-label":"Search sessions"}),m?r.jsx("button",{onClick:()=>g(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 rounded-md text-cc-muted hover:text-cc-fg transition-all duration-200 cursor-pointer","aria-label":"Clear search",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3 h-3",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})})}):r.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-[9px] text-cc-fg/45 font-mono pointer-events-none select-none",children:"Ctrl+K"})]})}),r.jsxs("div",{className:"flex-1 overflow-y-auto flex flex-col",children:[c&&r.jsx("div",{className:"mx-3 mb-2 p-2.5 rounded-xl bg-amber-500/10 border border-amber-500/20 shadow-sm",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-amber-500 shrink-0 mt-0.5",children:r.jsx("path",{d:"M8.982 1.566a1.13 1.13 0 00-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 01-1.1 0L7.1 5.995A.905.905 0 018 5zm.002 6a1 1 0 110 2 1 1 0 010-2z"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("p",{className:"text-[11px] text-cc-fg leading-snug",children:["Archiving will ",r.jsx("strong",{children:"delete the worktree"})," and any uncommitted changes."]}),r.jsxs("div",{className:"flex gap-2 mt-2",children:[r.jsx("button",{onClick:Ze,className:"px-2.5 py-1 text-[11px] font-medium rounded-lg bg-cc-hover text-cc-muted hover:text-cc-fg transition-all duration-200 cursor-pointer",children:"Cancel"}),r.jsx("button",{onClick:ye,className:"px-2.5 py-1 text-[11px] font-medium rounded-lg bg-red-500/10 text-red-500 hover:bg-red-500/20 transition-all duration-200 cursor-pointer",children:"Archive"})]})]})]})}),r.jsxs("div",{className:"px-1.5",children:[r.jsxs("div",{className:"px-1.5 py-2 flex items-center justify-between",children:[r.jsx("span",{className:"text-[10px] font-semibold text-cc-fg/50 uppercase tracking-widest",children:"Sessions"}),de>0&&r.jsx("span",{className:"text-[10px] text-cc-fg/45 tabular-nums",children:de})]}),Kt.length===0&&Ft.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center px-3 py-8 text-center",children:[r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-7 h-7 text-cc-fg/35 mb-2",children:r.jsx("path",{d:"M12 20.25c4.97 0 9-3.694 9-8.25s-4.03-8.25-9-8.25S3 7.444 3 12c0 2.104.859 4.023 2.273 5.48.432.447.74 1.04.586 1.641a4.483 4.483 0 01-.923 1.785A5.969 5.969 0 006 21c1.282 0 2.47-.402 3.445-1.087.81.22 1.668.337 2.555.337z",strokeLinecap:"round",strokeLinejoin:"round"})}),r.jsxs("p",{className:"text-[11px] text-cc-muted leading-relaxed",children:["No sessions yet.",r.jsx("br",{}),"Click ",r.jsx("strong",{children:"New"})," to start."]})]}):r.jsxs(r.Fragment,{children:[vt.map(({folder:se,sessions:fe})=>{const H=R.has(se.id);return r.jsxs("div",{className:"mb-0.5",children:[r.jsxs("div",{className:"flex items-center group",children:[r.jsxs("button",{onClick:()=>T(se.id),className:"flex-1 flex items-center gap-1.5 rounded-lg px-2 py-1 text-[10px] font-semibold text-cc-muted uppercase tracking-wider hover:text-cc-fg hover:bg-cc-hover/50 transition-all duration-200 cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 transition-transform duration-200 ${H?"":"rotate-90"}`,children:r.jsx("path",{d:"M6 3l5 5-5 5V3z"})}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 opacity-50",style:se.color?{color:se.color}:void 0,children:r.jsx("path",{d:"M1 3.5A1.5 1.5 0 012.5 2h3.379a1.5 1.5 0 011.06.44l.622.621a.5.5 0 00.353.146H13.5A1.5 1.5 0 0115 4.707V12.5a1.5 1.5 0 01-1.5 1.5h-11A1.5 1.5 0 011 12.5v-9z"})}),r.jsx("span",{className:"truncate",children:se.name}),r.jsx("span",{className:"text-cc-fg/50 ml-auto tabular-nums",children:fe.length})]}),r.jsx("button",{onClick:()=>be(se.id),className:"opacity-0 group-hover:opacity-100 px-1 rounded-md text-cc-muted hover:text-cc-error hover:bg-cc-hover/50 transition-all duration-200 cursor-pointer",title:"Delete folder",children:r.jsx("svg",{viewBox:"0 0 16 16",className:"w-3 h-3",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})})})]}),!H&&fe.map(ee=>{var Ie;return r.jsx(Im,{session:ee,isActive:ee.id===B,sessionName:L==null?void 0:L.get(ee.id),permCount:((Ie=X.get(ee.id))==null?void 0:Ie.size)??0,isRecentlyRenamed:Q.has(ee.id),...qe},ee.id)})]},se.id)}),M&&r.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 mb-1",children:[r.jsx("input",{type:"text",value:U,onChange:se=>I(se.target.value),onKeyDown:se=>{se.key==="Enter"&&oe(),se.key==="Escape"&&O(!1)},placeholder:"Folder name",className:"flex-1 px-2 py-0.5 text-[11px] rounded-lg border border-cc-border bg-cc-bg text-cc-fg focus:outline-none focus:ring-1 focus:ring-cc-primary/30 transition-all duration-200",autoFocus:!0}),r.jsx("button",{onClick:oe,className:"text-[10px] text-cc-primary hover:text-cc-primary-hover cursor-pointer",children:"+"})]}),q.length>0||M?r.jsxs("button",{onClick:()=>O(!M),className:"w-full flex items-center gap-1.5 px-2 py-1 mb-1 text-[10px] text-cc-fg/50 hover:text-cc-muted transition-all duration-200 cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("path",{d:"M8 2a.75.75 0 01.75.75v4.5h4.5a.75.75 0 010 1.5h-4.5v4.5a.75.75 0 01-1.5 0v-4.5h-4.5a.75.75 0 010-1.5h4.5v-4.5A.75.75 0 018 2z"})}),r.jsx("span",{children:"New folder"})]}):null,(_e?Be:gs).map(({label:se,sessions:fe})=>r.jsxs("div",{className:"mb-1",children:[r.jsx("div",{className:"px-2 pt-3 pb-1",children:r.jsx("span",{className:"text-[10px] font-medium text-cc-fg/45 uppercase tracking-wider",children:se})}),fe.map(H=>{var ee;return r.jsx(Im,{session:H,isActive:H.id===B,sessionName:L==null?void 0:L.get(H.id),permCount:((ee=X.get(H.id))==null?void 0:ee.size)??0,isRecentlyRenamed:Q.has(H.id),...qe},H.id)})]},se)),de>Bd&&!m&&r.jsxs("button",{onClick:()=>v(!_),className:"w-full flex items-center justify-center gap-1.5 py-2.5 mt-1 text-[11px] text-cc-fg/55 hover:text-cc-primary transition-colors cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 transition-transform duration-200 ${_?"rotate-180":""}`,children:r.jsx("path",{d:"M8 10.5l-4-4h8l-4 4z"})}),_?"Show less":`Show ${de-Bd} more`]}),m&&Rt.length===0&&r.jsxs("p",{className:"px-3 py-4 text-[11px] text-cc-muted text-center",children:['No sessions matching "',m,'"']}),Ft.length>0&&r.jsxs("div",{className:"mt-2 pt-2 border-t border-cc-border/30",children:[r.jsxs("button",{onClick:()=>l(!a),className:"w-full flex items-center gap-1.5 rounded-lg px-2 py-2 text-[10px] font-medium text-cc-fg/50 uppercase tracking-wider hover:text-cc-fg/70 hover:bg-cc-hover/40 transition-all duration-200 cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 transition-transform duration-200 ${a?"rotate-90":""}`,children:r.jsx("path",{d:"M6 3l5 5-5 5V3z"})}),"Archived",r.jsx("span",{className:"rounded-full bg-cc-hover text-cc-muted text-[10px] px-1.5 ml-auto",children:Ft.length})]}),a&&r.jsx("div",{className:"space-y-0.5 mt-0.5",children:Ft.map(se=>{var fe;return r.jsx(Im,{session:se,isActive:B===se.id,isArchived:!0,sessionName:L.get(se.id),permCount:((fe=X.get(se.id))==null?void 0:fe.size)??0,isRecentlyRenamed:Q.has(se.id),...qe},se.id)})})]})]})]}),r.jsx("div",{className:"flex-1 min-h-4"}),r.jsxs("div",{className:"pt-2 pb-1",children:[r.jsx("div",{className:"h-px bg-cc-border/30 mx-3 mb-3"}),xs("Tools",KM),xs("Data",YM),xs("Config",XM)]})]}),r.jsx("div",{className:"px-3 py-2.5 border-t border-cc-border/40",children:r.jsxs("button",{onClick:()=>{f==="#/settings"?window.location.hash="":Je("#/settings")},className:`w-full flex items-center gap-2.5 rounded-lg px-2.5 py-[7px] text-[12px] font-medium transition-all duration-150 cursor-pointer ${f==="#/settings"?"bg-cc-primary/10 text-cc-primary":"text-cc-fg/70 hover:text-cc-fg hover:bg-cc-hover/60"}`,"aria-current":f==="#/settings"?"page":void 0,children:[r.jsx("span",{className:"w-6 h-6 rounded-md bg-cc-hover/50 flex items-center justify-center shrink-0",children:r.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{fillRule:"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.53 1.53 0 01-2.29.95c-1.35-.8-2.92.77-2.12 2.12.54.9.07 2.04-.95 2.29-1.56.38-1.56 2.6 0 2.98 1.02.25 1.49 1.39.95 2.29-.8 1.35.77 2.92 2.12 2.12.9-.54 2.04-.07 2.29.95.38 1.56 2.6 1.56 2.98 0 .25-1.02 1.39-1.49 2.29-.95 1.35.8 2.92-.77 2.12-2.12-.54-.9-.07-2.04.95-2.29 1.56-.38 1.56-2.6 0-2.98-1.02-.25-1.49-1.39-.95-2.29.8-1.35-.77-2.92-2.12-2.12-.9.54-2.04.07-2.29-.95zM10 13a3 3 0 100-6 3 3 0 000 6z",clipRule:"evenodd"})})}),"Settings"]})})]})}const QM="modulepreload",ZM=function(e){return"/"+e},Nw={},Xi=function(t,s,n){let a=Promise.resolve();if(s&&s.length>0){let c=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),f=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));a=c(s.map(h=>{if(h=ZM(h),h in Nw)return;Nw[h]=!0;const m=h.endsWith(".css"),g=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${g}`))return;const _=document.createElement("link");if(_.rel=m?"stylesheet":QM,m||(_.as="script"),_.crossOrigin="",_.href=h,f&&_.setAttribute("nonce",f),document.head.appendChild(_),m)return new Promise((v,y)=>{_.addEventListener("load",v),_.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${h}`)))})}))}function l(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return a.then(c=>{for(const d of c||[])d.status==="rejected"&&l(d.reason);return t().catch(l)})};function eT(e,t){const s={};return(e[e.length-1]===""?[...e,""]:e).join((s.padRight?" ":"")+","+(s.padLeft===!1?"":" ")).trim()}const tT=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,sT=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nT={};function Ew(e,t){return(nT.jsx?sT:tT).test(e)}const rT=/[ \t\n\f\r]/g;function iT(e){return typeof e=="object"?e.type==="text"?Mw(e.value):!1:Mw(e)}function Mw(e){return e.replace(rT,"")===""}class ou{constructor(t,s,n){this.normal=s,this.property=t,n&&(this.space=n)}}ou.prototype.normal={};ou.prototype.property={};ou.prototype.space=void 0;function Uj(e,t){const s={},n={};for(const a of e)Object.assign(s,a.property),Object.assign(n,a.normal);return new ou(s,n,t)}function ux(e){return e.toLowerCase()}class xn{constructor(t,s){this.attribute=s,this.property=t}}xn.prototype.attribute="";xn.prototype.booleanish=!1;xn.prototype.boolean=!1;xn.prototype.commaOrSpaceSeparated=!1;xn.prototype.commaSeparated=!1;xn.prototype.defined=!1;xn.prototype.mustUseProperty=!1;xn.prototype.number=!1;xn.prototype.overloadedBoolean=!1;xn.prototype.property="";xn.prototype.spaceSeparated=!1;xn.prototype.space=void 0;let aT=0;const tt=La(),ds=La(),dx=La(),we=La(),Dt=La(),Fo=La(),Mn=La();function La(){return 2**++aT}const hx=Object.freeze(Object.defineProperty({__proto__:null,boolean:tt,booleanish:ds,commaOrSpaceSeparated:Mn,commaSeparated:Fo,number:we,overloadedBoolean:dx,spaceSeparated:Dt},Symbol.toStringTag,{value:"Module"})),Fm=Object.keys(hx);class M0 extends xn{constructor(t,s,n,a){let l=-1;if(super(t,s),Tw(this,"space",a),typeof n=="number")for(;++l<Fm.length;){const c=Fm[l];Tw(this,Fm[l],(n&hx[c])===hx[c])}}}M0.prototype.defined=!0;function Tw(e,t,s){s&&(e[t]=s)}function Zo(e){const t={},s={};for(const[n,a]of Object.entries(e.properties)){const l=new M0(n,e.transform(e.attributes||{},n),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(n)&&(l.mustUseProperty=!0),t[n]=l,s[ux(n)]=n,s[ux(l.attribute)]=n}return new ou(t,s,e.space)}const Vj=Zo({properties:{ariaActiveDescendant:null,ariaAtomic:ds,ariaAutoComplete:null,ariaBusy:ds,ariaChecked:ds,ariaColCount:we,ariaColIndex:we,ariaColSpan:we,ariaControls:Dt,ariaCurrent:null,ariaDescribedBy:Dt,ariaDetails:null,ariaDisabled:ds,ariaDropEffect:Dt,ariaErrorMessage:null,ariaExpanded:ds,ariaFlowTo:Dt,ariaGrabbed:ds,ariaHasPopup:null,ariaHidden:ds,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Dt,ariaLevel:we,ariaLive:null,ariaModal:ds,ariaMultiLine:ds,ariaMultiSelectable:ds,ariaOrientation:null,ariaOwns:Dt,ariaPlaceholder:null,ariaPosInSet:we,ariaPressed:ds,ariaReadOnly:ds,ariaRelevant:null,ariaRequired:ds,ariaRoleDescription:Dt,ariaRowCount:we,ariaRowIndex:we,ariaRowSpan:we,ariaSelected:ds,ariaSetSize:we,ariaSort:null,ariaValueMax:we,ariaValueMin:we,ariaValueNow:we,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Wj(e,t){return t in e?e[t]:t}function qj(e,t){return Wj(e,t.toLowerCase())}const oT=Zo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Fo,acceptCharset:Dt,accessKey:Dt,action:null,allow:null,allowFullScreen:tt,allowPaymentRequest:tt,allowUserMedia:tt,alt:null,as:null,async:tt,autoCapitalize:null,autoComplete:Dt,autoFocus:tt,autoPlay:tt,blocking:Dt,capture:null,charSet:null,checked:tt,cite:null,className:Dt,cols:we,colSpan:null,content:null,contentEditable:ds,controls:tt,controlsList:Dt,coords:we|Fo,crossOrigin:null,data:null,dateTime:null,decoding:null,default:tt,defer:tt,dir:null,dirName:null,disabled:tt,download:dx,draggable:ds,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:tt,formTarget:null,headers:Dt,height:we,hidden:dx,high:we,href:null,hrefLang:null,htmlFor:Dt,httpEquiv:Dt,id:null,imageSizes:null,imageSrcSet:null,inert:tt,inputMode:null,integrity:null,is:null,isMap:tt,itemId:null,itemProp:Dt,itemRef:Dt,itemScope:tt,itemType:Dt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:tt,low:we,manifest:null,max:null,maxLength:we,media:null,method:null,min:null,minLength:we,multiple:tt,muted:tt,name:null,nonce:null,noModule:tt,noValidate:tt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:tt,optimum:we,pattern:null,ping:Dt,placeholder:null,playsInline:tt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:tt,referrerPolicy:null,rel:Dt,required:tt,reversed:tt,rows:we,rowSpan:we,sandbox:Dt,scope:null,scoped:tt,seamless:tt,selected:tt,shadowRootClonable:tt,shadowRootDelegatesFocus:tt,shadowRootMode:null,shape:null,size:we,sizes:null,slot:null,span:we,spellCheck:ds,src:null,srcDoc:null,srcLang:null,srcSet:null,start:we,step:null,style:null,tabIndex:we,target:null,title:null,translate:null,type:null,typeMustMatch:tt,useMap:null,value:ds,width:we,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Dt,axis:null,background:null,bgColor:null,border:we,borderColor:null,bottomMargin:we,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:tt,declare:tt,event:null,face:null,frame:null,frameBorder:null,hSpace:we,leftMargin:we,link:null,longDesc:null,lowSrc:null,marginHeight:we,marginWidth:we,noResize:tt,noHref:tt,noShade:tt,noWrap:tt,object:null,profile:null,prompt:null,rev:null,rightMargin:we,rules:null,scheme:null,scrolling:ds,standby:null,summary:null,text:null,topMargin:we,valueType:null,version:null,vAlign:null,vLink:null,vSpace:we,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:tt,disableRemotePlayback:tt,prefix:null,property:null,results:we,security:null,unselectable:null},space:"html",transform:qj}),lT=Zo({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Mn,accentHeight:we,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:we,amplitude:we,arabicForm:null,ascent:we,attributeName:null,attributeType:null,azimuth:we,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:we,by:null,calcMode:null,capHeight:we,className:Dt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:we,diffuseConstant:we,direction:null,display:null,dur:null,divisor:we,dominantBaseline:null,download:tt,dx:null,dy:null,edgeMode:null,editable:null,elevation:we,enableBackground:null,end:null,event:null,exponent:we,externalResourcesRequired:null,fill:null,fillOpacity:we,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Fo,g2:Fo,glyphName:Fo,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:we,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:we,horizOriginX:we,horizOriginY:we,id:null,ideographic:we,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:we,k:we,k1:we,k2:we,k3:we,k4:we,kernelMatrix:Mn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:we,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:we,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:we,overlineThickness:we,paintOrder:null,panose1:null,path:null,pathLength:we,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Dt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:we,pointsAtY:we,pointsAtZ:we,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Mn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Mn,rev:Mn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Mn,requiredFeatures:Mn,requiredFonts:Mn,requiredFormats:Mn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:we,specularExponent:we,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:we,strikethroughThickness:we,string:null,stroke:null,strokeDashArray:Mn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:we,strokeOpacity:we,strokeWidth:null,style:null,surfaceScale:we,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Mn,tabIndex:we,tableValues:null,target:null,targetX:we,targetY:we,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Mn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:we,underlineThickness:we,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:we,values:null,vAlphabetic:we,vMathematical:we,vectorEffect:null,vHanging:we,vIdeographic:we,version:null,vertAdvY:we,vertOriginX:we,vertOriginY:we,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:we,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Wj}),Gj=Zo({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Kj=Zo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:qj}),Yj=Zo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),cT={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},uT=/[A-Z]/g,Aw=/-[a-z]/g,dT=/^data[-\w.:]+$/i;function hT(e,t){const s=ux(t);let n=t,a=xn;if(s in e.normal)return e.property[e.normal[s]];if(s.length>4&&s.slice(0,4)==="data"&&dT.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(Aw,pT);n="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!Aw.test(l)){let c=l.replace(uT,fT);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=M0}return new a(n,t)}function fT(e){return"-"+e.toLowerCase()}function pT(e){return e.charAt(1).toUpperCase()}const mT=Uj([Vj,oT,Gj,Kj,Yj],"html"),T0=Uj([Vj,lT,Gj,Kj,Yj],"svg");function gT(e){return e.join(" ").trim()}var ko={},Hm,Rw;function xT(){if(Rw)return Hm;Rw=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,s=/^\s*/,n=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g,f=`
56
+ `,h="/",m="*",g="",_="comment",v="declaration";function y(j,k){if(typeof j!="string")throw new TypeError("First argument must be a string");if(!j)return[];k=k||{};var N=1,E=1;function B(q){var A=q.match(t);A&&(N+=A.length);var M=q.lastIndexOf(f);E=~M?q.length-M:E+q.length}function F(){var q={line:N,column:E};return function(A){return A.position=new $(q),W(),A}}function $(q){this.start=q,this.end={line:N,column:E},this.source=k.source}$.prototype.content=j;function K(q){var A=new Error(k.source+":"+N+":"+E+": "+q);if(A.reason=q,A.filename=k.source,A.line=N,A.column=E,A.source=j,!k.silent)throw A}function Y(q){var A=q.exec(j);if(A){var M=A[0];return B(M),j=j.slice(M.length),A}}function W(){Y(s)}function L(q){var A;for(q=q||[];A=Q();)A!==!1&&q.push(A);return q}function Q(){var q=F();if(!(h!=j.charAt(0)||m!=j.charAt(1))){for(var A=2;g!=j.charAt(A)&&(m!=j.charAt(A)||h!=j.charAt(A+1));)++A;if(A+=2,g===j.charAt(A-1))return K("End of comment missing");var M=j.slice(2,A-2);return E+=2,B(M),j=j.slice(A),E+=2,q({type:_,comment:M})}}function V(){var q=F(),A=Y(n);if(A){if(Q(),!Y(a))return K("property missing ':'");var M=Y(l),O=q({type:v,property:S(A[0].replace(e,g)),value:M?S(M[0].replace(e,g)):g});return Y(c),O}}function X(){var q=[];L(q);for(var A;A=V();)A!==!1&&(q.push(A),L(q));return q}return W(),X()}function S(j){return j?j.replace(d,g):g}return Hm=y,Hm}var Dw;function vT(){if(Dw)return ko;Dw=1;var e=ko&&ko.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(ko,"__esModule",{value:!0}),ko.default=s;const t=e(xT());function s(n,a){let l=null;if(!n||typeof n!="string")return l;const c=(0,t.default)(n),d=typeof a=="function";return c.forEach(f=>{if(f.type!=="declaration")return;const{property:h,value:m}=f;d?a(h,m,f):m&&(l=l||{},l[h]=m)}),l}return ko}var nc={},Lw;function bT(){if(Lw)return nc;Lw=1,Object.defineProperty(nc,"__esModule",{value:!0}),nc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,s=/^[^-]+$/,n=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,l=function(h){return!h||s.test(h)||e.test(h)},c=function(h,m){return m.toUpperCase()},d=function(h,m){return"".concat(m,"-")},f=function(h,m){return m===void 0&&(m={}),l(h)?h:(h=h.toLowerCase(),m.reactCompat?h=h.replace(a,d):h=h.replace(n,d),h.replace(t,c))};return nc.camelCase=f,nc}var rc,Bw;function _T(){if(Bw)return rc;Bw=1;var e=rc&&rc.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(vT()),s=bT();function n(a,l){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(d,f){d&&f&&(c[(0,s.camelCase)(d,l)]=f)}),c}return n.default=n,rc=n,rc}var yT=_T();const wT=p0(yT),Xj=Jj("end"),A0=Jj("start");function Jj(e){return t;function t(s){const n=s&&s.position&&s.position[e]||{};if(typeof n.line=="number"&&n.line>0&&typeof n.column=="number"&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset=="number"&&n.offset>-1?n.offset:void 0}}}function ST(e){const t=A0(e),s=Xj(e);if(t&&s)return{start:t,end:s}}function zc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Ow(e.position):"start"in e||"end"in e?Ow(e):"line"in e||"column"in e?fx(e):""}function fx(e){return zw(e&&e.line)+":"+zw(e&&e.column)}function Ow(e){return fx(e&&e.start)+"-"+fx(e&&e.end)}function zw(e){return e&&typeof e=="number"?e:1}class qs extends Error{constructor(t,s,n){super(),typeof s=="string"&&(n=s,s=void 0);let a="",l={},c=!1;if(s&&("line"in s&&"column"in s?l={place:s}:"start"in s&&"end"in s?l={place:s}:"type"in s?l={ancestors:[s],place:s.position}:l={...s}),typeof t=="string"?a=t:!l.cause&&t&&(c=!0,a=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof n=="string"){const f=n.indexOf(":");f===-1?l.ruleId=n:(l.source=n.slice(0,f),l.ruleId=n.slice(f+1))}if(!l.place&&l.ancestors&&l.ancestors){const f=l.ancestors[l.ancestors.length-1];f&&(l.place=f.position)}const d=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=d?d.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=d?d.line:void 0,this.name=zc(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=c&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}qs.prototype.file="";qs.prototype.name="";qs.prototype.reason="";qs.prototype.message="";qs.prototype.stack="";qs.prototype.column=void 0;qs.prototype.line=void 0;qs.prototype.ancestors=void 0;qs.prototype.cause=void 0;qs.prototype.fatal=void 0;qs.prototype.place=void 0;qs.prototype.ruleId=void 0;qs.prototype.source=void 0;const R0={}.hasOwnProperty,jT=new Map,kT=/[A-Z]/g,CT=new Set(["table","tbody","thead","tfoot","tr"]),NT=new Set(["td","th"]),Qj="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function ET(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const s=t.filePath||void 0;let n;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");n=OT(s,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");n=BT(s,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:n,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:s,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?T0:mT,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=Zj(a,e,void 0);return l&&typeof l!="string"?l:a.create(e,a.Fragment,{children:l||void 0},void 0)}function Zj(e,t,s){if(t.type==="element")return MT(e,t,s);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return TT(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return RT(e,t,s);if(t.type==="mdxjsEsm")return AT(e,t);if(t.type==="root")return DT(e,t,s);if(t.type==="text")return LT(e,t)}function MT(e,t,s){const n=e.schema;let a=n;t.tagName.toLowerCase()==="svg"&&n.space==="html"&&(a=T0,e.schema=a),e.ancestors.push(t);const l=tk(e,t.tagName,!1),c=zT(e,t);let d=L0(e,t);return CT.has(t.tagName)&&(d=d.filter(function(f){return typeof f=="string"?!iT(f):!0})),ek(e,c,l,t),D0(c,d),e.ancestors.pop(),e.schema=n,e.create(t,l,c,s)}function TT(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Yc(e,t.position)}function AT(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Yc(e,t.position)}function RT(e,t,s){const n=e.schema;let a=n;t.name==="svg"&&n.space==="html"&&(a=T0,e.schema=a),e.ancestors.push(t);const l=t.name===null?e.Fragment:tk(e,t.name,!0),c=PT(e,t),d=L0(e,t);return ek(e,c,l,t),D0(c,d),e.ancestors.pop(),e.schema=n,e.create(t,l,c,s)}function DT(e,t,s){const n={};return D0(n,L0(e,t)),e.create(t,e.Fragment,n,s)}function LT(e,t){return t.value}function ek(e,t,s,n){typeof s!="string"&&s!==e.Fragment&&e.passNode&&(t.node=n)}function D0(e,t){if(t.length>0){const s=t.length>1?t:t[0];s&&(e.children=s)}}function BT(e,t,s){return n;function n(a,l,c,d){const h=Array.isArray(c.children)?s:t;return d?h(l,c,d):h(l,c)}}function OT(e,t){return s;function s(n,a,l,c){const d=Array.isArray(l.children),f=A0(n);return t(a,l,c,d,{columnNumber:f?f.column-1:void 0,fileName:e,lineNumber:f?f.line:void 0},void 0)}}function zT(e,t){const s={};let n,a;for(a in t.properties)if(a!=="children"&&R0.call(t.properties,a)){const l=$T(e,a,t.properties[a]);if(l){const[c,d]=l;e.tableCellAlignToStyle&&c==="align"&&typeof d=="string"&&NT.has(t.tagName)?n=d:s[c]=d}}if(n){const l=s.style||(s.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=n}return s}function PT(e,t){const s={};for(const n of t.attributes)if(n.type==="mdxJsxExpressionAttribute")if(n.data&&n.data.estree&&e.evaluater){const l=n.data.estree.body[0];l.type;const c=l.expression;c.type;const d=c.properties[0];d.type,Object.assign(s,e.evaluater.evaluateExpression(d.argument))}else Yc(e,t.position);else{const a=n.name;let l;if(n.value&&typeof n.value=="object")if(n.value.data&&n.value.data.estree&&e.evaluater){const d=n.value.data.estree.body[0];d.type,l=e.evaluater.evaluateExpression(d.expression)}else Yc(e,t.position);else l=n.value===null?!0:n.value;s[a]=l}return s}function L0(e,t){const s=[];let n=-1;const a=e.passKeys?new Map:jT;for(;++n<t.children.length;){const l=t.children[n];let c;if(e.passKeys){const f=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(f){const h=a.get(f)||0;c=f+"-"+h,a.set(f,h+1)}}const d=Zj(e,l,c);d!==void 0&&s.push(d)}return s}function $T(e,t,s){const n=hT(e.schema,t);if(!(s==null||typeof s=="number"&&Number.isNaN(s))){if(Array.isArray(s)&&(s=n.commaSeparated?eT(s):gT(s)),n.property==="style"){let a=typeof s=="object"?s:IT(e,String(s));return e.stylePropertyNameCase==="css"&&(a=FT(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&n.space?cT[n.property]||n.property:n.attribute,s]}}function IT(e,t){try{return wT(t,{reactCompat:!0})}catch(s){if(e.ignoreInvalidStyle)return{};const n=s,a=new qs("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=Qj+"#cannot-parse-style-attribute",a}}function tk(e,t,s){let n;if(!s)n={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let l=-1,c;for(;++l<a.length;){const d=Ew(a[l])?{type:"Identifier",name:a[l]}:{type:"Literal",value:a[l]};c=c?{type:"MemberExpression",object:c,property:d,computed:!!(l&&d.type==="Literal"),optional:!1}:d}n=c}else n=Ew(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(n.type==="Literal"){const a=n.value;return R0.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(n);Yc(e)}function Yc(e,t){const s=new qs("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=Qj+"#cannot-handle-mdx-estrees-without-createevaluater",s}function FT(e){const t={};let s;for(s in e)R0.call(e,s)&&(t[HT(s)]=e[s]);return t}function HT(e){let t=e.replace(kT,UT);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function UT(e){return"-"+e.toLowerCase()}const Um={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},VT={};function B0(e,t){const s=VT,n=typeof s.includeImageAlt=="boolean"?s.includeImageAlt:!0,a=typeof s.includeHtml=="boolean"?s.includeHtml:!0;return sk(e,n,a)}function sk(e,t,s){if(WT(e)){if("value"in e)return e.type==="html"&&!s?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Pw(e.children,t,s)}return Array.isArray(e)?Pw(e,t,s):""}function Pw(e,t,s){const n=[];let a=-1;for(;++a<e.length;)n[a]=sk(e[a],t,s);return n.join("")}function WT(e){return!!(e&&typeof e=="object")}const $w=document.createElement("i");function O0(e){const t="&"+e+";";$w.innerHTML=t;const s=$w.textContent;return s.charCodeAt(s.length-1)===59&&e!=="semi"||s===t?!1:s}function Rn(e,t,s,n){const a=e.length;let l=0,c;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,s=s>0?s:0,n.length<1e4)c=Array.from(n),c.unshift(t,s),e.splice(...c);else for(s&&e.splice(t,s);l<n.length;)c=n.slice(l,l+1e4),c.unshift(t,0),e.splice(...c),l+=1e4,t+=1e4}function Gn(e,t){return e.length>0?(Rn(e,e.length,0,t),e):t}const Iw={}.hasOwnProperty;function nk(e){const t={};let s=-1;for(;++s<e.length;)qT(t,e[s]);return t}function qT(e,t){let s;for(s in t){const a=(Iw.call(e,s)?e[s]:void 0)||(e[s]={}),l=t[s];let c;if(l)for(c in l){Iw.call(a,c)||(a[c]=[]);const d=l[c];GT(a[c],Array.isArray(d)?d:d?[d]:[])}}}function GT(e,t){let s=-1;const n=[];for(;++s<t.length;)(t[s].add==="after"?e:n).push(t[s]);Rn(e,0,0,n)}function rk(e,t){const s=Number.parseInt(e,t);return s<9||s===11||s>13&&s<32||s>126&&s<160||s>55295&&s<57344||s>64975&&s<65008||(s&65535)===65535||(s&65535)===65534||s>1114111?"�":String.fromCodePoint(s)}function sr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const tn=Ji(/[A-Za-z]/),Ws=Ji(/[\dA-Za-z]/),KT=Ji(/[#-'*+\--9=?A-Z^-~]/);function Ch(e){return e!==null&&(e<32||e===127)}const px=Ji(/\d/),YT=Ji(/[\dA-Fa-f]/),XT=Ji(/[!-/:-@[-`{-~]/);function Ue(e){return e!==null&&e<-2}function At(e){return e!==null&&(e<0||e===32)}function ot(e){return e===-2||e===-1||e===32}const Vh=Ji(new RegExp("\\p{P}|\\p{S}","u")),Ma=Ji(/\s/);function Ji(e){return t;function t(s){return s!==null&&s>-1&&e.test(String.fromCharCode(s))}}function el(e){const t=[];let s=-1,n=0,a=0;for(;++s<e.length;){const l=e.charCodeAt(s);let c="";if(l===37&&Ws(e.charCodeAt(s+1))&&Ws(e.charCodeAt(s+2)))a=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(c=String.fromCharCode(l));else if(l>55295&&l<57344){const d=e.charCodeAt(s+1);l<56320&&d>56319&&d<57344?(c=String.fromCharCode(l,d),a=1):c="�"}else c=String.fromCharCode(l);c&&(t.push(e.slice(n,s),encodeURIComponent(c)),n=s+a+1,c=""),a&&(s+=a,a=0)}return t.join("")+e.slice(n)}function ht(e,t,s,n){const a=n?n-1:Number.POSITIVE_INFINITY;let l=0;return c;function c(f){return ot(f)?(e.enter(s),d(f)):t(f)}function d(f){return ot(f)&&l++<a?(e.consume(f),d):(e.exit(s),t(f))}}const JT={tokenize:QT};function QT(e){const t=e.attempt(this.parser.constructs.contentInitial,n,a);let s;return t;function n(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),ht(e,t,"linePrefix")}function a(d){return e.enter("paragraph"),l(d)}function l(d){const f=e.enter("chunkText",{contentType:"text",previous:s});return s&&(s.next=f),s=f,c(d)}function c(d){if(d===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(d);return}return Ue(d)?(e.consume(d),e.exit("chunkText"),l):(e.consume(d),c)}}const ZT={tokenize:eA},Fw={tokenize:tA};function eA(e){const t=this,s=[];let n=0,a,l,c;return d;function d(E){if(n<s.length){const B=s[n];return t.containerState=B[1],e.attempt(B[0].continuation,f,h)(E)}return h(E)}function f(E){if(n++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&N();const B=t.events.length;let F=B,$;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){$=t.events[F][1].end;break}k(n);let K=B;for(;K<t.events.length;)t.events[K][1].end={...$},K++;return Rn(t.events,F+1,0,t.events.slice(B)),t.events.length=K,h(E)}return d(E)}function h(E){if(n===s.length){if(!a)return _(E);if(a.currentConstruct&&a.currentConstruct.concrete)return y(E);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Fw,m,g)(E)}function m(E){return a&&N(),k(n),_(E)}function g(E){return t.parser.lazy[t.now().line]=n!==s.length,c=t.now().offset,y(E)}function _(E){return t.containerState={},e.attempt(Fw,v,y)(E)}function v(E){return n++,s.push([t.currentConstruct,t.containerState]),_(E)}function y(E){if(E===null){a&&N(),k(0),e.consume(E);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:l}),S(E)}function S(E){if(E===null){j(e.exit("chunkFlow"),!0),k(0),e.consume(E);return}return Ue(E)?(e.consume(E),j(e.exit("chunkFlow")),n=0,t.interrupt=void 0,d):(e.consume(E),S)}function j(E,B){const F=t.sliceStream(E);if(B&&F.push(null),E.previous=l,l&&(l.next=E),l=E,a.defineSkip(E.start),a.write(F),t.parser.lazy[E.start.line]){let $=a.events.length;for(;$--;)if(a.events[$][1].start.offset<c&&(!a.events[$][1].end||a.events[$][1].end.offset>c))return;const K=t.events.length;let Y=K,W,L;for(;Y--;)if(t.events[Y][0]==="exit"&&t.events[Y][1].type==="chunkFlow"){if(W){L=t.events[Y][1].end;break}W=!0}for(k(n),$=K;$<t.events.length;)t.events[$][1].end={...L},$++;Rn(t.events,Y+1,0,t.events.slice(K)),t.events.length=$}}function k(E){let B=s.length;for(;B-- >E;){const F=s[B];t.containerState=F[1],F[0].exit.call(t,e)}s.length=E}function N(){a.write([null]),l=void 0,a=void 0,t.containerState._closeFlow=void 0}}function tA(e,t,s){return ht(e,e.attempt(this.parser.constructs.document,t,s),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Go(e){if(e===null||At(e)||Ma(e))return 1;if(Vh(e))return 2}function Wh(e,t,s){const n=[];let a=-1;for(;++a<e.length;){const l=e[a].resolveAll;l&&!n.includes(l)&&(t=l(t,s),n.push(l))}return t}const mx={name:"attention",resolveAll:sA,tokenize:nA};function sA(e,t){let s=-1,n,a,l,c,d,f,h,m;for(;++s<e.length;)if(e[s][0]==="enter"&&e[s][1].type==="attentionSequence"&&e[s][1]._close){for(n=s;n--;)if(e[n][0]==="exit"&&e[n][1].type==="attentionSequence"&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[s][1]).charCodeAt(0)){if((e[n][1]._close||e[s][1]._open)&&(e[s][1].end.offset-e[s][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[s][1].end.offset-e[s][1].start.offset)%3))continue;f=e[n][1].end.offset-e[n][1].start.offset>1&&e[s][1].end.offset-e[s][1].start.offset>1?2:1;const g={...e[n][1].end},_={...e[s][1].start};Hw(g,-f),Hw(_,f),c={type:f>1?"strongSequence":"emphasisSequence",start:g,end:{...e[n][1].end}},d={type:f>1?"strongSequence":"emphasisSequence",start:{...e[s][1].start},end:_},l={type:f>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[s][1].start}},a={type:f>1?"strong":"emphasis",start:{...c.start},end:{...d.end}},e[n][1].end={...c.start},e[s][1].start={...d.end},h=[],e[n][1].end.offset-e[n][1].start.offset&&(h=Gn(h,[["enter",e[n][1],t],["exit",e[n][1],t]])),h=Gn(h,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",l,t]]),h=Gn(h,Wh(t.parser.constructs.insideSpan.null,e.slice(n+1,s),t)),h=Gn(h,[["exit",l,t],["enter",d,t],["exit",d,t],["exit",a,t]]),e[s][1].end.offset-e[s][1].start.offset?(m=2,h=Gn(h,[["enter",e[s][1],t],["exit",e[s][1],t]])):m=0,Rn(e,n-1,s-n+3,h),s=n+h.length-m-2;break}}for(s=-1;++s<e.length;)e[s][1].type==="attentionSequence"&&(e[s][1].type="data");return e}function nA(e,t){const s=this.parser.constructs.attentionMarkers.null,n=this.previous,a=Go(n);let l;return c;function c(f){return l=f,e.enter("attentionSequence"),d(f)}function d(f){if(f===l)return e.consume(f),d;const h=e.exit("attentionSequence"),m=Go(f),g=!m||m===2&&a||s.includes(f),_=!a||a===2&&m||s.includes(n);return h._open=!!(l===42?g:g&&(a||!_)),h._close=!!(l===42?_:_&&(m||!g)),t(f)}}function Hw(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const rA={name:"autolink",tokenize:iA};function iA(e,t,s){let n=0;return a;function a(v){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(v){return tn(v)?(e.consume(v),c):v===64?s(v):h(v)}function c(v){return v===43||v===45||v===46||Ws(v)?(n=1,d(v)):h(v)}function d(v){return v===58?(e.consume(v),n=0,f):(v===43||v===45||v===46||Ws(v))&&n++<32?(e.consume(v),d):(n=0,h(v))}function f(v){return v===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),t):v===null||v===32||v===60||Ch(v)?s(v):(e.consume(v),f)}function h(v){return v===64?(e.consume(v),m):KT(v)?(e.consume(v),h):s(v)}function m(v){return Ws(v)?g(v):s(v)}function g(v){return v===46?(e.consume(v),n=0,m):v===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),t):_(v)}function _(v){if((v===45||Ws(v))&&n++<63){const y=v===45?_:g;return e.consume(v),y}return s(v)}}const lu={partial:!0,tokenize:aA};function aA(e,t,s){return n;function n(l){return ot(l)?ht(e,a,"linePrefix")(l):a(l)}function a(l){return l===null||Ue(l)?t(l):s(l)}}const ik={continuation:{tokenize:lA},exit:cA,name:"blockQuote",tokenize:oA};function oA(e,t,s){const n=this;return a;function a(c){if(c===62){const d=n.containerState;return d.open||(e.enter("blockQuote",{_container:!0}),d.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),l}return s(c)}function l(c){return ot(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function lA(e,t,s){const n=this;return a;function a(c){return ot(c)?ht(e,l,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):l(c)}function l(c){return e.attempt(ik,t,s)(c)}}function cA(e){e.exit("blockQuote")}const ak={name:"characterEscape",tokenize:uA};function uA(e,t,s){return n;function n(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),a}function a(l){return XT(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):s(l)}}const ok={name:"characterReference",tokenize:dA};function dA(e,t,s){const n=this;let a=0,l,c;return d;function d(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),f}function f(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),l=31,c=Ws,m(g))}function h(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,c=YT,m):(e.enter("characterReferenceValue"),l=7,c=px,m(g))}function m(g){if(g===59&&a){const _=e.exit("characterReferenceValue");return c===Ws&&!O0(n.sliceSerialize(_))?s(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(g)&&a++<l?(e.consume(g),m):s(g)}}const Uw={partial:!0,tokenize:fA},Vw={concrete:!0,name:"codeFenced",tokenize:hA};function hA(e,t,s){const n=this,a={partial:!0,tokenize:F};let l=0,c=0,d;return f;function f($){return h($)}function h($){const K=n.events[n.events.length-1];return l=K&&K[1].type==="linePrefix"?K[2].sliceSerialize(K[1],!0).length:0,d=$,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),m($)}function m($){return $===d?(c++,e.consume($),m):c<3?s($):(e.exit("codeFencedFenceSequence"),ot($)?ht(e,g,"whitespace")($):g($))}function g($){return $===null||Ue($)?(e.exit("codeFencedFence"),n.interrupt?t($):e.check(Uw,S,B)($)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),_($))}function _($){return $===null||Ue($)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g($)):ot($)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ht(e,v,"whitespace")($)):$===96&&$===d?s($):(e.consume($),_)}function v($){return $===null||Ue($)?g($):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y($))}function y($){return $===null||Ue($)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g($)):$===96&&$===d?s($):(e.consume($),y)}function S($){return e.attempt(a,B,j)($)}function j($){return e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),k}function k($){return l>0&&ot($)?ht(e,N,"linePrefix",l+1)($):N($)}function N($){return $===null||Ue($)?e.check(Uw,S,B)($):(e.enter("codeFlowValue"),E($))}function E($){return $===null||Ue($)?(e.exit("codeFlowValue"),N($)):(e.consume($),E)}function B($){return e.exit("codeFenced"),t($)}function F($,K,Y){let W=0;return L;function L(A){return $.enter("lineEnding"),$.consume(A),$.exit("lineEnding"),Q}function Q(A){return $.enter("codeFencedFence"),ot(A)?ht($,V,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):V(A)}function V(A){return A===d?($.enter("codeFencedFenceSequence"),X(A)):Y(A)}function X(A){return A===d?(W++,$.consume(A),X):W>=c?($.exit("codeFencedFenceSequence"),ot(A)?ht($,q,"whitespace")(A):q(A)):Y(A)}function q(A){return A===null||Ue(A)?($.exit("codeFencedFence"),K(A)):Y(A)}}}function fA(e,t,s){const n=this;return a;function a(c){return c===null?s(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l)}function l(c){return n.parser.lazy[n.now().line]?s(c):t(c)}}const Vm={name:"codeIndented",tokenize:mA},pA={partial:!0,tokenize:gA};function mA(e,t,s){const n=this;return a;function a(h){return e.enter("codeIndented"),ht(e,l,"linePrefix",5)(h)}function l(h){const m=n.events[n.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?c(h):s(h)}function c(h){return h===null?f(h):Ue(h)?e.attempt(pA,c,f)(h):(e.enter("codeFlowValue"),d(h))}function d(h){return h===null||Ue(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),d)}function f(h){return e.exit("codeIndented"),t(h)}}function gA(e,t,s){const n=this;return a;function a(c){return n.parser.lazy[n.now().line]?s(c):Ue(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):ht(e,l,"linePrefix",5)(c)}function l(c){const d=n.events[n.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(c):Ue(c)?a(c):s(c)}}const xA={name:"codeText",previous:bA,resolve:vA,tokenize:_A};function vA(e){let t=e.length-4,s=3,n,a;if((e[s][1].type==="lineEnding"||e[s][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(n=s;++n<t;)if(e[n][1].type==="codeTextData"){e[s][1].type="codeTextPadding",e[t][1].type="codeTextPadding",s+=2,t-=2;break}}for(n=s-1,t++;++n<=t;)a===void 0?n!==t&&e[n][1].type!=="lineEnding"&&(a=n):(n===t||e[n][1].type==="lineEnding")&&(e[a][1].type="codeTextData",n!==a+2&&(e[a][1].end=e[n-1][1].end,e.splice(a+2,n-a-2),t-=n-a-2,n=a+2),a=void 0);return e}function bA(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function _A(e,t,s){let n=0,a,l;return c;function c(g){return e.enter("codeText"),e.enter("codeTextSequence"),d(g)}function d(g){return g===96?(e.consume(g),n++,d):(e.exit("codeTextSequence"),f(g))}function f(g){return g===null?s(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),f):g===96?(l=e.enter("codeTextSequence"),a=0,m(g)):Ue(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),f):(e.enter("codeTextData"),h(g))}function h(g){return g===null||g===32||g===96||Ue(g)?(e.exit("codeTextData"),f(g)):(e.consume(g),h)}function m(g){return g===96?(e.consume(g),a++,m):a===n?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(l.type="codeTextData",h(g))}}class yA{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,s){const n=s??Number.POSITIVE_INFINITY;return n<this.left.length?this.left.slice(t,n):t>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(t,s,n){const a=s||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return n&&ic(this.left,n),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),ic(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ic(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const s=this.left.splice(t,Number.POSITIVE_INFINITY);ic(this.right,s.reverse())}else{const s=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ic(this.left,s.reverse())}}}function ic(e,t){let s=0;if(t.length<1e4)e.push(...t);else for(;s<t.length;)e.push(...t.slice(s,s+1e4)),s+=1e4}function lk(e){const t={};let s=-1,n,a,l,c,d,f,h;const m=new yA(e);for(;++s<m.length;){for(;s in t;)s=t[s];if(n=m.get(s),s&&n[1].type==="chunkFlow"&&m.get(s-1)[1].type==="listItemPrefix"&&(f=n[1]._tokenizer.events,l=0,l<f.length&&f[l][1].type==="lineEndingBlank"&&(l+=2),l<f.length&&f[l][1].type==="content"))for(;++l<f.length&&f[l][1].type!=="content";)f[l][1].type==="chunkText"&&(f[l][1]._isInFirstContentOfListItem=!0,l++);if(n[0]==="enter")n[1].contentType&&(Object.assign(t,wA(m,s)),s=t[s],h=!0);else if(n[1]._container){for(l=s,a=void 0;l--;)if(c=m.get(l),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(a&&(m.get(a)[1].type="lineEndingBlank"),c[1].type="lineEnding",a=l);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;a&&(n[1].end={...m.get(a)[1].start},d=m.slice(a,s),d.unshift(n),m.splice(a,s-a+1,d))}}return Rn(e,0,Number.POSITIVE_INFINITY,m.slice(0)),!h}function wA(e,t){const s=e.get(t)[1],n=e.get(t)[2];let a=t-1;const l=[];let c=s._tokenizer;c||(c=n.parser[s.contentType](s.start),s._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const d=c.events,f=[],h={};let m,g,_=-1,v=s,y=0,S=0;const j=[S];for(;v;){for(;e.get(++a)[1]!==v;);l.push(a),v._tokenizer||(m=n.sliceStream(v),v.next||m.push(null),g&&c.defineSkip(v.start),v._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(m),v._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),g=v,v=v.next}for(v=s;++_<d.length;)d[_][0]==="exit"&&d[_-1][0]==="enter"&&d[_][1].type===d[_-1][1].type&&d[_][1].start.line!==d[_][1].end.line&&(S=_+1,j.push(S),v._tokenizer=void 0,v.previous=void 0,v=v.next);for(c.events=[],v?(v._tokenizer=void 0,v.previous=void 0):j.pop(),_=j.length;_--;){const k=d.slice(j[_],j[_+1]),N=l.pop();f.push([N,N+k.length-1]),e.splice(N,2,k)}for(f.reverse(),_=-1;++_<f.length;)h[y+f[_][0]]=y+f[_][1],y+=f[_][1]-f[_][0]-1;return h}const SA={resolve:kA,tokenize:CA},jA={partial:!0,tokenize:NA};function kA(e){return lk(e),e}function CA(e,t){let s;return n;function n(d){return e.enter("content"),s=e.enter("chunkContent",{contentType:"content"}),a(d)}function a(d){return d===null?l(d):Ue(d)?e.check(jA,c,l)(d):(e.consume(d),a)}function l(d){return e.exit("chunkContent"),e.exit("content"),t(d)}function c(d){return e.consume(d),e.exit("chunkContent"),s.next=e.enter("chunkContent",{contentType:"content",previous:s}),s=s.next,a}}function NA(e,t,s){const n=this;return a;function a(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),ht(e,l,"linePrefix")}function l(c){if(c===null||Ue(c))return s(c);const d=n.events[n.events.length-1];return!n.parser.constructs.disable.null.includes("codeIndented")&&d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(c):e.interrupt(n.parser.constructs.flow,s,t)(c)}}function ck(e,t,s,n,a,l,c,d,f){const h=f||Number.POSITIVE_INFINITY;let m=0;return g;function g(k){return k===60?(e.enter(n),e.enter(a),e.enter(l),e.consume(k),e.exit(l),_):k===null||k===32||k===41||Ch(k)?s(k):(e.enter(n),e.enter(c),e.enter(d),e.enter("chunkString",{contentType:"string"}),S(k))}function _(k){return k===62?(e.enter(l),e.consume(k),e.exit(l),e.exit(a),e.exit(n),t):(e.enter(d),e.enter("chunkString",{contentType:"string"}),v(k))}function v(k){return k===62?(e.exit("chunkString"),e.exit(d),_(k)):k===null||k===60||Ue(k)?s(k):(e.consume(k),k===92?y:v)}function y(k){return k===60||k===62||k===92?(e.consume(k),v):v(k)}function S(k){return!m&&(k===null||k===41||At(k))?(e.exit("chunkString"),e.exit(d),e.exit(c),e.exit(n),t(k)):m<h&&k===40?(e.consume(k),m++,S):k===41?(e.consume(k),m--,S):k===null||k===32||k===40||Ch(k)?s(k):(e.consume(k),k===92?j:S)}function j(k){return k===40||k===41||k===92?(e.consume(k),S):S(k)}}function uk(e,t,s,n,a,l){const c=this;let d=0,f;return h;function h(v){return e.enter(n),e.enter(a),e.consume(v),e.exit(a),e.enter(l),m}function m(v){return d>999||v===null||v===91||v===93&&!f||v===94&&!d&&"_hiddenFootnoteSupport"in c.parser.constructs?s(v):v===93?(e.exit(l),e.enter(a),e.consume(v),e.exit(a),e.exit(n),t):Ue(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),g(v))}function g(v){return v===null||v===91||v===93||Ue(v)||d++>999?(e.exit("chunkString"),m(v)):(e.consume(v),f||(f=!ot(v)),v===92?_:g)}function _(v){return v===91||v===92||v===93?(e.consume(v),d++,g):g(v)}}function dk(e,t,s,n,a,l){let c;return d;function d(_){return _===34||_===39||_===40?(e.enter(n),e.enter(a),e.consume(_),e.exit(a),c=_===40?41:_,f):s(_)}function f(_){return _===c?(e.enter(a),e.consume(_),e.exit(a),e.exit(n),t):(e.enter(l),h(_))}function h(_){return _===c?(e.exit(l),f(c)):_===null?s(_):Ue(_)?(e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),ht(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(_))}function m(_){return _===c||_===null||Ue(_)?(e.exit("chunkString"),h(_)):(e.consume(_),_===92?g:m)}function g(_){return _===c||_===92?(e.consume(_),m):m(_)}}function Pc(e,t){let s;return n;function n(a){return Ue(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s=!0,n):ot(a)?ht(e,n,s?"linePrefix":"lineSuffix")(a):t(a)}}const EA={name:"definition",tokenize:TA},MA={partial:!0,tokenize:AA};function TA(e,t,s){const n=this;let a;return l;function l(v){return e.enter("definition"),c(v)}function c(v){return uk.call(n,e,d,s,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function d(v){return a=sr(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),v===58?(e.enter("definitionMarker"),e.consume(v),e.exit("definitionMarker"),f):s(v)}function f(v){return At(v)?Pc(e,h)(v):h(v)}function h(v){return ck(e,m,s,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function m(v){return e.attempt(MA,g,g)(v)}function g(v){return ot(v)?ht(e,_,"whitespace")(v):_(v)}function _(v){return v===null||Ue(v)?(e.exit("definition"),n.parser.defined.push(a),t(v)):s(v)}}function AA(e,t,s){return n;function n(d){return At(d)?Pc(e,a)(d):s(d)}function a(d){return dk(e,l,s,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function l(d){return ot(d)?ht(e,c,"whitespace")(d):c(d)}function c(d){return d===null||Ue(d)?t(d):s(d)}}const RA={name:"hardBreakEscape",tokenize:DA};function DA(e,t,s){return n;function n(l){return e.enter("hardBreakEscape"),e.consume(l),a}function a(l){return Ue(l)?(e.exit("hardBreakEscape"),t(l)):s(l)}}const LA={name:"headingAtx",resolve:BA,tokenize:OA};function BA(e,t){let s=e.length-2,n=3,a,l;return e[n][1].type==="whitespace"&&(n+=2),s-2>n&&e[s][1].type==="whitespace"&&(s-=2),e[s][1].type==="atxHeadingSequence"&&(n===s-1||s-4>n&&e[s-2][1].type==="whitespace")&&(s-=n+1===s?2:4),s>n&&(a={type:"atxHeadingText",start:e[n][1].start,end:e[s][1].end},l={type:"chunkText",start:e[n][1].start,end:e[s][1].end,contentType:"text"},Rn(e,n,s-n+1,[["enter",a,t],["enter",l,t],["exit",l,t],["exit",a,t]])),e}function OA(e,t,s){let n=0;return a;function a(m){return e.enter("atxHeading"),l(m)}function l(m){return e.enter("atxHeadingSequence"),c(m)}function c(m){return m===35&&n++<6?(e.consume(m),c):m===null||At(m)?(e.exit("atxHeadingSequence"),d(m)):s(m)}function d(m){return m===35?(e.enter("atxHeadingSequence"),f(m)):m===null||Ue(m)?(e.exit("atxHeading"),t(m)):ot(m)?ht(e,d,"whitespace")(m):(e.enter("atxHeadingText"),h(m))}function f(m){return m===35?(e.consume(m),f):(e.exit("atxHeadingSequence"),d(m))}function h(m){return m===null||m===35||At(m)?(e.exit("atxHeadingText"),d(m)):(e.consume(m),h)}}const zA=["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","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Ww=["pre","script","style","textarea"],PA={concrete:!0,name:"htmlFlow",resolveTo:FA,tokenize:HA},$A={partial:!0,tokenize:VA},IA={partial:!0,tokenize:UA};function FA(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function HA(e,t,s){const n=this;let a,l,c,d,f;return h;function h(T){return m(T)}function m(T){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(T),g}function g(T){return T===33?(e.consume(T),_):T===47?(e.consume(T),l=!0,S):T===63?(e.consume(T),a=3,n.interrupt?t:R):tn(T)?(e.consume(T),c=String.fromCharCode(T),j):s(T)}function _(T){return T===45?(e.consume(T),a=2,v):T===91?(e.consume(T),a=5,d=0,y):tn(T)?(e.consume(T),a=4,n.interrupt?t:R):s(T)}function v(T){return T===45?(e.consume(T),n.interrupt?t:R):s(T)}function y(T){const oe="CDATA[";return T===oe.charCodeAt(d++)?(e.consume(T),d===oe.length?n.interrupt?t:V:y):s(T)}function S(T){return tn(T)?(e.consume(T),c=String.fromCharCode(T),j):s(T)}function j(T){if(T===null||T===47||T===62||At(T)){const oe=T===47,be=c.toLowerCase();return!oe&&!l&&Ww.includes(be)?(a=1,n.interrupt?t(T):V(T)):zA.includes(c.toLowerCase())?(a=6,oe?(e.consume(T),k):n.interrupt?t(T):V(T)):(a=7,n.interrupt&&!n.parser.lazy[n.now().line]?s(T):l?N(T):E(T))}return T===45||Ws(T)?(e.consume(T),c+=String.fromCharCode(T),j):s(T)}function k(T){return T===62?(e.consume(T),n.interrupt?t:V):s(T)}function N(T){return ot(T)?(e.consume(T),N):L(T)}function E(T){return T===47?(e.consume(T),L):T===58||T===95||tn(T)?(e.consume(T),B):ot(T)?(e.consume(T),E):L(T)}function B(T){return T===45||T===46||T===58||T===95||Ws(T)?(e.consume(T),B):F(T)}function F(T){return T===61?(e.consume(T),$):ot(T)?(e.consume(T),F):E(T)}function $(T){return T===null||T===60||T===61||T===62||T===96?s(T):T===34||T===39?(e.consume(T),f=T,K):ot(T)?(e.consume(T),$):Y(T)}function K(T){return T===f?(e.consume(T),f=null,W):T===null||Ue(T)?s(T):(e.consume(T),K)}function Y(T){return T===null||T===34||T===39||T===47||T===60||T===61||T===62||T===96||At(T)?F(T):(e.consume(T),Y)}function W(T){return T===47||T===62||ot(T)?E(T):s(T)}function L(T){return T===62?(e.consume(T),Q):s(T)}function Q(T){return T===null||Ue(T)?V(T):ot(T)?(e.consume(T),Q):s(T)}function V(T){return T===45&&a===2?(e.consume(T),M):T===60&&a===1?(e.consume(T),O):T===62&&a===4?(e.consume(T),P):T===63&&a===3?(e.consume(T),R):T===93&&a===5?(e.consume(T),I):Ue(T)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check($A,z,X)(T)):T===null||Ue(T)?(e.exit("htmlFlowData"),X(T)):(e.consume(T),V)}function X(T){return e.check(IA,q,z)(T)}function q(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),A}function A(T){return T===null||Ue(T)?X(T):(e.enter("htmlFlowData"),V(T))}function M(T){return T===45?(e.consume(T),R):V(T)}function O(T){return T===47?(e.consume(T),c="",U):V(T)}function U(T){if(T===62){const oe=c.toLowerCase();return Ww.includes(oe)?(e.consume(T),P):V(T)}return tn(T)&&c.length<8?(e.consume(T),c+=String.fromCharCode(T),U):V(T)}function I(T){return T===93?(e.consume(T),R):V(T)}function R(T){return T===62?(e.consume(T),P):T===45&&a===2?(e.consume(T),R):V(T)}function P(T){return T===null||Ue(T)?(e.exit("htmlFlowData"),z(T)):(e.consume(T),P)}function z(T){return e.exit("htmlFlow"),t(T)}}function UA(e,t,s){const n=this;return a;function a(c){return Ue(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):s(c)}function l(c){return n.parser.lazy[n.now().line]?s(c):t(c)}}function VA(e,t,s){return n;function n(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(lu,t,s)}}const WA={name:"htmlText",tokenize:qA};function qA(e,t,s){const n=this;let a,l,c;return d;function d(R){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(R),f}function f(R){return R===33?(e.consume(R),h):R===47?(e.consume(R),F):R===63?(e.consume(R),E):tn(R)?(e.consume(R),Y):s(R)}function h(R){return R===45?(e.consume(R),m):R===91?(e.consume(R),l=0,y):tn(R)?(e.consume(R),N):s(R)}function m(R){return R===45?(e.consume(R),v):s(R)}function g(R){return R===null?s(R):R===45?(e.consume(R),_):Ue(R)?(c=g,O(R)):(e.consume(R),g)}function _(R){return R===45?(e.consume(R),v):g(R)}function v(R){return R===62?M(R):R===45?_(R):g(R)}function y(R){const P="CDATA[";return R===P.charCodeAt(l++)?(e.consume(R),l===P.length?S:y):s(R)}function S(R){return R===null?s(R):R===93?(e.consume(R),j):Ue(R)?(c=S,O(R)):(e.consume(R),S)}function j(R){return R===93?(e.consume(R),k):S(R)}function k(R){return R===62?M(R):R===93?(e.consume(R),k):S(R)}function N(R){return R===null||R===62?M(R):Ue(R)?(c=N,O(R)):(e.consume(R),N)}function E(R){return R===null?s(R):R===63?(e.consume(R),B):Ue(R)?(c=E,O(R)):(e.consume(R),E)}function B(R){return R===62?M(R):E(R)}function F(R){return tn(R)?(e.consume(R),$):s(R)}function $(R){return R===45||Ws(R)?(e.consume(R),$):K(R)}function K(R){return Ue(R)?(c=K,O(R)):ot(R)?(e.consume(R),K):M(R)}function Y(R){return R===45||Ws(R)?(e.consume(R),Y):R===47||R===62||At(R)?W(R):s(R)}function W(R){return R===47?(e.consume(R),M):R===58||R===95||tn(R)?(e.consume(R),L):Ue(R)?(c=W,O(R)):ot(R)?(e.consume(R),W):M(R)}function L(R){return R===45||R===46||R===58||R===95||Ws(R)?(e.consume(R),L):Q(R)}function Q(R){return R===61?(e.consume(R),V):Ue(R)?(c=Q,O(R)):ot(R)?(e.consume(R),Q):W(R)}function V(R){return R===null||R===60||R===61||R===62||R===96?s(R):R===34||R===39?(e.consume(R),a=R,X):Ue(R)?(c=V,O(R)):ot(R)?(e.consume(R),V):(e.consume(R),q)}function X(R){return R===a?(e.consume(R),a=void 0,A):R===null?s(R):Ue(R)?(c=X,O(R)):(e.consume(R),X)}function q(R){return R===null||R===34||R===39||R===60||R===61||R===96?s(R):R===47||R===62||At(R)?W(R):(e.consume(R),q)}function A(R){return R===47||R===62||At(R)?W(R):s(R)}function M(R){return R===62?(e.consume(R),e.exit("htmlTextData"),e.exit("htmlText"),t):s(R)}function O(R){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),U}function U(R){return ot(R)?ht(e,I,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):I(R)}function I(R){return e.enter("htmlTextData"),c(R)}}const z0={name:"labelEnd",resolveAll:XA,resolveTo:JA,tokenize:QA},GA={tokenize:ZA},KA={tokenize:e7},YA={tokenize:t7};function XA(e){let t=-1;const s=[];for(;++t<e.length;){const n=e[t][1];if(s.push(e[t]),n.type==="labelImage"||n.type==="labelLink"||n.type==="labelEnd"){const a=n.type==="labelImage"?4:2;n.type="data",t+=a}}return e.length!==s.length&&Rn(e,0,e.length,s),e}function JA(e,t){let s=e.length,n=0,a,l,c,d;for(;s--;)if(a=e[s][1],l){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[s][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(c){if(e[s][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(l=s,a.type!=="labelLink")){n=2;break}}else a.type==="labelEnd"&&(c=s);const f={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[l][1].start},end:{...e[c][1].end}},m={type:"labelText",start:{...e[l+n+2][1].end},end:{...e[c-2][1].start}};return d=[["enter",f,t],["enter",h,t]],d=Gn(d,e.slice(l+1,l+n+3)),d=Gn(d,[["enter",m,t]]),d=Gn(d,Wh(t.parser.constructs.insideSpan.null,e.slice(l+n+4,c-3),t)),d=Gn(d,[["exit",m,t],e[c-2],e[c-1],["exit",h,t]]),d=Gn(d,e.slice(c+1)),d=Gn(d,[["exit",f,t]]),Rn(e,l,e.length,d),e}function QA(e,t,s){const n=this;let a=n.events.length,l,c;for(;a--;)if((n.events[a][1].type==="labelImage"||n.events[a][1].type==="labelLink")&&!n.events[a][1]._balanced){l=n.events[a][1];break}return d;function d(_){return l?l._inactive?g(_):(c=n.parser.defined.includes(sr(n.sliceSerialize({start:l.end,end:n.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(_),e.exit("labelMarker"),e.exit("labelEnd"),f):s(_)}function f(_){return _===40?e.attempt(GA,m,c?m:g)(_):_===91?e.attempt(KA,m,c?h:g)(_):c?m(_):g(_)}function h(_){return e.attempt(YA,m,g)(_)}function m(_){return t(_)}function g(_){return l._balanced=!0,s(_)}}function ZA(e,t,s){return n;function n(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),a}function a(g){return At(g)?Pc(e,l)(g):l(g)}function l(g){return g===41?m(g):ck(e,c,d,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function c(g){return At(g)?Pc(e,f)(g):m(g)}function d(g){return s(g)}function f(g){return g===34||g===39||g===40?dk(e,h,s,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):m(g)}function h(g){return At(g)?Pc(e,m)(g):m(g)}function m(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),t):s(g)}}function e7(e,t,s){const n=this;return a;function a(d){return uk.call(n,e,l,c,"reference","referenceMarker","referenceString")(d)}function l(d){return n.parser.defined.includes(sr(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)))?t(d):s(d)}function c(d){return s(d)}}function t7(e,t,s){return n;function n(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),a}function a(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):s(l)}}const s7={name:"labelStartImage",resolveAll:z0.resolveAll,tokenize:n7};function n7(e,t,s){const n=this;return a;function a(d){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(d),e.exit("labelImageMarker"),l}function l(d){return d===91?(e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelImage"),c):s(d)}function c(d){return d===94&&"_hiddenFootnoteSupport"in n.parser.constructs?s(d):t(d)}}const r7={name:"labelStartLink",resolveAll:z0.resolveAll,tokenize:i7};function i7(e,t,s){const n=this;return a;function a(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),l}function l(c){return c===94&&"_hiddenFootnoteSupport"in n.parser.constructs?s(c):t(c)}}const Wm={name:"lineEnding",tokenize:a7};function a7(e,t){return s;function s(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),ht(e,t,"linePrefix")}}const rh={name:"thematicBreak",tokenize:o7};function o7(e,t,s){let n=0,a;return l;function l(h){return e.enter("thematicBreak"),c(h)}function c(h){return a=h,d(h)}function d(h){return h===a?(e.enter("thematicBreakSequence"),f(h)):n>=3&&(h===null||Ue(h))?(e.exit("thematicBreak"),t(h)):s(h)}function f(h){return h===a?(e.consume(h),n++,f):(e.exit("thematicBreakSequence"),ot(h)?ht(e,d,"whitespace")(h):d(h))}}const fn={continuation:{tokenize:d7},exit:f7,name:"list",tokenize:u7},l7={partial:!0,tokenize:p7},c7={partial:!0,tokenize:h7};function u7(e,t,s){const n=this,a=n.events[n.events.length-1];let l=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,c=0;return d;function d(v){const y=n.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!n.containerState.marker||v===n.containerState.marker:px(v)){if(n.containerState.type||(n.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),v===42||v===45?e.check(rh,s,h)(v):h(v);if(!n.interrupt||v===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),f(v)}return s(v)}function f(v){return px(v)&&++c<10?(e.consume(v),f):(!n.interrupt||c<2)&&(n.containerState.marker?v===n.containerState.marker:v===41||v===46)?(e.exit("listItemValue"),h(v)):s(v)}function h(v){return e.enter("listItemMarker"),e.consume(v),e.exit("listItemMarker"),n.containerState.marker=n.containerState.marker||v,e.check(lu,n.interrupt?s:m,e.attempt(l7,_,g))}function m(v){return n.containerState.initialBlankLine=!0,l++,_(v)}function g(v){return ot(v)?(e.enter("listItemPrefixWhitespace"),e.consume(v),e.exit("listItemPrefixWhitespace"),_):s(v)}function _(v){return n.containerState.size=l+n.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(v)}}function d7(e,t,s){const n=this;return n.containerState._closeFlow=void 0,e.check(lu,a,l);function a(d){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,ht(e,t,"listItemIndent",n.containerState.size+1)(d)}function l(d){return n.containerState.furtherBlankLines||!ot(d)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,c(d)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,e.attempt(c7,t,c)(d))}function c(d){return n.containerState._closeFlow=!0,n.interrupt=void 0,ht(e,e.attempt(fn,t,s),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function h7(e,t,s){const n=this;return ht(e,a,"listItemIndent",n.containerState.size+1);function a(l){const c=n.events[n.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===n.containerState.size?t(l):s(l)}}function f7(e){e.exit(this.containerState.type)}function p7(e,t,s){const n=this;return ht(e,a,"listItemPrefixWhitespace",n.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(l){const c=n.events[n.events.length-1];return!ot(l)&&c&&c[1].type==="listItemPrefixWhitespace"?t(l):s(l)}}const qw={name:"setextUnderline",resolveTo:m7,tokenize:g7};function m7(e,t){let s=e.length,n,a,l;for(;s--;)if(e[s][0]==="enter"){if(e[s][1].type==="content"){n=s;break}e[s][1].type==="paragraph"&&(a=s)}else e[s][1].type==="content"&&e.splice(s,1),!l&&e[s][1].type==="definition"&&(l=s);const c={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",l?(e.splice(a,0,["enter",c,t]),e.splice(l+1,0,["exit",e[n][1],t]),e[n][1].end={...e[l][1].end}):e[n][1]=c,e.push(["exit",c,t]),e}function g7(e,t,s){const n=this;let a;return l;function l(h){let m=n.events.length,g;for(;m--;)if(n.events[m][1].type!=="lineEnding"&&n.events[m][1].type!=="linePrefix"&&n.events[m][1].type!=="content"){g=n.events[m][1].type==="paragraph";break}return!n.parser.lazy[n.now().line]&&(n.interrupt||g)?(e.enter("setextHeadingLine"),a=h,c(h)):s(h)}function c(h){return e.enter("setextHeadingLineSequence"),d(h)}function d(h){return h===a?(e.consume(h),d):(e.exit("setextHeadingLineSequence"),ot(h)?ht(e,f,"lineSuffix")(h):f(h))}function f(h){return h===null||Ue(h)?(e.exit("setextHeadingLine"),t(h)):s(h)}}const x7={tokenize:v7};function v7(e){const t=this,s=e.attempt(lu,n,e.attempt(this.parser.constructs.flowInitial,a,ht(e,e.attempt(this.parser.constructs.flow,a,e.attempt(SA,a)),"linePrefix")));return s;function n(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,s}function a(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,s}}const b7={resolveAll:fk()},_7=hk("string"),y7=hk("text");function hk(e){return{resolveAll:fk(e==="text"?w7:void 0),tokenize:t};function t(s){const n=this,a=this.parser.constructs[e],l=s.attempt(a,c,d);return c;function c(m){return h(m)?l(m):d(m)}function d(m){if(m===null){s.consume(m);return}return s.enter("data"),s.consume(m),f}function f(m){return h(m)?(s.exit("data"),l(m)):(s.consume(m),f)}function h(m){if(m===null)return!0;const g=a[m];let _=-1;if(g)for(;++_<g.length;){const v=g[_];if(!v.previous||v.previous.call(n,n.previous))return!0}return!1}}}function fk(e){return t;function t(s,n){let a=-1,l;for(;++a<=s.length;)l===void 0?s[a]&&s[a][1].type==="data"&&(l=a,a++):(!s[a]||s[a][1].type!=="data")&&(a!==l+2&&(s[l][1].end=s[a-1][1].end,s.splice(l+2,a-l-2),a=l+2),l=void 0);return e?e(s,n):s}}function w7(e,t){let s=0;for(;++s<=e.length;)if((s===e.length||e[s][1].type==="lineEnding")&&e[s-1][1].type==="data"){const n=e[s-1][1],a=t.sliceStream(n);let l=a.length,c=-1,d=0,f;for(;l--;){const h=a[l];if(typeof h=="string"){for(c=h.length;h.charCodeAt(c-1)===32;)d++,c--;if(c)break;c=-1}else if(h===-2)f=!0,d++;else if(h!==-1){l++;break}}if(t._contentTypeTextTrailing&&s===e.length&&(d=0),d){const h={type:s===e.length||f||d<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?c:n.start._bufferIndex+c,_index:n.start._index+l,line:n.end.line,column:n.end.column-d,offset:n.end.offset-d},end:{...n.end}};n.end={...h.start},n.start.offset===n.end.offset?Object.assign(n,h):(e.splice(s,0,["enter",h,t],["exit",h,t]),s+=2)}s++}return e}const S7={42:fn,43:fn,45:fn,48:fn,49:fn,50:fn,51:fn,52:fn,53:fn,54:fn,55:fn,56:fn,57:fn,62:ik},j7={91:EA},k7={[-2]:Vm,[-1]:Vm,32:Vm},C7={35:LA,42:rh,45:[qw,rh],60:PA,61:qw,95:rh,96:Vw,126:Vw},N7={38:ok,92:ak},E7={[-5]:Wm,[-4]:Wm,[-3]:Wm,33:s7,38:ok,42:mx,60:[rA,WA],91:r7,92:[RA,ak],93:z0,95:mx,96:xA},M7={null:[mx,b7]},T7={null:[42,95]},A7={null:[]},R7=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:T7,contentInitial:j7,disable:A7,document:S7,flow:C7,flowInitial:k7,insideSpan:M7,string:N7,text:E7},Symbol.toStringTag,{value:"Module"}));function D7(e,t,s){let n={_bufferIndex:-1,_index:0,line:s&&s.line||1,column:s&&s.column||1,offset:s&&s.offset||0};const a={},l=[];let c=[],d=[];const f={attempt:K(F),check:K($),consume:N,enter:E,exit:B,interrupt:K($,{interrupt:!0})},h={code:null,containerState:{},defineSkip:S,events:[],now:y,parser:e,previous:null,sliceSerialize:_,sliceStream:v,write:g};let m=t.tokenize.call(h,f);return t.resolveAll&&l.push(t),h;function g(Q){return c=Gn(c,Q),j(),c[c.length-1]!==null?[]:(Y(t,0),h.events=Wh(l,h.events,h),h.events)}function _(Q,V){return B7(v(Q),V)}function v(Q){return L7(c,Q)}function y(){const{_bufferIndex:Q,_index:V,line:X,column:q,offset:A}=n;return{_bufferIndex:Q,_index:V,line:X,column:q,offset:A}}function S(Q){a[Q.line]=Q.column,L()}function j(){let Q;for(;n._index<c.length;){const V=c[n._index];if(typeof V=="string")for(Q=n._index,n._bufferIndex<0&&(n._bufferIndex=0);n._index===Q&&n._bufferIndex<V.length;)k(V.charCodeAt(n._bufferIndex));else k(V)}}function k(Q){m=m(Q)}function N(Q){Ue(Q)?(n.line++,n.column=1,n.offset+=Q===-3?2:1,L()):Q!==-1&&(n.column++,n.offset++),n._bufferIndex<0?n._index++:(n._bufferIndex++,n._bufferIndex===c[n._index].length&&(n._bufferIndex=-1,n._index++)),h.previous=Q}function E(Q,V){const X=V||{};return X.type=Q,X.start=y(),h.events.push(["enter",X,h]),d.push(X),X}function B(Q){const V=d.pop();return V.end=y(),h.events.push(["exit",V,h]),V}function F(Q,V){Y(Q,V.from)}function $(Q,V){V.restore()}function K(Q,V){return X;function X(q,A,M){let O,U,I,R;return Array.isArray(q)?z(q):"tokenize"in q?z([q]):P(q);function P(re){return ve;function ve(Te){const Re=Te!==null&&re[Te],je=Te!==null&&re.null,Ye=[...Array.isArray(Re)?Re:Re?[Re]:[],...Array.isArray(je)?je:je?[je]:[]];return z(Ye)(Te)}}function z(re){return O=re,U=0,re.length===0?M:T(re[U])}function T(re){return ve;function ve(Te){return R=W(),I=re,re.partial||(h.currentConstruct=re),re.name&&h.parser.constructs.disable.null.includes(re.name)?be():re.tokenize.call(V?Object.assign(Object.create(h),V):h,f,oe,be)(Te)}}function oe(re){return Q(I,R),A}function be(re){return R.restore(),++U<O.length?T(O[U]):M}}}function Y(Q,V){Q.resolveAll&&!l.includes(Q)&&l.push(Q),Q.resolve&&Rn(h.events,V,h.events.length-V,Q.resolve(h.events.slice(V),h)),Q.resolveTo&&(h.events=Q.resolveTo(h.events,h))}function W(){const Q=y(),V=h.previous,X=h.currentConstruct,q=h.events.length,A=Array.from(d);return{from:q,restore:M};function M(){n=Q,h.previous=V,h.currentConstruct=X,h.events.length=q,d=A,L()}}function L(){n.line in a&&n.column<2&&(n.column=a[n.line],n.offset+=a[n.line]-1)}}function L7(e,t){const s=t.start._index,n=t.start._bufferIndex,a=t.end._index,l=t.end._bufferIndex;let c;if(s===a)c=[e[s].slice(n,l)];else{if(c=e.slice(s,a),n>-1){const d=c[0];typeof d=="string"?c[0]=d.slice(n):c.shift()}l>0&&c.push(e[a].slice(0,l))}return c}function B7(e,t){let s=-1;const n=[];let a;for(;++s<e.length;){const l=e[s];let c;if(typeof l=="string")c=l;else switch(l){case-5:{c="\r";break}case-4:{c=`
57
+ `;break}case-3:{c=`\r
58
+ `;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&a)continue;c=" ";break}default:c=String.fromCharCode(l)}a=l===-2,n.push(c)}return n.join("")}function O7(e){const n={constructs:nk([R7,...(e||{}).extensions||[]]),content:a(JT),defined:[],document:a(ZT),flow:a(x7),lazy:{},string:a(_7),text:a(y7)};return n;function a(l){return c;function c(d){return D7(n,l,d)}}}function z7(e){for(;!lk(e););return e}const Gw=/[\0\t\n\r]/g;function P7(){let e=1,t="",s=!0,n;return a;function a(l,c,d){const f=[];let h,m,g,_,v;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(c||void 0).decode(l)),g=0,t="",s&&(l.charCodeAt(0)===65279&&g++,s=void 0);g<l.length;){if(Gw.lastIndex=g,h=Gw.exec(l),_=h&&h.index!==void 0?h.index:l.length,v=l.charCodeAt(_),!h){t=l.slice(g);break}if(v===10&&g===_&&n)f.push(-3),n=void 0;else switch(n&&(f.push(-5),n=void 0),g<_&&(f.push(l.slice(g,_)),e+=_-g),v){case 0:{f.push(65533),e++;break}case 9:{for(m=Math.ceil(e/4)*4,f.push(-2);e++<m;)f.push(-1);break}case 10:{f.push(-4),e=1;break}default:n=!0,e=1}g=_+1}return d&&(n&&f.push(-5),t&&f.push(t),f.push(null)),f}}const $7=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function I7(e){return e.replace($7,F7)}function F7(e,t,s){if(t)return t;if(s.charCodeAt(0)===35){const a=s.charCodeAt(1),l=a===120||a===88;return rk(s.slice(l?2:1),l?16:10)}return O0(s)||e}const pk={}.hasOwnProperty;function H7(e,t,s){return typeof t!="string"&&(s=t,t=void 0),U7(s)(z7(O7(s).document().write(P7()(e,t,!0))))}function U7(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Kt),autolinkProtocol:W,autolinkEmail:W,atxHeading:l(Ze),blockQuote:l(je),characterEscape:W,characterReference:W,codeFenced:l(Ye),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:l(Ye,c),codeText:l(Xe,c),codeTextData:W,data:W,codeFlowValue:W,definition:l(Pe),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:l(ye),hardBreakEscape:l(ft),hardBreakTrailing:l(ft),htmlFlow:l(mt,c),htmlFlowData:W,htmlText:l(mt,c),htmlTextData:W,image:l(ts),label:c,link:l(Kt),listItem:l(Rt),listItemValue:_,listOrdered:l(Ft,g),listUnordered:l(Ft),paragraph:l(Hs),reference:T,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:l(Ze),strong:l(gs),thematicBreak:l(rr)},exit:{atxHeading:f(),atxHeadingSequence:F,autolink:f(),autolinkEmail:Re,autolinkProtocol:Te,blockQuote:f(),characterEscapeValue:L,characterReferenceMarkerHexadecimal:be,characterReferenceMarkerNumeric:be,characterReferenceValue:re,characterReference:ve,codeFenced:f(j),codeFencedFence:S,codeFencedFenceInfo:v,codeFencedFenceMeta:y,codeFlowValue:L,codeIndented:f(k),codeText:f(A),codeTextData:L,data:L,definition:f(),definitionDestinationString:B,definitionLabelString:N,definitionTitleString:E,emphasis:f(),hardBreakEscape:f(V),hardBreakTrailing:f(V),htmlFlow:f(X),htmlFlowData:L,htmlText:f(q),htmlTextData:L,image:f(O),label:I,labelText:U,lineEnding:Q,link:f(M),listItem:f(),listOrdered:f(),listUnordered:f(),paragraph:f(),referenceString:oe,resourceDestinationString:R,resourceTitleString:P,resource:z,setextHeading:f(Y),setextHeadingLineSequence:K,setextHeadingText:$,strong:f(),thematicBreak:f()}};mk(t,(e||{}).mdastExtensions||[]);const s={};return n;function n(de){let _e={type:"root",children:[]};const Be={stack:[_e],tokenStack:[],config:t,enter:d,exit:h,buffer:c,resume:m,data:s},qe=[];let Je=-1;for(;++Je<de.length;)if(de[Je][1].type==="listOrdered"||de[Je][1].type==="listUnordered")if(de[Je][0]==="enter")qe.push(Je);else{const Yt=qe.pop();Je=a(de,Yt,Je)}for(Je=-1;++Je<de.length;){const Yt=t[de[Je][0]];pk.call(Yt,de[Je][1].type)&&Yt[de[Je][1].type].call(Object.assign({sliceSerialize:de[Je][2].sliceSerialize},Be),de[Je][1])}if(Be.tokenStack.length>0){const Yt=Be.tokenStack[Be.tokenStack.length-1];(Yt[1]||Kw).call(Be,void 0,Yt[0])}for(_e.position={start:Li(de.length>0?de[0][1].start:{line:1,column:1,offset:0}),end:Li(de.length>0?de[de.length-2][1].end:{line:1,column:1,offset:0})},Je=-1;++Je<t.transforms.length;)_e=t.transforms[Je](_e)||_e;return _e}function a(de,_e,Be){let qe=_e-1,Je=-1,Yt=!1,xs,se,fe,H;for(;++qe<=Be;){const ee=de[qe];switch(ee[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ee[0]==="enter"?Je++:Je--,H=void 0;break}case"lineEndingBlank":{ee[0]==="enter"&&(xs&&!H&&!Je&&!fe&&(fe=qe),H=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:H=void 0}if(!Je&&ee[0]==="enter"&&ee[1].type==="listItemPrefix"||Je===-1&&ee[0]==="exit"&&(ee[1].type==="listUnordered"||ee[1].type==="listOrdered")){if(xs){let Ie=qe;for(se=void 0;Ie--;){const We=de[Ie];if(We[1].type==="lineEnding"||We[1].type==="lineEndingBlank"){if(We[0]==="exit")continue;se&&(de[se][1].type="lineEndingBlank",Yt=!0),We[1].type="lineEnding",se=Ie}else if(!(We[1].type==="linePrefix"||We[1].type==="blockQuotePrefix"||We[1].type==="blockQuotePrefixWhitespace"||We[1].type==="blockQuoteMarker"||We[1].type==="listItemIndent"))break}fe&&(!se||fe<se)&&(xs._spread=!0),xs.end=Object.assign({},se?de[se][1].start:ee[1].end),de.splice(se||qe,0,["exit",xs,ee[2]]),qe++,Be++}if(ee[1].type==="listItemPrefix"){const Ie={type:"listItem",_spread:!1,start:Object.assign({},ee[1].start),end:void 0};xs=Ie,de.splice(qe,0,["enter",Ie,ee[2]]),qe++,Be++,fe=void 0,H=!0}}}return de[_e][1]._spread=Yt,Be}function l(de,_e){return Be;function Be(qe){d.call(this,de(qe),qe),_e&&_e.call(this,qe)}}function c(){this.stack.push({type:"fragment",children:[]})}function d(de,_e,Be){this.stack[this.stack.length-1].children.push(de),this.stack.push(de),this.tokenStack.push([_e,Be||void 0]),de.position={start:Li(_e.start),end:void 0}}function f(de){return _e;function _e(Be){de&&de.call(this,Be),h.call(this,Be)}}function h(de,_e){const Be=this.stack.pop(),qe=this.tokenStack.pop();if(qe)qe[0].type!==de.type&&(_e?_e.call(this,de,qe[0]):(qe[1]||Kw).call(this,de,qe[0]));else throw new Error("Cannot close `"+de.type+"` ("+zc({start:de.start,end:de.end})+"): it’s not open");Be.position.end=Li(de.end)}function m(){return B0(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function _(de){if(this.data.expectingFirstListItemValue){const _e=this.stack[this.stack.length-2];_e.start=Number.parseInt(this.sliceSerialize(de),10),this.data.expectingFirstListItemValue=void 0}}function v(){const de=this.resume(),_e=this.stack[this.stack.length-1];_e.lang=de}function y(){const de=this.resume(),_e=this.stack[this.stack.length-1];_e.meta=de}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function j(){const de=this.resume(),_e=this.stack[this.stack.length-1];_e.value=de.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const de=this.resume(),_e=this.stack[this.stack.length-1];_e.value=de.replace(/(\r?\n|\r)$/g,"")}function N(de){const _e=this.resume(),Be=this.stack[this.stack.length-1];Be.label=_e,Be.identifier=sr(this.sliceSerialize(de)).toLowerCase()}function E(){const de=this.resume(),_e=this.stack[this.stack.length-1];_e.title=de}function B(){const de=this.resume(),_e=this.stack[this.stack.length-1];_e.url=de}function F(de){const _e=this.stack[this.stack.length-1];if(!_e.depth){const Be=this.sliceSerialize(de).length;_e.depth=Be}}function $(){this.data.setextHeadingSlurpLineEnding=!0}function K(de){const _e=this.stack[this.stack.length-1];_e.depth=this.sliceSerialize(de).codePointAt(0)===61?1:2}function Y(){this.data.setextHeadingSlurpLineEnding=void 0}function W(de){const Be=this.stack[this.stack.length-1].children;let qe=Be[Be.length-1];(!qe||qe.type!=="text")&&(qe=vt(),qe.position={start:Li(de.start),end:void 0},Be.push(qe)),this.stack.push(qe)}function L(de){const _e=this.stack.pop();_e.value+=this.sliceSerialize(de),_e.position.end=Li(de.end)}function Q(de){const _e=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Be=_e.children[_e.children.length-1];Be.position.end=Li(de.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(_e.type)&&(W.call(this,de),L.call(this,de))}function V(){this.data.atHardBreak=!0}function X(){const de=this.resume(),_e=this.stack[this.stack.length-1];_e.value=de}function q(){const de=this.resume(),_e=this.stack[this.stack.length-1];_e.value=de}function A(){const de=this.resume(),_e=this.stack[this.stack.length-1];_e.value=de}function M(){const de=this.stack[this.stack.length-1];if(this.data.inReference){const _e=this.data.referenceType||"shortcut";de.type+="Reference",de.referenceType=_e,delete de.url,delete de.title}else delete de.identifier,delete de.label;this.data.referenceType=void 0}function O(){const de=this.stack[this.stack.length-1];if(this.data.inReference){const _e=this.data.referenceType||"shortcut";de.type+="Reference",de.referenceType=_e,delete de.url,delete de.title}else delete de.identifier,delete de.label;this.data.referenceType=void 0}function U(de){const _e=this.sliceSerialize(de),Be=this.stack[this.stack.length-2];Be.label=I7(_e),Be.identifier=sr(_e).toLowerCase()}function I(){const de=this.stack[this.stack.length-1],_e=this.resume(),Be=this.stack[this.stack.length-1];if(this.data.inReference=!0,Be.type==="link"){const qe=de.children;Be.children=qe}else Be.alt=_e}function R(){const de=this.resume(),_e=this.stack[this.stack.length-1];_e.url=de}function P(){const de=this.resume(),_e=this.stack[this.stack.length-1];_e.title=de}function z(){this.data.inReference=void 0}function T(){this.data.referenceType="collapsed"}function oe(de){const _e=this.resume(),Be=this.stack[this.stack.length-1];Be.label=_e,Be.identifier=sr(this.sliceSerialize(de)).toLowerCase(),this.data.referenceType="full"}function be(de){this.data.characterReferenceType=de.type}function re(de){const _e=this.sliceSerialize(de),Be=this.data.characterReferenceType;let qe;Be?(qe=rk(_e,Be==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):qe=O0(_e);const Je=this.stack[this.stack.length-1];Je.value+=qe}function ve(de){const _e=this.stack.pop();_e.position.end=Li(de.end)}function Te(de){L.call(this,de);const _e=this.stack[this.stack.length-1];_e.url=this.sliceSerialize(de)}function Re(de){L.call(this,de);const _e=this.stack[this.stack.length-1];_e.url="mailto:"+this.sliceSerialize(de)}function je(){return{type:"blockquote",children:[]}}function Ye(){return{type:"code",lang:null,meta:null,value:""}}function Xe(){return{type:"inlineCode",value:""}}function Pe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ye(){return{type:"emphasis",children:[]}}function Ze(){return{type:"heading",depth:0,children:[]}}function ft(){return{type:"break"}}function mt(){return{type:"html",value:""}}function ts(){return{type:"image",title:null,url:"",alt:null}}function Kt(){return{type:"link",title:null,url:"",children:[]}}function Ft(de){return{type:"list",ordered:de.type==="listOrdered",start:null,spread:de._spread,children:[]}}function Rt(de){return{type:"listItem",spread:de._spread,checked:null,children:[]}}function Hs(){return{type:"paragraph",children:[]}}function gs(){return{type:"strong",children:[]}}function vt(){return{type:"text",value:""}}function rr(){return{type:"thematicBreak"}}}function Li(e){return{line:e.line,column:e.column,offset:e.offset}}function mk(e,t){let s=-1;for(;++s<t.length;){const n=t[s];Array.isArray(n)?mk(e,n):V7(e,n)}}function V7(e,t){let s;for(s in t)if(pk.call(t,s))switch(s){case"canContainEols":{const n=t[s];n&&e[s].push(...n);break}case"transforms":{const n=t[s];n&&e[s].push(...n);break}case"enter":case"exit":{const n=t[s];n&&Object.assign(e[s],n);break}}}function Kw(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+zc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+zc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+zc({start:t.start,end:t.end})+") is still open")}function W7(e){const t=this;t.parser=s;function s(n){return H7(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function q7(e,t){const s={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,s),e.applyData(t,s)}function G7(e,t){const s={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,s),[e.applyData(t,s),{type:"text",value:`
59
+ `}]}function K7(e,t){const s=t.value?t.value+`
60
+ `:"",n={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(n.className=["language-"+a[0]]);let l={type:"element",tagName:"code",properties:n,children:[{type:"text",value:s}]};return t.meta&&(l.data={meta:t.meta}),e.patch(t,l),l=e.applyData(t,l),l={type:"element",tagName:"pre",properties:{},children:[l]},e.patch(t,l),l}function Y7(e,t){const s={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function X7(e,t){const s={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function J7(e,t){const s=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=String(t.identifier).toUpperCase(),a=el(n.toLowerCase()),l=e.footnoteOrder.indexOf(n);let c,d=e.footnoteCounts.get(n);d===void 0?(d=0,e.footnoteOrder.push(n),c=e.footnoteOrder.length):c=l+1,d+=1,e.footnoteCounts.set(n,d);const f={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+a,id:s+"fnref-"+a+(d>1?"-"+d:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,f);const h={type:"element",tagName:"sup",properties:{},children:[f]};return e.patch(t,h),e.applyData(t,h)}function Q7(e,t){const s={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function Z7(e,t){if(e.options.allowDangerousHtml){const s={type:"raw",value:t.value};return e.patch(t,s),e.applyData(t,s)}}function gk(e,t){const s=t.referenceType;let n="]";if(s==="collapsed"?n+="[]":s==="full"&&(n+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+n}];const a=e.all(t),l=a[0];l&&l.type==="text"?l.value="["+l.value:a.unshift({type:"text",value:"["});const c=a[a.length-1];return c&&c.type==="text"?c.value+=n:a.push({type:"text",value:n}),a}function e8(e,t){const s=String(t.identifier).toUpperCase(),n=e.definitionById.get(s);if(!n)return gk(e,t);const a={src:el(n.url||""),alt:t.alt};n.title!==null&&n.title!==void 0&&(a.title=n.title);const l={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,l),e.applyData(t,l)}function t8(e,t){const s={src:el(t.url)};t.alt!==null&&t.alt!==void 0&&(s.alt=t.alt),t.title!==null&&t.title!==void 0&&(s.title=t.title);const n={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,n),e.applyData(t,n)}function s8(e,t){const s={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,s);const n={type:"element",tagName:"code",properties:{},children:[s]};return e.patch(t,n),e.applyData(t,n)}function n8(e,t){const s=String(t.identifier).toUpperCase(),n=e.definitionById.get(s);if(!n)return gk(e,t);const a={href:el(n.url||"")};n.title!==null&&n.title!==void 0&&(a.title=n.title);const l={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function r8(e,t){const s={href:el(t.url)};t.title!==null&&t.title!==void 0&&(s.title=t.title);const n={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function i8(e,t,s){const n=e.all(t),a=s?a8(s):xk(t),l={},c=[];if(typeof t.checked=="boolean"){const m=n[0];let g;m&&m.type==="element"&&m.tagName==="p"?g=m:(g={type:"element",tagName:"p",properties:{},children:[]},n.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),l.className=["task-list-item"]}let d=-1;for(;++d<n.length;){const m=n[d];(a||d!==0||m.type!=="element"||m.tagName!=="p")&&c.push({type:"text",value:`
61
+ `}),m.type==="element"&&m.tagName==="p"&&!a?c.push(...m.children):c.push(m)}const f=n[n.length-1];f&&(a||f.type!=="element"||f.tagName!=="p")&&c.push({type:"text",value:`
62
+ `});const h={type:"element",tagName:"li",properties:l,children:c};return e.patch(t,h),e.applyData(t,h)}function a8(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const s=e.children;let n=-1;for(;!t&&++n<s.length;)t=xk(s[n])}return t}function xk(e){const t=e.spread;return t??e.children.length>1}function o8(e,t){const s={},n=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(s.start=t.start);++a<n.length;){const c=n[a];if(c.type==="element"&&c.tagName==="li"&&c.properties&&Array.isArray(c.properties.className)&&c.properties.className.includes("task-list-item")){s.className=["contains-task-list"];break}}const l={type:"element",tagName:t.ordered?"ol":"ul",properties:s,children:e.wrap(n,!0)};return e.patch(t,l),e.applyData(t,l)}function l8(e,t){const s={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function c8(e,t){const s={type:"root",children:e.wrap(e.all(t))};return e.patch(t,s),e.applyData(t,s)}function u8(e,t){const s={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function d8(e,t){const s=e.all(t),n=s.shift(),a=[];if(n){const c={type:"element",tagName:"thead",properties:{},children:e.wrap([n],!0)};e.patch(t.children[0],c),a.push(c)}if(s.length>0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(s,!0)},d=A0(t.children[1]),f=Xj(t.children[t.children.length-1]);d&&f&&(c.position={start:d,end:f}),a.push(c)}const l={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,l),e.applyData(t,l)}function h8(e,t,s){const n=s?s.children:void 0,l=(n?n.indexOf(t):1)===0?"th":"td",c=s&&s.type==="table"?s.align:void 0,d=c?c.length:t.children.length;let f=-1;const h=[];for(;++f<d;){const g=t.children[f],_={},v=c?c[f]:void 0;v&&(_.align=v);let y={type:"element",tagName:l,properties:_,children:[]};g&&(y.children=e.all(g),e.patch(g,y),y=e.applyData(g,y)),h.push(y)}const m={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(t,m),e.applyData(t,m)}function f8(e,t){const s={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}const Yw=9,Xw=32;function p8(e){const t=String(e),s=/\r?\n|\r/g;let n=s.exec(t),a=0;const l=[];for(;n;)l.push(Jw(t.slice(a,n.index),a>0,!0),n[0]),a=n.index+n[0].length,n=s.exec(t);return l.push(Jw(t.slice(a),a>0,!1)),l.join("")}function Jw(e,t,s){let n=0,a=e.length;if(t){let l=e.codePointAt(n);for(;l===Yw||l===Xw;)n++,l=e.codePointAt(n)}if(s){let l=e.codePointAt(a-1);for(;l===Yw||l===Xw;)a--,l=e.codePointAt(a-1)}return a>n?e.slice(n,a):""}function m8(e,t){const s={type:"text",value:p8(String(t.value))};return e.patch(t,s),e.applyData(t,s)}function g8(e,t){const s={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,s),e.applyData(t,s)}const x8={blockquote:q7,break:G7,code:K7,delete:Y7,emphasis:X7,footnoteReference:J7,heading:Q7,html:Z7,imageReference:e8,image:t8,inlineCode:s8,linkReference:n8,link:r8,listItem:i8,list:o8,paragraph:l8,root:c8,strong:u8,table:d8,tableCell:f8,tableRow:h8,text:m8,thematicBreak:g8,toml:Od,yaml:Od,definition:Od,footnoteDefinition:Od};function Od(){}const vk=-1,qh=0,$c=1,Nh=2,P0=3,$0=4,I0=5,F0=6,bk=7,_k=8,Qw=typeof self=="object"?self:globalThis,v8=(e,t)=>{const s=(a,l)=>(e.set(l,a),a),n=a=>{if(e.has(a))return e.get(a);const[l,c]=t[a];switch(l){case qh:case vk:return s(c,a);case $c:{const d=s([],a);for(const f of c)d.push(n(f));return d}case Nh:{const d=s({},a);for(const[f,h]of c)d[n(f)]=n(h);return d}case P0:return s(new Date(c),a);case $0:{const{source:d,flags:f}=c;return s(new RegExp(d,f),a)}case I0:{const d=s(new Map,a);for(const[f,h]of c)d.set(n(f),n(h));return d}case F0:{const d=s(new Set,a);for(const f of c)d.add(n(f));return d}case bk:{const{name:d,message:f}=c;return s(new Qw[d](f),a)}case _k:return s(BigInt(c),a);case"BigInt":return s(Object(BigInt(c)),a);case"ArrayBuffer":return s(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:d}=new Uint8Array(c);return s(new DataView(d),c)}}return s(new Qw[l](c),a)};return n},Zw=e=>v8(new Map,e)(0),Co="",{toString:b8}={},{keys:_8}=Object,ac=e=>{const t=typeof e;if(t!=="object"||!e)return[qh,t];const s=b8.call(e).slice(8,-1);switch(s){case"Array":return[$c,Co];case"Object":return[Nh,Co];case"Date":return[P0,Co];case"RegExp":return[$0,Co];case"Map":return[I0,Co];case"Set":return[F0,Co];case"DataView":return[$c,s]}return s.includes("Array")?[$c,s]:s.includes("Error")?[bk,s]:[Nh,s]},zd=([e,t])=>e===qh&&(t==="function"||t==="symbol"),y8=(e,t,s,n)=>{const a=(c,d)=>{const f=n.push(c)-1;return s.set(d,f),f},l=c=>{if(s.has(c))return s.get(c);let[d,f]=ac(c);switch(d){case qh:{let m=c;switch(f){case"bigint":d=_k,m=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+f);m=null;break;case"undefined":return a([vk],c)}return a([d,m],c)}case $c:{if(f){let _=c;return f==="DataView"?_=new Uint8Array(c.buffer):f==="ArrayBuffer"&&(_=new Uint8Array(c)),a([f,[..._]],c)}const m=[],g=a([d,m],c);for(const _ of c)m.push(l(_));return g}case Nh:{if(f)switch(f){case"BigInt":return a([f,c.toString()],c);case"Boolean":case"Number":case"String":return a([f,c.valueOf()],c)}if(t&&"toJSON"in c)return l(c.toJSON());const m=[],g=a([d,m],c);for(const _ of _8(c))(e||!zd(ac(c[_])))&&m.push([l(_),l(c[_])]);return g}case P0:return a([d,c.toISOString()],c);case $0:{const{source:m,flags:g}=c;return a([d,{source:m,flags:g}],c)}case I0:{const m=[],g=a([d,m],c);for(const[_,v]of c)(e||!(zd(ac(_))||zd(ac(v))))&&m.push([l(_),l(v)]);return g}case F0:{const m=[],g=a([d,m],c);for(const _ of c)(e||!zd(ac(_)))&&m.push(l(_));return g}}const{message:h}=c;return a([d,{name:f,message:h}],c)};return l},e5=(e,{json:t,lossy:s}={})=>{const n=[];return y8(!(t||s),!!t,new Map,n)(e),n},Eh=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Zw(e5(e,t)):structuredClone(e):(e,t)=>Zw(e5(e,t));function w8(e,t){const s=[{type:"text",value:"↩"}];return t>1&&s.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),s}function S8(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function j8(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=e.options.footnoteBackContent||w8,n=e.options.footnoteBackLabel||S8,a=e.options.footnoteLabel||"Footnotes",l=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},d=[];let f=-1;for(;++f<e.footnoteOrder.length;){const h=e.footnoteById.get(e.footnoteOrder[f]);if(!h)continue;const m=e.all(h),g=String(h.identifier).toUpperCase(),_=el(g.toLowerCase());let v=0;const y=[],S=e.footnoteCounts.get(g);for(;S!==void 0&&++v<=S;){y.length>0&&y.push({type:"text",value:" "});let N=typeof s=="string"?s:s(f,v);typeof N=="string"&&(N={type:"text",value:N}),y.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+_+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof n=="string"?n:n(f,v),className:["data-footnote-backref"]},children:Array.isArray(N)?N:[N]})}const j=m[m.length-1];if(j&&j.type==="element"&&j.tagName==="p"){const N=j.children[j.children.length-1];N&&N.type==="text"?N.value+=" ":j.children.push({type:"text",value:" "}),j.children.push(...y)}else m.push(...y);const k={type:"element",tagName:"li",properties:{id:t+"fn-"+_},children:e.wrap(m,!0)};e.patch(h,k),d.push(k)}if(d.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:l,properties:{...Eh(c),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
63
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(d,!0)},{type:"text",value:`
64
+ `}]}}const Gh=(function(e){if(e==null)return E8;if(typeof e=="function")return Kh(e);if(typeof e=="object")return Array.isArray(e)?k8(e):C8(e);if(typeof e=="string")return N8(e);throw new Error("Expected function, string, or object as test")});function k8(e){const t=[];let s=-1;for(;++s<e.length;)t[s]=Gh(e[s]);return Kh(n);function n(...a){let l=-1;for(;++l<t.length;)if(t[l].apply(this,a))return!0;return!1}}function C8(e){const t=e;return Kh(s);function s(n){const a=n;let l;for(l in e)if(a[l]!==t[l])return!1;return!0}}function N8(e){return Kh(t);function t(s){return s&&s.type===e}}function Kh(e){return t;function t(s,n,a){return!!(M8(s)&&e.call(this,s,typeof n=="number"?n:void 0,a||void 0))}}function E8(){return!0}function M8(e){return e!==null&&typeof e=="object"&&"type"in e}const yk=[],T8=!0,gx=!1,A8="skip";function wk(e,t,s,n){let a;typeof t=="function"&&typeof s!="function"?(n=s,s=t):a=t;const l=Gh(a),c=n?-1:1;d(e,void 0,[])();function d(f,h,m){const g=f&&typeof f=="object"?f:{};if(typeof g.type=="string"){const v=typeof g.tagName=="string"?g.tagName:typeof g.name=="string"?g.name:void 0;Object.defineProperty(_,"name",{value:"node ("+(f.type+(v?"<"+v+">":""))+")"})}return _;function _(){let v=yk,y,S,j;if((!t||l(f,h,m[m.length-1]||void 0))&&(v=R8(s(f,m)),v[0]===gx))return v;if("children"in f&&f.children){const k=f;if(k.children&&v[0]!==A8)for(S=(n?k.children.length:-1)+c,j=m.concat(k);S>-1&&S<k.children.length;){const N=k.children[S];if(y=d(N,S,j)(),y[0]===gx)return y;S=typeof y[1]=="number"?y[1]:S+c}}return v}}}function R8(e){return Array.isArray(e)?e:typeof e=="number"?[T8,e]:e==null?yk:[e]}function H0(e,t,s,n){let a,l,c;typeof t=="function"&&typeof s!="function"?(l=void 0,c=t,a=s):(l=t,c=s,a=n),wk(e,l,d,a);function d(f,h){const m=h[h.length-1],g=m?m.children.indexOf(f):void 0;return c(f,g,m)}}const xx={}.hasOwnProperty,D8={};function L8(e,t){const s=t||D8,n=new Map,a=new Map,l=new Map,c={...x8,...s.handlers},d={all:h,applyData:O8,definitionById:n,footnoteById:a,footnoteCounts:l,footnoteOrder:[],handlers:c,one:f,options:s,patch:B8,wrap:P8};return H0(e,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const g=m.type==="definition"?n:a,_=String(m.identifier).toUpperCase();g.has(_)||g.set(_,m)}}),d;function f(m,g){const _=m.type,v=d.handlers[_];if(xx.call(d.handlers,_)&&v)return v(d,m,g);if(d.options.passThrough&&d.options.passThrough.includes(_)){if("children"in m){const{children:S,...j}=m,k=Eh(j);return k.children=d.all(m),k}return Eh(m)}return(d.options.unknownHandler||z8)(d,m,g)}function h(m){const g=[];if("children"in m){const _=m.children;let v=-1;for(;++v<_.length;){const y=d.one(_[v],m);if(y){if(v&&_[v-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=t5(y.value)),!Array.isArray(y)&&y.type==="element")){const S=y.children[0];S&&S.type==="text"&&(S.value=t5(S.value))}Array.isArray(y)?g.push(...y):g.push(y)}}}return g}}function B8(e,t){e.position&&(t.position=ST(e))}function O8(e,t){let s=t;if(e&&e.data){const n=e.data.hName,a=e.data.hChildren,l=e.data.hProperties;if(typeof n=="string")if(s.type==="element")s.tagName=n;else{const c="children"in s?s.children:[s];s={type:"element",tagName:n,properties:{},children:c}}s.type==="element"&&l&&Object.assign(s.properties,Eh(l)),"children"in s&&s.children&&a!==null&&a!==void 0&&(s.children=a)}return s}function z8(e,t){const s=t.data||{},n="value"in t&&!(xx.call(s,"hProperties")||xx.call(s,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function P8(e,t){const s=[];let n=-1;for(t&&s.push({type:"text",value:`
65
+ `});++n<e.length;)n&&s.push({type:"text",value:`
66
+ `}),s.push(e[n]);return t&&e.length>0&&s.push({type:"text",value:`
67
+ `}),s}function t5(e){let t=0,s=e.charCodeAt(t);for(;s===9||s===32;)t++,s=e.charCodeAt(t);return e.slice(t)}function s5(e,t){const s=L8(e,t),n=s.one(e,void 0),a=j8(s),l=Array.isArray(n)?{type:"root",children:n}:n||{type:"root",children:[]};return a&&l.children.push({type:"text",value:`
68
+ `},a),l}function $8(e,t){return e&&"run"in e?async function(s,n){const a=s5(s,{file:n,...t});await e.run(a,n)}:function(s,n){return s5(s,{file:n,...e||t})}}function n5(e){if(e)throw e}var qm,r5;function I8(){if(r5)return qm;r5=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,s=Object.defineProperty,n=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},l=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var m=e.call(h,"constructor"),g=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!m&&!g)return!1;var _;for(_ in h);return typeof _>"u"||e.call(h,_)},c=function(h,m){s&&m.name==="__proto__"?s(h,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):h[m.name]=m.newValue},d=function(h,m){if(m==="__proto__")if(e.call(h,m)){if(n)return n(h,m).value}else return;return h[m]};return qm=function f(){var h,m,g,_,v,y,S=arguments[0],j=1,k=arguments.length,N=!1;for(typeof S=="boolean"&&(N=S,S=arguments[1]||{},j=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});j<k;++j)if(h=arguments[j],h!=null)for(m in h)g=d(S,m),_=d(h,m),S!==_&&(N&&_&&(l(_)||(v=a(_)))?(v?(v=!1,y=g&&a(g)?g:[]):y=g&&l(g)?g:{},c(S,{name:m,newValue:f(N,y,_)})):typeof _<"u"&&c(S,{name:m,newValue:_}));return S},qm}var F8=I8();const Gm=p0(F8);function vx(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function H8(){const e=[],t={run:s,use:n};return t;function s(...a){let l=-1;const c=a.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);d(null,...a);function d(f,...h){const m=e[++l];let g=-1;if(f){c(f);return}for(;++g<a.length;)(h[g]===null||h[g]===void 0)&&(h[g]=a[g]);a=h,m?U8(m,d)(...h):c(null,...h)}}function n(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function U8(e,t){let s;return n;function n(...c){const d=e.length>c.length;let f;d&&c.push(a);try{f=e.apply(this,c)}catch(h){const m=h;if(d&&s)throw m;return a(m)}d||(f&&f.then&&typeof f.then=="function"?f.then(l,a):f instanceof Error?a(f):l(f))}function a(c,...d){s||(s=!0,t(c,...d))}function l(c){a(null,c)}}const mr={basename:V8,dirname:W8,extname:q8,join:G8,sep:"/"};function V8(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');cu(e);let s=0,n=-1,a=e.length,l;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(l){s=a+1;break}}else n<0&&(l=!0,n=a+1);return n<0?"":e.slice(s,n)}if(t===e)return"";let c=-1,d=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(l){s=a+1;break}}else c<0&&(l=!0,c=a+1),d>-1&&(e.codePointAt(a)===t.codePointAt(d--)?d<0&&(n=a):(d=-1,n=c));return s===n?n=c:n<0&&(n=e.length),e.slice(s,n)}function W8(e){if(cu(e),e.length===0)return".";let t=-1,s=e.length,n;for(;--s;)if(e.codePointAt(s)===47){if(n){t=s;break}}else n||(n=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function q8(e){cu(e);let t=e.length,s=-1,n=0,a=-1,l=0,c;for(;t--;){const d=e.codePointAt(t);if(d===47){if(c){n=t+1;break}continue}s<0&&(c=!0,s=t+1),d===46?a<0?a=t:l!==1&&(l=1):a>-1&&(l=-1)}return a<0||s<0||l===0||l===1&&a===s-1&&a===n+1?"":e.slice(a,s)}function G8(...e){let t=-1,s;for(;++t<e.length;)cu(e[t]),e[t]&&(s=s===void 0?e[t]:s+"/"+e[t]);return s===void 0?".":K8(s)}function K8(e){cu(e);const t=e.codePointAt(0)===47;let s=Y8(e,!t);return s.length===0&&!t&&(s="."),s.length>0&&e.codePointAt(e.length-1)===47&&(s+="/"),t?"/"+s:s}function Y8(e,t){let s="",n=0,a=-1,l=0,c=-1,d,f;for(;++c<=e.length;){if(c<e.length)d=e.codePointAt(c);else{if(d===47)break;d=47}if(d===47){if(!(a===c-1||l===1))if(a!==c-1&&l===2){if(s.length<2||n!==2||s.codePointAt(s.length-1)!==46||s.codePointAt(s.length-2)!==46){if(s.length>2){if(f=s.lastIndexOf("/"),f!==s.length-1){f<0?(s="",n=0):(s=s.slice(0,f),n=s.length-1-s.lastIndexOf("/")),a=c,l=0;continue}}else if(s.length>0){s="",n=0,a=c,l=0;continue}}t&&(s=s.length>0?s+"/..":"..",n=2)}else s.length>0?s+="/"+e.slice(a+1,c):s=e.slice(a+1,c),n=c-a-1;a=c,l=0}else d===46&&l>-1?l++:l=-1}return s}function cu(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const X8={cwd:J8};function J8(){return"/"}function bx(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Q8(e){if(typeof e=="string")e=new URL(e);else if(!bx(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return Z8(e)}function Z8(e){if(e.hostname!==""){const n=new TypeError('File URL host must be "localhost" or empty on darwin');throw n.code="ERR_INVALID_FILE_URL_HOST",n}const t=e.pathname;let s=-1;for(;++s<t.length;)if(t.codePointAt(s)===37&&t.codePointAt(s+1)===50){const n=t.codePointAt(s+2);if(n===70||n===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(t)}const Km=["history","path","basename","stem","extname","dirname"];class Sk{constructor(t){let s;t?bx(t)?s={path:t}:typeof t=="string"||eR(t)?s={value:t}:s=t:s={},this.cwd="cwd"in s?"":X8.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Km.length;){const l=Km[n];l in s&&s[l]!==void 0&&s[l]!==null&&(this[l]=l==="history"?[...s[l]]:s[l])}let a;for(a in s)Km.includes(a)||(this[a]=s[a])}get basename(){return typeof this.path=="string"?mr.basename(this.path):void 0}set basename(t){Xm(t,"basename"),Ym(t,"basename"),this.path=mr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?mr.dirname(this.path):void 0}set dirname(t){i5(this.basename,"dirname"),this.path=mr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?mr.extname(this.path):void 0}set extname(t){if(Ym(t,"extname"),i5(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=mr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){bx(t)&&(t=Q8(t)),Xm(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?mr.basename(this.path,this.extname):void 0}set stem(t){Xm(t,"stem"),Ym(t,"stem"),this.path=mr.join(this.dirname||"",t+(this.extname||""))}fail(t,s,n){const a=this.message(t,s,n);throw a.fatal=!0,a}info(t,s,n){const a=this.message(t,s,n);return a.fatal=void 0,a}message(t,s,n){const a=new qs(t,s,n);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Ym(e,t){if(e&&e.includes(mr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+mr.sep+"`")}function Xm(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function i5(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function eR(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const tR=(function(e){const n=this.constructor.prototype,a=n[e],l=function(){return a.apply(l,arguments)};return Object.setPrototypeOf(l,n),l}),sR={}.hasOwnProperty;class U0 extends tR{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=H8()}copy(){const t=new U0;let s=-1;for(;++s<this.attachers.length;){const n=this.attachers[s];t.use(...n)}return t.data(Gm(!0,{},this.namespace)),t}data(t,s){return typeof t=="string"?arguments.length===2?(Zm("data",this.frozen),this.namespace[t]=s,this):sR.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Zm("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[s,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);const a=s.call(t,...n);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const s=Pd(t),n=this.parser||this.Parser;return Jm("parse",n),n(String(s),s)}process(t,s){const n=this;return this.freeze(),Jm("process",this.parser||this.Parser),Qm("process",this.compiler||this.Compiler),s?a(void 0,s):new Promise(a);function a(l,c){const d=Pd(t),f=n.parse(d);n.run(f,d,function(m,g,_){if(m||!g||!_)return h(m);const v=g,y=n.stringify(v,_);iR(y)?_.value=y:_.result=y,h(m,_)});function h(m,g){m||!g?c(m):l?l(g):s(void 0,g)}}}processSync(t){let s=!1,n;return this.freeze(),Jm("processSync",this.parser||this.Parser),Qm("processSync",this.compiler||this.Compiler),this.process(t,a),o5("processSync","process",s),n;function a(l,c){s=!0,n5(l),n=c}}run(t,s,n){a5(t),this.freeze();const a=this.transformers;return!n&&typeof s=="function"&&(n=s,s=void 0),n?l(void 0,n):new Promise(l);function l(c,d){const f=Pd(s);a.run(t,f,h);function h(m,g,_){const v=g||t;m?d(m):c?c(v):n(void 0,v,_)}}}runSync(t,s){let n=!1,a;return this.run(t,s,l),o5("runSync","run",n),a;function l(c,d){n5(c),a=d,n=!0}}stringify(t,s){this.freeze();const n=Pd(s),a=this.compiler||this.Compiler;return Qm("stringify",a),a5(t),a(t,n)}use(t,...s){const n=this.attachers,a=this.namespace;if(Zm("use",this.frozen),t!=null)if(typeof t=="function")f(t,s);else if(typeof t=="object")Array.isArray(t)?d(t):c(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function l(h){if(typeof h=="function")f(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[m,...g]=h;f(m,g)}else c(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function c(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");d(h.plugins),h.settings&&(a.settings=Gm(!0,a.settings,h.settings))}function d(h){let m=-1;if(h!=null)if(Array.isArray(h))for(;++m<h.length;){const g=h[m];l(g)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function f(h,m){let g=-1,_=-1;for(;++g<n.length;)if(n[g][0]===h){_=g;break}if(_===-1)n.push([h,...m]);else if(m.length>0){let[v,...y]=m;const S=n[_][1];vx(S)&&vx(v)&&(v=Gm(!0,S,v)),n[_]=[h,v,...y]}}}}const nR=new U0().freeze();function Jm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Qm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Zm(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function a5(e){if(!vx(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function o5(e,t,s){if(!s)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Pd(e){return rR(e)?e:new Sk(e)}function rR(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function iR(e){return typeof e=="string"||aR(e)}function aR(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const oR="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",l5=[],c5={allowDangerousHtml:!0},lR=/^(https?|ircs?|mailto|xmpp)$/i,cR=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function V0(e){const t=uR(e),s=dR(e);return hR(t.runSync(t.parse(s),s),e)}function uR(e){const t=e.rehypePlugins||l5,s=e.remarkPlugins||l5,n=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...c5}:c5;return nR().use(W7).use(s).use($8,n).use(t)}function dR(e){const t=e.children||"",s=new Sk;return typeof t=="string"&&(s.value=t),s}function hR(e,t){const s=t.allowedElements,n=t.allowElement,a=t.components,l=t.disallowedElements,c=t.skipHtml,d=t.unwrapDisallowed,f=t.urlTransform||fR;for(const m of cR)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+oR+m.id,void 0);return H0(e,h),ET(e,{Fragment:r.Fragment,components:a,ignoreInvalidStyle:!0,jsx:r.jsx,jsxs:r.jsxs,passKeys:!0,passNode:!0});function h(m,g,_){if(m.type==="raw"&&_&&typeof g=="number")return c?_.children.splice(g,1):_.children[g]={type:"text",value:m.value},g;if(m.type==="element"){let v;for(v in Um)if(Object.hasOwn(Um,v)&&Object.hasOwn(m.properties,v)){const y=m.properties[v],S=Um[v];(S===null||S.includes(m.tagName))&&(m.properties[v]=f(String(y||""),v,m))}}if(m.type==="element"){let v=s?!s.includes(m.tagName):l?l.includes(m.tagName):!1;if(!v&&n&&typeof g=="number"&&(v=!n(m,g,_)),v&&_&&typeof g=="number")return d&&m.children?_.children.splice(g,1,...m.children):_.children.splice(g,1),g}}}function fR(e){const t=e.indexOf(":"),s=e.indexOf("?"),n=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||s!==-1&&t>s||n!==-1&&t>n||lR.test(e.slice(0,t))?e:""}function u5(e,t){const s=String(e);if(typeof t!="string")throw new TypeError("Expected character");let n=0,a=s.indexOf(t);for(;a!==-1;)n++,a=s.indexOf(t,a+t.length);return n}function pR(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function mR(e,t,s){const a=Gh((s||{}).ignore||[]),l=gR(t);let c=-1;for(;++c<l.length;)wk(e,"text",d);function d(h,m){let g=-1,_;for(;++g<m.length;){const v=m[g],y=_?_.children:void 0;if(a(v,y?y.indexOf(v):void 0,_))return;_=v}if(_)return f(h,m)}function f(h,m){const g=m[m.length-1],_=l[c][0],v=l[c][1];let y=0;const j=g.children.indexOf(h);let k=!1,N=[];_.lastIndex=0;let E=_.exec(h.value);for(;E;){const B=E.index,F={index:E.index,input:E.input,stack:[...m,h]};let $=v(...E,F);if(typeof $=="string"&&($=$.length>0?{type:"text",value:$}:void 0),$===!1?_.lastIndex=B+1:(y!==B&&N.push({type:"text",value:h.value.slice(y,B)}),Array.isArray($)?N.push(...$):$&&N.push($),y=B+E[0].length,k=!0),!_.global)break;E=_.exec(h.value)}return k?(y<h.value.length&&N.push({type:"text",value:h.value.slice(y)}),g.children.splice(j,1,...N)):N=[h],j+N.length}}function gR(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const s=!e[0]||Array.isArray(e[0])?e:[e];let n=-1;for(;++n<s.length;){const a=s[n];t.push([xR(a[0]),vR(a[1])])}return t}function xR(e){return typeof e=="string"?new RegExp(pR(e),"g"):e}function vR(e){return typeof e=="function"?e:function(){return e}}const eg="phrasing",tg=["autolink","link","image","label"];function bR(){return{transforms:[CR],enter:{literalAutolink:yR,literalAutolinkEmail:sg,literalAutolinkHttp:sg,literalAutolinkWww:sg},exit:{literalAutolink:kR,literalAutolinkEmail:jR,literalAutolinkHttp:wR,literalAutolinkWww:SR}}}function _R(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:eg,notInConstruct:tg},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:eg,notInConstruct:tg},{character:":",before:"[ps]",after:"\\/",inConstruct:eg,notInConstruct:tg}]}}function yR(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function sg(e){this.config.enter.autolinkProtocol.call(this,e)}function wR(e){this.config.exit.autolinkProtocol.call(this,e)}function SR(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function jR(e){this.config.exit.autolinkEmail.call(this,e)}function kR(e){this.exit(e)}function CR(e){mR(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,NR],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),ER]],{ignore:["link","linkReference"]})}function NR(e,t,s,n,a){let l="";if(!jk(a)||(/^w/i.test(t)&&(s=t+s,t="",l="http://"),!MR(s)))return!1;const c=TR(s+n);if(!c[0])return!1;const d={type:"link",title:null,url:l+t+c[0],children:[{type:"text",value:t+c[0]}]};return c[1]?[d,{type:"text",value:c[1]}]:d}function ER(e,t,s,n){return!jk(n,!0)||/[-\d_]$/.test(s)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+s,children:[{type:"text",value:t+"@"+s}]}}function MR(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function TR(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let s=t[0],n=s.indexOf(")");const a=u5(e,"(");let l=u5(e,")");for(;n!==-1&&a>l;)e+=s.slice(0,n+1),s=s.slice(n+1),n=s.indexOf(")"),l++;return[e,s]}function jk(e,t){const s=e.input.charCodeAt(e.index-1);return(e.index===0||Ma(s)||Vh(s))&&(!t||s!==47)}kk.peek=$R;function AR(){this.buffer()}function RR(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function DR(){this.buffer()}function LR(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function BR(e){const t=this.resume(),s=this.stack[this.stack.length-1];s.type,s.identifier=sr(this.sliceSerialize(e)).toLowerCase(),s.label=t}function OR(e){this.exit(e)}function zR(e){const t=this.resume(),s=this.stack[this.stack.length-1];s.type,s.identifier=sr(this.sliceSerialize(e)).toLowerCase(),s.label=t}function PR(e){this.exit(e)}function $R(){return"["}function kk(e,t,s,n){const a=s.createTracker(n);let l=a.move("[^");const c=s.enter("footnoteReference"),d=s.enter("reference");return l+=a.move(s.safe(s.associationId(e),{after:"]",before:l})),d(),c(),l+=a.move("]"),l}function IR(){return{enter:{gfmFootnoteCallString:AR,gfmFootnoteCall:RR,gfmFootnoteDefinitionLabelString:DR,gfmFootnoteDefinition:LR},exit:{gfmFootnoteCallString:BR,gfmFootnoteCall:OR,gfmFootnoteDefinitionLabelString:zR,gfmFootnoteDefinition:PR}}}function FR(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:s,footnoteReference:kk},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function s(n,a,l,c){const d=l.createTracker(c);let f=d.move("[^");const h=l.enter("footnoteDefinition"),m=l.enter("label");return f+=d.move(l.safe(l.associationId(n),{before:f,after:"]"})),m(),f+=d.move("]:"),n.children&&n.children.length>0&&(d.shift(4),f+=d.move((t?`
69
+ `:" ")+l.indentLines(l.containerFlow(n,d.current()),t?Ck:HR))),h(),f}}function HR(e,t,s){return t===0?e:Ck(e,t,s)}function Ck(e,t,s){return(s?"":" ")+e}const UR=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Nk.peek=KR;function VR(){return{canContainEols:["delete"],enter:{strikethrough:qR},exit:{strikethrough:GR}}}function WR(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:UR}],handlers:{delete:Nk}}}function qR(e){this.enter({type:"delete",children:[]},e)}function GR(e){this.exit(e)}function Nk(e,t,s,n){const a=s.createTracker(n),l=s.enter("strikethrough");let c=a.move("~~");return c+=s.containerPhrasing(e,{...a.current(),before:c,after:"~"}),c+=a.move("~~"),l(),c}function KR(){return"~"}function YR(e){return e.length}function XR(e,t){const s=t||{},n=(s.align||[]).concat(),a=s.stringLength||YR,l=[],c=[],d=[],f=[];let h=0,m=-1;for(;++m<e.length;){const S=[],j=[];let k=-1;for(e[m].length>h&&(h=e[m].length);++k<e[m].length;){const N=JR(e[m][k]);if(s.alignDelimiters!==!1){const E=a(N);j[k]=E,(f[k]===void 0||E>f[k])&&(f[k]=E)}S.push(N)}c[m]=S,d[m]=j}let g=-1;if(typeof n=="object"&&"length"in n)for(;++g<h;)l[g]=d5(n[g]);else{const S=d5(n);for(;++g<h;)l[g]=S}g=-1;const _=[],v=[];for(;++g<h;){const S=l[g];let j="",k="";S===99?(j=":",k=":"):S===108?j=":":S===114&&(k=":");let N=s.alignDelimiters===!1?1:Math.max(1,f[g]-j.length-k.length);const E=j+"-".repeat(N)+k;s.alignDelimiters!==!1&&(N=j.length+N+k.length,N>f[g]&&(f[g]=N),v[g]=N),_[g]=E}c.splice(1,0,_),d.splice(1,0,v),m=-1;const y=[];for(;++m<c.length;){const S=c[m],j=d[m];g=-1;const k=[];for(;++g<h;){const N=S[g]||"";let E="",B="";if(s.alignDelimiters!==!1){const F=f[g]-(j[g]||0),$=l[g];$===114?E=" ".repeat(F):$===99?F%2?(E=" ".repeat(F/2+.5),B=" ".repeat(F/2-.5)):(E=" ".repeat(F/2),B=E):B=" ".repeat(F)}s.delimiterStart!==!1&&!g&&k.push("|"),s.padding!==!1&&!(s.alignDelimiters===!1&&N==="")&&(s.delimiterStart!==!1||g)&&k.push(" "),s.alignDelimiters!==!1&&k.push(E),k.push(N),s.alignDelimiters!==!1&&k.push(B),s.padding!==!1&&k.push(" "),(s.delimiterEnd!==!1||g!==h-1)&&k.push("|")}y.push(s.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return y.join(`
70
+ `)}function JR(e){return e==null?"":String(e)}function d5(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function QR(e,t,s,n){const a=s.enter("blockquote"),l=s.createTracker(n);l.move("> "),l.shift(2);const c=s.indentLines(s.containerFlow(e,l.current()),ZR);return a(),c}function ZR(e,t,s){return">"+(s?"":" ")+e}function eD(e,t){return h5(e,t.inConstruct,!0)&&!h5(e,t.notInConstruct,!1)}function h5(e,t,s){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return s;let n=-1;for(;++n<t.length;)if(e.includes(t[n]))return!0;return!1}function f5(e,t,s,n){let a=-1;for(;++a<s.unsafe.length;)if(s.unsafe[a].character===`
71
+ `&&eD(s.stack,s.unsafe[a]))return/[ \t]/.test(n.before)?"":" ";return`\\
72
+ `}function tD(e,t){const s=String(e);let n=s.indexOf(t),a=n,l=0,c=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;n!==-1;)n===a?++l>c&&(c=l):l=1,a=n+t.length,n=s.indexOf(t,a);return c}function sD(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function nD(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function rD(e,t,s,n){const a=nD(s),l=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(sD(e,s)){const g=s.enter("codeIndented"),_=s.indentLines(l,iD);return g(),_}const d=s.createTracker(n),f=a.repeat(Math.max(tD(l,a)+1,3)),h=s.enter("codeFenced");let m=d.move(f);if(e.lang){const g=s.enter(`codeFencedLang${c}`);m+=d.move(s.safe(e.lang,{before:m,after:" ",encode:["`"],...d.current()})),g()}if(e.lang&&e.meta){const g=s.enter(`codeFencedMeta${c}`);m+=d.move(" "),m+=d.move(s.safe(e.meta,{before:m,after:`
73
+ `,encode:["`"],...d.current()})),g()}return m+=d.move(`
74
+ `),l&&(m+=d.move(l+`
75
+ `)),m+=d.move(f),h(),m}function iD(e,t,s){return(s?"":" ")+e}function W0(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function aD(e,t,s,n){const a=W0(s),l=a==='"'?"Quote":"Apostrophe",c=s.enter("definition");let d=s.enter("label");const f=s.createTracker(n);let h=f.move("[");return h+=f.move(s.safe(s.associationId(e),{before:h,after:"]",...f.current()})),h+=f.move("]: "),d(),!e.url||/[\0- \u007F]/.test(e.url)?(d=s.enter("destinationLiteral"),h+=f.move("<"),h+=f.move(s.safe(e.url,{before:h,after:">",...f.current()})),h+=f.move(">")):(d=s.enter("destinationRaw"),h+=f.move(s.safe(e.url,{before:h,after:e.title?" ":`
76
+ `,...f.current()}))),d(),e.title&&(d=s.enter(`title${l}`),h+=f.move(" "+a),h+=f.move(s.safe(e.title,{before:h,after:a,...f.current()})),h+=f.move(a),d()),c(),h}function oD(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Xc(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Mh(e,t,s){const n=Go(e),a=Go(t);return n===void 0?a===void 0?s==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:n===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Ek.peek=lD;function Ek(e,t,s,n){const a=oD(s),l=s.enter("emphasis"),c=s.createTracker(n),d=c.move(a);let f=c.move(s.containerPhrasing(e,{after:a,before:d,...c.current()}));const h=f.charCodeAt(0),m=Mh(n.before.charCodeAt(n.before.length-1),h,a);m.inside&&(f=Xc(h)+f.slice(1));const g=f.charCodeAt(f.length-1),_=Mh(n.after.charCodeAt(0),g,a);_.inside&&(f=f.slice(0,-1)+Xc(g));const v=c.move(a);return l(),s.attentionEncodeSurroundingInfo={after:_.outside,before:m.outside},d+f+v}function lD(e,t,s){return s.options.emphasis||"*"}function cD(e,t){let s=!1;return H0(e,function(n){if("value"in n&&/\r?\n|\r/.test(n.value)||n.type==="break")return s=!0,gx}),!!((!e.depth||e.depth<3)&&B0(e)&&(t.options.setext||s))}function uD(e,t,s,n){const a=Math.max(Math.min(6,e.depth||1),1),l=s.createTracker(n);if(cD(e,s)){const m=s.enter("headingSetext"),g=s.enter("phrasing"),_=s.containerPhrasing(e,{...l.current(),before:`
77
+ `,after:`
78
+ `});return g(),m(),_+`
79
+ `+(a===1?"=":"-").repeat(_.length-(Math.max(_.lastIndexOf("\r"),_.lastIndexOf(`
80
+ `))+1))}const c="#".repeat(a),d=s.enter("headingAtx"),f=s.enter("phrasing");l.move(c+" ");let h=s.containerPhrasing(e,{before:"# ",after:`
81
+ `,...l.current()});return/^[\t ]/.test(h)&&(h=Xc(h.charCodeAt(0))+h.slice(1)),h=h?c+" "+h:c,s.options.closeAtx&&(h+=" "+c),f(),d(),h}Mk.peek=dD;function Mk(e){return e.value||""}function dD(){return"<"}Tk.peek=hD;function Tk(e,t,s,n){const a=W0(s),l=a==='"'?"Quote":"Apostrophe",c=s.enter("image");let d=s.enter("label");const f=s.createTracker(n);let h=f.move("![");return h+=f.move(s.safe(e.alt,{before:h,after:"]",...f.current()})),h+=f.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=s.enter("destinationLiteral"),h+=f.move("<"),h+=f.move(s.safe(e.url,{before:h,after:">",...f.current()})),h+=f.move(">")):(d=s.enter("destinationRaw"),h+=f.move(s.safe(e.url,{before:h,after:e.title?" ":")",...f.current()}))),d(),e.title&&(d=s.enter(`title${l}`),h+=f.move(" "+a),h+=f.move(s.safe(e.title,{before:h,after:a,...f.current()})),h+=f.move(a),d()),h+=f.move(")"),c(),h}function hD(){return"!"}Ak.peek=fD;function Ak(e,t,s,n){const a=e.referenceType,l=s.enter("imageReference");let c=s.enter("label");const d=s.createTracker(n);let f=d.move("![");const h=s.safe(e.alt,{before:f,after:"]",...d.current()});f+=d.move(h+"]["),c();const m=s.stack;s.stack=[],c=s.enter("reference");const g=s.safe(s.associationId(e),{before:f,after:"]",...d.current()});return c(),s.stack=m,l(),a==="full"||!h||h!==g?f+=d.move(g+"]"):a==="shortcut"?f=f.slice(0,-1):f+=d.move("]"),f}function fD(){return"!"}Rk.peek=pD;function Rk(e,t,s){let n=e.value||"",a="`",l=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(n);)a+="`";for(/[^ \r\n]/.test(n)&&(/^[ \r\n]/.test(n)&&/[ \r\n]$/.test(n)||/^`|`$/.test(n))&&(n=" "+n+" ");++l<s.unsafe.length;){const c=s.unsafe[l],d=s.compilePattern(c);let f;if(c.atBreak)for(;f=d.exec(n);){let h=f.index;n.charCodeAt(h)===10&&n.charCodeAt(h-1)===13&&h--,n=n.slice(0,h)+" "+n.slice(f.index+1)}}return a+n+a}function pD(){return"`"}function Dk(e,t){const s=B0(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(s===e.url||"mailto:"+s===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Lk.peek=mD;function Lk(e,t,s,n){const a=W0(s),l=a==='"'?"Quote":"Apostrophe",c=s.createTracker(n);let d,f;if(Dk(e,s)){const m=s.stack;s.stack=[],d=s.enter("autolink");let g=c.move("<");return g+=c.move(s.containerPhrasing(e,{before:g,after:">",...c.current()})),g+=c.move(">"),d(),s.stack=m,g}d=s.enter("link"),f=s.enter("label");let h=c.move("[");return h+=c.move(s.containerPhrasing(e,{before:h,after:"](",...c.current()})),h+=c.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=s.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(s.safe(e.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(f=s.enter("destinationRaw"),h+=c.move(s.safe(e.url,{before:h,after:e.title?" ":")",...c.current()}))),f(),e.title&&(f=s.enter(`title${l}`),h+=c.move(" "+a),h+=c.move(s.safe(e.title,{before:h,after:a,...c.current()})),h+=c.move(a),f()),h+=c.move(")"),d(),h}function mD(e,t,s){return Dk(e,s)?"<":"["}Bk.peek=gD;function Bk(e,t,s,n){const a=e.referenceType,l=s.enter("linkReference");let c=s.enter("label");const d=s.createTracker(n);let f=d.move("[");const h=s.containerPhrasing(e,{before:f,after:"]",...d.current()});f+=d.move(h+"]["),c();const m=s.stack;s.stack=[],c=s.enter("reference");const g=s.safe(s.associationId(e),{before:f,after:"]",...d.current()});return c(),s.stack=m,l(),a==="full"||!h||h!==g?f+=d.move(g+"]"):a==="shortcut"?f=f.slice(0,-1):f+=d.move("]"),f}function gD(){return"["}function q0(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function xD(e){const t=q0(e),s=e.options.bulletOther;if(!s)return t==="*"?"-":"*";if(s!=="*"&&s!=="+"&&s!=="-")throw new Error("Cannot serialize items with `"+s+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(s===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+s+"`) to be different");return s}function vD(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Ok(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function bD(e,t,s,n){const a=s.enter("list"),l=s.bulletCurrent;let c=e.ordered?vD(s):q0(s);const d=e.ordered?c==="."?")":".":xD(s);let f=t&&s.bulletLastUsed?c===s.bulletLastUsed:!1;if(!e.ordered){const m=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&m&&(!m.children||!m.children[0])&&s.stack[s.stack.length-1]==="list"&&s.stack[s.stack.length-2]==="listItem"&&s.stack[s.stack.length-3]==="list"&&s.stack[s.stack.length-4]==="listItem"&&s.indexStack[s.indexStack.length-1]===0&&s.indexStack[s.indexStack.length-2]===0&&s.indexStack[s.indexStack.length-3]===0&&(f=!0),Ok(s)===c&&m){let g=-1;for(;++g<e.children.length;){const _=e.children[g];if(_&&_.type==="listItem"&&_.children&&_.children[0]&&_.children[0].type==="thematicBreak"){f=!0;break}}}}f&&(c=d),s.bulletCurrent=c;const h=s.containerFlow(e,n);return s.bulletLastUsed=c,s.bulletCurrent=l,a(),h}function _D(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function yD(e,t,s,n){const a=_D(s);let l=s.bulletCurrent||q0(s);t&&t.type==="list"&&t.ordered&&(l=(typeof t.start=="number"&&t.start>-1?t.start:1)+(s.options.incrementListMarker===!1?0:t.children.indexOf(e))+l);let c=l.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const d=s.createTracker(n);d.move(l+" ".repeat(c-l.length)),d.shift(c);const f=s.enter("listItem"),h=s.indentLines(s.containerFlow(e,d.current()),m);return f(),h;function m(g,_,v){return _?(v?"":" ".repeat(c))+g:(v?l:l+" ".repeat(c-l.length))+g}}function wD(e,t,s,n){const a=s.enter("paragraph"),l=s.enter("phrasing"),c=s.containerPhrasing(e,n);return l(),a(),c}const SD=Gh(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function jD(e,t,s,n){return(e.children.some(function(c){return SD(c)})?s.containerPhrasing:s.containerFlow).call(s,e,n)}function kD(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}zk.peek=CD;function zk(e,t,s,n){const a=kD(s),l=s.enter("strong"),c=s.createTracker(n),d=c.move(a+a);let f=c.move(s.containerPhrasing(e,{after:a,before:d,...c.current()}));const h=f.charCodeAt(0),m=Mh(n.before.charCodeAt(n.before.length-1),h,a);m.inside&&(f=Xc(h)+f.slice(1));const g=f.charCodeAt(f.length-1),_=Mh(n.after.charCodeAt(0),g,a);_.inside&&(f=f.slice(0,-1)+Xc(g));const v=c.move(a+a);return l(),s.attentionEncodeSurroundingInfo={after:_.outside,before:m.outside},d+f+v}function CD(e,t,s){return s.options.strong||"*"}function ND(e,t,s,n){return s.safe(e.value,n)}function ED(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function MD(e,t,s){const n=(Ok(s)+(s.options.ruleSpaces?" ":"")).repeat(ED(s));return s.options.ruleSpaces?n.slice(0,-1):n}const Pk={blockquote:QR,break:f5,code:rD,definition:aD,emphasis:Ek,hardBreak:f5,heading:uD,html:Mk,image:Tk,imageReference:Ak,inlineCode:Rk,link:Lk,linkReference:Bk,list:bD,listItem:yD,paragraph:wD,root:jD,strong:zk,text:ND,thematicBreak:MD};function TD(){return{enter:{table:AD,tableData:p5,tableHeader:p5,tableRow:DD},exit:{codeText:LD,table:RD,tableData:ng,tableHeader:ng,tableRow:ng}}}function AD(e){const t=e._align;this.enter({type:"table",align:t.map(function(s){return s==="none"?null:s}),children:[]},e),this.data.inTable=!0}function RD(e){this.exit(e),this.data.inTable=void 0}function DD(e){this.enter({type:"tableRow",children:[]},e)}function ng(e){this.exit(e)}function p5(e){this.enter({type:"tableCell",children:[]},e)}function LD(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,BD));const s=this.stack[this.stack.length-1];s.type,s.value=t,this.exit(e)}function BD(e,t){return t==="|"?t:e}function OD(e){const t=e||{},s=t.tableCellPadding,n=t.tablePipeAlign,a=t.stringLength,l=s?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
82
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:_,table:c,tableCell:f,tableRow:d}};function c(v,y,S,j){return h(m(v,S,j),v.align)}function d(v,y,S,j){const k=g(v,S,j),N=h([k]);return N.slice(0,N.indexOf(`
83
+ `))}function f(v,y,S,j){const k=S.enter("tableCell"),N=S.enter("phrasing"),E=S.containerPhrasing(v,{...j,before:l,after:l});return N(),k(),E}function h(v,y){return XR(v,{align:y,alignDelimiters:n,padding:s,stringLength:a})}function m(v,y,S){const j=v.children;let k=-1;const N=[],E=y.enter("table");for(;++k<j.length;)N[k]=g(j[k],y,S);return E(),N}function g(v,y,S){const j=v.children;let k=-1;const N=[],E=y.enter("tableRow");for(;++k<j.length;)N[k]=f(j[k],v,y,S);return E(),N}function _(v,y,S){let j=Pk.inlineCode(v,y,S);return S.stack.includes("tableCell")&&(j=j.replace(/\|/g,"\\$&")),j}}function zD(){return{exit:{taskListCheckValueChecked:m5,taskListCheckValueUnchecked:m5,paragraph:$D}}}function PD(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:ID}}}function m5(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function $D(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const s=this.stack[this.stack.length-1];s.type;const n=s.children[0];if(n&&n.type==="text"){const a=t.children;let l=-1,c;for(;++l<a.length;){const d=a[l];if(d.type==="paragraph"){c=d;break}}c===s&&(n.value=n.value.slice(1),n.value.length===0?s.children.shift():s.position&&n.position&&typeof n.position.start.offset=="number"&&(n.position.start.column++,n.position.start.offset++,s.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function ID(e,t,s,n){const a=e.children[0],l=typeof e.checked=="boolean"&&a&&a.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",d=s.createTracker(n);l&&d.move(c);let f=Pk.listItem(e,t,s,{...n,...d.current()});return l&&(f=f.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),f;function h(m){return m+c}}function FD(){return[bR(),IR(),VR(),TD(),zD()]}function HD(e){return{extensions:[_R(),FR(e),WR(),OD(e),PD()]}}const UD={tokenize:YD,partial:!0},$k={tokenize:XD,partial:!0},Ik={tokenize:JD,partial:!0},Fk={tokenize:QD,partial:!0},VD={tokenize:ZD,partial:!0},Hk={name:"wwwAutolink",tokenize:GD,previous:Vk},Uk={name:"protocolAutolink",tokenize:KD,previous:Wk},ri={name:"emailAutolink",tokenize:qD,previous:qk},kr={};function WD(){return{text:kr}}let ba=48;for(;ba<123;)kr[ba]=ri,ba++,ba===58?ba=65:ba===91&&(ba=97);kr[43]=ri;kr[45]=ri;kr[46]=ri;kr[95]=ri;kr[72]=[ri,Uk];kr[104]=[ri,Uk];kr[87]=[ri,Hk];kr[119]=[ri,Hk];function qD(e,t,s){const n=this;let a,l;return c;function c(g){return!_x(g)||!qk.call(n,n.previous)||G0(n.events)?s(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),d(g))}function d(g){return _x(g)?(e.consume(g),d):g===64?(e.consume(g),f):s(g)}function f(g){return g===46?e.check(VD,m,h)(g):g===45||g===95||Ws(g)?(l=!0,e.consume(g),f):m(g)}function h(g){return e.consume(g),a=!0,f}function m(g){return l&&a&&tn(n.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(g)):s(g)}}function GD(e,t,s){const n=this;return a;function a(c){return c!==87&&c!==119||!Vk.call(n,n.previous)||G0(n.events)?s(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(UD,e.attempt($k,e.attempt(Ik,l),s),s)(c))}function l(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(c)}}function KD(e,t,s){const n=this;let a="",l=!1;return c;function c(g){return(g===72||g===104)&&Wk.call(n,n.previous)&&!G0(n.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(g),e.consume(g),d):s(g)}function d(g){if(tn(g)&&a.length<5)return a+=String.fromCodePoint(g),e.consume(g),d;if(g===58){const _=a.toLowerCase();if(_==="http"||_==="https")return e.consume(g),f}return s(g)}function f(g){return g===47?(e.consume(g),l?h:(l=!0,f)):s(g)}function h(g){return g===null||Ch(g)||At(g)||Ma(g)||Vh(g)?s(g):e.attempt($k,e.attempt(Ik,m),s)(g)}function m(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(g)}}function YD(e,t,s){let n=0;return a;function a(c){return(c===87||c===119)&&n<3?(n++,e.consume(c),a):c===46&&n===3?(e.consume(c),l):s(c)}function l(c){return c===null?s(c):t(c)}}function XD(e,t,s){let n,a,l;return c;function c(h){return h===46||h===95?e.check(Fk,f,d)(h):h===null||At(h)||Ma(h)||h!==45&&Vh(h)?f(h):(l=!0,e.consume(h),c)}function d(h){return h===95?n=!0:(a=n,n=void 0),e.consume(h),c}function f(h){return a||n||!l?s(h):t(h)}}function JD(e,t){let s=0,n=0;return a;function a(c){return c===40?(s++,e.consume(c),a):c===41&&n<s?l(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(Fk,t,l)(c):c===null||At(c)||Ma(c)?t(c):(e.consume(c),a)}function l(c){return c===41&&n++,e.consume(c),a}}function QD(e,t,s){return n;function n(d){return d===33||d===34||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===63||d===95||d===126?(e.consume(d),n):d===38?(e.consume(d),l):d===93?(e.consume(d),a):d===60||d===null||At(d)||Ma(d)?t(d):s(d)}function a(d){return d===null||d===40||d===91||At(d)||Ma(d)?t(d):n(d)}function l(d){return tn(d)?c(d):s(d)}function c(d){return d===59?(e.consume(d),n):tn(d)?(e.consume(d),c):s(d)}}function ZD(e,t,s){return n;function n(l){return e.consume(l),a}function a(l){return Ws(l)?s(l):t(l)}}function Vk(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||At(e)}function Wk(e){return!tn(e)}function qk(e){return!(e===47||_x(e))}function _x(e){return e===43||e===45||e===46||e===95||Ws(e)}function G0(e){let t=e.length,s=!1;for(;t--;){const n=e[t][1];if((n.type==="labelLink"||n.type==="labelImage")&&!n._balanced){s=!0;break}if(n._gfmAutolinkLiteralWalkedInto){s=!1;break}}return e.length>0&&!s&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),s}const eL={tokenize:lL,partial:!0};function tL(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:iL,continuation:{tokenize:aL},exit:oL}},text:{91:{name:"gfmFootnoteCall",tokenize:rL},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:sL,resolveTo:nL}}}}function sL(e,t,s){const n=this;let a=n.events.length;const l=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let c;for(;a--;){const f=n.events[a][1];if(f.type==="labelImage"){c=f;break}if(f.type==="gfmFootnoteCall"||f.type==="labelLink"||f.type==="label"||f.type==="image"||f.type==="link")break}return d;function d(f){if(!c||!c._balanced)return s(f);const h=sr(n.sliceSerialize({start:c.end,end:n.now()}));return h.codePointAt(0)!==94||!l.includes(h.slice(1))?s(f):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),t(f))}}function nL(e,t){let s=e.length;for(;s--;)if(e[s][1].type==="labelImage"&&e[s][0]==="enter"){e[s][1];break}e[s+1][1].type="data",e[s+3][1].type="gfmFootnoteCallLabelMarker";const n={type:"gfmFootnoteCall",start:Object.assign({},e[s+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[s+3][1].end),end:Object.assign({},e[s+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const l={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},l.start),end:Object.assign({},l.end)},d=[e[s+1],e[s+2],["enter",n,t],e[s+3],e[s+4],["enter",a,t],["exit",a,t],["enter",l,t],["enter",c,t],["exit",c,t],["exit",l,t],e[e.length-2],e[e.length-1],["exit",n,t]];return e.splice(s,e.length-s+1,...d),e}function rL(e,t,s){const n=this,a=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let l=0,c;return d;function d(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),f}function f(g){return g!==94?s(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(g){if(l>999||g===93&&!c||g===null||g===91||At(g))return s(g);if(g===93){e.exit("chunkString");const _=e.exit("gfmFootnoteCallString");return a.includes(sr(n.sliceSerialize(_)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):s(g)}return At(g)||(c=!0),l++,e.consume(g),g===92?m:h}function m(g){return g===91||g===92||g===93?(e.consume(g),l++,h):h(g)}}function iL(e,t,s){const n=this,a=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let l,c=0,d;return f;function f(y){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(y){return y===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",m):s(y)}function m(y){if(c>999||y===93&&!d||y===null||y===91||At(y))return s(y);if(y===93){e.exit("chunkString");const S=e.exit("gfmFootnoteDefinitionLabelString");return l=sr(n.sliceSerialize(S)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),_}return At(y)||(d=!0),c++,e.consume(y),y===92?g:m}function g(y){return y===91||y===92||y===93?(e.consume(y),c++,m):m(y)}function _(y){return y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),a.includes(l)||a.push(l),ht(e,v,"gfmFootnoteDefinitionWhitespace")):s(y)}function v(y){return t(y)}}function aL(e,t,s){return e.check(lu,t,e.attempt(eL,t,s))}function oL(e){e.exit("gfmFootnoteDefinition")}function lL(e,t,s){const n=this;return ht(e,a,"gfmFootnoteDefinitionIndent",5);function a(l){const c=n.events[n.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(l):s(l)}}function cL(e){let s=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:l,resolveAll:a};return s==null&&(s=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function a(c,d){let f=-1;for(;++f<c.length;)if(c[f][0]==="enter"&&c[f][1].type==="strikethroughSequenceTemporary"&&c[f][1]._close){let h=f;for(;h--;)if(c[h][0]==="exit"&&c[h][1].type==="strikethroughSequenceTemporary"&&c[h][1]._open&&c[f][1].end.offset-c[f][1].start.offset===c[h][1].end.offset-c[h][1].start.offset){c[f][1].type="strikethroughSequence",c[h][1].type="strikethroughSequence";const m={type:"strikethrough",start:Object.assign({},c[h][1].start),end:Object.assign({},c[f][1].end)},g={type:"strikethroughText",start:Object.assign({},c[h][1].end),end:Object.assign({},c[f][1].start)},_=[["enter",m,d],["enter",c[h][1],d],["exit",c[h][1],d],["enter",g,d]],v=d.parser.constructs.insideSpan.null;v&&Rn(_,_.length,0,Wh(v,c.slice(h+1,f),d)),Rn(_,_.length,0,[["exit",g,d],["enter",c[f][1],d],["exit",c[f][1],d],["exit",m,d]]),Rn(c,h-1,f-h+3,_),f=h+_.length-2;break}}for(f=-1;++f<c.length;)c[f][1].type==="strikethroughSequenceTemporary"&&(c[f][1].type="data");return c}function l(c,d,f){const h=this.previous,m=this.events;let g=0;return _;function _(y){return h===126&&m[m.length-1][1].type!=="characterEscape"?f(y):(c.enter("strikethroughSequenceTemporary"),v(y))}function v(y){const S=Go(h);if(y===126)return g>1?f(y):(c.consume(y),g++,v);if(g<2&&!s)return f(y);const j=c.exit("strikethroughSequenceTemporary"),k=Go(y);return j._open=!k||k===2&&!!S,j._close=!S||S===2&&!!k,d(y)}}}class uL{constructor(){this.map=[]}add(t,s,n){dL(this,t,s,n)}consume(t){if(this.map.sort(function(l,c){return l[0]-c[0]}),this.map.length===0)return;let s=this.map.length;const n=[];for(;s>0;)s-=1,n.push(t.slice(this.map[s][0]+this.map[s][1]),this.map[s][2]),t.length=this.map[s][0];n.push(t.slice()),t.length=0;let a=n.pop();for(;a;){for(const l of a)t.push(l);a=n.pop()}this.map.length=0}}function dL(e,t,s,n){let a=0;if(!(s===0&&n.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=s,e.map[a][2].push(...n);return}a+=1}e.map.push([t,s,n])}}function hL(e,t){let s=!1;const n=[];for(;t<e.length;){const a=e[t];if(s){if(a[0]==="enter")a[1].type==="tableContent"&&n.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const l=n.length-1;n[l]=n[l]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(s=!0);t+=1}return n}function fL(){return{flow:{null:{name:"table",tokenize:pL,resolveAll:mL}}}}function pL(e,t,s){const n=this;let a=0,l=0,c;return d;function d(L){let Q=n.events.length-1;for(;Q>-1;){const q=n.events[Q][1].type;if(q==="lineEnding"||q==="linePrefix")Q--;else break}const V=Q>-1?n.events[Q][1].type:null,X=V==="tableHead"||V==="tableRow"?$:f;return X===$&&n.parser.lazy[n.now().line]?s(L):X(L)}function f(L){return e.enter("tableHead"),e.enter("tableRow"),h(L)}function h(L){return L===124||(c=!0,l+=1),m(L)}function m(L){return L===null?s(L):Ue(L)?l>1?(l=0,n.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),v):s(L):ot(L)?ht(e,m,"whitespace")(L):(l+=1,c&&(c=!1,a+=1),L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),c=!0,m):(e.enter("data"),g(L)))}function g(L){return L===null||L===124||At(L)?(e.exit("data"),m(L)):(e.consume(L),L===92?_:g)}function _(L){return L===92||L===124?(e.consume(L),g):g(L)}function v(L){return n.interrupt=!1,n.parser.lazy[n.now().line]?s(L):(e.enter("tableDelimiterRow"),c=!1,ot(L)?ht(e,y,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):y(L))}function y(L){return L===45||L===58?j(L):L===124?(c=!0,e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),S):F(L)}function S(L){return ot(L)?ht(e,j,"whitespace")(L):j(L)}function j(L){return L===58?(l+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),k):L===45?(l+=1,k(L)):L===null||Ue(L)?B(L):F(L)}function k(L){return L===45?(e.enter("tableDelimiterFiller"),N(L)):F(L)}function N(L){return L===45?(e.consume(L),N):L===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),E):(e.exit("tableDelimiterFiller"),E(L))}function E(L){return ot(L)?ht(e,B,"whitespace")(L):B(L)}function B(L){return L===124?y(L):L===null||Ue(L)?!c||a!==l?F(L):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(L)):F(L)}function F(L){return s(L)}function $(L){return e.enter("tableRow"),K(L)}function K(L){return L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),K):L===null||Ue(L)?(e.exit("tableRow"),t(L)):ot(L)?ht(e,K,"whitespace")(L):(e.enter("data"),Y(L))}function Y(L){return L===null||L===124||At(L)?(e.exit("data"),K(L)):(e.consume(L),L===92?W:Y)}function W(L){return L===92||L===124?(e.consume(L),Y):Y(L)}}function mL(e,t){let s=-1,n=!0,a=0,l=[0,0,0,0],c=[0,0,0,0],d=!1,f=0,h,m,g;const _=new uL;for(;++s<e.length;){const v=e[s],y=v[1];v[0]==="enter"?y.type==="tableHead"?(d=!1,f!==0&&(g5(_,t,f,h,m),m=void 0,f=0),h={type:"table",start:Object.assign({},y.start),end:Object.assign({},y.end)},_.add(s,0,[["enter",h,t]])):y.type==="tableRow"||y.type==="tableDelimiterRow"?(n=!0,g=void 0,l=[0,0,0,0],c=[0,s+1,0,0],d&&(d=!1,m={type:"tableBody",start:Object.assign({},y.start),end:Object.assign({},y.end)},_.add(s,0,[["enter",m,t]])),a=y.type==="tableDelimiterRow"?2:m?3:1):a&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")?(n=!1,c[2]===0&&(l[1]!==0&&(c[0]=c[1],g=$d(_,t,l,a,void 0,g),l=[0,0,0,0]),c[2]=s)):y.type==="tableCellDivider"&&(n?n=!1:(l[1]!==0&&(c[0]=c[1],g=$d(_,t,l,a,void 0,g)),l=c,c=[l[1],s,0,0])):y.type==="tableHead"?(d=!0,f=s):y.type==="tableRow"||y.type==="tableDelimiterRow"?(f=s,l[1]!==0?(c[0]=c[1],g=$d(_,t,l,a,s,g)):c[1]!==0&&(g=$d(_,t,c,a,s,g)),a=0):a&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(c[3]=s)}for(f!==0&&g5(_,t,f,h,m),_.consume(t.events),s=-1;++s<t.events.length;){const v=t.events[s];v[0]==="enter"&&v[1].type==="table"&&(v[1]._align=hL(t.events,s))}return e}function $d(e,t,s,n,a,l){const c=n===1?"tableHeader":n===2?"tableDelimiter":"tableData",d="tableContent";s[0]!==0&&(l.end=Object.assign({},Ro(t.events,s[0])),e.add(s[0],0,[["exit",l,t]]));const f=Ro(t.events,s[1]);if(l={type:c,start:Object.assign({},f),end:Object.assign({},f)},e.add(s[1],0,[["enter",l,t]]),s[2]!==0){const h=Ro(t.events,s[2]),m=Ro(t.events,s[3]),g={type:d,start:Object.assign({},h),end:Object.assign({},m)};if(e.add(s[2],0,[["enter",g,t]]),n!==2){const _=t.events[s[2]],v=t.events[s[3]];if(_[1].end=Object.assign({},v[1].end),_[1].type="chunkText",_[1].contentType="text",s[3]>s[2]+1){const y=s[2]+1,S=s[3]-s[2]-1;e.add(y,S,[])}}e.add(s[3]+1,0,[["exit",g,t]])}return a!==void 0&&(l.end=Object.assign({},Ro(t.events,a)),e.add(a,0,[["exit",l,t]]),l=void 0),l}function g5(e,t,s,n,a){const l=[],c=Ro(t.events,s);a&&(a.end=Object.assign({},c),l.push(["exit",a,t])),n.end=Object.assign({},c),l.push(["exit",n,t]),e.add(s+1,0,l)}function Ro(e,t){const s=e[t],n=s[0]==="enter"?"start":"end";return s[1][n]}const gL={name:"tasklistCheck",tokenize:vL};function xL(){return{text:{91:gL}}}function vL(e,t,s){const n=this;return a;function a(f){return n.previous!==null||!n._gfmTasklistFirstContentOfListItem?s(f):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(f),e.exit("taskListCheckMarker"),l)}function l(f){return At(f)?(e.enter("taskListCheckValueUnchecked"),e.consume(f),e.exit("taskListCheckValueUnchecked"),c):f===88||f===120?(e.enter("taskListCheckValueChecked"),e.consume(f),e.exit("taskListCheckValueChecked"),c):s(f)}function c(f){return f===93?(e.enter("taskListCheckMarker"),e.consume(f),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),d):s(f)}function d(f){return Ue(f)?t(f):ot(f)?e.check({tokenize:bL},t,s)(f):s(f)}}function bL(e,t,s){return ht(e,n,"whitespace");function n(a){return a===null?s(a):t(a)}}function _L(e){return nk([WD(),tL(),cL(e),fL(),xL()])}const yL={};function K0(e){const t=this,s=e||yL,n=t.data(),a=n.micromarkExtensions||(n.micromarkExtensions=[]),l=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),c=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);a.push(_L(s)),l.push(FD()),c.push(HD(s))}class Gk{diff(t,s,n={}){let a;typeof n=="function"?(a=n,n={}):"callback"in n&&(a=n.callback);const l=this.castInput(t,n),c=this.castInput(s,n),d=this.removeEmpty(this.tokenize(l,n)),f=this.removeEmpty(this.tokenize(c,n));return this.diffWithOptionsObj(d,f,n,a)}diffWithOptionsObj(t,s,n,a){var l;const c=N=>{if(N=this.postProcess(N,n),a){setTimeout(function(){a(N)},0);return}else return N},d=s.length,f=t.length;let h=1,m=d+f;n.maxEditLength!=null&&(m=Math.min(m,n.maxEditLength));const g=(l=n.timeout)!==null&&l!==void 0?l:1/0,_=Date.now()+g,v=[{oldPos:-1,lastComponent:void 0}];let y=this.extractCommon(v[0],s,t,0,n);if(v[0].oldPos+1>=f&&y+1>=d)return c(this.buildValues(v[0].lastComponent,s,t));let S=-1/0,j=1/0;const k=()=>{for(let N=Math.max(S,-h);N<=Math.min(j,h);N+=2){let E;const B=v[N-1],F=v[N+1];B&&(v[N-1]=void 0);let $=!1;if(F){const Y=F.oldPos-N;$=F&&0<=Y&&Y<d}const K=B&&B.oldPos+1<f;if(!$&&!K){v[N]=void 0;continue}if(!K||$&&B.oldPos<F.oldPos?E=this.addToPath(F,!0,!1,0,n):E=this.addToPath(B,!1,!0,1,n),y=this.extractCommon(E,s,t,N,n),E.oldPos+1>=f&&y+1>=d)return c(this.buildValues(E.lastComponent,s,t))||!0;v[N]=E,E.oldPos+1>=f&&(j=Math.min(j,N-1)),y+1>=d&&(S=Math.max(S,N+1))}h++};if(a)(function N(){setTimeout(function(){if(h>m||Date.now()>_)return a(void 0);k()||N()},0)})();else for(;h<=m&&Date.now()<=_;){const N=k();if(N)return N}}addToPath(t,s,n,a,l){const c=t.lastComponent;return c&&!l.oneChangePerToken&&c.added===s&&c.removed===n?{oldPos:t.oldPos+a,lastComponent:{count:c.count+1,added:s,removed:n,previousComponent:c.previousComponent}}:{oldPos:t.oldPos+a,lastComponent:{count:1,added:s,removed:n,previousComponent:c}}}extractCommon(t,s,n,a,l){const c=s.length,d=n.length;let f=t.oldPos,h=f-a,m=0;for(;h+1<c&&f+1<d&&this.equals(n[f+1],s[h+1],l);)h++,f++,m++,l.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return m&&!l.oneChangePerToken&&(t.lastComponent={count:m,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=f,h}equals(t,s,n){return n.comparator?n.comparator(t,s):t===s||!!n.ignoreCase&&t.toLowerCase()===s.toLowerCase()}removeEmpty(t){const s=[];for(let n=0;n<t.length;n++)t[n]&&s.push(t[n]);return s}castInput(t,s){return t}tokenize(t,s){return Array.from(t)}join(t){return t.join("")}postProcess(t,s){return t}get useLongestToken(){return!1}buildValues(t,s,n){const a=[];let l;for(;t;)a.push(t),l=t.previousComponent,delete t.previousComponent,t=l;a.reverse();const c=a.length;let d=0,f=0,h=0;for(;d<c;d++){const m=a[d];if(m.removed)m.value=this.join(n.slice(h,h+m.count)),h+=m.count;else{if(!m.added&&this.useLongestToken){let g=s.slice(f,f+m.count);g=g.map(function(_,v){const y=n[h+v];return y.length>_.length?y:_}),m.value=this.join(g)}else m.value=this.join(s.slice(f,f+m.count));f+=m.count,m.added||(h+=m.count)}}return a}}function x5(e,t){let s;for(s=0;s<e.length&&s<t.length;s++)if(e[s]!=t[s])return e.slice(0,s);return e.slice(0,s)}function v5(e,t){let s;if(!e||!t||e[e.length-1]!=t[t.length-1])return"";for(s=0;s<e.length&&s<t.length;s++)if(e[e.length-(s+1)]!=t[t.length-(s+1)])return e.slice(-s);return e.slice(-s)}function yx(e,t,s){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return s+e.slice(t.length)}function wx(e,t,s){if(!t)return e+s;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+s}function oc(e,t){return yx(e,t,"")}function Id(e,t){return wx(e,t,"")}function b5(e,t){return t.slice(0,wL(e,t))}function wL(e,t){let s=0;e.length>t.length&&(s=e.length-t.length);let n=t.length;e.length<t.length&&(n=e.length);const a=Array(n);let l=0;a[0]=0;for(let c=1;c<n;c++){for(t[c]==t[l]?a[c]=a[l]:a[c]=l;l>0&&t[c]!=t[l];)l=a[l];t[c]==t[l]&&l++}l=0;for(let c=s;c<e.length;c++){for(;l>0&&e[c]!=t[l];)l=a[l];e[c]==t[l]&&l++}return l}function lc(e){let t;for(t=e.length-1;t>=0&&e[t].match(/\s/);t--);return e.substring(t+1)}function Bi(e){const t=e.match(/^\s*/);return t?t[0]:""}const _5="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}",SL=new RegExp(`[${_5}]+|\\s+|[^${_5}]`,"ug");class jL extends Gk{equals(t,s,n){return n.ignoreCase&&(t=t.toLowerCase(),s=s.toLowerCase()),t.trim()===s.trim()}tokenize(t,s={}){let n;if(s.intlSegmenter){const c=s.intlSegmenter;if(c.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');n=[];for(const d of Array.from(c.segment(t))){const f=d.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(f)?n[n.length-1]+=f:n.push(f)}}else n=t.match(SL)||[];const a=[];let l=null;return n.forEach(c=>{/\s/.test(c)?l==null?a.push(c):a.push(a.pop()+c):l!=null&&/\s/.test(l)?a[a.length-1]==l?a.push(a.pop()+c):a.push(l+c):a.push(c),l=c}),a}join(t){return t.map((s,n)=>n==0?s:s.replace(/^\s+/,"")).join("")}postProcess(t,s){if(!t||s.oneChangePerToken)return t;let n=null,a=null,l=null;return t.forEach(c=>{c.added?a=c:c.removed?l=c:((a||l)&&y5(n,l,a,c),n=c,a=null,l=null)}),(a||l)&&y5(n,l,a,null),t}}const kL=new jL;function CL(e,t,s){return kL.diff(e,t,s)}function y5(e,t,s,n){if(t&&s){const a=Bi(t.value),l=lc(t.value),c=Bi(s.value),d=lc(s.value);if(e){const f=x5(a,c);e.value=wx(e.value,c,f),t.value=oc(t.value,f),s.value=oc(s.value,f)}if(n){const f=v5(l,d);n.value=yx(n.value,d,f),t.value=Id(t.value,f),s.value=Id(s.value,f)}}else if(s){if(e){const a=Bi(s.value);s.value=s.value.substring(a.length)}if(n){const a=Bi(n.value);n.value=n.value.substring(a.length)}}else if(e&&n){const a=Bi(n.value),l=Bi(t.value),c=lc(t.value),d=x5(a,l);t.value=oc(t.value,d);const f=v5(oc(a,d),c);t.value=Id(t.value,f),n.value=yx(n.value,a,f),e.value=wx(e.value,a,a.slice(0,a.length-f.length))}else if(n){const a=Bi(n.value),l=lc(t.value),c=b5(l,a);t.value=Id(t.value,c)}else if(e){const a=lc(e.value),l=Bi(t.value),c=b5(a,l);t.value=oc(t.value,c)}}class NL extends Gk{constructor(){super(...arguments),this.tokenize=ML}equals(t,s,n){return n.ignoreWhitespace?((!n.newlineIsToken||!t.includes(`
84
+ `))&&(t=t.trim()),(!n.newlineIsToken||!s.includes(`
85
+ `))&&(s=s.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(t.endsWith(`
86
+ `)&&(t=t.slice(0,-1)),s.endsWith(`
87
+ `)&&(s=s.slice(0,-1))),super.equals(t,s,n)}}const EL=new NL;function w5(e,t,s){return EL.diff(e,t,s)}function ML(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
88
+ `));const s=[],n=e.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(let a=0;a<n.length;a++){const l=n[a];a%2&&!t.newlineIsToken?s[s.length-1]+=l:s.push(l)}return s}function TL(e,t,s,n,a,l,c){let d;c?typeof c=="function"?d={callback:c}:d=c:d={},typeof d.context>"u"&&(d.context=4);const f=d.context;if(d.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(d.callback){const{callback:m}=d;w5(s,n,Object.assign(Object.assign({},d),{callback:g=>{const _=h(g);m(_)}}))}else return h(w5(s,n,d));function h(m){if(!m)return;m.push({value:"",lines:[]});function g(N){return N.map(function(E){return" "+E})}const _=[];let v=0,y=0,S=[],j=1,k=1;for(let N=0;N<m.length;N++){const E=m[N],B=E.lines||AL(E.value);if(E.lines=B,E.added||E.removed){if(!v){const F=m[N-1];v=j,y=k,F&&(S=f>0?g(F.lines.slice(-f)):[],v-=S.length,y-=S.length)}for(const F of B)S.push((E.added?"+":"-")+F);E.added?k+=B.length:j+=B.length}else{if(v)if(B.length<=f*2&&N<m.length-2)for(const F of g(B))S.push(F);else{const F=Math.min(B.length,f);for(const K of g(B.slice(0,F)))S.push(K);const $={oldStart:v,oldLines:j-v+F,newStart:y,newLines:k-y+F,lines:S};_.push($),v=0,y=0,S=[]}j+=B.length,k+=B.length}}for(const N of _)for(let E=0;E<N.lines.length;E++)N.lines[E].endsWith(`
89
+ `)?N.lines[E]=N.lines[E].slice(0,-1):(N.lines.splice(E+1,0,"\"),E++);return{oldFileName:e,newFileName:t,oldHeader:a,newHeader:l,hunks:_}}}function AL(e){const t=e.endsWith(`
90
+ `),s=e.split(`
91
+ `).map(n=>n+`
92
+ `);return t?s.pop():s.push(s.pop().slice(0,-1)),s}function RL(e,t){return TL("","",e,t,"","",{context:3}).hunks.map(n=>{const a=`@@ -${n.oldStart},${n.oldLines} +${n.newStart},${n.newLines} @@`,l=[];let c=n.oldStart,d=n.newStart;for(const f of n.lines){const h=f[0],m=f.slice(1);h==="-"?l.push({type:"del",content:m,oldLineNo:c++}):h==="+"?l.push({type:"add",content:m,newLineNo:d++}):l.push({type:"context",content:m,oldLineNo:c++,newLineNo:d++})}return Kk(l),{header:a,lines:l}})}function DL(e){const t=[],s=e.split(`
93
+ `);let n=null,a=null,l=0,c=0;for(const d of s){if(d.startsWith("diff --git")||d.startsWith("diff --cc")){a&&n&&n.hunks.push(a),n&&t.push(n),n={fileName:"",hunks:[]},a=null;continue}if(d.startsWith("--- a/")||d.startsWith("--- /dev/null"))continue;if(d.startsWith("+++ b/")){n&&(n.fileName=d.slice(6));continue}if(d.startsWith("+++ /dev/null")||d.startsWith("index ")||d.startsWith("new file")||d.startsWith("deleted file")||d.startsWith("old mode")||d.startsWith("new mode")||d.startsWith("rename from")||d.startsWith("rename to")||d.startsWith("similarity index")||d.startsWith("Binary files"))continue;const f=d.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@(.*)$/);if(f){a&&n&&n.hunks.push(a),l=parseInt(f[1],10),c=parseInt(f[2],10),a={header:d,lines:[]};continue}a&&(d.startsWith("+")?a.lines.push({type:"add",content:d.slice(1),newLineNo:c++}):d.startsWith("-")?a.lines.push({type:"del",content:d.slice(1),oldLineNo:l++}):d.startsWith(" ")&&a.lines.push({type:"context",content:d.slice(1),oldLineNo:l++,newLineNo:c++}))}a&&n&&n.hunks.push(a),n&&t.push(n);for(const d of t)for(const f of d.hunks)Kk(f.lines);return t}function Kk(e){let t=0;for(;t<e.length;){const s=t;for(;t<e.length&&e[t].type==="del";)t++;const n=t,a=t;for(;t<e.length&&e[t].type==="add";)t++;const l=t,c=n-s,d=l-a;if(c>0&&d>0){const f=Math.min(c,d);for(let h=0;h<f;h++){const m=e[s+h],g=e[a+h],_=CL(m.content,g.content);m.wordChanges=_.filter(v=>!v.added).map(v=>({value:v.value,removed:v.removed})),g.wordChanges=_.filter(v=>!v.removed).map(v=>({value:v.value,added:v.added}))}}t===s&&t++}}function LL({line:e}){return e.wordChanges?r.jsx(r.Fragment,{children:e.wordChanges.map((t,s)=>t.added?r.jsx("span",{className:"diff-word-add",children:t.value},s):t.removed?r.jsx("span",{className:"diff-word-del",children:t.value},s):r.jsx("span",{children:t.value},s))}):r.jsx(r.Fragment,{children:e.content})}function BL({hunk:e,showLineNumbers:t}){return r.jsxs("div",{className:"diff-hunk",children:[r.jsx("div",{className:"diff-hunk-header",children:e.header}),e.lines.map((s,n)=>r.jsxs("div",{className:`diff-line diff-line-${s.type}`,children:[t&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"diff-gutter diff-gutter-old",children:s.oldLineNo??""}),r.jsx("span",{className:"diff-gutter diff-gutter-new",children:s.newLineNo??""})]}),r.jsx("span",{className:"diff-marker",children:s.type==="add"?"+":s.type==="del"?"-":" "}),r.jsxs("span",{className:"diff-content",children:[r.jsx(LL,{line:s}),!s.content&&" "]})]},n))]})}function OL({fileName:e}){const t=e.split("/"),s=t.pop()||e,n=t.join("/");return r.jsxs("div",{className:"diff-file-header",children:[r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5 text-cc-primary shrink-0",children:[r.jsx("path",{d:"M9 1H4a1 1 0 00-1 1v12a1 1 0 001 1h8a1 1 0 001-1V5L9 1z"}),r.jsx("polyline",{points:"9 1 9 5 13 5"})]}),n&&r.jsxs("span",{className:"text-cc-muted",children:[n,"/"]}),r.jsx("span",{className:"font-semibold text-cc-fg",children:s})]})}function br({oldText:e,newText:t,unifiedDiff:s,fileName:n,mode:a="compact"}){const l=a==="compact",c=!l,d=w.useMemo(()=>{if(s)return DL(s);const f=e??"",h=t??"";if(!f&&!h)return[];const m=RL(f,h);return[{fileName:n||"",hunks:m}]},[e,t,s,n]);return d.length===0||d.every(f=>f.hunks.length===0)?r.jsx("div",{className:"diff-viewer diff-empty",children:r.jsx("span",{className:"text-cc-muted text-xs",children:"No changes"})}):r.jsx("div",{className:`diff-viewer ${l?"diff-compact":"diff-full"}`,children:d.map((f,h)=>r.jsxs("div",{className:"diff-file",children:[(f.fileName||n)&&r.jsx(OL,{fileName:f.fileName||n||""}),f.hunks.map((m,g)=>r.jsx(BL,{hunk:m,showLineNumbers:c},g))]},h))})}const zL={Bash:"terminal",Read:"file",Write:"file-plus",Edit:"file-edit",Glob:"search",Grep:"search",WebFetch:"globe",WebSearch:"globe",NotebookEdit:"notebook",Task:"agent",TodoWrite:"checklist",TaskCreate:"list",TaskUpdate:"list",SendMessage:"message",web_search:"globe",mcp_tool_call:"tool"};function uu(e){return zL[e]||"tool"}function Ta(e){return e==="Bash"?"Terminal":e==="Read"?"Read File":e==="Write"?"Write File":e==="Edit"?"Edit File":e==="Glob"?"Find Files":e==="Grep"?"Search Content":e==="WebSearch"?"Web Search":e==="WebFetch"?"Web Fetch":e==="Task"?"Subagent":e==="TodoWrite"?"Tasks":e==="NotebookEdit"?"Notebook":e==="SendMessage"?"Message":e==="web_search"?"Web Search":e==="mcp_tool_call"?"MCP Tool":e.startsWith("mcp:")?e.split(":").slice(1).join(":"):e}function pn({name:e,input:t,toolUseId:s}){const[n,a]=w.useState(!1),l=uu(e),c=Ta(e),d=Ko(e,t);return r.jsxs("div",{className:`rounded-lg border border-cc-border/60 bg-cc-card shadow-sm transition-all duration-200 ${n?"":"hover:bg-cc-hover/50"}`,children:[r.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left rounded-lg transition-all duration-200 cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-4 h-4 text-cc-muted/60 transition-transform duration-200 shrink-0 ${n?"rotate-90":""}`,children:r.jsx("path",{d:"M6 4l4 4-4 4"})}),r.jsx(Aa,{type:l}),r.jsx("span",{className:"text-[12px] font-medium text-cc-fg font-mono-code",children:c}),d&&r.jsx("span",{className:"text-[11px] text-cc-muted/80 font-mono-code truncate flex-1",children:d})]}),n&&r.jsx("div",{className:"border-t border-cc-border/40 px-4 py-3 bg-cc-bg/50 rounded-b-lg",children:r.jsx(PL,{name:e,input:t})})]})}function PL({name:e,input:t}){switch(e){case"Bash":return r.jsx($L,{input:t});case"Edit":return r.jsx(IL,{input:t});case"Write":return r.jsx(FL,{input:t});case"Read":return r.jsx(HL,{input:t});case"Glob":return r.jsx(UL,{input:t});case"Grep":return r.jsx(VL,{input:t});case"WebSearch":case"web_search":return r.jsx(WL,{input:t});case"WebFetch":return r.jsx(qL,{input:t});case"Task":return r.jsx(GL,{input:t});case"TodoWrite":return r.jsx(KL,{input:t});case"NotebookEdit":return r.jsx(YL,{input:t});case"SendMessage":return r.jsx(XL,{input:t});default:return r.jsx("pre",{className:"text-[11px] text-cc-muted font-mono-code whitespace-pre-wrap leading-relaxed max-h-60 overflow-y-auto",children:JSON.stringify(t,null,2)})}}function $L({input:e}){return r.jsxs("div",{className:"space-y-2",children:[!!e.description&&r.jsx("div",{className:"text-[11px] text-cc-muted italic mb-2",children:String(e.description)}),r.jsxs("pre",{className:"px-3 py-2.5 rounded-lg border border-cc-border bg-cc-code-bg text-cc-code-fg text-[12px] font-mono-code leading-relaxed overflow-x-auto",children:[r.jsx("span",{className:"text-cc-muted select-none",children:"$ "}),String(e.command||"")]}),!!e.timeout&&r.jsxs("span",{className:"inline-block rounded-full bg-cc-warning/10 text-cc-warning px-2 py-0.5 text-[10px] font-medium",children:["timeout: ",String(e.timeout),"ms"]})]})}function IL({input:e}){const t=String(e.file_path||""),s=String(e.old_string||""),n=String(e.new_string||"");return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"rounded-md bg-cc-hover px-2 py-0.5 text-[11px] font-mono-code text-cc-fg truncate",children:t}),!!e.replace_all&&r.jsx("span",{className:"shrink-0 rounded-full bg-cc-warning/10 text-cc-warning px-2 py-0.5 text-[10px] font-medium",children:"replace all"})]}),r.jsx(br,{oldText:s,newText:n,fileName:t,mode:"compact"})]})}function FL({input:e}){const t=String(e.file_path||""),s=String(e.content||"");return r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"rounded-md bg-cc-hover px-2 py-0.5 text-[11px] font-mono-code text-cc-fg truncate inline-block",children:t}),r.jsx(br,{newText:s,fileName:t,mode:"compact"})]})}function HL({input:e}){const t=String(e.file_path||e.path||""),s=e.offset,n=e.limit,a=s!=null||n!=null,l=s??1,c=n!=null?l+n-1:void 0;return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] font-mono-code text-cc-fg truncate",children:t}),a&&r.jsx("span",{className:"shrink-0 rounded-full bg-cc-hover px-2 py-0.5 text-[10px] font-medium text-cc-muted",children:c!=null?`lines ${l}–${c}`:`from line ${l}`})]})}function UL({input:e}){return r.jsxs("div",{className:"space-y-2",children:[r.jsx("pre",{className:"inline-block px-2.5 py-1 rounded-lg border border-cc-border bg-cc-code-bg text-cc-code-fg text-[11px] font-mono-code",children:String(e.pattern||"")}),!!e.path&&r.jsxs("div",{className:"text-[10px] text-cc-muted",children:["path: ",r.jsx("span",{className:"font-mono-code",children:String(e.path)})]})]})}function VL({input:e}){return r.jsxs("div",{className:"space-y-2",children:[r.jsx("pre",{className:"px-3 py-2 rounded-lg border border-cc-border bg-cc-code-bg text-cc-code-fg text-[12px] font-mono-code overflow-x-auto",children:String(e.pattern||"")}),r.jsxs("div",{className:"flex flex-wrap gap-1.5 text-[10px]",children:[!!e.path&&r.jsxs("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-cc-muted font-medium",children:["path: ",r.jsx("span",{className:"font-mono-code",children:String(e.path)})]}),!!e.glob&&r.jsxs("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-cc-muted font-medium",children:["glob: ",r.jsx("span",{className:"font-mono-code",children:String(e.glob)})]}),!!e.output_mode&&r.jsxs("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-cc-muted font-medium",children:["mode: ",String(e.output_mode)]}),!!e.context&&r.jsxs("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-cc-muted font-medium",children:["context: ",String(e.context)]}),!!e.head_limit&&r.jsxs("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-cc-muted font-medium",children:["limit: ",String(e.head_limit)]})]})]})}function WL({input:e}){return r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-xs text-cc-fg font-medium",children:String(e.query||"")}),Array.isArray(e.allowed_domains)&&e.allowed_domains.length>0&&r.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.allowed_domains.map((t,s)=>r.jsx("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-[10px] text-cc-muted font-medium font-mono-code",children:t},s))})]})}function qL({input:e}){return r.jsxs("div",{className:"space-y-2",children:[!!e.url&&r.jsx("div",{className:"text-xs font-mono-code text-cc-primary truncate",children:String(e.url)}),!!e.prompt&&r.jsx("div",{className:"text-[11px] text-cc-muted italic line-clamp-2",children:String(e.prompt)})]})}function GL({input:e}){return r.jsxs("div",{className:"space-y-2",children:[!!e.description&&r.jsx("div",{className:"text-xs text-cc-fg font-medium",children:String(e.description)}),!!e.subagent_type&&r.jsx("span",{className:"inline-block rounded-full bg-cc-primary/10 text-cc-primary px-2 py-0.5 text-[10px] font-medium",children:String(e.subagent_type)}),!!e.prompt&&r.jsx("pre",{className:"px-3 py-2.5 rounded-lg border border-cc-border bg-cc-code-bg text-[11px] text-cc-muted font-mono-code whitespace-pre-wrap leading-relaxed max-h-40 overflow-y-auto",children:String(e.prompt)})]})}function KL({input:e}){const t=e.todos;return Array.isArray(t)?r.jsx("div",{className:"rounded-lg border border-cc-border/40 bg-cc-card p-2.5 space-y-1",children:t.map((s,n)=>{const a=s.status||"pending";return r.jsxs("div",{className:"flex items-start gap-2 py-0.5",children:[r.jsx("span",{className:"shrink-0 mt-0.5",children:a==="completed"?r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-success",children:r.jsx("path",{fillRule:"evenodd",d:"M8 15A7 7 0 108 1a7 7 0 000 14zm3.354-9.354a.5.5 0 00-.708-.708L7 8.586 5.354 6.94a.5.5 0 10-.708.708l2 2a.5.5 0 00.708 0l4-4z",clipRule:"evenodd"})}):a==="in_progress"?r.jsx("svg",{className:"w-3.5 h-3.5 text-cc-primary animate-spin",viewBox:"0 0 16 16",fill:"none",children:r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"28",strokeDashoffset:"8",strokeLinecap:"round"})}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-3.5 h-3.5 text-cc-muted",children:r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"})})}),r.jsx("span",{className:`text-[11px] leading-snug ${a==="completed"?"text-cc-muted line-through":"text-cc-fg"}`,children:s.content||"Task"})]},n)})}):r.jsx("pre",{className:"text-[11px] text-cc-muted font-mono-code whitespace-pre-wrap leading-relaxed max-h-60 overflow-y-auto",children:JSON.stringify(e,null,2)})}function YL({input:e}){const t=String(e.notebook_path||""),s=e.cell_type,n=e.edit_mode;return r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"rounded-md bg-cc-hover px-2 py-0.5 text-[11px] font-mono-code text-cc-fg inline-block",children:t}),r.jsxs("div",{className:"flex gap-1.5 text-[10px]",children:[s&&r.jsxs("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-cc-muted font-medium",children:["type: ",s]}),n&&r.jsxs("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-cc-muted font-medium",children:["mode: ",n]}),e.cell_number!=null&&r.jsxs("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-cc-muted font-medium",children:["cell: ",String(e.cell_number)]})]}),!!e.new_source&&r.jsx("pre",{className:"px-3 py-2.5 rounded-lg border border-cc-border bg-cc-code-bg text-cc-code-fg text-[11px] font-mono-code leading-relaxed max-h-40 overflow-y-auto",children:String(e.new_source)})]})}function XL({input:e}){return r.jsxs("div",{className:"space-y-2",children:[!!e.recipient&&r.jsxs("div",{className:"text-[11px] text-cc-muted",children:["to: ",r.jsx("span",{className:"font-medium text-cc-fg",children:String(e.recipient)})]}),!!e.content&&r.jsx("div",{className:"text-xs text-cc-fg whitespace-pre-wrap",children:String(e.content)})]})}function Ko(e,t){if(e==="Bash"&&typeof t.command=="string"){const s=t.command;return s.length>60?s.slice(0,60)+"…":s}if(e==="Edit"&&t.file_path){const n=String(t.file_path).split("/").slice(-2).join("/"),a=typeof t.old_string=="string"?t.old_string:"",l=typeof t.new_string=="string"?t.new_string:"";if(a||l){const c=a.split(`
94
+ `).length,d=l.split(`
95
+ `).length;return`${n} +${d}/-${c}`}return n}if((e==="Read"||e==="Write")&&t.file_path)return String(t.file_path).split("/").slice(-2).join("/");if(e==="Glob"&&t.pattern)return String(t.pattern);if(e==="Grep"&&t.pattern){const s=String(t.pattern),n=t.path?` in ${String(t.path).split("/").slice(-2).join("/")}`:"",a=s+n;return a.length>60?a.slice(0,60)+"…":a}if((e==="WebSearch"||e==="web_search")&&t.query)return String(t.query);if(e==="WebFetch"&&t.url)try{const s=new URL(String(t.url));return s.hostname+s.pathname}catch{return String(t.url).slice(0,60)}return e==="Task"&&t.description?String(t.description):e==="TodoWrite"&&Array.isArray(t.todos)?`${t.todos.length} task${t.todos.length!==1?"s":""}`:e==="NotebookEdit"&&t.notebook_path?String(t.notebook_path).split("/").pop()||"":e==="SendMessage"&&t.recipient?`→ ${String(t.recipient)}`:""}function Aa({type:e}){const t="w-4 h-4 text-cc-muted/60 shrink-0";return e==="terminal"?r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:t,children:[r.jsx("polyline",{points:"3 11 6 8 3 5"}),r.jsx("line",{x1:"8",y1:"11",x2:"13",y2:"11"})]}):e==="file"||e==="file-plus"||e==="file-edit"?r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:t,children:[r.jsx("path",{d:"M9 1H4a1 1 0 00-1 1v12a1 1 0 001 1h8a1 1 0 001-1V5L9 1z"}),r.jsx("polyline",{points:"9 1 9 5 13 5"})]}):e==="search"?r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:t,children:[r.jsx("circle",{cx:"7",cy:"7",r:"4"}),r.jsx("path",{d:"M13 13l-3-3"})]}):e==="globe"?r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:t,children:[r.jsx("circle",{cx:"8",cy:"8",r:"6"}),r.jsx("path",{d:"M2 8h12M8 2c2 2 3 4 3 6s-1 4-3 6c-2-2-3-4-3-6s1-4 3-6z"})]}):e==="message"?r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:t,children:r.jsx("path",{d:"M14 10a1 1 0 01-1 1H5l-3 3V3a1 1 0 011-1h10a1 1 0 011 1v7z"})}):e==="list"?r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:t,children:r.jsx("path",{d:"M3 4h10M3 8h10M3 12h6"})}):e==="agent"?r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:t,children:[r.jsx("circle",{cx:"8",cy:"5",r:"3"}),r.jsx("path",{d:"M3 14c0-2.8 2.2-5 5-5s5 2.2 5 5",strokeLinecap:"round"})]}):e==="checklist"?r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:t,children:[r.jsx("path",{d:"M3 4l1.5 1.5L7 3M3 8l1.5 1.5L7 7M3 12l1.5 1.5L7 11",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M9 4h4M9 8h4M9 12h4"})]}):e==="notebook"?r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:t,children:[r.jsx("rect",{x:"3",y:"1",width:"10",height:"14",rx:"1"}),r.jsx("path",{d:"M6 1v14M3 5h3M3 9h3M3 13h3"})]}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:t,children:r.jsx("path",{d:"M10.5 2.5l3 3-8 8H2.5v-3l8-8z"})})}const JL=w.lazy(()=>Xi(()=>import("./MermaidDiagram-By1J3Whj.js"),[]).then(e=>({default:e.MermaidDiagram})));function QL(e){var t,s;if(e.content&&typeof e.content=="string"){if((t=e.contentBlocks)!=null&&t.length){const n=e.contentBlocks.filter(a=>a.type==="text").map(a=>a.text);if(n.length>0)return n.join(`
96
+
97
+ `)}return e.content}return(s=e.contentBlocks)!=null&&s.length?e.contentBlocks.filter(n=>n.type==="text").map(n=>n.text).join(`
98
+
99
+ `):""}function S5({text:e}){const[t,s]=w.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3)}catch{const a=document.createElement("textarea");a.value=e,a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a),s(!0),setTimeout(()=>s(!1),2e3)}};return e?r.jsx("button",{onClick:n,className:"w-6 h-6 flex items-center justify-center rounded-md text-cc-muted/50 hover:text-cc-fg hover:bg-cc-hover transition-all duration-200",title:t?"Copied!":"Copy message",children:t?r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-success",children:r.jsx("path",{fillRule:"evenodd",d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})}):r.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:[r.jsx("path",{d:"M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25z"}),r.jsx("path",{d:"M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25z"})]})}):null}function fr({message:e,onFork:t}){if(e.role==="system")return r.jsxs("div",{className:"flex items-center gap-3 py-1",children:[r.jsx("div",{className:"flex-1 h-px bg-cc-border/30"}),r.jsx("span",{className:"text-[10px] text-cc-muted/40 uppercase tracking-[0.15em] font-mono-code shrink-0 px-1",children:e.content}),r.jsx("div",{className:"flex-1 h-px bg-cc-border/30"})]});if(e.role==="user")return r.jsxs("div",{className:"group/msg animate-[fadeSlideIn_0.15s_ease-out] relative",children:[r.jsx("div",{className:"absolute right-2 top-2 opacity-0 group-hover/msg:opacity-100 transition-all duration-200 z-10",children:r.jsxs("div",{className:"rounded-lg bg-cc-card border border-cc-border shadow-sm p-0.5 flex items-center gap-0.5",children:[typeof e.content=="string"&&e.content&&r.jsx(S5,{text:e.content}),t&&r.jsx("button",{onClick:t,className:"w-6 h-6 flex items-center justify-center rounded-md text-cc-muted/50 hover:text-cc-fg hover:bg-cc-hover transition-all duration-200",title:"Fork session from here",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("path",{fillRule:"evenodd",d:"M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z"})})})]})}),r.jsxs("div",{className:"bg-cc-primary/[0.04] dark:bg-cc-primary/[0.08] rounded-xl px-4 py-3 border border-cc-primary/10",children:[e.images&&e.images.length>0&&r.jsx("div",{className:"flex gap-2 flex-wrap mb-2",children:e.images.map((n,a)=>r.jsx("img",{src:`data:${n.media_type};base64,${n.data}`,alt:"attachment",className:"max-w-[180px] sm:max-w-[240px] max-h-[140px] sm:max-h-[180px] rounded-lg object-cover border border-cc-border overflow-hidden shadow-sm"},a))}),r.jsx("pre",{className:"text-[13px] whitespace-pre-wrap break-words font-sans-ui leading-[1.65] text-cc-fg",children:e.content})]})]});const s=QL(e);return r.jsxs("div",{className:"group/msg animate-[fadeSlideIn_0.15s_ease-out] relative",children:[r.jsx("div",{className:"absolute right-0 top-0 opacity-0 group-hover/msg:opacity-100 transition-all duration-200 z-10",children:r.jsxs("div",{className:"rounded-lg bg-cc-card border border-cc-border shadow-sm p-0.5 flex items-center gap-0.5",children:[s&&r.jsx(S5,{text:s}),t&&r.jsx("button",{onClick:t,className:"w-6 h-6 flex items-center justify-center rounded-md text-cc-muted/50 hover:text-cc-fg hover:bg-cc-hover transition-all duration-200",title:"Fork session from here",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("path",{fillRule:"evenodd",d:"M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z"})})})]})}),r.jsx("div",{className:"py-1",children:r.jsx(eB,{message:e})})]})}function ZL(e){const t=[];for(const s of e)if(s.type==="tool_use"){const n=t[t.length-1];(n==null?void 0:n.kind)==="tool_group"&&n.name===s.name?n.items.push({id:s.id,name:s.name,input:s.input}):t.push({kind:"tool_group",name:s.name,items:[{id:s.id,name:s.name,input:s.input}]})}else t.push({kind:"content",block:s});return t}function eB({message:e}){const t=e.contentBlocks||[],s=w.useMemo(()=>ZL(t),[t]);return t.length===0&&e.content?r.jsx("div",{className:"log-accent",children:r.jsx(Yk,{text:e.content})}):r.jsx("div",{className:"space-y-2",children:s.map((n,a)=>{if(n.kind==="content")return r.jsx("div",{className:"log-accent",children:r.jsx(tB,{block:n.block})},a);if(n.items.length===1){const l=n.items[0];return r.jsx("div",{className:"log-tool",children:r.jsx(pn,{name:l.name,input:l.input,toolUseId:l.id})},a)}return r.jsx("div",{className:"log-tool",children:r.jsx(sB,{name:n.name,items:n.items})},a)})})}function Yk({text:e}){return r.jsx("div",{className:"markdown-body text-[13px] text-cc-fg leading-[1.7] overflow-hidden",children:r.jsx(V0,{remarkPlugins:[K0],components:{p:({children:t})=>r.jsx("p",{className:"mb-2 last:mb-0 leading-[1.7]",children:t}),strong:({children:t})=>r.jsx("strong",{className:"font-semibold text-cc-fg",children:t}),em:({children:t})=>r.jsx("em",{className:"italic",children:t}),h1:({children:t})=>r.jsx("h1",{className:"text-base font-semibold text-cc-fg mt-4 mb-1.5 tracking-tight",children:t}),h2:({children:t})=>r.jsx("h2",{className:"text-[14px] font-semibold text-cc-fg mt-3 mb-1 tracking-tight",children:t}),h3:({children:t})=>r.jsx("h3",{className:"text-[13px] font-semibold text-cc-fg mt-2 mb-0.5",children:t}),ul:({children:t})=>r.jsx("ul",{className:"list-disc pl-5 mb-2 space-y-0.5",children:t}),ol:({children:t})=>r.jsx("ol",{className:"list-decimal pl-5 mb-2 space-y-0.5",children:t}),li:({children:t})=>r.jsx("li",{className:"text-cc-fg leading-[1.6]",children:t}),a:({href:t,children:s})=>r.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-cc-primary hover:underline underline-offset-2 decoration-cc-primary/40 transition-colors",children:s}),blockquote:({children:t})=>r.jsx("blockquote",{className:"border-l-2 border-cc-border pl-3 my-2 text-cc-muted italic",children:t}),hr:()=>r.jsx("hr",{className:"border-cc-border my-4"}),code:t=>{const{children:s,className:n}=t,a=/language-(\w+)/.exec(n||"");if(a||typeof s=="string"&&s.includes(`
100
+ `)){const c=(a==null?void 0:a[1])||"",d=typeof s=="string"?s:String(s??"");return c==="mermaid"?r.jsx(w.Suspense,{fallback:r.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-cc-border",children:[r.jsx("div",{className:"px-3 py-1 bg-cc-code-bg border-b border-cc-border flex items-center",children:r.jsx("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-[9px] text-cc-code-fg/40 font-mono-code uppercase",children:"mermaid"})}),r.jsx("div",{className:"px-3 py-3 bg-cc-code-bg text-[11px] text-cc-muted animate-pulse",children:"Loading diagram..."})]}),children:r.jsx(JL,{code:d})}):r.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-cc-border",children:[c&&r.jsx("div",{className:"px-3 py-1.5 bg-cc-code-bg border-b border-cc-border flex items-center",children:r.jsx("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-[9px] text-cc-code-fg/40 font-mono-code uppercase",children:c})}),r.jsx("pre",{className:"px-3 py-2 bg-cc-code-bg text-cc-code-fg text-[12px] font-mono-code leading-[1.6] overflow-x-auto",children:r.jsx("code",{children:s})})]})}return r.jsx("code",{className:"px-1 py-0.5 rounded bg-cc-fg/[0.04] dark:bg-cc-fg/[0.08] text-[12px] font-mono-code text-cc-fg",children:s})},pre:({children:t})=>r.jsx(r.Fragment,{children:t}),table:({children:t})=>r.jsx("div",{className:"overflow-x-auto my-2",children:r.jsx("table",{className:"min-w-full text-[12px] border-collapse",children:t})}),thead:({children:t})=>r.jsx("thead",{className:"bg-cc-fg/[0.03]",children:t}),th:({children:t})=>r.jsx("th",{className:"px-2.5 py-1.5 text-left text-[11px] font-semibold text-cc-fg border border-cc-border/60",children:t}),td:({children:t})=>r.jsx("td",{className:"px-2.5 py-1.5 text-[11px] text-cc-fg border border-cc-border/40",children:t}),tr:({children:t})=>r.jsx("tr",{className:"hover:bg-cc-hover/40 transition-colors",children:t})},children:e})})}function tB({block:e}){if(e.type==="text")return r.jsx(Yk,{text:e.text});if(e.type==="thinking")return r.jsx(nB,{text:e.thinking});if(e.type==="tool_use")return r.jsx(pn,{name:e.name,input:e.input,toolUseId:e.id});if(e.type==="tool_result"){const t=typeof e.content=="string"?e.content:JSON.stringify(e.content),s=e.is_error;return r.jsx("div",{className:`text-[11px] font-mono-code rounded-lg px-3 py-2 border ${s?"bg-cc-error/5 text-cc-error border-cc-error/20":"bg-cc-hover text-cc-muted border-cc-border/40"} max-h-40 overflow-y-auto whitespace-pre-wrap`,children:t})}return null}function sB({name:e,items:t}){const[s,n]=w.useState(!1),a=uu(e),l=Ta(e);return r.jsxs("div",{className:"rounded-lg overflow-hidden border border-cc-border/60 bg-cc-card",children:[r.jsxs("button",{onClick:()=>n(!s),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-cc-hover transition-all duration-200 cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 text-cc-muted/50 transition-transform duration-200 shrink-0 ${s?"rotate-90":""}`,children:r.jsx("path",{d:"M6 4l4 4-4 4"})}),r.jsx(Aa,{type:a}),r.jsxs("span",{className:"text-[11px] font-medium text-cc-fg font-mono-code",children:[t.length,"x ",l]})]}),s&&r.jsx("div",{className:"px-3 py-1.5",children:t.map((c,d)=>{const f=Ko(c.name,c.input);return r.jsxs("div",{className:`flex items-center gap-2 py-0.5 text-[11px] text-cc-muted font-mono-code truncate ${d>0?"border-t border-cc-border/40 pt-1":""}`,children:[r.jsx("span",{className:"text-cc-muted/30 select-none",children:"-"}),r.jsx("span",{className:"truncate",children:f||JSON.stringify(c.input).slice(0,80)})]},c.id||d)})})]})}function nB({text:e}){const[t,s]=w.useState(!1);return r.jsxs("div",{className:"rounded-lg border border-cc-border/60 bg-cc-card/50 overflow-hidden",children:[r.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-2 px-3 py-2 text-left cursor-pointer hover:bg-cc-hover/50 transition-all duration-200",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-muted/40 shrink-0",children:r.jsx("path",{d:"M8 1a5 5 0 00-3.5 8.57V12a1 1 0 001 1h5a1 1 0 001-1V9.57A5 5 0 008 1zm-1.5 13a.5.5 0 000 1h3a.5.5 0 000-1h-3z"})}),r.jsx("span",{className:"text-[11px] font-medium text-cc-muted/60 font-mono-code",children:"Reasoning"}),r.jsxs("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-[9px] text-cc-muted/40 font-mono-code tabular-nums",children:[e.length,"c"]}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 text-cc-muted/30 transition-transform duration-200 ml-auto ${t?"rotate-90":""}`,children:r.jsx("path",{d:"M6 4l4 4-4 4"})})]}),r.jsx("div",{className:"overflow-hidden transition-[max-height] duration-200 ease-in-out",style:{maxHeight:t?"10rem":"0"},children:r.jsx("div",{className:"overflow-y-auto max-h-40 border-t border-cc-border/40",children:r.jsx("div",{className:"px-3 py-2",children:r.jsx("pre",{className:"text-[12px] text-cc-muted/70 italic font-mono-code whitespace-pre-wrap leading-relaxed",children:e})})})})]})}const Fd=100;function j5(e){const t=Math.floor(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function k5(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const rB=[];function iB(e){if(e.role!=="assistant")return null;const t=e.contentBlocks;if(!t||t.length===0)return null;let s=null;for(const n of t){if(n.type==="text"&&n.text.trim()||n.type==="thinking")return null;if(n.type==="tool_use"){if(s===null)s=n.name;else if(s!==n.name)return null}}return s}function C5(e){return(e.contentBlocks||[]).filter(s=>s.type==="tool_use").map(s=>({id:s.id,name:s.name,input:s.input}))}function aB(e){return e.kind==="message"?(e.msg.contentBlocks||[]).filter(s=>s.type==="tool_use").filter(s=>s.name==="Task").map(s=>s.id):e.kind==="tool_msg_group"&&e.toolName==="Task"?e.items.map(t=>t.id):[]}function Xk(e){const t=[];for(const s of e){const n=iB(s);if(n){const a=t[t.length-1];if((a==null?void 0:a.kind)==="tool_msg_group"&&a.toolName===n){a.items.push(...C5(s));continue}t.push({kind:"tool_msg_group",toolName:n,items:C5(s),firstId:s.id})}else t.push({kind:"message",msg:s})}return t}function Jk(e,t,s){const n=Xk(e),a=[];for(const l of n){a.push(l);const c=aB(l);for(const d of c){const f=s.get(d);if(f&&f.length>0){const h=t.get(d)||{description:"Subagent",agentType:""},m=Jk(f,t,s);a.push({kind:"subagent",taskToolUseId:d,description:h.description,agentType:h.agentType,children:m})}}}return a}function oB(e){const t=new Map;for(const a of e)if(a.contentBlocks){for(const l of a.contentBlocks)if(l.type==="tool_use"&&l.name==="Task"){const{input:c,id:d}=l;t.set(d,{description:String((c==null?void 0:c.description)||"Subagent"),agentType:String((c==null?void 0:c.subagent_type)||"")})}}if(t.size===0)return Xk(e);const s=new Map,n=[];for(const a of e)if(a.parentToolUseId&&t.has(a.parentToolUseId)){let l=s.get(a.parentToolUseId);l||(l=[],s.set(a.parentToolUseId,l)),l.push(a)}else n.push(a);return Jk(n,t,s)}function N5(e){return e.kind==="message"?e.msg.role:e.kind==="tool_msg_group"||e.kind==="subagent"?"assistant":null}function lB({group:e}){const[t,s]=w.useState(!1),n=uu(e.toolName),a=Ta(e.toolName),l=e.items.length;if(l===1){const c=e.items[0];return r.jsx("div",{className:"animate-[fadeSlideIn_0.15s_ease-out]",children:r.jsx("div",{className:"log-tool",children:r.jsxs("div",{className:"rounded-lg overflow-hidden border border-cc-border/60 bg-cc-card",children:[r.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-cc-hover transition-all duration-200 cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 text-cc-muted/50 transition-transform duration-200 shrink-0 ${t?"rotate-90":""}`,children:r.jsx("path",{d:"M6 4l4 4-4 4"})}),r.jsx(Aa,{type:n}),r.jsx("span",{className:"text-[11px] font-medium text-cc-fg font-mono-code",children:a}),r.jsx("span",{className:"text-[11px] text-cc-muted truncate flex-1 font-mono-code",children:Ko(c.name,c.input)})]}),t&&r.jsx("div",{className:"px-3 pb-2.5 pt-0 border-t border-cc-border/40 mt-0",children:r.jsx("pre",{className:"mt-1.5 text-[11px] text-cc-muted font-mono-code whitespace-pre-wrap leading-relaxed max-h-60 overflow-y-auto",children:JSON.stringify(c.input,null,2)})})]})})})}return r.jsx("div",{className:"animate-[fadeSlideIn_0.15s_ease-out]",children:r.jsx("div",{className:"log-tool",children:r.jsxs("div",{className:"rounded-lg overflow-hidden border border-cc-border/60 bg-cc-card",children:[r.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-cc-hover transition-all duration-200 cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 text-cc-muted/50 transition-transform duration-200 shrink-0 ${t?"rotate-90":""}`,children:r.jsx("path",{d:"M6 4l4 4-4 4"})}),r.jsx(Aa,{type:n}),r.jsx("span",{className:"text-[11px] font-medium text-cc-fg font-mono-code",children:a}),r.jsxs("span",{className:"text-[10px] text-cc-muted/60 font-mono-code tabular-nums",children:["x",l]})]}),t&&r.jsx("div",{className:"px-3 py-1.5",children:e.items.map((c,d)=>{const f=Ko(c.name,c.input);return r.jsxs("div",{className:`flex items-center gap-2 py-0.5 text-[11px] text-cc-muted font-mono-code truncate ${d>0?"border-t border-cc-border/40 pt-1":""}`,children:[r.jsx("span",{className:"text-cc-muted/30 select-none",children:"-"}),r.jsx("span",{className:"truncate",children:f||JSON.stringify(c.input).slice(0,80)})]},c.id||d)})})]})})})}function Qk({entries:e,onForkAt:t}){return r.jsx(r.Fragment,{children:e.map((s,n)=>{const a=n>0?e[n-1]:null,l=N5(s),c=a?N5(a):null,d=n===0?"":l!==c?"mt-6":"mt-2";return s.kind==="tool_msg_group"?r.jsx("div",{className:d,children:r.jsx(lB,{group:s})},s.firstId||n):s.kind==="subagent"?r.jsx("div",{className:d,children:r.jsx(cB,{group:s})},s.taskToolUseId):r.jsx("div",{className:d,children:r.jsx(fr,{message:s.msg,onFork:t?()=>t(s.msg.id):void 0})},s.msg.id)})})}function cB({group:e}){const[t,s]=w.useState(!1),n=e.description||"Subagent",a=e.agentType,l=e.children.length,c=e.children[e.children.length-1],d=w.useMemo(()=>{var f,h;if(!c)return"";if(c.kind==="tool_msg_group")return`${Ta(c.toolName)}${c.items.length>1?` x${c.items.length}`:""}`;if(c.kind==="message"&&c.msg.role==="assistant"){const m=(f=c.msg.content)==null?void 0:f.trim();if(m)return m.length>60?m.slice(0,60)+"...":m;const g=(h=c.msg.contentBlocks)==null?void 0:h.find(_=>_.type==="tool_use");if(g)return Ta(g.name)}return""},[c]);return r.jsx("div",{className:"animate-[fadeSlideIn_0.15s_ease-out]",children:r.jsxs("div",{className:"ml-3 rounded-lg border border-cc-border/60 bg-cc-card/50 border-l-2 border-l-cc-primary/30 pl-3",children:[r.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-2 py-2 px-2 text-left cursor-pointer mb-0.5 hover:bg-cc-hover/50 rounded-t-lg transition-all duration-200",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 text-cc-muted/50 transition-transform duration-200 shrink-0 ${t?"rotate-90":""}`,children:r.jsx("path",{d:"M6 4l4 4-4 4"})}),r.jsx("span",{className:"text-[11px] font-medium text-cc-fg font-mono-code truncate",children:n}),a&&r.jsx("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-[9px] text-cc-muted/60 font-mono-code shrink-0",children:a}),!t&&d&&r.jsx("span",{className:"text-[11px] text-cc-muted/50 truncate ml-1 font-mono-code",children:d}),r.jsx("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-[10px] text-cc-muted/40 font-mono-code tabular-nums shrink-0 ml-auto",children:l})]}),t&&r.jsx("div",{className:"pb-2 px-2",children:r.jsx(Qk,{entries:e.children})})]})})}function Y0({sessionId:e}){const t=G(W=>W.messages.get(e)??rB),s=G(W=>W.streaming.get(e)),n=G(W=>W.streamingStartedAt.get(e)),a=G(W=>W.streamingOutputTokens.get(e)),l=G(W=>W.sessionStatus.get(e)),c=G(W=>W.toolProgress.get(e)),d=w.useRef(null),f=w.useRef(null),h=w.useRef(!0),[m,g]=w.useState(0),[_,v]=w.useState(Fd),y=G(W=>W.replaySessionId),S=e===y,j=G(W=>{var L;return(L=W.sessions.get(e))==null?void 0:L.cwd}),k=w.useCallback(async W=>{if(S||!j)return;const L=t.findIndex(Q=>Q.id===W);if(!(L<0))try{const Q=await ne.forkSession(e,{messageIndex:L+1});if(Q.sessionId){G.getState().setCurrentSession(Q.sessionId);const{connectSession:V}=await Xi(async()=>{const{connectSession:q}=await Promise.resolve().then(()=>Hj);return{connectSession:q}},void 0);V(Q.sessionId);const X=await ne.listSessions();G.getState().setSdkSessions(X)}}catch(Q){console.error("[MessageFeed] Fork failed:",Q)}},[e,t,S,j]),N=w.useMemo(()=>oB(t),[t]);w.useEffect(()=>{v(Fd)},[e]);const E=N.length,B=E>_,F=B?N.slice(E-_):N,$=E-F.length,K=w.useCallback(()=>{const W=f.current,L=(W==null?void 0:W.scrollHeight)??0;v(Q=>Q+Fd),requestAnimationFrame(()=>{if(W){const Q=W.scrollHeight;W.scrollTop+=Q-L}})},[]);w.useEffect(()=>{if(!n&&l!=="running"){g(0);return}const W=n||Date.now();g(Date.now()-W);const L=setInterval(()=>g(Date.now()-W),1e3);return()=>clearInterval(L)},[n,l]);function Y(){const W=f.current;W&&(h.current=W.scrollHeight-W.scrollTop-W.clientHeight<120)}return w.useEffect(()=>{var W;h.current&&((W=d.current)==null||W.scrollIntoView({behavior:"smooth"}))},[t.length,s]),t.length===0&&!s?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center select-none px-6 gap-3",children:[r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"w-10 h-10 text-cc-muted/25",children:r.jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),r.jsxs("div",{className:"flex flex-col items-center gap-1",children:[r.jsx("span",{className:"text-sm font-medium text-cc-muted",children:"Start a conversation"}),r.jsx("span",{className:"text-xs text-cc-muted/50",children:"Type a message below to begin"})]})]}):r.jsx("div",{className:"flex-1 min-h-0 relative overflow-hidden",children:r.jsx("div",{ref:f,onScroll:Y,className:"h-full overflow-y-auto scroll-smooth px-4 sm:px-6 py-4",children:r.jsxs("div",{className:"max-w-3xl mx-auto",children:[B&&r.jsx("div",{className:"flex justify-center pb-3",children:r.jsxs("button",{onClick:K,className:"rounded-full border border-cc-border px-3 py-1 text-[11px] text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-all duration-200 cursor-pointer",children:["+ ",Math.min(Fd,$)," more (",$," hidden)"]})}),r.jsx(Qk,{entries:F,onForkAt:!S&&j?k:void 0}),c&&c.size>0&&!s&&r.jsx("div",{className:"mt-4 flex items-center gap-2 animate-pulse",children:Array.from(c.values()).map((W,L)=>r.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-cc-hover px-2.5 py-0.5 text-[10px] text-cc-muted font-mono-code",children:[L>0&&r.jsx("span",{className:"text-cc-muted/20",children:"|"}),r.jsx(Aa,{type:uu(W.toolName)}),r.jsx("span",{children:Ta(W.toolName)}),r.jsxs("span",{className:"text-cc-muted/40 tabular-nums",children:[W.elapsedSeconds,"s"]})]},L))}),s&&r.jsxs("div",{className:"mt-4 animate-[fadeSlideIn_0.1s_ease-out]",children:[r.jsx("div",{className:"bg-cc-card rounded-xl border border-cc-border/60 px-4 py-3",children:r.jsxs("pre",{className:"font-sans-ui text-[13px] text-cc-fg whitespace-pre-wrap break-words leading-[1.7]",children:[s,r.jsx("span",{className:"inline-block w-1.5 h-4 ml-0.5 rounded-sm bg-gradient-to-b from-cc-primary/80 to-cc-primary/30 animate-pulse align-middle"})]})}),m>0&&r.jsx("div",{className:"mt-1.5 pl-1 flex items-center gap-1.5",children:r.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-cc-hover px-2.5 py-0.5 text-[10px] text-cc-muted/60 font-mono-code",children:[r.jsx("span",{className:"tabular-nums",children:j5(m)}),(a??0)>0&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-cc-muted/20",children:"|"}),r.jsxs("span",{className:"tabular-nums",children:[k5(a)," tokens"]})]})]})})]}),!s&&l==="running"&&m>0&&r.jsx("div",{className:"mt-4 pl-1 flex items-center gap-2",children:r.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-cc-hover px-2.5 py-0.5 text-[10px] text-cc-muted/60 font-mono-code",children:[r.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-cc-primary/50 animate-breathing"}),r.jsx("span",{className:"tabular-nums",children:j5(m)}),(a??0)>0&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-cc-muted/20",children:"|"}),r.jsxs("span",{className:"tabular-nums",children:[k5(a)," tokens"]})]})]})}),r.jsx("div",{ref:d})]})})})}const Zk=[{value:"claude-opus-4-6",label:"Opus",icon:"✳"},{value:"claude-sonnet-4-5-20250929",label:"Sonnet",icon:"◕"},{value:"claude-haiku-4-5-20251001",label:"Haiku",icon:"⚡"}],uB=[],eC=[{value:"default",label:"Default",icon:"◆"},{value:"claude-sonnet-4-5-20250929",label:"Claude Sonnet",icon:"◕"},{value:"claude-opus-4-6",label:"Claude Opus",icon:"✳"},{value:"gpt-4o",label:"GPT-4o",icon:"●"},{value:"ollama/llama3.3",label:"Llama 3.3 (Ollama)",icon:"⚡"}],X0=[{value:"bypassPermissions",label:"Agent (auto-approve)"},{value:"acceptEdits",label:"Accept Edits"},{value:"default",label:"Ask Every Time"},{value:"plan",label:"Plan"}],J0=[{value:"bypassPermissions",label:"Auto"},{value:"acceptEdits",label:"Accept Edits"},{value:"plan",label:"Suggest"}],tC=[{value:"bypassPermissions",label:"Auto"},{value:"default",label:"Prompt"}],sC=[{value:"gpt-4o",label:"GPT-4o",icon:"●"},{value:"claude-sonnet-4-5",label:"Claude Sonnet",icon:"◕"},{value:"deepseek/deepseek-chat",label:"DeepSeek Chat",icon:"◆"},{value:"o3-mini",label:"o3-mini",icon:"⚡"}],nC=[{value:"default",label:"Default"}],rC=[{value:"default",label:"Default",icon:"◆"},{value:"claude-sonnet-4-5-20250929",label:"Claude Sonnet",icon:"◕"},{value:"gpt-4o",label:"GPT-4o",icon:"●"}],iC=[{value:"default",label:"Default"}],aC=[{value:"default",label:"Default",icon:"◆"},{value:"claude-sonnet-4-5",label:"Claude Sonnet",icon:"◕"},{value:"gpt-4o",label:"GPT-4o",icon:"●"},{value:"gemini-2.5-pro",label:"Gemini 2.5 Pro",icon:"◈"}],oC=[{value:"default",label:"Prompt"},{value:"bypassPermissions",label:"Auto"}];function Yh(e){return e==="codex"?uB:e==="goose"?eC:e==="aider"?sC:e==="openhands"?rC:e==="openclaw"?aC:Zk}function Sx(e){return e==="codex"?J0:e==="goose"?tC:e==="aider"?nC:e==="openhands"?iC:e==="openclaw"?oC:X0}function si(e){return e==="codex"?"":e==="goose"?eC[0].value:e==="aider"?sC[0].value:e==="openhands"?rC[0].value:e==="openclaw"?aC[0].value:Zk[0].value}function Jc(e){return e==="codex"?J0[0].value:e==="goose"?tC[0].value:e==="aider"?nC[0].value:e==="openhands"?iC[0].value:e==="openclaw"?oC[0].value:X0[0].value}function dB(e){const t=typeof window<"u"?window.SpeechRecognition||window.webkitSpeechRecognition:void 0,s=!!t,[n,a]=w.useState(!1),[l,c]=w.useState(""),d=w.useRef(null),f=w.useRef(!1),h=w.useRef(e);h.current=e;const m=w.useCallback(()=>{if(!t)return;const v=new t;v.continuous=!0,v.interimResults=!0,v.lang=navigator.language||"en-US",v.onresult=y=>{let S="",j="";for(let k=y.resultIndex;k<y.results.length;k++){const N=y.results[k];N.isFinal?S+=N[0].transcript:j+=N[0].transcript}S?(h.current(S),c("")):c(j)},v.onerror=y=>{y.error==="no-speech"||y.error==="aborted"||(console.warn("[SpeechToText] error:",y.error),f.current=!1,a(!1),c(""))},v.onend=()=>{if(f.current)try{v.start()}catch{f.current=!1,a(!1),c("")}else a(!1),c("")},d.current=v,f.current=!0;try{v.start(),a(!0)}catch{f.current=!1,a(!1)}},[t]),g=w.useCallback(()=>{f.current=!1,d.current&&(d.current.abort(),d.current=null),a(!1),c("")},[]),_=w.useCallback(()=>{n?g():m()},[n,g,m]);return w.useEffect(()=>()=>{var v;f.current=!1,(v=d.current)==null||v.abort()},[]),{isSupported:s,isListening:n,interimText:l,toggle:_,stop:g}}let E5=0;const hB=[];function rg(e){return new Promise((t,s)=>{const n=new FileReader;n.onload=()=>{const l=n.result.split(",")[1];t({base64:l,mediaType:e.type})},n.onerror=s,n.readAsDataURL(e)})}function fB({sessionId:e}){var se,fe;const[t,s]=w.useState(""),[n,a]=w.useState([]),[l,c]=w.useState(!1),[d,f]=w.useState(0),[h,m]=w.useState(!1),[g,_]=w.useState(0),[v,y]=w.useState([]),S=w.useRef(null),j=w.useRef(null),k=w.useRef(null),N=G(H=>H.cliConnected),E=G(H=>H.sessions.get(e)),B=G(H=>H.previousPermissionMode.get(e)||"acceptEdits"),F=w.useCallback(H=>{s(ee=>{const Ie=ee.length>0&&!ee.endsWith(" ");return ee+(Ie?" ":"")+H}),requestAnimationFrame(()=>{const ee=S.current;ee&&(ee.style.height="auto",ee.style.height=Math.min(ee.scrollHeight,200)+"px")})},[]),{isSupported:$,isListening:K,interimText:Y,toggle:W,stop:L}=dB(F),V=G(H=>H.myRole.get(e)??"spectator")==="spectator",X=N.get(e)??!1,q=(E==null?void 0:E.permissionMode)||"acceptEdits",A=q==="plan",M=(E==null?void 0:E.backend_type)==="codex",U=((fe=(se=(M?J0:X0).find(H=>H.value===q))==null?void 0:se.label)==null?void 0:fe.toLowerCase())||q,I=w.useMemo(()=>{const H=[];if(E!=null&&E.slash_commands)for(const ee of E.slash_commands)H.push({name:ee,type:"command"});if(E!=null&&E.skills)for(const ee of E.skills)H.push({name:ee,type:"skill"});return H},[E==null?void 0:E.slash_commands,E==null?void 0:E.skills]),R=w.useMemo(()=>{if(!l)return[];const H=t.match(/^\/(\S*)$/);if(!H)return[];const ee=H[1].toLowerCase();return ee===""?I:I.filter(Ie=>Ie.name.toLowerCase().includes(ee))},[t,l,I]);w.useEffect(()=>{const H=t.startsWith("/")&&/^\/\S*$/.test(t)&&I.length>0;H&&!l?(c(!0),f(0)):!H&&l&&c(!1)},[t,I.length,l]),w.useEffect(()=>{d>=R.length&&f(Math.max(0,R.length-1))},[R.length,d]),w.useEffect(()=>{if(!k.current||!l)return;const ee=k.current.querySelectorAll("[data-cmd-index]")[d];ee&&ee.scrollIntoView({block:"nearest"})},[d,l]);const P=w.useCallback(H=>{var ee;s(`/${H.name} `),c(!1),(ee=S.current)==null||ee.focus()},[]),z=w.useMemo(()=>{const H=t.match(/@(\w*)$/);return H?H[1].toLowerCase():null},[t]),T=w.useMemo(()=>h?z===null?[]:z===""?v:v.filter(H=>H.name.toLowerCase().includes(z)||H.content.toLowerCase().includes(z)):[],[h,z,v]),oe=E==null?void 0:E.cwd;w.useEffect(()=>{y([])},[oe]),w.useEffect(()=>{const H=z!==null;H&&!h?(m(!0),_(0),ne.listPrompts(oe?{cwd:oe}:void 0).then(y).catch(()=>{})):!H&&h&&m(!1)},[z,h,oe]),w.useEffect(()=>{g>=T.length&&_(Math.max(0,T.length-1))},[T.length,g]);const be=w.useCallback(H=>{var Ie;const ee=t.replace(/@\w*$/,H.content);s(ee),m(!1),(Ie=S.current)==null||Ie.focus(),requestAnimationFrame(()=>{const We=S.current;We&&(We.style.height="auto",We.style.height=Math.min(We.scrollHeight,200)+"px")})},[t]);function re(H,ee){en(e,{type:"user_message",content:H,session_id:e,images:ee&&ee.length>0?ee.map(Ie=>({media_type:Ie.mediaType,data:Ie.base64})):void 0}),G.getState().appendMessage(e,{id:`user-${Date.now()}-${++E5}`,role:"user",content:H,images:ee&&ee.length>0?ee.map(Ie=>({media_type:Ie.mediaType,data:Ie.base64})):void 0,timestamp:Date.now()})}function ve(){var We;const H=t.trim();if(!H||!X||V)return;G.getState().sessionStatus.get(e)==="running"?(G.getState().enqueueMessage(e,H),G.getState().appendMessage(e,{id:`user-queued-${Date.now()}-${++E5}`,role:"system",content:`Queued: "${H.length>60?H.slice(0,60)+"…":H}"`,timestamp:Date.now()})):re(H,n),s(""),a([]),c(!1),m(!1),K&&L(),S.current&&(S.current.style.height="auto"),(We=S.current)==null||We.focus()}function Te(H){if(h&&T.length>0){if(H.key==="ArrowDown"){H.preventDefault(),_(ee=>(ee+1)%T.length);return}if(H.key==="ArrowUp"){H.preventDefault(),_(ee=>(ee-1+T.length)%T.length);return}if(H.key==="Tab"&&!H.shiftKey){H.preventDefault(),be(T[g]);return}if(H.key==="Enter"&&!H.shiftKey){H.preventDefault(),be(T[g]);return}if(H.key==="Escape"){H.preventDefault(),m(!1);return}}if(l&&R.length>0){if(H.key==="ArrowDown"){H.preventDefault(),f(ee=>(ee+1)%R.length);return}if(H.key==="ArrowUp"){H.preventDefault(),f(ee=>(ee-1+R.length)%R.length);return}if(H.key==="Tab"&&!H.shiftKey){H.preventDefault(),P(R[d]);return}if(H.key==="Enter"&&!H.shiftKey){H.preventDefault(),P(R[d]);return}if(H.key==="Escape"){H.preventDefault(),c(!1);return}}if(H.key==="m"&&H.shiftKey&&(H.ctrlKey||H.metaKey)&&$){H.preventDefault(),W();return}if(H.key==="Tab"&&H.shiftKey){H.preventDefault(),ft();return}H.key==="Enter"&&!H.shiftKey&&(H.preventDefault(),ve())}function Re(H){s(H.target.value);const ee=H.target;ee.style.height="auto",ee.style.height=Math.min(ee.scrollHeight,200)+"px"}function je(){V||en(e,{type:"interrupt"})}async function Ye(H){const ee=H.target.files;if(!ee)return;const Ie=[];for(const We of Array.from(ee)){if(!We.type.startsWith("image/"))continue;const{base64:Bt,mediaType:ss}=await rg(We);Ie.push({name:We.name,base64:Bt,mediaType:ss})}a(We=>[...We,...Ie]),H.target.value=""}function Xe(H){a(ee=>ee.filter((Ie,We)=>We!==H))}async function Pe(H){var We;const ee=(We=H.clipboardData)==null?void 0:We.items;if(!ee)return;const Ie=[];for(const Bt of Array.from(ee)){if(!Bt.type.startsWith("image/"))continue;const ss=Bt.getAsFile();if(!ss)continue;const{base64:ir,mediaType:oi}=await rg(ss);Ie.push({name:`pasted-${Date.now()}.${ss.type.split("/")[1]}`,base64:ir,mediaType:oi})}Ie.length>0&&(H.preventDefault(),a(Bt=>[...Bt,...Ie]))}const[ye,Ze]=w.useState(!1);function ft(){if(!X||M||V)return;const H=G.getState();if(!A)H.setPreviousPermissionMode(e,q),en(e,{type:"set_permission_mode",mode:"plan"}),H.updateSession(e,{permissionMode:"plan"});else{const ee=B||"acceptEdits";en(e,{type:"set_permission_mode",mode:ee}),H.updateSession(e,{permissionMode:ee})}}function mt(H){if(!X||V)return;const ee=G.getState();en(e,{type:"set_permission_mode",mode:H}),ee.updateSession(e,{permissionMode:H}),Ze(!1)}const ts={bypassPermissions:"bg-green-400",acceptEdits:"bg-blue-400",default:"bg-amber-400",plan:"bg-purple-400"},Kt={bypassPermissions:"Agent",acceptEdits:"Auto-edit",default:"Ask",plan:"Plan"},Rt=G(H=>H.sessionStatus).get(e)==="running",Hs=G(H=>H.messageQueue.get(e))??hB,gs=t.trim().length>0&&X&&!V,vt=w.useRef(Rt);w.useEffect(()=>{const H=vt.current;if(vt.current=Rt,H&&!Rt&&X&&!V){const ee=G.getState().dequeueMessage(e);ee&&setTimeout(()=>re(ee),300)}},[Rt,X,V,e]);const[rr,de]=w.useState(!1),_e=w.useRef(0);function Be(H){H.preventDefault(),H.stopPropagation(),_e.current++,_e.current===1&&de(!0)}function qe(H){H.preventDefault(),H.stopPropagation(),_e.current--,_e.current<=0&&(_e.current=0,de(!1))}function Je(H){H.preventDefault(),H.stopPropagation()}async function Yt(H){var We;H.preventDefault(),H.stopPropagation(),_e.current=0,de(!1);const ee=(We=H.dataTransfer)==null?void 0:We.files;if(!ee||ee.length===0)return;const Ie=[];for(const Bt of Array.from(ee)){if(!Bt.type.startsWith("image/"))continue;const{base64:ss,mediaType:ir}=await rg(Bt);Ie.push({name:Bt.name,base64:ss,mediaType:ir})}Ie.length>0&&a(Bt=>[...Bt,...Ie])}const xs=V?"Spectators cannot send messages":X?Rt?"Send follow-up (will queue)...":"Send a message... (/ for commands)":"Waiting for connection...";return r.jsxs("div",{className:"shrink-0 px-4 pb-4 pt-1 relative",onDragEnter:Be,onDragLeave:qe,onDragOver:Je,onDrop:Yt,children:[rr&&r.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-cc-primary/5 border-2 border-dashed border-cc-primary/30 rounded-xl backdrop-blur-sm pointer-events-none",children:r.jsxs("div",{className:"flex items-center gap-2 text-cc-primary text-xs font-medium",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4",children:r.jsx("path",{d:"M3.5 4A1.5 1.5 0 012 2.5V2h12v.5A1.5 1.5 0 0112.5 4h-9zM2 5v7.5A1.5 1.5 0 003.5 14h9a1.5 1.5 0 001.5-1.5V5H2zm5.25 2.5a.75.75 0 011.5 0v1.75H10.5a.75.75 0 010 1.5H8.75V12.5a.75.75 0 01-1.5 0v-1.75H5.5a.75.75 0 010-1.5h1.75V7.5z"})}),"Drop images here"]})}),r.jsxs("div",{className:"max-w-3xl mx-auto",children:[Rt&&r.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-full bg-cc-primary/10 text-cc-primary px-2.5 py-0.5 text-[11px] font-medium mb-2",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 animate-spin",children:r.jsx("path",{d:"M8 0a8 8 0 018 8h-2a6 6 0 00-6-6V0z"})}),"Agent is working..."]}),Hs.length>0&&r.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[r.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-cc-primary/10 text-cc-primary text-[11px] font-medium shadow-sm border border-cc-primary/20",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("path",{d:"M8 0a1 1 0 011 1v5.268l3.562-1.78a1 1 0 01.894 1.789L8 9.382l-5.456-3.105a1 1 0 11.894-1.79L7 6.27V1a1 1 0 011-1zM3 12a1 1 0 100 2h10a1 1 0 100-2H3z"})}),Hs.length," message",Hs.length>1?"s":""," queued"]}),r.jsx("button",{onClick:()=>G.getState().clearQueue(e),className:"text-[10px] text-cc-muted hover:text-cc-error transition-colors cursor-pointer",children:"Clear"})]}),r.jsx("input",{ref:j,type:"file",accept:"image/*",multiple:!0,onChange:Ye,className:"hidden"}),r.jsxs("div",{className:`relative bg-cc-card rounded-xl overflow-visible shadow-sm transition-all duration-200 border focus-within:shadow-md focus-within:ring-2 ${A?"border-purple-400/30 focus-within:border-purple-400/40 focus-within:ring-purple-400/10":"border-cc-border focus-within:border-cc-primary/30 focus-within:ring-cc-primary/10"}`,children:[Rt&&r.jsx("div",{className:"h-1 bg-gradient-to-r from-cc-primary/60 via-cc-primary to-cc-primary/60 animate-pulse rounded-t-xl"}),h&&T.length>0&&r.jsx("div",{className:"absolute left-2 right-2 bottom-full mb-1 max-h-[240px] overflow-y-auto rounded-xl border border-cc-border bg-cc-card shadow-lg z-20 py-1",children:T.map((H,ee)=>r.jsxs("button",{onClick:()=>be(H),className:`w-full px-2.5 py-1.5 text-left flex items-center gap-2.5 transition-colors cursor-pointer rounded-lg mx-1 ${ee===g?"bg-cc-primary/10 text-cc-primary":"hover:bg-cc-hover"}`,style:{width:"calc(100% - 0.5rem)"},children:[r.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded-lg bg-cc-hover/80 text-cc-muted shrink-0 text-[10px] font-bold",children:"@"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-[12px] font-medium text-cc-fg",children:H.name}),r.jsx("span",{className:"ml-2 text-[10px] text-cc-muted capitalize",children:H.scope}),r.jsxs("p",{className:"text-[10px] text-cc-muted truncate mt-0.5",children:[H.content.slice(0,60),H.content.length>60?"…":""]})]})]},H.id))}),l&&R.length>0&&r.jsx("div",{ref:k,className:"absolute left-2 right-2 bottom-full mb-1 max-h-[240px] overflow-y-auto rounded-xl border border-cc-border bg-cc-card shadow-lg z-20 py-1",children:R.map((H,ee)=>r.jsxs("button",{"data-cmd-index":ee,onClick:()=>P(H),className:`w-full px-2.5 py-1.5 text-left flex items-center gap-2.5 transition-colors cursor-pointer rounded-lg mx-1 ${ee===d?"bg-cc-primary/10 text-cc-primary":"hover:bg-cc-hover"}`,style:{width:"calc(100% - 0.5rem)"},children:[r.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded-lg bg-cc-hover/80 text-cc-muted shrink-0",children:H.type==="skill"?r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("path",{d:"M8 1l1.796 3.64L14 5.255l-3 2.924.708 4.126L8 10.5l-3.708 1.805L5 8.18 2 5.255l4.204-.615L8 1z"})}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3 h-3",children:r.jsx("path",{d:"M5 12L10 4",strokeLinecap:"round"})})}),r.jsxs("div",{className:"flex-1 min-w-0 flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs("span",{className:"text-[12px] font-medium text-cc-fg",children:["/",H.name]}),r.jsx("span",{className:"ml-2 text-[10px] text-cc-muted",children:H.type})]}),r.jsx("span",{className:"text-[9px] text-cc-muted/50 font-mono-code px-1 py-0.5 rounded bg-cc-hover",children:H.type==="skill"?"skill":"cmd"})]})]},`${H.type}-${H.name}`))}),n.length>0&&r.jsx("div",{className:"flex items-center gap-1.5 px-3 pt-2 flex-wrap",children:n.map((H,ee)=>r.jsxs("div",{className:"inline-flex items-center gap-1.5 pl-1 pr-2 py-0.5 rounded-lg border border-cc-border bg-cc-card shadow-sm text-[11px] text-cc-fg group",children:[r.jsx("img",{src:`data:${H.mediaType};base64,${H.base64}`,alt:H.name,className:"w-8 h-8 rounded-md object-cover shrink-0"}),r.jsx("span",{className:"truncate max-w-[80px]",children:H.name}),r.jsx("button",{onClick:()=>Xe(ee),className:"w-3.5 h-3.5 rounded-full flex items-center justify-center text-cc-muted hover:text-cc-error hover:bg-cc-error/10 transition-colors cursor-pointer shrink-0",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-2.5 h-2.5",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]},ee))}),r.jsx("textarea",{ref:S,value:t,onChange:Re,onKeyDown:Te,onPaste:Pe,placeholder:xs,disabled:!X||V,rows:1,className:"w-full px-4 pt-3 pb-1.5 text-[13px] bg-transparent resize-none focus:outline-none text-cc-fg font-sans-ui placeholder:text-cc-muted/50 disabled:opacity-40",style:{minHeight:"34px",maxHeight:"200px"}}),K&&r.jsxs("div",{className:"flex items-center gap-2 px-3.5 pb-1 text-[11px] text-cc-muted font-sans-ui animate-pulse",children:[r.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-error shrink-0",children:[r.jsx("path",{d:"M8 1a2.5 2.5 0 00-2.5 2.5v4a2.5 2.5 0 005 0v-4A2.5 2.5 0 008 1z"}),r.jsx("path",{d:"M3.5 7a.75.75 0 011.5 0 3 3 0 006 0 .75.75 0 011.5 0 4.5 4.5 0 01-3.75 4.437V13h1.5a.75.75 0 010 1.5h-4.5a.75.75 0 010-1.5h1.5v-1.563A4.5 4.5 0 013.5 7z"})]}),r.jsx("span",{children:Y||"Listening..."})]}),r.jsxs("div",{className:"flex items-center justify-between px-3 pb-2.5",children:[r.jsxs("div",{className:"relative",children:[r.jsxs("button",{onClick:()=>{M||V||!X||Ze(!ye)},disabled:!X||M||V,className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium transition-colors select-none ${!X||M||V?"opacity-25 cursor-not-allowed text-cc-muted":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover cursor-pointer"}`,title:M?"Mode is fixed for Codex sessions":"Switch permission mode (Shift+Tab)",children:[r.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${ts[q]||"bg-cc-muted"}`}),r.jsx("span",{children:Kt[q]||U})]}),ye&&r.jsx("div",{className:"absolute left-0 bottom-full mb-1 w-48 rounded-xl border border-cc-border bg-cc-card shadow-lg z-20 py-1",children:[{value:"bypassPermissions",label:"Agent",desc:"Auto-approve all tools",dot:"bg-green-400"},{value:"acceptEdits",label:"Auto-edit",desc:"Auto-approve file edits",dot:"bg-blue-400"},{value:"default",label:"Ask",desc:"Prompt for each tool",dot:"bg-amber-400"},{value:"plan",label:"Plan",desc:"No tool execution",dot:"bg-purple-400"}].map(H=>r.jsxs("button",{onClick:()=>mt(H.value),className:`w-full px-2.5 py-2 text-left hover:bg-cc-hover transition-colors cursor-pointer flex items-center gap-2 rounded-lg mx-1 ${q===H.value?"text-cc-fg":"text-cc-muted"}`,style:{width:"calc(100% - 0.5rem)"},children:[r.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${H.dot}`}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-[11px] font-medium",children:H.label}),r.jsx("div",{className:"text-[10px] text-cc-muted",children:H.desc})]}),q===H.value&&r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-primary shrink-0",children:r.jsx("path",{d:"M3 8.5l3.5 3.5 6.5-7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]},H.value))})]}),(E==null?void 0:E.git_branch)&&r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-cc-muted/60 font-mono-code overflow-hidden rounded-md bg-cc-hover/50 px-2 py-0.5",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 shrink-0 opacity-50",children:r.jsx("path",{d:"M11.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.116.862a2.25 2.25 0 10-.862.862A4.48 4.48 0 007.25 7.5h-1.5A2.25 2.25 0 003.5 9.75v.318a2.25 2.25 0 101.5 0V9.75a.75.75 0 01.75-.75h1.5a5.98 5.98 0 003.884-1.435A2.25 2.25 0 109.634 3.362zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5z"})}),r.jsx("span",{className:"truncate max-w-[80px] sm:max-w-[120px]",children:E.git_branch}),E.is_worktree&&r.jsx("span",{className:"text-[9px] bg-cc-hover text-cc-muted px-1 rounded",children:"wt"}),((E.git_ahead||0)>0||(E.git_behind||0)>0)&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[(E.git_ahead||0)>0&&r.jsxs("span",{className:"text-green-500",children:[E.git_ahead,"↑"]}),(E.git_behind||0)>0&&r.jsxs("button",{className:"text-cc-warning hover:text-amber-400 cursor-pointer hover:underline",title:"Pull latest changes",onClick:()=>{const H=E.repo_root||E.cwd;H&&ne.gitPull(H).then(ee=>{G.getState().updateSession(e,{git_ahead:ee.git_ahead,git_behind:ee.git_behind}),ee.success||console.warn("[git pull]",ee.output)}).catch(ee=>console.error("[git pull]",ee))},children:[E.git_behind,"↓"]})]}),((E.total_lines_added||0)>0||(E.total_lines_removed||0)>0)&&r.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[r.jsxs("span",{className:"text-green-500",children:["+",E.total_lines_added||0]}),r.jsxs("span",{className:"text-red-400",children:["-",E.total_lines_removed||0]})]})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{onClick:()=>{var H;return(H=j.current)==null?void 0:H.click()},disabled:!X||V,className:`flex items-center justify-center w-8 h-8 rounded-lg transition-colors ${X&&!V?"text-cc-muted hover:text-cc-fg hover:bg-cc-hover cursor-pointer":"text-cc-muted opacity-30 cursor-not-allowed"}`,title:"Upload image",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-4 h-4",children:[r.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),r.jsx("circle",{cx:"5.5",cy:"5.5",r:"1",fill:"currentColor",stroke:"none"}),r.jsx("path",{d:"M2 11l3-3 2 2 3-4 4 5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),Rt?r.jsx("button",{onClick:je,disabled:V,className:`flex items-center justify-center w-8 h-8 rounded-lg transition-colors ${V?"bg-cc-hover text-cc-muted/40 cursor-not-allowed":"bg-cc-error/10 text-cc-error border border-cc-error/20 hover:bg-cc-error/20 cursor-pointer"}`,title:V?"Spectators cannot interrupt":"Stop generation",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1"})})}):r.jsx("button",{onClick:ve,disabled:!gs,className:`flex items-center justify-center w-8 h-8 rounded-lg transition-all duration-200 ${gs?"bg-cc-primary text-white shadow-sm hover:shadow-md hover:opacity-90 cursor-pointer":"bg-cc-hover text-cc-muted/40 cursor-not-allowed"}`,title:"Send message (Enter)",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M8 12V4M4 7l4-4 4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})]})]})}function pB(e){if(e.type==="setMode")return`Set mode to "${e.mode}"`;const s=e.destination==="session"?"for session":"always";if(e.type==="addRules"||e.type==="replaceRules"){const n=e.rules[0];if(n!=null&&n.ruleContent)return`Allow "${n.ruleContent}" ${s}`;if(n!=null&&n.toolName)return`Allow ${n.toolName} ${s}`}return e.type==="addDirectories"?`Trust ${e.directories[0]||"directory"} ${s}`:`Allow ${s}`}function mB(e){return e==="AskUserQuestion"?"ask":["Read","Glob","Grep","WebSearch","WebFetch"].includes(e)?"read":"write"}function Zs({permission:e,sessionId:t}){const[s,n]=w.useState(!1),a=G(v=>v.removePermission),l=G(v=>v.removeChangedFile),c=G(v=>v.myRole.get(t)??"spectator");function d(v,y){c!=="spectator"&&(n(!0),en(t,{type:"permission_response",request_id:e.request_id,behavior:"allow",updated_input:v,...y!=null&&y.length?{updated_permissions:y}:{}}),a(t,e.request_id))}function f(){var v,y,S;if(c!=="spectator"){if(n(!0),en(t,{type:"permission_response",request_id:e.request_id,behavior:"deny",message:"Denied by user"}),(e.tool_name==="Write"||e.tool_name==="Edit")&&typeof((v=e.input)==null?void 0:v.file_path)=="string"){const j=((y=G.getState().sessions.get(t))==null?void 0:y.cwd)||((S=G.getState().sdkSessions.find(N=>N.sessionId===t))==null?void 0:S.cwd),k=Uh(e.input.file_path,j);l(t,k)}a(t,e.request_id)}}const h=e.tool_name==="AskUserQuestion",m=e.permission_suggestions,g=mB(e.tool_name),_=g==="read"?"border-l-4 border-l-blue-400/50":g==="ask"?"border-l-4 border-l-cc-primary/50":"border-l-4 border-l-amber-400/50";return r.jsx("div",{className:"px-4 py-3 border-t border-cc-border animate-[fadeSlideIn_0.2s_ease-out]",children:r.jsx("div",{className:`max-w-3xl mx-auto rounded-xl border bg-cc-card shadow-sm p-4 ${_}`,children:r.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[r.jsx("div",{className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 mt-0.5 ${h?"bg-gradient-to-br from-cc-primary/15 to-cc-primary/5 border border-cc-primary/20":g==="read"?"bg-gradient-to-br from-blue-400/15 to-blue-400/5 border border-blue-400/20":"bg-gradient-to-br from-cc-warning/15 to-cc-warning/5 border border-cc-warning/20"}`,children:h?r.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"w-4.5 h-4.5 text-cc-primary",children:r.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})}):g==="read"?r.jsxs("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"w-4.5 h-4.5 text-blue-400",children:[r.jsx("path",{d:"M10 12.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"}),r.jsx("path",{fillRule:"evenodd",d:"M.664 10.59a1.651 1.651 0 010-1.186A10.004 10.004 0 0110 3c4.257 0 7.893 2.66 9.336 6.41.147.381.146.804 0 1.186A10.004 10.004 0 0110 17c-4.257 0-7.893-2.66-9.336-6.41zM14 10a4 4 0 11-8 0 4 4 0 018 0z",clipRule:"evenodd"})]}):r.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"w-4.5 h-4.5 text-cc-warning",children:r.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[r.jsx("span",{className:`text-[13px] font-semibold ${h?"text-cc-primary":g==="read"?"text-blue-400":"text-cc-warning"}`,children:h?"Question":"Permission Request"}),!h&&r.jsx("span",{className:"rounded-full bg-cc-hover px-2 py-0.5 text-[10px] font-mono-code text-cc-muted",children:e.tool_name})]}),h?r.jsxs(r.Fragment,{children:[r.jsx(vB,{input:e.input,onSelect:v=>d({...e.input,answers:v}),disabled:s||c==="spectator"}),r.jsxs("div",{className:"mt-2 space-y-1",children:[r.jsx(M5,{sessionId:t,requestId:e.request_id}),c==="spectator"&&r.jsx("span",{className:"rounded-full bg-cc-hover text-cc-muted px-2.5 py-0.5 text-[10px] italic",children:"Spectators cannot vote"})]})]}):r.jsx(gB,{toolName:e.tool_name,input:e.input,description:e.description}),!h&&r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsx(M5,{sessionId:t,requestId:e.request_id}),r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsxs("button",{onClick:()=>d(),disabled:s||c==="spectator",className:"inline-flex items-center gap-1.5 rounded-lg bg-cc-success hover:bg-cc-success/90 text-white px-4 py-2 text-[13px] font-medium shadow-sm hover:shadow-md transition-all duration-200 disabled:opacity-50 cursor-pointer min-h-[40px]",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M3 8.5l3.5 3.5 6.5-7"})}),"Allow",r.jsx("span",{className:"rounded-md bg-white/15 border border-white/10 px-1.5 py-0.5 text-[9px] font-mono-code ml-0.5",children:"Y"})]}),r.jsxs("button",{onClick:f,disabled:s||c==="spectator",className:"inline-flex items-center gap-1.5 rounded-lg border border-cc-error/30 text-cc-error hover:bg-cc-error/10 px-4 py-2 text-[13px] font-medium transition-all duration-200 disabled:opacity-50 cursor-pointer min-h-[40px]",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})}),"Deny",r.jsx("span",{className:"rounded-md bg-cc-hover border border-cc-border/60 px-1.5 py-0.5 text-[9px] font-mono-code text-cc-muted ml-0.5",children:"N"})]}),c==="spectator"&&r.jsx("span",{className:"rounded-full bg-cc-hover text-cc-muted px-2.5 py-0.5 text-[10px] italic",children:"Spectators cannot vote"})]}),m&&m.length>0&&r.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:m.map((v,y)=>r.jsx("button",{onClick:()=>d(void 0,[v]),disabled:s||c==="spectator",title:`${v.type}: ${JSON.stringify(v)}`,className:"rounded-full border border-cc-primary/20 bg-cc-primary/5 text-cc-primary px-3 py-1 text-[11px] font-medium hover:bg-cc-primary/10 disabled:opacity-50 transition-colors cursor-pointer",children:pB(v)},y))})]})]})]})})})}function gB({toolName:e,input:t,description:s}){return e==="Bash"?r.jsx(xB,{input:t}):e==="Edit"?r.jsx(bB,{input:t}):e==="Write"?r.jsx(_B,{input:t}):e==="Read"?r.jsx(yB,{input:t}):e==="Glob"?r.jsx(wB,{input:t}):e==="Grep"?r.jsx(SB,{input:t}):e==="ExitPlanMode"?r.jsx(jB,{input:t}):r.jsx(lC,{input:t,description:s})}function xB({input:e}){const t=typeof e.command=="string"?e.command:"",s=typeof e.description=="string"?e.description:"";return r.jsxs("div",{className:"space-y-1.5",children:[s&&r.jsx("div",{className:"text-xs text-cc-muted",children:s}),r.jsxs("pre",{className:"text-sm text-cc-code-fg font-mono-code bg-cc-code-bg rounded-xl border border-cc-border px-4 py-3 max-h-40 overflow-y-auto overflow-x-auto whitespace-pre-wrap break-words leading-relaxed",children:[r.jsx("span",{className:"text-cc-code-fg/50 select-none",children:"$ "}),t]})]})}function vB({input:e,onSelect:t,disabled:s}){const n=Array.isArray(e.questions)?e.questions:[],[a,l]=w.useState({}),[c,d]=w.useState({}),[f,h]=w.useState({});function m(v,y){const S=String(v);l(j=>({...j,[S]:y})),h(j=>({...j,[S]:!1})),n.length<=1&&t({[S]:y})}function g(v){var j;const y=String(v),S=(j=c[y])==null?void 0:j.trim();S&&(l(k=>({...k,[y]:S})),n.length<=1&&t({[y]:S}))}function _(){t(a)}if(n.length===0){const v=typeof e.question=="string"?e.question:"";return v?r.jsx("div",{className:"text-sm text-cc-fg bg-cc-code-bg/30 rounded-lg px-3 py-2",children:v}):r.jsx(lC,{input:e})}return r.jsxs("div",{className:"space-y-3",children:[n.map((v,y)=>{var F;const S=typeof v.header=="string"?v.header:"",j=typeof v.question=="string"?v.question:"",k=Array.isArray(v.options)?v.options:[],N=String(y),E=a[N],B=f[N];return r.jsxs("div",{className:"space-y-2",children:[S&&r.jsx("span",{className:"inline-block text-[10px] font-semibold text-cc-primary bg-cc-primary/10 px-1.5 py-0.5 rounded",children:S}),j&&r.jsx("p",{className:"text-sm text-cc-fg leading-relaxed",children:j}),k.length>0&&r.jsxs("div",{className:"space-y-1.5",children:[k.map(($,K)=>{const Y=typeof $.label=="string"?$.label:String($),W=typeof $.description=="string"?$.description:"",L=E===Y;return r.jsx("button",{onClick:()=>m(y,Y),disabled:s,className:`w-full text-left rounded-xl border p-3 transition-all duration-200 cursor-pointer disabled:opacity-50 ${L?"border-cc-primary bg-cc-primary/10 ring-1 ring-cc-primary/30 shadow-sm":"border-cc-border hover:border-cc-primary/30 hover:shadow-sm"}`,children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`w-5 h-5 rounded-full border-2 flex items-center justify-center shrink-0 ${L?"border-cc-primary":"border-cc-muted/40"}`,children:L&&r.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-cc-primary"})}),r.jsxs("div",{children:[r.jsx("span",{className:"text-xs font-medium text-cc-fg",children:Y}),W&&r.jsx("p",{className:"text-[11px] text-cc-muted mt-0.5 leading-snug",children:W})]})]})},K)}),r.jsx("button",{onClick:()=>h($=>({...$,[N]:!$[N]})),disabled:s,className:`w-full text-left rounded-xl border p-3 transition-all duration-200 cursor-pointer disabled:opacity-50 ${B?"border-cc-primary bg-cc-primary/10 ring-1 ring-cc-primary/30 shadow-sm":"border-cc-border hover:border-cc-primary/30 hover:shadow-sm"}`,children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`w-5 h-5 rounded-full border-2 flex items-center justify-center shrink-0 ${B?"border-cc-primary":"border-cc-muted/40"}`,children:B&&r.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-cc-primary"})}),r.jsx("span",{className:"text-xs font-medium text-cc-muted",children:"Other..."})]})}),B&&r.jsxs("div",{className:"flex gap-2 pl-6",children:[r.jsx("input",{type:"text",value:c[N]||"",onChange:$=>d(K=>({...K,[N]:$.target.value})),onKeyDown:$=>{$.key==="Enter"&&g(y)},placeholder:"Type your answer...",className:"flex-1 px-2.5 py-1.5 text-xs bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/50",autoFocus:!0}),r.jsx("button",{onClick:()=>g(y),disabled:!((F=c[N])!=null&&F.trim()),className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-cc-primary hover:bg-cc-primary-hover text-white disabled:opacity-50 transition-colors cursor-pointer",children:"Send"})]})]})]},y)}),n.length>1&&Object.keys(a).length>0&&r.jsx("button",{onClick:_,disabled:s,className:"inline-flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-lg bg-cc-primary hover:bg-cc-primary-hover text-white disabled:opacity-50 transition-colors cursor-pointer",children:"Submit answers"})]})}function bB({input:e}){const t=String(e.file_path||""),s=String(e.old_string||""),n=String(e.new_string||""),[a,l]=w.useState(!1),c=Math.max(s.split(`
101
+ `).length,n.split(`
102
+ `).length),d=c>12&&!a;return r.jsxs("div",{className:"space-y-1",children:[r.jsx("div",{className:"rounded-xl border border-cc-border overflow-hidden",children:r.jsx(br,{oldText:d?s.split(`
103
+ `).slice(0,12).join(`
104
+ `):s,newText:d?n.split(`
105
+ `).slice(0,12).join(`
106
+ `):n,fileName:t,mode:"compact"})}),c>12&&r.jsx("button",{onClick:()=>l(!a),className:"text-[11px] text-cc-primary hover:text-cc-primary-hover cursor-pointer",children:a?"Show less":`Show more (${c} lines)`})]})}function _B({input:e}){const t=String(e.file_path||""),s=String(e.content||""),[n,a]=w.useState(!1),l=s.split(`
107
+ `).length,c=l>12&&!n;return r.jsxs("div",{className:"space-y-1",children:[r.jsx("div",{className:"rounded-xl border border-cc-border overflow-hidden",children:r.jsx(br,{newText:c?s.split(`
108
+ `).slice(0,12).join(`
109
+ `):s,fileName:t,mode:"compact"})}),l>12&&r.jsx("button",{onClick:()=>a(!n),className:"text-[11px] text-cc-primary hover:text-cc-primary-hover cursor-pointer",children:n?"Show less":`Show more (${l} lines)`})]})}function yB({input:e}){const t=String(e.file_path||"");return r.jsx("div",{className:"text-xs text-cc-muted font-mono-code bg-cc-code-bg/30 rounded-lg px-3 py-2",children:t})}function wB({input:e}){const t=typeof e.pattern=="string"?e.pattern:"",s=typeof e.path=="string"?e.path:"";return r.jsxs("div",{className:"text-xs font-mono-code bg-cc-code-bg/30 rounded-lg px-3 py-2 space-y-0.5",children:[r.jsx("div",{className:"text-cc-fg",children:t}),s&&r.jsx("div",{className:"text-cc-muted",children:s})]})}function SB({input:e}){const t=typeof e.pattern=="string"?e.pattern:"",s=typeof e.path=="string"?e.path:"",n=typeof e.glob=="string"?e.glob:"";return r.jsxs("div",{className:"text-xs font-mono-code bg-cc-code-bg/30 rounded-lg px-3 py-2 space-y-0.5",children:[r.jsx("div",{className:"text-cc-fg",children:t}),s&&r.jsx("div",{className:"text-cc-muted",children:s}),n&&r.jsx("div",{className:"text-cc-muted",children:n})]})}function jB({input:e}){const t=typeof e.plan=="string"?e.plan:"",s=Array.isArray(e.allowedPrompts)?e.allowedPrompts:[];return r.jsxs("div",{className:"space-y-2",children:[t&&r.jsxs("div",{className:"rounded-lg border border-cc-border overflow-hidden",children:[r.jsx("div",{className:"px-2.5 py-1.5 bg-cc-code-bg/10 border-b border-cc-border text-[10px] text-cc-muted font-mono-code uppercase tracking-wider",children:"Plan"}),r.jsx("div",{className:"px-3 py-2.5 max-h-64 overflow-y-auto text-xs text-cc-fg leading-relaxed markdown-body",children:r.jsx(V0,{remarkPlugins:[K0],children:t})})]}),s.length>0&&r.jsxs("div",{className:"space-y-1",children:[r.jsx("div",{className:"text-[10px] text-cc-muted uppercase tracking-wider",children:"Requested permissions"}),r.jsx("div",{className:"space-y-1",children:s.map((n,a)=>r.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-mono-code bg-cc-code-bg/30 rounded-lg px-2.5 py-1.5",children:[r.jsx("span",{className:"text-cc-muted shrink-0",children:String(n.tool||"")}),r.jsx("span",{className:"text-cc-fg",children:String(n.prompt||"")})]},a))})]}),!t&&s.length===0&&r.jsx("div",{className:"text-xs text-cc-muted",children:"Plan approval requested"})]})}function M5({sessionId:e,requestId:t}){const s=G(v=>{var y;return(y=v.permissionVotes.get(e))==null?void 0:y.get(t)}),n=G(v=>{var y;return(y=v.voteResults.get(e))==null?void 0:y.get(t)}),[a,l]=w.useState(null),[c]=w.useState(30);if(w.useEffect(()=>{if(!s){l(null);return}const v=()=>{const S=Math.max(0,Math.ceil((s.deadline-Date.now())/1e3));l(S)};v();const y=setInterval(v,1e3);return()=>clearInterval(y)},[s]),n)return r.jsxs("div",{className:`inline-flex items-center gap-2 rounded-full px-3 py-1 text-[11px] font-medium ${n.result==="allow"?"bg-cc-success/10 text-cc-success":"bg-cc-error/10 text-cc-error"}`,children:[n.result==="allow"?r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"w-3 h-3",children:r.jsx("path",{d:"M3 8.5l3.5 3.5 6.5-7"})}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"w-3 h-3",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})}),"Vote resolved: ",n.result," (",n.policy,")"]});if(!s)return null;const{votes:d,votersTotal:f}=s,h=d.filter(v=>v.vote==="allow").length,m=d.filter(v=>v.vote==="deny").length,g=a!==null?Math.max(0,a/c*100):100,_=a!==null&&a<=5?"bg-cc-error":a!==null&&a<=15?"bg-amber-400":"bg-cc-success";return r.jsxs("div",{className:"space-y-1.5",children:[a!==null&&a>0&&r.jsx("div",{className:"h-2 w-full bg-cc-border rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full ${_} transition-all duration-1000 ease-linear rounded-full`,style:{width:`${g}%`}})}),r.jsxs("div",{className:"flex items-center gap-3 text-[11px]",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"inline-flex items-center rounded-full bg-cc-success/10 text-cc-success px-2 py-0.5 font-medium",children:[h," allow"]}),r.jsx("span",{className:"text-cc-muted",children:"/"}),r.jsxs("span",{className:"inline-flex items-center rounded-full bg-cc-error/10 text-cc-error px-2 py-0.5 font-medium",children:[m," deny"]}),r.jsxs("span",{className:"text-cc-muted",children:["(",d.length,"/",f," voted)"]})]}),a!==null&&a>0&&r.jsxs("span",{className:"text-cc-muted font-mono",children:[a,"s"]}),r.jsx("div",{className:"flex items-center -space-x-1.5",children:d.map(v=>r.jsx("div",{className:`w-6 h-6 rounded-lg flex items-center justify-center text-[9px] font-bold ring-2 ring-cc-card ${v.vote==="allow"?"bg-cc-success/20 text-cc-success":"bg-cc-error/20 text-cc-error"}`,title:`${v.viewerName}: ${v.vote}`,children:v.viewerName.charAt(0).toUpperCase()},v.viewerId))})]})]})}function lC({input:e,description:t}){const s=Object.entries(e).filter(([,n])=>n!=null&&n!=="");return s.length===0&&t?r.jsx("div",{className:"text-xs text-cc-fg",children:t}):r.jsxs("div",{className:"space-y-1",children:[t&&r.jsx("div",{className:"text-xs text-cc-muted mb-1",children:t}),r.jsx("div",{className:"bg-cc-code-bg/30 rounded-lg px-3 py-2 space-y-1.5",children:s.map(([n,a])=>{const l=typeof a=="string"?a.length>200?a.slice(0,200)+"...":a:JSON.stringify(a);return r.jsxs("div",{className:"flex gap-2 text-[11px] font-mono-code",children:[r.jsx("span",{className:"text-cc-muted shrink-0 min-w-[60px]",children:n}),r.jsx("span",{className:"text-cc-fg break-all",children:l})]},n)})})]})}function cC(e,t){const s=Math.max(0,Math.round(((t||Date.now())-e)/1e3));if(s<60)return`${s}s`;const n=Math.floor(s/60),a=s%60;return a>0?n+"m "+a+"s":n+"m"}function kB(e){return e<.01?"":`$${e.toFixed(2)}`}function CB(e){return e==="running"?"bg-cc-primary":e==="compacting"?"bg-cc-warning":"bg-cc-success"}function NB(e){return e==="running"?"bg-cc-primary":e==="failed"||e==="timeout"?"bg-cc-error":"bg-cc-success"}const T5=[],A5=[];function EB(e){const[t,s]=w.useState(0);return w.useEffect(()=>{if(!e)return;const n=setInterval(()=>s(a=>a+1),1e3);return()=>clearInterval(n)},[e]),t}function MB(e,t,s,n=4e3){const[a,l]=w.useState(!1),c=w.useRef(void 0),d=e.length+t.length+s.length,f=d>0&&t.every(h=>h.status==="completed")&&e.every(h=>h.status!=="running")&&s.length===0;return w.useEffect(()=>(clearTimeout(c.current),f?c.current=setTimeout(()=>l(!0),n):l(!1),()=>clearTimeout(c.current)),[f,n]),w.useEffect(()=>{l(!1)},[d]),a}function TB(e,t,s,n){w.useEffect(()=>{if(!e)return;function a(l){s.current&&!s.current.contains(l.target)&&t(!1)}return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[e,t,s]),w.useEffect(()=>{if(!e)return;function a(l){l.key==="Escape"&&(l.stopPropagation(),t(!1))}return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,t]),w.useEffect(()=>{e&&n.current&&n.current.focus()},[e,n])}function AB(e,t,s,n,a,l){const c=[];return e>0?c.push(`${e} agent${e>1?"s":""}`):t>0&&c.push(`${t} done`),s>0&&c.push(`${s} tool${s>1?"s":""}`),a>0&&c.push(`${n}/${a}`),l>0&&c.push(`${l} session${l>1?"s":""}`),c.join(" · ")||"activity"}function RB(){const e=G(A=>A.currentSessionId),t=G(A=>A.sdkSessions),s=G(A=>A.sessionStatus),n=G(A=>A.sessionNames),a=G(A=>A.sessions),l=G(A=>A.pendingPermissions),c=G(A=>A.sessionStartTimes),d=G(A=>A.setCurrentSession),f=G(A=>e&&A.sessionBackgroundAgents.get(e)||T5),h=G(A=>e&&A.sessionTasks.get(e)||A5),m=G(A=>e?A.toolProgress.get(e):void 0),g=w.useMemo(()=>m?Array.from(m.entries()).map(([A,M])=>({toolUseId:A,toolName:M.toolName,elapsedSeconds:M.elapsedSeconds})):[],[m]),[_,v]=w.useState(!1),[y,S]=w.useState("activity"),j=w.useRef(null),k=w.useRef(null),N=w.useMemo(()=>t.filter(A=>!A.archived&&A.sessionId!==e).map(A=>{const M=s.get(A.sessionId),O=a.get(A.sessionId),U=l.get(A.sessionId);let I="disconnected";return M==="running"?I="running":M==="compacting"?I="compacting":M==="idle"&&(I="idle"),{sessionId:A.sessionId,name:n.get(A.sessionId)||A.sessionId.slice(0,8),status:I,cost:(O==null?void 0:O.total_cost_usd)||0,pendingPerms:U?U.size:0,startedAt:c.get(A.sessionId)||null}}).filter(A=>A.status==="running"||A.status==="compacting"||A.pendingPerms>0),[t,e,s,n,a,l,c]),E=f.filter(A=>A.status==="running").length,B=f.filter(A=>A.status!=="running").length,F=h.filter(A=>A.status==="completed").length,$=N.filter(A=>A.status==="running"||A.status==="compacting").length,K=N.reduce((A,M)=>A+M.pendingPerms,0),Y=f.length>0||h.length>0||g.length>0,W=N.length>0,L=Y||W,Q=E>0||$>0||g.length>0;EB(Q);const V=MB(f,h,N);w.useEffect(()=>{Y&&!W?S("activity"):!Y&&W&&S("sessions")},[Y,W]),TB(_,v,k,j);const X=w.useCallback(A=>{d(A),v(!1)},[d]);if(V&&!L||!L&&!_)return null;const q=AB(E,B,g.length,F,h.length,$);return r.jsxs("div",{ref:k,className:"absolute bottom-3 right-3 z-20",style:{transition:"opacity 0.4s ease-out",opacity:L?1:0,pointerEvents:L?"auto":"none"},children:[_&&L&&r.jsxs("dialog",{ref:j,open:!0,"aria-label":"Activity panel",id:"session-pulse-panel",className:"mb-2 w-80 max-w-[calc(100vw-2rem)] max-h-80 rounded-xl border border-cc-border/60 bg-cc-card/95 backdrop-blur-xl shadow-float animate-slide-up outline-none p-0 m-0 relative flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 pb-1 border-b border-cc-border/40",children:[Y&&r.jsxs("button",{onClick:()=>S("activity"),className:`px-2.5 py-1 rounded-md text-[10px] font-semibold uppercase tracking-wider transition-colors cursor-pointer ${y==="activity"?"bg-cc-primary/10 text-cc-primary":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:["Activity"," ",r.jsx("span",{className:"text-[9px] tabular-nums opacity-70",children:f.length+g.length+h.length})]}),W&&r.jsxs("button",{onClick:()=>S("sessions"),className:`px-2.5 py-1 rounded-md text-[10px] font-semibold uppercase tracking-wider transition-colors cursor-pointer ${y==="sessions"?"bg-cc-primary/10 text-cc-primary":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:["Sessions",N.length>0&&r.jsx("span",{className:"ml-1.5 text-[9px] tabular-nums opacity-70",children:N.length})]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:()=>v(!1),className:"p-1 rounded hover:bg-cc-hover transition-colors cursor-pointer","aria-label":"Close panel",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-muted",children:r.jsx("path",{d:"M4.28 3.22a.75.75 0 00-1.06 1.06L6.94 8l-3.72 3.72a.75.75 0 101.06 1.06L8 9.06l3.72 3.72a.75.75 0 101.06-1.06L9.06 8l3.72-3.72a.75.75 0 00-1.06-1.06L8 6.94 4.28 3.22z"})})})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[y==="activity"&&Y&&r.jsx(DB,{agents:f,tools:g,tasks:h}),y==="sessions"&&W&&r.jsx(zB,{sessions:N,onJump:X})]})]}),r.jsxs("button",{onClick:()=>v(A=>!A),"aria-expanded":_,"aria-controls":"session-pulse-panel",className:["flex items-center gap-2 px-3 h-8 rounded-full","border border-cc-border/50 bg-cc-card/90 backdrop-blur-lg","hover:bg-cc-hover/80 hover:border-cc-border/70","transition-all duration-200 cursor-pointer","animate-slide-up shadow-panel",_?"ring-1 ring-cc-primary/30":""].join(" "),children:[r.jsxs("span",{className:"relative flex h-2 w-2",children:[Q&&r.jsx("span",{className:"absolute inset-0 rounded-full bg-cc-primary opacity-75 animate-ping"}),r.jsx("span",{className:`relative inline-flex rounded-full h-2 w-2 ${Q?"bg-cc-primary":"bg-cc-success"}`})]}),r.jsx("span",{className:"text-[11px] font-medium text-cc-fg/80 font-mono-code whitespace-nowrap",children:q}),K>0&&r.jsx("span",{className:"flex items-center justify-center min-w-[16px] h-4 px-1 rounded-full bg-cc-warning/15 text-cc-warning text-[9px] font-semibold tabular-nums",children:K}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 text-cc-muted/60 transition-transform duration-200 ${_?"rotate-180":""}`,children:r.jsx("path",{d:"M4.427 9.573l3.396-3.396a.25.25 0 01.354 0l3.396 3.396a.25.25 0 01-.177.427H4.604a.25.25 0 01-.177-.427z"})})]})]})}function DB({agents:e,tools:t,tasks:s}){const n=e.length>0,a=n&&t.length>0,l=(n||t.length>0)&&s.length>0;return r.jsxs("div",{className:"py-1.5",children:[e.length>0&&r.jsxs("div",{children:[r.jsx("div",{className:"px-3 py-1",children:r.jsx("span",{className:"text-[9px] text-cc-muted/50 uppercase tracking-widest font-semibold",children:"Agents"})}),e.map(c=>r.jsx(LB,{agent:c},c.toolUseId))]}),a&&r.jsx("hr",{className:"mx-3 my-1.5 border-t border-cc-border/30 border-b-0 border-x-0"}),t.length>0&&r.jsxs("div",{children:[r.jsx("div",{className:"px-3 py-1",children:r.jsx("span",{className:"text-[9px] text-cc-muted/50 uppercase tracking-widest font-semibold",children:"Tools"})}),t.map(c=>r.jsx(BB,{tool:c},c.toolUseId))]}),l&&r.jsx("hr",{className:"mx-3 my-1.5 border-t border-cc-border/30 border-b-0 border-x-0"}),s.length>0&&r.jsxs("div",{children:[r.jsx("div",{className:"px-3 py-1",children:r.jsx("span",{className:"text-[9px] text-cc-muted/50 uppercase tracking-widest font-semibold",children:"Tasks"})}),s.map(c=>r.jsx(OB,{task:c},c.id))]})]})}function LB({agent:e}){var d,f;const[t,s]=w.useState(!1),n=e.status==="running",a=cC(e.startedAt,e.completedAt),l=!!e.summary,c=r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0",children:[n&&r.jsx("span",{className:"absolute inset-0 rounded-full bg-cc-primary opacity-75 animate-breathing"}),r.jsx("span",{className:`relative inline-flex rounded-full h-1.5 w-1.5 ${NB(e.status)}`})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:`text-[11px] font-medium truncate ${e.status==="running"?"text-cc-fg":"text-cc-fg/60"}`,children:e.name}),r.jsx("span",{className:"text-[8px] text-cc-muted/40 uppercase font-mono-code shrink-0",children:e.agentType})]}),l&&t&&r.jsxs("div",{className:"mt-0.5 space-y-0.5",children:[r.jsx("p",{className:"text-[10px] text-cc-muted/60 leading-tight",children:e.summary}),(e.costUsd||((d=e.filesChanged)==null?void 0:d.length)||e.error)&&r.jsx("p",{className:"text-[9px] text-cc-muted/50 font-mono-code truncate",children:e.error||`${e.costUsd?`$${e.costUsd.toFixed(4)}`:"$0"}${(f=e.filesChanged)!=null&&f.length?` / ${e.filesChanged.length} files`:""}`})]})]}),r.jsx("span",{className:"text-[10px] text-cc-muted/50 font-mono-code tabular-nums shrink-0",children:a})]});return l?r.jsx("button",{onClick:()=>s(h=>!h),"aria-expanded":t,className:"w-full flex items-center gap-2.5 px-3 py-1.5 hover:bg-cc-hover/60 transition-colors text-left cursor-pointer",children:c}):r.jsx("div",{className:"flex items-center gap-2.5 px-3 py-1.5",children:c})}function BB({tool:e}){const t=e.elapsedSeconds<60?e.elapsedSeconds+"s":Math.floor(e.elapsedSeconds/60)+"m "+e.elapsedSeconds%60+"s";return r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-1.5",children:[r.jsxs("svg",{className:"w-3.5 h-3.5 text-cc-primary animate-spin shrink-0",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:[r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),r.jsx("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),r.jsx("span",{className:"text-[11px] font-medium text-cc-fg truncate flex-1",children:e.toolName}),r.jsx("span",{className:"text-[10px] text-cc-muted/50 font-mono-code tabular-nums shrink-0",children:t})]})}function OB({task:e}){return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1",children:[e.status==="in_progress"&&r.jsxs("svg",{className:"w-3.5 h-3.5 text-cc-primary animate-spin shrink-0",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:[r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),r.jsx("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.status==="completed"&&r.jsx("svg",{className:"w-3.5 h-3.5 text-cc-success shrink-0",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":!0,children:r.jsx("path",{d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})}),e.status==="pending"&&r.jsx("svg",{className:"w-3.5 h-3.5 text-cc-muted/30 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":!0,children:r.jsx("circle",{cx:"8",cy:"8",r:"5.5"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:`text-[11px] truncate block ${e.status==="completed"?"text-cc-muted/50 line-through":"text-cc-fg"}`,children:e.subject}),e.status==="in_progress"&&e.activeForm&&r.jsx("span",{className:"text-[10px] text-cc-muted/50 italic truncate block",children:e.activeForm})]})]})}function zB({sessions:e,onJump:t}){return r.jsx("div",{className:"py-1",children:e.map(s=>r.jsx(PB,{activity:s,onJump:t},s.sessionId))})}function PB({activity:e,onJump:t}){const s=kB(e.cost),n=e.status==="running"||e.status==="compacting";return r.jsxs("button",{onClick:()=>t(e.sessionId),className:"w-full flex items-center gap-2.5 px-3 py-2 hover:bg-cc-hover/60 transition-colors text-left cursor-pointer group",title:`Switch to ${e.name}`,children:[r.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0",children:[n&&r.jsx("span",{className:`absolute inset-0 rounded-full opacity-75 animate-breathing ${e.status==="compacting"?"bg-cc-warning":"bg-cc-primary"}`}),r.jsx("span",{className:`relative inline-flex rounded-full h-1.5 w-1.5 ${CB(e.status)}`})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[11px] font-medium text-cc-fg truncate",children:e.name}),e.status==="compacting"&&r.jsx("span",{className:"text-[9px] text-cc-warning/70 font-mono-code shrink-0",children:"compacting"})]}),r.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[n&&e.startedAt!=null&&r.jsx("span",{className:"text-[10px] text-cc-muted/50 font-mono-code tabular-nums",children:cC(e.startedAt)}),s&&r.jsx("span",{className:"text-[10px] text-cc-muted/50 font-mono-code tabular-nums",children:s})]})]}),e.pendingPerms>0&&r.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-cc-warning/10 shrink-0",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-2.5 h-2.5 text-cc-warning","aria-hidden":!0,children:r.jsx("path",{d:"M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"})}),r.jsx("span",{className:"text-[9px] font-semibold text-cc-warning tabular-nums",children:e.pendingPerms})]}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-muted/30 group-hover:text-cc-primary/60 transition-colors shrink-0","aria-hidden":!0,children:r.jsx("path",{d:"M8.22 2.97a.75.75 0 011.06 0l4.25 4.25a.75.75 0 010 1.06l-4.25 4.25a.75.75 0 01-1.06-1.06l2.97-2.97H3.75a.75.75 0 010-1.5h7.44L8.22 4.03a.75.75 0 010-1.06z"})})]})}function uC({sessionId:e}){const t=G(_=>_.pendingPermissions.get(e)),s=G(_=>_.connectionStatus.get(e)??"disconnected"),n=G(_=>_.cliConnected.get(e)??!1),a=G(_=>_.cliLaunching.get(e)??!1),l=G(_=>_.sessions.get(e)),c=G(_=>_.sdkSessions.find(v=>v.sessionId===e)),d=G(_=>_.completedSubagentSessions.get(e)),f=(l==null?void 0:l.orchestration_role)==="subagent"||!!(l!=null&&l.parent_session_id)||(c==null?void 0:c.orchestrationRole)==="subagent"||!!(c!=null&&c.parentSessionId),h=!!d||f&&!n&&(c==null?void 0:c.state)==="exited",m=d==="failed"?"subagent failed":d==="timeout"?"subagent timed out":"subagent completed",g=w.useMemo(()=>t?Array.from(t.values()):[],[t]);return r.jsxs("div",{className:"flex flex-col h-full min-h-0 relative",children:[s==="connected"&&!n&&a&&r.jsxs("div",{className:"px-4 py-1.5 bg-cc-accent/5 border-b border-cc-border text-center flex items-center justify-center gap-3",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-cc-accent animate-pulse"}),r.jsx("span",{className:"text-[11px] text-cc-muted font-mono-code",children:"starting agent..."})]}),h&&!a&&r.jsxs("div",{className:"px-4 py-1.5 bg-cc-hover/40 border-b border-cc-border text-center flex items-center justify-center gap-2",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-cc-muted/60"}),r.jsx("span",{className:"text-[11px] text-cc-muted font-mono-code",children:m})]}),s==="connected"&&!n&&!a&&!h&&r.jsxs("div",{className:"px-4 py-1.5 bg-cc-warning/5 border-b border-cc-border text-center flex items-center justify-center gap-3",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-cc-warning animate-pulse"}),r.jsx("span",{className:"text-[11px] text-cc-warning/80 font-mono-code",children:"agent disconnected"}),r.jsx("button",{onClick:()=>ne.relaunchSession(e).catch(console.error),className:"text-[11px] font-mono-code px-2 py-0.5 rounded bg-cc-warning/10 hover:bg-cc-warning/20 text-cc-warning transition-colors cursor-pointer",children:"reconnect"})]}),s==="disconnected"&&!h&&r.jsxs("div",{className:"px-4 py-1.5 bg-cc-warning/5 border-b border-cc-border text-center flex items-center justify-center gap-2",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-cc-warning animate-pulse"}),r.jsx("span",{className:"text-[11px] text-cc-warning/80 font-mono-code",children:"reconnecting..."})]}),r.jsx(Y0,{sessionId:e}),g.length>0&&r.jsx("div",{className:"shrink-0 max-h-[55dvh] overflow-y-auto border-t border-cc-border",children:g.map(_=>r.jsx(Zs,{permission:_,sessionId:e},_.request_id))}),r.jsx(fB,{sessionId:e}),r.jsx(RB,{})]})}const $B=w.lazy(()=>Xi(()=>Promise.resolve().then(()=>hu),void 0).then(e=>({default:e.CodeEditor})));function dC({cwd:e,open:t,onClose:s}){var Q;const[n,a]=w.useState([]),[l,c]=w.useState(!0),[d,f]=w.useState(0),[h,m]=w.useState(""),[g,_]=w.useState(!1),[v,y]=w.useState(!1),[S,j]=w.useState(null),[k,N]=w.useState(null),E=w.useCallback(()=>{c(!0),j(null),ne.getClaudeMdFiles(e).then(V=>{a(V.files),V.files.length>0&&(f(0),m(V.files[0].content)),N(null),_(!1),c(!1)}).catch(V=>{j(V.message),c(!1)})},[e]);w.useEffect(()=>{t&&E()},[t,E]);const B=V=>{g&&!confirm("Discard unsaved changes?")||(f(V),m(n[V].content),_(!1),N(null))},F=async()=>{var X;const V=k||((X=n[d])==null?void 0:X.path);if(V){y(!0),j(null);try{await ne.saveClaudeMd(V,h),_(!1),k?E():a(q=>q.map((A,M)=>M===d?{...A,content:h}:A))}catch(q){j(q instanceof Error?q.message:"Failed to save")}finally{y(!1)}}},$=V=>{const X=V==="root"?`${e}/CLAUDE.md`:`${e}/.claude/CLAUDE.md`;N(X),m(`# CLAUDE.md
110
+
111
+ `),_(!0)},K=()=>{g&&!confirm("Discard unsaved changes?")||s()};if(!t)return null;const Y=V=>V.startsWith(e+"/")?V.slice(e.length+1):V,W=n.some(V=>V.path===`${e}/CLAUDE.md`),L=n.some(V=>V.path===`${e}/.claude/CLAUDE.md`);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 bg-black/40 z-50",onClick:K}),r.jsxs("div",{className:"fixed inset-4 sm:inset-8 md:inset-x-[10%] md:inset-y-[5%] z-50 flex flex-col bg-cc-bg border border-cc-border rounded-2xl shadow-2xl overflow-hidden",children:[r.jsxs("div",{className:"shrink-0 flex items-center justify-between px-4 sm:px-5 py-3 bg-cc-card border-b border-cc-border",children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"w-7 h-7 rounded-lg bg-cc-primary/10 flex items-center justify-center",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-primary",children:r.jsx("path",{d:"M4 1.5a.5.5 0 01.5-.5h7a.5.5 0 01.354.146l2 2A.5.5 0 0114 3.5v11a.5.5 0 01-.5.5h-11a.5.5 0 01-.5-.5v-13zm1 .5v12h8V4h-1.5a.5.5 0 01-.5-.5V2H5zm6 0v1h1l-1-1z"})})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-sm font-semibold text-cc-fg",children:"CLAUDE.md"}),r.jsx("p",{className:"text-[11px] text-cc-muted",children:"Project instructions for Claude Code"})]})]}),r.jsx("button",{onClick:K,className:"w-7 h-7 flex items-center justify-center rounded-lg text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-4 h-4",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})})})]}),r.jsx("div",{className:"flex-1 flex min-h-0",children:l?r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx("div",{className:"w-5 h-5 border-2 border-cc-primary border-t-transparent rounded-full animate-spin"})}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"shrink-0 w-[180px] sm:w-[200px] border-r border-cc-border bg-cc-sidebar flex flex-col",children:[r.jsx("div",{className:"px-3 py-2 text-[10px] font-semibold text-cc-muted uppercase tracking-wider border-b border-cc-border",children:"Files"}),r.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[n.map((V,X)=>r.jsxs("button",{onClick:()=>B(X),className:`flex items-center gap-2 w-full px-3 py-2 text-left text-[12px] transition-colors cursor-pointer ${!k&&d===X?"bg-cc-active text-cc-fg":"text-cc-fg/70 hover:bg-cc-hover"}`,children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-primary shrink-0",children:r.jsx("path",{d:"M4 1.5a.5.5 0 01.5-.5h7a.5.5 0 01.354.146l2 2A.5.5 0 0114 3.5v11a.5.5 0 01-.5.5h-11a.5.5 0 01-.5-.5v-13z"})}),r.jsx("span",{className:"truncate font-mono-code",children:Y(V.path)})]},V.path)),k&&r.jsxs("div",{className:"flex items-center gap-2 w-full px-3 py-2 text-[12px] bg-cc-active text-cc-fg",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-success shrink-0",children:r.jsx("path",{d:"M8 2a.5.5 0 01.5.5v5h5a.5.5 0 010 1h-5v5a.5.5 0 01-1 0v-5h-5a.5.5 0 010-1h5v-5A.5.5 0 018 2z"})}),r.jsx("span",{className:"truncate font-mono-code",children:Y(k)})]})]}),(!W||!L)&&!k&&r.jsxs("div",{className:"shrink-0 border-t border-cc-border p-2",children:[r.jsx("div",{className:"text-[10px] text-cc-muted uppercase tracking-wider px-1 mb-1",children:"Create new"}),!W&&r.jsxs("button",{onClick:()=>$("root"),className:"flex items-center gap-1.5 w-full px-2 py-1.5 text-[11px] text-cc-fg/70 hover:bg-cc-hover rounded-md transition-colors cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-success shrink-0",children:r.jsx("path",{d:"M8 2a.5.5 0 01.5.5v5h5a.5.5 0 010 1h-5v5a.5.5 0 01-1 0v-5h-5a.5.5 0 010-1h5v-5A.5.5 0 018 2z"})}),r.jsx("span",{className:"font-mono-code",children:"CLAUDE.md"})]}),!L&&r.jsxs("button",{onClick:()=>$("dotclaude"),className:"flex items-center gap-1.5 w-full px-2 py-1.5 text-[11px] text-cc-fg/70 hover:bg-cc-hover rounded-md transition-colors cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-success shrink-0",children:r.jsx("path",{d:"M8 2a.5.5 0 01.5.5v5h5a.5.5 0 010 1h-5v5a.5.5 0 01-1 0v-5h-5a.5.5 0 010-1h5v-5A.5.5 0 018 2z"})}),r.jsx("span",{className:"font-mono-code",children:".claude/CLAUDE.md"})]})]})]}),r.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[n.length===0&&!k?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 px-6",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-cc-card border border-cc-border flex items-center justify-center",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-6 h-6 text-cc-muted",children:r.jsx("path",{d:"M4 1.5a.5.5 0 01.5-.5h7a.5.5 0 01.354.146l2 2A.5.5 0 0114 3.5v11a.5.5 0 01-.5.5h-11a.5.5 0 01-.5-.5v-13z"})})}),r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-sm text-cc-fg font-medium mb-1",children:"No CLAUDE.md found"}),r.jsx("p",{className:"text-xs text-cc-muted leading-relaxed max-w-[280px]",children:"Create a CLAUDE.md file to give Claude Code project-specific instructions, coding conventions, and context."})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:()=>$("root"),className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-cc-primary text-white hover:bg-cc-primary/90 transition-colors cursor-pointer",children:"Create CLAUDE.md"}),r.jsx("button",{onClick:()=>$("dotclaude"),className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-cc-hover text-cc-fg border border-cc-border hover:bg-cc-active transition-colors cursor-pointer",children:"Create .claude/CLAUDE.md"})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"shrink-0 flex items-center justify-between px-4 py-2 bg-cc-card border-b border-cc-border",children:[r.jsx("span",{className:"text-[12px] text-cc-muted font-mono-code truncate",children:Y(k||(((Q=n[d])==null?void 0:Q.path)??""))}),r.jsxs("div",{className:"flex items-center gap-2",children:[g&&r.jsx("span",{className:"text-[10px] text-cc-warning font-medium",children:"Unsaved"}),r.jsx("button",{onClick:F,disabled:!g||v,className:`px-3 py-1 text-[11px] font-medium rounded-md transition-colors cursor-pointer ${g&&!v?"bg-cc-primary text-white hover:bg-cc-primary/90":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:v?"Saving...":"Save"})]})]}),r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"p-4 text-cc-muted text-[12px]",children:"Loading editor..."}),children:r.jsx($B,{value:h,onChange:V=>{m(V),_(!0)},language:"markdown",height:"60vh",minimap:!1,wordWrap:!0,ariaLabel:"CLAUDE.md editor",className:"border-0 rounded-none"})})]}),S&&r.jsx("div",{className:"shrink-0 px-4 py-2 bg-cc-error/10 border-t border-cc-error/20 text-xs text-cc-error",children:S})]})]})})]})]})}function IB(e,t){return t||e||"claude"}function FB(e,t){const s=e.find(a=>a.value===t);if(s)return s;if(!t)return null;const n=t.split("/").pop()||t;return{value:t,label:n,icon:"◆"}}function HB({sessionId:e}){const t=G(v=>v.sdkSessions.find(y=>y.sessionId===e)||null),s=G(v=>v.sessions.get(e)),n=G(v=>v.cliConnected.get(e)??!1),[a,l]=w.useState(!1),c=w.useRef(null),d=IB(t==null?void 0:t.backendType,s==null?void 0:s.backend_type),f=d==="codex",h=(s==null?void 0:s.model)??(t==null?void 0:t.model)??si(d),m=Yh(d),g=FB(m,h);w.useEffect(()=>{if(!a)return;function v(y){c.current&&!c.current.contains(y.target)&&l(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[a]),w.useEffect(()=>{if(!a)return;function v(y){y.key==="Escape"&&(y.stopPropagation(),l(!1))}return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[a]);function _(v){if(v===h){l(!1);return}n&&en(e,{type:"set_model",model:v});const{sdkSessions:y,setSdkSessions:S}=G.getState();S(y.map(j=>j.sessionId===e?{...j,model:v}:j)),l(!1)}return f||!g?null:r.jsxs("div",{className:"relative",ref:c,children:[r.jsxs("button",{onClick:()=>l(v=>!v),"aria-label":"Switch model","aria-expanded":a,"aria-haspopup":"listbox",className:`flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-mono-code transition-colors cursor-pointer ${a?"bg-cc-active text-cc-fg":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:[r.jsx("span",{className:"text-[10px]",children:g.icon}),r.jsx("span",{className:"max-w-[80px] truncate hidden sm:inline",children:g.label}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 transition-transform duration-150 ${a?"rotate-180":""}`,children:r.jsx("path",{d:"M4.427 9.573l3.396-3.396a.25.25 0 01.354 0l3.396 3.396a.25.25 0 01-.177.427H4.604a.25.25 0 01-.177-.427z"})})]}),a&&r.jsxs("ul",{"aria-label":"Available models",className:"absolute right-0 top-full mt-1 z-50 min-w-[180px] max-h-64 overflow-y-auto bg-cc-card border border-cc-border rounded-lg shadow-float py-1 animate-slide-down list-none m-0 p-0 py-1",children:[r.jsx("div",{className:"px-3 py-1",children:r.jsx("span",{className:"text-[9px] text-cc-muted/50 uppercase tracking-widest font-semibold",children:d})}),m.map(v=>{const y=v.value===h;return r.jsx("li",{children:r.jsxs("button",{onClick:()=>_(v.value),"aria-pressed":y,className:`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors cursor-pointer ${y?"bg-cc-primary/8 text-cc-fg":"text-cc-fg/80 hover:bg-cc-hover"}`,children:[r.jsx("span",{className:"text-[11px] w-4 text-center shrink-0",children:v.icon}),r.jsx("span",{className:"text-[11px] font-medium flex-1 truncate",children:v.label}),y&&r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-primary shrink-0","aria-hidden":!0,children:r.jsx("path",{d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})})]})},v.value)})]})]})}const UB={claude:{label:"Claude",color:"text-[#5BA8A0]",icon:"✨"},codex:{label:"Codex",color:"text-blue-500",icon:"✳"},goose:{label:"Goose",color:"text-amber-500",icon:"🦪"},aider:{label:"Aider",color:"text-purple-500",icon:"◆"},openhands:{label:"OpenHands",color:"text-rose-500",icon:"✋"},openclaw:{label:"OpenClaw",color:"text-orange-500",icon:"🐾"},opencode:{label:"OpenCode",color:"text-teal-500",icon:"●"}};function R5(e){return UB[e]||{label:e,color:"text-cc-muted",icon:"◆"}}function VB({sessionId:e}){const t=G(S=>S.sdkSessions.find(j=>j.sessionId===e)||null),s=G(S=>S.sessions.get(e)),n=G(S=>S.setCurrentSession),[a,l]=w.useState(!1),[c,d]=w.useState([]),[f,h]=w.useState(!1),m=w.useRef(null),g=(s==null?void 0:s.backend_type)||(t==null?void 0:t.backendType)||"claude",_=(s==null?void 0:s.cwd)||(t==null?void 0:t.cwd)||"",v=R5(g);w.useEffect(()=>{a&&ne.getBackends().then(d).catch(()=>{})},[a]),w.useEffect(()=>{if(!a)return;function S(j){m.current&&!m.current.contains(j.target)&&l(!1)}return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[a]),w.useEffect(()=>{if(!a)return;function S(j){j.key==="Escape"&&(j.stopPropagation(),l(!1))}return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[a]);const y=w.useCallback(async S=>{if(S===g){l(!1);return}h(!0);try{const j=S,k=await ne.createSession({backend:j,model:si(j),permissionMode:Jc(j),cwd:_||void 0});k.sessionId&&(Sr(k.sessionId),n(k.sessionId)),l(!1)}catch(j){console.error("[ProviderSwitcher] Failed to create session:",j)}finally{h(!1)}},[g,_,n]);return r.jsxs("div",{className:"relative",ref:m,children:[r.jsxs("button",{onClick:()=>l(S=>!S),"aria-label":"Switch provider","aria-expanded":a,className:`flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium transition-colors cursor-pointer ${a?"bg-cc-active text-cc-fg":`${v.color} hover:bg-cc-hover`}`,children:[r.jsx("span",{className:"text-[10px]",children:v.icon}),r.jsx("span",{className:"hidden sm:inline",children:v.label}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 transition-transform duration-150 ${a?"rotate-180":""}`,children:r.jsx("path",{d:"M4.427 9.573l3.396-3.396a.25.25 0 01.354 0l3.396 3.396a.25.25 0 01-.177.427H4.604a.25.25 0 01-.177-.427z"})})]}),a&&r.jsxs("ul",{"aria-label":"Available providers",className:"absolute right-0 top-full mt-1 z-50 min-w-[200px] bg-cc-card border border-cc-border rounded-lg shadow-float py-1 animate-slide-down list-none m-0 p-0 py-1",children:[r.jsx("li",{className:"px-3 py-1",children:r.jsx("span",{className:"text-[9px] text-cc-muted/50 uppercase tracking-widest font-semibold",children:"Providers"})}),c.map(S=>{const j=R5(S.id),k=S.id===g;return r.jsx("li",{children:r.jsxs("button",{onClick:()=>y(S.id),disabled:!S.available||f,"aria-pressed":k,className:`w-full flex items-center gap-2.5 px-3 py-2 text-left transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed ${k?"bg-cc-primary/8":"hover:bg-cc-hover"}`,children:[r.jsx("span",{className:`text-sm ${j.color}`,children:j.icon}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[11px] font-medium text-cc-fg",children:j.label}),!S.available&&r.jsx("span",{className:"text-[8px] text-cc-muted/50 font-mono-code",children:"not installed"})]}),k&&r.jsx("span",{className:"text-[9px] text-cc-muted/60",children:"current session"}),!k&&S.available&&r.jsx("span",{className:"text-[9px] text-cc-muted/50",children:"new session, same directory"})]}),k&&r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-primary shrink-0","aria-hidden":!0,children:r.jsx("path",{d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})})]})},S.id)}),c.length===0&&r.jsx("li",{className:"px-3 py-2 text-[11px] text-cc-muted",children:"Loading providers..."}),f&&r.jsx("li",{className:"px-3 py-1.5 text-[10px] text-cc-primary font-mono-code animate-breathing",children:"Creating session..."})]})]})}const D5=[];function WB(){var Pe;const e=w.useSyncExternalStore(ye=>(window.addEventListener("hashchange",ye),()=>window.removeEventListener("hashchange",ye)),()=>window.location.hash),t=e!=="#/settings"&&e!=="#/terminal"&&e!=="#/environments"&&e!=="#/gallery"&&e!=="#/webhooks"&&e!=="#/adapters",s=G(ye=>ye.currentSessionId),n=G(ye=>ye.cliConnected),a=G(ye=>ye.sessionStatus),l=G(ye=>ye.sessionNames),c=G(ye=>ye.sdkSessions),d=G(ye=>ye.completedSubagentSessions),f=G(ye=>ye.sidebarOpen),h=G(ye=>ye.setSidebarOpen),m=G(ye=>ye.taskPanelOpen),g=G(ye=>ye.setTaskPanelOpen),_=G(ye=>ye.activeTab),v=G(ye=>ye.setActiveTab),[y,S]=w.useState(!1),[j,k]=w.useState(!1),[N,E]=w.useState(!1),[B,F]=w.useState(!1),[$,K]=w.useState(!1),[Y,W]=w.useState(!1),[L,Q]=w.useState(""),V=w.useRef(null),X=w.useRef(null),q=G(ye=>{var ts,Kt;if(!s)return 0;const Ze=((ts=ye.sessions.get(s))==null?void 0:ts.cwd)||((Kt=ye.sdkSessions.find(Ft=>Ft.sessionId===s))==null?void 0:Kt.cwd),ft=ye.changedFiles.get(s);if(!ft)return 0;if(!Ze)return ft.size;const mt=`${Ze}/`;return[...ft].filter(Ft=>Ft===Ze||Ft.startsWith(mt)).length}),A=G(ye=>{var Ze,ft;return s&&(((Ze=ye.sessions.get(s))==null?void 0:Ze.cwd)||((ft=ye.sdkSessions.find(mt=>mt.sessionId===s))==null?void 0:ft.cwd))||null}),M=G(ye=>{var Ze;return s?((Ze=ye.sessions.get(s))==null?void 0:Ze.total_cost_usd)??0:0}),U=G(ye=>s?ye.myRole.get(s)??null:null)==="spectator",I=G(ye=>s?ye.sessionViewers.get(s)??D5:D5),R=s?n.get(s)??!1:!1,P=s?a.get(s)??null:null,z=G(ye=>s?ye.sessions.get(s):void 0),T=s?c.find(ye=>ye.sessionId===s):void 0,oe=(z==null?void 0:z.orchestration_role)==="subagent"||!!(z!=null&&z.parent_session_id)||(T==null?void 0:T.orchestrationRole)==="subagent"||!!(T!=null&&T.parentSessionId),be=s?d.get(s):void 0,re=!!be||oe&&!R&&(T==null?void 0:T.state)==="exited",ve=s?(l==null?void 0:l.get(s))||((Pe=c.find(ye=>ye.sessionId===s))==null?void 0:Pe.name)||`Session ${s.slice(0,8)}`:null;w.useEffect(()=>{Y&&V.current&&(V.current.focus(),V.current.select())},[Y]);async function Te(){if(!(!s||B)){F(!0);try{const ye=await ne.forkSession(s);if(ye.sessionId){G.getState().setCurrentSession(ye.sessionId);const{connectSession:Ze}=await Xi(async()=>{const{connectSession:mt}=await Promise.resolve().then(()=>Hj);return{connectSession:mt}},void 0);Ze(ye.sessionId);const ft=await ne.listSessions();G.getState().setSdkSessions(ft)}}catch(ye){console.error("[TopBar] Failed to fork session:",ye)}finally{F(!1)}}}async function Re(ye){if(!(!s||j))try{const{url:Ze}=await ne.createInviteLink(s,ye);let ft=!1;try{await navigator.clipboard.writeText(Ze),ft=!0}catch{try{const mt=document.createElement("textarea");mt.value=Ze,mt.style.position="fixed",mt.style.opacity="0",document.body.appendChild(mt),mt.select(),ft=document.execCommand("copy"),document.body.removeChild(mt)}catch{}}ft?(k(!0),E(!1),K(!1),setTimeout(()=>k(!1),2e3)):(E(!1),K(!1),window.prompt("Copy this invite link:",Ze))}catch(Ze){console.error("[TopBar] Failed to create invite link:",Ze)}}function je(){U||!s||(Q(ve||""),W(!0))}async function Ye(){W(!1);const ye=L.trim();if(!(!s||!ye||ye===ve))try{await ne.renameSession(s,ye),G.getState().setSessionName(s,ye)}catch(Ze){console.error("[TopBar] Failed to rename session:",Ze)}}function Xe(){s&&(navigator.clipboard.writeText(s).catch(()=>{window.prompt("Session ID:",s)}),K(!1))}return r.jsxs("header",{className:"shrink-0 flex items-center justify-between px-3 h-11 bg-cc-bg border-b border-cc-border",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[!U&&r.jsx("button",{onClick:()=>h(!f),"aria-label":"Toggle sidebar","aria-pressed":f,className:"flex items-center justify-center w-7 h-7 rounded text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-4 h-4",children:r.jsx("path",{d:"M2 4h12M2 8h12M2 12h12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),U&&r.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-mono-code uppercase tracking-wider bg-cc-muted/10 text-cc-muted",children:"spectator"}),s&&r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[r.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${R?"bg-cc-success":"bg-cc-muted/30"}`,title:R?"Connected":"Disconnected"}),Y?r.jsx("input",{ref:V,value:L,onChange:ye=>Q(ye.target.value),onBlur:Ye,onKeyDown:ye=>{ye.key==="Enter"&&Ye(),ye.key==="Escape"&&W(!1)},className:"text-sm font-medium text-cc-fg bg-transparent border-b border-cc-primary/50 outline-none max-w-[12rem] sm:max-w-[20rem]"}):r.jsx("span",{onClick:je,className:`text-sm font-medium text-cc-fg max-w-[10rem] sm:max-w-[20rem] truncate ${U?"":"cursor-pointer hover:text-cc-primary transition-colors"}`,title:ve||void 0,children:ve}),P==="compacting"&&r.jsx("span",{className:"text-[10px] text-cc-warning/70 font-mono-code animate-pulse ml-1",children:"compacting"}),P==="running"&&r.jsxs("div",{className:"flex items-center gap-1 ml-1",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-cc-primary/60 animate-breathing"}),r.jsx("span",{className:"text-[10px] text-cc-primary/70 font-mono-code",children:"running"})]}),re&&r.jsx("span",{className:"text-[10px] text-cc-muted font-mono-code ml-1",children:be??"completed"}),!R&&!U&&!re&&r.jsx("button",{onClick:()=>s&&ne.relaunchSession(s).catch(console.error),className:"text-[10px] text-cc-warning/80 hover:text-cc-warning font-medium font-mono-code cursor-pointer ml-1 hidden sm:inline",children:"reconnect"})]})]}),s&&t&&r.jsxs("div",{className:"flex items-center gap-2",children:[I.length>1&&r.jsxs("div",{className:"flex items-center gap-0.5 mr-1",title:`${I.length} viewers`,children:[I.slice(0,3).map(ye=>r.jsx("span",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[9px] font-bold ${ye.role==="owner"?"bg-cc-primary/15 text-cc-primary":"bg-cc-hover text-cc-muted/60"}`,title:`${ye.name} (${ye.role})`,children:ye.name.charAt(0).toUpperCase()},ye.id)),I.length>3&&r.jsxs("span",{className:"text-[9px] text-cc-muted/40 ml-0.5",children:["+",I.length-3]})]}),r.jsxs("div",{className:"flex items-center bg-cc-hover/50 rounded-md p-0.5",children:[r.jsx("button",{onClick:()=>v("chat"),"aria-pressed":_==="chat",className:`text-[11px] px-2.5 py-1 rounded-md transition-colors cursor-pointer ${_==="chat"?"text-cc-fg bg-cc-active":"text-cc-muted hover:text-cc-fg"}`,children:"Log"}),r.jsxs("button",{onClick:()=>v("diff"),"aria-pressed":_==="diff",className:`text-[11px] px-2.5 py-1 rounded-md transition-colors cursor-pointer flex items-center gap-1 ${_==="diff"?"text-cc-fg bg-cc-active":"text-cc-muted hover:text-cc-fg"}`,children:["Diff",q>0&&r.jsx("span",{className:"text-[9px] text-cc-warning tabular-nums",children:q})]}),r.jsx("button",{onClick:()=>v("files"),"aria-pressed":_==="files",className:`text-[11px] px-2.5 py-1 rounded-md transition-colors cursor-pointer ${_==="files"?"text-cc-fg bg-cc-active":"text-cc-muted hover:text-cc-fg"}`,children:"Files"})]}),M>0&&r.jsxs("span",{className:"text-[11px] text-cc-muted font-mono-code tabular-nums",title:`Session cost: $${M.toFixed(4)}`,children:["$",M<.01?M.toFixed(4):M.toFixed(2)]}),!U&&r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx(VB,{sessionId:s}),r.jsx("span",{className:"text-cc-border text-[10px] select-none",children:"/"}),r.jsx(HB,{sessionId:s})]}),!U&&r.jsxs("div",{className:"relative",ref:X,children:[r.jsx("button",{onClick:()=>K(!$),"aria-label":"More actions",className:"flex items-center justify-center w-7 h-7 rounded text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4",children:[r.jsx("circle",{cx:"8",cy:"3",r:"1.5"}),r.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),r.jsx("circle",{cx:"8",cy:"13",r:"1.5"})]})}),$&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>{K(!1),E(!1)}}),r.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 bg-cc-card border border-cc-border rounded-md shadow-panel py-1 min-w-[180px]",children:[A&&r.jsxs("button",{onClick:()=>{Te(),K(!1)},disabled:B,className:"w-full text-left px-3 py-1.5 text-[11px] text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer font-mono-code flex items-center gap-2 disabled:opacity-40",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 shrink-0",children:r.jsx("path",{fillRule:"evenodd",d:"M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z"})}),B?"Forking...":"Fork session"]}),r.jsxs("div",{className:"relative",children:[r.jsxs("button",{onClick:()=>E(!N),className:"w-full text-left px-3 py-1.5 text-[11px] text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer font-mono-code flex items-center gap-2",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 shrink-0",children:r.jsx("path",{d:"M15 8a3 3 0 10-2.977-2.63l-4.94 2.47a3 3 0 100 4.319l4.94 2.47a3 3 0 10.895-1.789l-4.94-2.47a3.027 3.027 0 000-.74l4.94-2.47C13.456 7.68 14.19 8 15 8z"})}),j?"Copied!":"Share",r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 ml-auto",children:r.jsx("path",{d:"M6 4l4 4-4 4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),N&&r.jsxs("div",{className:"absolute right-full top-0 mr-1 bg-cc-card border border-cc-border rounded-md shadow-panel py-1 min-w-[150px]",children:[r.jsxs("button",{onClick:()=>Re("collaborator"),className:"w-full text-left px-3 py-1.5 text-[11px] text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer font-mono-code",children:[r.jsx("span",{className:"font-medium",children:"Collaborator"}),r.jsx("span",{className:"block text-cc-muted/60 text-[9px]",children:"approve & send"})]}),r.jsxs("button",{onClick:()=>Re("spectator"),className:"w-full text-left px-3 py-1.5 text-[11px] text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer font-mono-code",children:[r.jsx("span",{className:"font-medium",children:"Spectator"}),r.jsx("span",{className:"block text-cc-muted/60 text-[9px]",children:"watch only"})]})]})]}),r.jsx("div",{className:"my-1 border-t border-cc-border"}),A&&r.jsxs("button",{onClick:()=>{S(!0),K(!1)},className:"w-full text-left px-3 py-1.5 text-[11px] text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer font-mono-code flex items-center gap-2",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 shrink-0",children:r.jsx("path",{d:"M4 1.5a.5.5 0 01.5-.5h7a.5.5 0 01.354.146l2 2A.5.5 0 0114 3.5v11a.5.5 0 01-.5.5h-11a.5.5 0 01-.5-.5v-13zm1 .5v12h8V4h-1.5a.5.5 0 01-.5-.5V2H5zm6 0v1h1l-1-1zM6.5 7a.5.5 0 000 1h5a.5.5 0 000-1h-5zm0 2a.5.5 0 000 1h5a.5.5 0 000-1h-5zm0 2a.5.5 0 000 1h3a.5.5 0 000-1h-3z"})}),"Edit CLAUDE.md"]}),r.jsxs("button",{onClick:()=>{window.location.hash=s?`#/gallery?session=${encodeURIComponent(s)}`:"#/gallery",K(!1)},className:"w-full text-left px-3 py-1.5 text-[11px] text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer font-mono-code flex items-center gap-2",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 shrink-0",children:r.jsx("path",{d:"M2 3a1 1 0 011-1h10a1 1 0 011 1v1H2V3zm0 2.5h12v7a1 1 0 01-1 1H3a1 1 0 01-1-1v-7zM4 7v3h3V7H4zm5 0v1h3V7H9zm3 2.5H9V11h3V9.5z"})}),"View in gallery"]}),r.jsx("div",{className:"my-1 border-t border-cc-border"}),r.jsxs("button",{onClick:Xe,className:"w-full text-left px-3 py-1.5 text-[11px] text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer font-mono-code flex items-center gap-2",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 shrink-0",children:r.jsx("path",{d:"M5.75 1a.75.75 0 00-.75.75v1.5a.75.75 0 001.5 0V2.5h5v9h-.75a.75.75 0 000 1.5h1.5a.75.75 0 00.75-.75v-10.5A.75.75 0 0012.25 1h-6.5zM3.75 4a.75.75 0 00-.75.75v10.5a.75.75 0 00.75.75h6.5a.75.75 0 00.75-.75V4.75a.75.75 0 00-.75-.75h-6.5zM4.5 5.5h5v9h-5v-9z"})}),"Copy session ID"]})]})]})]}),r.jsx("button",{onClick:()=>g(!m),"aria-label":"Toggle session panel","aria-pressed":m,className:`flex items-center justify-center w-7 h-7 rounded transition-colors cursor-pointer ${m?"text-cc-primary bg-cc-active":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4",children:r.jsx("path",{d:"M3 2h10a1 1 0 011 1v10a1 1 0 01-1 1H3a1 1 0 01-1-1V3a1 1 0 011-1zm1 2v2h3V4H4zm5 0v1h3V4H9zm-5 3v2h3V7H4zm5 0v1h3V7H9zm-5 3v2h2V10H4z"})})})]}),A&&r.jsx(dC,{cwd:A,open:y,onClose:()=>S(!1)})]})}const hC="cc-recent-dirs";function Q0(){try{return JSON.parse(localStorage.getItem(hC)||"[]")}catch{return[]}}function fC(e){const t=Q0().filter(s=>s!==e);t.unshift(e),localStorage.setItem(hC,JSON.stringify(t.slice(0,5)))}var Z0=pS();function qB(e){return e.length<=6?"••••••":e.slice(0,3)+"•".repeat(Math.min(e.length-6,20))+e.slice(-3)}function GB(e){return`${e} variable${e!==1?"s":""}`}function pC({onClose:e,embedded:t=!1}){const[s,n]=w.useState([]),[a,l]=w.useState(!0),[c,d]=w.useState(null),[f,h]=w.useState(""),[m,g]=w.useState([]),[_,v]=w.useState(""),[y,S]=w.useState(new Set),[j,k]=w.useState(null),[N,E]=w.useState(""),[B,F]=w.useState([{key:"",value:""}]),[$,K]=w.useState(!1),[Y,W]=w.useState(!1),L=()=>{ne.listEnvs().then(n).catch(()=>{}).finally(()=>l(!1))};w.useEffect(()=>{L()},[]);function Q(I){S(R=>{const P=new Set(R);return P.has(I)?P.delete(I):P.add(I),P})}function V(I){d(I.slug),h(I.name);const R=Object.entries(I.variables).map(([P,z])=>({key:P,value:z}));R.length===0&&R.push({key:"",value:""}),g(R),v(""),W(!1)}function X(){d(null),v("")}async function q(){if(!c)return;const I={};for(const R of m){const P=R.key.trim();P&&(I[P]=R.value)}try{await ne.updateEnv(c,{name:f.trim()||void 0,variables:I}),d(null),v(""),L()}catch(R){v(R instanceof Error?R.message:String(R))}}async function A(I){try{await ne.deleteEnv(I),c===I&&d(null),k(null),L()}catch(R){v(R instanceof Error?R.message:String(R))}}async function M(){const I=N.trim();if(!I)return;K(!0);const R={};for(const P of B){const z=P.key.trim();z&&(R[z]=P.value)}try{await ne.createEnv(I,R),E(""),F([{key:"",value:""}]),v(""),W(!1),L()}catch(P){v(P instanceof Error?P.message:String(P))}finally{K(!1)}}function O(I){const R=c===I.slug,P=y.has(I.slug),z=j===I.slug,T=Object.entries(I.variables);return r.jsxs("div",{className:`rounded-xl border transition-all duration-200 overflow-hidden ${R?"border-cc-primary/40 bg-cc-card shadow-sm ring-1 ring-cc-primary/10":"border-cc-border/60 bg-cc-card hover:border-cc-border"}`,children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${R?"bg-cc-primary/10":"bg-cc-hover/70"}`,children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-4 h-4 ${R?"text-cc-primary":"text-cc-fg/50"}`,children:r.jsx("path",{d:"M8 1a2 2 0 012 2v1h2a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6a2 2 0 012-2h2V3a2 2 0 012-2zm0 1.5a.5.5 0 00-.5.5v1h1V3a.5.5 0 00-.5-.5zM4 5.5a.5.5 0 00-.5.5v6a.5.5 0 00.5.5h8a.5.5 0 00.5-.5V6a.5.5 0 00-.5-.5H4z"})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"text-[13px] font-semibold text-cc-fg truncate",children:I.name}),r.jsx("p",{className:"text-[11px] text-cc-fg/50",children:GB(T.length)})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[!R&&r.jsxs(r.Fragment,{children:[T.length>0&&r.jsx("button",{onClick:()=>Q(I.slug),className:"p-1.5 rounded-md text-cc-fg/40 hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",title:P?"Hide values":"Reveal values","aria-label":P?"Hide values":"Reveal values",children:P?r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M2.5 2.5l11 11M6.2 6.2a2.5 2.5 0 003.6 3.6M4 4.5C2.8 5.5 1.8 7 1 8c1.5 2.5 3.8 5 7 5 .8 0 1.6-.2 2.3-.4M12 11.5c1.2-1 2.2-2.5 3-3.5-1.5-2.5-3.8-5-7-5-.8 0-1.6.2-2.3.4",strokeLinecap:"round",strokeLinejoin:"round"})}):r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:[r.jsx("path",{d:"M1 8s2.5-5 7-5 7 5 7 5-2.5 5-7 5-7-5-7-5z",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("circle",{cx:"8",cy:"8",r:"2.5"})]})}),r.jsx("button",{onClick:()=>V(I),className:"p-1.5 rounded-md text-cc-fg/40 hover:text-cc-primary hover:bg-cc-primary/5 transition-colors cursor-pointer",title:"Edit profile","aria-label":"Edit profile",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M11.5 1.5l3 3-9 9H2.5v-3l9-9z",strokeLinecap:"round",strokeLinejoin:"round"})})}),r.jsx("button",{onClick:()=>k(I.slug),className:"p-1.5 rounded-md text-cc-fg/40 hover:text-cc-error hover:bg-cc-error/5 transition-colors cursor-pointer",title:"Delete profile","aria-label":"Delete profile",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M3 4h10M5.5 4V2.5h5V4M6 6.5v5M10 6.5v5M4.5 4l.5 9.5h6l.5-9.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),R&&r.jsx("button",{onClick:X,className:"px-2.5 py-1 rounded-md text-[11px] font-medium text-cc-fg/60 hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Cancel"})]})]}),z&&r.jsx("div",{className:"px-4 py-3 bg-cc-error/5 border-t border-cc-error/10",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-[12px] text-cc-error font-medium",children:['Delete "',I.name,'"?']}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>k(null),className:"px-2.5 py-1 rounded-md text-[11px] font-medium text-cc-fg/60 hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Cancel"}),r.jsx("button",{onClick:()=>A(I.slug),className:"px-2.5 py-1 rounded-md text-[11px] font-medium bg-cc-error text-white hover:bg-cc-error/90 transition-colors cursor-pointer",children:"Delete"})]})]})}),R&&r.jsxs("div",{className:"px-4 py-4 border-t border-cc-border/40 space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-medium text-cc-fg/70 mb-1.5",children:"Profile name"}),r.jsx("input",{type:"text",value:f,onChange:oe=>h(oe.target.value),placeholder:"Environment name",className:"w-full px-3 py-2 text-[13px] bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg placeholder:text-cc-fg/40 focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 transition-all"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-medium text-cc-fg/70 mb-1.5",children:"Variables"}),r.jsx(ig,{rows:m,onChange:g})]}),r.jsx("div",{className:"flex justify-end pt-1",children:r.jsx("button",{onClick:q,className:"px-4 py-2 text-[12px] font-medium bg-cc-primary hover:bg-cc-primary-hover text-white rounded-lg shadow-sm transition-colors cursor-pointer",children:"Save Changes"})})]}),!R&&T.length>0&&r.jsx("div",{className:"px-4 py-3 border-t border-cc-border/30 bg-cc-bg/50",children:r.jsx("div",{className:"space-y-1.5",children:T.map(([oe,be])=>r.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[r.jsx("span",{className:"font-mono-code text-cc-fg font-medium shrink-0",children:oe}),r.jsx("span",{className:"text-cc-fg/30",children:"="}),r.jsx("span",{className:"font-mono-code text-cc-fg/50 truncate",children:P?be:qB(be)})]},oe))})})]},I.slug)}if(t)return r.jsx("div",{className:"h-full bg-cc-bg overflow-y-auto font-sans-ui antialiased",children:r.jsxs("div",{className:"max-w-3xl mx-auto px-4 sm:px-8 py-6 sm:py-10",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[r.jsx("button",{onClick:()=>{window.location.hash=""},className:"flex items-center justify-center w-8 h-8 rounded-lg text-cc-fg/60 hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer","aria-label":"Go back",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",className:"w-4 h-4",children:r.jsx("path",{d:"M10 3L5 8l5 5",strokeLinecap:"round",strokeLinejoin:"round"})})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-[11px] text-cc-fg/50 font-medium",children:"Settings"}),r.jsx("h1",{className:"text-xl font-semibold text-cc-fg -mt-0.5",children:"Environments"})]}),r.jsx("button",{onClick:()=>{W(!Y),d(null)},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all cursor-pointer ${Y?"bg-cc-hover text-cc-fg":"bg-cc-primary hover:bg-cc-primary-hover text-white shadow-sm"}`,children:Y?r.jsxs(r.Fragment,{children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3 h-3",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})}),"Cancel"]}):r.jsxs(r.Fragment,{children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"w-3 h-3",children:r.jsx("path",{d:"M8 3v10M3 8h10"})}),"New Profile"]})})]}),r.jsx("p",{className:"text-[13px] text-cc-fg/60 mb-6",children:"Create and manage reusable environment profiles. Variables are injected when starting new sessions."}),_&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl bg-cc-error/8 border border-cc-error/15 text-[12px] text-cc-error flex items-center gap-2",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 shrink-0",children:r.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm0 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 4zm0 7a1 1 0 100-2 1 1 0 000 2z"})}),_]}),Y&&r.jsxs("div",{className:"mb-5 rounded-xl border border-cc-primary/30 bg-cc-card shadow-sm ring-1 ring-cc-primary/10 overflow-hidden",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-cc-border/30",children:[r.jsx("h3",{className:"text-[13px] font-semibold text-cc-fg",children:"New Environment Profile"}),r.jsx("p",{className:"text-[11px] text-cc-fg/50 mt-0.5",children:"Define a name and key-value pairs for this profile."})]}),r.jsxs("div",{className:"px-5 py-4 space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-medium text-cc-fg/70 mb-1.5",htmlFor:"new-env-name",children:"Profile name"}),r.jsx("input",{id:"new-env-name",type:"text",value:N,onChange:I=>E(I.target.value),placeholder:"e.g. production, staging, local",className:"w-full px-3.5 py-2.5 text-[13px] bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg placeholder:text-cc-fg/40 focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 transition-all",onKeyDown:I=>{I.key==="Enter"&&N.trim()&&M()},autoFocus:!0})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-medium text-cc-fg/70 mb-1.5",children:"Variables"}),r.jsx(ig,{rows:B,onChange:F})]}),r.jsxs("div",{className:"flex items-center justify-between pt-1",children:[r.jsxs("p",{className:"text-[11px] text-cc-fg/40",children:[B.filter(I=>I.key.trim()).length," variable",B.filter(I=>I.key.trim()).length!==1?"s":""," defined"]}),r.jsx("button",{onClick:M,disabled:!N.trim()||$,className:`px-4 py-2 rounded-lg text-[12px] font-medium transition-all ${N.trim()&&!$?"bg-cc-primary hover:bg-cc-primary-hover text-white shadow-sm cursor-pointer":"bg-cc-hover text-cc-fg/35 cursor-not-allowed"}`,children:$?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Creating..."]}):"Create Profile"})]})]})]}),a?r.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[r.jsx("span",{className:"w-6 h-6 border-2 border-cc-fg/10 border-t-cc-fg/50 rounded-full animate-spin mb-3"}),r.jsx("p",{className:"text-[12px] text-cc-fg/50",children:"Loading profiles..."})]}):s.length===0&&!Y?r.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[r.jsx("div",{className:"w-12 h-12 rounded-2xl bg-cc-hover/70 flex items-center justify-center mb-4",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-6 h-6 text-cc-fg/30",children:r.jsx("path",{d:"M8 1a2 2 0 012 2v1h2a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6a2 2 0 012-2h2V3a2 2 0 012-2zm0 1.5a.5.5 0 00-.5.5v1h1V3a.5.5 0 00-.5-.5zM4 5.5a.5.5 0 00-.5.5v6a.5.5 0 00.5.5h8a.5.5 0 00.5-.5V6a.5.5 0 00-.5-.5H4z"})})}),r.jsx("h3",{className:"text-[14px] font-semibold text-cc-fg mb-1",children:"No environment profiles"}),r.jsx("p",{className:"text-[12px] text-cc-fg/50 max-w-xs",children:"Create your first profile to store environment variables for session creation."}),r.jsx("button",{onClick:()=>W(!0),className:"mt-4 px-4 py-2 rounded-lg text-[12px] font-medium bg-cc-primary hover:bg-cc-primary-hover text-white shadow-sm transition-colors cursor-pointer",children:"Create First Profile"})]}):r.jsx("div",{className:"space-y-3",children:s.map(I=>O(I))})]})});const U=r.jsxs("div",{className:"w-full max-w-lg max-h-[90dvh] sm:max-h-[80dvh] mx-0 sm:mx-4 flex flex-col bg-cc-bg border border-cc-border rounded-t-xl sm:rounded-xl shadow-2xl overflow-hidden",onClick:I=>I.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-5 py-3 sm:py-4 border-b border-cc-border",children:[r.jsx("h2",{className:"text-sm font-semibold text-cc-fg",children:"Manage Environments"}),e&&r.jsx("button",{onClick:e,className:"w-6 h-6 flex items-center justify-center rounded-md text-cc-fg/50 hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})})})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto px-3 sm:px-5 py-3 sm:py-4 space-y-3",children:[_&&r.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:_}),s.map(I=>O(I)),r.jsxs("div",{className:"rounded-xl border border-cc-border/60 bg-cc-card overflow-hidden",children:[r.jsx("div",{className:"px-4 py-3 border-b border-cc-border/30",children:r.jsx("h3",{className:"text-[13px] font-semibold text-cc-fg",children:"New Profile"})}),r.jsxs("div",{className:"px-4 py-3 space-y-3",children:[r.jsx("input",{type:"text",value:N,onChange:I=>E(I.target.value),placeholder:"Profile name (e.g. production)",className:"w-full px-3 py-2 text-[13px] bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg placeholder:text-cc-fg/40 focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 transition-all",onKeyDown:I=>{I.key==="Enter"&&N.trim()&&M()}}),r.jsx(ig,{rows:B,onChange:F}),r.jsx("div",{className:"flex justify-end",children:r.jsx("button",{onClick:M,disabled:!N.trim()||$,className:`px-4 py-2 text-[12px] font-medium rounded-lg transition-all ${N.trim()&&!$?"bg-cc-primary hover:bg-cc-primary-hover text-white shadow-sm cursor-pointer":"bg-cc-hover text-cc-fg/35 cursor-not-allowed"}`,children:$?"Creating...":"Create"})})]})]})]})]});return Z0.createPortal(r.jsx("div",{className:"fixed inset-0 z-50 flex items-end sm:items-center justify-center bg-black/50",onClick:e,children:U}),document.body)}function ig({rows:e,onChange:t}){function s(l,c,d){const f=[...e];f[l]={...f[l],[c]:d},t(f)}function n(l){const c=e.filter((d,f)=>f!==l);c.length===0&&c.push({key:"",value:""}),t(c)}function a(){t([...e,{key:"",value:""}])}return r.jsxs("div",{className:"space-y-2",children:[e.map((l,c)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"text",value:l.key,onChange:d=>s(c,"key",d.target.value),placeholder:"KEY",className:"flex-1 min-w-0 px-3 py-2 text-[12px] font-mono-code bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg placeholder:text-cc-fg/30 focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 transition-all"}),r.jsx("span",{className:"text-[11px] text-cc-fg/30 font-mono-code",children:"="}),r.jsx("input",{type:"text",value:l.value,onChange:d=>s(c,"value",d.target.value),placeholder:"value",className:"flex-[1.5] min-w-0 px-3 py-2 text-[12px] font-mono-code bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg placeholder:text-cc-fg/30 focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 transition-all"}),r.jsx("button",{onClick:()=>n(c),className:"w-7 h-7 flex items-center justify-center rounded-lg text-cc-fg/30 hover:text-cc-error hover:bg-cc-error/5 transition-colors cursor-pointer shrink-0","aria-label":"Remove variable",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3 h-3",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})})})]},c)),r.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 text-[11px] font-medium text-cc-fg/45 hover:text-cc-primary transition-colors cursor-pointer pt-0.5",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3 h-3",children:r.jsx("path",{d:"M8 3v10M3 8h10",strokeLinecap:"round"})}),"Add variable"]})]})}function KB({cwd:e,repoRoot:t,onIssueSelected:s,onBranchFromIssue:n}){const[a,l]=w.useState(null),[c,d]=w.useState([]),[f,h]=w.useState(null),[m,g]=w.useState(""),[_,v]=w.useState([]),[y,S]=w.useState(!1),[j,k]=w.useState(null),[N,E]=w.useState(!1),B=w.useRef(null);w.useEffect(()=>{ne.getLinearConnection().then(Y=>{l(Y.connected),Y.teams&&d(Y.teams)}).catch(()=>l(!1))},[]),w.useEffect(()=>{!t||!a||ne.getLinearProjectMapping(t).then(Y=>{Y.mapping&&h(Y.mapping)}).catch(()=>{})},[t,a]);const F=w.useCallback(Y=>{if(!Y.trim()){v([]);return}S(!0),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{const W=f!=null&&f.teamKey?`team:${f.teamKey} `:"";ne.searchLinearIssues(W+Y,10).then(L=>{v(L.issues)}).catch(()=>{v([])}).finally(()=>S(!1))},300)},[f]),$=w.useCallback(Y=>{k(Y),g(""),v([]),s==null||s(Y);const W=`${Y.identifier.toLowerCase()}/${Y.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").slice(0,40)}`;n==null||n(W)},[s,n]),K=w.useCallback(async Y=>{try{await ne.setLinearProjectMapping({repoRoot:t,teamId:Y.id,teamKey:Y.key,teamName:Y.name}),h({teamId:Y.id,teamKey:Y.key,teamName:Y.name,repoRoot:t}),E(!1)}catch{}},[t]);return a===!1||a===null||!t?null:r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("svg",{viewBox:"0 0 16 16",className:"w-3.5 h-3.5 text-indigo-400 shrink-0",fill:"currentColor",children:[r.jsx("path",{d:"M1 3a2 2 0 012-2h10a2 2 0 012 2v10a2 2 0 01-2 2H3a2 2 0 01-2-2V3zm2-.5a.5.5 0 00-.5.5v10a.5.5 0 00.5.5h10a.5.5 0 00.5-.5V3a.5.5 0 00-.5-.5H3z"}),r.jsx("path",{d:"M4 5.75a.75.75 0 01.75-.75h2.5a.75.75 0 010 1.5h-2.5A.75.75 0 014 5.75zm0 4a.75.75 0 01.75-.75h6.5a.75.75 0 010 1.5h-6.5A.75.75 0 014 9.75z"})]}),r.jsx("span",{className:"text-xs text-cc-muted font-medium",children:"Linear"}),f?r.jsx("span",{className:"text-xs text-indigo-400 bg-indigo-500/10 px-1.5 py-0.5 rounded-full font-medium",children:f.teamKey}):r.jsx("button",{onClick:()=>E(!N),className:"text-[11px] text-cc-muted hover:text-cc-fg transition-colors cursor-pointer",children:"Link team..."})]}),N&&!f&&r.jsxs("div",{className:"bg-cc-card border border-cc-border rounded-lg overflow-hidden",children:[r.jsx("div",{className:"px-3 py-2 text-xs text-cc-muted border-b border-cc-border",children:"Select a Linear team for this repository"}),c.map(Y=>r.jsxs("button",{onClick:()=>K(Y),className:"w-full px-3 py-2 text-left text-xs hover:bg-cc-hover transition-colors cursor-pointer flex items-center gap-2",children:[r.jsx("span",{className:"font-medium text-cc-fg",children:Y.key}),r.jsx("span",{className:"text-cc-muted",children:Y.name})]},Y.id)),c.length===0&&r.jsx("div",{className:"px-3 py-2 text-xs text-cc-muted",children:"No teams found"})]}),f&&r.jsxs("div",{className:"relative",children:[r.jsx("input",{type:"text",placeholder:`Search ${f.teamKey} issues...`,value:m,onChange:Y=>{g(Y.target.value),F(Y.target.value)},className:"w-full px-3 py-1.5 text-xs bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted/50 outline-none focus:border-indigo-500/50 transition-colors"}),y&&r.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:r.jsx("svg",{className:"w-3 h-3 text-cc-muted animate-spin",viewBox:"0 0 16 16",fill:"none",children:r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"28",strokeDashoffset:"8",strokeLinecap:"round"})})}),_.length>0&&r.jsx("div",{className:"absolute z-50 mt-1 w-full bg-cc-card border border-cc-border rounded-lg shadow-lg overflow-hidden max-h-48 overflow-y-auto",children:_.map(Y=>r.jsxs("button",{onClick:()=>$(Y),className:"w-full px-3 py-2 text-left hover:bg-cc-hover transition-colors cursor-pointer border-b border-cc-border last:border-b-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[10px] font-mono text-indigo-400 shrink-0",children:Y.identifier}),r.jsx("span",{className:"text-xs text-cc-fg truncate",children:Y.title})]}),r.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:r.jsx("span",{className:"text-[10px] text-cc-muted",children:Y.state.name})})]},Y.id))})]}),j&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-indigo-500/10 border border-indigo-500/20 rounded-lg",children:[r.jsx("span",{className:"text-[10px] font-mono text-indigo-400",children:j.identifier}),r.jsx("span",{className:"text-xs text-cc-fg truncate flex-1",children:j.title}),r.jsx("button",{onClick:()=>{k(null),s==null||s(void 0)},className:"text-cc-muted hover:text-cc-fg transition-colors cursor-pointer shrink-0",children:r.jsx("svg",{viewBox:"0 0 16 16",className:"w-3 h-3",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})})})]})]})}function ev({initialPath:e,onSelect:t,onClose:s}){const[n,a]=w.useState(""),[l,c]=w.useState([]),[d,f]=w.useState(!1),[h,m]=w.useState(""),[g,_]=w.useState(!1),[v]=w.useState(()=>Q0()),y=w.useCallback(async j=>{f(!0);try{const k=await ne.listDirs(j);a(k.path),c(k.dirs)}catch{c([])}finally{f(!1)}},[]);w.useEffect(()=>{y(e||void 0)},[]),w.useEffect(()=>{function j(k){k.key==="Escape"&&!g&&s()}return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[s,g]);function S(j){fC(j),t(j),s()}return Z0.createPortal(r.jsx("div",{className:"fixed inset-0 z-50 flex items-end sm:items-center justify-center bg-black/50",onClick:s,children:r.jsxs("div",{className:"w-full max-w-lg h-[min(480px,90dvh)] mx-0 sm:mx-4 flex flex-col bg-cc-bg border border-cc-border rounded-t-xl sm:rounded-xl shadow-2xl overflow-hidden",onClick:j=>j.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-5 py-3 sm:py-4 border-b border-cc-border shrink-0",children:[r.jsx("h2",{className:"text-sm font-semibold text-cc-fg",children:"Select Folder"}),r.jsx("button",{onClick:s,className:"w-6 h-6 flex items-center justify-center rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})})})]}),v.length>0&&r.jsxs("div",{className:"border-b border-cc-border shrink-0",children:[r.jsx("div",{className:"px-4 pt-2.5 pb-1 text-[10px] text-cc-muted uppercase tracking-wider",children:"Recent"}),v.map(j=>r.jsxs("button",{onClick:()=>S(j),className:"w-full px-4 py-2 sm:py-1.5 text-xs text-left hover:bg-cc-hover transition-colors cursor-pointer flex items-center gap-2 text-cc-fg",children:[r.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 opacity-30 shrink-0",children:[r.jsx("path",{d:"M8 3.5a.5.5 0 00-1 0V8a.5.5 0 00.252.434l3.5 2a.5.5 0 00.496-.868L8 7.71V3.5z"}),r.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 108 0a8 8 0 000 16zm7-8A7 7 0 111 8a7 7 0 0114 0z"})]}),r.jsx("span",{className:"font-medium truncate",children:j.split("/").pop()||j}),r.jsx("span",{className:"text-cc-muted font-mono-code text-[10px] truncate ml-auto",children:j})]},j))]}),r.jsx("div",{className:"px-4 py-2.5 border-b border-cc-border flex items-center gap-2 shrink-0",children:g?r.jsx("input",{type:"text",value:h,onChange:j=>m(j.target.value),onKeyDown:j=>{j.key==="Enter"&&h.trim()&&S(h.trim()),j.key==="Escape"&&(j.stopPropagation(),_(!1))},placeholder:"/path/to/project",className:"flex-1 px-2 py-1 text-base sm:text-xs bg-cc-input-bg border border-cc-border rounded-md text-cc-fg font-mono-code placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/50",autoFocus:!0}):r.jsxs(r.Fragment,{children:[n&&n!=="/"&&r.jsx("button",{onClick:()=>{const j=n.split("/").slice(0,-1).join("/")||"/";y(j)},className:"w-6 h-6 flex items-center justify-center rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer shrink-0",title:"Go to parent directory",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("path",{d:"M8 12l-4-4h2.5V4h3v4H12L8 12z",transform:"rotate(180 8 8)"})})}),r.jsx("span",{className:"text-[11px] text-cc-muted font-mono-code truncate flex-1",children:n}),r.jsx("button",{onClick:()=>{_(!0),m(n)},className:"w-6 h-6 flex items-center justify-center rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer shrink-0",title:"Type path manually",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("path",{d:"M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L3.463 11.098a.25.25 0 00-.064.108l-.563 1.97 1.971-.564a.25.25 0 00.108-.064l8.61-8.61a.25.25 0 000-.354l-1.098-1.097z"})})})]})}),!g&&r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[r.jsxs("button",{onClick:()=>S(n),className:"w-full px-4 py-2 text-xs text-left hover:bg-cc-hover transition-colors cursor-pointer flex items-center gap-2 text-cc-primary font-medium border-b border-cc-border shrink-0",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 shrink-0",children:r.jsx("path",{d:"M12.416 3.376a.75.75 0 01.208 1.04l-5 7.5a.75.75 0 01-1.154.114l-3-3a.75.75 0 011.06-1.06l2.353 2.353 4.493-6.74a.75.75 0 011.04-.207z"})}),r.jsxs("span",{className:"truncate font-mono-code",children:["Select: ",n.split("/").pop()||"/"]})]}),r.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d?r.jsx("div",{className:"px-4 py-6 text-xs text-cc-muted text-center",children:"Loading..."}):l.length===0?r.jsx("div",{className:"px-4 py-6 text-xs text-cc-muted text-center",children:"No subdirectories"}):l.map(j=>r.jsxs("div",{className:"flex items-center hover:bg-cc-hover transition-colors",children:[r.jsxs("button",{onClick:()=>y(j.path),onDoubleClick:()=>S(j.path),className:"flex-1 min-w-0 px-4 py-2 sm:py-1.5 text-xs text-left cursor-pointer font-mono-code flex items-center gap-2 text-cc-fg",title:j.path,children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 opacity-40 shrink-0",children:r.jsx("path",{d:"M1 3.5A1.5 1.5 0 012.5 2h3.379a1.5 1.5 0 011.06.44l.622.621a.5.5 0 00.353.146H13.5A1.5 1.5 0 0115 4.707V12.5a1.5 1.5 0 01-1.5 1.5h-11A1.5 1.5 0 011 12.5v-9z"})}),r.jsx("span",{className:"truncate",children:j.name}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 opacity-30 shrink-0 ml-auto",children:r.jsx("path",{d:"M6 4l4 4-4 4"})})]}),r.jsx("button",{onClick:()=>S(j.path),className:"shrink-0 w-8 h-8 sm:w-6 sm:h-6 mr-2 flex items-center justify-center rounded-md text-cc-muted hover:text-cc-primary hover:bg-cc-primary/10 transition-colors cursor-pointer",title:`Select ${j.name}`,children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("path",{d:"M12.416 3.376a.75.75 0 01.208 1.04l-5 7.5a.75.75 0 01-1.154.114l-3-3a.75.75 0 011.06-1.06l2.353 2.353 4.493-6.74a.75.75 0 011.04-.207z"})})})]},j.path))})]})]})}),document.body)}const YB={checking_image:"Checking image",pulling_image:"Pulling image",creating_container:"Creating container",seeding_auth:"Seeding authentication",launching_agent:"Launching agent"},L5=["checking_image","pulling_image","creating_container","seeding_auth","launching_agent"];function XB({onRetry:e,onCancel:t}){const s=G(c=>c.sessionCreating),n=G(c=>c.creationProgress),a=G(c=>c.creationError);if(!s&&!a)return null;const l=n?L5.indexOf(n.step):-1;return r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:r.jsx("div",{className:"mx-4 w-full max-w-md rounded-xl border border-neutral-200 bg-white p-6 shadow-2xl dark:border-neutral-700 dark:bg-neutral-900",children:a?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"mb-4 flex items-center gap-2 text-red-600 dark:text-red-400",children:[r.jsx("svg",{className:"h-5 w-5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),r.jsx("h3",{className:"text-lg font-semibold",children:"Container Launch Failed"})]}),r.jsx("p",{className:"mb-4 text-sm text-neutral-600 dark:text-neutral-400",children:a}),r.jsxs("div",{className:"flex gap-2",children:[e&&r.jsx("button",{onClick:e,className:"flex-1 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700",children:"Retry"}),t&&r.jsx("button",{onClick:t,className:"flex-1 rounded-lg border border-neutral-300 px-4 py-2 text-sm font-medium text-neutral-700 hover:bg-neutral-100 dark:border-neutral-600 dark:text-neutral-300 dark:hover:bg-neutral-800",children:"Cancel"})]})]}):r.jsxs(r.Fragment,{children:[r.jsx("h3",{className:"mb-4 text-lg font-semibold text-neutral-900 dark:text-neutral-100",children:"Launching Container Session"}),r.jsx("div",{className:"mb-4 space-y-2",children:L5.map((c,d)=>{const f=d===l,h=d<l,m=d>l;return r.jsxs("div",{className:`flex items-center gap-2 text-sm ${f?"font-medium text-blue-600 dark:text-blue-400":h?"text-green-600 dark:text-green-400":"text-neutral-400 dark:text-neutral-600"}`,children:[h?r.jsx("svg",{className:"h-4 w-4 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):f?r.jsxs("svg",{className:"h-4 w-4 flex-shrink-0 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):r.jsx("div",{className:`h-4 w-4 flex-shrink-0 rounded-full border ${m?"border-neutral-300 dark:border-neutral-600":""}`}),r.jsx("span",{children:YB[c]||c})]},c)})}),(n==null?void 0:n.step)==="pulling_image"&&n.percent!=null&&r.jsxs("div",{className:"mb-3",children:[r.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-neutral-200 dark:bg-neutral-700",children:r.jsx("div",{className:"h-full rounded-full bg-blue-600 transition-all duration-300",style:{width:`${Math.min(n.percent,100)}%`}})}),r.jsxs("p",{className:"mt-1 text-xs text-neutral-500",children:[n.percent,"%"]})]}),(n==null?void 0:n.message)&&r.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400 truncate",children:n.message})]})})})}function B5(e){return new Promise((t,s)=>{const n=new FileReader;n.onload=()=>{const l=n.result.split(",")[1];t({base64:l,mediaType:e.type})},n.onerror=s,n.readAsDataURL(e)})}let JB=0;function QB(e,t){return e?t?"bg-cc-card text-cc-fg font-semibold shadow-md cursor-pointer":"text-cc-muted hover:text-cc-fg cursor-pointer":"text-cc-muted/40 cursor-not-allowed"}function ZB(){const[e,t]=w.useState(""),[s,n]=w.useState(()=>localStorage.getItem("cc-backend")||"claude"),[a,l]=w.useState([]),[c,d]=w.useState(()=>si(localStorage.getItem("cc-backend")||"claude")),[f,h]=w.useState(()=>Jc(localStorage.getItem("cc-backend")||"claude")),[m,g]=w.useState(()=>Q0()[0]||""),[_,v]=w.useState([]),[y,S]=w.useState(!1),[j,k]=w.useState(""),[N,E]=w.useState(()=>localStorage.getItem("cc-codex-internet-access")==="1"),[B,F]=w.useState(()=>localStorage.getItem("cc-codex-reasoning-effort")||"medium"),$=Yh(s),K=Sx(s),[Y,W]=w.useState([]),[L,Q]=w.useState(()=>localStorage.getItem("cc-selected-env")||""),[V,X]=w.useState(!1),q=w.useRef(null),[A,M]=w.useState(!1),[O,U]=w.useState(!1),[I,R]=w.useState(null),[P,z]=w.useState(!1),[T,oe]=w.useState(""),[be,re]=w.useState([]),[ve,Te]=w.useState(!1),[Re,je]=w.useState(""),[Ye,Xe]=w.useState(!1),[Pe,ye]=w.useState(null),[Ze,ft]=w.useState(!1),[mt,ts]=w.useState(""),Kt=w.useRef(null),[Ft,Rt]=w.useState(!1),[Hs,gs]=w.useState(0),[vt,rr]=w.useState([]),de=w.useRef(!1);w.useEffect(()=>{de.current||(de.current=!0,ne.getSlashCommands().then(ce=>{ce.commands.length>0&&rr(ce.commands)}).catch(()=>{}))},[]);const _e=w.useMemo(()=>{if(!Ft)return[];const ce=e.match(/^\/(\S*)$/);if(!ce)return[];const $e=ce[1].toLowerCase();return $e===""?vt:vt.filter(wt=>wt.toLowerCase().includes($e))},[e,Ft,vt]),Be=w.useRef(null),qe=G(ce=>ce.setCurrentSession),Je=G(ce=>ce.currentSessionId);w.useEffect(()=>{var $e;globalThis.matchMedia("(min-width: 640px)").matches&&(($e=Kt.current)==null||$e.focus())},[]),w.useEffect(()=>{ne.getHome().then(({home:ce,cwd:$e})=>{m||g($e||ce)}).catch(()=>{}),ne.listEnvs().then(W).catch(()=>{}),ne.getBackends().then(l).catch(()=>{})},[]);function Yt(ce){n(ce),localStorage.setItem("cc-backend",ce),d(si(ce)),h(Jc(ce))}w.useEffect(()=>{function ce($e){Be.current&&!Be.current.contains($e.target)&&Te(!1)}return document.addEventListener("pointerdown",ce),()=>document.removeEventListener("pointerdown",ce)},[]),w.useEffect(()=>{if(!m){R(null);return}ne.getRepoInfo(m).then(ce=>{R(ce),z(!1),oe(ce.currentBranch),Xe(!1),ne.listBranches(ce.repoRoot).then(re).catch(()=>re([]))}).catch(()=>{R(null)})},[m]),w.useEffect(()=>{I&&ne.listBranches(I.repoRoot).then(re).catch(()=>re([]))},[I]);const xs=m?m.split("/").pop()||m:"Select folder";async function se(ce){const $e=ce.target.files;if(!$e)return;const wt=[];for(const Xt of Array.from($e)){if(!Xt.type.startsWith("image/"))continue;const{base64:Ot,mediaType:pt}=await B5(Xt);wt.push({name:Xt.name,base64:Ot,mediaType:pt})}v(Xt=>[...Xt,...wt]),ce.target.value=""}function fe(ce){v($e=>$e.filter((wt,Xt)=>Xt!==ce))}async function H(ce){var Xt;const $e=(Xt=ce.clipboardData)==null?void 0:Xt.items;if(!$e)return;const wt=[];for(const Ot of Array.from($e)){if(!Ot.type.startsWith("image/"))continue;const pt=Ot.getAsFile();if(!pt)continue;const{base64:Oa,mediaType:ar}=await B5(pt);wt.push({name:`pasted-${Date.now()}.${pt.type.split("/")[1]}`,base64:Oa,mediaType:ar})}wt.length>0&&(ce.preventDefault(),v(Ot=>[...Ot,...wt]))}function ee(ce){const $e=ce.target.value;t($e);const wt=ce.target;wt.style.height="auto",wt.style.height=Math.min(wt.scrollHeight,300)+"px",Rt($e.match(/^\/\S*$/)!==null),gs(0)}function Ie(ce){var $e;t(`/${ce} `),Rt(!1),($e=Kt.current)==null||$e.focus()}function We(ce){if(Ft&&_e.length>0){if(ce.key==="ArrowDown"){ce.preventDefault(),gs($e=>Math.min($e+1,_e.length-1));return}if(ce.key==="ArrowUp"){ce.preventDefault(),gs($e=>Math.max($e-1,0));return}if(ce.key==="Enter"||ce.key==="Tab"){ce.preventDefault(),Ie(_e[Hs]);return}if(ce.key==="Escape"){ce.preventDefault(),Rt(!1);return}}if(ce.key==="Tab"&&ce.shiftKey){ce.preventDefault();const $e=Sx(s),Xt=($e.findIndex(Ot=>Ot.value===f)+1)%$e.length;h($e[Xt].value);return}ce.key==="Enter"&&!ce.shiftKey&&(ce.preventDefault(),Bt())}async function Bt(){const ce=e.trim();if(!(!ce||y)){if(S(!0),k(""),ts(""),I){const $e=P?T:I.currentBranch;if($e&&$e===I.currentBranch){const wt=be.find(Xt=>Xt.name===$e&&!Xt.isRemote);if(wt&&wt.behind>0){ye({behind:wt.behind,branchName:$e});return}}}await ss(ce)}}async function ss(ce){if(!ce){S(!1);return}try{Je&&qo(Je);const $e=T.trim()||void 0,wt={...s==="codex"?{}:{model:c},permissionMode:f,cwd:m||void 0,envSlug:L||void 0,branch:$e,createBranch:$e&&Ye?!0:void 0,useWorktree:P||void 0,backend:s,codexInternetAccess:s==="codex"?N:void 0,codexReasoningEffort:s==="codex"?B:void 0},Ot=(await ne.createSession(wt)).sessionId,pt=new Set(G.getState().sessionNames.values()),Oa=Rj(pt);G.getState().setSessionName(Ot,Oa),m&&fC(m),G.getState().setPreviousPermissionMode(Ot,f),qe(Ot),Sr(Ot),await Pj(Ot),en(Ot,{type:"user_message",content:ce,session_id:Ot,images:_.length>0?_.map(ar=>({media_type:ar.mediaType,data:ar.base64})):void 0}),G.getState().appendMessage(Ot,{id:`user-${Date.now()}-${++JB}`,role:"user",content:ce,images:_.length>0?_.map(ar=>({media_type:ar.mediaType,data:ar.base64})):void 0,timestamp:Date.now()})}catch($e){k($e instanceof Error?$e.message:"Unknown error"),S(!1)}}async function ir(){if(Pe){ft(!0),ts("");try{const ce=m||(I==null?void 0:I.repoRoot);if(!ce)throw new Error("No working directory");const $e=await ne.gitPull(ce);if(!$e.success){ts($e.output||"Pull failed"),ft(!1),S(!1);return}I&&ne.listBranches(I.repoRoot).then(re).catch(()=>{}),ye(null),ft(!1),await ss(e.trim())}catch(ce){ts(ce instanceof Error?ce.message:"Unknown error"),ft(!1)}}}function oi(){const ce=e.trim();ye(null),ts(""),ss(ce)}function Cr(){ye(null),ts(""),S(!1)}const Qi=e.trim().length>0&&!y;return r.jsxs("div",{className:"flex-1 h-full flex items-start justify-center px-3 sm:px-4 pt-[12vh] sm:pt-[18vh] overflow-y-auto",children:[r.jsxs("div",{className:"w-full max-w-xl",children:[r.jsx("img",{src:"/icon-512.png",alt:"Campfire",className:"w-20 h-20 sm:w-24 sm:h-24 mx-auto mb-5 rounded-[22px] shadow-lg"}),r.jsx("h1",{className:"text-2xl sm:text-3xl font-light text-cc-fg text-center",children:"What are you working on?"}),r.jsx("p",{className:"text-sm text-cc-muted/60 text-center mt-2 mb-6",children:"Describe your task and choose a backend to get started"}),I&&r.jsx("div",{className:"mb-4",children:r.jsx(KB,{cwd:m,repoRoot:I.repoRoot,onBranchFromIssue:ce=>{oe(ce),Xe(!0),z(!0)}})}),r.jsxs("div",{className:"bg-cc-card rounded-2xl border border-cc-border/50 shadow-lg transition-all duration-300 focus-within:shadow-xl focus-within:border-cc-border",children:[_.length>0&&r.jsx("div",{className:"flex items-center gap-2 px-4 pt-3 flex-wrap",children:_.map((ce,$e)=>r.jsxs("div",{className:"relative group",children:[r.jsx("img",{src:`data:${ce.mediaType};base64,${ce.base64}`,alt:ce.name,className:"w-14 h-14 rounded-xl object-cover border border-cc-border shadow-sm"}),r.jsx("button",{onClick:()=>fe($e),"aria-label":`Remove ${ce.name}`,className:"absolute -top-1.5 -right-1.5 w-4 h-4 rounded-full bg-cc-error text-white flex items-center justify-center text-[10px] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-2.5 h-2.5",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})})]},ce.name))}),r.jsx("input",{ref:q,type:"file",accept:"image/*",multiple:!0,onChange:se,className:"hidden","aria-label":"Upload images"}),Ft&&_e.length>0&&r.jsx("ul",{className:"mx-4 mb-1 max-h-48 overflow-y-auto rounded-xl border border-cc-border bg-cc-card shadow-float py-1 list-none m-0 p-0 py-1","aria-label":"Slash commands",children:_e.map((ce,$e)=>r.jsx("li",{children:r.jsxs("button",{onMouseDown:wt=>{wt.preventDefault(),Ie(ce)},"aria-pressed":$e===Hs,className:`w-full text-left px-3 py-1.5 text-[13px] font-mono-code cursor-pointer transition-colors ${$e===Hs?"bg-cc-primary/10 text-cc-primary":"text-cc-fg hover:bg-cc-hover"}`,children:["/",ce]})},ce))}),r.jsx("textarea",{ref:Kt,value:e,onChange:ee,onKeyDown:We,onPaste:H,placeholder:"Attach files or start a conversation...",rows:3,"aria-label":"Task description",className:"w-full px-5 pt-5 pb-3 text-[15px] bg-transparent resize-none focus:outline-none text-cc-fg placeholder:text-cc-muted/70",style:{minHeight:"96px",maxHeight:"300px"}}),r.jsxs("div",{className:"flex flex-col gap-3 px-4 pb-4",children:[a.length>1&&r.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-none bg-cc-hover/40 rounded-xl p-1",role:"radiogroup","aria-label":"Backend",children:a.map(ce=>r.jsx("button",{onClick:()=>ce.available&&Yt(ce.id),disabled:!ce.available,role:"radio","aria-checked":s===ce.id,title:ce.available?ce.name:`${ce.name} CLI not found in PATH`,className:`px-3 py-1.5 text-[12px] rounded-lg transition-colors whitespace-nowrap shrink-0 ${QB(ce.available,s===ce.id)}`,children:ce.name},ce.id))}),r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsxs("button",{onClick:()=>M(!A),"aria-expanded":A,"aria-controls":"options-panel",className:`flex items-center gap-1 px-3 py-2 text-[12px] rounded-xl transition-colors cursor-pointer ${A?"text-cc-fg bg-cc-hover":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:[r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:[r.jsx("path",{d:"M8 4v8M4 8h8",strokeLinecap:"round",style:{display:A?"none":"block"}}),r.jsx("path",{d:"M4 8h8",strokeLinecap:"round",style:{display:A?"block":"none"}})]}),"Options"]}),r.jsx("button",{onClick:()=>{var ce;return(ce=q.current)==null?void 0:ce.click()},"aria-label":"Upload image",className:"flex items-center justify-center w-9 h-9 rounded-xl text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-4 h-4",children:[r.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),r.jsx("circle",{cx:"5.5",cy:"5.5",r:"1",fill:"currentColor",stroke:"none"}),r.jsx("path",{d:"M2 11l3-3 2 2 3-4 4 5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r.jsx("button",{onClick:Bt,disabled:!Qi,"aria-label":"Send message",className:`flex items-center justify-center w-10 h-10 rounded-full shadow-md hover:shadow-lg transition-all ${Qi?"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed shadow-none"}`,children:y?r.jsx("span",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4",children:r.jsx("path",{d:"M8 2.5a.75.75 0 01.75.75v7.69l2.72-2.72a.75.75 0 111.06 1.06l-4 4a.75.75 0 01-1.06 0l-4-4a.75.75 0 111.06-1.06l2.72 2.72V3.25A.75.75 0 018 2.5z",transform:"rotate(180 8 8)"})})})]})]})]}),A&&r.jsx("div",{id:"options-panel",className:"mt-4 p-4 bg-cc-card rounded-2xl border border-cc-border/50 shadow-sm",children:r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[s==="codex"?r.jsxs("div",{children:[r.jsx("div",{className:"block text-[10px] font-semibold text-cc-muted/60 uppercase tracking-wider mb-1.5",children:"Model"}),r.jsx("div",{className:"w-full px-3 py-2 text-[12px] bg-cc-bg border border-cc-border rounded-xl text-cc-muted",children:"Codex default"})]}):r.jsxs("div",{children:[r.jsx("label",{className:"block text-[10px] font-semibold text-cc-muted/60 uppercase tracking-wider mb-1.5",htmlFor:"model-select",children:"Model"}),r.jsx("select",{id:"model-select",value:c,onChange:ce=>d(ce.target.value),className:"w-full px-3 py-2 text-[12px] bg-cc-bg border border-cc-border rounded-xl text-cc-fg focus:outline-none focus:border-cc-primary/50 cursor-pointer",children:$.map(ce=>r.jsx("option",{value:ce.value,children:ce.label},ce.value))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[10px] font-semibold text-cc-muted/60 uppercase tracking-wider mb-1.5",htmlFor:"mode-select",children:"Permission mode"}),r.jsx("select",{id:"mode-select",value:f,onChange:ce=>h(ce.target.value),className:"w-full px-3 py-2 text-[12px] bg-cc-bg border border-cc-border rounded-xl text-cc-fg focus:outline-none focus:border-cc-primary/50 cursor-pointer",children:K.map(ce=>r.jsx("option",{value:ce.value,children:ce.label},ce.value))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[10px] font-semibold text-cc-muted/60 uppercase tracking-wider mb-1.5",htmlFor:"env-select",children:"Environment"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsxs("select",{id:"env-select",value:L,onChange:ce=>{Q(ce.target.value),localStorage.setItem("cc-selected-env",ce.target.value)},onFocus:()=>{ne.listEnvs().then(W).catch(()=>{})},className:"flex-1 min-w-0 px-3 py-2 text-[12px] bg-cc-bg border border-cc-border rounded-xl text-cc-fg focus:outline-none focus:border-cc-primary/50 cursor-pointer",children:[r.jsx("option",{value:"",children:"No environment"}),Y.map(ce=>r.jsxs("option",{value:ce.slug,children:[ce.name," (",Object.keys(ce.variables).length," vars)"]},ce.slug))]}),r.jsx("button",{onClick:()=>X(!0),"aria-label":"Manage environments",className:"px-3 py-2 text-[12px] text-cc-muted hover:text-cc-fg bg-cc-bg border border-cc-border rounded-xl hover:bg-cc-hover transition-colors cursor-pointer shrink-0",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:[r.jsx("path",{d:"M8 4.754a3.246 3.246 0 100 6.492 3.246 3.246 0 000-6.492zM5.754 8a2.246 2.246 0 114.492 0 2.246 2.246 0 01-4.492 0z"}),r.jsx("path",{d:"M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0a1.843 1.843 0 01-2.739 1.049c-1.547-.966-3.317.803-2.35 2.35a1.843 1.843 0 01-1.049 2.74c-1.79.526-1.79 3.064 0 3.59a1.843 1.843 0 011.049 2.74c-.966 1.547.803 3.317 2.35 2.35a1.843 1.843 0 012.74 1.049c.526 1.79 3.064 1.79 3.59 0a1.843 1.843 0 012.74-1.049c1.547.966 3.317-.803 2.35-2.35a1.843 1.843 0 011.049-2.74c1.79-.526 1.79-3.064 0-3.59a1.843 1.843 0 01-1.049-2.74c.966-1.547-.803-3.317-2.35-2.35a1.843 1.843 0 01-2.74-1.049zM8 4.754a3.246 3.246 0 100 6.492 3.246 3.246 0 000-6.492z"})]})})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[10px] font-semibold text-cc-muted/60 uppercase tracking-wider mb-1.5",htmlFor:"cwd-picker",children:"Working directory"}),r.jsxs("button",{id:"cwd-picker",onClick:()=>U(!0),className:"w-full flex items-center gap-1.5 px-3 py-2 text-[12px] bg-cc-bg border border-cc-border rounded-xl text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer text-left",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-muted shrink-0",children:r.jsx("path",{d:"M1 3.5A1.5 1.5 0 012.5 2h3.379a1.5 1.5 0 011.06.44l.622.621a.5.5 0 00.353.146H13.5A1.5 1.5 0 0115 4.707V12.5a1.5 1.5 0 01-1.5 1.5h-11A1.5 1.5 0 011 12.5v-9z"})}),r.jsx("span",{className:"truncate font-mono-code",children:xs})]}),O&&r.jsx(ev,{initialPath:m||"",onSelect:ce=>{g(ce)},onClose:()=>U(!1)})]}),I&&r.jsxs("div",{className:"relative",ref:Be,children:[r.jsx("label",{className:"block text-[10px] font-semibold text-cc-muted/60 uppercase tracking-wider mb-1.5",htmlFor:"branch-picker",children:"Branch"}),r.jsxs("button",{id:"branch-picker",onClick:()=>{!ve&&I&&ne.gitFetch(I.repoRoot).catch(()=>{}).finally(()=>{ne.listBranches(I.repoRoot).then(re).catch(()=>re([]))}),Te(!ve),je("")},className:"w-full flex items-center gap-1.5 px-3 py-2 text-[12px] bg-cc-bg border border-cc-border rounded-xl text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer text-left",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-muted shrink-0",children:r.jsx("path",{d:"M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.378A2.5 2.5 0 007.5 8h1a1 1 0 010 2h-1A2.5 2.5 0 005 12.5v.128a2.25 2.25 0 101.5 0V12.5a1 1 0 011-1h1a2.5 2.5 0 000-5h-1a1 1 0 01-1-1V5.372zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5z"})}),r.jsx("span",{className:"truncate font-mono-code",children:T||I.currentBranch})]}),ve&&r.jsxs("div",{className:"absolute left-0 top-full mt-1 w-72 max-w-[calc(100vw-2rem)] bg-cc-card border border-cc-border rounded-2xl shadow-xl z-10 overflow-hidden",children:[r.jsx("div",{className:"px-2 py-2 border-b border-cc-border",children:r.jsx("input",{type:"text",value:Re,onChange:ce=>je(ce.target.value),placeholder:"Filter or create branch...",className:"w-full px-2 py-1 text-base sm:text-xs bg-cc-input-bg border border-cc-border rounded-md text-cc-fg font-mono-code placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/50",autoFocus:!0,onKeyDown:ce=>{ce.key==="Escape"&&Te(!1)}})}),r.jsx("div",{className:"max-h-[240px] overflow-y-auto py-1",children:(()=>{const ce=Re.toLowerCase().trim(),$e=be.filter(pt=>!pt.isRemote&&(!ce||pt.name.toLowerCase().includes(ce))),wt=be.filter(pt=>pt.isRemote&&(!ce||pt.name.toLowerCase().includes(ce))),Xt=be.some(pt=>pt.name.toLowerCase()===ce),Ot=$e.length>0||wt.length>0;return r.jsxs(r.Fragment,{children:[$e.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-3 py-1 text-[10px] text-cc-muted uppercase tracking-wider",children:"Local"}),$e.map(pt=>r.jsxs("button",{onClick:()=>{oe(pt.name),Xe(!1),Te(!1)},className:`w-full px-3 py-1.5 text-xs text-left hover:bg-cc-hover transition-colors cursor-pointer flex items-center gap-2 ${pt.name===T?"text-cc-primary font-medium":"text-cc-fg"}`,children:[r.jsx("span",{className:"truncate font-mono-code",children:pt.name}),r.jsxs("span",{className:"ml-auto flex items-center gap-1.5 shrink-0",children:[pt.ahead>0&&r.jsxs("span",{className:"text-[9px] text-green-500",children:[pt.ahead,"↑"]}),pt.behind>0&&r.jsxs("span",{className:"text-[9px] text-amber-500",children:[pt.behind,"↓"]}),pt.isCurrent&&r.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-green-500/15 text-green-600 dark:text-green-400",children:"current"}),pt.worktreePath&&r.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/15 text-blue-600 dark:text-blue-400",children:"wt"})]})]},pt.name))]}),wt.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-3 py-1 text-[10px] text-cc-muted uppercase tracking-wider mt-1",children:"Remote"}),wt.map(pt=>r.jsxs("button",{onClick:()=>{oe(pt.name),Xe(!1),Te(!1)},className:`w-full px-3 py-1.5 text-xs text-left hover:bg-cc-hover transition-colors cursor-pointer flex items-center gap-2 ${pt.name===T?"text-cc-primary font-medium":"text-cc-fg"}`,children:[r.jsx("span",{className:"truncate font-mono-code",children:pt.name}),r.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-cc-hover text-cc-muted ml-auto shrink-0",children:"remote"})]},`remote-${pt.name}`))]}),!Ot&&ce&&r.jsx("div",{className:"px-3 py-2 text-xs text-cc-muted text-center",children:"No matching branches"}),ce&&!Xt&&r.jsx("div",{className:"border-t border-cc-border mt-1 pt-1",children:r.jsxs("button",{onClick:()=>{oe(Re.trim()),Xe(!0),Te(!1)},className:"w-full px-3 py-1.5 text-xs text-left hover:bg-cc-hover transition-colors cursor-pointer flex items-center gap-2 text-cc-primary",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 shrink-0",children:r.jsx("path",{d:"M8 2a.75.75 0 01.75.75v4.5h4.5a.75.75 0 010 1.5h-4.5v4.5a.75.75 0 01-1.5 0v-4.5h-4.5a.75.75 0 010-1.5h4.5v-4.5A.75.75 0 018 2z"})}),r.jsxs("span",{children:["Create ",r.jsx("span",{className:"font-mono-code font-medium",children:Re.trim()})]})]})})]})})()})]})]}),I&&r.jsxs("div",{children:[r.jsx("label",{className:"block text-[10px] font-semibold text-cc-muted/60 uppercase tracking-wider mb-1.5",htmlFor:"worktree-toggle",children:"Worktree"}),r.jsxs("button",{id:"worktree-toggle",onClick:()=>z(!P),className:`w-full flex items-center gap-1.5 px-3 py-2 text-[12px] rounded-xl border transition-colors cursor-pointer ${P?"bg-cc-primary/10 border-cc-primary/30 text-cc-primary font-medium":"bg-cc-bg border-cc-border text-cc-fg hover:bg-cc-hover"}`,title:"Create an isolated worktree for this session",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 shrink-0 opacity-70",children:r.jsx("path",{d:"M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v5.256a2.25 2.25 0 101.5 0V5.372zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5zm7.5-9.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122V7A2.5 2.5 0 0110 9.5H6a1 1 0 000 2h4a2.5 2.5 0 012.5 2.5v.628a2.25 2.25 0 11-1.5 0V14a1 1 0 00-1-1H6a2.5 2.5 0 01-2.5-2.5V10a2.5 2.5 0 012.5-2.5h4a1 1 0 001-1V5.372a2.25 2.25 0 01-1.5-2.122z"})}),P?"Enabled":"Disabled"]})]}),s==="codex"&&r.jsxs("div",{children:[r.jsx("label",{className:"block text-[10px] font-semibold text-cc-muted/60 uppercase tracking-wider mb-1.5",htmlFor:"internet-toggle",children:"Internet access"}),r.jsxs("button",{id:"internet-toggle",onClick:()=>{const ce=!N;E(ce),localStorage.setItem("cc-codex-internet-access",ce?"1":"0")},className:`w-full flex items-center gap-1.5 px-3 py-2 text-[12px] rounded-xl border transition-colors cursor-pointer ${N?"bg-cc-primary/10 border-cc-primary/30 text-cc-primary font-medium":"bg-cc-bg border-cc-border text-cc-fg hover:bg-cc-hover"}`,title:"Allow Codex internet/network access for this session",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 shrink-0 opacity-70",children:r.jsx("path",{d:"M8 2a6 6 0 100 12A6 6 0 008 2zm0 1.5c.8 0 1.55.22 2.2.61-.39.54-.72 1.21-.95 1.98H6.75c-.23-.77-.56-1.44-.95-1.98A4.47 4.47 0 018 3.5zm-3.2 1.3c.3.4.57.86.78 1.37H3.83c.24-.53.57-1.01.97-1.37zm-.97 2.87h2.15c.07.44.12.9.12 1.38 0 .48-.05.94-.12 1.38H3.83A4.56 4.56 0 013.5 9c0-.47.12-.92.33-1.33zm2.03 4.08c.39-.54.72-1.21.95-1.98h2.38c.23.77.56 1.44.95 1.98A4.47 4.47 0 018 12.5c-.8 0-1.55-.22-2.2-.61zm4.34-1.37c.07-.44.12-.9.12-1.38 0-.48-.05-.94-.12-1.38h2.15c.21.41.33.86.33 1.33 0 .47-.12.92-.33 1.33H10.2zm1.37-3.58h-1.75c-.21-.51-.48-.97-.78-1.37.4.36.73.84.97 1.37z"})}),N?"Enabled":"Disabled"]})]}),s==="codex"&&r.jsxs("div",{children:[r.jsx("label",{className:"block text-[10px] font-semibold text-cc-muted/60 uppercase tracking-wider mb-1.5",htmlFor:"reasoning-effort",children:"Reasoning effort"}),r.jsx("div",{id:"reasoning-effort",className:"flex rounded-lg border border-cc-border overflow-hidden",children:["low","medium","high"].map(ce=>r.jsx("button",{onClick:()=>{F(ce),localStorage.setItem("cc-codex-reasoning-effort",ce)},className:`flex-1 px-2 py-1.5 text-[11px] transition-colors cursor-pointer ${B===ce?"bg-cc-primary/15 text-cc-primary font-medium":"bg-cc-bg text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:ce.charAt(0).toUpperCase()+ce.slice(1)},ce))})]})]})}),Pe&&r.jsx("div",{className:"mt-3 p-3 rounded-2xl bg-amber-500/10 border border-amber-500/20",children:r.jsxs("div",{className:"flex items-start gap-2.5",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-amber-500 shrink-0 mt-0.5",children:r.jsx("path",{d:"M8.982 1.566a1.13 1.13 0 00-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 01-1.1 0L7.1 5.995A.905.905 0 018 5zm.002 6a1 1 0 110 2 1 1 0 010-2z"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("p",{className:"text-xs text-cc-fg leading-snug",children:[r.jsx("span",{className:"font-mono-code font-medium",children:Pe.branchName})," is"," ",r.jsxs("span",{className:"font-semibold text-amber-500",children:[Pe.behind," commit",Pe.behind===1?"":"s"," behind"]})," ","remote. Pull before starting?"]}),mt&&r.jsx("div",{className:"mt-2 px-2 py-1.5 rounded-md bg-cc-error/10 border border-cc-error/20 text-[11px] text-cc-error font-mono-code whitespace-pre-wrap",children:mt}),r.jsxs("div",{className:"flex gap-2 mt-2.5",children:[r.jsx("button",{onClick:Cr,disabled:Ze,className:"px-3 py-1.5 text-[11px] font-medium rounded-lg bg-cc-hover text-cc-muted hover:text-cc-fg transition-colors cursor-pointer",children:"Cancel"}),r.jsx("button",{onClick:oi,disabled:Ze,className:"px-3 py-1.5 text-[11px] font-medium rounded-lg bg-cc-hover text-cc-muted hover:text-cc-fg transition-colors cursor-pointer",children:"Continue anyway"}),r.jsx("button",{onClick:ir,disabled:Ze,className:"px-3 py-1.5 text-[11px] font-medium rounded-lg bg-cc-primary/15 text-cc-primary hover:bg-cc-primary/25 transition-colors cursor-pointer flex items-center gap-1.5",children:Ze?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"w-3 h-3 border-2 border-cc-primary/30 border-t-cc-primary rounded-full animate-spin"})," ","Pulling..."]}):"Pull and continue"})]})]})]})}),j&&r.jsxs("div",{className:"mt-3 flex items-center gap-2 px-3 py-2 rounded-2xl bg-cc-error/5 border border-cc-error/20",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-error shrink-0",children:r.jsx("path",{fillRule:"evenodd",d:"M8 15A7 7 0 108 1a7 7 0 000 14zm1-3a1 1 0 11-2 0 1 1 0 012 0zM7.5 5.5a.5.5 0 011 0v3a.5.5 0 01-1 0v-3z",clipRule:"evenodd"})}),r.jsx("p",{className:"text-xs text-cc-error",children:j})]})]}),V&&r.jsx(pC,{onClose:()=>{X(!1),ne.listEnvs().then(W).catch(()=>{})}}),r.jsx(XB,{onRetry:()=>{G.getState().setCreationError(null),G.getState().setSessionCreating(!1),S(!1)},onCancel:()=>{G.getState().setCreationError(null),G.getState().setSessionCreating(!1),S(!1)}})]})}const eO=[],tO=[],sO={connected:{label:"Connected",badge:"text-cc-success bg-cc-success/10",dot:"bg-cc-success"},connecting:{label:"Connecting",badge:"text-cc-warning bg-cc-warning/10",dot:"bg-cc-warning animate-pulse"},failed:{label:"Failed",badge:"text-cc-error bg-cc-error/10",dot:"bg-cc-error"},disabled:{label:"Disabled",badge:"text-cc-muted bg-cc-hover",dot:"bg-cc-muted opacity-40"}},nO={label:"Unknown",badge:"text-cc-muted bg-cc-hover",dot:"bg-cc-muted opacity-40"};function rO({server:e,sessionId:t}){var d,f;const[s,n]=w.useState(!1),a=sO[e.status]||nO,l=e.status!=="disabled",c=((d=e.tools)==null?void 0:d.length)??0;return r.jsxs("div",{className:"rounded-lg border border-cc-border bg-cc-bg",children:[r.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2",children:[r.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${a.dot}`}),r.jsx("button",{onClick:()=>n(!s),className:"flex-1 min-w-0 text-left cursor-pointer",children:r.jsx("span",{className:"text-[12px] font-medium text-cc-fg truncate block",children:e.name})}),r.jsx("span",{className:`text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 ${a.badge}`,children:a.label}),r.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[r.jsx("button",{onClick:()=>$j(t,e.name,!l),className:`w-6 h-6 flex items-center justify-center rounded-md transition-colors cursor-pointer ${l?"text-cc-muted hover:text-cc-fg hover:bg-cc-hover":"text-cc-muted/50 hover:text-cc-success hover:bg-cc-success/10"}`,title:l?"Disable server":"Enable server",children:l?r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3 h-3",children:[r.jsx("circle",{cx:"8",cy:"8",r:"6"}),r.jsx("path",{d:"M5 8h6",strokeLinecap:"round"})]}):r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3 h-3",children:[r.jsx("circle",{cx:"8",cy:"8",r:"6"}),r.jsx("path",{d:"M8 5v6M5 8h6",strokeLinecap:"round"})]})}),(e.status==="failed"||e.status==="connected")&&r.jsx("button",{onClick:()=>Ij(t,e.name),className:"w-6 h-6 flex items-center justify-center rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",title:"Reconnect server",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3 h-3",children:[r.jsx("path",{d:"M2.5 8a5.5 5.5 0 019.78-3.5M13.5 8a5.5 5.5 0 01-9.78 3.5",strokeLinecap:"round"}),r.jsx("path",{d:"M12.5 2v3h-3M3.5 14v-3h3",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),s&&r.jsxs("div",{className:"px-2.5 pb-2.5 space-y-1.5 border-t border-cc-border pt-2",children:[r.jsxs("div",{className:"text-[11px] text-cc-muted space-y-0.5",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"text-cc-muted/60",children:"Type:"}),r.jsx("span",{children:e.config.type})]}),e.config.command&&r.jsxs("div",{className:"flex items-start gap-1",children:[r.jsx("span",{className:"text-cc-muted/60 shrink-0",children:"Cmd:"}),r.jsxs("span",{className:"font-mono text-[10px] break-all",children:[e.config.command,(f=e.config.args)!=null&&f.length?` ${e.config.args.join(" ")}`:""]})]}),e.config.url&&r.jsxs("div",{className:"flex items-start gap-1",children:[r.jsx("span",{className:"text-cc-muted/60 shrink-0",children:"URL:"}),r.jsx("span",{className:"font-mono text-[10px] break-all",children:e.config.url})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"text-cc-muted/60",children:"Scope:"}),r.jsx("span",{children:e.scope})]})]}),e.error&&r.jsx("div",{className:"text-[11px] text-cc-error bg-cc-error/5 rounded px-2 py-1",children:e.error}),c>0&&r.jsxs("div",{className:"space-y-1",children:[r.jsxs("span",{className:"text-[10px] text-cc-muted uppercase tracking-wider",children:["Tools (",c,")"]}),r.jsx("div",{className:"flex flex-wrap gap-1",children:e.tools.map(h=>r.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-cc-hover text-cc-fg",title:h.annotations&&Object.entries(h.annotations).filter(([,m])=>m).map(([m])=>m).join(", ")||void 0,children:h.name},h.name))})]})]})]})}function iO({sessionId:e,onDone:t}){const[s,n]=w.useState(""),[a,l]=w.useState("stdio"),[c,d]=w.useState(""),[f,h]=w.useState(""),[m,g]=w.useState(""),_=s.trim()&&(a==="stdio"?c.trim():m.trim());function v(y){if(y.preventDefault(),!_)return;const S={type:a};a==="stdio"?(S.command=c.trim(),f.trim()&&(S.args=f.trim().split(/\s+/))):S.url=m.trim(),Fj(e,{[s.trim()]:S}),t()}return r.jsxs("form",{onSubmit:v,className:"space-y-2 p-2.5 rounded-lg border border-cc-border bg-cc-bg",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-cc-muted uppercase tracking-wider block mb-0.5",children:"Server Name"}),r.jsx("input",{type:"text",value:s,onChange:y=>n(y.target.value),placeholder:"my-mcp-server",className:"w-full text-[12px] bg-cc-bg-secondary border border-cc-border rounded px-2 py-1.5 text-cc-fg placeholder:text-cc-muted/40 focus:outline-none focus:border-cc-accent"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-cc-muted uppercase tracking-wider block mb-0.5",children:"Type"}),r.jsx("div",{className:"flex gap-1",children:["stdio","sse","http"].map(y=>r.jsx("button",{type:"button",onClick:()=>l(y),className:`text-[11px] px-2 py-1 rounded-md border transition-colors cursor-pointer ${a===y?"border-cc-accent text-cc-accent bg-cc-accent/10":"border-cc-border text-cc-muted hover:text-cc-fg hover:border-cc-muted"}`,children:y},y))})]}),a==="stdio"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-cc-muted uppercase tracking-wider block mb-0.5",children:"Command"}),r.jsx("input",{type:"text",value:c,onChange:y=>d(y.target.value),placeholder:"npx -y @modelcontextprotocol/server-memory",className:"w-full text-[12px] bg-cc-bg-secondary border border-cc-border rounded px-2 py-1.5 text-cc-fg placeholder:text-cc-muted/40 font-mono focus:outline-none focus:border-cc-accent"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-cc-muted uppercase tracking-wider block mb-0.5",children:"Args (space-separated, optional)"}),r.jsx("input",{type:"text",value:f,onChange:y=>h(y.target.value),placeholder:"--port 3000",className:"w-full text-[12px] bg-cc-bg-secondary border border-cc-border rounded px-2 py-1.5 text-cc-fg placeholder:text-cc-muted/40 font-mono focus:outline-none focus:border-cc-accent"})]})]}),(a==="sse"||a==="http")&&r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-cc-muted uppercase tracking-wider block mb-0.5",children:"URL"}),r.jsx("input",{type:"text",value:m,onChange:y=>g(y.target.value),placeholder:"http://localhost:3000/mcp",className:"w-full text-[12px] bg-cc-bg-secondary border border-cc-border rounded px-2 py-1.5 text-cc-fg placeholder:text-cc-muted/40 font-mono focus:outline-none focus:border-cc-accent"})]}),r.jsxs("div",{className:"flex gap-1.5 pt-1",children:[r.jsx("button",{type:"submit",disabled:!_,className:`flex-1 text-[11px] font-medium py-1.5 rounded-md transition-colors ${_?"bg-cc-accent text-white hover:bg-cc-accent/90 cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:"Add Server"}),r.jsx("button",{type:"button",onClick:t,className:"text-[11px] font-medium px-3 py-1.5 rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Cancel"})]})]})}function aO({sessionId:e}){const t=G(d=>d.mcpServers.get(e)||eO),s=G(d=>d.cliConnected.get(e)??!1),[n,a]=w.useState(!1),l=G(d=>{var f;return((f=d.sessions.get(e))==null?void 0:f.mcp_servers)??tO});t.length>0||l.length>0,w.useEffect(()=>{s&&cx(e)},[e,s]);const c=t.length>0?t:l.map(d=>({name:d.name,status:d.status,config:{type:"unknown"},scope:""}));return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"shrink-0 px-4 py-2.5 border-b border-cc-border flex items-center justify-between",children:[r.jsxs("span",{className:"text-[12px] font-semibold text-cc-fg flex items-center gap-1.5",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-muted",children:r.jsx("path",{d:"M1.5 3A1.5 1.5 0 013 1.5h10A1.5 1.5 0 0114.5 3v1A1.5 1.5 0 0113 5.5H3A1.5 1.5 0 011.5 4V3zm0 5A1.5 1.5 0 013 6.5h10A1.5 1.5 0 0114.5 8v1A1.5 1.5 0 0113 10.5H3A1.5 1.5 0 011.5 9V8zm0 5A1.5 1.5 0 013 11.5h10a1.5 1.5 0 011.5 1.5v1a1.5 1.5 0 01-1.5 1.5H3A1.5 1.5 0 011.5 14v-1z"})}),"MCP Servers"]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{onClick:()=>a(!n),disabled:!s,className:`text-[11px] font-medium transition-colors ${s?"text-cc-muted hover:text-cc-fg cursor-pointer":"text-cc-muted/30 cursor-not-allowed"}`,title:"Add MCP server",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M8 3v10M3 8h10",strokeLinecap:"round"})})}),r.jsx("button",{onClick:()=>cx(e),disabled:!s,className:`text-[11px] font-medium transition-colors ${s?"text-cc-muted hover:text-cc-fg cursor-pointer":"text-cc-muted/30 cursor-not-allowed"}`,title:"Refresh MCP server status",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:[r.jsx("path",{d:"M2.5 8a5.5 5.5 0 019.78-3.5M13.5 8a5.5 5.5 0 01-9.78 3.5",strokeLinecap:"round"}),r.jsx("path",{d:"M12.5 2v3h-3M3.5 14v-3h3",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),n&&r.jsx("div",{className:"px-3 py-2 border-b border-cc-border",children:r.jsx(iO,{sessionId:e,onDone:()=>a(!1)})}),c.length>0&&r.jsx("div",{className:"px-3 py-2 space-y-1.5 border-b border-cc-border",children:c.map(d=>r.jsx(rO,{server:d,sessionId:e},d.name))}),!n&&c.length===0&&r.jsx("div",{className:"px-3 py-3 border-b border-cc-border",children:r.jsxs("p",{className:"text-[11px] text-cc-muted text-center",children:["No MCP servers configured."," ",s&&r.jsx("button",{onClick:()=>a(!0),className:"text-cc-accent hover:underline cursor-pointer",children:"Add one"})]})})]})}function O5(e){if(e<=0)return"< 1m";const t=Math.floor(e/6e4);if(t<60)return`${t}m`;const s=Math.floor(t/60),n=t%60;return n>0?`${s}h ${n}m`:`${s}h`}function z5(e){return e===0?"$0.00":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function jx({sessionName:e,cost:t,turns:s,durationMs:n,model:a,backend:l,linesAdded:c,linesRemoved:d}){const f=w.useRef(null),h=w.useCallback(()=>{const m=document.createElement("canvas"),g=600,_=320;m.width=g*2,m.height=_*2;const v=m.getContext("2d");if(!v)return;v.scale(2,2),v.fillStyle="#1a1b26",v.beginPath(),v.roundRect(0,0,g,_,16),v.fill(),v.strokeStyle="#2a2b3d",v.lineWidth=1,v.beginPath(),v.roundRect(0,0,g,_,16),v.stroke(),v.fillStyle="#c0caf5",v.font="bold 18px system-ui, -apple-system, sans-serif",v.fillText(e.length>40?e.slice(0,40)+"...":e,32,48),v.fillStyle="#565f89",v.font="13px system-ui, -apple-system, sans-serif",v.fillText(`${a} / ${l}`,32,72),v.strokeStyle="#2a2b3d",v.lineWidth=1,v.beginPath(),v.moveTo(32,88),v.lineTo(g-32,88),v.stroke();const y=[{label:"Cost",value:z5(t)},{label:"Duration",value:O5(n)},{label:"Turns",value:String(s)},{label:"Lines",value:`+${c} / -${d}`}],S=(g-64)/2;y.forEach((k,N)=>{const E=N%2,B=Math.floor(N/2),F=32+E*S,$=118+B*72;v.fillStyle="#565f89",v.font="11px system-ui, -apple-system, sans-serif",v.fillText(k.label.toUpperCase(),F,$),v.fillStyle="#c0caf5",v.font="bold 28px system-ui, -apple-system, sans-serif",v.fillText(k.value,F,$+32)}),v.fillStyle="#3b3d57",v.font="11px system-ui, -apple-system, sans-serif",v.fillText("Campfire",g-80,_-20);const j=document.createElement("a");j.download=`campfire-${e.replace(/\s+/g,"-").toLowerCase()}.png`,j.href=m.toDataURL("image/png"),j.click()},[e,t,s,n,a,l,c,d]);return r.jsxs("div",{className:"shrink-0 px-4 py-3 border-b border-cc-border space-y-3",children:[r.jsx("span",{className:"text-[11px] text-cc-muted uppercase tracking-wider",children:"Session Summary"}),r.jsxs("div",{ref:f,className:"rounded-xl p-5 space-y-3",style:{background:"#1a1b26"},children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[14px] font-bold text-[#c0caf5] truncate",children:e}),r.jsxs("p",{className:"text-[11px] text-[#565f89]",children:[a," / ",l]})]}),r.jsx("div",{className:"border-t border-[#2a2b3d]"}),r.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-3",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[9px] text-[#565f89] uppercase tracking-wider",children:"Cost"}),r.jsx("p",{className:"text-[18px] font-bold text-[#c0caf5] tabular-nums",children:z5(t)})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[9px] text-[#565f89] uppercase tracking-wider",children:"Duration"}),r.jsx("p",{className:"text-[18px] font-bold text-[#c0caf5]",children:O5(n)})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[9px] text-[#565f89] uppercase tracking-wider",children:"Turns"}),r.jsx("p",{className:"text-[18px] font-bold text-[#c0caf5] tabular-nums",children:s})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[9px] text-[#565f89] uppercase tracking-wider",children:"Lines"}),r.jsxs("p",{className:"text-[18px] font-bold tabular-nums",children:[r.jsxs("span",{className:"text-green-400",children:["+",c]}),r.jsx("span",{className:"text-[#565f89]",children:" / "}),r.jsxs("span",{className:"text-red-400",children:["-",d]})]})]})]}),r.jsx("div",{className:"text-right",children:r.jsx("span",{className:"text-[9px] text-[#3b3d57]",children:"Campfire"})})]}),r.jsx("button",{onClick:h,className:"w-full text-[11px] font-medium py-1.5 rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",children:"Download PNG"})]})}function oO(e){var t,s;return(t=e.envMissing)!=null&&t.length?"Missing env":(s=e.envPresent)!=null&&s.length?"Configured":"Detected"}function mC({detected:e}){return!e||e.rules.length===0?null:r.jsxs("div",{className:"mx-3 mt-3 rounded-lg border border-cc-border/60 bg-cc-card overflow-hidden",children:[r.jsxs("div",{className:"px-3 py-2.5 border-b border-cc-border/40 flex items-center justify-between",children:[r.jsx("span",{className:"text-[12px] font-semibold text-cc-fg",children:"Environment"}),r.jsx("span",{className:"text-[10px] text-cc-muted tabular-nums",children:e.rules.length})]}),r.jsx("div",{className:"divide-y divide-cc-border/30",children:e.rules.map(t=>{var s;return r.jsxs("div",{className:"px-3 py-2",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("span",{className:"text-[11px] font-medium text-cc-fg truncate",children:t.name}),r.jsx("span",{className:"text-[9px] text-cc-muted uppercase font-mono-code shrink-0",children:oO(t)})]}),r.jsx("p",{className:"mt-0.5 text-[10px] text-cc-muted/70 leading-snug",children:t.description}),(s=t.envMissing)!=null&&s.length?r.jsxs("p",{className:"mt-1 text-[10px] text-cc-warning font-mono-code truncate",children:["Missing ",t.envMissing.join(", ")]}):null]},t.id)})})]})}const lO=[],cO=[],uO=6e4,ag=new Map;function P5(e){try{const t=new Date(e).getTime()-Date.now();if(t<=0)return"now";const s=Math.floor(t/864e5),n=Math.floor(t%864e5/36e5),a=Math.floor(t%36e5/6e4);return s>0?`${s}d ${n}h${a}m`:n>0?`${n}h${a}m`:`${a}m`}catch{return"N/A"}}function Ho(e){return e>80?"bg-cc-error":e>50?"bg-cc-warning":"bg-cc-primary"}function dO(e){return e>80?"bg-red-500":e>50?"bg-yellow-500":"bg-green-500"}function hO({sessionId:e}){var f;const[t,s]=w.useState(ag.get(e)??null),n=w.useCallback(async()=>{try{const h=await ne.getSessionUsageLimits(e);ag.set(e,h),s(h)}catch{}},[e]);w.useEffect(()=>{s(ag.get(e)??null)},[e]),w.useEffect(()=>{n();const h=setInterval(n,uO);return()=>clearInterval(h)},[n]);const[,a]=w.useState(0);if(w.useEffect(()=>{const h=setInterval(()=>a(m=>m+1),3e4);return()=>clearInterval(h)},[]),!t)return null;const l=t.five_hour!==null,c=t.seven_day!==null,d=!l&&!c&&((f=t.extra_usage)==null?void 0:f.is_enabled);return!l&&!c&&!d?null:r.jsxs("div",{className:"mx-3 mt-3 rounded-lg border border-cc-border/60 bg-cc-card px-3 py-2.5 space-y-2",children:[t.five_hour&&r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[10px] text-cc-muted font-medium",children:"5h Limit"}),r.jsxs("span",{className:"text-[10px] text-cc-muted tabular-nums",children:[t.five_hour.utilization,"%",t.five_hour.resets_at&&r.jsxs("span",{className:"ml-1 text-cc-muted",children:["(",P5(t.five_hour.resets_at),")"]})]})]}),r.jsx("div",{className:"w-full h-1.5 rounded-full bg-cc-hover overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${Ho(t.five_hour.utilization)}`,style:{width:`${Math.min(t.five_hour.utilization,100)}%`}})})]}),t.seven_day&&r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[10px] text-cc-muted font-medium",children:"7d Limit"}),r.jsxs("span",{className:"text-[10px] text-cc-muted tabular-nums",children:[t.seven_day.utilization,"%",t.seven_day.resets_at&&r.jsxs("span",{className:"ml-1 text-cc-muted",children:["(",P5(t.seven_day.resets_at),")"]})]})]}),r.jsx("div",{className:"w-full h-1.5 rounded-full bg-cc-hover overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${Ho(t.seven_day.utilization)}`,style:{width:`${Math.min(t.seven_day.utilization,100)}%`}})})]}),d&&t.extra_usage&&r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[10px] text-cc-muted font-medium",children:"Extra"}),r.jsxs("span",{className:"text-[10px] text-cc-muted tabular-nums",children:["$",t.extra_usage.used_credits.toFixed(2)," / $",t.extra_usage.monthly_limit]})]}),t.extra_usage.utilization!==null&&r.jsx("div",{className:"w-full h-1.5 rounded-full bg-cc-hover overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${Ho(t.extra_usage.utilization)}`,style:{width:`${Math.min(t.extra_usage.utilization,100)}%`}})})]})]})}function $5(e){const t=e-Date.now();if(t<=0)return"now";const s=Math.floor(t/864e5),n=Math.floor(t%864e5/36e5),a=Math.floor(t%36e5/6e4);return s>0?`${s}d ${n}h`:n>0?`${n}h${a}m`:`${a}m`}function I5(e){return e>=1440?`${Math.round(e/1440)}d`:e>=60?`${Math.round(e/60)}h`:`${e}m`}function gC({sessionId:e}){const t=G(l=>{var c;return(c=l.sessions.get(e))==null?void 0:c.codex_rate_limits}),[,s]=w.useState(0);if(w.useEffect(()=>{if(!t)return;const l=setInterval(()=>s(c=>c+1),3e4);return()=>clearInterval(l)},[t]),!t)return null;const{primary:n,secondary:a}=t;return!n&&!a?null:r.jsxs("div",{className:"mx-3 mt-3 rounded-lg border border-cc-border/60 bg-cc-card px-3 py-2.5 space-y-2",children:[n&&r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-[10px] text-cc-muted font-medium",children:[I5(n.windowDurationMins)," Limit"]}),r.jsxs("span",{className:"text-[10px] text-cc-muted tabular-nums",children:[Math.round(n.usedPercent),"%",n.resetsAt>0&&r.jsxs("span",{className:"ml-1",children:["(",$5(n.resetsAt),")"]})]})]}),r.jsx("div",{className:"w-full h-1.5 rounded-full bg-cc-hover overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${Ho(n.usedPercent)}`,style:{width:`${Math.min(n.usedPercent,100)}%`}})})]}),a&&r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-[10px] text-cc-muted font-medium",children:[I5(a.windowDurationMins)," Limit"]}),r.jsxs("span",{className:"text-[10px] text-cc-muted tabular-nums",children:[Math.round(a.usedPercent),"%",a.resetsAt>0&&r.jsxs("span",{className:"ml-1",children:["(",$5(a.resetsAt),")"]})]})]}),r.jsx("div",{className:"w-full h-1.5 rounded-full bg-cc-hover overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${Ho(a.usedPercent)}`,style:{width:`${Math.min(a.usedPercent,100)}%`}})})]})]})}function Ui(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function xC({sessionId:e}){const t=G(l=>{var c;return(c=l.sessions.get(e))==null?void 0:c.codex_token_details}),s=G(l=>{var c;return((c=l.sessions.get(e))==null?void 0:c.context_used_percent)??0}),[n,a]=w.useState(!1);return t?r.jsxs("div",{className:"mx-3 mt-3 rounded-lg border border-cc-border/60 bg-cc-card overflow-hidden",children:[r.jsxs("button",{onClick:()=>a(!n),className:"flex items-center gap-1.5 text-[10px] text-cc-muted uppercase tracking-wider hover:text-cc-fg hover:bg-cc-hover/50 transition-colors cursor-pointer w-full px-3 py-2.5",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 transition-transform duration-200 ${n?"rotate-90":""}`,children:r.jsx("path",{d:"M6 3l5 5-5 5V3z"})}),"Tokens"]}),n&&r.jsx("div",{className:"px-3 pb-3 border-t border-cc-border/40",children:r.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1.5 pt-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[10px] text-cc-muted",children:"Input"}),r.jsx("span",{className:"text-[11px] text-cc-fg tabular-nums font-mono-code",children:Ui(t.inputTokens)})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[10px] text-cc-muted",children:"Output"}),r.jsx("span",{className:"text-[11px] text-cc-fg tabular-nums font-mono-code",children:Ui(t.outputTokens)})]}),t.cachedInputTokens>0&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[10px] text-cc-muted",children:"Cached"}),r.jsx("span",{className:"text-[11px] text-cc-fg tabular-nums font-mono-code",children:Ui(t.cachedInputTokens)})]}),t.reasoningOutputTokens>0&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[10px] text-cc-muted",children:"Reasoning"}),r.jsx("span",{className:"text-[11px] text-cc-fg tabular-nums font-mono-code",children:Ui(t.reasoningOutputTokens)})]})]})}),t.modelContextWindow>0&&r.jsxs("div",{className:"px-3 pb-2.5 space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[10px] text-cc-muted",children:"Context"}),r.jsxs("span",{className:"text-[10px] text-cc-muted tabular-nums",children:[s,"%"]})]}),r.jsx("div",{className:"w-full h-1.5 rounded-full bg-cc-hover overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${Ho(s)}`,style:{width:`${Math.min(s,100)}%`}})})]})]}):null}function fO(e){return e===0?"$0":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function vC({sessionId:e}){const t=G(a=>{var l;return(l=a.sessions.get(e))==null?void 0:l.claude_token_details}),[s,n]=w.useState(!1);return t?r.jsxs("div",{className:"mx-3 mt-3 rounded-lg border border-cc-border/60 bg-cc-card overflow-hidden",children:[r.jsxs("button",{onClick:()=>n(!s),className:"flex items-center gap-1.5 text-[10px] text-cc-muted uppercase tracking-wider hover:text-cc-fg hover:bg-cc-hover/50 transition-colors cursor-pointer w-full px-3 py-2.5",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 transition-transform duration-200 ${s?"rotate-90":""}`,children:r.jsx("path",{d:"M6 3l5 5-5 5V3z"})}),"Tokens"]}),s&&r.jsx("div",{className:"px-3 pb-3 border-t border-cc-border/40",children:r.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1.5 pt-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[10px] text-cc-muted",children:"Input"}),r.jsx("span",{className:"text-[11px] text-cc-fg tabular-nums font-mono-code",children:Ui(t.inputTokens)})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[10px] text-cc-muted",children:"Output"}),r.jsx("span",{className:"text-[11px] text-cc-fg tabular-nums font-mono-code",children:Ui(t.outputTokens)})]}),t.cacheReadInputTokens>0&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[10px] text-cc-muted",children:"Cache Read"}),r.jsx("span",{className:"text-[11px] text-cc-fg tabular-nums font-mono-code",children:Ui(t.cacheReadInputTokens)})]}),t.cacheCreationInputTokens>0&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[10px] text-cc-muted",children:"Cache Write"}),r.jsx("span",{className:"text-[11px] text-cc-fg tabular-nums font-mono-code",children:Ui(t.cacheCreationInputTokens)})]}),t.costUsd>0&&r.jsxs("div",{className:"flex items-center justify-between col-span-2 pt-1 border-t border-cc-border/50",children:[r.jsx("span",{className:"text-[10px] text-cc-muted",children:"Cost"}),r.jsx("span",{className:"text-[11px] text-cc-fg tabular-nums font-mono-code",children:fO(t.costUsd)})]})]})})]}):null}function pO({sessionId:e}){const t=G(s=>{var n;return((n=s.sessions.get(e))==null?void 0:n.context_used_percent)??0});return t===0?null:r.jsxs("div",{className:"mx-3 mt-3 rounded-lg border border-cc-border/60 bg-cc-card px-3 py-2",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[r.jsx("span",{className:"text-[10px] text-cc-muted font-medium",children:"Context"}),r.jsxs("span",{className:"text-[10px] text-cc-muted tabular-nums",children:[t,"%"]})]}),r.jsx("div",{className:"w-full h-1.5 rounded-full bg-cc-hover overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${dO(t)}`,style:{width:`${Math.min(t,100)}%`}})})]})}function mO({sessionId:e}){const t=G(d=>d.sessions.get(e));if(!t)return null;const s=t.total_cost_usd??0,n=t.num_turns??0,a=t.context_used_percent??0,l=t.total_lines_added??0,c=t.total_lines_removed??0;return s===0&&n===0?null:r.jsxs("div",{className:"mx-3 mt-3 grid grid-cols-2 gap-2",children:[r.jsxs("div",{className:"rounded-lg border border-cc-border/60 bg-cc-card px-3 py-2",children:[r.jsx("span",{className:"text-[10px] text-cc-muted uppercase tracking-wider block",children:"Cost"}),r.jsxs("span",{className:"text-[14px] font-semibold text-cc-fg font-mono-code",children:["$",s<.01?s.toFixed(4):s.toFixed(2)]})]}),r.jsxs("div",{className:"rounded-lg border border-cc-border/60 bg-cc-card px-3 py-2",children:[r.jsx("span",{className:"text-[10px] text-cc-muted uppercase tracking-wider block",children:"Turns"}),r.jsx("span",{className:"text-[14px] font-semibold text-cc-fg font-mono-code",children:n})]}),a>0&&r.jsxs("div",{className:"rounded-lg border border-cc-border/60 bg-cc-card px-3 py-2",children:[r.jsx("span",{className:"text-[10px] text-cc-muted uppercase tracking-wider block",children:"Context"}),r.jsxs("span",{className:"text-[14px] font-semibold text-cc-fg font-mono-code",children:[a,"%"]})]}),(l>0||c>0)&&r.jsxs("div",{className:"rounded-lg border border-cc-border/60 bg-cc-card px-3 py-2",children:[r.jsx("span",{className:"text-[10px] text-cc-muted uppercase tracking-wider block",children:"Lines"}),r.jsxs("span",{className:"text-[14px] font-semibold font-mono-code",children:[r.jsxs("span",{className:"text-cc-success",children:["+",l]})," / ",r.jsxs("span",{className:"text-cc-error",children:["-",c]})]})]})]})}function gO(e,t){if(t)return{label:"Draft",cls:"text-cc-muted bg-cc-hover"};switch(e){case"OPEN":return{label:"Open",cls:"text-cc-success bg-cc-success/10"};case"MERGED":return{label:"Merged",cls:"text-purple-400 bg-purple-400/10"};case"CLOSED":return{label:"Closed",cls:"text-cc-error bg-cc-error/10"}}}function Cc({pr:e}){const t=gO(e.state,e.isDraft),{checksSummary:s,reviewThreads:n}=e;return r.jsxs("div",{className:"mx-3 mt-3 rounded-lg border border-cc-border/60 bg-cc-card px-3 py-2.5 space-y-1.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-[12px] font-semibold text-cc-fg hover:text-cc-primary transition-colors",children:["PR #",e.number]}),r.jsx("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${t.cls}`,children:t.label}),s.total>0&&r.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[s.success>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-cc-success",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cc-success inline-block"}),s.success]}),s.pending>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-cc-warning",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cc-warning inline-block"}),s.pending]}),s.failure>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-cc-error",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cc-error inline-block"}),s.failure]})]})]}),r.jsx("p",{className:"text-[11px] text-cc-muted truncate",title:e.title,children:e.title}),r.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-cc-muted",children:[e.reviewDecision==="APPROVED"&&r.jsx("span",{className:"text-cc-success",children:"Approved"}),e.reviewDecision==="CHANGES_REQUESTED"&&r.jsx("span",{className:"text-cc-error",children:"Changes requested"}),(e.reviewDecision==="REVIEW_REQUIRED"||e.reviewDecision===null)&&e.state==="OPEN"&&r.jsx("span",{children:"Review pending"}),n.unresolved>0&&r.jsxs("span",{className:"text-cc-warning",children:[n.unresolved," unresolved"]}),r.jsxs("span",{className:"ml-auto",children:[r.jsxs("span",{className:"text-cc-success",children:["+",e.additions]})," ",r.jsxs("span",{className:"text-cc-error",children:["-",e.deletions]})," ",r.jsxs("span",{children:["· ",e.changedFiles,"f"]})]})]})]})}function xO({sessionId:e}){const t=G(c=>c.sessions.get(e)),s=G(c=>c.sdkSessions.find(d=>d.sessionId===e)),n=G(c=>c.prStatus.get(e)),a=(t==null?void 0:t.cwd)||(s==null?void 0:s.cwd),l=(t==null?void 0:t.git_branch)||(s==null?void 0:s.gitBranch);return w.useEffect(()=>{n||!a||!l||ne.getPRStatus(a,l).then(c=>{G.getState().setPRStatus(e,c)}).catch(()=>{})},[e,a,l,n]),!(n!=null&&n.available)||!n.pr?null:r.jsx(Cc,{pr:n.pr})}function vO({sessionId:e}){const t=G(d=>d.sessions.get(e)),s=G(d=>d.sessionNames.get(e)??`Session ${e.slice(0,8)}`),n=G(d=>d.sessionStatus.get(e));if(!t)return null;const a=t.total_cost_usd??0,l=t.num_turns??0;if(n!=="idle"||l===0)return null;const c=t.total_duration_api_ms??0;return r.jsx("div",{className:"mx-3 mt-3",children:r.jsx(jx,{sessionName:s,cost:a,turns:l,durationMs:c,model:t.model||"unknown",backend:t.backend_type||"claude",linesAdded:t.total_lines_added??0,linesRemoved:t.total_lines_removed??0})})}function bO({sessionId:e}){const t=G(l=>l.mcpServers.get(e)),[s,n]=w.useState(!1),a=(t==null?void 0:t.length)??0;return a===0?null:r.jsxs("div",{className:"mx-3 mt-3 rounded-lg border border-cc-border/60 bg-cc-card overflow-hidden",children:[r.jsxs("button",{onClick:()=>n(!s),className:"flex items-center gap-1.5 w-full px-3 py-2.5 text-[10px] text-cc-muted uppercase tracking-wider hover:text-cc-fg hover:bg-cc-hover/50 transition-colors cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 transition-transform duration-200 ${s?"rotate-90":""}`,children:r.jsx("path",{d:"M6 3l5 5-5 5V3z"})}),"MCP Servers",r.jsx("span",{className:"rounded-full bg-cc-primary/10 text-cc-primary px-1.5 text-[10px] font-medium leading-[16px] ml-auto",children:a})]}),s&&r.jsx("div",{className:"border-t border-cc-border/40",children:r.jsx(aO,{sessionId:e})})]})}function _O({agents:e}){const t=G(s=>s.setCurrentSession);return e.length===0?null:r.jsxs("div",{className:"mx-3 mt-3 rounded-lg border border-cc-border/60 bg-cc-card overflow-hidden",children:[r.jsxs("div",{className:"px-3 py-2.5 border-b border-cc-border/40 flex items-center justify-between",children:[r.jsx("span",{className:"text-[12px] font-semibold text-cc-fg",children:"Sub-Agents"}),r.jsx("span",{className:"text-[10px] text-cc-muted tabular-nums",children:e.length})]}),r.jsx("div",{className:"divide-y divide-cc-border/30",children:e.map(s=>r.jsxs("button",{onClick:()=>{s.sessionId&&(t(s.sessionId),Sr(s.sessionId),window.location.hash="")},className:"w-full px-3 py-2 text-left hover:bg-cc-hover/50",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("span",{className:"text-[11px] font-medium text-cc-fg truncate",children:s.name}),r.jsx("span",{className:"text-[9px] uppercase font-mono-code text-cc-muted shrink-0",children:s.status})]}),r.jsxs("p",{className:"mt-0.5 text-[10px] text-cc-muted/70 truncate",children:[s.backendType||s.agentType,s.costUsd?` / $${s.costUsd.toFixed(4)}`:""]}),s.summary&&r.jsx("p",{className:"mt-1 text-[10px] text-cc-muted/60 line-clamp-2",children:s.summary})]},s.toolUseId))})]})}function yO({sessionId:e}){const t=G(y=>y.sessionTasks.get(e)||lO),s=G(y=>y.sessionBackgroundAgents.get(e)||cO),n=G(y=>y.sessions.get(e)),a=G(y=>{var S;return(S=y.sdkSessions.find(j=>j.sessionId===e))==null?void 0:S.backendType}),l=G(y=>y.taskPanelOpen),c=G(y=>y.setTaskPanelOpen);if(!l)return null;const d=((n==null?void 0:n.backend_type)||a)==="codex",f=!!n,h=t.filter(y=>y.status==="in_progress"),m=t.filter(y=>y.status!=="in_progress"&&y.status!=="completed"),g=t.filter(y=>y.status==="completed"),_=[...h,...m,...g],v=g.length;return r.jsxs("aside",{className:"w-[280px] h-full flex flex-col overflow-hidden bg-cc-bg border-l border-cc-border",children:[r.jsxs("div",{className:"shrink-0 flex items-center justify-between px-4 h-11 border-b border-cc-border",children:[r.jsx("span",{className:"text-[13px] font-semibold text-cc-fg",children:"Session"}),r.jsx("button",{onClick:()=>c(!1),className:"flex items-center justify-center w-7 h-7 rounded-lg text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-all duration-200 cursor-pointer",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})})})]}),r.jsx(pO,{sessionId:e}),r.jsxs("div",{"data-testid":"task-panel-content",className:"min-h-0 flex-1 overflow-y-auto pb-3",children:[d?r.jsxs(r.Fragment,{children:[r.jsx(gC,{sessionId:e}),r.jsx(xC,{sessionId:e})]}):r.jsxs(r.Fragment,{children:[r.jsx(hO,{sessionId:e}),r.jsx(vC,{sessionId:e})]}),r.jsx(mO,{sessionId:e}),r.jsx(vO,{sessionId:e}),r.jsx(mC,{detected:n==null?void 0:n.detected_environment}),r.jsx(xO,{sessionId:e}),r.jsx(bO,{sessionId:e}),r.jsx(_O,{agents:s}),f&&r.jsxs("div",{className:"mx-3 mt-3 rounded-lg border border-cc-border/60 bg-cc-card overflow-hidden",children:[r.jsxs("div",{className:"px-3 py-2.5 border-b border-cc-border/40 flex items-center justify-between",children:[r.jsx("span",{className:"text-[12px] font-semibold text-cc-fg",children:"Tasks"}),r.jsxs("div",{className:"flex items-center gap-2",children:[t.length>0&&r.jsxs("span",{className:"text-[11px] text-cc-muted tabular-nums",children:[v,"/",t.length]}),t.length>0&&r.jsxs("button",{onClick:()=>{globalThis.location.hash="#/kanban"},className:"text-[10px] font-mono-code text-cc-muted hover:text-cc-fg px-1.5 py-0.5 rounded hover:bg-cc-hover transition-all duration-200 cursor-pointer",title:"View Kanban board",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 inline-block mr-0.5 -mt-px",children:r.jsx("path",{d:"M1.5 2h4v12h-4V2zm.75.75v10.5h2.5V2.75h-2.5zM6 2h4v8H6V2zm.75.75v6.5h2.5v-6.5h-2.5zM10.5 2h4v10h-4V2zm.75.75v8.5h2.5v-8.5h-2.5z"})}),"board"]})]})]}),r.jsx("div",{className:"px-1",children:t.length===0?r.jsx("p",{className:"text-xs text-cc-muted text-center py-8",children:"No tasks yet"}):r.jsx("div",{className:"divide-y divide-cc-border/30",children:_.map(y=>r.jsx(SO,{task:y},y.id))})})]})]})]})}function wO({status:e}){return e==="in_progress"?r.jsx("svg",{className:"w-[18px] h-[18px] text-cc-primary animate-spin",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"28",strokeDashoffset:"8",strokeLinecap:"round"})}):e==="completed"?r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-[18px] h-[18px] text-cc-success","aria-hidden":!0,children:r.jsx("path",{fillRule:"evenodd",d:"M8 15A7 7 0 108 1a7 7 0 000 14zm3.354-9.354a.5.5 0 00-.708-.708L7 8.586 5.354 6.94a.5.5 0 10-.708.708l2 2a.5.5 0 00.708 0l4-4z",clipRule:"evenodd"})}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-[18px] h-[18px] text-cc-muted","aria-hidden":!0,children:r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"})})}function SO({task:e}){const t=e.status==="completed",s=e.status==="in_progress";return r.jsxs("div",{className:"px-2.5 py-2 hover:bg-cc-hover/30 transition-colors",children:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"shrink-0 flex items-center justify-center w-[18px] h-[18px] mt-px",children:r.jsx(wO,{status:e.status})}),r.jsx("span",{className:`text-[12px] leading-snug flex-1 ${t?"text-cc-muted/60 opacity-60":"text-cc-fg"}`,children:e.subject})]}),s&&e.activeForm&&r.jsx("p",{className:"mt-1 ml-[26px] text-[11px] text-cc-muted italic truncate",children:e.activeForm}),e.blockedBy&&e.blockedBy.length>0&&r.jsxs("p",{className:"mt-1 ml-[26px] text-[11px] text-cc-muted flex items-center gap-1",children:[r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-3 h-3 shrink-0",children:[r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"}),r.jsx("path",{d:"M5 8h6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),r.jsxs("span",{children:["blocked by ",e.blockedBy.map(n=>`#${n}`).join(", ")]})]})]})}function F5(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,n=Array(t);s<t;s++)n[s]=e[s];return n}function jO(e){if(Array.isArray(e))return e}function kO(e,t,s){return(t=RO(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function CO(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var n,a,l,c,d=[],f=!0,h=!1;try{if(l=(s=s.call(e)).next,t!==0)for(;!(f=(n=l.call(s)).done)&&(d.push(n.value),d.length!==t);f=!0);}catch(m){h=!0,a=m}finally{try{if(!f&&s.return!=null&&(c=s.return(),Object(c)!==c))return}finally{if(h)throw a}}return d}}function NO(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
112
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function H5(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),s.push.apply(s,n)}return s}function U5(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?H5(Object(s),!0).forEach(function(n){kO(e,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):H5(Object(s)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(s,n))})}return e}function EO(e,t){if(e==null)return{};var s,n,a=MO(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)s=l[n],t.indexOf(s)===-1&&{}.propertyIsEnumerable.call(e,s)&&(a[s]=e[s])}return a}function MO(e,t){if(e==null)return{};var s={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;s[n]=e[n]}return s}function TO(e,t){return jO(e)||CO(e,t)||DO(e,t)||NO()}function AO(e,t){if(typeof e!="object"||!e)return e;var s=e[Symbol.toPrimitive];if(s!==void 0){var n=s.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function RO(e){var t=AO(e,"string");return typeof t=="symbol"?t:t+""}function DO(e,t){if(e){if(typeof e=="string")return F5(e,t);var s={}.toString.call(e).slice(8,-1);return s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set"?Array.from(e):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?F5(e,t):void 0}}function LO(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function V5(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),s.push.apply(s,n)}return s}function W5(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?V5(Object(s),!0).forEach(function(n){LO(e,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):V5(Object(s)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(s,n))})}return e}function BO(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return function(n){return t.reduceRight(function(a,l){return l(a)},n)}}function Nc(e){return function t(){for(var s=this,n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return a.length>=e.length?e.apply(this,a):function(){for(var c=arguments.length,d=new Array(c),f=0;f<c;f++)d[f]=arguments[f];return t.apply(s,[].concat(a,d))}}}function Th(e){return{}.toString.call(e).includes("Object")}function OO(e){return!Object.keys(e).length}function Qc(e){return typeof e=="function"}function zO(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function PO(e,t){return Th(t)||Ki("changeType"),Object.keys(t).some(function(s){return!zO(e,s)})&&Ki("changeField"),t}function $O(e){Qc(e)||Ki("selectorType")}function IO(e){Qc(e)||Th(e)||Ki("handlerType"),Th(e)&&Object.values(e).some(function(t){return!Qc(t)})&&Ki("handlersType")}function FO(e){e||Ki("initialIsRequired"),Th(e)||Ki("initialType"),OO(e)&&Ki("initialContent")}function HO(e,t){throw new Error(e[t]||e.default)}var UO={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},Ki=Nc(HO)(UO),Hd={changes:PO,selector:$O,handler:IO,initial:FO};function VO(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Hd.initial(e),Hd.handler(t);var s={current:e},n=Nc(GO)(s,t),a=Nc(qO)(s),l=Nc(Hd.changes)(e),c=Nc(WO)(s);function d(){var h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(m){return m};return Hd.selector(h),h(s.current)}function f(h){BO(n,a,l,c)(h)}return[d,f]}function WO(e,t){return Qc(t)?t(e.current):t}function qO(e,t){return e.current=W5(W5({},e.current),t),t}function GO(e,t,s){return Qc(t)?t(e.current):Object.keys(s).forEach(function(n){var a;return(a=t[n])===null||a===void 0?void 0:a.call(t,e.current[n])}),s}var KO={create:VO},YO={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function XO(e){return function t(){for(var s=this,n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return a.length>=e.length?e.apply(this,a):function(){for(var c=arguments.length,d=new Array(c),f=0;f<c;f++)d[f]=arguments[f];return t.apply(s,[].concat(a,d))}}}function JO(e){return{}.toString.call(e).includes("Object")}function QO(e){return e||q5("configIsRequired"),JO(e)||q5("configType"),e.urls?(ZO(),{paths:{vs:e.urls.monacoBase}}):e}function ZO(){console.warn(bC.deprecation)}function ez(e,t){throw new Error(e[t]||e.default)}var bC={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
113
+ You are using deprecated way of configuration.
114
+
115
+ Instead of using
116
+ monaco.config({ urls: { monacoBase: '...' } })
117
+ use
118
+ monaco.config({ paths: { vs: '...' } })
119
+
120
+ For more please check the link https://github.com/suren-atoyan/monaco-loader#config
121
+ `},q5=XO(ez)(bC),tz={config:QO},sz=function(){for(var t=arguments.length,s=new Array(t),n=0;n<t;n++)s[n]=arguments[n];return function(a){return s.reduceRight(function(l,c){return c(l)},a)}};function _C(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],_C(e[s],t[s]))}),U5(U5({},e),t)}var nz={type:"cancelation",msg:"operation is manually canceled"};function og(e){var t=!1,s=new Promise(function(n,a){e.then(function(l){return t?a(nz):n(l)}),e.catch(a)});return s.cancel=function(){return t=!0},s}var rz=["monaco"],iz=KO.create({config:YO,isInitialized:!1,resolve:null,reject:null,monaco:null}),yC=TO(iz,2),du=yC[0],Xh=yC[1];function az(e){var t=tz.config(e),s=t.monaco,n=EO(t,rz);Xh(function(a){return{config:_C(a.config,n),monaco:s}})}function oz(){var e=du(function(t){var s=t.monaco,n=t.isInitialized,a=t.resolve;return{monaco:s,isInitialized:n,resolve:a}});if(!e.isInitialized){if(Xh({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),og(lg);if(window.monaco&&window.monaco.editor)return wC(window.monaco),e.resolve(window.monaco),og(lg);sz(lz,uz)(dz)}return og(lg)}function lz(e){return document.body.appendChild(e)}function cz(e){var t=document.createElement("script");return e&&(t.src=e),t}function uz(e){var t=du(function(n){var a=n.config,l=n.reject;return{config:a,reject:l}}),s=cz("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function dz(){var e=du(function(s){var n=s.config,a=s.resolve,l=s.reject;return{config:n,resolve:a,reject:l}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var n=s.m||s;wC(n),e.resolve(n)},function(s){e.reject(s)})}function wC(e){du().monaco||Xh({monaco:e})}function hz(){return du(function(e){var t=e.monaco;return t})}var lg=new Promise(function(e,t){return Xh({resolve:e,reject:t})}),SC={config:az,init:oz,__getMonacoInstance:hz},fz={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},cg=fz,pz={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},mz=pz;function gz({children:e}){return xr.createElement("div",{style:mz.container},e)}var xz=gz,vz=xz;function bz({width:e,height:t,isEditorReady:s,loading:n,_ref:a,className:l,wrapperProps:c}){return xr.createElement("section",{style:{...cg.wrapper,width:e,height:t},...c},!s&&xr.createElement(vz,null,n),xr.createElement("div",{ref:a,style:{...cg.fullWidth,...!s&&cg.hide},className:l}))}var _z=bz,jC=w.memo(_z);function yz(e){w.useEffect(e,[])}var kC=yz;function wz(e,t,s=!0){let n=w.useRef(!0);w.useEffect(n.current||!s?()=>{n.current=!1}:e,t)}var Tn=wz;function Ic(){}function zo(e,t,s,n){return Sz(e,n)||jz(e,t,s,n)}function Sz(e,t){return e.editor.getModel(CC(e,t))}function jz(e,t,s,n){return e.editor.createModel(t,s,n?CC(e,n):void 0)}function CC(e,t){return e.Uri.parse(t)}function kz({original:e,modified:t,language:s,originalLanguage:n,modifiedLanguage:a,originalModelPath:l,modifiedModelPath:c,keepCurrentOriginalModel:d=!1,keepCurrentModifiedModel:f=!1,theme:h="light",loading:m="Loading...",options:g={},height:_="100%",width:v="100%",className:y,wrapperProps:S={},beforeMount:j=Ic,onMount:k=Ic}){let[N,E]=w.useState(!1),[B,F]=w.useState(!0),$=w.useRef(null),K=w.useRef(null),Y=w.useRef(null),W=w.useRef(k),L=w.useRef(j),Q=w.useRef(!1);kC(()=>{let A=SC.init();return A.then(M=>(K.current=M)&&F(!1)).catch(M=>(M==null?void 0:M.type)!=="cancelation"&&console.error("Monaco initialization: error:",M)),()=>$.current?q():A.cancel()}),Tn(()=>{if($.current&&K.current){let A=$.current.getOriginalEditor(),M=zo(K.current,e||"",n||s||"text",l||"");M!==A.getModel()&&A.setModel(M)}},[l],N),Tn(()=>{if($.current&&K.current){let A=$.current.getModifiedEditor(),M=zo(K.current,t||"",a||s||"text",c||"");M!==A.getModel()&&A.setModel(M)}},[c],N),Tn(()=>{let A=$.current.getModifiedEditor();A.getOption(K.current.editor.EditorOption.readOnly)?A.setValue(t||""):t!==A.getValue()&&(A.executeEdits("",[{range:A.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),A.pushUndoStop())},[t],N),Tn(()=>{var A,M;(M=(A=$.current)==null?void 0:A.getModel())==null||M.original.setValue(e||"")},[e],N),Tn(()=>{let{original:A,modified:M}=$.current.getModel();K.current.editor.setModelLanguage(A,n||s||"text"),K.current.editor.setModelLanguage(M,a||s||"text")},[s,n,a],N),Tn(()=>{var A;(A=K.current)==null||A.editor.setTheme(h)},[h],N),Tn(()=>{var A;(A=$.current)==null||A.updateOptions(g)},[g],N);let V=w.useCallback(()=>{var O;if(!K.current)return;L.current(K.current);let A=zo(K.current,e||"",n||s||"text",l||""),M=zo(K.current,t||"",a||s||"text",c||"");(O=$.current)==null||O.setModel({original:A,modified:M})},[s,t,a,e,n,l,c]),X=w.useCallback(()=>{var A;!Q.current&&Y.current&&($.current=K.current.editor.createDiffEditor(Y.current,{automaticLayout:!0,...g}),V(),(A=K.current)==null||A.editor.setTheme(h),E(!0),Q.current=!0)},[g,h,V]);w.useEffect(()=>{N&&W.current($.current,K.current)},[N]),w.useEffect(()=>{!B&&!N&&X()},[B,N,X]);function q(){var M,O,U,I;let A=(M=$.current)==null?void 0:M.getModel();d||((O=A==null?void 0:A.original)==null||O.dispose()),f||((U=A==null?void 0:A.modified)==null||U.dispose()),(I=$.current)==null||I.dispose()}return xr.createElement(jC,{width:v,height:_,isEditorReady:N,loading:m,_ref:Y,className:y,wrapperProps:S})}var Cz=kz;w.memo(Cz);function Nz(e){let t=w.useRef();return w.useEffect(()=>{t.current=e},[e]),t.current}var Ez=Nz,Ud=new Map;function Mz({defaultValue:e,defaultLanguage:t,defaultPath:s,value:n,language:a,path:l,theme:c="light",line:d,loading:f="Loading...",options:h={},overrideServices:m={},saveViewState:g=!0,keepCurrentModel:_=!1,width:v="100%",height:y="100%",className:S,wrapperProps:j={},beforeMount:k=Ic,onMount:N=Ic,onChange:E,onValidate:B=Ic}){let[F,$]=w.useState(!1),[K,Y]=w.useState(!0),W=w.useRef(null),L=w.useRef(null),Q=w.useRef(null),V=w.useRef(N),X=w.useRef(k),q=w.useRef(),A=w.useRef(n),M=Ez(l),O=w.useRef(!1),U=w.useRef(!1);kC(()=>{let P=SC.init();return P.then(z=>(W.current=z)&&Y(!1)).catch(z=>(z==null?void 0:z.type)!=="cancelation"&&console.error("Monaco initialization: error:",z)),()=>L.current?R():P.cancel()}),Tn(()=>{var z,T,oe,be;let P=zo(W.current,e||n||"",t||a||"",l||s||"");P!==((z=L.current)==null?void 0:z.getModel())&&(g&&Ud.set(M,(T=L.current)==null?void 0:T.saveViewState()),(oe=L.current)==null||oe.setModel(P),g&&((be=L.current)==null||be.restoreViewState(Ud.get(l))))},[l],F),Tn(()=>{var P;(P=L.current)==null||P.updateOptions(h)},[h],F),Tn(()=>{!L.current||n===void 0||(L.current.getOption(W.current.editor.EditorOption.readOnly)?L.current.setValue(n):n!==L.current.getValue()&&(U.current=!0,L.current.executeEdits("",[{range:L.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),L.current.pushUndoStop(),U.current=!1))},[n],F),Tn(()=>{var z,T;let P=(z=L.current)==null?void 0:z.getModel();P&&a&&((T=W.current)==null||T.editor.setModelLanguage(P,a))},[a],F),Tn(()=>{var P;d!==void 0&&((P=L.current)==null||P.revealLine(d))},[d],F),Tn(()=>{var P;(P=W.current)==null||P.editor.setTheme(c)},[c],F);let I=w.useCallback(()=>{var P;if(!(!Q.current||!W.current)&&!O.current){X.current(W.current);let z=l||s,T=zo(W.current,n||e||"",t||a||"",z||"");L.current=(P=W.current)==null?void 0:P.editor.create(Q.current,{model:T,automaticLayout:!0,...h},m),g&&L.current.restoreViewState(Ud.get(z)),W.current.editor.setTheme(c),d!==void 0&&L.current.revealLine(d),$(!0),O.current=!0}},[e,t,s,n,a,l,h,m,g,c,d]);w.useEffect(()=>{F&&V.current(L.current,W.current)},[F]),w.useEffect(()=>{!K&&!F&&I()},[K,F,I]),A.current=n,w.useEffect(()=>{var P,z;F&&E&&((P=q.current)==null||P.dispose(),q.current=(z=L.current)==null?void 0:z.onDidChangeModelContent(T=>{U.current||E(L.current.getValue(),T)}))},[F,E]),w.useEffect(()=>{if(F){let P=W.current.editor.onDidChangeMarkers(z=>{var oe;let T=(oe=L.current.getModel())==null?void 0:oe.uri;if(T&&z.find(be=>be.path===T.path)){let be=W.current.editor.getModelMarkers({resource:T});B==null||B(be)}});return()=>{P==null||P.dispose()}}return()=>{}},[F,B]);function R(){var P,z;(P=q.current)==null||P.dispose(),_?g&&Ud.set(l,L.current.saveViewState()):(z=L.current.getModel())==null||z.dispose(),L.current.dispose()}return xr.createElement(jC,{width:v,height:y,isEditorReady:F,loading:f,_ref:Q,className:S,wrapperProps:j})}var Tz=Mz,Az=w.memo(Tz),Rz=Az;const Dz={base:"vs",inherit:!0,rules:[{token:"comment",foreground:"71717A",fontStyle:"italic"},{token:"keyword",foreground:"5B5FC7"},{token:"string",foreground:"22C55E"},{token:"number",foreground:"F59E0B"},{token:"type",foreground:"5BA8A0"},{token:"variable",foreground:"09090B"}],colors:{"editor.background":"#FFFFFF","editor.foreground":"#09090B","editor.lineHighlightBackground":"#00000006","editor.selectionBackground":"#5B5FC730","editor.inactiveSelectionBackground":"#5B5FC715","editorLineNumber.foreground":"#71717A60","editorLineNumber.activeForeground":"#71717A","editorIndentGuide.background":"#00000008","editorCursor.foreground":"#5B5FC7","editor.findMatchBackground":"#F59E0B30","editor.findMatchHighlightBackground":"#F59E0B18","editorWidget.background":"#FFFFFF","editorWidget.border":"#00000010","input.background":"#FAFAFA","input.border":"#00000010","minimap.background":"#FAFAFA","scrollbarSlider.background":"#71717A20","scrollbarSlider.hoverBackground":"#71717A40"}},Lz={base:"vs-dark",inherit:!0,rules:[{token:"comment",foreground:"A1A1AA",fontStyle:"italic"},{token:"keyword",foreground:"818CF8"},{token:"string",foreground:"4ADE80"},{token:"number",foreground:"FBBF24"},{token:"type",foreground:"5BA8A0"},{token:"variable",foreground:"FAFAFA"}],colors:{"editor.background":"#18181B","editor.foreground":"#FAFAFA","editor.lineHighlightBackground":"#FFFFFF06","editor.selectionBackground":"#818CF830","editor.inactiveSelectionBackground":"#818CF815","editorLineNumber.foreground":"#A1A1AA50","editorLineNumber.activeForeground":"#A1A1AA","editorIndentGuide.background":"#FFFFFF08","editorCursor.foreground":"#818CF8","editor.findMatchBackground":"#FBBF2430","editor.findMatchHighlightBackground":"#FBBF2418","editorWidget.background":"#18181B","editorWidget.border":"#FFFFFF10","input.background":"#09090B","input.border":"#FFFFFF10","minimap.background":"#09090B","scrollbarSlider.background":"#A1A1AA20","scrollbarSlider.hoverBackground":"#A1A1AA40"}};let G5=!1;function Bz(e){G5||(e.editor.defineTheme("campfire-light",Dz),e.editor.defineTheme("campfire-dark",Lz),G5=!0)}const Oz={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",rs:"rust",go:"go",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",rb:"ruby",php:"php",swift:"swift",kt:"kotlin",scala:"scala",r:"r",html:"html",htm:"html",css:"css",scss:"scss",less:"less",json:"json",jsonc:"json",yaml:"yaml",yml:"yaml",toml:"ini",md:"markdown",mdx:"markdown",txt:"plaintext",sql:"sql",xml:"xml",xsl:"xml",sh:"shell",bash:"shell",zsh:"shell",fish:"shell",dockerfile:"dockerfile",docker:"dockerfile",graphql:"graphql",gql:"graphql"};function tv(e){var n,a;const t=((n=e.split(".").pop())==null?void 0:n.toLowerCase())||"",s=((a=e.split("/").pop())==null?void 0:a.toLowerCase())||"";return s==="dockerfile"?"dockerfile":s==="makefile"?"plaintext":s.endsWith(".json")?"json":Oz[t]||"plaintext"}function zz({value:e,onChange:t,language:s="plaintext",readOnly:n=!1,height:a="300px",minimap:l=!1,lineNumbers:c=!0,wordWrap:d=!0,className:f="",ariaLabel:h}){const m=G(S=>S.darkMode),g=w.useRef(null),_=w.useCallback((S,j)=>{Bz(j),j.editor.setTheme(m?"campfire-dark":"campfire-light"),g.current=S,S.updateOptions({fontSize:13,fontFamily:"'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontLigatures:!1,renderLineHighlight:n?"none":"line",scrollBeyondLastLine:!1,smoothScrolling:!0,cursorBlinking:"smooth",cursorSmoothCaretAnimation:"on",padding:{top:12,bottom:12},overviewRulerLanes:0,hideCursorInOverviewRuler:!0,overviewRulerBorder:!1,roundedSelection:!0,guides:{indentation:!0,bracketPairs:!1}}),h&&S.updateOptions({ariaLabel:h})},[m,n,h]),v=w.useCallback(S=>{t&&S!==void 0&&t(S)},[t]),y=m?"campfire-dark":"campfire-light";return r.jsx("div",{className:`rounded-xl border border-cc-border overflow-hidden ${f}`,children:r.jsx(Rz,{height:a,language:s,value:e,onChange:v,onMount:_,theme:y,options:{readOnly:n,minimap:{enabled:l},lineNumbers:c?"on":"off",wordWrap:d?"on":"off",scrollbar:{vertical:"auto",horizontal:"auto",verticalScrollbarSize:6,horizontalScrollbarSize:6},folding:!0,glyphMargin:!1,lineDecorationsWidth:8,lineNumbersMinChars:3,tabSize:2,insertSpaces:!0,automaticLayout:!0,contextmenu:!0,quickSuggestions:!n,suggestOnTriggerCharacters:!n,bracketPairColorization:{enabled:!0}},loading:r.jsx("div",{className:"flex items-center justify-center h-full text-cc-muted text-[12px]",children:"Loading editor..."})})})}const hu=Object.freeze(Object.defineProperty({__proto__:null,CodeEditor:zz,detectLanguage:tv},Symbol.toStringTag,{value:"Module"})),Pz=w.lazy(()=>Xi(()=>Promise.resolve().then(()=>hu),void 0).then(e=>({default:e.CodeEditor})));function $z({sessionId:e}){const t=G(U=>U.sessions.get(e)),s=G(U=>U.sdkSessions.find(I=>I.sessionId===e)),n=G(U=>U.diffPanelSelectedFile.get(e)??null),a=G(U=>U.setDiffPanelSelectedFile),l=G(U=>U.changedFiles.get(e)),c=(t==null?void 0:t.cwd)||(s==null?void 0:s.cwd),d=t==null?void 0:t.git_start_commit,[f,h]=w.useState(""),[m,g]=w.useState(!1),[_,v]=w.useState(!0),[y,S]=w.useState("diff"),[j,k]=w.useState(""),[N,E]=w.useState(!1),[B,F]=w.useState(!1),[$,K]=w.useState(!1),[Y,W]=w.useState(!1),[L,Q]=w.useState(()=>typeof window<"u"?window.innerWidth>=640:!0),V=w.useMemo(()=>l??new Set,[l]),X=w.useMemo(()=>{if(!V.size||!c)return[];const U=`${c}/`;return[...V].filter(I=>I===c||I.startsWith(U)).map(I=>({abs:I,rel:I.startsWith(c+"/")?I.slice(c.length+1):I})).sort((I,R)=>I.rel.localeCompare(R.rel))},[V,c]);w.useEffect(()=>{!n&&X.length>0&&a(e,X[0].abs)},[n,X,e,a]),w.useEffect(()=>{var U;n&&(X.some(I=>I.abs===n)||a(e,((U=X[0])==null?void 0:U.abs)??null))},[n,X,e,a]),w.useEffect(()=>{if(!n){h(""),v(!0);return}let U=!1;return g(!0),ne.getFileDiff(n,{base:d,knownChanged:!0,sessionId:e}).then(I=>{U||(h(I.diff),v(I.exists!==!1),g(!1))}).catch(()=>{U||(h(""),v(!0),g(!1))}),()=>{U=!0}},[n,d,e]),w.useEffect(()=>{if(y!=="edit"||!n)return;let U=!1;return E(!0),W(!1),K(!1),ne.readFile(n).then(I=>{U||(k(I.content),E(!1))}).catch(()=>{U||(k(""),E(!1))}),()=>{U=!0}},[y,n]);const q=w.useCallback(async()=>{if(!(!n||B)){F(!0);try{await ne.writeFile(n,j),W(!1),K(!0),setTimeout(()=>K(!1),2e3)}catch{}F(!1)}},[n,j,B]),A=w.useCallback(U=>{a(e,U),typeof window<"u"&&window.innerWidth<640&&Q(!1)},[e,a]),M=w.useMemo(()=>!n||!c?n:n.startsWith(c+"/")?n.slice(c.length+1):n,[n,c]),O=w.useMemo(()=>{if(!f.trim())return"";const U=f.match(/`+/g)??[];let I=0;for(const P of U)P.length>I&&(I=P.length);const R="`".repeat(Math.max(3,I+1));return`${R}diff
122
+ ${f}
123
+ ${R}`},[f]);return c?X.length===0?r.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-4 select-none px-6",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-cc-card border border-cc-border flex items-center justify-center",children:r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-7 h-7 text-cc-muted",children:r.jsx("path",{d:"M12 3v18M3 12h18",strokeLinecap:"round"})})}),r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-sm text-cc-fg font-medium mb-1",children:"No changes yet"}),r.jsx("p",{className:"text-xs text-cc-muted leading-relaxed",children:"File changes from Edit and Write tool calls will appear here."})]})]}):r.jsxs("div",{className:"h-full flex bg-cc-bg relative",children:[L&&r.jsx("div",{className:"fixed inset-0 bg-black/30 z-20 sm:hidden",onClick:()=>Q(!1)}),r.jsxs("div",{className:`
124
+ ${L?"w-[220px] translate-x-0":"w-0 -translate-x-full"}
125
+ fixed sm:relative z-30 sm:z-auto
126
+ ${L?"sm:w-[220px]":"sm:w-0 sm:-translate-x-full"}
127
+ shrink-0 h-full flex flex-col bg-cc-sidebar border-r border-cc-border transition-all duration-200 overflow-hidden
128
+ `,children:[r.jsxs("div",{className:"w-[220px] px-4 py-3 text-[11px] font-semibold text-cc-fg uppercase tracking-wider border-b border-cc-border shrink-0 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-2 h-2 rounded-full bg-cc-warning"}),r.jsxs("span",{children:["Changed (",X.length,")"]})]}),r.jsx("button",{onClick:()=>Q(!1),className:"w-5 h-5 flex items-center justify-center rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer sm:hidden",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3 h-3",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})})})]}),r.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden py-1",children:X.map(({abs:U,rel:I})=>r.jsxs("button",{onClick:()=>A(U),className:`flex items-center gap-2 w-full mx-1 px-2 py-1.5 text-[13px] rounded-lg hover:bg-cc-hover transition-colors cursor-pointer whitespace-nowrap ${U===n?"bg-cc-active text-cc-fg":"text-cc-fg/70"}`,style:{width:"calc(100% - 8px)"},children:[r.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-warning shrink-0",children:r.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),r.jsx("span",{className:"truncate leading-snug",children:I})]},U))})]}),r.jsxs("div",{className:"flex-1 min-w-0 h-full flex flex-col",children:[n&&r.jsxs("div",{className:"shrink-0 flex items-center gap-2 sm:gap-2.5 px-2 sm:px-4 py-2.5 bg-cc-card border-b border-cc-border",children:[!L&&r.jsx("button",{onClick:()=>Q(!0),className:"flex items-center justify-center w-6 h-6 rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer shrink-0",title:"Show file list",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M1 3.5A1.5 1.5 0 012.5 2h3.379a1.5 1.5 0 011.06.44l.622.621a.5.5 0 00.353.146H13.5A1.5 1.5 0 0115 4.707V12.5a1.5 1.5 0 01-1.5 1.5h-11A1.5 1.5 0 011 12.5v-9z"})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-cc-fg text-[13px] font-medium truncate block",children:M==null?void 0:M.split("/").pop()}),r.jsx("span",{className:"text-cc-muted truncate text-[11px] hidden sm:block font-mono-code",children:M})]}),r.jsx("span",{className:"text-cc-muted text-[11px] shrink-0 hidden sm:inline",children:"Compared to session start"}),r.jsxs("div",{className:"ml-2 hidden sm:flex items-center gap-1 rounded-md bg-cc-bg border border-cc-border p-0.5 text-[11px]",children:[r.jsx("button",{onClick:()=>S("diff"),className:`px-2 py-0.5 rounded cursor-pointer transition-colors ${y==="diff"?"bg-cc-active text-cc-fg":"text-cc-muted hover:text-cc-fg"}`,children:"Diff"}),r.jsx("button",{onClick:()=>S("edit"),className:`px-2 py-0.5 rounded cursor-pointer transition-colors ${y==="edit"?"bg-cc-active text-cc-fg":"text-cc-muted hover:text-cc-fg"}`,children:"Edit"}),r.jsx("button",{onClick:()=>S("raw"),className:`px-2 py-0.5 rounded cursor-pointer transition-colors ${y==="raw"?"bg-cc-active text-cc-fg":"text-cc-muted hover:text-cc-fg"}`,children:"Raw"})]}),y==="edit"&&r.jsxs("div",{className:"ml-2 flex items-center gap-2",children:[r.jsx("button",{onClick:q,disabled:B||!Y,className:"px-3 py-1 rounded-md bg-cc-primary text-white text-[11px] font-medium hover:bg-cc-primary-hover transition-colors cursor-pointer disabled:opacity-40",children:B?"Saving...":"Save"}),$&&r.jsx("span",{className:"text-[10px] text-cc-success",children:"Saved"}),Y&&!$&&r.jsx("span",{className:"text-[10px] text-cc-warning",children:"Unsaved"})]})]}),r.jsx("div",{className:"flex-1 overflow-auto",children:m?r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx("div",{className:"w-5 h-5 border-2 border-cc-primary border-t-transparent rounded-full animate-spin"})}):n&&y==="edit"?N?r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx("div",{className:"w-5 h-5 border-2 border-cc-primary border-t-transparent rounded-full animate-spin"})}):r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"h-full flex items-center justify-center text-cc-muted text-[12px]",children:"Loading editor..."}),children:r.jsx(Pz,{value:j,onChange:U=>{k(U),W(!0)},language:tv(n),height:"calc(100vh - 120px)",minimap:!0,lineNumbers:!0,wordWrap:!1,ariaLabel:`Editing ${M||n}`,className:"border-0 rounded-none"})}):n?r.jsx("div",{className:"p-4",children:!_&&!f.trim()?r.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-12",children:[r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-8 h-8 text-cc-muted",children:r.jsx("path",{d:"M12 9v4m0 4h.01M5.07 19h13.86c1.05 0 1.7-1.14 1.18-2.06l-6.93-12a1.33 1.33 0 00-2.36 0l-6.93 12c-.52.92.13 2.06 1.18 2.06z",strokeLinecap:"round",strokeLinejoin:"round"})}),r.jsx("p",{className:"text-cc-muted text-sm",children:"File not found on disk"}),r.jsx("p",{className:"text-cc-muted text-xs",children:"The file may have been deleted or the write was not executed."})]}):y==="raw"?O?r.jsx("div",{className:"markdown-body text-[12px] text-cc-fg leading-[1.7]",children:r.jsx(V0,{remarkPlugins:[K0],children:O})}):r.jsx("p",{className:"text-cc-muted text-sm",children:"No diff content returned."}):r.jsx(br,{unifiedDiff:f,fileName:M||void 0,mode:"full"})}):r.jsxs("div",{className:"h-full flex flex-col items-center justify-center",children:[!L&&r.jsxs("button",{onClick:()=>Q(!0),className:"mb-4 flex items-center gap-2 px-3 py-2 rounded-lg text-xs text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M1 3.5A1.5 1.5 0 012.5 2h3.379a1.5 1.5 0 011.06.44l.622.621a.5.5 0 00.353.146H13.5A1.5 1.5 0 0115 4.707V12.5a1.5 1.5 0 01-1.5 1.5h-11A1.5 1.5 0 011 12.5v-9z"})}),"Show file list"]}),r.jsx("p",{className:"text-cc-muted text-sm",children:"Select a file to view changes"})]})})]})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:r.jsx("p",{className:"text-cc-muted text-sm",children:"Waiting for session to initialize..."})})}const Iz=w.lazy(()=>Xi(()=>Promise.resolve().then(()=>hu),void 0).then(e=>({default:e.CodeEditor}))),Fz=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp"]);function kx(e){var s;const t=((s=e.split(".").pop())==null?void 0:s.toLowerCase())||"";return Fz.has(t)}function Hz({sessionId:e}){const t=G(I=>I.sessions.get(e)),s=G(I=>I.sdkSessions.find(R=>R.sessionId===e)),n=G(I=>I.changedFiles.get(e)),a=(t==null?void 0:t.cwd)||(s==null?void 0:s.cwd)||"",[l,c]=w.useState({expanded:new Set,children:new Map,loading:new Set}),[d,f]=w.useState(null),[h,m]=w.useState(""),[g,_]=w.useState(""),[v,y]=w.useState(!1),[S,j]=w.useState(!1),[k,N]=w.useState(!1),[E,B]=w.useState(!1),[F,$]=w.useState(""),[K,Y]=w.useState(!1),[W,L]=w.useState(!0),Q=w.useMemo(()=>n??new Set,[n]);w.useEffect(()=>{a&&V(a)},[a,K]);function V(I){c(R=>{const P=new Set(R.loading);return P.add(I),{...R,loading:P}}),ne.listEntries(I,K).then(R=>{const P=[...R.entries].sort((z,T)=>z.type!==T.type?z.type==="directory"?-1:1:z.name.localeCompare(T.name));c(z=>{const T=new Map(z.children);T.set(I,P);const oe=new Set(z.loading);return oe.delete(I),{...z,children:T,loading:oe}})}).catch(()=>{c(R=>{const P=new Set(R.loading);return P.delete(I),{...R,loading:P}})})}function X(I){c(R=>{const P=new Set(R.expanded);return P.has(I)?P.delete(I):(P.add(I),R.children.has(I)||V(I)),{...R,expanded:P}})}w.useEffect(()=>{if(!d||kx(d))return;let I=!1;return y(!0),j(!1),B(!1),ne.readFile(d).then(R=>{I||(m(R.content),_(R.content),y(!1))}).catch(()=>{I||(m(""),_(""),y(!1))}),()=>{I=!0}},[d]);const q=w.useCallback(async()=>{if(!(!d||k)){N(!0);try{await ne.writeFile(d,h),_(h),j(!1),B(!0),setTimeout(()=>B(!1),2e3)}catch{}N(!1)}},[d,h,k]),A=w.useCallback(()=>{m(g),j(!1)},[g]),M=w.useCallback(I=>{S&&!globalThis.confirm("Discard unsaved changes?")||(f(I),globalThis.innerWidth<640&&L(!1))},[S]),O=F.toLowerCase();if(!a)return r.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:r.jsx("p",{className:"text-cc-muted text-sm",children:"Waiting for session to initialize..."})});const U=(d==null?void 0:d.split("/").pop())||"";return r.jsxs("div",{className:"h-full flex bg-cc-bg relative",children:[W&&r.jsx("button",{className:"fixed inset-0 bg-black/30 z-20 sm:hidden cursor-default border-none",onClick:()=>L(!1),"aria-label":"Close file tree",tabIndex:-1}),r.jsxs("div",{className:`${W?"w-[240px] translate-x-0":"w-0 -translate-x-full"} fixed sm:relative z-30 sm:z-auto shrink-0 h-full flex flex-col bg-cc-sidebar border-r border-cc-border transition-all duration-200 overflow-hidden`,children:[r.jsxs("div",{className:"w-[240px] shrink-0",children:[r.jsxs("div",{className:"px-3 py-2.5 border-b border-cc-border flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] font-semibold text-cc-fg uppercase tracking-wider flex-1",children:"Files"}),r.jsx("button",{onClick:()=>Y(I=>!I),title:K?"Hide dotfiles":"Show dotfiles",className:`w-5 h-5 flex items-center justify-center rounded text-[10px] cursor-pointer transition-colors ${K?"text-cc-primary bg-cc-primary/10":"text-cc-muted/40 hover:text-cc-muted"}`,children:".*"}),r.jsx("button",{onClick:()=>V(a),title:"Refresh",className:"w-5 h-5 flex items-center justify-center rounded text-cc-muted/50 hover:text-cc-muted cursor-pointer",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3","aria-hidden":!0,children:r.jsx("path",{d:"M1.705 8.005a.75.75 0 01.834.656 5.5 5.5 0 009.592 2.97l-1.204-1.204a.25.25 0 01.177-.427h3.646a.25.25 0 01.25.25v3.646a.25.25 0 01-.427.177l-1.38-1.38A7.002 7.002 0 011.05 8.84a.75.75 0 01.656-.834zM8 2.5a5.487 5.487 0 00-4.131 1.869l1.204 1.204A.25.25 0 014.896 6H1.25A.25.25 0 011 5.75V2.104a.25.25 0 01.427-.177l1.38 1.38A7.002 7.002 0 0114.95 7.16a.75.75 0 11-1.49.178A5.5 5.5 0 008 2.5z"})})})]}),r.jsx("div",{className:"px-3 py-2 border-b border-cc-border",children:r.jsx("input",{value:F,onChange:I=>$(I.target.value),placeholder:"Filter files...",className:"w-full h-7 px-2 rounded-md border border-cc-border bg-cc-input-bg text-[11px] text-cc-fg placeholder:text-cc-muted/30 focus:outline-none focus:ring-1 focus:ring-cc-primary/30"})})]}),r.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden py-1 w-[240px]",children:r.jsx(NC,{parentPath:a,tree:l,filter:O,changedFiles:Q,selectedFile:d,onToggleDir:X,onSelectFile:M,depth:0})})]}),r.jsxs("div",{className:"flex-1 min-w-0 h-full flex flex-col",children:[d&&r.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3 py-2.5 bg-cc-card border-b border-cc-border",children:[!W&&r.jsx("button",{onClick:()=>L(!0),className:"w-6 h-6 flex items-center justify-center rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-hover cursor-pointer shrink-0",title:"Show file tree",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5","aria-hidden":!0,children:r.jsx("path",{d:"M1 3.5A1.5 1.5 0 012.5 2h3.379a1.5 1.5 0 011.06.44l.622.621a.5.5 0 00.353.146H13.5A1.5 1.5 0 0115 4.707V12.5a1.5 1.5 0 01-1.5 1.5h-11A1.5 1.5 0 011 12.5v-9z"})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-[13px] font-medium text-cc-fg truncate block",children:U}),r.jsx("span",{className:"text-[10px] text-cc-muted font-mono-code truncate block",children:d.replace(a+"/","")})]}),!kx(d)&&r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[S&&!E&&r.jsx("span",{className:"text-[10px] text-cc-warning",children:"Unsaved"}),E&&r.jsx("span",{className:"text-[10px] text-cc-success",children:"Saved"}),S&&r.jsx("button",{onClick:A,className:"px-3 py-1 rounded-md text-[11px] font-medium text-cc-muted hover:text-cc-fg hover:bg-cc-hover cursor-pointer transition-colors",children:"Cancel"}),r.jsx("button",{onClick:q,disabled:k||!S,className:"px-3 py-1 rounded-md bg-cc-primary text-white text-[11px] font-medium hover:bg-cc-primary-hover cursor-pointer disabled:opacity-40 transition-colors",children:k?"Saving...":"Save"})]})]}),r.jsx("div",{className:"flex-1 overflow-auto",children:r.jsx(Uz,{selectedFile:d,selectedName:U,fileLoading:v,fileContent:h,onContentChange:I=>{m(I),j(!0)}})})]})]})}function Uz({selectedFile:e,selectedName:t,fileLoading:s,fileContent:n,onContentChange:a}){return e?s?r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx("div",{className:"w-5 h-5 border-2 border-cc-primary border-t-transparent rounded-full animate-spin"})}):kx(e)?r.jsx("div",{className:"h-full flex items-center justify-center p-8 bg-cc-bg",children:r.jsx("img",{src:`/api/fs/read-raw?path=${encodeURIComponent(e)}`,alt:t,className:"max-w-full max-h-full object-contain rounded-lg shadow-panel"})}):r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"h-full flex items-center justify-center text-cc-muted text-[12px]",children:"Loading editor..."}),children:r.jsx(Iz,{value:n,onChange:a,language:tv(e),height:"calc(100vh - 120px)",minimap:!0,lineNumbers:!0,wordWrap:!1,ariaLabel:`Editing ${t}`,className:"border-0 rounded-none"})}):r.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-3 select-none px-6",children:[r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-8 h-8 text-cc-muted/40","aria-hidden":!0,children:[r.jsx("path",{d:"M13 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V9l-7-7z",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("polyline",{points:"13 2 13 9 20 9",strokeLinecap:"round",strokeLinejoin:"round"})]}),r.jsx("p",{className:"text-sm text-cc-muted",children:"Select a file to view or edit"})]})}function NC({parentPath:e,tree:t,filter:s,changedFiles:n,selectedFile:a,onToggleDir:l,onSelectFile:c,depth:d}){const f=t.children.get(e);if(t.loading.has(e)&&!f)return r.jsx("div",{className:"px-3 py-1 text-[10px] text-cc-muted",style:{paddingLeft:12+d*16},children:"Loading..."});if(!f)return null;const m=s?f.filter(g=>g.name.toLowerCase().includes(s)):f;return r.jsx(r.Fragment,{children:m.map(g=>{const _=g.type==="directory",v=t.expanded.has(g.path),y=g.path===a,S=n.has(g.path);return _?r.jsxs("div",{children:[r.jsxs("button",{onClick:()=>l(g.path),className:"flex items-center gap-1.5 w-full px-2 py-1 text-[12px] text-cc-fg/80 hover:bg-cc-hover transition-colors cursor-pointer",style:{paddingLeft:8+d*16},children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 text-cc-muted/50 shrink-0 transition-transform duration-150 ${v?"rotate-90":""}`,"aria-hidden":!0,children:r.jsx("path",{d:"M6 4l4 4-4 4V4z"})}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-warning/60 shrink-0","aria-hidden":!0,children:r.jsx("path",{d:"M1 3.5A1.5 1.5 0 012.5 2h3.379a1.5 1.5 0 011.06.44l.622.621a.5.5 0 00.353.146H13.5A1.5 1.5 0 0115 4.707V12.5a1.5 1.5 0 01-1.5 1.5h-11A1.5 1.5 0 011 12.5v-9z"})}),r.jsx("span",{className:"truncate",children:g.name})]}),v&&r.jsx(NC,{parentPath:g.path,tree:t,filter:s,changedFiles:n,selectedFile:a,onToggleDir:l,onSelectFile:c,depth:d+1})]},g.path):r.jsxs("button",{onClick:()=>c(g.path),className:`flex items-center gap-1.5 w-full px-2 py-1 text-[12px] transition-colors cursor-pointer ${y?"bg-cc-active text-cc-fg":"text-cc-fg/70 hover:bg-cc-hover"}`,style:{paddingLeft:8+d*16+16},children:[S?r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cc-warning shrink-0",title:"Modified by agent"}):r.jsx("span",{className:"w-1.5 h-1.5 shrink-0"}),r.jsx("span",{className:`truncate ${S?"text-cc-warning":""}`,children:g.name})]},g.path)})})}function EC(){const e=G(h=>h.updateInfo),t=G(h=>h.updateDismissedVersion),s=G(h=>h.dismissUpdate),n=G(h=>h.setUpdateOverlayActive),[a,l]=w.useState(!1);if(!(e!=null&&e.updateAvailable)||!e.latestVersion||t===e.latestVersion)return null;const c=async()=>{l(!0);try{await ne.triggerUpdate(),n(!0)}catch(h){console.error("Update failed:",h),l(!1)}},d=()=>{s(e.latestVersion)},f=a||e.updateInProgress;return r.jsxs("div",{className:"px-4 py-1.5 bg-cc-primary/10 border-b border-cc-primary/20 flex items-center justify-center gap-3 animate-[fadeSlideIn_0.2s_ease-out]",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-primary shrink-0",children:r.jsx("path",{d:"M8 1a7 7 0 1 1 0 14A7 7 0 0 1 8 1zm0 2a.75.75 0 0 0-.75.75v3.69L5.78 6.15a.75.75 0 0 0-.96 1.15l2.5 2.08a.75.75 0 0 0 1.08-.12l2-2.5a.75.75 0 1 0-1.17-.94L8.75 6.5V3.75A.75.75 0 0 0 8 3z"})}),r.jsxs("span",{className:"text-xs text-cc-fg",children:[r.jsxs("span",{className:"font-medium",children:["v",e.latestVersion]})," available",r.jsxs("span",{className:"text-cc-muted ml-1",children:["(current: v",e.currentVersion,")"]})]}),e.isServiceMode?r.jsx("button",{onClick:c,disabled:f,className:"text-xs font-medium px-2.5 py-0.5 rounded-md bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:f?"Updating...":"Update & Restart"}):r.jsxs("span",{className:"text-xs text-cc-muted",children:["Run"," ",r.jsx("code",{className:"font-mono-code bg-cc-code-bg px-1 py-0.5 rounded text-cc-code-fg",children:"the-campfire install"})," ","for auto-updates"]}),r.jsx("button",{onClick:d,className:"text-cc-muted hover:text-cc-fg transition-colors cursor-pointer ml-auto",title:"Dismiss",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3 h-3",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})})})]})}function Vz(e){if(e<6e4)return`${Math.round(e/1e3)}s`;const t=Math.floor(e/6e4);if(t<60)return`${t}m`;const s=Math.floor(t/60),n=t%60;return n>0?`${s}h ${n}m`:`${s}h`}function Wz(e){return e===0?"$0":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function qz(e){const t=Date.now()-e,s=Math.floor(t/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const n=Math.floor(s/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}const Gz={claude:"text-[#5BA8A0] bg-[#5BA8A0]/10 border-[#5BA8A0]/20",codex:"text-blue-500 bg-blue-500/10 border-blue-500/20",goose:"text-amber-600 bg-amber-500/10 border-amber-500/20",aider:"text-purple-500 bg-purple-500/10 border-purple-500/20",openhands:"text-rose-500 bg-rose-500/10 border-rose-500/20",openclaw:"text-orange-500 bg-orange-500/10 border-orange-500/20"};function ih({entry:e,onVote:t,onDelete:s,onFeature:n,onExportClawHub:a,clawHubAvailable:l,onPostMoltbook:c,moltbookAvailable:d,onCreatePublicLink:f}){const[h,m]=w.useState(null),[g,_]=w.useState(!1);async function v(S){if(!h){m(S);try{t(e.id,S)}finally{m(null)}}}const y=Gz[e.backendType]||"text-cc-fg/60 bg-cc-hover border-cc-border/40";return r.jsxs("div",{className:"rounded-xl border border-cc-border/60 bg-cc-card hover:border-cc-border transition-all duration-200 overflow-hidden group",children:[r.jsx("div",{className:"px-5 py-4",children:r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsxs("div",{className:"flex flex-col items-center gap-0.5 pt-0.5 shrink-0",children:[r.jsx("button",{onClick:()=>v(1),disabled:h!==null,className:"w-7 h-6 flex items-center justify-center rounded-md text-cc-fg/35 hover:text-cc-primary hover:bg-cc-primary/5 transition-colors cursor-pointer disabled:opacity-50",title:"Upvote","aria-label":"Upvote",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4",children:r.jsx("path",{d:"M8 4l4 5H4l4-5z"})})}),r.jsx("span",{className:`text-[13px] font-bold tabular-nums leading-none ${e.votes>0?"text-cc-primary":e.votes<0?"text-cc-error":"text-cc-fg/40"}`,children:e.votes}),r.jsx("button",{onClick:()=>v(-1),disabled:h!==null,className:"w-7 h-6 flex items-center justify-center rounded-md text-cc-fg/35 hover:text-cc-error hover:bg-cc-error/5 transition-colors cursor-pointer disabled:opacity-50",title:"Downvote","aria-label":"Downvote",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4",children:r.jsx("path",{d:"M8 12l4-5H4l4 5z"})})})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[e.featured&&r.jsx("span",{className:"text-amber-500 shrink-0",title:"Featured",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4",children:r.jsx("path",{d:"M8 1.5l2.09 4.26 4.66.68-3.38 3.28.8 4.64L8 12.17l-4.17 2.19.8-4.64-3.38-3.28 4.66-.68L8 1.5z"})})}),r.jsx("h3",{className:"text-[14px] font-semibold text-cc-fg truncate",children:e.name}),r.jsx("span",{className:"text-[11px] text-cc-fg/40 shrink-0 ml-auto",children:qz(e.createdAt)})]}),e.description&&r.jsx("p",{className:"mt-1 text-[12px] text-cc-fg/55 line-clamp-2 leading-relaxed",children:e.description}),r.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-3",children:[r.jsx("span",{className:`text-[10px] font-semibold px-2 py-0.5 rounded-full border ${y}`,children:e.backendType}),e.model&&r.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-cc-hover/70 text-cc-fg/55 border border-cc-border/30 truncate max-w-[140px]",children:e.model}),e.totalCostUsd>0&&r.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-cc-hover/70 text-cc-fg/55 border border-cc-border/30",children:Wz(e.totalCostUsd)}),e.numTurns>0&&r.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-cc-hover/70 text-cc-fg/55 border border-cc-border/30",children:[e.numTurns," turns"]}),e.durationMs>0&&r.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-cc-hover/70 text-cc-fg/55 border border-cc-border/30",children:Vz(e.durationMs)}),(e.totalLinesAdded>0||e.totalLinesRemoved>0)&&r.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-cc-hover/70 border border-cc-border/30",children:[r.jsxs("span",{className:"text-green-500",children:["+",e.totalLinesAdded]}),r.jsx("span",{className:"text-cc-fg/30 mx-0.5",children:"/"}),r.jsxs("span",{className:"text-red-500",children:["-",e.totalLinesRemoved]})]})]}),e.tags.length>0&&r.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2.5",children:e.tags.map(S=>r.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-cc-primary/5 text-cc-primary/70 border border-cc-primary/10",children:["#",S]},S))})]})]})}),r.jsxs("div",{className:"flex items-center justify-between px-5 py-2.5 border-t border-cc-border/30 bg-cc-bg/50",children:[r.jsxs("a",{href:`#/replay/session/${e.sessionId}`,className:"inline-flex items-center gap-1.5 text-[11px] font-medium text-cc-primary hover:text-cc-primary-hover transition-colors",title:"Watch replay",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M4.5 3.5A.5.5 0 015.22 3l7 4.5a.5.5 0 010 .86l-7 4.5A.5.5 0 014.5 12.5v-9z"})}),"Watch Replay"]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[n&&r.jsx("button",{onClick:()=>n(e.id),className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors cursor-pointer ${e.featured?"text-amber-500 bg-amber-500/10":"text-cc-fg/30 hover:text-amber-500 hover:bg-amber-500/5"}`,title:e.featured?"Unfeature":"Feature","aria-label":e.featured?"Unfeature":"Feature",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M8 1.5l2.09 4.26 4.66.68-3.38 3.28.8 4.64L8 12.17l-4.17 2.19.8-4.64-3.38-3.28 4.66-.68L8 1.5z"})})}),a&&l&&r.jsx("button",{onClick:()=>a(e.id),className:"w-7 h-7 flex items-center justify-center rounded-lg text-cc-fg/30 hover:text-orange-500 hover:bg-orange-500/5 transition-colors cursor-pointer",title:"Export to ClawHub","aria-label":"Export to ClawHub",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M7 1h8v8M15 1L8 8M6 3H2v11h11v-4",strokeLinecap:"round",strokeLinejoin:"round"})})}),c&&d&&r.jsx("button",{onClick:()=>c(e.id),className:"w-7 h-7 flex items-center justify-center rounded-lg text-cc-fg/30 hover:text-violet-500 hover:bg-violet-500/5 transition-colors cursor-pointer",title:"Post to Moltbook","aria-label":"Post to Moltbook",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M8 0a8 8 0 110 16A8 8 0 018 0zm0 2a1.5 1.5 0 00-1.5 1.5v3.793l-1.146-1.147a1.5 1.5 0 00-2.122 2.122l3.5 3.5a1.5 1.5 0 002.122 0l3.5-3.5a1.5 1.5 0 00-2.122-2.122L9.5 7.293V3.5A1.5 1.5 0 008 2z"})})}),f&&r.jsx("button",{onClick:()=>f(e.id),className:"w-7 h-7 flex items-center justify-center rounded-lg text-cc-fg/30 hover:text-cc-primary hover:bg-cc-primary/5 transition-colors cursor-pointer",title:"Copy public link","aria-label":"Copy public replay link",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:[r.jsx("path",{d:"M4.715 6.542L3.343 7.914a3 3 0 104.243 4.243l1.828-1.829A3 3 0 008.586 5.5L8 6.086a1.002 1.002 0 00-.154.199 2 2 0 01.861 3.337L6.88 11.45a2 2 0 11-2.83-2.83l.793-.792a4.018 4.018 0 01-.128-1.287z"}),r.jsx("path",{d:"M11.285 9.458l1.372-1.372a3 3 0 10-4.243-4.243L6.586 5.672A3 3 0 007.414 10.5l.586-.586a1.002 1.002 0 00.154-.199 2 2 0 01-.861-3.337L9.12 4.55a2 2 0 112.83 2.83l-.793.792c.112.42.155.855.128 1.287z"})]})}),s&&!g&&r.jsx("button",{onClick:()=>_(!0),className:"w-7 h-7 flex items-center justify-center rounded-lg text-cc-fg/30 hover:text-cc-error hover:bg-cc-error/5 transition-colors cursor-pointer",title:"Delete","aria-label":"Delete",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M3 4h10M5.5 4V2.5h5V4M6 6.5v5M10 6.5v5M4.5 4l.5 9.5h6l.5-9.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),s&&g&&r.jsxs("div",{className:"flex items-center gap-1 ml-1",children:[r.jsx("button",{onClick:()=>_(!1),className:"px-2 py-1 rounded-md text-[10px] font-medium text-cc-fg/50 hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Cancel"}),r.jsx("button",{onClick:()=>{s(e.id),_(!1)},className:"px-2 py-1 rounded-md text-[10px] font-medium bg-cc-error text-white hover:bg-cc-error/90 transition-colors cursor-pointer",children:"Delete"})]})]})]})]})}const Ys="playground-session";function vn(e){return{request_id:`perm-${Math.random().toString(36).slice(2,8)}`,tool_use_id:`tu-${Math.random().toString(36).slice(2,8)}`,timestamp:Date.now(),...e}}const K5=vn({tool_name:"Bash",input:{command:"git log --oneline -20 && npm run build",description:"View recent commits and build the project"},permission_suggestions:[{type:"addRules",rules:[{toolName:"Bash",ruleContent:"git log --oneline -20 && npm run build"}],behavior:"allow",destination:"session"},{type:"addRules",rules:[{toolName:"Bash",ruleContent:"git log --oneline -20 && npm run build"}],behavior:"allow",destination:"projectSettings"}]}),Kz=vn({tool_name:"Edit",input:{file_path:"/Users/stan/Dev/project/src/utils/format.ts",old_string:`export function formatDate(d: Date) {
129
+ return d.toISOString();
130
+ }`,new_string:`export function formatDate(d: Date, locale = "en-US") {
131
+ return d.toLocaleDateString(locale, {
132
+ year: "numeric",
133
+ month: "short",
134
+ day: "numeric",
135
+ });
136
+ }`},permission_suggestions:[{type:"addRules",rules:[{toolName:"Edit"}],behavior:"allow",destination:"session"}]}),Yz=vn({tool_name:"Write",input:{file_path:"/Users/stan/Dev/project/src/config.ts",content:`export const config = {
137
+ apiUrl: "https://api.example.com",
138
+ timeout: 5000,
139
+ retries: 3,
140
+ debug: process.env.NODE_ENV !== "production",
141
+ };
142
+ `}}),Xz=vn({tool_name:"Read",input:{file_path:"/Users/stan/Dev/project/package.json"},permission_suggestions:[{type:"addRules",rules:[{toolName:"Read"}],behavior:"allow",destination:"session"},{type:"addRules",rules:[{toolName:"Read"}],behavior:"allow",destination:"userSettings"}]}),Jz=vn({tool_name:"Glob",input:{pattern:"**/*.test.ts",path:"/Users/stan/Dev/project/src"}}),Qz=vn({tool_name:"Grep",input:{pattern:"TODO|FIXME|HACK",path:"/Users/stan/Dev/project/src",glob:"*.ts"}}),Zz=vn({tool_name:"ExitPlanMode",input:{plan:`## Summary
143
+ Refactor the authentication module to use JWT tokens instead of session cookies.
144
+
145
+ ## Changes
146
+ 1. **Add JWT utility** — new \`src/auth/jwt.ts\` with sign/verify helpers
147
+ 2. **Update middleware** — modify \`src/middleware/auth.ts\` to validate Bearer tokens
148
+ 3. **Migrate login endpoint** — return JWT in response body instead of Set-Cookie
149
+ 4. **Update tests** — adapt all auth tests to use token-based flow
150
+
151
+ ## Test plan
152
+ - Run \`npm test -- --grep auth\`
153
+ - Manual test with curl`,allowedPrompts:[{tool:"Bash",prompt:"run tests"},{tool:"Bash",prompt:"install dependencies"}]}}),eP=vn({tool_name:"WebSearch",input:{query:"TypeScript 5.5 new features",allowed_domains:["typescriptlang.org","github.com"]},description:"Search the web for TypeScript 5.5 features"}),Y5=vn({tool_name:"dynamic:code_interpreter",input:{code:"print('hello from dynamic tool')"},description:"Custom tool call: code_interpreter"}),tP=vn({tool_name:"AskUserQuestion",input:{questions:[{header:"Auth method",question:"Which authentication method should we use for the API?",options:[{label:"JWT tokens (Recommended)",description:"Stateless, scalable, works well with microservices"},{label:"Session cookies",description:"Traditional approach, simpler but requires session storage"},{label:"OAuth 2.0",description:"Delegated auth, best for third-party integrations"}],multiSelect:!1}]}}),sP=vn({tool_name:"AskUserQuestion",input:{questions:[{header:"Database",question:"Which database should we use?",options:[{label:"PostgreSQL",description:"Relational, strong consistency"},{label:"MongoDB",description:"Document store, flexible schema"}],multiSelect:!1},{header:"Cache",question:"Do you want to add a caching layer?",options:[{label:"Redis",description:"In-memory, fast, supports pub/sub"},{label:"No cache",description:"Keep it simple for now"}],multiSelect:!1}]}}),X5={id:"msg-1",role:"user",content:"Can you help me refactor the authentication module to use JWT tokens?",timestamp:Date.now()-6e4},nP={id:"msg-2",role:"user",content:"Here's a screenshot of the error I'm seeing",images:[{media_type:"image/png",data:"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg=="}],timestamp:Date.now()-55e3},ug={id:"msg-3",role:"assistant",content:"",contentBlocks:[{type:"text",text:`I'll help you refactor the authentication module. Let me first look at the current implementation.
154
+
155
+ Here's what I found:
156
+ - The current auth uses **session cookies** via \`express-session\`
157
+ - Sessions are stored in a \`MemoryStore\` (not production-ready)
158
+ - The middleware checks \`req.session.userId\`
159
+
160
+ \`\`\`typescript
161
+ // Current implementation
162
+ app.use(session({
163
+ secret: process.env.SESSION_SECRET,
164
+ resave: false,
165
+ saveUninitialized: false,
166
+ }));
167
+ \`\`\`
168
+
169
+ | Feature | Cookies | JWT |
170
+ |---------|---------|-----|
171
+ | Stateless | No | Yes |
172
+ | Scalable | Limited | Excellent |
173
+ | Revocation | Easy | Needs blocklist |
174
+ `}],timestamp:Date.now()-5e4},J5={id:"msg-4",role:"assistant",content:"",contentBlocks:[{type:"text",text:"Let me check the current auth files."},{type:"tool_use",id:"tu-1",name:"Glob",input:{pattern:"src/auth/**/*.ts"}},{type:"tool_result",tool_use_id:"tu-1",content:`src/auth/middleware.ts
175
+ src/auth/login.ts
176
+ src/auth/session.ts`},{type:"tool_use",id:"tu-2",name:"Read",input:{file_path:"src/auth/middleware.ts"}},{type:"tool_result",tool_use_id:"tu-2",content:`export function authMiddleware(req, res, next) {
177
+ if (!req.session.userId) {
178
+ return res.status(401).json({ error: "Unauthorized" });
179
+ }
180
+ next();
181
+ }`},{type:"text",text:"Now I understand the current structure. Let me create the JWT utility."}],timestamp:Date.now()-45e3},rP={id:"msg-5",role:"assistant",content:"",contentBlocks:[{type:"thinking",thinking:`Let me think about the best approach here. The user wants to migrate from session cookies to JWT. I need to:
182
+ 1. Create a JWT sign/verify utility
183
+ 2. Update the middleware to read Authorization header
184
+ 3. Change the login endpoint to return a token
185
+ 4. Update all tests
186
+
187
+ I should use jsonwebtoken package for signing and jose for verification in edge environments. But since this is a Node.js server, jsonwebtoken is fine.
188
+
189
+ The token should contain: userId, role, iat, exp. Expiry should be configurable. I'll also add a refresh token mechanism.`},{type:"text",text:"I've analyzed the codebase and have a clear plan. Let me start implementing."}],timestamp:Date.now()-4e4},iP={id:"msg-6",role:"system",content:"Context compacted successfully",timestamp:Date.now()-3e4},Q5={id:"msg-7",role:"assistant",content:"",contentBlocks:[{type:"text",text:"Let me try running the tests."},{type:"tool_use",id:"tu-3",name:"Bash",input:{command:"npm test -- --grep auth"}},{type:"tool_result",tool_use_id:"tu-3",content:`FAIL src/auth/__tests__/middleware.test.ts
190
+ ● Auth Middleware › should reject expired tokens
191
+ Expected: 401
192
+ Received: 500
193
+
194
+ TypeError: Cannot read property 'verify' of undefined`,is_error:!0},{type:"text",text:"There's a test failure. Let me fix the issue."}],timestamp:Date.now()-2e4},Z5=[{id:"1",subject:"Create JWT utility module",description:"",status:"completed"},{id:"2",subject:"Update auth middleware",description:"",status:"completed",activeForm:"Updating auth middleware"},{id:"3",subject:"Migrate login endpoint",description:"",status:"in_progress",activeForm:"Refactoring login to return JWT"},{id:"4",subject:"Add refresh token support",description:"",status:"pending"},{id:"5",subject:"Update all auth tests",description:"",status:"pending",blockedBy:["3"]},{id:"6",subject:"Run full test suite and fix failures",description:"",status:"pending",blockedBy:["5"]}],aP=[{id:"tg-1",name:"Read",input:{file_path:"src/auth/middleware.ts"}},{id:"tg-2",name:"Read",input:{file_path:"src/auth/login.ts"}},{id:"tg-3",name:"Read",input:{file_path:"src/auth/session.ts"}},{id:"tg-4",name:"Read",input:{file_path:"src/auth/types.ts"}}],oP=[{id:"sa-1",name:"Grep",input:{pattern:"useAuth",path:"src/"}},{id:"sa-2",name:"Grep",input:{pattern:"session.userId",path:"src/"}}],lP={number:162,title:"feat: add dark mode toggle to application settings",url:"https://github.com/example/project/pull/162",state:"OPEN",isDraft:!1,reviewDecision:"CHANGES_REQUESTED",additions:91,deletions:88,changedFiles:24,checks:[{name:"CI / Build",status:"COMPLETED",conclusion:"SUCCESS"},{name:"CI / Test",status:"COMPLETED",conclusion:"FAILURE"},{name:"CI / Lint",status:"COMPLETED",conclusion:"SUCCESS"}],checksSummary:{total:3,success:2,failure:1,pending:0},reviewThreads:{total:4,resolved:2,unresolved:2}},cP={number:158,title:"fix: prevent mobile keyboard layout shift and iOS zoom",url:"https://github.com/example/project/pull/158",state:"OPEN",isDraft:!1,reviewDecision:"APPROVED",additions:42,deletions:12,changedFiles:3,checks:[{name:"CI / Build",status:"COMPLETED",conclusion:"SUCCESS"},{name:"CI / Test",status:"COMPLETED",conclusion:"SUCCESS"}],checksSummary:{total:2,success:2,failure:0,pending:0},reviewThreads:{total:1,resolved:1,unresolved:0}},uP={number:165,title:"refactor: migrate auth module to JWT tokens with refresh support",url:"https://github.com/example/project/pull/165",state:"OPEN",isDraft:!0,reviewDecision:null,additions:340,deletions:156,changedFiles:18,checks:[{name:"CI / Build",status:"IN_PROGRESS",conclusion:null},{name:"CI / Test",status:"QUEUED",conclusion:null}],checksSummary:{total:2,success:0,failure:0,pending:2},reviewThreads:{total:0,resolved:0,unresolved:0}},dP={number:155,title:"feat(cli): add service install/uninstall and separate dev/prod ports",url:"https://github.com/example/project/pull/155",state:"MERGED",isDraft:!1,reviewDecision:"APPROVED",additions:287,deletions:63,changedFiles:11,checks:[{name:"CI / Build",status:"COMPLETED",conclusion:"SUCCESS"},{name:"CI / Test",status:"COMPLETED",conclusion:"SUCCESS"},{name:"CI / Lint",status:"COMPLETED",conclusion:"SUCCESS"}],checksSummary:{total:3,success:3,failure:0,pending:0},reviewThreads:{total:3,resolved:3,unresolved:0}},hP={id:"auth-refactor",sessionId:"sess-abc-123",name:"Auth System Refactor",description:"Migrated from cookie-based auth to JWT with refresh tokens. Full test coverage included.",tags:["auth","jwt","refactor"],featured:!0,votes:24,createdAt:Date.now()-864e5*3,updatedAt:Date.now()-864e5*2,backendType:"claude",model:"claude-opus-4-6",totalCostUsd:1.45,durationMs:18e5,totalLinesAdded:542,totalLinesRemoved:218,numTurns:28},fP={id:"api-tests",sessionId:"sess-def-456",name:"API Integration Tests",description:"Added comprehensive integration tests for all REST endpoints.",tags:["testing","api"],featured:!1,votes:7,createdAt:Date.now()-864e5,updatedAt:Date.now()-864e5,backendType:"claude",model:"claude-sonnet-4-5-20250929",totalCostUsd:.38,durationMs:6e5,totalLinesAdded:890,totalLinesRemoved:12,numTurns:12},pP={id:"quick-bugfix",sessionId:"sess-ghi-789",name:"Fix Race Condition",description:"Fixed async race condition in the event queue.",tags:["bugfix"],featured:!1,votes:-2,createdAt:Date.now()-36e5,updatedAt:Date.now()-36e5,backendType:"codex",model:"gpt-5.3-codex",totalCostUsd:.02,durationMs:45e3,totalLinesAdded:8,totalLinesRemoved:3,numTurns:3},mP=[{name:"filesystem",status:"connected",config:{type:"stdio",command:"npx",args:["-y","@anthropic/mcp-fs"]},scope:"project",tools:[{name:"read_file",annotations:{readOnly:!0}},{name:"write_file",annotations:{destructive:!0}},{name:"list_directory",annotations:{readOnly:!0}}]},{name:"github",status:"connected",config:{type:"stdio",command:"npx",args:["-y","@anthropic/mcp-github"]},scope:"user",tools:[{name:"create_issue"},{name:"list_prs",annotations:{readOnly:!0}},{name:"create_pr"}]},{name:"postgres",status:"failed",error:"Connection refused: ECONNREFUSED 127.0.0.1:5432",config:{type:"stdio",command:"npx",args:["-y","@anthropic/mcp-postgres"]},scope:"project",tools:[]},{name:"web-search",status:"disabled",config:{type:"sse",url:"http://localhost:8080/sse"},scope:"user",tools:[{name:"search",annotations:{readOnly:!0,openWorld:!0}}]},{name:"docker",status:"connecting",config:{type:"stdio",command:"docker-mcp-server"},scope:"project",tools:[]}],dg=[{id:"v-1",name:"Alice",role:"owner"},{id:"v-2",name:"Bob",role:"collaborator"},{id:"v-3",name:"Carol",role:"spectator"}],gP=[{viewerId:"v-1",viewerName:"Alice",vote:"allow",timestamp:Date.now()-5e3},{viewerId:"v-2",viewerName:"Bob",vote:"deny",timestamp:Date.now()-3e3}],e2=vn({tool_name:"Bash",input:{command:"rm -rf node_modules && npm install",description:"Clean reinstall dependencies"}}),t2=vn({tool_name:"Write",input:{file_path:"src/config.ts",content:"export default {}"}}),xP=vn({tool_name:"Bash",input:{command:"npm test",description:"Run tests"}});function vP(){const[e,t]=w.useState(()=>document.documentElement.classList.contains("dark"));return w.useEffect(()=>{document.documentElement.classList.toggle("dark",e)},[e]),w.useEffect(()=>{const s=G.getState(),n=G.getState(),a=Ys,l=n.sessions.get(a),c=n.messages.get(a),d=n.pendingPermissions.get(a),f=n.connectionStatus.get(a),h=n.cliConnected.get(a),m=n.sessionStatus.get(a),g=n.streaming.get(a),_=n.streamingStartedAt.get(a),v=n.streamingOutputTokens.get(a),y={session_id:a,backend_type:"claude",model:"claude-sonnet-4-5",cwd:"/Users/stan/Dev/project",tools:["Bash","Read","Edit","Write","Glob","Grep","WebSearch"],permissionMode:"default",claude_code_version:"1.0.0",mcp_servers:[],agents:[],slash_commands:["explain","review","fix"],skills:["doc-coauthoring","frontend-design"],total_cost_usd:.1847,num_turns:14,context_used_percent:62,is_compacting:!1,git_branch:"feat/jwt-auth",is_worktree:!0,repo_root:"/Users/stan/Dev/project",git_ahead:3,git_behind:0,total_lines_added:142,total_lines_removed:38,total_duration_api_ms:0};return s.addSession(y),s.setConnectionStatus(a,"connected"),s.setCliConnected(a,!0),s.setSessionStatus(a,"running"),s.setMessages(a,[X5,ug,J5,Q5]),s.setStreaming(a,"I'm updating tests and then I'll run the full suite."),s.setStreamingStats(a,{startedAt:Date.now()-12e3,outputTokens:1200}),s.addPermission(a,K5),s.addPermission(a,Y5),s.setSessionViewers(a,dg),s.setMyRole(a,"owner"),s.setMyViewerId(a,"v-1"),s.setPermissionVotes(a,e2.request_id,{votes:gP,votersTotal:3,deadline:Date.now()+25e3}),s.setVoteResult(a,t2.request_id,{result:"allow",policy:"majority-rules"}),()=>{G.setState(S=>{const j=new Map(S.sessions),k=new Map(S.messages),N=new Map(S.pendingPermissions),E=new Map(S.connectionStatus),B=new Map(S.cliConnected),F=new Map(S.sessionStatus),$=new Map(S.streaming),K=new Map(S.streamingStartedAt),Y=new Map(S.streamingOutputTokens);l?j.set(a,l):j.delete(a),c?k.set(a,c):k.delete(a),d?N.set(a,d):N.delete(a),f?E.set(a,f):E.delete(a),typeof h=="boolean"?B.set(a,h):B.delete(a),m?F.set(a,m):F.delete(a),typeof g=="string"?$.set(a,g):$.delete(a),typeof _=="number"?K.set(a,_):K.delete(a),typeof v=="number"?Y.set(a,v):Y.delete(a);const W=new Map(S.sessionViewers);W.delete(a);const L=new Map(S.myRole);L.delete(a);const Q=new Map(S.myViewerId);Q.delete(a);const V=new Map(S.permissionVotes);V.delete(a);const X=new Map(S.voteResults);return X.delete(a),{sessions:j,messages:k,pendingPermissions:N,connectionStatus:E,cliConnected:B,sessionStatus:F,streaming:$,streamingStartedAt:K,streamingOutputTokens:Y,sessionViewers:W,myRole:L,myViewerId:Q,permissionVotes:V,voteResults:X}})}},[]),r.jsxs("div",{className:"min-h-screen bg-cc-bg text-cc-fg font-sans-ui",children:[r.jsx("header",{className:"sticky top-0 z-50 bg-cc-sidebar border-b border-cc-border",children:r.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-4 flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-cc-fg tracking-tight",children:"Component Playground"}),r.jsx("p",{className:"text-xs text-cc-muted mt-0.5",children:"Visual catalog of all UI components"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:()=>{window.location.hash=""},className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg border border-cc-border transition-colors cursor-pointer",children:"Back to App"}),r.jsx("button",{onClick:()=>t(!e),className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-cc-primary/10 hover:bg-cc-primary/20 text-cc-primary border border-cc-primary/20 transition-colors cursor-pointer",children:e?"Light Mode":"Dark Mode"})]})]})}),r.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-8 space-y-12",children:[r.jsx(_t,{title:"Permission Banners",description:"Tool approval requests shown above the composer",children:r.jsxs("div",{className:"border border-cc-border rounded-xl overflow-hidden bg-cc-card divide-y divide-cc-border",children:[r.jsx(Zs,{permission:K5,sessionId:Ys}),r.jsx(Zs,{permission:Kz,sessionId:Ys}),r.jsx(Zs,{permission:Yz,sessionId:Ys}),r.jsx(Zs,{permission:Xz,sessionId:Ys}),r.jsx(Zs,{permission:Jz,sessionId:Ys}),r.jsx(Zs,{permission:Qz,sessionId:Ys}),r.jsx(Zs,{permission:eP,sessionId:Ys}),r.jsx(Zs,{permission:Y5,sessionId:Ys})]})}),r.jsx(_t,{title:"Presence Indicators",description:"Viewer avatars with role-based coloring — shown in TopBar when multiple viewers are connected",children:r.jsxs("div",{className:"space-y-4",children:[r.jsx(Le,{label:"Viewers connected (owner, collaborator, spectator)",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex items-center -space-x-1.5",children:dg.map(s=>r.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold border-2 border-cc-card ${s.role==="owner"?"bg-cc-primary/20 text-cc-primary":s.role==="spectator"?"bg-cc-muted/20 text-cc-muted":"bg-cc-success/20 text-cc-success"}`,title:`${s.name} (${s.role})`,children:s.name.charAt(0).toUpperCase()},s.id))}),r.jsxs("div",{className:"text-xs text-cc-muted",children:[dg.length," viewers connected"]})]})}),r.jsx(Le,{label:"Role legend",children:r.jsx("div",{className:"flex items-center gap-4",children:["owner","collaborator","spectator"].map(s=>r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("div",{className:`w-3 h-3 rounded-full ${s==="owner"?"bg-cc-primary/40":s==="collaborator"?"bg-cc-success/40":"bg-cc-muted/40"}`}),r.jsx("span",{className:"text-[11px] text-cc-fg capitalize",children:s})]},s))})})]})}),r.jsx(_t,{title:"Permission Voting",description:"Multi-viewer vote collection with countdown timer, vote counts, and resolved state",children:r.jsxs("div",{className:"space-y-4",children:[r.jsx(Le,{label:"Active vote (2/3 voted, countdown running)",children:r.jsx("div",{className:"border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:r.jsx(Zs,{permission:e2,sessionId:Ys})})}),r.jsx(Le,{label:"Resolved vote (majority allow)",children:r.jsx("div",{className:"border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:r.jsx(Zs,{permission:t2,sessionId:Ys})})}),r.jsx(Le,{label:"Spectator view (buttons disabled)",children:r.jsx(jP,{})})]})}),r.jsx(_t,{title:"Real Chat Stack",description:"Integrated ChatView using real MessageFeed + PermissionBanner + Composer components",children:r.jsx("div",{"data-testid":"playground-real-chat-stack",className:"max-w-3xl border border-cc-border rounded-xl overflow-hidden bg-cc-card h-[620px]",children:r.jsx(uC,{sessionId:Ys})})}),r.jsx(_t,{title:"Session Replay Controls",description:"Replay player UI — play/pause, speed selector, timeline scrubber, and recording metadata",children:r.jsxs("div",{className:"space-y-4",children:[r.jsx(Le,{label:"Replay controls (idle)",children:r.jsx(Vd,{state:"idle",position:0,total:42,speed:1})}),r.jsx(Le,{label:"Replay controls (playing at 4x)",children:r.jsx(Vd,{state:"playing",position:18,total:42,speed:4})}),r.jsx(Le,{label:"Replay controls (paused mid-way)",children:r.jsx(Vd,{state:"paused",position:30,total:42,speed:2})}),r.jsx(Le,{label:"Replay controls (ended)",children:r.jsx(Vd,{state:"ended",position:42,total:42,speed:1})}),r.jsx(Le,{label:"Replay header bar",children:r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-cc-sidebar border border-cc-border rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-cc-primary/10 flex items-center justify-center shrink-0",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-cc-primary",children:r.jsx("path",{d:"M4 2l10 6-10 6V2z"})})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-cc-fg truncate",children:"Session Replay"}),r.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-cc-muted",children:[r.jsx("span",{className:"px-1.5 py-0.5 bg-cc-hover rounded text-[10px] font-medium",children:"claude"}),r.jsx("span",{children:"claude-sonnet-4-5"}),r.jsx("span",{className:"text-cc-muted/40",children:"|"}),r.jsx("span",{children:"42 messages"})]})]})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsx("button",{className:"p-2 rounded-lg hover:bg-cc-hover text-cc-muted transition-colors cursor-pointer",title:"Share replay link",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-4 h-4",children:[r.jsx("path",{d:"M6 10l4-4M10 10V6H6",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"})]})}),r.jsx("button",{className:"p-2 rounded-lg hover:bg-cc-hover text-cc-muted transition-colors cursor-pointer",title:"Close replay",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4",children:r.jsx("path",{d:"M4.646 4.646a.5.5 0 01.708 0L8 7.293l2.646-2.647a.5.5 0 01.708.708L8.707 8l2.647 2.646a.5.5 0 01-.708.708L8 8.707l-2.646 2.647a.5.5 0 01-.708-.708L7.293 8 4.646 5.354a.5.5 0 010-.708z"})})})]})]})}),r.jsx(Le,{label:"Fork from message (hover icon)",children:r.jsx("div",{className:"max-w-3xl",children:r.jsx(fr,{message:ug,onFork:()=>{}})})})]})}),r.jsx(_t,{title:"ExitPlanMode",description:"Plan approval request — previously rendered as raw JSON, now shows formatted markdown",children:r.jsx("div",{className:"border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:r.jsx(Zs,{permission:Zz,sessionId:Ys})})}),r.jsx(_t,{title:"AskUserQuestion",description:"Interactive questions with selectable options",children:r.jsxs("div",{className:"space-y-4",children:[r.jsx(Le,{label:"Single question",children:r.jsx(Zs,{permission:tP,sessionId:Ys})}),r.jsx(Le,{label:"Multi-question",children:r.jsx(Zs,{permission:sP,sessionId:Ys})})]})}),r.jsx(_t,{title:"Messages",description:"Chat message bubbles for all roles",children:r.jsxs("div",{className:"space-y-4 max-w-3xl",children:[r.jsx(Le,{label:"User message",children:r.jsx(fr,{message:X5})}),r.jsx(Le,{label:"User message with image",children:r.jsx(fr,{message:nP})}),r.jsx(Le,{label:"Assistant message (markdown)",children:r.jsx(fr,{message:ug})}),r.jsx(Le,{label:"Assistant message (with tool calls)",children:r.jsx(fr,{message:J5})}),r.jsx(Le,{label:"Assistant message (thinking block)",children:r.jsx(fr,{message:rP})}),r.jsx(Le,{label:"Tool result with error",children:r.jsx(fr,{message:Q5})}),r.jsx(Le,{label:"System message",children:r.jsx(fr,{message:iP})})]})}),r.jsx(_t,{title:"Tool Blocks",description:"Expandable tool call visualization",children:r.jsxs("div",{className:"space-y-2 max-w-3xl",children:[r.jsx(pn,{name:"Bash",input:{command:"git status && npm run lint",description:"Check git status and lint"},toolUseId:"tb-1"}),r.jsx(pn,{name:"Read",input:{file_path:"/Users/stan/Dev/project/src/index.ts",offset:10,limit:50},toolUseId:"tb-2"}),r.jsx(pn,{name:"Edit",input:{file_path:"src/utils.ts",old_string:"const x = 1;",new_string:"const x = 2;",replace_all:!0},toolUseId:"tb-3"}),r.jsx(pn,{name:"Write",input:{file_path:"src/new-file.ts",content:`export const hello = "world";
195
+ `},toolUseId:"tb-4"}),r.jsx(pn,{name:"Glob",input:{pattern:"**/*.tsx",path:"/Users/stan/Dev/project/src"},toolUseId:"tb-5"}),r.jsx(pn,{name:"Grep",input:{pattern:"useEffect",path:"src/",glob:"*.tsx",output_mode:"content",context:3,head_limit:20},toolUseId:"tb-6"}),r.jsx(pn,{name:"WebSearch",input:{query:"React 19 new features",allowed_domains:["react.dev","github.com"]},toolUseId:"tb-7"}),r.jsx(pn,{name:"WebFetch",input:{url:"https://react.dev/blog/2024/12/05/react-19",prompt:"Summarize the key changes in React 19"},toolUseId:"tb-8"}),r.jsx(pn,{name:"Task",input:{description:"Search for auth patterns",subagent_type:"Explore",prompt:"Find all files related to authentication and authorization in the codebase. Look for middleware, guards, and token handling."},toolUseId:"tb-9"}),r.jsx(pn,{name:"TodoWrite",input:{todos:[{content:"Create JWT utility module",status:"completed",activeForm:"Creating JWT module"},{content:"Update auth middleware",status:"in_progress",activeForm:"Updating middleware"},{content:"Migrate login endpoint",status:"pending",activeForm:"Migrating login"},{content:"Run full test suite",status:"pending",activeForm:"Running tests"}]},toolUseId:"tb-10"}),r.jsx(pn,{name:"NotebookEdit",input:{notebook_path:"/Users/stan/Dev/project/analysis.ipynb",cell_type:"code",edit_mode:"replace",cell_number:3,new_source:`import pandas as pd
196
+ df = pd.read_csv('data.csv')
197
+ df.describe()`},toolUseId:"tb-11"}),r.jsx(pn,{name:"SendMessage",input:{type:"message",recipient:"researcher",content:"Please investigate the auth module structure and report back.",summary:"Requesting auth module investigation"},toolUseId:"tb-12"})]})}),r.jsx(_t,{title:"Tool Progress",description:"Real-time progress indicator shown while tools are running",children:r.jsxs("div",{className:"space-y-4 max-w-3xl",children:[r.jsx(Le,{label:"Single tool running",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-cc-muted font-mono-code pl-9",children:[r.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-cc-primary animate-pulse"}),r.jsx("span",{children:"Terminal"}),r.jsx("span",{className:"text-cc-muted/60",children:"8s"})]})}),r.jsx(Le,{label:"Multiple tools running",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-cc-muted font-mono-code pl-9",children:[r.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-cc-primary animate-pulse"}),r.jsx("span",{children:"Search Content"}),r.jsx("span",{className:"text-cc-muted/60",children:"3s"}),r.jsx("span",{className:"text-cc-muted/40",children:"·"}),r.jsx("span",{children:"Find Files"}),r.jsx("span",{className:"text-cc-muted/60",children:"2s"})]})})]})}),r.jsx(_t,{title:"Tool Use Summary",description:"System message summarizing batch tool execution",children:r.jsx("div",{className:"space-y-4 max-w-3xl",children:r.jsx(Le,{label:"Summary as system message",children:r.jsx(fr,{message:{id:"summary-1",role:"system",content:"Read 4 files, searched 12 matches across 3 directories",timestamp:Date.now()}})})})}),r.jsx(_t,{title:"Tasks",description:"Task list states: pending, in progress, completed, blocked",children:r.jsxs("div",{className:"w-[280px] border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:[r.jsxs("div",{className:"px-4 py-3 border-b border-cc-border space-y-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-cc-muted uppercase tracking-wider",children:"Cost"}),r.jsx("span",{className:"text-[13px] font-medium text-cc-fg tabular-nums",children:"$0.1847"})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-cc-muted uppercase tracking-wider",children:"Context"}),r.jsx("span",{className:"text-[11px] text-cc-muted tabular-nums",children:"62%"})]}),r.jsx("div",{className:"w-full h-1.5 rounded-full bg-cc-hover overflow-hidden",children:r.jsx("div",{className:"h-full rounded-full bg-cc-warning transition-all duration-500",style:{width:"62%"}})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-cc-muted uppercase tracking-wider",children:"Turns"}),r.jsx("span",{className:"text-[13px] font-medium text-cc-fg tabular-nums",children:"14"})]})]}),r.jsxs("div",{className:"px-4 py-2.5 border-b border-cc-border flex items-center justify-between",children:[r.jsx("span",{className:"text-[12px] font-semibold text-cc-fg",children:"Tasks"}),r.jsxs("span",{className:"text-[11px] text-cc-muted tabular-nums",children:["2/",Z5.length]})]}),r.jsx("div",{className:"px-3 py-2 space-y-0.5",children:Z5.map(s=>r.jsx(kP,{task:s},s.id))})]})}),r.jsx(_t,{title:"Session Pulse",description:"Unified floating activity widget — combines per-session agent/task tracking with cross-session awareness. Two tabs: Agents (current session subagents + tasks) and Sessions (other running sessions).",children:r.jsxs("div",{className:"space-y-4 max-w-3xl",children:[r.jsx(Le,{label:"Trigger pill — agents + sessions active",children:r.jsx("div",{className:"relative h-14 bg-cc-bg rounded-lg border border-cc-border/30 flex items-end justify-end p-3",children:r.jsxs("div",{className:"flex items-center gap-2 px-3 h-8 rounded-full border border-cc-border/50 bg-cc-card/90 backdrop-blur-lg shadow-panel",children:[r.jsxs("span",{className:"relative flex h-2 w-2",children:[r.jsx("span",{className:"absolute inset-0 rounded-full bg-cc-primary opacity-75 animate-ping"}),r.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-cc-primary"})]}),r.jsx("span",{className:"text-[11px] font-medium text-cc-fg/80 font-mono-code",children:"2 agents · 1 tool · 3/5 · 1 session"}),r.jsx("span",{className:"flex items-center justify-center min-w-[16px] h-4 px-1 rounded-full bg-cc-warning/15 text-cc-warning text-[9px] font-semibold",children:"1"}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-muted/60",children:r.jsx("path",{d:"M4.427 9.573l3.396-3.396a.25.25 0 01.354 0l3.396 3.396a.25.25 0 01-.177.427H4.604a.25.25 0 01-.177-.427z"})})]})})}),r.jsx(Le,{label:"Activity tab — agents, tools, and tasks (all backends)",children:r.jsxs("div",{className:"w-80 rounded-xl border border-cc-border/60 bg-cc-card/95 shadow-float overflow-hidden",children:[r.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 pb-1 border-b border-cc-border/40",children:[r.jsxs("span",{className:"px-2.5 py-1 rounded-md text-[10px] font-semibold uppercase tracking-wider bg-cc-primary/10 text-cc-primary",children:["Activity ",r.jsx("span",{className:"ml-1 text-[9px] tabular-nums opacity-70",children:"5"})]}),r.jsxs("span",{className:"px-2.5 py-1 rounded-md text-[10px] font-semibold uppercase tracking-wider text-cc-muted hover:text-cc-fg cursor-pointer",children:["Sessions ",r.jsx("span",{className:"ml-1 text-[9px] tabular-nums opacity-70",children:"1"})]}),r.jsx("div",{className:"flex-1"}),r.jsx("span",{className:"p-1 rounded hover:bg-cc-hover cursor-pointer",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-muted",children:r.jsx("path",{d:"M4.28 3.22a.75.75 0 00-1.06 1.06L6.94 8l-3.72 3.72a.75.75 0 101.06 1.06L8 9.06l3.72 3.72a.75.75 0 101.06-1.06L9.06 8l3.72-3.72a.75.75 0 00-1.06-1.06L8 6.94 4.28 3.22z"})})})]}),r.jsxs("div",{className:"py-1.5",children:[r.jsx("div",{className:"px-3 py-1",children:r.jsx("span",{className:"text-[9px] text-cc-muted/50 uppercase tracking-widest font-semibold",children:"Agents"})}),r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-1.5",children:[r.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0",children:[r.jsx("span",{className:"absolute inset-0 rounded-full bg-cc-primary opacity-75 animate-breathing"}),r.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-cc-primary"})]}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[11px] font-medium text-cc-fg truncate",children:"Search codebase for utils"}),r.jsx("span",{className:"text-[8px] text-cc-muted/40 uppercase font-mono-code",children:"Explore"})]})}),r.jsx("span",{className:"text-[10px] text-cc-muted/50 font-mono-code tabular-nums shrink-0",children:"32s"})]}),r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-1.5",children:[r.jsx("span",{className:"relative flex h-1.5 w-1.5 shrink-0",children:r.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-cc-success"})}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[11px] font-medium text-cc-fg/60 truncate",children:"Analyze test coverage"}),r.jsx("span",{className:"text-[8px] text-cc-muted/40 uppercase font-mono-code",children:"general-purpose"})]})}),r.jsx("span",{className:"text-[10px] text-cc-muted/50 font-mono-code tabular-nums shrink-0",children:"1m 14s"})]}),r.jsx("hr",{className:"mx-3 my-1.5 border-t border-cc-border/30 border-b-0 border-x-0"}),r.jsx("div",{className:"px-3 py-1",children:r.jsx("span",{className:"text-[9px] text-cc-muted/50 uppercase tracking-widest font-semibold",children:"Tools"})}),r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-1.5",children:[r.jsxs("svg",{className:"w-3.5 h-3.5 text-cc-primary animate-spin shrink-0",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),r.jsx("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),r.jsx("span",{className:"text-[11px] font-medium text-cc-fg truncate flex-1",children:"Bash"}),r.jsx("span",{className:"text-[10px] text-cc-muted/50 font-mono-code tabular-nums shrink-0",children:"8s"})]}),r.jsx("hr",{className:"mx-3 my-1.5 border-t border-cc-border/30 border-b-0 border-x-0"}),r.jsx("div",{className:"px-3 py-1",children:r.jsx("span",{className:"text-[9px] text-cc-muted/50 uppercase tracking-widest font-semibold",children:"Tasks"})}),r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1",children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-cc-success shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:r.jsx("path",{d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})}),r.jsx("span",{className:"text-[11px] text-cc-muted/50 line-through truncate",children:"Set up test infrastructure"})]}),r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1",children:[r.jsxs("svg",{className:"w-3.5 h-3.5 text-cc-primary animate-spin shrink-0",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),r.jsx("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-[11px] text-cc-fg truncate block",children:"Write unit tests for API"}),r.jsx("span",{className:"text-[10px] text-cc-muted/50 italic truncate block",children:"Writing unit tests for API"})]})]}),r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1",children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-cc-muted/30 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:r.jsx("circle",{cx:"8",cy:"8",r:"5.5"})}),r.jsx("span",{className:"text-[11px] text-cc-fg truncate",children:"Run integration tests"})]})]})]})}),r.jsx(Le,{label:"Sessions tab — cross-session awareness",children:r.jsxs("div",{className:"w-80 rounded-xl border border-cc-border/60 bg-cc-card/95 shadow-float overflow-hidden",children:[r.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 pb-1 border-b border-cc-border/40",children:[r.jsxs("span",{className:"px-2.5 py-1 rounded-md text-[10px] font-semibold uppercase tracking-wider text-cc-muted hover:text-cc-fg cursor-pointer",children:["Activity ",r.jsx("span",{className:"ml-1 text-[9px] tabular-nums opacity-70",children:"5"})]}),r.jsxs("span",{className:"px-2.5 py-1 rounded-md text-[10px] font-semibold uppercase tracking-wider bg-cc-primary/10 text-cc-primary",children:["Sessions ",r.jsx("span",{className:"ml-1 text-[9px] tabular-nums opacity-70",children:"2"})]}),r.jsx("div",{className:"flex-1"}),r.jsx("span",{className:"p-1 rounded hover:bg-cc-hover cursor-pointer",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-muted",children:r.jsx("path",{d:"M4.28 3.22a.75.75 0 00-1.06 1.06L6.94 8l-3.72 3.72a.75.75 0 101.06 1.06L8 9.06l3.72 3.72a.75.75 0 101.06-1.06L9.06 8l3.72-3.72a.75.75 0 00-1.06-1.06L8 6.94 4.28 3.22z"})})})]}),r.jsxs("div",{className:"py-1",children:[r.jsxs("div",{className:"w-full flex items-center gap-2.5 px-3 py-2 hover:bg-cc-hover/60 transition-colors text-left cursor-pointer group",children:[r.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0",children:[r.jsx("span",{className:"absolute inset-0 rounded-full bg-cc-primary opacity-75 animate-breathing"}),r.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-cc-primary"})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-[11px] font-medium text-cc-fg truncate block",children:"Refactor API layer"}),r.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[r.jsx("span",{className:"text-[10px] text-cc-muted/50 font-mono-code tabular-nums",children:"4m 23s"}),r.jsx("span",{className:"text-[10px] text-cc-muted/50 font-mono-code tabular-nums",children:"$0.12"})]})]}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-muted/30 group-hover:text-cc-primary/60 transition-colors shrink-0",children:r.jsx("path",{d:"M8.22 2.97a.75.75 0 011.06 0l4.25 4.25a.75.75 0 010 1.06l-4.25 4.25a.75.75 0 01-1.06-1.06l2.97-2.97H3.75a.75.75 0 010-1.5h7.44L8.22 4.03a.75.75 0 010-1.06z"})})]}),r.jsxs("div",{className:"w-full flex items-center gap-2.5 px-3 py-2 hover:bg-cc-hover/60 transition-colors text-left cursor-pointer group",children:[r.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0",children:[r.jsx("span",{className:"absolute inset-0 rounded-full bg-cc-primary opacity-75 animate-breathing"}),r.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-cc-primary"})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-[11px] font-medium text-cc-fg truncate block",children:"Write unit tests"}),r.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[r.jsx("span",{className:"text-[10px] text-cc-muted/50 font-mono-code tabular-nums",children:"1m 47s"}),r.jsx("span",{className:"text-[10px] text-cc-muted/50 font-mono-code tabular-nums",children:"$0.08"})]})]}),r.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-cc-warning/10 shrink-0",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-2.5 h-2.5 text-cc-warning",children:r.jsx("path",{d:"M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"})}),r.jsx("span",{className:"text-[9px] font-semibold text-cc-warning tabular-nums",children:"1"})]}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-muted/30 group-hover:text-cc-primary/60 transition-colors shrink-0",children:r.jsx("path",{d:"M8.22 2.97a.75.75 0 011.06 0l4.25 4.25a.75.75 0 010 1.06l-4.25 4.25a.75.75 0 01-1.06-1.06l2.97-2.97H3.75a.75.75 0 010-1.5h7.44L8.22 4.03a.75.75 0 010-1.06z"})})]})]})]})})]})}),r.jsx(_t,{title:"Environment Detection",description:"Detected project services and missing environment variables shown in the session panel",children:r.jsx(Le,{label:"Detected Next.js, Prisma, and Stripe",children:r.jsx("div",{className:"w-[280px] border border-cc-border rounded-xl overflow-hidden bg-cc-bg py-1",children:r.jsx(mC,{detected:{cwd:"/Users/stan/Dev/project",scannedAt:Date.now(),mcpServers:{},rules:[{id:"vercel",name:"Vercel",description:"Vercel or Next.js deployment target detected."},{id:"prisma",name:"Prisma",description:"Prisma schema or dependency detected.",envRequired:["DATABASE_URL"],envMissing:["DATABASE_URL"],envPresent:[]},{id:"stripe",name:"Stripe",description:"Stripe SDK or secret key detected.",envRequired:["STRIPE_SECRET_KEY"],envPresent:["STRIPE_SECRET_KEY"],envMissing:[]}]}})})})}),r.jsx(_t,{title:"Cost Card",description:"Shareable session summary card with key metrics and PNG export",children:r.jsxs("div",{className:"space-y-4",children:[r.jsx(Le,{label:"Completed session with cost",children:r.jsx("div",{className:"w-[280px] border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:r.jsx(jx,{sessionName:"Implement auth flow",cost:.2847,turns:14,durationMs:12*6e4,model:"claude-opus-4-6",backend:"claude",linesAdded:342,linesRemoved:87})})}),r.jsx(Le,{label:"Low-cost quick task",children:r.jsx("div",{className:"w-[280px] border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:r.jsx(jx,{sessionName:"Fix typo in README",cost:.0043,turns:2,durationMs:45e3,model:"claude-sonnet-4-5-20250929",backend:"claude",linesAdded:1,linesRemoved:1})})})]})}),r.jsx(_t,{title:"GitHub PR Status",description:"PR health shown in the TaskPanel — checks, reviews, unresolved comments",children:r.jsxs("div",{className:"space-y-4",children:[r.jsx(Le,{label:"Open PR — failing checks + changes requested",children:r.jsx("div",{className:"w-[280px] border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:r.jsx(Cc,{pr:lP})})}),r.jsx(Le,{label:"Open PR — all checks passed + approved",children:r.jsx("div",{className:"w-[280px] border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:r.jsx(Cc,{pr:cP})})}),r.jsx(Le,{label:"Draft PR — pending checks",children:r.jsx("div",{className:"w-[280px] border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:r.jsx(Cc,{pr:uP})})}),r.jsx(Le,{label:"Merged PR",children:r.jsx("div",{className:"w-[280px] border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:r.jsx(Cc,{pr:dP})})})]})}),r.jsx(_t,{title:"MCP Servers",description:"MCP server status display with toggle, reconnect, and tool listing",children:r.jsx("div",{className:"space-y-4",children:r.jsx(Le,{label:"All server states (connected, failed, disabled, connecting)",children:r.jsxs("div",{className:"w-[280px] border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:[r.jsxs("div",{className:"shrink-0 px-4 py-2.5 border-b border-cc-border flex items-center justify-between",children:[r.jsxs("span",{className:"text-[12px] font-semibold text-cc-fg flex items-center gap-1.5",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-muted",children:r.jsx("path",{d:"M1.5 3A1.5 1.5 0 013 1.5h10A1.5 1.5 0 0114.5 3v1A1.5 1.5 0 0113 5.5H3A1.5 1.5 0 011.5 4V3zm0 5A1.5 1.5 0 013 6.5h10A1.5 1.5 0 0114.5 8v1A1.5 1.5 0 0113 10.5H3A1.5 1.5 0 011.5 9V8zm0 5A1.5 1.5 0 013 11.5h10a1.5 1.5 0 011.5 1.5v1a1.5 1.5 0 01-1.5 1.5H3A1.5 1.5 0 011.5 14v-1z"})}),"MCP Servers"]}),r.jsx("span",{className:"text-[11px] text-cc-muted",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:[r.jsx("path",{d:"M2.5 8a5.5 5.5 0 019.78-3.5M13.5 8a5.5 5.5 0 01-9.78 3.5",strokeLinecap:"round"}),r.jsx("path",{d:"M12.5 2v3h-3M3.5 14v-3h3",strokeLinecap:"round",strokeLinejoin:"round"})]})})]}),r.jsx("div",{className:"px-3 py-2 space-y-1.5",children:mP.map(s=>r.jsx(SP,{server:s},s.name))})]})})})}),r.jsx(_t,{title:"Codex Session Details",description:"Rate limits and token details for Codex (OpenAI) sessions — streamed via session_update",children:r.jsx("div",{className:"space-y-4",children:r.jsx(Le,{label:"Rate limits with token breakdown",children:r.jsx(_P,{})})})}),r.jsx(_t,{title:"Claude Session Details",description:"Token usage and cost for Claude Code sessions — updated at turn end from modelUsage",children:r.jsx("div",{className:"space-y-4",children:r.jsx(Le,{label:"Token breakdown with cost",children:r.jsx(yP,{})})})}),r.jsx(_t,{title:"Update Banner",description:"Notification banner for available updates",children:r.jsxs("div",{className:"space-y-4 max-w-3xl",children:[r.jsx(Le,{label:"Service mode (auto-update)",children:r.jsx(hg,{updateInfo:{currentVersion:"0.22.1",latestVersion:"0.23.0",updateAvailable:!0,isServiceMode:!0,updateInProgress:!1,lastChecked:Date.now()}})}),r.jsx(Le,{label:"Foreground mode (manual)",children:r.jsx(hg,{updateInfo:{currentVersion:"0.22.1",latestVersion:"0.23.0",updateAvailable:!0,isServiceMode:!1,updateInProgress:!1,lastChecked:Date.now()}})}),r.jsx(Le,{label:"Update in progress",children:r.jsx(hg,{updateInfo:{currentVersion:"0.22.1",latestVersion:"0.23.0",updateAvailable:!0,isServiceMode:!0,updateInProgress:!0,lastChecked:Date.now()}})})]})}),r.jsx(_t,{title:"Status Indicators",description:"Connection and session status banners",children:r.jsxs("div",{className:"space-y-3 max-w-3xl",children:[r.jsx(Le,{label:"Disconnected warning",children:r.jsx("div",{className:"px-4 py-2 bg-cc-warning/10 border border-cc-warning/20 rounded-lg text-center",children:r.jsx("span",{className:"text-xs text-cc-warning font-medium",children:"Reconnecting to session..."})})}),r.jsx(Le,{label:"Connected",children:r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-cc-card border border-cc-border rounded-lg",children:[r.jsx("span",{className:"w-2 h-2 rounded-full bg-cc-success"}),r.jsx("span",{className:"text-xs text-cc-fg font-medium",children:"Connected"}),r.jsx("span",{className:"text-[11px] text-cc-muted ml-auto",children:"claude-opus-4-6"})]})}),r.jsx(Le,{label:"Running / Thinking",children:r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-cc-card border border-cc-border rounded-lg",children:[r.jsx("span",{className:"w-2 h-2 rounded-full bg-cc-primary animate-[pulse-dot_1.5s_ease-in-out_infinite]"}),r.jsx("span",{className:"text-xs text-cc-fg font-medium",children:"Thinking"})]})}),r.jsx(Le,{label:"Compacting",children:r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-cc-card border border-cc-border rounded-lg",children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-cc-muted animate-spin",viewBox:"0 0 16 16",fill:"none",children:r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"28",strokeDashoffset:"8",strokeLinecap:"round"})}),r.jsx("span",{className:"text-xs text-cc-muted font-medium",children:"Compacting context..."})]})})]})}),r.jsx(_t,{title:"Session Items",description:"Sidebar session items with status-first layout, model badges, and hover-revealed git stats",children:r.jsxs("div",{className:"max-w-xs space-y-1 bg-cc-bg p-2 rounded-lg border border-cc-border",children:[r.jsx("div",{className:"relative group",children:r.jsxs("div",{className:"w-full pl-3.5 pr-8 py-2.5 sm:py-2 text-left rounded-lg bg-cc-active",children:[r.jsx("span",{className:"absolute left-0 top-1.5 bottom-1.5 w-[3px] rounded-full bg-cc-success animate-[pulse-dot_1.5s_ease-in-out_infinite] opacity-100"}),r.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[13px] font-medium truncate text-cc-fg leading-snug",children:"Refactor auth module"}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-[#5BA8A0] bg-[#5BA8A0]/10",children:"Sonnet"})]}),r.jsxs("div",{className:"flex items-center gap-1 text-[10.5px] text-cc-muted leading-tight truncate",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-2.5 h-2.5 shrink-0 opacity-50",children:r.jsx("path",{d:"M11.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.116.862a2.25 2.25 0 10-.862.862A4.48 4.48 0 007.25 7.5h-1.5A2.25 2.25 0 003.5 9.75v.318a2.25 2.25 0 101.5 0V9.75a.75.75 0 01.75-.75h1.5a5.98 5.98 0 003.884-1.435A2.25 2.25 0 109.634 3.362zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5z"})}),r.jsx("span",{className:"truncate",children:"feat/auth-jwt"})]}),r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-cc-muted",children:[r.jsx("span",{className:"flex items-center gap-0.5",children:r.jsx("span",{className:"text-green-500",children:"2↑"})}),r.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[r.jsx("span",{className:"text-green-500",children:"+48"}),r.jsx("span",{className:"text-red-400",children:"-12"})]})]})]})]})}),r.jsx("div",{className:"relative group",children:r.jsxs("div",{className:"w-full pl-3.5 pr-8 py-2.5 sm:py-2 text-left rounded-lg hover:bg-cc-hover",children:[r.jsx("span",{className:"absolute left-0 top-1.5 bottom-1.5 w-[3px] rounded-full bg-cc-success/60 opacity-60"}),r.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[13px] font-medium truncate text-cc-fg leading-snug",children:"Fix CI pipeline"}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-blue-400 bg-blue-500/10",children:"Codex"})]}),r.jsxs("div",{className:"flex items-center gap-1 text-[10.5px] text-cc-muted leading-tight truncate",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-2.5 h-2.5 shrink-0 opacity-50",children:r.jsx("path",{d:"M11.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.116.862a2.25 2.25 0 10-.862.862A4.48 4.48 0 007.25 7.5h-1.5A2.25 2.25 0 003.5 9.75v.318a2.25 2.25 0 101.5 0V9.75a.75.75 0 01.75-.75h1.5a5.98 5.98 0 003.884-1.435A2.25 2.25 0 109.634 3.362zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5z"})}),r.jsx("span",{className:"truncate",children:"main"})]})]})]})}),r.jsxs("div",{className:"relative group",children:[r.jsxs("div",{className:"w-full pl-3.5 pr-8 py-2.5 sm:py-2 text-left rounded-lg hover:bg-cc-hover",children:[r.jsx("span",{className:"absolute left-0 top-1.5 bottom-1.5 w-[3px] rounded-full bg-cc-warning animate-[pulse-dot_1.5s_ease-in-out_infinite] opacity-100"}),r.jsx("div",{className:"flex flex-col gap-0.5 min-w-0",children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[13px] font-medium truncate text-cc-fg leading-snug",children:"Update dependencies"}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-[#5BA8A0] bg-[#5BA8A0]/10",children:"Opus"})]})})]}),r.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 min-w-[18px] h-[18px] flex items-center justify-center rounded-full bg-cc-warning text-white text-[10px] font-bold leading-none px-1",children:"2"})]}),r.jsx("div",{className:"relative group",children:r.jsxs("div",{className:"w-full pl-3.5 pr-8 py-2.5 sm:py-2 text-left rounded-lg hover:bg-cc-hover",children:[r.jsx("span",{className:"absolute left-0 top-1.5 bottom-1.5 w-[3px] rounded-full bg-cc-muted/30 opacity-60"}),r.jsx("div",{className:"flex flex-col gap-0.5 min-w-0",children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[13px] font-medium truncate text-cc-fg leading-snug",children:"Add dark mode toggle"}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-[#5BA8A0] bg-[#5BA8A0]/10",children:"Haiku"})]})})]})})]})}),r.jsx(_t,{title:"Session Launch Overlay",description:"Container session creation progress with step indicators and progress bar",children:r.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[r.jsx(Le,{label:"In progress — pulling image",children:r.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white p-6 dark:border-neutral-700 dark:bg-neutral-900",children:[r.jsx("h3",{className:"mb-4 text-lg font-semibold text-neutral-900 dark:text-neutral-100",children:"Launching Container Session"}),r.jsx("div",{className:"mb-4 space-y-2",children:["Checking image","Pulling image","Creating container","Seeding authentication","Launching agent"].map((s,n)=>r.jsxs("div",{className:`flex items-center gap-2 text-sm ${n<1?"text-green-600 dark:text-green-400":n===1?"font-medium text-blue-600 dark:text-blue-400":"text-neutral-400 dark:text-neutral-600"}`,children:[n<1?r.jsx("svg",{className:"h-4 w-4 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):n===1?r.jsxs("svg",{className:"h-4 w-4 flex-shrink-0 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):r.jsx("div",{className:"h-4 w-4 flex-shrink-0 rounded-full border border-neutral-300 dark:border-neutral-600"}),r.jsx("span",{children:s})]},s))}),r.jsxs("div",{className:"mb-3",children:[r.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-neutral-200 dark:bg-neutral-700",children:r.jsx("div",{className:"h-full rounded-full bg-blue-600 transition-all duration-300",style:{width:"63%"}})}),r.jsx("p",{className:"mt-1 text-xs text-neutral-500",children:"63%"})]}),r.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400 truncate",children:"Downloading layer sha256:a1b2c3d4..."})]})}),r.jsx(Le,{label:"Error state",children:r.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white p-6 dark:border-neutral-700 dark:bg-neutral-900",children:[r.jsxs("div",{className:"mb-4 flex items-center gap-2 text-red-600 dark:text-red-400",children:[r.jsx("svg",{className:"h-5 w-5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),r.jsx("h3",{className:"text-lg font-semibold",children:"Container Launch Failed"})]}),r.jsx("p",{className:"mb-4 text-sm text-neutral-600 dark:text-neutral-400",children:"Failed to pull image campfire-dev:latest — connection timed out"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{className:"flex-1 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700",children:"Retry"}),r.jsx("button",{className:"flex-1 rounded-lg border border-neutral-300 px-4 py-2 text-sm font-medium text-neutral-700 hover:bg-neutral-100 dark:border-neutral-600 dark:text-neutral-300 dark:hover:bg-neutral-800",children:"Cancel"})]})]})})]})}),r.jsx(_t,{title:"Composer",description:"Message input bar with mode toggle, image upload, and send/stop buttons",children:r.jsxs("div",{className:"max-w-3xl",children:[r.jsx(Le,{label:"Connected — code mode",children:r.jsx("div",{className:"border-t border-cc-border bg-cc-card px-4 py-3",children:r.jsxs("div",{className:"bg-cc-input-bg border border-cc-border rounded-xl overflow-hidden",children:[r.jsx("textarea",{readOnly:!0,value:"Can you refactor the auth module to use JWT?",rows:1,className:"w-full px-4 pt-3 pb-1 text-sm bg-transparent resize-none text-cc-fg font-sans-ui",style:{minHeight:"36px"}}),r.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-[12px] font-medium text-cc-muted",children:[r.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:[r.jsx("path",{d:"M2.5 4l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),r.jsx("path",{d:"M8.5 4l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}),r.jsx("span",{children:"code"})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg text-cc-muted",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-4 h-4",children:[r.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),r.jsx("circle",{cx:"5.5",cy:"5.5",r:"1",fill:"currentColor",stroke:"none"}),r.jsx("path",{d:"M2 11l3-3 2 2 3-4 4 5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-cc-primary text-white",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M3 2l11 6-11 6V9.5l7-1.5-7-1.5V2z"})})})]})]})]})})}),r.jsx("div",{className:"mt-4"}),r.jsx(Le,{label:"Plan mode active",children:r.jsx("div",{className:"border-t border-cc-border bg-cc-card px-4 py-3",children:r.jsxs("div",{className:"bg-cc-input-bg border border-cc-primary/40 rounded-xl overflow-hidden",children:[r.jsx("textarea",{readOnly:!0,value:"",placeholder:"Type a message... (/ for commands)",rows:1,className:"w-full px-4 pt-3 pb-1 text-sm bg-transparent resize-none text-cc-fg font-sans-ui placeholder:text-cc-muted",style:{minHeight:"36px"}}),r.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-[12px] font-medium text-cc-primary",children:[r.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:[r.jsx("rect",{x:"3",y:"3",width:"3.5",height:"10",rx:"0.75"}),r.jsx("rect",{x:"9.5",y:"3",width:"3.5",height:"10",rx:"0.75"})]}),r.jsx("span",{children:"plan"})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg text-cc-muted",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-4 h-4",children:[r.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),r.jsx("circle",{cx:"5.5",cy:"5.5",r:"1",fill:"currentColor",stroke:"none"}),r.jsx("path",{d:"M2 11l3-3 2 2 3-4 4 5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-cc-hover text-cc-muted",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M3 2l11 6-11 6V9.5l7-1.5-7-1.5V2z"})})})]})]})]})})}),r.jsx("div",{className:"mt-4"}),r.jsx(Le,{label:"Running — stop button visible",children:r.jsx("div",{className:"border-t border-cc-border bg-cc-card px-4 py-3",children:r.jsxs("div",{className:"bg-cc-input-bg border border-cc-border rounded-xl overflow-hidden",children:[r.jsx("textarea",{readOnly:!0,value:"",placeholder:"Type a message... (/ for commands)",rows:1,className:"w-full px-4 pt-3 pb-1 text-sm bg-transparent resize-none text-cc-fg font-sans-ui placeholder:text-cc-muted",style:{minHeight:"36px"}}),r.jsxs("div",{className:"flex items-center gap-2 px-4 pb-1 text-[11px] text-cc-muted overflow-hidden",children:[r.jsxs("span",{className:"flex items-center gap-1 truncate min-w-0",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 shrink-0 opacity-60",children:r.jsx("path",{d:"M11.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.116.862a2.25 2.25 0 10-.862.862A4.48 4.48 0 007.25 7.5h-1.5A2.25 2.25 0 003.5 9.75v.318a2.25 2.25 0 101.5 0V9.75a.75.75 0 01.75-.75h1.5a5.98 5.98 0 003.884-1.435A2.25 2.25 0 109.634 3.362zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5z"})}),r.jsx("span",{className:"truncate",children:"feat/jwt-auth"}),r.jsx("span",{className:"text-[10px] bg-cc-hover text-cc-muted px-1 rounded",children:"worktree"})]}),r.jsx("span",{className:"flex items-center gap-0.5 text-[10px]",children:r.jsx("span",{className:"text-green-500",children:"3↑"})}),r.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[r.jsx("span",{className:"text-green-500",children:"+142"}),r.jsx("span",{className:"text-red-400",children:"-38"})]})]}),r.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-[12px] font-medium text-cc-muted",children:[r.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:[r.jsx("path",{d:"M2.5 4l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),r.jsx("path",{d:"M8.5 4l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}),r.jsx("span",{children:"code"})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg text-cc-muted",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-4 h-4",children:[r.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),r.jsx("circle",{cx:"5.5",cy:"5.5",r:"1",fill:"currentColor",stroke:"none"}),r.jsx("path",{d:"M2 11l3-3 2 2 3-4 4 5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-cc-error/10 text-cc-error",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})})]})]})]})})})]})}),r.jsx(_t,{title:"Streaming Indicator",description:"Live typing animation shown while the assistant is generating",children:r.jsxs("div",{className:"space-y-4 max-w-3xl",children:[r.jsx(Le,{label:"Streaming with cursor",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-6 h-6 rounded-full bg-cc-primary/10 flex items-center justify-center shrink-0 mt-0.5",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-3.5 h-3.5 text-cc-primary",children:r.jsx("path",{d:"M8 1v14M1 8h14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsxs("pre",{className:"font-sans-ui text-[15px] text-cc-fg whitespace-pre-wrap break-words leading-relaxed",children:["I'll start by creating the JWT utility module with sign and verify helpers. Let me first check what dependencies are already installed...",r.jsx("span",{className:"inline-block w-0.5 h-4 bg-cc-primary ml-0.5 align-middle animate-[pulse-dot_0.8s_ease-in-out_infinite]"})]})})]})}),r.jsx(Le,{label:"Generation stats bar",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-cc-muted font-mono-code pl-9",children:[r.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-cc-primary animate-pulse"}),r.jsx("span",{children:"Generating..."}),r.jsx("span",{className:"text-cc-muted/60",children:"("}),r.jsx("span",{children:"12s"}),r.jsx("span",{className:"text-cc-muted/40",children:"·"}),r.jsx("span",{children:"↓ 1.2k"}),r.jsx("span",{className:"text-cc-muted/60",children:")"})]})})]})}),r.jsx(_t,{title:"Tool Message Groups",description:"Consecutive same-tool calls collapsed into a single expandable row",children:r.jsxs("div",{className:"space-y-4 max-w-3xl",children:[r.jsx(Le,{label:"Multi-item group (4 Reads)",children:r.jsx(Cx,{toolName:"Read",items:aP})}),r.jsx(Le,{label:"Single-item group",children:r.jsx(Cx,{toolName:"Glob",items:[{id:"sg-1",name:"Glob",input:{pattern:"src/auth/**/*.ts"}}]})})]})}),r.jsx(_t,{title:"Subagent Groups",description:"Nested messages from Task tool subagents shown in a collapsible indent",children:r.jsx("div",{className:"space-y-4 max-w-3xl",children:r.jsx(Le,{label:"Subagent with nested tool calls",children:r.jsx(bP,{description:"Search codebase for auth patterns",agentType:"Explore",items:oP})})})}),r.jsx(_t,{title:"Diff Viewer",description:"Unified diff rendering with word-level highlighting — used in ToolBlock, PermissionBanner, and DiffPanel",children:r.jsxs("div",{className:"space-y-4 max-w-3xl",children:[r.jsx(Le,{label:"Edit diff (compact mode)",children:r.jsx(br,{oldText:`export function formatDate(d: Date) {
198
+ return d.toISOString();
199
+ }`,newText:`export function formatDate(d: Date, locale = "en-US") {
200
+ return d.toLocaleDateString(locale, {
201
+ year: "numeric",
202
+ month: "short",
203
+ day: "numeric",
204
+ });
205
+ }`,fileName:"src/utils/format.ts",mode:"compact"})}),r.jsx(Le,{label:"New file diff (compact mode)",children:r.jsx(br,{newText:`export const config = {
206
+ apiUrl: "https://api.example.com",
207
+ timeout: 5000,
208
+ retries: 3,
209
+ debug: process.env.NODE_ENV !== "production",
210
+ };
211
+ `,fileName:"src/config.ts",mode:"compact"})}),r.jsx(Le,{label:"Git diff (full mode with line numbers)",children:r.jsx(br,{unifiedDiff:`diff --git a/src/auth/middleware.ts b/src/auth/middleware.ts
212
+ --- a/src/auth/middleware.ts
213
+ +++ b/src/auth/middleware.ts
214
+ @@ -1,8 +1,12 @@
215
+ -import { getSession } from "./session";
216
+ +import { verifyToken } from "./jwt";
217
+ +import type { Request, Response, NextFunction } from "express";
218
+
219
+ -export function authMiddleware(req, res, next) {
220
+ - const session = getSession(req);
221
+ - if (!session?.userId) {
222
+ +export function authMiddleware(req: Request, res: Response, next: NextFunction) {
223
+ + const header = req.headers.authorization;
224
+ + if (!header?.startsWith("Bearer ")) {
225
+ return res.status(401).json({ error: "Unauthorized" });
226
+ }
227
+ - req.userId = session.userId;
228
+ + const token = header.slice(7);
229
+ + const payload = verifyToken(token);
230
+ + if (!payload) return res.status(401).json({ error: "Invalid token" });
231
+ + req.userId = payload.userId;
232
+ next();
233
+ }`,mode:"full"})}),r.jsx(Le,{label:"No changes",children:r.jsx(br,{oldText:"same content",newText:"same content"})})]})}),r.jsx(_t,{title:"CLAUDE.md Editor",description:"Modal for viewing and editing project CLAUDE.md instructions",children:r.jsx("div",{className:"space-y-4 max-w-3xl",children:r.jsx(Le,{label:"Open editor button (from TopBar)",children:r.jsx(wP,{})})})}),r.jsx(_t,{title:"Gallery Cards",description:"Session gallery entries with voting, tags, featured badge, and stats",children:r.jsxs("div",{className:"space-y-4 max-w-3xl",children:[r.jsx(Le,{label:"Featured entry with high votes",children:r.jsx(ih,{entry:hP,onVote:()=>{},onDelete:()=>{},onFeature:()=>{}})}),r.jsx(Le,{label:"Regular entry with tags",children:r.jsx(ih,{entry:fP,onVote:()=>{},onDelete:()=>{},onFeature:()=>{}})}),r.jsx(Le,{label:"Codex entry with low cost",children:r.jsx(ih,{entry:pP,onVote:()=>{},onDelete:()=>{},onFeature:()=>{}})})]})}),r.jsx(_t,{title:"Webhook & Adapter Pages",description:"Management UIs for webhooks and community adapters (navigate to #/webhooks or #/adapters)",children:r.jsxs("div",{className:"space-y-4 max-w-3xl",children:[r.jsx(Le,{label:"Webhook card with delivery stats",children:r.jsxs("div",{className:"border border-cc-border rounded-lg overflow-hidden bg-cc-card",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 bg-cc-card border-b border-cc-border",children:[r.jsx("span",{className:"text-sm font-medium text-cc-fg flex-1 truncate",children:"Slack Notifications"}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-cc-success bg-cc-success/10",children:"47/50"}),r.jsx("span",{className:"relative w-8 h-[18px] rounded-full bg-cc-primary shrink-0",children:r.jsx("span",{className:"absolute top-[2px] left-[16px] w-[14px] h-[14px] rounded-full bg-white"})})]}),r.jsxs("div",{className:"px-3 py-2.5 space-y-1.5",children:[r.jsx("div",{className:"text-xs text-cc-muted font-mono-code truncate",children:"https://hooks.slack.com/services/T00.../B00.../xxx"}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:["session.completed","session.failed","cost.threshold"].map(s=>r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full bg-cc-hover text-cc-muted",children:s},s))}),r.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-cc-muted",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("path",{d:"M8 1a3.5 3.5 0 00-3.5 3.5V7H4a1 1 0 00-1 1v5a1 1 0 001 1h8a1 1 0 001-1V8a1 1 0 00-1-1h-.5V4.5A3.5 3.5 0 008 1zm2 6H6V4.5a2 2 0 114 0V7z"})}),"Signed"]}),r.jsx("span",{children:"Last: 5m ago"})]})]})]})}),r.jsx(Le,{label:"Adapter card with models",children:r.jsxs("div",{className:"border border-cc-border rounded-lg overflow-hidden bg-cc-card",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 bg-cc-card border-b border-cc-border",children:[r.jsx("span",{className:"text-sm font-medium text-cc-fg flex-1 truncate",children:"My Custom Agent"}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-cc-muted bg-cc-hover",children:"v1.2.0"}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-blue-500 bg-blue-500/10",children:"WebSocket"})]}),r.jsxs("div",{className:"px-3 py-2.5 space-y-1.5",children:[r.jsx("div",{className:"text-xs text-cc-muted",children:"A custom agent for automated code review"}),r.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-cc-muted",children:[r.jsx("span",{className:"font-mono-code",children:"my-agent"}),r.jsx("span",{children:"3 models"}),r.jsx("span",{children:"by @community"}),r.jsx("span",{className:"font-mono-code",children:"@campfire/my-agent"})]}),r.jsx("div",{className:"flex flex-wrap gap-1",children:["GPT-4o","GPT-4o-mini","o1-preview"].map(s=>r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full bg-cc-hover text-cc-muted",children:s},s))})]})]})})]})})]})]})}function _t({title:e,description:t,children:s}){return r.jsxs("section",{children:[r.jsxs("div",{className:"mb-4",children:[r.jsx("h2",{className:"text-base font-semibold text-cc-fg",children:e}),r.jsx("p",{className:"text-xs text-cc-muted mt-0.5",children:t})]}),s]})}function Le({label:e,children:t}){return r.jsxs("div",{className:"border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:[r.jsx("div",{className:"px-3 py-1.5 bg-cc-hover/50 border-b border-cc-border",children:r.jsx("span",{className:"text-[10px] text-cc-muted font-mono-code uppercase tracking-wider",children:e})}),r.jsx("div",{className:"p-4",children:t})]})}function Cx({toolName:e,items:t}){const[s,n]=w.useState(!1),a=uu(e),l=Ta(e),c=t.length;if(c===1){const d=t[0];return r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-6 h-6 rounded-full bg-cc-primary/10 flex items-center justify-center shrink-0 mt-0.5",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-primary",children:r.jsx("circle",{cx:"8",cy:"8",r:"3"})})}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsxs("div",{className:"border border-cc-border rounded-lg overflow-hidden bg-cc-card",children:[r.jsxs("button",{onClick:()=>n(!s),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:bg-cc-hover transition-colors cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 text-cc-muted transition-transform shrink-0 ${s?"rotate-90":""}`,children:r.jsx("path",{d:"M6 4l4 4-4 4"})}),r.jsx(Aa,{type:a}),r.jsx("span",{className:"text-xs font-medium text-cc-fg",children:l}),r.jsx("span",{className:"text-xs text-cc-muted truncate flex-1 font-mono-code",children:Ko(d.name,d.input)})]}),s&&r.jsx("div",{className:"px-3 pb-3 pt-0 border-t border-cc-border mt-0",children:r.jsx("pre",{className:"mt-2 text-[11px] text-cc-muted font-mono-code whitespace-pre-wrap leading-relaxed max-h-60 overflow-y-auto",children:JSON.stringify(d.input,null,2)})})]})})]})}return r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-6 h-6 rounded-full bg-cc-primary/10 flex items-center justify-center shrink-0 mt-0.5",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-primary",children:r.jsx("circle",{cx:"8",cy:"8",r:"3"})})}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsxs("div",{className:"border border-cc-border rounded-lg overflow-hidden bg-cc-card",children:[r.jsxs("button",{onClick:()=>n(!s),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:bg-cc-hover transition-colors cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 text-cc-muted transition-transform shrink-0 ${s?"rotate-90":""}`,children:r.jsx("path",{d:"M6 4l4 4-4 4"})}),r.jsx(Aa,{type:a}),r.jsx("span",{className:"text-xs font-medium text-cc-fg",children:l}),r.jsx("span",{className:"text-[10px] text-cc-muted bg-cc-hover rounded-full px-1.5 py-0.5 tabular-nums font-medium",children:c})]}),s&&r.jsx("div",{className:"border-t border-cc-border px-3 py-1.5",children:t.map((d,f)=>{const h=Ko(d.name,d.input);return r.jsxs("div",{className:"flex items-center gap-2 py-1 text-xs text-cc-muted font-mono-code truncate",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-cc-muted/40 shrink-0"}),r.jsx("span",{className:"truncate",children:h||JSON.stringify(d.input).slice(0,80)})]},d.id||f)})})]})})]})}function bP({description:e,agentType:t,items:s}){var l;const[n,a]=w.useState(!0);return r.jsxs("div",{className:"ml-9 border-l-2 border-cc-border pl-4",children:[r.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-center gap-2 py-1.5 text-left cursor-pointer mb-1",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 text-cc-muted transition-transform shrink-0 ${n?"rotate-90":""}`,children:r.jsx("path",{d:"M6 4l4 4-4 4"})}),r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5 text-cc-primary shrink-0",children:[r.jsx("circle",{cx:"8",cy:"8",r:"5"}),r.jsx("path",{d:"M8 5v3l2 1",strokeLinecap:"round"})]}),r.jsx("span",{className:"text-xs font-medium text-cc-fg truncate",children:e}),t&&r.jsx("span",{className:"text-[10px] text-cc-muted bg-cc-hover rounded-full px-1.5 py-0.5 shrink-0",children:t}),r.jsx("span",{className:"text-[10px] text-cc-muted bg-cc-hover rounded-full px-1.5 py-0.5 tabular-nums shrink-0 ml-auto",children:s.length})]}),n&&r.jsx("div",{className:"space-y-3 pb-2",children:r.jsx(Cx,{toolName:((l=s[0])==null?void 0:l.name)||"Grep",items:s})})]})}const No="codex-playground-demo";function _P(){return w.useEffect(()=>{const e=G.getState(),t=e.sessions.get(No);return e.addSession({session_id:No,backend_type:"codex",model:"o3",cwd:"/Users/demo/project",tools:[],permissionMode:"bypassPermissions",claude_code_version:"0.1.0",mcp_servers:[],agents:[],slash_commands:[],skills:[],total_cost_usd:0,num_turns:8,context_used_percent:45,is_compacting:!1,git_branch:"main",is_worktree:!1,repo_root:"/Users/demo/project",git_ahead:0,git_behind:0,total_lines_added:0,total_lines_removed:0,total_duration_api_ms:0,codex_rate_limits:{primary:{usedPercent:62,windowDurationMins:300,resetsAt:Date.now()+2*36e5},secondary:{usedPercent:18,windowDurationMins:10080,resetsAt:Date.now()+5*864e5}},codex_token_details:{inputTokens:84230,outputTokens:12450,cachedInputTokens:41200,reasoningOutputTokens:8900,modelContextWindow:2e5}}),()=>{G.setState(s=>{const n=new Map(s.sessions);return t?n.set(No,t):n.delete(No),{sessions:n}})}},[]),r.jsxs("div",{className:"w-[280px] border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:[r.jsx(gC,{sessionId:No}),r.jsx(xC,{sessionId:No})]})}const cc="claude-playground-demo";function yP(){return w.useEffect(()=>{const e=G.getState(),t=e.sessions.get(cc);return e.addSession({session_id:cc,backend_type:"claude",model:"claude-sonnet-4-20250514",cwd:"/Users/demo/project",tools:[],permissionMode:"default",claude_code_version:"1.0.0",mcp_servers:[],agents:[],slash_commands:[],skills:[],total_cost_usd:.87,num_turns:5,context_used_percent:38,is_compacting:!1,git_branch:"feat/auth",is_worktree:!1,repo_root:"/Users/demo/project",git_ahead:2,git_behind:0,total_lines_added:142,total_lines_removed:23,total_duration_api_ms:45e3,claude_token_details:{inputTokens:125400,outputTokens:18200,cacheReadInputTokens:98300,cacheCreationInputTokens:12600,contextWindow:2e5,costUsd:.87}}),()=>{G.setState(s=>{const n=new Map(s.sessions);return t?n.set(cc,t):n.delete(cc),{sessions:n}})}},[]),r.jsx("div",{className:"w-[280px] border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:r.jsx(vC,{sessionId:cc})})}function hg({updateInfo:e}){return w.useEffect(()=>{const t=G.getState().updateInfo,s=G.getState().updateDismissedVersion;return G.getState().setUpdateInfo(e),s&&G.setState({updateDismissedVersion:null}),()=>{G.getState().setUpdateInfo(t),s&&G.setState({updateDismissedVersion:s})}},[e]),r.jsx(EC,{})}function wP(){const[e,t]=w.useState(!1),[s,n]=w.useState("/tmp");return w.useEffect(()=>{ne.getHome().then(a=>n(a.cwd)).catch(()=>{})},[]),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("button",{onClick:()=>t(!0),className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-cc-hover border border-cc-border hover:bg-cc-active transition-colors cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-cc-primary",children:r.jsx("path",{d:"M4 1.5a.5.5 0 01.5-.5h7a.5.5 0 01.354.146l2 2A.5.5 0 0114 3.5v11a.5.5 0 01-.5.5h-11a.5.5 0 01-.5-.5v-13zm1 .5v12h8V4h-1.5a.5.5 0 01-.5-.5V2H5zm6 0v1h1l-1-1zM6.5 7a.5.5 0 000 1h5a.5.5 0 000-1h-5zm0 2a.5.5 0 000 1h5a.5.5 0 000-1h-5zm0 2a.5.5 0 000 1h3a.5.5 0 000-1h-3z"})}),r.jsx("span",{className:"text-xs font-medium text-cc-fg",children:"Edit CLAUDE.md"})]}),r.jsx("span",{className:"text-[11px] text-cc-muted",children:"Click to open the editor modal (uses server working directory)"}),r.jsx(dC,{cwd:s,open:e,onClose:()=>t(!1)})]})}function SP({server:e}){var l;const[t,s]=w.useState(!1),n={connected:{label:"Connected",cls:"text-cc-success bg-cc-success/10",dot:"bg-cc-success"},connecting:{label:"Connecting",cls:"text-cc-warning bg-cc-warning/10",dot:"bg-cc-warning animate-pulse"},failed:{label:"Failed",cls:"text-cc-error bg-cc-error/10",dot:"bg-cc-error"},disabled:{label:"Disabled",cls:"text-cc-muted bg-cc-hover",dot:"bg-cc-muted opacity-40"}},a=n[e.status]||n.disabled;return r.jsxs("div",{className:"rounded-lg border border-cc-border bg-cc-bg",children:[r.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2",children:[r.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${a.dot}`}),r.jsx("button",{onClick:()=>s(!t),className:"flex-1 min-w-0 text-left cursor-pointer",children:r.jsx("span",{className:"text-[12px] font-medium text-cc-fg truncate block",children:e.name})}),r.jsx("span",{className:`text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 ${a.cls}`,children:a.label})]}),t&&r.jsxs("div",{className:"px-2.5 pb-2.5 space-y-1.5 border-t border-cc-border pt-2",children:[r.jsxs("div",{className:"text-[11px] text-cc-muted space-y-0.5",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"text-cc-muted/60",children:"Type:"}),r.jsx("span",{children:e.config.type})]}),e.config.command&&r.jsxs("div",{className:"flex items-start gap-1",children:[r.jsx("span",{className:"text-cc-muted/60 shrink-0",children:"Cmd:"}),r.jsxs("span",{className:"font-mono text-[10px] break-all",children:[e.config.command,(l=e.config.args)!=null&&l.length?` ${e.config.args.join(" ")}`:""]})]}),e.config.url&&r.jsxs("div",{className:"flex items-start gap-1",children:[r.jsx("span",{className:"text-cc-muted/60 shrink-0",children:"URL:"}),r.jsx("span",{className:"font-mono text-[10px] break-all",children:e.config.url})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"text-cc-muted/60",children:"Scope:"}),r.jsx("span",{children:e.scope})]})]}),e.error&&r.jsx("div",{className:"text-[11px] text-cc-error bg-cc-error/5 rounded px-2 py-1",children:e.error}),e.tools&&e.tools.length>0&&r.jsxs("div",{className:"space-y-1",children:[r.jsxs("span",{className:"text-[10px] text-cc-muted uppercase tracking-wider",children:["Tools (",e.tools.length,")"]}),r.jsx("div",{className:"flex flex-wrap gap-1",children:e.tools.map(c=>r.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-cc-hover text-cc-fg",children:c.name},c.name))})]})]})]})}const uc="playground-spectator";function jP(){return w.useEffect(()=>{const e=G.getState();return e.addSession({session_id:uc,backend_type:"claude",model:"claude-sonnet-4-5",cwd:"/tmp",tools:[],permissionMode:"default",claude_code_version:"1.0.0",mcp_servers:[],agents:[],slash_commands:[],skills:[],total_cost_usd:0,num_turns:0,context_used_percent:0,is_compacting:!1,git_branch:"main",is_worktree:!1,repo_root:"/tmp",git_ahead:0,git_behind:0,total_lines_added:0,total_lines_removed:0,total_duration_api_ms:0}),e.setMyRole(uc,"spectator"),()=>{G.setState(t=>{const s=new Map(t.sessions);s.delete(uc);const n=new Map(t.myRole);return n.delete(uc),{sessions:s,myRole:n}})}},[]),r.jsx("div",{className:"border border-cc-border rounded-xl overflow-hidden bg-cc-card",children:r.jsx(Zs,{permission:xP,sessionId:uc})})}function Vd({state:e,position:t,total:s,speed:n}){const a=e==="playing",l=e==="ended";return r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-cc-sidebar border border-cc-border rounded-lg",children:[r.jsx("button",{className:"w-8 h-8 rounded-full bg-cc-primary/10 flex items-center justify-center text-cc-primary hover:bg-cc-primary/20 transition-colors cursor-pointer shrink-0",children:l?r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M2.5 2a.5.5 0 01.854-.354l4.646 4.647V2.5a.5.5 0 01.854-.354l5 5a.5.5 0 010 .708l-5 5A.5.5 0 018 12.5V8.707l-4.646 4.647A.5.5 0 012.5 13V2z"})}):a?r.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:[r.jsx("rect",{x:"4",y:"3",width:"3",height:"10",rx:"0.75"}),r.jsx("rect",{x:"9",y:"3",width:"3",height:"10",rx:"0.75"})]}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M4 2l10 6-10 6V2z"})})}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx("div",{className:"relative w-full h-1.5 rounded-full bg-cc-hover overflow-hidden",children:r.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full bg-cc-primary transition-all duration-300",style:{width:`${s>0?t/s*100:0}%`}})})}),r.jsxs("span",{className:"text-[11px] text-cc-muted tabular-nums font-mono-code shrink-0",children:[t,"/",s]}),r.jsx("div",{className:"flex items-center gap-0.5 shrink-0",children:[1,2,4,8].map(c=>r.jsxs("button",{className:`px-1.5 py-0.5 text-[10px] font-medium rounded transition-colors cursor-pointer ${c===n?"bg-cc-primary/20 text-cc-primary":"text-cc-muted hover:bg-cc-hover"}`,children:[c,"x"]},c))})]})}function kP({task:e}){const t=e.status==="completed",s=e.status==="in_progress";return r.jsxs("div",{className:`px-2.5 py-2 rounded-lg ${t?"opacity-50":""}`,children:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"shrink-0 flex items-center justify-center w-4 h-4 mt-px",children:s?r.jsx("svg",{className:"w-4 h-4 text-cc-primary animate-spin",viewBox:"0 0 16 16",fill:"none",children:r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"28",strokeDashoffset:"8",strokeLinecap:"round"})}):t?r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-cc-success",children:r.jsx("path",{fillRule:"evenodd",d:"M8 15A7 7 0 108 1a7 7 0 000 14zm3.354-9.354a.5.5 0 00-.708-.708L7 8.586 5.354 6.94a.5.5 0 10-.708.708l2 2a.5.5 0 00.708 0l4-4z",clipRule:"evenodd"})}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-4 h-4 text-cc-muted",children:r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"})})}),r.jsx("span",{className:`text-[13px] leading-snug flex-1 ${t?"text-cc-muted line-through":"text-cc-fg"}`,children:e.subject})]}),s&&e.activeForm&&r.jsx("p",{className:"mt-1 ml-6 text-[11px] text-cc-muted italic truncate",children:e.activeForm}),e.blockedBy&&e.blockedBy.length>0&&r.jsxs("p",{className:"mt-1 ml-6 text-[11px] text-cc-muted flex items-center gap-1",children:[r.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-3 h-3 shrink-0",children:[r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"}),r.jsx("path",{d:"M5 8h6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),r.jsxs("span",{children:["blocked by ",e.blockedBy.map(n=>`#${n}`).join(", ")]})]})]})}const CP={checking_image:"Checking image",pulling_image:"Pulling image",creating_container:"Creating container",seeding_auth:"Seeding authentication",launching_agent:"Launching agent"};function NP(e,t,s){return t?EP(t,s):TP(e,s)}function EP(e,t){const s=["checking_image","pulling_image","creating_container","seeding_auth","launching_agent"],n=s.indexOf(e.step),a=s.map((l,c)=>{let d="pending";return c<n?d="done":c===n&&(d="active"),{label:CP[l]||l,status:d}});if(t)for(const l of a)l.status="done";return a}function MP(e,t){return t?"done":e?"active":"pending"}function TP(e,t){const s=e==="starting",n=t||e==="connected"||e==="running";return[{label:"Spawning process",status:s||n?"done":"active"},{label:"Waiting for connection",status:MP(s,n)},{label:"Ready",status:n?"done":"pending"}]}function AP(e,t=2e3){const[s,n]=w.useState(!1),a=w.useRef(void 0);return w.useEffect(()=>(clearTimeout(a.current),e?a.current=setTimeout(()=>n(!0),t):n(!1),()=>clearTimeout(a.current)),[e,t]),s}function RP(){const e=G(k=>k.sdkSessions),t=G(k=>k.cliConnected),s=G(k=>k.sessionCreating),n=G(k=>k.creationProgress),a=G(k=>k.creationError),l=G(k=>k.sessionNames),c=e.filter(k=>k.state==="starting"&&!k.archived),d=s&&!a,f=c.length>0||d,h=c.length>0?c[c.length-1]:null,m=h==null?void 0:h.sessionId,g=m?l.get(m):null,_=h==null?void 0:h.state,v=m?t.get(m)??!1:!1,y=NP(_,d?n:null,v),S=y.every(k=>k.status==="done"),j=AP(S);return!f&&!a||j&&!a?null:a?r.jsx("div",{className:"fixed bottom-4 left-4 z-40 w-72 rounded-xl border border-cc-error/30 bg-cc-card shadow-float animate-slide-up overflow-hidden",children:r.jsxs("div",{className:"px-3 py-2.5 flex items-center gap-2",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-cc-error shrink-0","aria-hidden":!0,children:r.jsx("path",{d:"M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-[11px] font-medium text-cc-error",children:"Launch failed"}),r.jsx("p",{className:"text-[10px] text-cc-muted truncate",children:a})]})]})}):r.jsxs("div",{className:"fixed bottom-4 left-4 z-40 w-64 rounded-xl border border-cc-border/60 bg-cc-card/95 backdrop-blur-xl shadow-float animate-slide-up overflow-hidden",style:{transition:"opacity 0.4s ease-out",opacity:j?0:1},children:[r.jsxs("div",{className:"px-3 py-2 border-b border-cc-border/30 flex items-center gap-2",children:[!S&&r.jsxs("svg",{className:"w-3.5 h-3.5 text-cc-primary animate-spin shrink-0",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:[r.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),r.jsx("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),S&&r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-success shrink-0","aria-hidden":!0,children:r.jsx("path",{d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})}),r.jsx("span",{className:"text-[11px] font-medium text-cc-fg truncate",children:S?"Session ready":"Launching session"}),g&&r.jsx("span",{className:"text-[9px] text-cc-muted font-mono-code truncate ml-auto",children:g})]}),r.jsx("div",{className:"px-3 py-2 space-y-1",children:y.map(k=>r.jsx(LP,{step:k},k.label))}),(n==null?void 0:n.percent)!=null&&r.jsxs("div",{className:"px-3 pb-2",children:[r.jsx("div",{className:"w-full h-1 rounded-full bg-cc-hover overflow-hidden",children:r.jsx("div",{className:"h-full rounded-full bg-cc-primary transition-all duration-300",style:{width:`${Math.min(100,n.percent)}%`}})}),r.jsx("p",{className:"text-[9px] text-cc-muted/60 font-mono-code mt-0.5 truncate",children:n.message})]})]})}function DP(e){return e==="done"?"text-cc-muted/50":e==="active"?"text-cc-fg":"text-cc-muted/40"}function LP({step:e}){return r.jsxs("div",{className:"flex items-center gap-2",children:[e.status==="done"&&r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-success shrink-0","aria-hidden":!0,children:r.jsx("path",{d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})}),e.status==="active"&&r.jsxs("svg",{className:"w-3 h-3 text-cc-primary animate-spin shrink-0",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:[r.jsx("circle",{cx:"8",cy:"8",r:"5",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),r.jsx("path",{d:"M13 8a5 5 0 00-5-5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.status==="pending"&&r.jsx("svg",{className:"w-3 h-3 text-cc-muted/30 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":!0,children:r.jsx("circle",{cx:"8",cy:"8",r:"4.5"})}),r.jsx("span",{className:`text-[10px] ${DP(e.status)}`,children:e.label})]})}function Nx(e){if(e<6e4)return`${Math.round(e/1e3)}s`;const t=Math.floor(e/6e4);return t<60?`${t}m`:`${Math.floor(t/60)}h ${t%60}m`}function BP(e){return new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function OP(e){return e==="playable"?"Playable":e==="metadata"?"Metadata only":"All types"}function zP(e){if(e.compatible)return"Protocol Compatible";const t=e.diffs.length;return`${t} Issue${t>1?"s":""}`}const PP=new Set(["assistant","result","user_message","stream_event","permission_request","permission_cancelled","status_change","session_init","session_update","cli_connected","error","tool_progress","session_name_update"]);function fg(e){return Object.keys(e).some(t=>PP.has(t))}const MC={claude:"text-[#5BA8A0] bg-[#5BA8A0]/10",codex:"text-blue-500 bg-blue-500/10",goose:"text-amber-500 bg-amber-500/10",aider:"text-purple-500 bg-purple-500/10",openhands:"text-rose-500 bg-rose-500/10",openclaw:"text-orange-500 bg-orange-500/10",opencode:"text-teal-500 bg-teal-500/10"};function $P({embedded:e=!1}){const[t,s]=w.useState([]),[n,a]=w.useState(!0),[l,c]=w.useState(!1),[d,f]=w.useState(null),[h,m]=w.useState(null),[g,_]=w.useState(null),[v,y]=w.useState(!1),[S,j]=w.useState(""),[k,N]=w.useState("all"),[E,B]=w.useState("all"),[F,$]=w.useState("newest"),K=w.useCallback(()=>{ne.listHubRecordings().then(s).catch(()=>{}).finally(()=>a(!1))},[]);w.useEffect(()=>{K()},[K]);async function Y(){c(!0);try{(await ne.indexAllRecordings()).imported>0&&K()}catch{}c(!1)}async function W(A){if(d===A){f(null);return}f(A),m(null),_(null),y(!0);try{const[M,O]=await Promise.all([ne.validateRecording(A),ne.getRecordingDiagnostics(A)]);m(M),_(O)}catch{}y(!1)}async function L(A){await ne.deleteHubRecording(A).catch(()=>{}),K()}const Q=w.useCallback(A=>{globalThis.location.hash=`#/replay/${encodeURIComponent(A)}`},[]),V=w.useMemo(()=>[...new Set(t.map(M=>M.backendType))].sort((M,O)=>M.localeCompare(O)),[t]),X=w.useMemo(()=>{const A={all:t.length};for(const M of t)A[M.backendType]=(A[M.backendType]||0)+1;return A},[t]),q=w.useMemo(()=>{let A=t;if(S){const M=S.toLowerCase();A=A.filter(O=>O.filename.toLowerCase().includes(M)||O.backendType.includes(M)||O.tags.some(U=>U.toLowerCase().includes(M)))}return k!=="all"&&(A=A.filter(M=>M.backendType===k)),E==="playable"?A=A.filter(M=>fg(M.messageTypeSummary)):E==="metadata"&&(A=A.filter(M=>!fg(M.messageTypeSummary))),[...A].sort((M,O)=>F==="oldest"?M.startedAt-O.startedAt:F==="longest"?O.duration-M.duration:F==="most-messages"?O.entryCount-M.entryCount:O.startedAt-M.startedAt)},[t,S,k,E,F]);return r.jsxs("div",{className:e?"px-4 py-6 max-w-5xl mx-auto":"p-6 max-w-5xl mx-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Recording Hub"}),r.jsx("p",{className:"text-[12px] text-cc-muted mt-0.5",children:"Browse, validate, and diagnose session recordings"})]}),r.jsx("button",{onClick:Y,disabled:l,className:"px-3 py-1.5 rounded-lg bg-cc-primary text-white text-[12px] font-medium hover:bg-cc-primary-hover transition-colors cursor-pointer disabled:opacity-40",children:l?"Indexing...":"Index Recordings"})]}),r.jsx("div",{className:"mb-3",children:r.jsx("input",{value:S,onChange:A=>j(A.target.value),placeholder:"Search by filename, backend, or tag...",className:"w-full h-9 px-3 rounded-lg border border-cc-border bg-cc-input-bg text-[13px] text-cc-fg placeholder:text-cc-muted/30 focus:outline-none focus:ring-2 focus:ring-cc-primary/20"})}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsxs("button",{onClick:()=>N("all"),className:`px-2 py-1 rounded-md text-[10px] font-medium transition-colors cursor-pointer ${k==="all"?"bg-cc-primary/10 text-cc-primary":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:["All ",r.jsx("span",{className:"ml-0.5 opacity-60 tabular-nums",children:X.all})]}),V.map(A=>{const M=MC[A]||"text-cc-muted bg-cc-hover";return r.jsxs("button",{onClick:()=>N(k===A?"all":A),className:`px-2 py-1 rounded-md text-[10px] font-medium transition-colors cursor-pointer ${k===A?M:"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:[A," ",r.jsx("span",{className:"ml-0.5 opacity-60 tabular-nums",children:X[A]||0})]},A)})]}),r.jsx("div",{className:"w-px h-4 bg-cc-border/50"}),r.jsx("div",{className:"flex items-center gap-1",children:["all","playable","metadata"].map(A=>r.jsx("button",{onClick:()=>B(A),className:`px-2 py-1 rounded-md text-[10px] font-medium transition-colors cursor-pointer ${E===A?"bg-cc-primary/10 text-cc-primary":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:OP(A)},A))}),r.jsx("div",{className:"w-px h-4 bg-cc-border/50"}),r.jsxs("select",{value:F,onChange:A=>$(A.target.value),className:"h-7 px-2 rounded-md border border-cc-border bg-cc-input-bg text-[10px] text-cc-fg cursor-pointer","aria-label":"Sort recordings",children:[r.jsx("option",{value:"newest",children:"Newest first"}),r.jsx("option",{value:"oldest",children:"Oldest first"}),r.jsx("option",{value:"longest",children:"Longest duration"}),r.jsx("option",{value:"most-messages",children:"Most messages"})]}),r.jsxs("span",{className:"text-[10px] text-cc-muted/50 ml-auto tabular-nums",children:[q.length," recording",q.length===1?"":"s"]})]}),n&&r.jsx("p",{className:"text-cc-muted text-sm",children:"Loading..."}),!n&&q.length===0&&r.jsxs("div",{className:"text-center py-12 text-cc-muted",children:[r.jsx("p",{className:"text-sm",children:"No recordings found yet"}),r.jsx("p",{className:"text-xs mt-1",children:'Use "Index Recordings" to refresh the recording index'})]}),r.jsx("div",{className:"space-y-2",children:q.map(A=>r.jsxs("div",{children:[r.jsx(IP,{recording:A,playable:fg(A.messageTypeSummary),isExpanded:d===A.id,onExpand:()=>W(A.id),onDelete:()=>L(A.id),onReplay:()=>Q(A.filename)}),d===A.id&&r.jsx(FP,{recording:A,validation:h,diagnostics:g,loading:v})]},A.id))})]})}function IP({recording:e,playable:t,isExpanded:s,onExpand:n,onDelete:a,onReplay:l}){const c=MC[e.backendType]||"text-cc-muted bg-cc-hover";return r.jsx("div",{className:`border rounded-lg transition-all ${s?"border-cc-primary/30 bg-cc-primary/[0.02]":"border-cc-border bg-cc-card hover:shadow-panel"}`,children:r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r.jsx("span",{className:`text-[9px] font-semibold px-2 py-0.5 rounded-full ${c}`,children:e.backendType}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-[12px] font-medium text-cc-fg truncate block font-mono-code",children:e.filename}),r.jsxs("div",{className:"flex items-center gap-3 mt-0.5 text-[10px] text-cc-muted",children:[r.jsx("span",{children:BP(e.startedAt)}),r.jsx("span",{className:"tabular-nums",children:Nx(e.duration)}),r.jsxs("span",{className:"tabular-nums",children:[e.entryCount," msgs"]}),!t&&r.jsx("span",{className:"text-cc-muted/40",children:"metadata only"})]})]}),e.tags.length>0&&r.jsx("div",{className:"flex gap-1 shrink-0",children:e.tags.slice(0,3).map(d=>r.jsx("span",{className:"text-[8px] px-1.5 py-0.5 rounded-full bg-cc-hover text-cc-muted",children:d},d))}),r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx("button",{onClick:l,disabled:!t,title:t?"Replay":"No playable messages",className:`p-1.5 rounded-md transition-colors ${t?"hover:bg-cc-hover text-cc-primary cursor-pointer":"text-cc-muted/30 cursor-not-allowed"}`,children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5","aria-hidden":!0,children:r.jsx("path",{d:"M4 2l10 6-10 6V2z"})})}),r.jsx("button",{onClick:n,title:"Details",className:`p-1.5 rounded-md hover:bg-cc-hover cursor-pointer transition-colors ${s?"text-cc-primary":"text-cc-muted"}`,children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5","aria-hidden":!0,children:r.jsx("path",{d:"M8 2a6 6 0 100 12A6 6 0 008 2zm.75 3.5a.75.75 0 00-1.5 0v2.25H5a.75.75 0 000 1.5h2.25V11.5a.75.75 0 001.5 0V9.25H11a.75.75 0 000-1.5H8.75V5.5z"})})}),r.jsx("button",{onClick:a,title:"Remove from hub",className:"p-1.5 rounded-md hover:bg-cc-hover text-cc-muted hover:text-cc-error cursor-pointer transition-colors",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5","aria-hidden":!0,children:r.jsx("path",{d:"M6.5 1.75a.25.25 0 01.25-.25h2.5a.25.25 0 01.25.25V3h-3V1.75zM11 3V1.75A1.75 1.75 0 009.25 0h-2.5A1.75 1.75 0 005 1.75V3H2.75a.75.75 0 000 1.5h.928l.856 10.268A1.75 1.75 0 006.282 16h3.436a1.75 1.75 0 001.748-1.632l.856-10.268h.928a.75.75 0 000-1.5H11z"})})})]})]})})}function FP({recording:e,validation:t,diagnostics:s,loading:n}){return n?r.jsxs("div",{className:"ml-4 my-2 flex items-center gap-2 text-cc-muted text-[11px]",children:[r.jsx("div",{className:"w-3.5 h-3.5 border-2 border-cc-primary border-t-transparent rounded-full animate-spin"}),"Analyzing recording..."]}):r.jsxs("div",{className:"mx-4 mb-3 mt-1 grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t&&r.jsxs("div",{className:`rounded-lg border p-3 ${t.compatible?"border-cc-success/30 bg-cc-success/[0.03]":"border-cc-error/30 bg-cc-error/[0.03]"}`,children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.compatible?r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-cc-success","aria-hidden":!0,children:r.jsx("path",{d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-cc-error","aria-hidden":!0,children:r.jsx("path",{d:"M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"})}),r.jsx("span",{className:"text-[12px] font-semibold text-cc-fg",children:zP(t)})]}),r.jsxs("div",{className:"text-[10px] text-cc-muted space-y-0.5",children:[r.jsxs("p",{children:["Checked ",t.checkedMessages," of ",t.totalMessages," messages"]}),r.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(t.messageTypeBreakdown).slice(0,8).map(([a,l])=>r.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[8px] font-mono-code ${l.issues>0?"bg-cc-error/10 text-cc-error":"bg-cc-hover text-cc-muted"}`,children:[a,": ",l.count]},a))})]})]}),s&&r.jsxs("div",{className:"rounded-lg border border-cc-border p-3",children:[r.jsx("h4",{className:"text-[12px] font-semibold text-cc-fg mb-2",children:"Health Report"}),r.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-[10px]",children:[r.jsx("span",{className:"text-cc-muted",children:"Duration"}),r.jsx("span",{className:"text-cc-fg font-mono-code tabular-nums",children:Nx(s.totalDuration)}),r.jsx("span",{className:"text-cc-muted",children:"Messages"}),r.jsx("span",{className:"text-cc-fg font-mono-code tabular-nums",children:s.totalMessages}),r.jsx("span",{className:"text-cc-muted",children:"Msg/min"}),r.jsx("span",{className:"text-cc-fg font-mono-code tabular-nums",children:s.messageRate}),r.jsx("span",{className:"text-cc-muted",children:"Disconnections"}),r.jsx("span",{className:`font-mono-code tabular-nums ${s.disconnections.length>0?"text-cc-error":"text-cc-fg"}`,children:s.disconnections.length}),r.jsx("span",{className:"text-cc-muted",children:"Data Gaps"}),r.jsx("span",{className:`font-mono-code tabular-nums ${s.dataGaps.length>0?"text-cc-warning":"text-cc-fg"}`,children:s.dataGaps.length}),s.avgPermissionResponseMs!==null&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-cc-muted",children:"Avg Perm Response"}),r.jsx("span",{className:"text-cc-fg font-mono-code tabular-nums",children:Nx(s.avgPermissionResponseMs)})]})]}),r.jsx("div",{className:"mt-2 space-y-0.5",children:s.patterns.map(a=>r.jsx("p",{className:`text-[9px] ${a.includes("No anomalies")?"text-cc-success":"text-cc-warning"}`,children:a},a))})]})]})}function HP(e){const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const s=Math.floor(t/60);return s<60?`${s}m ${t%60}s`:`${Math.floor(s/60)}h ${s%60}m`}function s2(e){return new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}const n2={claude:"text-[#5BA8A0]",codex:"text-blue-500",goose:"text-amber-500",aider:"text-purple-500",openhands:"text-rose-500",openclaw:"text-orange-500",opencode:"text-teal-500"};function UP({embedded:e=!1}){const[t,s]=w.useState(null),[n,a]=w.useState(!0),l=G(d=>d.sessionNames),c=w.useCallback(()=>{ne.getMonitorStats().then(s).catch(()=>{}).finally(()=>a(!1))},[]);return w.useEffect(()=>{c();const d=setInterval(c,3e3);return()=>clearInterval(d)},[c]),n?r.jsx("div",{className:"flex items-center justify-center h-64 text-cc-muted text-sm",children:"Loading monitor..."}):t?r.jsxs("div",{className:e?"px-4 py-6 max-w-5xl mx-auto":"p-6 max-w-5xl mx-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Protocol Monitor"}),r.jsx("p",{className:"text-[12px] text-cc-muted mt-0.5",children:"Real-time WebSocket message flow and health metrics"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-2 h-2 rounded-full bg-cc-success animate-breathing"}),r.jsxs("span",{className:"text-[11px] text-cc-muted font-mono-code",children:["Live · ",HP(t.uptime)]})]})]}),r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-5",children:[r.jsx(Wd,{label:"Total Messages",value:t.totalMessages.toLocaleString()}),r.jsx(Wd,{label:"Messages/min",value:String(t.globalMessagesPerMinute),accent:t.globalMessagesPerMinute>0}),r.jsx(Wd,{label:"Active Sessions",value:String(t.activeSessions)}),r.jsx(Wd,{label:"Errors",value:String(t.totalErrors),error:t.totalErrors>0})]}),Object.keys(t.backendBreakdown).length>0&&r.jsxs("div",{className:"mb-5",children:[r.jsx("h2",{className:"text-[12px] font-semibold text-cc-fg mb-2",children:"Backend Breakdown"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(t.backendBreakdown).map(([d,f])=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-cc-border bg-cc-card",children:[r.jsx("span",{className:`text-[12px] font-semibold ${n2[d]||"text-cc-muted"}`,children:d}),r.jsxs("span",{className:"text-[11px] text-cc-fg font-mono-code tabular-nums",children:[f.messages," msgs"]}),f.errors>0&&r.jsxs("span",{className:"text-[10px] text-cc-error font-mono-code tabular-nums",children:[f.errors," err"]})]},d))})]}),Object.keys(t.messageTypeGlobal).length>0&&r.jsxs("div",{className:"mb-5",children:[r.jsx("h2",{className:"text-[12px] font-semibold text-cc-fg mb-2",children:"Message Types (5min window)"}),r.jsx("div",{className:"flex flex-wrap gap-1",children:Object.entries(t.messageTypeGlobal).sort(([,d],[,f])=>f-d).slice(0,20).map(([d,f])=>r.jsxs("span",{className:"text-[9px] font-mono-code px-1.5 py-0.5 rounded bg-cc-hover text-cc-muted",children:[d,": ",r.jsx("span",{className:"text-cc-fg tabular-nums",children:f})]},d))})]}),t.sessionStats.length>0&&r.jsxs("div",{className:"mb-5",children:[r.jsx("h2",{className:"text-[12px] font-semibold text-cc-fg mb-2",children:"Active Sessions"}),r.jsx("div",{className:"space-y-1.5",children:t.sessionStats.map(d=>{const f=l.get(d.sessionId)||d.sessionId.slice(0,8);return r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg border border-cc-border bg-cc-card",children:[r.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-full ${n2[d.backendType]||"text-cc-muted"} bg-current/10`,children:d.backendType}),r.jsx("span",{className:"text-[12px] font-medium text-cc-fg truncate flex-1",children:f}),r.jsxs("span",{className:"text-[10px] text-cc-muted font-mono-code tabular-nums",children:[d.messageCount," msgs"]}),r.jsxs("span",{className:"text-[10px] text-cc-muted font-mono-code tabular-nums",children:[d.messagesPerMinute,"/min"]}),d.errorCount>0&&r.jsxs("span",{className:"text-[10px] text-cc-error font-mono-code tabular-nums",children:[d.errorCount," err"]}),r.jsx("span",{className:"text-[10px] text-cc-muted/50 font-mono-code",children:s2(d.lastMessageAt)})]},d.sessionId)})})]}),t.recentDrifts.length>0&&r.jsxs("div",{children:[r.jsx("h2",{className:"text-[12px] font-semibold text-cc-error mb-2",children:"Protocol Drift Alerts"}),r.jsx("div",{className:"space-y-1",children:t.recentDrifts.map(d=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-cc-error/20 bg-cc-error/[0.03]",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-error shrink-0","aria-hidden":!0,children:r.jsx("path",{d:"M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754z"})}),r.jsx("span",{className:"text-[11px] font-medium text-cc-fg",children:d.backendType}),r.jsxs("span",{className:"text-[10px] text-cc-muted font-mono-code",children:[d.direction," ",d.messageType]}),r.jsx("span",{className:"text-[10px] text-cc-error/70 flex-1 truncate",children:d.details}),r.jsx("span",{className:"text-[9px] text-cc-muted/50 font-mono-code",children:s2(d.timestamp)})]},`${d.backendType}-${d.messageType}-${d.timestamp}`))})]}),t.activeSessions===0&&t.totalMessages===0&&r.jsxs("div",{className:"text-center py-12 text-cc-muted",children:[r.jsx("p",{className:"text-sm",children:"No activity yet"}),r.jsx("p",{className:"text-xs mt-1",children:"Start a session to see real-time protocol metrics"})]})]}):r.jsx("div",{className:"flex items-center justify-center h-64 text-cc-muted text-sm",children:"Monitor not available"})}function VP(e,t){return e?"text-cc-error":t?"text-cc-primary":"text-cc-fg"}function Wd({label:e,value:t,accent:s=!1,error:n=!1}){return r.jsxs("div",{className:"rounded-xl border border-cc-border bg-cc-card px-4 py-3",children:[r.jsx("p",{className:"text-[10px] text-cc-muted uppercase tracking-wider mb-1",children:e}),r.jsx("p",{className:`text-xl font-bold font-mono-code tabular-nums ${VP(n,s)}`,children:t})]})}const WP={help:"Show available commands and keyboard shortcuts",clear:"Clear conversation history and start fresh",compact:"Compact conversation to save context window space",cost:"Show token usage and cost for this session",doctor:"Check health of Claude Code installation",init:"Initialize a new CLAUDE.md project file",login:"Switch accounts or re-authenticate",logout:"Sign out of current account",memory:"View and edit CLAUDE.md memory files",model:"Switch the AI model for this session",permissions:"View and manage tool permissions",review:"Review recent changes made by Claude",status:"Show session status, model, and connection info","terminal-setup":"Configure terminal integration (Shift+Enter)",vim:"Toggle vim keybindings mode"};function qP({embedded:e=!1}){var V,X;const[t,s]=w.useState([]),[n,a]=w.useState([]),[l,c]=w.useState(!0),[d,f]=w.useState(""),[h,m]=w.useState(null),[g,_]=w.useState(""),[v,y]=w.useState(!1),S=G(q=>q.currentSessionId),j=G(q=>q.sessions),k=G(q=>q.sdkSessions),N=S?((V=j.get(S))==null?void 0:V.cwd)||((X=k.find(q=>q.sessionId===S))==null?void 0:X.cwd):void 0,E=w.useCallback(()=>{ne.discoverCommands(N).then(q=>{s(q.commands),a(q.skills)}).catch(()=>{}).finally(()=>c(!1))},[N]);w.useEffect(()=>{E()},[E]);async function B(q){if(h===q){m(null);return}m(q),y(!0);try{const A=await ne.readCommand(q);_(A.content)}catch{_("Failed to read file")}y(!1)}const F=d.toLowerCase(),$=F?t.filter(q=>q.name.includes(F)||q.description.toLowerCase().includes(F)):t,K=F?n.filter(q=>q.slug.includes(F)||q.name.toLowerCase().includes(F)||q.description.toLowerCase().includes(F)):n,[Y,W]=w.useState([]);w.useEffect(()=>{ne.getSlashCommands().then(q=>{W(q.commands.map(A=>({name:A,description:WP[A]||""})))}).catch(()=>{})},[]);const L=F?Y.filter(q=>q.name.includes(F)||q.description.toLowerCase().includes(F)):Y,Q=$.length+K.length+L.length;return r.jsxs("div",{className:e?"px-4 py-6 max-w-4xl mx-auto":"p-6 max-w-4xl mx-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Commands & Skills"}),r.jsxs("p",{className:"text-[12px] text-cc-muted mt-0.5",children:["Slash commands from ",r.jsx("code",{className:"font-mono-code text-[10px] bg-cc-hover px-1 rounded",children:"~/.claude/commands/"})," and skills from ",r.jsx("code",{className:"font-mono-code text-[10px] bg-cc-hover px-1 rounded",children:"~/.claude/skills/"})]})]}),r.jsx("button",{onClick:E,className:"px-3 py-1.5 rounded-lg text-[12px] text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Refresh"})]}),r.jsx("div",{className:"mb-4",children:r.jsx("input",{value:d,onChange:q=>f(q.target.value),placeholder:"Search commands and skills...",className:"w-full h-9 px-3 rounded-lg border border-cc-border bg-cc-input-bg text-[13px] text-cc-fg placeholder:text-cc-muted/30 focus:outline-none focus:ring-2 focus:ring-cc-primary/20"})}),l&&r.jsx("p",{className:"text-cc-muted text-sm",children:"Discovering commands..."}),!l&&Q===0&&r.jsxs("div",{className:"text-center py-12 text-cc-muted",children:[r.jsx("p",{className:"text-sm",children:"No commands or skills found"}),r.jsxs("p",{className:"text-xs mt-1",children:["Create ",r.jsx("code",{className:"font-mono-code bg-cc-hover px-1 rounded",children:"~/.claude/commands/my-command.md"})," to add a slash command"]})]}),L.length>0&&r.jsxs("div",{className:"mb-6",children:[r.jsxs("h2",{className:"text-[11px] font-semibold text-cc-muted uppercase tracking-wider mb-2",children:["Built-in Commands ",r.jsx("span",{className:"text-cc-muted/50 tabular-nums ml-1",children:L.length})]}),r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5",children:L.map(q=>r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 rounded-lg border border-cc-border bg-cc-card",children:[r.jsx("span",{className:"w-7 h-7 rounded-md bg-cc-muted/10 text-cc-muted flex items-center justify-center text-[13px] font-bold shrink-0",children:"/"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("span",{className:"text-[12px] font-medium text-cc-fg font-mono-code",children:["/",q.name]}),r.jsx("p",{className:"text-[10px] text-cc-muted truncate",children:q.description})]})]},q.name))})]}),$.length>0&&r.jsxs("div",{className:"mb-6",children:[r.jsxs("h2",{className:"text-[11px] font-semibold text-cc-muted uppercase tracking-wider mb-2",children:["Custom Commands ",r.jsx("span",{className:"text-cc-muted/50 tabular-nums ml-1",children:$.length})]}),r.jsx("div",{className:"space-y-1.5",children:$.map(q=>r.jsxs("div",{children:[r.jsxs("button",{onClick:()=>B(q.path),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-lg border text-left transition-all cursor-pointer ${h===q.path?"border-cc-primary/30 bg-cc-primary/[0.03]":"border-cc-border bg-cc-card hover:shadow-panel"}`,children:[r.jsx("span",{className:"w-7 h-7 rounded-md bg-cc-primary/10 text-cc-primary flex items-center justify-center text-[13px] font-bold shrink-0",children:"/"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"text-[13px] font-medium text-cc-fg font-mono-code",children:["/",q.name]}),r.jsx("span",{className:`text-[8px] font-semibold px-1.5 rounded-full ${q.source==="project"?"text-amber-500 bg-amber-500/10":"text-cc-muted bg-cc-hover"}`,children:q.source})]}),q.description&&r.jsx("p",{className:"text-[11px] text-cc-muted truncate mt-0.5",children:q.description})]}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 text-cc-muted/40 transition-transform duration-150 shrink-0 ${h===q.path?"rotate-90":""}`,"aria-hidden":!0,children:r.jsx("path",{d:"M6 4l4 4-4 4V4z"})})]}),h===q.path&&r.jsx("div",{className:"ml-10 mt-1 mb-2",children:v?r.jsx("p",{className:"text-[11px] text-cc-muted py-2",children:"Loading..."}):r.jsx("pre",{className:"text-[11px] text-cc-code-fg bg-cc-code-bg rounded-lg p-3 overflow-x-auto max-h-64 overflow-y-auto font-mono-code leading-relaxed",children:g})})]},q.path))})]}),K.length>0&&r.jsxs("div",{children:[r.jsxs("h2",{className:"text-[11px] font-semibold text-cc-muted uppercase tracking-wider mb-2",children:["Skills ",r.jsx("span",{className:"text-cc-muted/50 tabular-nums ml-1",children:K.length})]}),r.jsx("div",{className:"space-y-1.5",children:K.map(q=>r.jsxs("div",{children:[r.jsxs("button",{onClick:()=>B(q.path),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-lg border text-left transition-all cursor-pointer ${h===q.path?"border-cc-primary/30 bg-cc-primary/[0.03]":"border-cc-border bg-cc-card hover:shadow-panel"}`,children:[r.jsx("span",{className:"w-7 h-7 rounded-md bg-cc-success/10 text-cc-success flex items-center justify-center shrink-0",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5","aria-hidden":!0,children:r.jsx("path",{d:"M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754z"})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-[13px] font-medium text-cc-fg",children:q.name}),q.description&&r.jsx("p",{className:"text-[11px] text-cc-muted truncate mt-0.5",children:q.description})]}),r.jsx("span",{className:"text-[9px] font-mono-code text-cc-muted/40 shrink-0",children:q.slug}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 text-cc-muted/40 transition-transform duration-150 shrink-0 ${h===q.path?"rotate-90":""}`,"aria-hidden":!0,children:r.jsx("path",{d:"M6 4l4 4-4 4V4z"})})]}),h===q.path&&r.jsx("div",{className:"ml-10 mt-1 mb-2",children:v?r.jsx("p",{className:"text-[11px] text-cc-muted py-2",children:"Loading..."}):r.jsx("pre",{className:"text-[11px] text-cc-code-fg bg-cc-code-bg rounded-lg p-3 overflow-x-auto max-h-64 overflow-y-auto font-mono-code leading-relaxed",children:g})})]},q.path))})]})]})}const GP=["welcome","providers","workspace","tour","launch"];function KP(e){return GP.indexOf(e)}function YP(e,t){return e?"bg-cc-primary text-white":t?"bg-cc-primary/15 text-cc-primary ring-2 ring-cc-primary/30":"bg-cc-hover text-cc-muted/50"}function XP(e){return e==="subscription"?"Logged in":e==="oauth-token"?"Token set":e==="api-key"?"API key set":""}function JP({onComplete:e}){const[t,s]=w.useState("welcome"),[n,a]=w.useState(null),[l,c]=w.useState(""),[d,f]=w.useState(""),[h,m]=w.useState(""),[g,_]=w.useState(!1),[v,y]=w.useState(""),S=w.useRef(null),j=KP(t);w.useEffect(()=>{var B;(B=S.current)==null||B.focus()},[t]),w.useEffect(()=>{ne.getProviderAuthStatus().then(a).catch(()=>{})},[t]);const k=w.useCallback(async()=>{try{await ne.updateSettings({onboardingCompleted:!0})}catch{}e()},[e]);async function N(){_(!0),y("");try{const B={};l.trim()&&(B.claudeOAuthToken=l.trim()),d.trim()&&(B.openaiApiKey=d.trim()),Object.keys(B).length>0&&await ne.updateSettings(B),s("workspace")}catch(B){y(B instanceof Error?B.message:"Failed to save")}finally{_(!1)}}function E(){ne.getProviderAuthStatus().then(a).catch(()=>{})}return r.jsx("dialog",{ref:S,open:!0,"aria-label":"Campfire setup wizard",className:"fixed inset-0 z-50 flex items-center justify-center w-full h-full m-0 p-0 bg-black/50 backdrop-blur-md border-none outline-none",children:r.jsxs("div",{className:"w-full max-w-[520px] mx-5 bg-cc-card rounded-2xl shadow-float border border-cc-border/60 overflow-hidden animate-slide-up",children:[r.jsx(QP,{current:j,total:4}),r.jsxs("div",{className:"px-7 pb-7 pt-5",children:[t==="welcome"&&r.jsx(ZP,{onNext:()=>s("providers"),onSkip:k}),t==="providers"&&r.jsx(e9,{authStatus:n,claudeToken:l,openaiKey:d,onClaudeTokenChange:c,onOpenaiKeyChange:f,saving:g,error:v,onSave:N,onSkip:()=>s("workspace"),onRefreshAuth:E}),t==="workspace"&&r.jsx(t9,{cwd:h,onCwdChange:m,onNext:()=>s("tour"),onSkip:()=>s("tour")}),t==="tour"&&r.jsx(n9,{onNext:()=>s("launch")}),t==="launch"&&r.jsx(r9,{cwd:h,onComplete:k})]})]})})}const r2=["Welcome","Providers","Workspace","Features"];function QP({current:e,total:t}){return e>=t?null:r.jsxs("output",{className:"block px-7 pt-6 pb-1","aria-label":`Step ${e+1} of ${t}: ${r2[e]}`,children:[r.jsx("div",{className:"flex items-center gap-1.5",children:Array.from({length:t},(s,n)=>{const a=n<e,l=n===e;return r.jsxs("div",{className:"flex items-center gap-1.5 flex-1",children:[r.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-semibold shrink-0 transition-all duration-300 ${YP(a,l)}`,children:a?r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3","aria-hidden":!0,children:r.jsx("path",{d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})}):n+1}),n<t-1&&r.jsx("div",{className:`flex-1 h-[2px] rounded-full transition-colors duration-300 ${n<e?"bg-cc-primary":"bg-cc-border"}`})]},n)})}),r.jsx("p",{className:"text-[10px] text-cc-muted mt-2 font-medium",children:r2[e]})]})}function ZP({onNext:e,onSkip:t}){return r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"w-16 h-16 mx-auto mb-5 rounded-2xl bg-gradient-to-br from-cc-primary/20 to-cc-primary/5 flex items-center justify-center border border-cc-primary/10",children:r.jsx("span",{className:"text-3xl",role:"img","aria-label":"Campfire",children:"🔥"})}),r.jsx("h1",{className:"text-[22px] font-bold text-cc-fg tracking-tight",children:"Welcome to Campfire"}),r.jsx("p",{className:"text-[14px] text-cc-muted mt-2 leading-relaxed max-w-[380px] mx-auto",children:"A unified web interface for AI coding agents. Run Claude, Codex, Goose, Aider and more from your browser."}),r.jsxs("div",{className:"mt-8 space-y-3",children:[r.jsx("button",{onClick:e,autoFocus:!0,className:"w-full h-11 rounded-xl bg-cc-primary text-white text-[14px] font-semibold hover:bg-cc-primary-hover active:scale-[0.98] transition-all cursor-pointer shadow-sm",children:"Get Started"}),r.jsx("button",{onClick:t,className:"w-full text-[12px] text-cc-muted/60 hover:text-cc-muted transition-colors cursor-pointer py-1",children:"Skip setup — I'll configure later in Settings"})]})]})}function e9({authStatus:e,claudeToken:t,openaiKey:s,onClaudeTokenChange:n,onOpenaiKeyChange:a,saving:l,error:c,onSave:d,onSkip:f,onRefreshAuth:h}){return r.jsxs("div",{children:[r.jsx("h2",{className:"text-[18px] font-bold text-cc-fg tracking-tight",children:"Connect Providers"}),r.jsx("p",{className:"text-[13px] text-cc-muted mt-1 mb-5",children:"Set up one or both. You can add more anytime in Settings."}),c&&r.jsxs("div",{className:"mb-4 flex items-center gap-2 px-3 py-2.5 rounded-xl bg-cc-error/8 border border-cc-error/15",role:"alert",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-cc-error shrink-0","aria-hidden":!0,children:r.jsx("path",{d:"M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"})}),r.jsx("p",{className:"text-[12px] text-cc-error",children:c})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsx(i2,{name:"Claude Code",description:"Anthropic's coding agent",accentColor:"bg-[#5BA8A0]",authenticated:(e==null?void 0:e.claude.authenticated)??!1,method:(e==null?void 0:e.claude.method)??null,loginCommand:"claude auth login",loginHint:"Signs in with your Claude Pro, Max, or Team subscription",tokenLabel:"OAuth token or API key",tokenPlaceholder:"sk-ant-... or paste from claude setup-token",tokenValue:t,onTokenChange:n,onRefresh:h}),r.jsx(i2,{name:"Codex",description:"OpenAI's coding agent",accentColor:"bg-blue-500",authenticated:(e==null?void 0:e.codex.authenticated)??!1,method:(e==null?void 0:e.codex.method)??null,loginCommand:"codex login",loginHint:"Signs in with your ChatGPT Plus or Pro subscription",tokenLabel:"OpenAI API key",tokenPlaceholder:"sk-...",tokenValue:s,onTokenChange:a,onRefresh:h})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[r.jsx("button",{onClick:d,disabled:l,className:"flex-1 h-11 rounded-xl bg-cc-primary text-white text-[14px] font-semibold hover:bg-cc-primary-hover active:scale-[0.98] transition-all cursor-pointer disabled:opacity-40 shadow-sm",children:l?"Saving...":"Continue"}),r.jsx("button",{onClick:f,className:"h-11 px-5 rounded-xl text-[13px] font-medium text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Skip"})]})]})}function i2({name:e,description:t,accentColor:s,authenticated:n,method:a,loginCommand:l,loginHint:c,tokenLabel:d,tokenPlaceholder:f,tokenValue:h,onTokenChange:m,onRefresh:g}){const[_,v]=w.useState(!1),[y,S]=w.useState(!1);function j(){navigator.clipboard.writeText(l).catch(()=>{}),S(!0),setTimeout(()=>S(!1),1500)}return r.jsxs("div",{className:`rounded-xl border transition-colors ${n?"border-cc-success/30 bg-cc-success/[0.03]":"border-cc-border hover:border-cc-border/80"}`,children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r.jsx("div",{className:`w-8 h-8 rounded-lg ${s} flex items-center justify-center`,children:r.jsx("span",{className:"text-white text-sm font-bold",children:e.charAt(0)})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"text-[13px] font-semibold text-cc-fg",children:e}),r.jsx("p",{className:"text-[11px] text-cc-muted",children:t})]}),n&&r.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] font-medium text-cc-success bg-cc-success/10 px-2.5 py-1 rounded-full",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3","aria-hidden":!0,children:r.jsx("path",{d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})}),XP(a)]})]}),!n&&r.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] text-cc-muted mb-1.5",children:"Run in your terminal:"}),r.jsxs("div",{className:"flex items-center bg-cc-code-bg rounded-lg border border-cc-border/30 overflow-hidden",children:[r.jsxs("div",{className:"flex-1 flex items-center gap-2 px-3 py-2.5 min-w-0",children:[r.jsx("span",{className:"text-cc-code-fg/40 text-[12px] font-mono-code select-none","aria-hidden":!0,children:"$"}),r.jsx("code",{className:"text-[12px] font-mono-code text-cc-code-fg truncate",children:l})]}),r.jsx("button",{onClick:j,className:"px-3 py-2.5 text-[10px] font-medium text-cc-code-fg/50 hover:text-cc-code-fg/80 hover:bg-white/5 transition-colors cursor-pointer border-l border-cc-border/20","aria-label":`Copy command: ${l}`,children:y?"Copied!":"Copy"})]}),r.jsx("p",{className:"text-[10px] text-cc-muted/70 mt-1.5",children:c})]}),r.jsxs("button",{onClick:g,className:"flex items-center gap-1.5 text-[11px] font-medium text-cc-primary hover:text-cc-primary-hover transition-colors cursor-pointer",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3","aria-hidden":!0,children:r.jsx("path",{d:"M1.705 8.005a.75.75 0 01.834.656 5.5 5.5 0 009.592 2.97l-1.204-1.204a.25.25 0 01.177-.427h3.646a.25.25 0 01.25.25v3.646a.25.25 0 01-.427.177l-1.38-1.38A7.002 7.002 0 011.05 8.84a.75.75 0 01.656-.834zM8 2.5a5.487 5.487 0 00-4.131 1.869l1.204 1.204A.25.25 0 014.896 6H1.25A.25.25 0 011 5.75V2.104a.25.25 0 01.427-.177l1.38 1.38A7.002 7.002 0 0114.95 7.16a.75.75 0 11-1.49.178A5.5 5.5 0 008 2.5z"})}),"I've logged in — check again"]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex-1 h-px bg-cc-border/50"}),r.jsx("button",{onClick:()=>v(k=>!k),className:"text-[10px] text-cc-muted/50 hover:text-cc-muted transition-colors cursor-pointer shrink-0",children:_?"Hide API key":"Or use an API key"}),r.jsx("div",{className:"flex-1 h-px bg-cc-border/50"})]}),_&&r.jsxs("div",{children:[r.jsx("label",{htmlFor:`key-${e}`,className:"text-[11px] font-medium text-cc-muted block mb-1",children:d}),r.jsx("input",{id:`key-${e}`,type:"password",value:h,onChange:k=>m(k.target.value),placeholder:f,className:"w-full h-9 px-3 rounded-lg border border-cc-border bg-cc-input-bg text-[12px] text-cc-fg font-mono-code placeholder:text-cc-muted/30 focus:outline-none focus:ring-2 focus:ring-cc-primary/20 focus:border-cc-primary/40 transition-all"})]})]})]})}function t9({cwd:e,onCwdChange:t,onNext:s,onSkip:n}){return r.jsxs("div",{children:[r.jsx("h2",{className:"text-[18px] font-bold text-cc-fg tracking-tight",children:"Your Workspace"}),r.jsx("p",{className:"text-[13px] text-cc-muted mt-1 mb-5",children:"Set a default working directory for new sessions. You can always change this per session."}),r.jsxs("div",{className:"mb-6",children:[r.jsx("label",{htmlFor:"onboarding-cwd",className:"text-[12px] font-medium text-cc-fg block mb-2",children:"Project directory"}),r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-cc-muted/40","aria-hidden":!0,children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4",children:r.jsx("path",{d:"M1.75 1A1.75 1.75 0 000 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0016 13.25v-8.5A1.75 1.75 0 0014.25 3H7.5a.25.25 0 01-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75z"})})}),r.jsx("input",{id:"onboarding-cwd",value:e,onChange:a=>t(a.target.value),placeholder:"/home/user/my-project",autoFocus:!0,className:"w-full h-11 pl-10 pr-3 rounded-xl border border-cc-border bg-cc-input-bg text-[13px] text-cc-fg font-mono-code placeholder:text-cc-muted/30 focus:outline-none focus:ring-2 focus:ring-cc-primary/20 focus:border-cc-primary/40 transition-all"})]}),r.jsxs("p",{className:"text-[11px] text-cc-muted/60 mt-2",children:["Use the absolute path to your project root, e.g. ",r.jsx("code",{className:"font-mono-code bg-cc-hover px-1 rounded text-[10px]",children:"~/projects/my-app"})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:s,className:"flex-1 h-11 rounded-xl bg-cc-primary text-white text-[14px] font-semibold hover:bg-cc-primary-hover active:scale-[0.98] transition-all cursor-pointer shadow-sm",children:"Continue"}),r.jsx("button",{onClick:n,className:"h-11 px-5 rounded-xl text-[13px] font-medium text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Skip"})]})]})}const s9=[{icon:r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-5 h-5",children:r.jsx("path",{d:"M20 12V8H6a2 2 0 01-2-2c0-1.1.9-2 2-2h12v4M20 12v4H6a2 2 0 00-2 2c0 1.1.9 2 2 2h12v-4M20 12H9",strokeLinecap:"round",strokeLinejoin:"round"})}),title:"Multi-Session",desc:"Run multiple agents in parallel across different projects and backends",color:"text-cc-primary bg-cc-primary/10"},{icon:r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-5 h-5",children:r.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",strokeLinecap:"round",strokeLinejoin:"round"})}),title:"Permission Control",desc:"Approve or deny tool calls before they execute — full visibility and safety",color:"text-cc-success bg-cc-success/10"},{icon:r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-5 h-5",children:r.jsx("path",{d:"M12 8V4H8M2 12h4M20 12h2M12 20v-4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83",strokeLinecap:"round"})}),title:"Agent Profiles",desc:"Create persistent agents with custom prompts, webhooks, and cron schedules",color:"text-amber-500 bg-amber-500/10"},{icon:r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-5 h-5",children:r.jsx("path",{d:"M17 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2M9 11a4 4 0 100-8 4 4 0 000 8zM23 21v-2a4 4 0 00-3-3.87M16 3.13a4 4 0 010 7.75",strokeLinecap:"round",strokeLinejoin:"round"})}),title:"Collaboration",desc:"Share sessions with teammates and vote on permissions together",color:"text-purple-500 bg-purple-500/10"}];function n9({onNext:e}){return r.jsxs("div",{children:[r.jsx("h2",{className:"text-[18px] font-bold text-cc-fg tracking-tight",children:"What you can do"}),r.jsx("p",{className:"text-[13px] text-cc-muted mt-1 mb-5",children:"A quick look at Campfire's key capabilities."}),r.jsx("div",{className:"grid grid-cols-2 gap-3 mb-6",children:s9.map(t=>r.jsxs("div",{className:"rounded-xl border border-cc-border/50 p-4 hover:border-cc-border transition-colors",children:[r.jsx("div",{className:`w-9 h-9 rounded-lg ${t.color} flex items-center justify-center mb-3`,children:t.icon}),r.jsx("h3",{className:"text-[13px] font-semibold text-cc-fg",children:t.title}),r.jsx("p",{className:"text-[11px] text-cc-muted leading-relaxed mt-1",children:t.desc})]},t.title))}),r.jsx("button",{onClick:e,autoFocus:!0,className:"w-full h-11 rounded-xl bg-cc-primary text-white text-[14px] font-semibold hover:bg-cc-primary-hover active:scale-[0.98] transition-all cursor-pointer shadow-sm",children:"Let's Go"})]})}function r9({cwd:e,onComplete:t}){return r.jsxs("div",{className:"text-center py-4",children:[r.jsx("div",{className:"w-16 h-16 mx-auto mb-5 rounded-full bg-cc-success/10 flex items-center justify-center",children:r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-8 h-8 text-cc-success","aria-hidden":!0,children:r.jsx("path",{d:"M20 6L9 17l-5-5",strokeLinecap:"round",strokeLinejoin:"round"})})}),r.jsx("h2",{className:"text-[22px] font-bold text-cc-fg tracking-tight",children:"You're all set!"}),r.jsx("p",{className:"text-[14px] text-cc-muted mt-2 max-w-[360px] mx-auto leading-relaxed",children:e?r.jsxs(r.Fragment,{children:["Your workspace is set to ",r.jsx("code",{className:"font-mono-code text-[12px] bg-cc-hover px-1.5 py-0.5 rounded",children:e})]}):"Start your first session from the home page"}),r.jsx("p",{className:"text-[12px] text-cc-muted/50 mt-2",children:"Providers and settings can be updated anytime."}),r.jsx("button",{onClick:t,autoFocus:!0,className:"w-full h-11 mt-8 rounded-xl bg-cc-primary text-white text-[14px] font-semibold hover:bg-cc-primary-hover active:scale-[0.98] transition-all cursor-pointer shadow-sm",children:"Open Campfire"})]})}const i9={installing:"Installing update...",restarting:"Restarting server...",waiting:"Waiting for server...",ready:"Update complete."};function a9(){const e=Hh();return e?{Authorization:`Bearer ${e}`}:{}}function o9(e){const[t,s]=w.useState("installing"),n=w.useRef(null),a=w.useRef(!0);return w.useEffect(()=>(a.current=!0,()=>{a.current=!1,n.current&&clearTimeout(n.current)}),[]),w.useEffect(()=>{if(!e){s("installing");return}const l=setTimeout(()=>{a.current&&s("restarting")},3e3),c=setTimeout(()=>{a.current&&s("waiting"),d()},5e3);function d(){a.current&&fetch("/api/update-check",{headers:a9(),signal:AbortSignal.timeout(3e3)}).then(f=>{if(!f.ok)throw new Error("Server is not ready");return f.json()}).then(f=>{if(f.updateInProgress)throw new Error("Update is still running");a.current&&(s("ready"),setTimeout(()=>{a.current&&window.location.reload()},800))}).catch(()=>{n.current=setTimeout(d,1500)})}return()=>{clearTimeout(l),clearTimeout(c),n.current&&clearTimeout(n.current)}},[e]),t}function l9({active:e}){const t=o9(e);if(!e)return null;const s=t==="ready";return r.jsxs("div",{className:"fixed inset-0 z-[100] flex flex-col items-center justify-center bg-cc-bg text-cc-fg animate-[fadeSlideIn_0.15s_ease-out]",role:"status","aria-live":"polite","data-testid":"update-overlay",children:[r.jsxs("div",{className:"relative mb-7",children:[!s&&r.jsx("div",{className:"absolute inset-0 -m-4 rounded-full bg-cc-primary/10 animate-pulse"}),r.jsx("img",{src:"/logo.svg",alt:"Campfire",className:`relative z-10 h-20 w-20 transition-transform duration-500 ${s?"":"scale-110"}`}),!s&&r.jsx("div",{className:"absolute -inset-3 z-0",children:r.jsx("svg",{className:"h-full w-full animate-[spin_1.2s_linear_infinite]",viewBox:"0 0 100 100",children:r.jsx("circle",{cx:"50",cy:"50",r:"46",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"60 230",strokeLinecap:"round",className:"text-cc-primary/45"})})}),s&&r.jsx("div",{className:"absolute -inset-3 z-0 rounded-full border-2 border-cc-success/30"})]}),r.jsx("p",{className:`mb-2 text-sm font-medium ${s?"text-cc-success":"text-cc-fg"}`,children:i9[t]}),r.jsx("p",{className:"text-xs text-cc-muted",children:s?"Reloading...":"This page will refresh automatically"}),!s&&r.jsx("div",{className:"mt-6 flex gap-1.5",children:[0,1,2].map(n=>r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-cc-primary/50",style:{animation:"pulse-dot 1.4s ease-in-out infinite",animationDelay:`${n*.2}s`}},n))}),r.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-cc-border/40",children:r.jsx("div",{className:"h-full bg-cc-primary/70 transition-all duration-1000",style:{width:s?"100%":"70%"}})})]})}const c9=[{id:"general",label:"General"},{id:"providers",label:"Providers"},{id:"api-keys",label:"API Keys"},{id:"security",label:"Security"},{id:"notifications",label:"Notifications"},{id:"appearance",label:"Appearance"},{id:"updates",label:"Updates"}];function u9(e,t){return e?`${t} active session${t===1?"":"s"}`:"Anyone with the URL can access this instance"}function d9(e){return e!=null&&e.latestVersion?e.updateAvailable?`v${e.latestVersion} available`:"You're on the latest version":"Check for updates to see the latest version"}function h9(e){return e?"text-cc-success bg-cc-success/10":"text-cc-warning bg-cc-warning/10"}function Ah({enabled:e,onToggle:t,label:s}){return r.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:t,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors duration-200 cursor-pointer shrink-0 ${e?"bg-cc-primary":"bg-cc-border"}`,children:r.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white shadow-sm transition-transform duration-200 ${e?"translate-x-[18px]":"translate-x-[3px]"}`})})}function ni({title:e,description:t,children:s}){return r.jsxs("div",{className:"bg-cc-card border border-cc-border/60 rounded-xl",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-cc-border/40",children:[r.jsx("h3",{className:"text-[13px] font-semibold text-cc-fg",children:e}),t&&r.jsx("p",{className:"mt-0.5 text-[12px] text-cc-fg/60",children:t})]}),r.jsx("div",{className:"px-5 py-4",children:s})]})}function Rh({label:e,description:t,children:s}){return r.jsxs("div",{className:"flex items-center justify-between gap-4 py-3 first:pt-0 last:pb-0 border-b border-cc-border/20 last:border-0",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"text-[13px] font-medium text-cc-fg",children:e}),t&&r.jsx("p",{className:"text-[11px] text-cc-fg/55 mt-0.5",children:t})]}),r.jsx("div",{className:"shrink-0",children:s})]})}function f9({telemetryEnabled:e,setTelemetryEnabled:t}){return r.jsxs(r.Fragment,{children:[r.jsx(ni,{title:"Telemetry",description:"Help improve Campfire with anonymous usage data",children:r.jsx(Rh,{label:"Usage analytics and crash reports",description:"Anonymous product analytics via PostHog. Browser Do Not Track is respected automatically.",children:r.jsx(Ah,{enabled:e,label:"Toggle telemetry",onToggle:()=>{const s=!e;NM(s),t(s)}})})}),r.jsx(ni,{title:"Environments",description:"Manage reusable environment profiles for sessions",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("p",{className:"text-[12px] text-cc-fg/60",children:"Configure named sets of environment variables to use when creating sessions."}),r.jsx("button",{type:"button",onClick:()=>{globalThis.location.hash="#/environments"},className:"px-3.5 py-2 rounded-lg text-[12px] font-medium bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors cursor-pointer shrink-0 ml-4",children:"Manage"})]})})]})}function p9({claudeOAuthToken:e,setClaudeOAuthToken:t,claudeConfigured:s,setClaudeConfigured:n,openaiApiKey:a,setOpenaiApiKey:l,openaiConfigured:c,setOpenaiConfigured:d,anthropicApiKey:f,setAnthropicApiKey:h,anthropicConfigured:m,setAnthropicConfigured:g,providerSaving:_,setProviderSaving:v,providerSaved:y,setProviderSaved:S,error:j,setError:k}){return r.jsxs("div",{className:"space-y-5",children:[r.jsx(ni,{title:"AI Provider Tokens",description:"Tokens are auto-injected into sessions for matching backends. Environment profiles take precedence.",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[r.jsx("label",{htmlFor:"claude-oauth",className:"text-[12px] font-medium text-cc-fg",children:"Claude Code OAuth Token"}),r.jsx("span",{className:`text-[10px] font-medium px-1.5 rounded-full ${s?"text-cc-success bg-cc-success/10":"text-cc-muted bg-cc-hover"}`,children:s?"Configured":"Not set"})]}),r.jsxs("p",{className:"text-[11px] text-cc-muted mb-1.5",children:["Injected as ",r.jsx("code",{className:"font-mono-code text-[10px] bg-cc-hover px-1 rounded",children:"CLAUDE_CODE_OAUTH_TOKEN"})," for Claude sessions"]}),r.jsx("input",{id:"claude-oauth",type:"password",value:e,onChange:N=>t(N.target.value),placeholder:s?"•••••••••••• (configured)":"Paste token from claude setup-token",className:"w-full h-9 px-3 rounded-lg border border-cc-border bg-cc-input-bg text-[12px] text-cc-fg font-mono-code"})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[r.jsx("label",{htmlFor:"openai-key",className:"text-[12px] font-medium text-cc-fg",children:"OpenAI API Key"}),r.jsx("span",{className:`text-[10px] font-medium px-1.5 rounded-full ${c?"text-cc-success bg-cc-success/10":"text-cc-muted bg-cc-hover"}`,children:c?"Configured":"Not set"})]}),r.jsxs("p",{className:"text-[11px] text-cc-muted mb-1.5",children:["Injected as ",r.jsx("code",{className:"font-mono-code text-[10px] bg-cc-hover px-1 rounded",children:"OPENAI_API_KEY"})," for Codex sessions"]}),r.jsx("input",{id:"openai-key",type:"password",value:a,onChange:N=>l(N.target.value),placeholder:c?"•••••••••••• (configured)":"sk-...",className:"w-full h-9 px-3 rounded-lg border border-cc-border bg-cc-input-bg text-[12px] text-cc-fg font-mono-code"})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[r.jsx("label",{htmlFor:"anthropic-key",className:"text-[12px] font-medium text-cc-fg",children:"Anthropic API Key"}),r.jsx("span",{className:`text-[10px] font-medium px-1.5 rounded-full ${m?"text-cc-success bg-cc-success/10":"text-cc-muted bg-cc-hover"}`,children:m?"Configured":"Not set"})]}),r.jsxs("p",{className:"text-[11px] text-cc-muted mb-1.5",children:["Injected as ",r.jsx("code",{className:"font-mono-code text-[10px] bg-cc-hover px-1 rounded",children:"ANTHROPIC_API_KEY"})," for all sessions (Goose, Aider, etc.)"]}),r.jsx("input",{id:"anthropic-key",type:"password",value:f,onChange:N=>h(N.target.value),placeholder:m?"•••••••••••• (configured)":"sk-ant-api03-...",className:"w-full h-9 px-3 rounded-lg border border-cc-border bg-cc-input-bg text-[12px] text-cc-fg font-mono-code"})]})]})}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{type:"button",onClick:async()=>{v(!0),k("");try{const N={};if(e.trim()&&(N.claudeOAuthToken=e.trim()),a.trim()&&(N.openaiApiKey=a.trim()),f.trim()&&(N.anthropicApiKey=f.trim()),Object.keys(N).length===0)return;const E=await ne.updateSettings(N);n(E.claudeOAuthTokenConfigured??!1),d(E.openaiApiKeyConfigured??!1),g(E.anthropicApiKeyConfigured??!1),t(""),l(""),h(""),S(!0),setTimeout(()=>S(!1),1800)}catch(N){k(N instanceof Error?N.message:"Save failed")}finally{v(!1)}},disabled:_,className:"px-4 py-1.5 rounded-lg bg-cc-primary text-white text-[12px] font-medium hover:bg-cc-primary-hover transition-colors cursor-pointer disabled:opacity-40",children:_?"Saving...":"Save Providers"}),y&&r.jsx("span",{className:"text-[11px] text-cc-success",children:"Saved"}),j&&r.jsx("span",{className:"text-[11px] text-cc-error",children:j})]}),r.jsx("div",{className:"rounded-lg border border-cc-border/40 bg-cc-hover/30 px-4 py-3",children:r.jsxs("p",{className:"text-[11px] text-cc-muted leading-relaxed",children:["Provider tokens are automatically injected into new sessions for the matching backend. If an environment profile already sets the same variable, the profile value takes precedence. Tokens are stored in ",r.jsx("code",{className:"font-mono-code text-[10px] bg-cc-hover px-1 rounded",children:"~/.campfire/settings.json"}),"."]})})]})}function m9({openrouterApiKey:e,setOpenrouterApiKey:t,openrouterModel:s,setOpenrouterModel:n,configured:a,moltbookApiKey:l,setMoltbookApiKey:c,moltbookConfigured:d,loading:f,saving:h,error:m,saved:g,onSave:_}){return r.jsxs("form",{onSubmit:_,className:"space-y-5",children:[r.jsx(ni,{title:"OpenRouter",description:"Used for auto-naming sessions after the first turn",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-[12px] font-medium text-cc-fg mb-1.5",htmlFor:"openrouter-key",children:"API Key"}),r.jsx("input",{id:"openrouter-key",type:"password",value:e,onChange:v=>t(v.target.value),placeholder:a?"Configured — enter a new key to replace":"sk-or-v1-...",className:"w-full px-3.5 py-2.5 text-[13px] bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg placeholder:text-cc-fg/40 focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 transition-all"}),r.jsx("div",{className:"flex items-center gap-2 mt-2",children:a?r.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-cc-success font-medium",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("path",{d:"M8 0a8 8 0 110 16A8 8 0 018 0zm3.78 4.97a.75.75 0 00-1.06 0L7 8.69 5.28 6.97a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.06 0l4.25-4.25a.75.75 0 000-1.06z"})}),"Configured"]}):r.jsx("span",{className:"text-[11px] text-cc-fg/50",children:"Not configured — auto-naming is disabled"})})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[12px] font-medium text-cc-fg mb-1.5",htmlFor:"openrouter-model",children:"Model"}),r.jsx("input",{id:"openrouter-model",type:"text",value:s,onChange:v=>n(v.target.value),placeholder:"openrouter/free",className:"w-full px-3.5 py-2.5 text-[13px] bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg placeholder:text-cc-fg/40 focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 transition-all"})]})]})}),r.jsx(ni,{title:"Moltbook",description:"Required to post gallery sessions to Moltbook",children:r.jsxs("div",{children:[r.jsx("label",{className:"block text-[12px] font-medium text-cc-fg mb-1.5",htmlFor:"moltbook-key",children:"API Key"}),r.jsx("input",{id:"moltbook-key",type:"password",value:l,onChange:v=>c(v.target.value),placeholder:d?"Configured — enter a new key to replace":"Paste your Moltbook API key",className:"w-full px-3.5 py-2.5 text-[13px] bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg placeholder:text-cc-fg/40 focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 transition-all"}),r.jsx("div",{className:"flex items-center gap-2 mt-2",children:d?r.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-cc-success font-medium",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("path",{d:"M8 0a8 8 0 110 16A8 8 0 018 0zm3.78 4.97a.75.75 0 00-1.06 0L7 8.69 5.28 6.97a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.06 0l4.25-4.25a.75.75 0 000-1.06z"})}),"Configured"]}):r.jsx("span",{className:"text-[11px] text-cc-fg/50",children:"Get a key at moltbook.com by registering an agent"})})]})}),r.jsxs("div",{className:"flex items-center justify-between bg-cc-card border border-cc-border/60 rounded-xl px-5 py-3.5",children:[r.jsxs("div",{className:"text-[12px]",children:[m&&r.jsx("span",{className:"text-cc-error",children:m}),g&&r.jsx("span",{className:"text-cc-success font-medium",children:"Settings saved successfully"}),!m&&!g&&r.jsx("span",{className:"text-cc-fg/50",children:f?"Loading...":"Changes are saved immediately"})]}),r.jsx("button",{type:"submit",disabled:h||f,className:`px-4 py-2 rounded-lg text-[13px] font-medium transition-all ${h||f?"bg-cc-hover text-cc-fg/40 cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white shadow-sm cursor-pointer"}`,children:h?"Saving...":"Save API Keys"})]})]})}function g9({authEnabled:e,setAuthEnabled:t,authPassword:s,setAuthPassword:n,authSaving:a,setAuthSaving:l,authSaved:c,setAuthSaved:d,authError:f,setAuthError:h,authSessions:m}){return r.jsx("div",{className:"space-y-5",children:r.jsxs(ni,{title:"Authentication",description:"Protect your Campfire instance with a password. When enabled, all API and WebSocket connections require a valid session token.",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-4 border-b border-cc-border/30",children:[r.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center ${e?"bg-cc-success/10":"bg-cc-hover"}`,children:r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:`w-5 h-5 ${e?"text-cc-success":"text-cc-muted"}`,"aria-hidden":!0,children:r.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",strokeLinecap:"round",strokeLinejoin:"round"})})}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("p",{className:"text-[13px] font-medium text-cc-fg",children:["Authentication is ",e?"enabled":"disabled"]}),r.jsx("p",{className:"text-[11px] text-cc-muted",children:u9(e,m)})]}),r.jsx("span",{className:`text-[10px] font-semibold px-2.5 py-1 rounded-full ${h9(e)}`,children:e?"Protected":"Open"})]}),f&&r.jsx("div",{className:"mb-3 px-3 py-2 rounded-lg bg-cc-error/8 border border-cc-error/15",role:"alert",children:r.jsx("p",{className:"text-[11px] text-cc-error",children:f})}),e?r.jsx(w9,{saving:a,onDisable:async()=>{l(!0),h("");try{await ne.disableAuth(),t(!1),d(!0),setTimeout(()=>d(!1),2e3)}catch(g){h(g instanceof Error?g.message:"Failed to disable auth")}finally{l(!1)}}}):r.jsx(y9,{password:s,saving:a,onPasswordChange:n,onEnable:async()=>{l(!0),h("");try{await ne.setupAuth(s);const{token:g}=await ne.login(s);Aj(g),t(!0),n(""),d(!0),setTimeout(()=>d(!1),2e3)}catch(g){h(g instanceof Error?g.message:"Failed to enable auth")}finally{l(!1)}}}),c&&r.jsx("p",{className:"text-[11px] text-cc-success mt-2",children:"Saved"})]})})}function x9({notificationSound:e,toggleNotificationSound:t,notificationDesktop:s,setNotificationDesktop:n,notificationApiAvailable:a}){return r.jsxs(ni,{title:"Notification Preferences",description:"Control how Campfire alerts you",children:[r.jsx(Rh,{label:"Sound",description:"Play a notification sound when a permission request arrives",children:r.jsx(Ah,{enabled:e,label:"Toggle notification sound",onToggle:t})}),a&&r.jsx(Rh,{label:"Desktop Alerts",description:"Show native browser notifications for permission requests",children:r.jsx(Ah,{enabled:s,label:"Toggle desktop notifications",onToggle:async()=>{if(s)n(!1);else{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted")return;n(!0)}}})})]})}function v9({darkMode:e,toggleDarkMode:t}){return r.jsx(ni,{title:"Theme",description:"Choose your preferred color scheme",children:r.jsx(Rh,{label:"Dark Mode",description:"Switch between light and dark themes",children:r.jsx(Ah,{enabled:e,label:"Toggle dark mode",onToggle:t})})})}function b9({updateInfo:e,updateError:t,updateStatus:s,checkingUpdates:n,updatingApp:a,onCheckUpdates:l,onTriggerUpdate:c}){return r.jsx(ni,{title:"Software Updates",description:"Keep Campfire up to date",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-3 py-2",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl bg-cc-primary/10 flex items-center justify-center shrink-0",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-5 h-5 text-cc-primary",children:r.jsx("path",{d:"M8 0a8 8 0 110 16A8 8 0 018 0zm0 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM8 4a.75.75 0 01.75.75v3.5h2.5a.75.75 0 010 1.5h-3.25a.75.75 0 01-.75-.75v-4.25A.75.75 0 018 4z"})})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[13px] font-medium text-cc-fg",children:e?`v${e.currentVersion}`:"Loading..."}),r.jsx("p",{className:"text-[11px] text-cc-fg/55",children:d9(e)})]})]}),t&&r.jsx("div",{className:"px-3.5 py-2.5 rounded-lg bg-cc-error/8 border border-cc-error/15 text-[12px] text-cc-error",children:t}),s&&r.jsx("div",{className:"px-3.5 py-2.5 rounded-lg bg-cc-success/8 border border-cc-success/15 text-[12px] text-cc-success",children:s}),r.jsxs("div",{className:"flex items-center gap-2.5 pt-1",children:[r.jsx("button",{type:"button",onClick:l,disabled:n,className:`px-4 py-2 rounded-lg text-[13px] font-medium transition-all ${n?"bg-cc-hover text-cc-fg/40 cursor-not-allowed":"bg-cc-hover hover:bg-cc-active text-cc-fg cursor-pointer"}`,children:n?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-3.5 h-3.5 border-2 border-cc-fg/20 border-t-cc-fg/60 rounded-full animate-spin"})," ","Checking..."]}):"Check for Updates"}),e!=null&&e.isServiceMode?r.jsx("button",{type:"button",onClick:c,disabled:a||e.updateInProgress||!e.updateAvailable,className:`px-4 py-2 rounded-lg text-[13px] font-medium transition-all ${a||e.updateInProgress||!e.updateAvailable?"bg-cc-hover text-cc-fg/40 cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white shadow-sm cursor-pointer"}`,children:a||e.updateInProgress?"Updating...":"Update & Restart"}):r.jsxs("p",{className:"text-[11px] text-cc-fg/55 self-center",children:["Run ",r.jsx("code",{className:"font-mono-code bg-cc-code-bg px-1.5 py-0.5 rounded text-cc-code-fg text-[10px]",children:"the-campfire install"})," to enable one-click updates"]})]})]})})}function _9({embedded:e=!1}){const[t,s]=w.useState("general"),[n,a]=w.useState(""),[l,c]=w.useState("openrouter/free"),[d,f]=w.useState(!1),[h,m]=w.useState(""),[g,_]=w.useState(!1),[v,y]=w.useState(""),[S,j]=w.useState(!1),[k,N]=w.useState(""),[E,B]=w.useState(!1),[F,$]=w.useState(""),[K,Y]=w.useState(!1),[W,L]=w.useState(!1),[Q,V]=w.useState(!1),[X,q]=w.useState(!0),[A,M]=w.useState(!1),[O,U]=w.useState(""),[I,R]=w.useState(!1),[P,z]=w.useState(!1),[T,oe]=w.useState(""),[be,re]=w.useState(!1),[ve,Te]=w.useState(!1),[Re,je]=w.useState(""),[Ye,Xe]=w.useState(0),Pe=G(ee=>ee.darkMode),ye=G(ee=>ee.toggleDarkMode),Ze=G(ee=>ee.notificationSound),ft=G(ee=>ee.toggleNotificationSound),mt=G(ee=>ee.notificationDesktop),ts=G(ee=>ee.setNotificationDesktop),Kt=G(ee=>ee.updateInfo),Ft=G(ee=>ee.setUpdateInfo),Rt=G(ee=>ee.setUpdateOverlayActive),Hs=typeof Notification<"u",[gs,vt]=w.useState(!1),[rr,de]=w.useState(!1),[_e,Be]=w.useState(""),[qe,Je]=w.useState(""),[Yt,xs]=w.useState(Ej());w.useEffect(()=>{ne.getSettings().then(ee=>{f(ee.openrouterApiKeyConfigured),c(ee.openrouterModel||"openrouter/free"),_(ee.moltbookApiKeyConfigured),j(ee.claudeOAuthTokenConfigured??!1),B(ee.openaiApiKeyConfigured??!1),Y(ee.anthropicApiKeyConfigured??!1)}).catch(ee=>U(ee instanceof Error?ee.message:"Unknown error")).finally(()=>q(!1)),ne.getAuthStatus().then(ee=>{z(ee.enabled),Xe(ee.activeSessions)}).catch(()=>{})},[]);async function se(ee){ee.preventDefault(),M(!0),U(""),R(!1);try{const Ie=n.trim(),We=h.trim(),Bt={openrouterModel:l.trim()||"openrouter/free"};Ie&&(Bt.openrouterApiKey=Ie),We&&(Bt.moltbookApiKey=We);const ss=await ne.updateSettings(Bt);f(ss.openrouterApiKeyConfigured),_(ss.moltbookApiKeyConfigured),a(""),m(""),R(!0),setTimeout(()=>R(!1),1800)}catch(Ie){U(Ie instanceof Error?Ie.message:"Unknown error")}finally{M(!1)}}async function fe(){vt(!0),Be(""),Je("");try{const ee=await ne.forceCheckForUpdate();Ft(ee),ee.updateAvailable&&ee.latestVersion?Be(`Update v${ee.latestVersion} is available.`):Be("You are up to date.")}catch(ee){Je(ee instanceof Error?ee.message:"Unknown error")}finally{vt(!1)}}async function H(){de(!0),Be(""),Je("");try{const ee=await ne.triggerUpdate();Be(ee.message),Rt(!0)}catch(ee){Je(ee instanceof Error?ee.message:"Unknown error"),de(!1)}}return r.jsx("div",{className:`${e?"h-full":"h-[100dvh]"} bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto`,children:r.jsxs("div",{className:"max-w-3xl mx-auto px-4 sm:px-8 py-6 sm:py-10",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[!e&&r.jsx("button",{onClick:()=>{globalThis.location.hash=""},className:"flex items-center justify-center w-8 h-8 rounded-lg text-cc-fg/60 hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer","aria-label":"Go back",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",className:"w-4 h-4",children:r.jsx("path",{d:"M10 3L5 8l5 5",strokeLinecap:"round",strokeLinejoin:"round"})})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] text-cc-fg/50 font-medium",children:"Settings"}),r.jsx("h1",{className:"text-xl font-semibold text-cc-fg -mt-0.5",children:"Settings"})]})]}),r.jsx("div",{className:"mt-5 mb-6 border-b border-cc-border/40",children:r.jsx("nav",{className:"flex gap-0 -mb-px overflow-x-auto","aria-label":"Settings tabs",children:c9.map(ee=>r.jsx("button",{onClick:()=>s(ee.id),className:`px-4 py-2.5 text-[13px] font-medium whitespace-nowrap border-b-2 transition-colors cursor-pointer ${t===ee.id?"border-cc-primary text-cc-fg":"border-transparent text-cc-fg/55 hover:text-cc-fg hover:border-cc-border/60"}`,"aria-selected":t===ee.id,role:"tab",children:ee.label},ee.id))})}),r.jsxs("div",{className:"space-y-5",children:[t==="general"&&r.jsx(f9,{telemetryEnabled:Yt,setTelemetryEnabled:xs}),t==="providers"&&r.jsx(p9,{claudeOAuthToken:v,setClaudeOAuthToken:y,claudeConfigured:S,setClaudeConfigured:j,openaiApiKey:k,setOpenaiApiKey:N,openaiConfigured:E,setOpenaiConfigured:B,anthropicApiKey:F,setAnthropicApiKey:$,anthropicConfigured:K,setAnthropicConfigured:Y,providerSaving:W,setProviderSaving:L,providerSaved:Q,setProviderSaved:V,error:O,setError:U}),t==="api-keys"&&r.jsx(m9,{openrouterApiKey:n,setOpenrouterApiKey:a,openrouterModel:l,setOpenrouterModel:c,configured:d,moltbookApiKey:h,setMoltbookApiKey:m,moltbookConfigured:g,loading:X,saving:A,error:O,saved:I,onSave:se}),t==="security"&&r.jsx(g9,{authEnabled:P,setAuthEnabled:z,authPassword:T,setAuthPassword:oe,authSaving:be,setAuthSaving:re,authSaved:ve,setAuthSaved:Te,authError:Re,setAuthError:je,authSessions:Ye}),t==="notifications"&&r.jsx(x9,{notificationSound:Ze,toggleNotificationSound:ft,notificationDesktop:mt,setNotificationDesktop:ts,notificationApiAvailable:Hs}),t==="appearance"&&r.jsx(v9,{darkMode:Pe,toggleDarkMode:ye}),t==="updates"&&r.jsx(b9,{updateInfo:Kt,updateError:qe,updateStatus:_e,checkingUpdates:gs,updatingApp:rr,onCheckUpdates:fe,onTriggerUpdate:H})]})]})})}function y9({password:e,saving:t,onPasswordChange:s,onEnable:n}){return r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"auth-password",className:"text-[12px] font-medium text-cc-fg block mb-1.5",children:"Set a password"}),r.jsx("input",{id:"auth-password",type:"password",value:e,onChange:a=>s(a.target.value),placeholder:"Minimum 4 characters",className:"w-full h-10 px-3 rounded-lg border border-cc-border bg-cc-input-bg text-[13px] text-cc-fg focus:outline-none focus:ring-2 focus:ring-cc-primary/20 focus:border-cc-primary/40"})]}),r.jsx("button",{type:"button",disabled:e.length<4||t,onClick:n,className:"w-full h-10 rounded-lg bg-cc-primary text-white text-[13px] font-medium hover:bg-cc-primary-hover transition-colors cursor-pointer disabled:opacity-40",children:t?"Enabling...":"Enable Authentication"})]})}function w9({saving:e,onDisable:t}){return r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"rounded-lg border border-cc-border/40 bg-cc-hover/30 px-4 py-3",children:r.jsxs("p",{className:"text-[11px] text-cc-muted leading-relaxed",children:["All REST API requests require a ",r.jsx("code",{className:"font-mono-code text-[10px] bg-cc-hover px-1 rounded",children:"Bearer"})," token. All WebSocket connections require an ",r.jsx("code",{className:"font-mono-code text-[10px] bg-cc-hover px-1 rounded",children:"auth_token"})," parameter. CLI connections from localhost are allowed without a token."]})}),r.jsx("button",{type:"button",disabled:e,onClick:t,className:"w-full h-10 rounded-lg border border-cc-error/30 text-cc-error text-[13px] font-medium hover:bg-cc-error/5 transition-colors cursor-pointer disabled:opacity-40",children:e?"Disabling...":"Disable Authentication"})]})}const S9=w.lazy(()=>Xi(()=>Promise.resolve().then(()=>hu),void 0).then(e=>({default:e.CodeEditor})));function j9(e){const t=Date.now()-e,s=Math.floor(t/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const n=Math.floor(s/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function k9(e){const t=e-Date.now();if(t<=0)return"now";const s=Math.floor(t/6e4);if(s<60)return`in ${s}m`;const n=Math.floor(s/60);return n<24?`in ${n}h`:`in ${Math.floor(n/24)}d`}function TC(e,t){if(!t)return"One-time";const s=e.trim().split(/\s+/);if(s.length!==5)return e;const[n,a,l,c,d]=s;if(e==="* * * * *")return"Every minute";if(a==="*"&&l==="*"&&c==="*"&&d==="*"&&n.startsWith("*/")){const f=parseInt(n.slice(2),10);return f===1?"Every minute":`Every ${f} minutes`}if(n==="0"&&l==="*"&&c==="*"&&d==="*"){if(a==="*")return"Every hour";if(a.startsWith("*/")){const f=parseInt(a.slice(2),10);return f===1?"Every hour":`Every ${f} hours`}}if(l==="*"&&c==="*"&&n!=="*"&&a!=="*"&&!a.includes("/")&&!a.includes(",")){const f=parseInt(a,10),h=parseInt(n,10);if(!isNaN(f)&&!isNaN(h)){const m=f>=12?"PM":"AM",g=f===0?12:f>12?f-12:f,_=h.toString().padStart(2,"0"),v=`${g}:${_} ${m}`;if(d==="*")return`Every day at ${v}`;if(d==="1-5")return`Weekdays at ${v}`;if(d==="0,6")return`Weekends at ${v}`}}return e}const pg={name:"",prompt:"",recurring:!0,schedule:"0 8 * * *",oneTimeDate:"",backendType:"claude",model:si("claude"),cwd:""},C9=[{label:"Every hour",value:"0 * * * *"},{label:"Every day at 8am",value:"0 8 * * *"},{label:"Every 2 hours",value:"0 */2 * * *"},{label:"Weekdays at 9am",value:"0 9 * * 1-5"}];function N9({onClose:e,embedded:t=!1}){const[s,n]=w.useState([]),[a,l]=w.useState(!0),[c,d]=w.useState(""),[f,h]=w.useState(null),[m,g]=w.useState(pg),[_,v]=w.useState(pg),[y,S]=w.useState(!1),[j,k]=w.useState(!0),[N,E]=w.useState(new Set),B=w.useCallback(()=>{ne.listCronJobs().then(n).catch(()=>{}).finally(()=>l(!1))},[]);w.useEffect(()=>{B();const M=setInterval(B,1e4);return()=>clearInterval(M)},[B]);async function F(){const M=_.name.trim(),O=_.prompt.trim();if(!M||!O)return;S(!0),d("");let U=_.schedule;!_.recurring&&_.oneTimeDate&&(U=new Date(_.oneTimeDate).toISOString());try{await ne.createCronJob({name:M,prompt:O,schedule:U,recurring:_.recurring,backendType:_.backendType,model:_.backendType==="codex"?"":_.model.trim()||void 0,cwd:_.cwd.trim()||void 0}),v(pg),k(!0),B()}catch(I){d(I instanceof Error?I.message:String(I))}finally{S(!1)}}function $(M){h(M.id),g({name:M.name,prompt:M.prompt,recurring:M.recurring,schedule:M.schedule,oneTimeDate:"",backendType:M.backendType,model:M.model,cwd:M.cwd}),d("")}function K(){h(null),d("")}async function Y(){if(!f)return;const M=m.name.trim(),O=m.prompt.trim();if(!M||!O)return;let U=m.schedule;!m.recurring&&m.oneTimeDate&&(U=new Date(m.oneTimeDate).toISOString());try{await ne.updateCronJob(f,{name:M,prompt:O,schedule:U,recurring:m.recurring,backendType:m.backendType,model:m.backendType==="codex"?"":m.model.trim()||void 0,cwd:m.cwd.trim()||void 0}),h(null),d(""),B()}catch(I){d(I instanceof Error?I.message:String(I))}}async function W(M){try{await ne.deleteCronJob(M),f===M&&h(null),B()}catch(O){d(O instanceof Error?O.message:String(O))}}async function L(M){try{await ne.toggleCronJob(M),B()}catch(O){d(O instanceof Error?O.message:String(O))}}async function Q(M){E(O=>new Set(O).add(M));try{await ne.runCronJob(M),B()}catch(O){d(O instanceof Error?O.message:String(O))}finally{E(O=>{const U=new Set(O);return U.delete(M),U})}}const V=c&&r.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:c}),X=a?r.jsx("div",{className:"text-sm text-cc-muted text-center py-6",children:"Loading scheduled tasks..."}):s.length===0?r.jsx("div",{className:"text-sm text-cc-muted text-center py-6",children:"No scheduled tasks yet. Create one below."}):r.jsx("div",{className:"space-y-3",children:s.map(M=>r.jsxs("div",{className:"border border-cc-border rounded-lg overflow-hidden bg-cc-card",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 bg-cc-card border-b border-cc-border",children:[r.jsx("span",{className:"text-sm font-medium text-cc-fg flex-1 truncate",children:M.name}),r.jsx("span",{className:`text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 ${M.backendType==="codex"?"text-blue-500 bg-blue-500/10":"text-[#5BA8A0] bg-[#5BA8A0]/10"}`,children:M.backendType==="codex"?"Codex":"Claude"}),M.consecutiveFailures>0&&r.jsxs("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-cc-error bg-cc-error/10",children:[M.consecutiveFailures," fail",M.consecutiveFailures!==1?"s":""]}),r.jsx("button",{onClick:()=>L(M.id),className:`relative w-8 h-[18px] rounded-full transition-colors cursor-pointer shrink-0 ${M.enabled?"bg-cc-primary":"bg-cc-border"}`,title:M.enabled?"Disable":"Enable",children:r.jsx("span",{className:`absolute top-[2px] w-[14px] h-[14px] rounded-full bg-white transition-transform ${M.enabled?"left-[16px]":"left-[2px]"}`})}),f===M.id?r.jsx("button",{onClick:K,className:"text-xs text-cc-muted hover:text-cc-fg cursor-pointer",children:"Cancel"}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>Q(M.id),disabled:N.has(M.id),className:`text-xs cursor-pointer ${N.has(M.id)?"text-cc-muted cursor-not-allowed":"text-cc-primary hover:text-cc-primary-hover"}`,children:N.has(M.id)?"Running...":"Run Now"}),r.jsx("button",{onClick:()=>$(M),className:"text-xs text-cc-muted hover:text-cc-fg cursor-pointer",children:"Edit"}),r.jsx("button",{onClick:()=>W(M.id),className:"text-xs text-cc-muted hover:text-cc-error cursor-pointer",children:"Delete"})]})]}),f===M.id&&r.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[r.jsx(a2,{form:m,onChange:g}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:Y,className:"px-3 py-2 text-xs font-medium bg-cc-primary hover:bg-cc-primary-hover text-white rounded-lg transition-colors cursor-pointer",children:"Save"}),r.jsx("button",{onClick:K,className:"px-3 py-2 text-xs font-medium text-cc-muted hover:text-cc-fg rounded-lg transition-colors cursor-pointer",children:"Cancel"})]})]}),f!==M.id&&r.jsxs("div",{className:"px-3 py-2.5 space-y-1.5",children:[r.jsx("div",{className:"text-xs text-cc-muted truncate",title:M.prompt,children:M.prompt}),r.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-cc-muted",children:[r.jsx("span",{children:TC(M.schedule,M.recurring)}),M.nextRunAt!=null&&M.enabled&&r.jsxs("span",{children:["Next: ",k9(M.nextRunAt)]}),M.lastRunAt!=null&&r.jsxs("span",{className:"flex items-center gap-1",children:["Last: ",j9(M.lastRunAt),M.consecutiveFailures===0?r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-success",children:r.jsx("path",{d:"M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2.5-2.5a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z"})}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-error",children:r.jsx("path",{d:"M4.646 4.646a.5.5 0 01.708 0L8 7.293l2.646-2.647a.5.5 0 01.708.708L8.707 8l2.647 2.646a.5.5 0 01-.708.708L8 8.707l-2.646 2.647a.5.5 0 01-.708-.708L7.293 8 4.646 5.354a.5.5 0 010-.708z"})})]}),M.totalRuns>0&&r.jsxs("span",{children:[M.totalRuns," run",M.totalRuns!==1?"s":""]}),M.cwd&&r.jsx("span",{className:"font-mono-code truncate max-w-[200px]",title:M.cwd,children:M.cwd})]})]})]},M.id))}),q=r.jsxs("div",{className:"border border-cc-border rounded-lg overflow-hidden bg-cc-card",children:[r.jsxs("button",{onClick:()=>k(!j),className:"w-full flex items-center gap-2 px-3 py-2.5 bg-cc-card border-b border-cc-border cursor-pointer hover:bg-cc-hover transition-colors",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`w-3 h-3 text-cc-muted transition-transform ${j?"":"rotate-90"}`,children:r.jsx("path",{d:"M6 4l4 4-4 4",strokeLinecap:"round",strokeLinejoin:"round"})}),r.jsx("span",{className:"text-sm font-medium text-cc-fg",children:"New Scheduled Task"})]}),!j&&r.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[r.jsx(a2,{form:_,onChange:v}),r.jsx("div",{className:"text-[10px] text-cc-muted",children:"Scheduled tasks run with full autonomy (bypassPermissions)"}),r.jsx("button",{onClick:F,disabled:!_.name.trim()||!_.prompt.trim()||y,className:`px-3 py-2 text-xs font-medium rounded-lg transition-colors ${_.name.trim()&&_.prompt.trim()&&!y?"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:y?"Creating...":"Create"})]})]});if(t)return r.jsx("div",{className:"h-full bg-cc-bg overflow-y-auto",children:r.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-8 py-6 sm:py-10",children:[r.jsxs("div",{className:"mb-6",children:[r.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"Scheduled Tasks"}),r.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Run autonomous Claude Code or Codex sessions on a schedule."})]}),V,r.jsxs("div",{className:"mt-4 space-y-4",children:[r.jsxs("section",{className:"bg-cc-card border border-cc-border rounded-xl p-4 sm:p-5 space-y-3",children:[r.jsx("h2",{className:"text-sm font-semibold text-cc-fg",children:"Tasks"}),X]}),r.jsx("section",{className:"bg-cc-card border border-cc-border rounded-xl p-4 sm:p-5 space-y-3",children:q})]})]})});const A=r.jsxs("div",{className:"w-full max-w-2xl max-h-[90dvh] sm:max-h-[80dvh] mx-0 sm:mx-4 flex flex-col bg-cc-bg border border-cc-border rounded-t-xl sm:rounded-xl shadow-2xl overflow-hidden",onClick:M=>M.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-5 py-3 sm:py-4 border-b border-cc-border",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-sm font-semibold text-cc-fg",children:"Scheduled Tasks"}),r.jsx("p",{className:"text-xs text-cc-muted mt-0.5",children:"Run autonomous Claude Code or Codex sessions on a schedule"})]}),e&&r.jsx("button",{onClick:e,className:"w-6 h-6 flex items-center justify-center rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})})})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto px-3 sm:px-5 py-3 sm:py-4 space-y-4",children:[V,X,q]})]});return Z0.createPortal(r.jsx("div",{className:"fixed inset-0 z-50 flex items-end sm:items-center justify-center bg-black/50",onClick:e,children:A}),document.body)}function a2({form:e,onChange:t}){const s=g=>t({...e,...g}),[n,a]=w.useState(!1),l=w.useRef(null),[c,d]=w.useState(!1),f=Yh(e.backendType),h=f.find(g=>g.value===e.model)||f[0];w.useEffect(()=>{e.model||s({model:si(e.backendType)})},[]),w.useEffect(()=>{if(!n)return;function g(_){l.current&&!l.current.contains(_.target)&&a(!1)}return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[n]);const m=e.cwd?e.cwd.split("/").pop()||e.cwd:"Select folder";return r.jsxs("div",{className:"space-y-2.5",children:[r.jsx("input",{type:"text",value:e.name,onChange:g=>s({name:g.target.value}),placeholder:"Task name (e.g. Daily test suite)",className:"w-full px-3 py-2 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/50"}),r.jsx("div",{children:r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"h-[150px] rounded-xl border border-cc-border flex items-center justify-center text-cc-muted text-[12px]",children:"Loading editor..."}),children:r.jsx(S9,{value:e.prompt,onChange:g=>s({prompt:g}),language:"markdown",height:"150px",minimap:!1,wordWrap:!0,ariaLabel:"Cron job prompt editor"})})}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("button",{onClick:()=>s({recurring:!0}),className:`px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors cursor-pointer ${e.recurring?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:"Recurring"}),r.jsx("button",{onClick:()=>s({recurring:!1}),className:`px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors cursor-pointer ${e.recurring?"bg-cc-hover text-cc-muted hover:text-cc-fg":"bg-cc-primary text-white"}`,children:"One-time"})]}),e.recurring?r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"flex flex-wrap gap-1.5",children:C9.map(g=>r.jsx("button",{onClick:()=>s({schedule:g.value}),className:`px-2 py-1 text-[10px] font-medium rounded-md transition-colors cursor-pointer ${e.schedule===g.value?"bg-cc-primary/20 text-cc-primary border border-cc-primary/30":"bg-cc-hover text-cc-muted hover:text-cc-fg border border-transparent"}`,children:g.label},g.value))}),r.jsx("input",{type:"text",value:e.schedule,onChange:g=>s({schedule:g.target.value}),placeholder:"Cron expression (e.g. 0 8 * * *)",className:"w-full px-3 py-2 text-sm font-mono-code bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/50"}),r.jsx("div",{className:"text-[10px] text-cc-muted",children:TC(e.schedule,!0)})]}):r.jsx("input",{type:"datetime-local",value:e.oneTimeDate,onChange:g=>s({oneTimeDate:g.target.value}),className:"w-full px-3 py-2 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/50"})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[r.jsx("button",{onClick:()=>{const g=["claude","codex","goose","aider","openhands","openclaw","opencode"],_=g.indexOf(e.backendType),v=g[(_+1)%g.length];s({backendType:v,model:si(v)})},className:`px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors cursor-pointer ${e.backendType==="codex"?"bg-blue-500/15 text-blue-500 border border-blue-500/30":"bg-[#5BA8A0]/15 text-[#5BA8A0] border border-[#5BA8A0]/30"}`,children:e.backendType==="codex"?"Codex":"Claude Code"}),e.backendType==="codex"?r.jsx("div",{className:"flex items-center gap-1.5 px-2 py-1.5 text-xs text-cc-muted rounded-lg border border-cc-border",children:"Codex default"}):r.jsxs("div",{className:"relative",ref:l,children:[r.jsxs("button",{onClick:()=>a(!n),className:"flex items-center gap-1.5 px-2 py-1.5 text-xs text-cc-muted hover:text-cc-fg rounded-lg hover:bg-cc-hover transition-colors cursor-pointer border border-cc-border",children:[r.jsx("span",{children:h==null?void 0:h.icon}),r.jsx("span",{children:h==null?void 0:h.label}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 opacity-50",children:r.jsx("path",{d:"M4 6l4 4 4-4"})})]}),n&&r.jsx("div",{className:"absolute left-0 bottom-full mb-1 w-52 bg-cc-card border border-cc-border rounded-lg shadow-lg z-10 py-1",children:f.map(g=>r.jsxs("button",{onClick:()=>{s({model:g.value}),a(!1)},className:`w-full px-3 py-2 text-xs text-left hover:bg-cc-hover transition-colors cursor-pointer flex items-center gap-2 ${g.value===e.model?"text-cc-primary font-medium":"text-cc-fg"}`,children:[r.jsx("span",{children:g.icon}),g.label]},g.value))})]}),r.jsxs("button",{onClick:()=>d(!0),className:"flex items-center gap-1.5 px-2 py-1.5 text-xs text-cc-muted hover:text-cc-fg rounded-lg hover:bg-cc-hover transition-colors cursor-pointer border border-cc-border",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 opacity-60",children:r.jsx("path",{d:"M1 3.5A1.5 1.5 0 012.5 2h3.379a1.5 1.5 0 011.06.44l.622.621a.5.5 0 00.353.146H13.5A1.5 1.5 0 0115 4.707V12.5a1.5 1.5 0 01-1.5 1.5h-11A1.5 1.5 0 011 12.5v-9z"})}),r.jsx("span",{className:"max-w-[200px] truncate font-mono-code",children:m}),r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 opacity-50",children:r.jsx("path",{d:"M4 6l4 4 4-4"})})]}),c&&r.jsx(ev,{initialPath:e.cwd||"",onSelect:g=>s({cwd:g}),onClose:()=>d(!1)})]})]})}/**
234
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
235
+ * @license MIT
236
+ *
237
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
238
+ * @license MIT
239
+ *
240
+ * Originally forked from (with the author's permission):
241
+ * Fabrice Bellard's javascript vt100 for jslinux:
242
+ * http://bellard.org/jslinux/
243
+ * Copyright (c) 2011 Fabrice Bellard
244
+ */var AC=Object.defineProperty,E9=Object.getOwnPropertyDescriptor,M9=(e,t)=>{for(var s in t)AC(e,s,{get:t[s],enumerable:!0})},es=(e,t,s,n)=>{for(var a=n>1?void 0:n?E9(t,s):t,l=e.length-1,c;l>=0;l--)(c=e[l])&&(a=(n?c(t,s,a):c(a))||a);return n&&a&&AC(t,s,a),a},Ae=(e,t)=>(s,n)=>t(s,n,e),o2="Terminal input",Ex={get:()=>o2,set:e=>o2=e},l2="Too much output to announce, navigate to rows manually to read",Mx={get:()=>l2,set:e=>l2=e};function T9(e){return e.replace(/\r?\n/g,"\r")}function A9(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function R9(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function D9(e,t,s,n){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");RC(a,t,s,n)}}function RC(e,t,s,n){e=T9(e),e=A9(e,s.decPrivateModes.bracketedPasteMode&&n.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function DC(e,t,s){let n=s.getBoundingClientRect(),a=e.clientX-n.left-10,l=e.clientY-n.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${a}px`,t.style.top=`${l}px`,t.style.zIndex="1000",t.focus()}function c2(e,t,s,n,a){DC(e,t,s),a&&n.rightClickSelect(e),t.value=n.selectionText,t.select()}function Fi(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Jh(e,t=0,s=e.length){let n="";for(let a=t;a<s;++a){let l=e[a];l>65535?(l-=65536,n+=String.fromCharCode((l>>10)+55296)+String.fromCharCode(l%1024+56320)):n+=String.fromCharCode(l)}return n}var L9=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let n=0,a=0;if(this._interim){let l=e.charCodeAt(a++);56320<=l&&l<=57343?t[n++]=(this._interim-55296)*1024+l-56320+65536:(t[n++]=this._interim,t[n++]=l),this._interim=0}for(let l=a;l<s;++l){let c=e.charCodeAt(l);if(55296<=c&&c<=56319){if(++l>=s)return this._interim=c,n;let d=e.charCodeAt(l);56320<=d&&d<=57343?t[n++]=(c-55296)*1024+d-56320+65536:(t[n++]=c,t[n++]=d);continue}c!==65279&&(t[n++]=c)}return n}},B9=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let n=0,a,l,c,d,f=0,h=0;if(this.interim[0]){let _=!1,v=this.interim[0];v&=(v&224)===192?31:(v&240)===224?15:7;let y=0,S;for(;(S=this.interim[++y]&63)&&y<4;)v<<=6,v|=S;let j=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,k=j-y;for(;h<k;){if(h>=s)return 0;if(S=e[h++],(S&192)!==128){h--,_=!0;break}else this.interim[y++]=S,v<<=6,v|=S&63}_||(j===2?v<128?h--:t[n++]=v:j===3?v<2048||v>=55296&&v<=57343||v===65279||(t[n++]=v):v<65536||v>1114111||(t[n++]=v)),this.interim.fill(0)}let m=s-4,g=h;for(;g<s;){for(;g<m&&!((a=e[g])&128)&&!((l=e[g+1])&128)&&!((c=e[g+2])&128)&&!((d=e[g+3])&128);)t[n++]=a,t[n++]=l,t[n++]=c,t[n++]=d,g+=4;if(a=e[g++],a<128)t[n++]=a;else if((a&224)===192){if(g>=s)return this.interim[0]=a,n;if(l=e[g++],(l&192)!==128){g--;continue}if(f=(a&31)<<6|l&63,f<128){g--;continue}t[n++]=f}else if((a&240)===224){if(g>=s)return this.interim[0]=a,n;if(l=e[g++],(l&192)!==128){g--;continue}if(g>=s)return this.interim[0]=a,this.interim[1]=l,n;if(c=e[g++],(c&192)!==128){g--;continue}if(f=(a&15)<<12|(l&63)<<6|c&63,f<2048||f>=55296&&f<=57343||f===65279)continue;t[n++]=f}else if((a&248)===240){if(g>=s)return this.interim[0]=a,n;if(l=e[g++],(l&192)!==128){g--;continue}if(g>=s)return this.interim[0]=a,this.interim[1]=l,n;if(c=e[g++],(c&192)!==128){g--;continue}if(g>=s)return this.interim[0]=a,this.interim[1]=l,this.interim[2]=c,n;if(d=e[g++],(d&192)!==128){g--;continue}if(f=(a&7)<<18|(l&63)<<12|(c&63)<<6|d&63,f<65536||f>1114111)continue;t[n++]=f}}return n}},LC="",Vi=" ",fu=class BC{constructor(){this.fg=0,this.bg=0,this.extended=new Dh}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new BC;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Dh=class OC{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new OC(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Xn=class zC extends fu{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Dh,this.combinedData=""}static fromCharData(t){let s=new zC;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Fi(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let n=t[1].charCodeAt(0);if(55296<=n&&n<=56319){let a=t[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(n-55296)*1024+a-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},u2="di$target",Tx="di$dependencies",mg=new Map;function O9(e){return e[Tx]||[]}function As(e){if(mg.has(e))return mg.get(e);let t=function(s,n,a){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");z9(t,s,a)};return t._id=e,mg.set(e,t),t}function z9(e,t,s){t[u2]===t?t[Tx].push({id:e,index:s}):(t[Tx]=[{id:e,index:s}],t[u2]=t)}var sn=As("BufferService"),PC=As("CoreMouseService"),Ba=As("CoreService"),P9=As("CharsetService"),sv=As("InstantiationService"),$C=As("LogService"),nn=As("OptionsService"),IC=As("OscLinkService"),$9=As("UnicodeService"),pu=As("DecorationService"),Ax=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var m;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let n=[],a=this._optionsService.rawOptions.linkHandler,l=new Xn,c=s.getTrimmedLength(),d=-1,f=-1,h=!1;for(let g=0;g<c;g++)if(!(f===-1&&!s.hasContent(g))){if(s.loadCell(g,l),l.hasExtendedAttrs()&&l.extended.urlId)if(f===-1){f=g,d=l.extended.urlId;continue}else h=l.extended.urlId!==d;else f!==-1&&(h=!0);if(h||f!==-1&&g===c-1){let _=(m=this._oscLinkService.getLinkData(d))==null?void 0:m.uri;if(_){let v={start:{x:f+1,y:e},end:{x:g+(!h&&g===c-1?1:0),y:e}},y=!1;if(!(a!=null&&a.allowNonHttpProtocols))try{let S=new URL(_);["http:","https:"].includes(S.protocol)||(y=!0)}catch{y=!0}y||n.push({text:_,range:v,activate:(S,j)=>a?a.activate(S,j,v):I9(S,j),hover:(S,j)=>{var k;return(k=a==null?void 0:a.hover)==null?void 0:k.call(a,S,j,v)},leave:(S,j)=>{var k;return(k=a==null?void 0:a.leave)==null?void 0:k.call(a,S,j,v)}})}h=!1,l.hasExtendedAttrs()&&l.extended.urlId?(f=g,d=l.extended.urlId):(f=-1,d=-1)}}t(n)}};Ax=es([Ae(0,sn),Ae(1,nn),Ae(2,IC)],Ax);function I9(e,t){if(confirm(`Do you want to navigate to ${t}?
245
+
246
+ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Qh=As("CharSizeService"),ii=As("CoreBrowserService"),nv=As("MouseService"),ai=As("RenderService"),F9=As("SelectionService"),FC=As("CharacterJoinerService"),tl=As("ThemeService"),HC=As("LinkProviderService"),H9=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?d2.isErrorNoTelemetry(e)?new d2(e.message+`
247
+
248
+ `+e.stack):new Error(e.message+`
249
+
250
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},U9=new H9;function ah(e){V9(e)||U9.onUnexpectedError(e)}var Rx="Canceled";function V9(e){return e instanceof W9?!0:e instanceof Error&&e.name===Rx&&e.message===Rx}var W9=class extends Error{constructor(){super(Rx),this.name=this.message}};function q9(e){return new Error(`Illegal argument: ${e}`)}var d2=class Dx extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Dx)return t;let s=new Dx;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Lx=class UC extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,UC.prototype)}};function Cn(e,t=0){return e[e.length-(1+t)]}var G9;(e=>{function t(l){return l<0}e.isLessThan=t;function s(l){return l<=0}e.isLessThanOrEqual=s;function n(l){return l>0}e.isGreaterThan=n;function a(l){return l===0}e.isNeitherLessOrGreaterThan=a,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(G9||(G9={}));function K9(e,t){let s=this,n=!1,a;return function(){return n||(n=!0,t||(a=e.apply(s,arguments))),a}}var VC;(e=>{function t(B){return B&&typeof B=="object"&&typeof B[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function n(){return s}e.empty=n;function*a(B){yield B}e.single=a;function l(B){return t(B)?B:a(B)}e.wrap=l;function c(B){return B||s}e.from=c;function*d(B){for(let F=B.length-1;F>=0;F--)yield B[F]}e.reverse=d;function f(B){return!B||B[Symbol.iterator]().next().done===!0}e.isEmpty=f;function h(B){return B[Symbol.iterator]().next().value}e.first=h;function m(B,F){let $=0;for(let K of B)if(F(K,$++))return!0;return!1}e.some=m;function g(B,F){for(let $ of B)if(F($))return $}e.find=g;function*_(B,F){for(let $ of B)F($)&&(yield $)}e.filter=_;function*v(B,F){let $=0;for(let K of B)yield F(K,$++)}e.map=v;function*y(B,F){let $=0;for(let K of B)yield*F(K,$++)}e.flatMap=y;function*S(...B){for(let F of B)yield*F}e.concat=S;function j(B,F,$){let K=$;for(let Y of B)K=F(K,Y);return K}e.reduce=j;function*k(B,F,$=B.length){for(F<0&&(F+=B.length),$<0?$+=B.length:$>B.length&&($=B.length);F<$;F++)yield B[F]}e.slice=k;function N(B,F=Number.POSITIVE_INFINITY){let $=[];if(F===0)return[$,B];let K=B[Symbol.iterator]();for(let Y=0;Y<F;Y++){let W=K.next();if(W.done)return[$,e.empty()];$.push(W.value)}return[$,{[Symbol.iterator](){return K}}]}e.consume=N;async function E(B){let F=[];for await(let $ of B)F.push($);return Promise.resolve(F)}e.asyncToArray=E})(VC||(VC={}));function Ra(e){if(VC.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(n){t.push(n)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Y9(...e){return Ut(()=>Ra(e))}function Ut(e){return{dispose:K9(()=>{e()})}}var WC=class qC{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Ra(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?qC.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};WC.DISABLE_DISPOSED_WARNING=!1;var Yi=WC,nt=class{constructor(){this._store=new Yi,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};nt.None=Object.freeze({dispose(){}});var Yo=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Zr=typeof window=="object"?window:globalThis,Bx=class Ox{constructor(t){this.element=t,this.next=Ox.Undefined,this.prev=Ox.Undefined}};Bx.Undefined=new Bx(void 0);var Vt=Bx,h2=class{constructor(){this._first=Vt.Undefined,this._last=Vt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Vt.Undefined}clear(){let e=this._first;for(;e!==Vt.Undefined;){let t=e.next;e.prev=Vt.Undefined,e.next=Vt.Undefined,e=t}this._first=Vt.Undefined,this._last=Vt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new Vt(e);if(this._first===Vt.Undefined)this._first=s,this._last=s;else if(t){let a=this._last;this._last=s,s.prev=a,a.next=s}else{let a=this._first;this._first=s,s.next=a,a.prev=s}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(s))}}shift(){if(this._first!==Vt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Vt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Vt.Undefined&&e.next!==Vt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Vt.Undefined&&e.next===Vt.Undefined?(this._first=Vt.Undefined,this._last=Vt.Undefined):e.next===Vt.Undefined?(this._last=this._last.prev,this._last.next=Vt.Undefined):e.prev===Vt.Undefined&&(this._first=this._first.next,this._first.prev=Vt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Vt.Undefined;)yield e.element,e=e.next}},X9=globalThis.performance&&typeof globalThis.performance.now=="function",J9=class GC{static create(t){return new GC(t)}constructor(t){this._now=X9&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Is;(e=>{e.None=()=>nt.None;function t(V,X){return g(V,()=>{},0,void 0,!0,void 0,X)}e.defer=t;function s(V){return(X,q=null,A)=>{let M=!1,O;return O=V(U=>{if(!M)return O?O.dispose():M=!0,X.call(q,U)},null,A),M&&O.dispose(),O}}e.once=s;function n(V,X,q){return h((A,M=null,O)=>V(U=>A.call(M,X(U)),null,O),q)}e.map=n;function a(V,X,q){return h((A,M=null,O)=>V(U=>{X(U),A.call(M,U)},null,O),q)}e.forEach=a;function l(V,X,q){return h((A,M=null,O)=>V(U=>X(U)&&A.call(M,U),null,O),q)}e.filter=l;function c(V){return V}e.signal=c;function d(...V){return(X,q=null,A)=>{let M=Y9(...V.map(O=>O(U=>X.call(q,U))));return m(M,A)}}e.any=d;function f(V,X,q,A){let M=q;return n(V,O=>(M=X(M,O),M),A)}e.reduce=f;function h(V,X){let q,A={onWillAddFirstListener(){q=V(M.fire,M)},onDidRemoveLastListener(){q==null||q.dispose()}},M=new ke(A);return X==null||X.add(M),M.event}function m(V,X){return X instanceof Array?X.push(V):X&&X.add(V),V}function g(V,X,q=100,A=!1,M=!1,O,U){let I,R,P,z=0,T,oe={leakWarningThreshold:O,onWillAddFirstListener(){I=V(re=>{z++,R=X(R,re),A&&!P&&(be.fire(R),R=void 0),T=()=>{let ve=R;R=void 0,P=void 0,(!A||z>1)&&be.fire(ve),z=0},typeof q=="number"?(clearTimeout(P),P=setTimeout(T,q)):P===void 0&&(P=0,queueMicrotask(T))})},onWillRemoveListener(){M&&z>0&&(T==null||T())},onDidRemoveLastListener(){T=void 0,I.dispose()}},be=new ke(oe);return U==null||U.add(be),be.event}e.debounce=g;function _(V,X=0,q){return e.debounce(V,(A,M)=>A?(A.push(M),A):[M],X,void 0,!0,void 0,q)}e.accumulate=_;function v(V,X=(A,M)=>A===M,q){let A=!0,M;return l(V,O=>{let U=A||!X(O,M);return A=!1,M=O,U},q)}e.latch=v;function y(V,X,q){return[e.filter(V,X,q),e.filter(V,A=>!X(A),q)]}e.split=y;function S(V,X=!1,q=[],A){let M=q.slice(),O=V(R=>{M?M.push(R):I.fire(R)});A&&A.add(O);let U=()=>{M==null||M.forEach(R=>I.fire(R)),M=null},I=new ke({onWillAddFirstListener(){O||(O=V(R=>I.fire(R)),A&&A.add(O))},onDidAddFirstListener(){M&&(X?setTimeout(U):U())},onDidRemoveLastListener(){O&&O.dispose(),O=null}});return A&&A.add(I),I.event}e.buffer=S;function j(V,X){return(q,A,M)=>{let O=X(new N);return V(function(U){let I=O.evaluate(U);I!==k&&q.call(A,I)},void 0,M)}}e.chain=j;let k=Symbol("HaltChainable");class N{constructor(){this.steps=[]}map(X){return this.steps.push(X),this}forEach(X){return this.steps.push(q=>(X(q),q)),this}filter(X){return this.steps.push(q=>X(q)?q:k),this}reduce(X,q){let A=q;return this.steps.push(M=>(A=X(A,M),A)),this}latch(X=(q,A)=>q===A){let q=!0,A;return this.steps.push(M=>{let O=q||!X(M,A);return q=!1,A=M,O?M:k}),this}evaluate(X){for(let q of this.steps)if(X=q(X),X===k)break;return X}}function E(V,X,q=A=>A){let A=(...I)=>U.fire(q(...I)),M=()=>V.on(X,A),O=()=>V.removeListener(X,A),U=new ke({onWillAddFirstListener:M,onDidRemoveLastListener:O});return U.event}e.fromNodeEventEmitter=E;function B(V,X,q=A=>A){let A=(...I)=>U.fire(q(...I)),M=()=>V.addEventListener(X,A),O=()=>V.removeEventListener(X,A),U=new ke({onWillAddFirstListener:M,onDidRemoveLastListener:O});return U.event}e.fromDOMEventEmitter=B;function F(V){return new Promise(X=>s(V)(X))}e.toPromise=F;function $(V){let X=new ke;return V.then(q=>{X.fire(q)},()=>{X.fire(void 0)}).finally(()=>{X.dispose()}),X.event}e.fromPromise=$;function K(V,X){return V(q=>X.fire(q))}e.forward=K;function Y(V,X,q){return X(q),V(A=>X(A))}e.runAndSubscribe=Y;class W{constructor(X,q){this._observable=X,this._counter=0,this._hasChanged=!1;let A={onWillAddFirstListener:()=>{X.addObserver(this)},onDidRemoveLastListener:()=>{X.removeObserver(this)}};this.emitter=new ke(A),q&&q.add(this.emitter)}beginUpdate(X){this._counter++}handlePossibleChange(X){}handleChange(X,q){this._hasChanged=!0}endUpdate(X){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function L(V,X){return new W(V,X).emitter.event}e.fromObservable=L;function Q(V){return(X,q,A)=>{let M=0,O=!1,U={beginUpdate(){M++},endUpdate(){M--,M===0&&(V.reportChanges(),O&&(O=!1,X.call(q)))},handlePossibleChange(){},handleChange(){O=!0}};V.addObserver(U),V.reportChanges();let I={dispose(){V.removeObserver(U)}};return A instanceof Yi?A.add(I):Array.isArray(A)&&A.push(I),I}}e.fromObservableLight=Q})(Is||(Is={}));var zx=class Px{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Px._idPool++}`,Px.all.add(this)}start(t){this._stopWatch=new J9,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};zx.all=new Set,zx._idPool=0;var Q9=zx,Z9=-1,KC=class YC{constructor(t,s,n=(YC._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=n,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let n=this.threshold;if(n<=0||s<n)return;this._stacks||(this._stacks=new Map);let a=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,a+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=n*.5;let[l,c]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${c}):`;console.warn(d),console.warn(l);let f=new s$(d,l);this._errorHandler(f)}return()=>{let l=this._stacks.get(t.value)||0;this._stacks.set(t.value,l-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[n,a]of this._stacks)(!t||s<a)&&(t=[n,a],s=a);return t}};KC._idPool=1;var e$=KC,t$=class XC{constructor(t){this.value=t}static create(){let t=new Error;return new XC(t.stack??"")}print(){console.warn(this.value.split(`
251
+ `).slice(2).join(`
252
+ `))}},s$=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},n$=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},r$=0,gg=class{constructor(e){this.value=e,this.id=r$++}},i$=2,a$,ke=class{constructor(e){var t,s,n,a;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new e$((e==null?void 0:e.onListenerError)??ah,((s=this._options)==null?void 0:s.leakWarningThreshold)??Z9):void 0,this._perfMon=(n=this._options)!=null&&n._profName?new Q9(this._options._profName):void 0,this._deliveryQueue=(a=this._options)==null?void 0:a.deliveryQueue}dispose(){var e,t,s,n;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||s.call(t),(n=this._leakageMon)==null||n.dispose())}get event(){return this._event??(this._event=(e,t,s)=>{var c,d,f,h,m;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let g=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(g);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],v=new n$(`${g}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((c=this._options)==null?void 0:c.onListenerError)||ah)(v),nt.None}if(this._disposed)return nt.None;t&&(e=e.bind(t));let n=new gg(e),a;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=t$.create(),a=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof gg?(this._deliveryQueue??(this._deliveryQueue=new o$),this._listeners=[this._listeners,n]):this._listeners.push(n):((f=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||f.call(d,this),this._listeners=n,(m=(h=this._options)==null?void 0:h.onDidAddFirstListener)==null||m.call(h,this)),this._size++;let l=Ut(()=>{a==null||a(),this._removeListener(n)});return s instanceof Yi?s.add(l):Array.isArray(s)&&s.push(l),l}),this._event}_removeListener(e){var a,l,c,d;if((l=(a=this._options)==null?void 0:a.onWillRemoveListener)==null||l.call(a,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(d=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||d.call(c,this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[s]=void 0;let n=this._deliveryQueue.current===this;if(this._size*i$<=t.length){let f=0;for(let h=0;h<t.length;h++)t[h]?t[f++]=t[h]:n&&(this._deliveryQueue.end--,f<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=f}}_deliver(e,t){var n;if(!e)return;let s=((n=this._options)==null?void 0:n.onListenerError)||ah;if(!s){e.value(t);return}try{e.value(t)}catch(a){s(a)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,s,n,a;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(s=this._perfMon)==null||s.stop()),(n=this._perfMon)==null||n.start(this._size),this._listeners)if(this._listeners instanceof gg)this._deliver(this._listeners,e);else{let l=this._deliveryQueue;l.enqueue(this,e,this._listeners.length),this._deliverQueue(l)}(a=this._perfMon)==null||a.stop()}hasListeners(){return this._size>0}},o$=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},$x=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ke,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ke,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let n=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(n,t),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let n=this.getWindowId(s);this.mapWindowIdToFullScreen.set(n,t),this._onDidChangeFullscreen.fire(n)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};$x.INSTANCE=new $x;var rv=$x;function l$(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}rv.INSTANCE.onDidChangeZoomLevel;function c$(e){return rv.INSTANCE.getZoomFactor(e)}rv.INSTANCE.onDidChangeFullscreen;var sl=typeof navigator=="object"?navigator.userAgent:"",Ix=sl.indexOf("Firefox")>=0,u$=sl.indexOf("AppleWebKit")>=0,iv=sl.indexOf("Chrome")>=0,d$=!iv&&sl.indexOf("Safari")>=0;sl.indexOf("Electron/")>=0;sl.indexOf("Android")>=0;var xg=!1;if(typeof Zr.matchMedia=="function"){let e=Zr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Zr.matchMedia("(display-mode: fullscreen)");xg=e.matches,l$(Zr,e,({matches:s})=>{xg&&t.matches||(xg=s)})}var Po="en",Fx=!1,Hx=!1,oh=!1,JC=!1,qd,lh=Po,f2=Po,h$,er,Ca=globalThis,zs,dS;typeof Ca.vscode<"u"&&typeof Ca.vscode.process<"u"?zs=Ca.vscode.process:typeof process<"u"&&typeof((dS=process==null?void 0:process.versions)==null?void 0:dS.node)=="string"&&(zs=process);var hS,f$=typeof((hS=zs==null?void 0:zs.versions)==null?void 0:hS.electron)=="string",p$=f$&&(zs==null?void 0:zs.type)==="renderer",fS;if(typeof zs=="object"){Fx=zs.platform==="win32",Hx=zs.platform==="darwin",oh=zs.platform==="linux",oh&&zs.env.SNAP&&zs.env.SNAP_REVISION,zs.env.CI||zs.env.BUILD_ARTIFACTSTAGINGDIRECTORY,qd=Po,lh=Po;let e=zs.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);qd=t.userLocale,f2=t.osLocale,lh=t.resolvedLanguage||Po,h$=(fS=t.languagePack)==null?void 0:fS.translationsConfigFile}catch{}JC=!0}else typeof navigator=="object"&&!p$?(er=navigator.userAgent,Fx=er.indexOf("Windows")>=0,Hx=er.indexOf("Macintosh")>=0,(er.indexOf("Macintosh")>=0||er.indexOf("iPad")>=0||er.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,oh=er.indexOf("Linux")>=0,(er==null?void 0:er.indexOf("Mobi"))>=0,lh=globalThis._VSCODE_NLS_LANGUAGE||Po,qd=navigator.language.toLowerCase(),f2=qd):console.error("Unable to resolve platform.");var QC=Fx,yr=Hx,m$=oh,p2=JC,jr=er,Oi=lh,g$;(e=>{function t(){return Oi}e.value=t;function s(){return Oi.length===2?Oi==="en":Oi.length>=3?Oi[0]==="e"&&Oi[1]==="n"&&Oi[2]==="-":!1}e.isDefaultVariant=s;function n(){return Oi==="en"}e.isDefault=n})(g$||(g$={}));var x$=typeof Ca.postMessage=="function"&&!Ca.importScripts;(()=>{if(x$){let e=[];Ca.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let n=0,a=e.length;n<a;n++){let l=e[n];if(l.id===s.data.vscodeScheduleAsyncWork){e.splice(n,1),l.callback();return}}});let t=0;return s=>{let n=++t;e.push({id:n,callback:s}),Ca.postMessage({vscodeScheduleAsyncWork:n},"*")}}return e=>setTimeout(e)})();var v$=!!(jr&&jr.indexOf("Chrome")>=0);jr&&jr.indexOf("Firefox")>=0;!v$&&jr&&jr.indexOf("Safari")>=0;jr&&jr.indexOf("Edg/")>=0;jr&&jr.indexOf("Android")>=0;var Eo=typeof navigator=="object"?navigator:{};p2||document.queryCommandSupported&&document.queryCommandSupported("copy")||Eo&&Eo.clipboard&&Eo.clipboard.writeText,p2||Eo&&Eo.clipboard&&Eo.clipboard.readText;var av=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},vg=new av,m2=new av,g2=new av,b$=new Array(230),ZC;(e=>{function t(d){return vg.keyCodeToStr(d)}e.toString=t;function s(d){return vg.strToKeyCode(d)}e.fromString=s;function n(d){return m2.keyCodeToStr(d)}e.toUserSettingsUS=n;function a(d){return g2.keyCodeToStr(d)}e.toUserSettingsGeneral=a;function l(d){return m2.strToKeyCode(d)||g2.strToKeyCode(d)}e.fromUserSettings=l;function c(d){if(d>=98&&d<=113)return null;switch(d){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return vg.keyCodeToStr(d)}e.toElectronAccelerator=c})(ZC||(ZC={}));var _$=class eN{constructor(t,s,n,a,l){this.ctrlKey=t,this.shiftKey=s,this.altKey=n,this.metaKey=a,this.keyCode=l}equals(t){return t instanceof eN&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",n=this.altKey?"1":"0",a=this.metaKey?"1":"0";return`K${t}${s}${n}${a}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new y$([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},y$=class{constructor(e){if(e.length===0)throw q9("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function w$(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return ZC.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Ix)switch(t){case 59:return 85;case 60:if(m$)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(yr)return 57;break}else if(u$&&(yr&&t===93||!yr&&t===92))return 57;return b$[t]||0}var S$=yr?256:2048,j$=512,k$=1024,C$=yr?2048:256,x2=class{constructor(e){var s;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(s=t.getModifierState)==null?void 0:s.call(t,"AltGraph"),this.keyCode=w$(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=S$),this.altKey&&(t|=j$),this.shiftKey&&(t|=k$),this.metaKey&&(t|=C$),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new _$(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},v2=new WeakMap;function N$(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var E$=class{static getSameOriginWindowChain(e){let t=v2.get(e);if(!t){t=[],v2.set(e,t);let s=e,n;do n=N$(s),n?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=n;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,n=0,a=this.getSameOriginWindowChain(e);for(let l of a){let c=l.window.deref();if(s+=(c==null?void 0:c.scrollY)??0,n+=(c==null?void 0:c.scrollX)??0,c===t||!l.iframeElement)break;let d=l.iframeElement.getBoundingClientRect();s+=d.top,n+=d.left}return{top:s,left:n}}},Gd=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=E$.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},b2=class{constructor(e,t=0,s=0){var a;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let n=!1;if(iv){let l=navigator.userAgent.match(/Chrome\/(\d+)/);n=(l?parseInt(l[1]):123)<=122}if(e){let l=e,c=e,d=((a=e.view)==null?void 0:a.devicePixelRatio)||1;if(typeof l.wheelDeltaY<"u")n?this.deltaY=l.wheelDeltaY/(120*d):this.deltaY=l.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?Ix&&!yr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof l.wheelDeltaX<"u")d$&&QC?this.deltaX=-(l.wheelDeltaX/120):n?this.deltaX=l.wheelDeltaX/(120*d):this.deltaX=l.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?Ix&&!yr?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(n?this.deltaY=e.wheelDelta/(120*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},tN=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),M$;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof T$?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Is.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:tN})})(M$||(M$={}));var T$=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?tN:(this._emitter||(this._emitter=new ke),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},ov=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Lx("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Lx("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},A$=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new Lx("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let n=s.setInterval(()=>{e()},t);this.disposable=Ut(()=>{s.clearInterval(n),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},R$;(e=>{async function t(n){let a,l=await Promise.all(n.map(c=>c.then(d=>d,d=>{a||(a=d)})));if(typeof a<"u")throw a;return l}e.settled=t;function s(n){return new Promise(async(a,l)=>{try{await n(a,l)}catch(c){l(c)}})}e.withAsyncBody=s})(R$||(R$={}));var _2=class Wn{static fromArray(t){return new Wn(s=>{s.emitMany(t)})}static fromPromise(t){return new Wn(async s=>{s.emitMany(await t)})}static fromPromises(t){return new Wn(async s=>{await Promise.all(t.map(async n=>s.emitOne(await n)))})}static merge(t){return new Wn(async s=>{await Promise.all(t.map(async n=>{for await(let a of n)s.emitOne(a)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new ke,queueMicrotask(async()=>{let n={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(t(n)),this.resolve()}catch(a){this.reject(a)}finally{n.emitOne=void 0,n.emitMany=void 0,n.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Is.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new Wn(async n=>{for await(let a of t)n.emitOne(s(a))})}map(t){return Wn.map(this,t)}static filter(t,s){return new Wn(async n=>{for await(let a of t)s(a)&&n.emitOne(a)})}filter(t){return Wn.filter(this,t)}static coalesce(t){return Wn.filter(t,s=>!!s)}coalesce(){return Wn.coalesce(this)}static async toPromise(t){let s=[];for await(let n of t)s.push(n);return s}toPromise(){return Wn.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};_2.EMPTY=_2.fromArray([]);var{getWindow:_r,getWindowId:D$,onDidRegisterWindow:L$}=(function(){let e=new Map,t={window:Zr,disposables:new Yi};e.set(Zr.vscodeWindowId,t);let s=new ke,n=new ke,a=new ke;function l(c,d){return(typeof c=="number"?e.get(c):void 0)??(d?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:n.event,registerWindow(c){if(e.has(c.vscodeWindowId))return nt.None;let d=new Yi,f={window:c,disposables:d.add(new Yi)};return e.set(c.vscodeWindowId,f),d.add(Ut(()=>{e.delete(c.vscodeWindowId),n.fire(c)})),d.add(Ge(c,Cs.BEFORE_UNLOAD,()=>{a.fire(c)})),s.fire(f),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:l,getWindow(c){var h;let d=c;if((h=d==null?void 0:d.ownerDocument)!=null&&h.defaultView)return d.ownerDocument.defaultView.window;let f=c;return f!=null&&f.view?f.view.window:Zr},getDocument(c){return _r(c).document}}})(),B$=class{constructor(e,t,s,n){this._node=e,this._type=t,this._handler=s,this._options=n||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ge(e,t,s,n){return new B$(e,t,s,n)}var y2=function(e,t,s,n){return Ge(e,t,s,n)},lv,O$=class extends A${constructor(e){super(),this.defaultTarget=e&&_r(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},w2=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){ah(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,n=new Map,a=l=>{s.set(l,!1);let c=e.get(l)??[];for(t.set(l,c),e.set(l,[]),n.set(l,!0);c.length>0;)c.sort(w2.sort),c.shift().execute();n.set(l,!1)};lv=(l,c,d=0)=>{let f=D$(l),h=new w2(c,d),m=e.get(f);return m||(m=[],e.set(f,m)),m.push(h),s.get(f)||(s.set(f,!0),l.requestAnimationFrame(()=>a(f))),h}})();function z$(e){let t=e.getBoundingClientRect(),s=_r(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Cs={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},P$=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=hn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=hn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=hn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=hn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=hn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=hn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=hn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=hn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=hn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=hn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=hn(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=hn(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=hn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=hn(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function hn(e){return typeof e=="number"?`${e}px`:e}function Fc(e){return new P$(e)}var sN=class{constructor(){this._hooks=new Yi,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,n,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=n,this._onStopCallback=a;let l=e;try{e.setPointerCapture(t),this._hooks.add(Ut(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{l=_r(e)}this._hooks.add(Ge(l,Cs.POINTER_MOVE,c=>{if(c.buttons!==s){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(Ge(l,Cs.POINTER_UP,c=>this.stopMonitoring(!0)))}};function $$(e,t,s){let n=null,a=null;if(typeof s.value=="function"?(n="value",a=s.value,a.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(n="get",a=s.get),!a)throw new Error("not supported");let l=`$memoize$${t}`;s[n]=function(...c){return this.hasOwnProperty(l)||Object.defineProperty(this,l,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,c)}),this[l]}}var pr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(pr||(pr={}));var Ec=class Vs extends nt{constructor(){super(),this.dispatched=!1,this.targets=new h2,this.ignoreTargets=new h2,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Is.runAndSubscribe(L$,({window:t,disposables:s})=>{s.add(Ge(t.document,"touchstart",n=>this.onTouchStart(n),{passive:!1})),s.add(Ge(t.document,"touchend",n=>this.onTouchEnd(t,n))),s.add(Ge(t.document,"touchmove",n=>this.onTouchMove(n),{passive:!1}))},{window:Zr,disposables:this._store}))}static addTarget(t){if(!Vs.isTouchDevice())return nt.None;Vs.INSTANCE||(Vs.INSTANCE=new Vs);let s=Vs.INSTANCE.targets.push(t);return Ut(s)}static ignoreTarget(t){if(!Vs.isTouchDevice())return nt.None;Vs.INSTANCE||(Vs.INSTANCE=new Vs);let s=Vs.INSTANCE.ignoreTargets.push(t);return Ut(s)}static isTouchDevice(){return"ontouchstart"in Zr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let n=0,a=t.targetTouches.length;n<a;n++){let l=t.targetTouches.item(n);this.activeTouches[l.identifier]={id:l.identifier,initialTarget:l.target,initialTimeStamp:s,initialPageX:l.pageX,initialPageY:l.pageY,rollingTimestamps:[s],rollingPageX:[l.pageX],rollingPageY:[l.pageY]};let c=this.newGestureEvent(pr.Start,l.target);c.pageX=l.pageX,c.pageY=l.pageY,this.dispatchEvent(c)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let n=Date.now(),a=Object.keys(this.activeTouches).length;for(let l=0,c=s.changedTouches.length;l<c;l++){let d=s.changedTouches.item(l);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let f=this.activeTouches[d.identifier],h=Date.now()-f.initialTimeStamp;if(h<Vs.HOLD_DELAY&&Math.abs(f.initialPageX-Cn(f.rollingPageX))<30&&Math.abs(f.initialPageY-Cn(f.rollingPageY))<30){let m=this.newGestureEvent(pr.Tap,f.initialTarget);m.pageX=Cn(f.rollingPageX),m.pageY=Cn(f.rollingPageY),this.dispatchEvent(m)}else if(h>=Vs.HOLD_DELAY&&Math.abs(f.initialPageX-Cn(f.rollingPageX))<30&&Math.abs(f.initialPageY-Cn(f.rollingPageY))<30){let m=this.newGestureEvent(pr.Contextmenu,f.initialTarget);m.pageX=Cn(f.rollingPageX),m.pageY=Cn(f.rollingPageY),this.dispatchEvent(m)}else if(a===1){let m=Cn(f.rollingPageX),g=Cn(f.rollingPageY),_=Cn(f.rollingTimestamps)-f.rollingTimestamps[0],v=m-f.rollingPageX[0],y=g-f.rollingPageY[0],S=[...this.targets].filter(j=>f.initialTarget instanceof Node&&j.contains(f.initialTarget));this.inertia(t,S,n,Math.abs(v)/_,v>0?1:-1,m,Math.abs(y)/_,y>0?1:-1,g)}this.dispatchEvent(this.newGestureEvent(pr.End,f.initialTarget)),delete this.activeTouches[d.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let n=document.createEvent("CustomEvent");return n.initEvent(t,!1,!0),n.initialTarget=s,n.tapCount=0,n}dispatchEvent(t){if(t.type===pr.Tap){let s=new Date().getTime(),n=0;s-this._lastSetTapCountTime>Vs.CLEAR_TAP_COUNT_TIME?n=1:n=2,this._lastSetTapCountTime=s,t.tapCount=n}else(t.type===pr.Change||t.type===pr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let n of this.ignoreTargets)if(n.contains(t.initialTarget))return;let s=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let a=0,l=t.initialTarget;for(;l&&l!==n;)a++,l=l.parentElement;s.push([a,n])}s.sort((n,a)=>n[0]-a[0]);for(let[n,a]of s)a.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,n,a,l,c,d,f,h){this.handle=lv(t,()=>{let m=Date.now(),g=m-n,_=0,v=0,y=!0;a+=Vs.SCROLL_FRICTION*g,d+=Vs.SCROLL_FRICTION*g,a>0&&(y=!1,_=l*a*g),d>0&&(y=!1,v=f*d*g);let S=this.newGestureEvent(pr.Change);S.translationX=_,S.translationY=v,s.forEach(j=>j.dispatchEvent(S)),y||this.inertia(t,s,m,a,l,c+_,d,f,h+v)})}onTouchMove(t){let s=Date.now();for(let n=0,a=t.changedTouches.length;n<a;n++){let l=t.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("end of an UNKNOWN touch",l);continue}let c=this.activeTouches[l.identifier],d=this.newGestureEvent(pr.Change,c.initialTarget);d.translationX=l.pageX-Cn(c.rollingPageX),d.translationY=l.pageY-Cn(c.rollingPageY),d.pageX=l.pageX,d.pageY=l.pageY,this.dispatchEvent(d),c.rollingPageX.length>3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(l.pageX),c.rollingPageY.push(l.pageY),c.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ec.SCROLL_FRICTION=-.005,Ec.HOLD_DELAY=700,Ec.CLEAR_TAP_COUNT_TIME=400,es([$$],Ec,"isTouchDevice",1);var I$=Ec,cv=class extends nt{onclick(e,t){this._register(Ge(e,Cs.CLICK,s=>t(new Gd(_r(e),s))))}onmousedown(e,t){this._register(Ge(e,Cs.MOUSE_DOWN,s=>t(new Gd(_r(e),s))))}onmouseover(e,t){this._register(Ge(e,Cs.MOUSE_OVER,s=>t(new Gd(_r(e),s))))}onmouseleave(e,t){this._register(Ge(e,Cs.MOUSE_LEAVE,s=>t(new Gd(_r(e),s))))}onkeydown(e,t){this._register(Ge(e,Cs.KEY_DOWN,s=>t(new x2(s))))}onkeyup(e,t){this._register(Ge(e,Cs.KEY_UP,s=>t(new x2(s))))}oninput(e,t){this._register(Ge(e,Cs.INPUT,t))}onblur(e,t){this._register(Ge(e,Cs.BLUR,t))}onfocus(e,t){this._register(Ge(e,Cs.FOCUS,t))}onchange(e,t){this._register(Ge(e,Cs.CHANGE,t))}ignoreGesture(e){return I$.ignoreTarget(e)}},S2=11,F$=class extends cv{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=S2+"px",this.domNode.style.height=S2+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new sN),this._register(y2(this.bgDomNode,Cs.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(y2(this.domNode,Cs.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new O$),this._pointerdownScheduleRepeatTimer=this._register(new ov)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,_r(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},H$=class Ux{constructor(t,s,n,a,l,c,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,n=n|0,a=a|0,l=l|0,c=c|0,d=d|0),this.rawScrollLeft=a,this.rawScrollTop=d,s<0&&(s=0),a+s>n&&(a=n-s),a<0&&(a=0),l<0&&(l=0),d+l>c&&(d=c-l),d<0&&(d=0),this.width=s,this.scrollWidth=n,this.scrollLeft=a,this.height=l,this.scrollHeight=c,this.scrollTop=d}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new Ux(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Ux(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let n=this.width!==t.width,a=this.scrollWidth!==t.scrollWidth,l=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,f=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:a,scrollLeftChanged:l,heightChanged:c,scrollHeightChanged:d,scrollTopChanged:f}}},U$=class extends nt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new H$(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var n;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(n=this._smoothScrolling)==null||n.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let n;t?n=new k2(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):n=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=n}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=k2.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},j2=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function bg(e,t){let s=t-e;return function(n){return e+s*q$(n)}}function V$(e,t,s){return function(n){return n<s?e(n/s):t((n-s)/(1-s))}}var k2=class Vx{constructor(t,s,n,a){this.from=t,this.to=s,this.duration=a,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,n){if(Math.abs(t-s)>2.5*n){let a,l;return t<s?(a=t+.75*n,l=s-.75*n):(a=t-.75*n,l=s+.75*n),V$(bg(t,a),bg(l,s),.33)}return bg(t,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let s=(t-this.startTime)/this.duration;if(s<1){let n=this.scrollLeft(s),a=this.scrollTop(s);return new j2(n,a,!1)}return new j2(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,n){return Vx.start(t,s,n)}static start(t,s,n){n=n+10;let a=Date.now()-10;return new Vx(t,s,a,n)}};function W$(e){return Math.pow(e,3)}function q$(e){return 1-W$(1-e)}var G$=class extends nt{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new ov)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},K$=140,nN=class extends cv{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new G$(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new sN),this._shouldRender=!0,this.domNode=Fc(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Ge(this.domNode.domNode,Cs.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new F$(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,n){this.slider=Fc(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof n=="number"&&this.slider.setHeight(n),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ge(this.slider.domNode,Cs.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),n=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);s<=a&&a<=n?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let a=z$(this.domNode.domNode);t=e.pageX-a.left,s=e.pageY-a.top}let n=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),n=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let l=this._sliderOrthogonalPointerPosition(a),c=Math.abs(l-s);if(QC&&c>K$){this._setDesiredScrollPositionNow(n.getScrollPosition());return}let d=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(n.getDesiredScrollPositionFromDelta(d))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},rN=class Wx{constructor(t,s,n,a,l,c){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=l,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Wx(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,n,a,l){let c=Math.max(0,n-t),d=Math.max(0,c-2*s),f=a>0&&a>n;if(!f)return{computedAvailableSize:Math.round(c),computedIsNeeded:f,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(n*d/a))),m=(d-h)/(a-n),g=l*m;return{computedAvailableSize:Math.round(c),computedIsNeeded:f,computedSliderSize:Math.round(h),computedSliderRatio:m,computedSliderPosition:Math.round(g)}}_refreshComputedValues(){let t=Wx._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,n=this._scrollPosition;return s<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},Y$=class extends nN{constructor(e,t,s){let n=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new rN(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,n.width,n.scrollWidth,a.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},X$=class extends nN{constructor(e,t,s){let n=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new rN(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,n.height,n.scrollHeight,a.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},J$=500,C2=50,Q$=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},qx=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,s=0,n=1,a=this._rear;do{let l=a===this._front?t:Math.pow(2,-n);if(t-=l,s+=this._memory[a].score*l,a===this._front)break;a=(this._capacity+a-1)%this._capacity,n++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(iv){let s=_r(t.browserEvent),n=c$(s);this.accept(Date.now(),t.deltaX*n,t.deltaY*n)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,n){let a=null,l=new Q$(t,s,n);this._front===-1&&this._rear===-1?(this._memory[0]=l,this._front=0,this._rear=0):(a=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=l),l.score=this._computeScore(l,a)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(n+=.25),s){let a=Math.abs(t.deltaX),l=Math.abs(t.deltaY),c=Math.abs(s.deltaX),d=Math.abs(s.deltaY),f=Math.max(Math.min(a,c),1),h=Math.max(Math.min(l,d),1),m=Math.max(a,c),g=Math.max(l,d);m%f===0&&g%h===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};qx.INSTANCE=new qx;var Z$=qx,eI=class extends cv{constructor(e,t,s){super(),this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ke),this.onWillScroll=this._onWillScroll.event,this._options=sI(t),this._scrollable=s,this._register(this._scrollable.onScroll(a=>{this._onWillScroll.fire(a),this._onDidScroll(a),this._onScroll.fire(a)}));let n={onMouseWheel:a=>this._onMouseWheel(a),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new X$(this._scrollable,this._options,n)),this._horizontalScrollbar=this._register(new Y$(this._scrollable,this._options,n)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Fc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Fc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Fc(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,a=>this._onMouseOver(a)),this.onmouseleave(this._listenOnDomNode,a=>this._onMouseLeave(a)),this._hideTimeout=this._register(new ov),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Ra(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,yr&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new b2(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Ra(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new b2(s))};this._mouseWheelToDispose.push(Ge(this._listenOnDomNode,Cs.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=Z$.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let l=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+l===0?c=l=0:Math.abs(l)>=Math.abs(c)?c=0:l=0),this._options.flipAxes&&([l,c]=[c,l]);let d=!yr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!c&&(c=l,l=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,l=l*this._options.fastScrollSensitivity);let f=this._scrollable.getFutureScrollPosition(),h={};if(l){let m=C2*l,g=f.scrollTop-(m<0?Math.floor(m):Math.ceil(m));this._verticalScrollbar.writeScrollPosition(h,g)}if(c){let m=C2*c,g=f.scrollLeft-(m<0?Math.floor(m):Math.ceil(m));this._horizontalScrollbar.writeScrollPosition(h,g)}h=this._scrollable.validateScrollPosition(h),(f.scrollLeft!==h.scrollLeft||f.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),s=!0)}let n=s;!n&&this._options.alwaysConsumeMouseWheel&&(n=!0),!n&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(n=!0),n&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,n=s?" left":"",a=t?" top":"",l=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${n}`),this._topShadowDomNode.setClassName(`shadow${a}`),this._topLeftShadowDomNode.setClassName(`shadow${l}${a}${n}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),J$)}},tI=class extends eI{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function sI(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,yr&&(t.className+=" mac"),t}var Gx=class extends nt{constructor(e,t,s,n,a,l,c,d){super(),this._bufferService=s,this._optionsService=c,this._renderService=d,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let f=this._register(new U$({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>lv(n.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{f.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new tI(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},f)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Is.runAndSubscribe(l.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=l.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Ut(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=n.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Ut(()=>this._styleElement.remove())),this._register(Is.runAndSubscribe(l.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${l.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${l.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${l.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
253
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Gx=es([Ae(2,sn),Ae(3,ii),Ae(4,PC),Ae(5,tl),Ae(6,nn),Ae(7,ai)],Gx);var Kx=class extends nt{constructor(e,t,s,n,a){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=n,this._renderService=a,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(l=>this._removeDecoration(l))),this._register(Ut(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var n;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((n=e==null?void 0:e.options)==null?void 0:n.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Kx=es([Ae(1,sn),Ae(2,ii),Ae(3,pu),Ae(4,ai)],Kx);var nI=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},dr={full:0,left:0,center:0,right:0},zi={full:0,left:0,center:0,right:0},dc={full:0,left:0,center:0,right:0},Lh=class extends nt{constructor(e,t,s,n,a,l,c,d){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=n,this._renderService=a,this._optionsService=l,this._themeService=c,this._coreBrowserService=d,this._colorZoneStore=new nI,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(Ut(()=>{var m;return(m=this._canvas)==null?void 0:m.remove()}));let f=this._canvas.getContext("2d");if(f)this._ctx=f;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);zi.full=this._canvas.width,zi.left=e,zi.center=t,zi.right=e,this._refreshDrawHeightConstants(),dc.full=1,dc.left=1,dc.center=1+zi.left,dc.right=1+zi.left+zi.center}_refreshDrawHeightConstants(){dr.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);dr.left=t,dr.center=t,dr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(dc[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-dr[e.position||"full"]/2),zi[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+dr[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Lh=es([Ae(2,sn),Ae(3,pu),Ae(4,ai),Ae(5,nn),Ae(6,tl),Ae(7,ii)],Lh);var xe;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
254
+ `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(xe||(xe={}));var ch;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(ch||(ch={}));var iN;(e=>e.ST=`${xe.ESC}\\`)(iN||(iN={}));var Yx=class{constructor(e,t,s,n,a,l){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=n,this._coreService=a,this._renderService=l,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${xe.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,a=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=a+"px",this._compositionView.style.top=n+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let l=this._compositionView.getBoundingClientRect();this._textarea.style.left=a+"px",this._textarea.style.top=n+"px",this._textarea.style.width=Math.max(l.width,1)+"px",this._textarea.style.height=Math.max(l.height,1)+"px",this._textarea.style.lineHeight=l.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Yx=es([Ae(2,sn),Ae(3,nn),Ae(4,Ba),Ae(5,ai)],Yx);var Ns=0,Es=0,Ms=0,Zt=0,N2={css:"#00000000",rgba:0},fs;(e=>{function t(a,l,c,d){return d!==void 0?`#${_a(a)}${_a(l)}${_a(c)}${_a(d)}`:`#${_a(a)}${_a(l)}${_a(c)}`}e.toCss=t;function s(a,l,c,d=255){return(a<<24|l<<16|c<<8|d)>>>0}e.toRgba=s;function n(a,l,c,d){return{css:e.toCss(a,l,c,d),rgba:e.toRgba(a,l,c,d)}}e.toColor=n})(fs||(fs={}));var $t;(e=>{function t(f,h){if(Zt=(h.rgba&255)/255,Zt===1)return{css:h.css,rgba:h.rgba};let m=h.rgba>>24&255,g=h.rgba>>16&255,_=h.rgba>>8&255,v=f.rgba>>24&255,y=f.rgba>>16&255,S=f.rgba>>8&255;Ns=v+Math.round((m-v)*Zt),Es=y+Math.round((g-y)*Zt),Ms=S+Math.round((_-S)*Zt);let j=fs.toCss(Ns,Es,Ms),k=fs.toRgba(Ns,Es,Ms);return{css:j,rgba:k}}e.blend=t;function s(f){return(f.rgba&255)===255}e.isOpaque=s;function n(f,h,m){let g=uh.ensureContrastRatio(f.rgba,h.rgba,m);if(g)return fs.toColor(g>>24&255,g>>16&255,g>>8&255)}e.ensureContrastRatio=n;function a(f){let h=(f.rgba|255)>>>0;return[Ns,Es,Ms]=uh.toChannels(h),{css:fs.toCss(Ns,Es,Ms),rgba:h}}e.opaque=a;function l(f,h){return Zt=Math.round(h*255),[Ns,Es,Ms]=uh.toChannels(f.rgba),{css:fs.toCss(Ns,Es,Ms,Zt),rgba:fs.toRgba(Ns,Es,Ms,Zt)}}e.opacity=l;function c(f,h){return Zt=f.rgba&255,l(f,Zt*h/255)}e.multiplyOpacity=c;function d(f){return[f.rgba>>24&255,f.rgba>>16&255,f.rgba>>8&255]}e.toColorRGB=d})($t||($t={}));var Wt;(e=>{let t,s;try{let a=document.createElement("canvas");a.width=1,a.height=1;let l=a.getContext("2d",{willReadFrequently:!0});l&&(t=l,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function n(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Ns=parseInt(a.slice(1,2).repeat(2),16),Es=parseInt(a.slice(2,3).repeat(2),16),Ms=parseInt(a.slice(3,4).repeat(2),16),fs.toColor(Ns,Es,Ms);case 5:return Ns=parseInt(a.slice(1,2).repeat(2),16),Es=parseInt(a.slice(2,3).repeat(2),16),Ms=parseInt(a.slice(3,4).repeat(2),16),Zt=parseInt(a.slice(4,5).repeat(2),16),fs.toColor(Ns,Es,Ms,Zt);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let l=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(l)return Ns=parseInt(l[1]),Es=parseInt(l[2]),Ms=parseInt(l[3]),Zt=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),fs.toColor(Ns,Es,Ms,Zt);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ns,Es,Ms,Zt]=t.getImageData(0,0,1,1).data,Zt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:fs.toRgba(Ns,Es,Ms,Zt),css:a}}e.toColor=n})(Wt||(Wt={}));var Qs;(e=>{function t(n){return s(n>>16&255,n>>8&255,n&255)}e.relativeLuminance=t;function s(n,a,l){let c=n/255,d=a/255,f=l/255,h=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),m=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4);return h*.2126+m*.7152+g*.0722}e.relativeLuminance2=s})(Qs||(Qs={}));var uh;(e=>{function t(c,d){if(Zt=(d&255)/255,Zt===1)return d;let f=d>>24&255,h=d>>16&255,m=d>>8&255,g=c>>24&255,_=c>>16&255,v=c>>8&255;return Ns=g+Math.round((f-g)*Zt),Es=_+Math.round((h-_)*Zt),Ms=v+Math.round((m-v)*Zt),fs.toRgba(Ns,Es,Ms)}e.blend=t;function s(c,d,f){let h=Qs.relativeLuminance(c>>8),m=Qs.relativeLuminance(d>>8);if(Gr(h,m)<f){if(m<h){let v=n(c,d,f),y=Gr(h,Qs.relativeLuminance(v>>8));if(y<f){let S=a(c,d,f),j=Gr(h,Qs.relativeLuminance(S>>8));return y>j?v:S}return v}let g=a(c,d,f),_=Gr(h,Qs.relativeLuminance(g>>8));if(_<f){let v=n(c,d,f),y=Gr(h,Qs.relativeLuminance(v>>8));return _>y?g:v}return g}}e.ensureContrastRatio=s;function n(c,d,f){let h=c>>24&255,m=c>>16&255,g=c>>8&255,_=d>>24&255,v=d>>16&255,y=d>>8&255,S=Gr(Qs.relativeLuminance2(_,v,y),Qs.relativeLuminance2(h,m,g));for(;S<f&&(_>0||v>0||y>0);)_-=Math.max(0,Math.ceil(_*.1)),v-=Math.max(0,Math.ceil(v*.1)),y-=Math.max(0,Math.ceil(y*.1)),S=Gr(Qs.relativeLuminance2(_,v,y),Qs.relativeLuminance2(h,m,g));return(_<<24|v<<16|y<<8|255)>>>0}e.reduceLuminance=n;function a(c,d,f){let h=c>>24&255,m=c>>16&255,g=c>>8&255,_=d>>24&255,v=d>>16&255,y=d>>8&255,S=Gr(Qs.relativeLuminance2(_,v,y),Qs.relativeLuminance2(h,m,g));for(;S<f&&(_<255||v<255||y<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),y=Math.min(255,y+Math.ceil((255-y)*.1)),S=Gr(Qs.relativeLuminance2(_,v,y),Qs.relativeLuminance2(h,m,g));return(_<<24|v<<16|y<<8|255)>>>0}e.increaseLuminance=a;function l(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=l})(uh||(uh={}));function _a(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Gr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var rI=class extends fu{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Bh=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Xn}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],n=t.translateToString(!0),a=0,l=0,c=0,d=t.getFg(0),f=t.getBg(0);for(let h=0;h<t.getTrimmedLength();h++)if(t.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==d||this._workCell.bg!==f){if(h-a>1){let m=this._getJoinedRanges(n,c,l,t,a);for(let g=0;g<m.length;g++)s.push(m[g])}a=h,c=l,d=this._workCell.fg,f=this._workCell.bg}l+=this._workCell.getChars().length||Vi.length}if(this._bufferService.cols-a>1){let h=this._getJoinedRanges(n,c,l,t,a);for(let m=0;m<h.length;m++)s.push(h[m])}return s}_getJoinedRanges(e,t,s,n,a){let l=e.substring(t,s),c=[];try{c=this._characterJoiners[0].handler(l)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let f=this._characterJoiners[d].handler(l);for(let h=0;h<f.length;h++)Bh._mergeRanges(c,f[h])}catch(f){console.error(f)}return this._stringRangesToCellRanges(c,n,a),c}_stringRangesToCellRanges(e,t,s){let n=0,a=!1,l=0,c=e[n];if(c){for(let d=s;d<this._bufferService.cols;d++){let f=t.getWidth(d),h=t.getString(d).length||Vi.length;if(f!==0){if(!a&&c[0]<=l&&(c[0]=d,a=!0),c[1]<=l){if(c[1]=d,c=e[++n],!c)break;c[0]<=l?(c[0]=d,a=!0):a=!1}l+=h}}c&&(c[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let n=0;n<e.length;n++){let a=e[n];if(s){if(t[1]<=a[0])return e[n-1][1]=t[1],e;if(t[1]<=a[1])return e[n-1][1]=Math.max(t[1],a[1]),e.splice(n,1),e;e.splice(n,1),n--}else{if(t[1]<=a[0])return e.splice(n,0,t),e;if(t[1]<=a[1])return a[0]=Math.min(t[0],a[0]),e;t[0]<a[1]&&(a[0]=Math.min(t[0],a[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};Bh=es([Ae(0,sn)],Bh);function iI(e){return 57508<=e&&e<=57558}function aI(e){return 9472<=e&&e<=9631}function oI(e){return iI(e)||aI(e)}function lI(){return{css:{canvas:Kd(),cell:Kd()},device:{canvas:Kd(),cell:Kd(),char:{width:0,height:0,left:0,top:0}}}}function Kd(){return{width:0,height:0}}var Xx=class{constructor(e,t,s,n,a,l,c){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=n,this._coreService=a,this._decorationService=l,this._themeService=c,this._workCell=new Xn,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,n,a,l,c,d,f,h,m){let g=[],_=this._characterJoinerService.getJoinedCharacters(t),v=this._themeService.colors,y=e.getNoBgTrimmedLength();s&&y<l+1&&(y=l+1);let S,j=0,k="",N=0,E=0,B=0,F=0,$=!1,K=0,Y=!1,W=0,L=0,Q=[],V=h!==-1&&m!==-1;for(let X=0;X<y;X++){e.loadCell(X,this._workCell);let q=this._workCell.getWidth();if(q===0)continue;let A=!1,M=X>=L,O=X,U=this._workCell;if(_.length>0&&X===_[0][0]&&M){let Pe=_.shift(),ye=this._isCellInSelection(Pe[0],t);for(N=Pe[0]+1;N<Pe[1];N++)M&&(M=ye===this._isCellInSelection(N,t));M&&(M=!s||l<Pe[0]||l>=Pe[1]),M?(A=!0,U=new rI(this._workCell,e.translateToString(!0,Pe[0],Pe[1]),Pe[1]-Pe[0]),O=Pe[1]-1,q=U.getWidth()):L=Pe[1]}let I=this._isCellInSelection(X,t),R=s&&X===l,P=V&&X>=h&&X<=m,z=!1;this._decorationService.forEachDecorationAtCell(X,t,void 0,Pe=>{z=!0});let T=U.getChars()||Vi;if(T===" "&&(U.isUnderline()||U.isOverline())&&(T=" "),W=q*d-f.get(T,U.isBold(),U.isItalic()),!S)S=this._document.createElement("span");else if(j&&(I&&Y||!I&&!Y&&U.bg===E)&&(I&&Y&&v.selectionForeground||U.fg===B)&&U.extended.ext===F&&P===$&&W===K&&!R&&!A&&!z&&M){U.isInvisible()?k+=Vi:k+=T,j++;continue}else j&&(S.textContent=k),S=this._document.createElement("span"),j=0,k="";if(E=U.bg,B=U.fg,F=U.extended.ext,$=P,K=W,Y=I,A&&l>=X&&l<=O&&(l=X),!this._coreService.isCursorHidden&&R&&this._coreService.isCursorInitialized){if(Q.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&Q.push("xterm-cursor-blink"),Q.push(n==="bar"?"xterm-cursor-bar":n==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":Q.push("xterm-cursor-outline");break;case"block":Q.push("xterm-cursor-block");break;case"bar":Q.push("xterm-cursor-bar");break;case"underline":Q.push("xterm-cursor-underline");break}}if(U.isBold()&&Q.push("xterm-bold"),U.isItalic()&&Q.push("xterm-italic"),U.isDim()&&Q.push("xterm-dim"),U.isInvisible()?k=Vi:k=U.getChars()||Vi,U.isUnderline()&&(Q.push(`xterm-underline-${U.extended.underlineStyle}`),k===" "&&(k=" "),!U.isUnderlineColorDefault()))if(U.isUnderlineColorRGB())S.style.textDecorationColor=`rgb(${fu.toColorRGB(U.getUnderlineColor()).join(",")})`;else{let Pe=U.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&U.isBold()&&Pe<8&&(Pe+=8),S.style.textDecorationColor=v.ansi[Pe].css}U.isOverline()&&(Q.push("xterm-overline"),k===" "&&(k=" ")),U.isStrikethrough()&&Q.push("xterm-strikethrough"),P&&(S.style.textDecoration="underline");let oe=U.getFgColor(),be=U.getFgColorMode(),re=U.getBgColor(),ve=U.getBgColorMode(),Te=!!U.isInverse();if(Te){let Pe=oe;oe=re,re=Pe;let ye=be;be=ve,ve=ye}let Re,je,Ye=!1;this._decorationService.forEachDecorationAtCell(X,t,void 0,Pe=>{Pe.options.layer!=="top"&&Ye||(Pe.backgroundColorRGB&&(ve=50331648,re=Pe.backgroundColorRGB.rgba>>8&16777215,Re=Pe.backgroundColorRGB),Pe.foregroundColorRGB&&(be=50331648,oe=Pe.foregroundColorRGB.rgba>>8&16777215,je=Pe.foregroundColorRGB),Ye=Pe.options.layer==="top")}),!Ye&&I&&(Re=this._coreBrowserService.isFocused?v.selectionBackgroundOpaque:v.selectionInactiveBackgroundOpaque,re=Re.rgba>>8&16777215,ve=50331648,Ye=!0,v.selectionForeground&&(be=50331648,oe=v.selectionForeground.rgba>>8&16777215,je=v.selectionForeground)),Ye&&Q.push("xterm-decoration-top");let Xe;switch(ve){case 16777216:case 33554432:Xe=v.ansi[re],Q.push(`xterm-bg-${re}`);break;case 50331648:Xe=fs.toColor(re>>16,re>>8&255,re&255),this._addStyle(S,`background-color:#${E2((re>>>0).toString(16),"0",6)}`);break;case 0:default:Te?(Xe=v.foreground,Q.push("xterm-bg-257")):Xe=v.background}switch(Re||U.isDim()&&(Re=$t.multiplyOpacity(Xe,.5)),be){case 16777216:case 33554432:U.isBold()&&oe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(oe+=8),this._applyMinimumContrast(S,Xe,v.ansi[oe],U,Re,void 0)||Q.push(`xterm-fg-${oe}`);break;case 50331648:let Pe=fs.toColor(oe>>16&255,oe>>8&255,oe&255);this._applyMinimumContrast(S,Xe,Pe,U,Re,je)||this._addStyle(S,`color:#${E2(oe.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(S,Xe,v.foreground,U,Re,je)||Te&&Q.push("xterm-fg-257")}Q.length&&(S.className=Q.join(" "),Q.length=0),!R&&!A&&!z&&M?j++:S.textContent=k,W!==this.defaultSpacing&&(S.style.letterSpacing=`${W}px`),g.push(S),X=O}return S&&j&&(S.textContent=k),g}_applyMinimumContrast(e,t,s,n,a,l){if(this._optionsService.rawOptions.minimumContrastRatio===1||oI(n.getCode()))return!1;let c=this._getContrastCache(n),d;if(!a&&!l&&(d=c.getColor(t.rgba,s.rgba)),d===void 0){let f=this._optionsService.rawOptions.minimumContrastRatio/(n.isDim()?2:1);d=$t.ensureContrastRatio(a||t,l||s,f),c.setColor((a||t).rgba,(l||s).rgba,d??null)}return d?(this._addStyle(e,`color:${d.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,n=this._selectionEnd;return!s||!n?!1:this._columnSelectMode?s[0]<=n[0]?e>=s[0]&&t>=s[1]&&e<n[0]&&t<=n[1]:e<s[0]&&t>=s[1]&&e>=n[0]&&t<=n[1]:t>s[1]&&t<n[1]||s[1]===n[1]&&t===s[1]&&e>=s[0]&&e<n[0]||s[1]<n[1]&&t===n[1]&&e<n[0]||s[1]<n[1]&&t===s[1]&&e>=s[0]}};Xx=es([Ae(1,FC),Ae(2,nn),Ae(3,ii),Ae(4,Ba),Ae(5,pu),Ae(6,tl)],Xx);function E2(e,t,s){for(;e.length<s;)e=t+e;return e}var cI=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontStyle="italic";let l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontWeight="bold",l.style.fontStyle="italic",this._measureElements=[s,n,a,l],this._container.appendChild(s),this._container.appendChild(n),this._container.appendChild(a),this._container.appendChild(l),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,s,n){e===this._font&&t===this._fontSize&&s===this._weight&&n===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=n,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${n}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${n}`,this.clear())}get(e,t,s){let n=0;if(!t&&!s&&e.length===1&&(n=e.charCodeAt(0))<256){if(this._flat[n]!==-9999)return this._flat[n];let c=this._measure(e,0);return c>0&&(this._flat[n]=c),c}let a=e;t&&(a+="B"),s&&(a+="I");let l=this._holey.get(a);if(l===void 0){let c=0;t&&(c|=1),s&&(c|=2),l=this._measure(e,c),l>0&&this._holey.set(a,l)}return l}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},uI=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,n=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let a=e.buffers.active.ydisp,l=t[1]-a,c=s[1]-a,d=Math.max(l,0),f=Math.min(c,e.rows-1);if(d>=e.rows||f<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=n,this.viewportStartRow=l,this.viewportEndRow=c,this.viewportCappedStartRow=d,this.viewportCappedEndRow=f,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function dI(){return new uI}var _g="xterm-dom-renderer-owner-",Vn="xterm-rows",Yd="xterm-fg-",M2="xterm-bg-",hc="xterm-focus",Xd="xterm-selection",hI=1,Jx=class extends nt{constructor(e,t,s,n,a,l,c,d,f,h,m,g,_,v){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=n,this._viewportElement=a,this._helperContainer=l,this._linkifier2=c,this._charSizeService=f,this._optionsService=h,this._bufferService=m,this._coreService=g,this._coreBrowserService=_,this._themeService=v,this._terminalClass=hI++,this._rowElements=[],this._selectionRenderModel=dI(),this.onRequestRedraw=this._register(new ke).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Vn),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Xd),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=lI(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(y=>this._injectCss(y))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(Xx,document),this._element.classList.add(_g+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(y=>this._handleLinkHover(y))),this._register(this._linkifier2.onHideLinkUnderline(y=>this._handleLinkLeave(y))),this._register(Ut(()=>{this._element.classList.remove(_g+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new cI(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Vn} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Vn} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Vn} .xterm-dim { color: ${$t.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,n=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${n} { 50% { box-shadow: none; }}`,t+=`@keyframes ${a} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Vn}.${hc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Vn}.${hc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Vn}.${hc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Xd} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Xd} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Xd} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[l,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Yd}${l} { color: ${c.css}; }${this._terminalSelector} .${Yd}${l}.xterm-dim { color: ${$t.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${M2}${l} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Yd}257 { color: ${$t.opaque(e.background).css}; }${this._terminalSelector} .${Yd}257.xterm-dim { color: ${$t.multiplyOpacity($t.opaque(e.background),.5).css}; }${this._terminalSelector} .${M2}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let n=this._document.createElement("div");this._rowContainer.appendChild(n),this._rowElements.push(n)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(hc),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(hc),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let n=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,l=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(s){let f=e[0]>t[0];d.appendChild(this._createSelectionElement(l,f?t[0]:e[0],f?e[0]:t[0],c-l+1))}else{let f=n===l?e[0]:0,h=l===a?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(l,f,h));let m=c-l-1;if(d.appendChild(this._createSelectionElement(l+1,0,this._bufferService.cols,m)),l!==c){let g=a===c?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(c,0,g))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,s,n=1){let a=this._document.createElement("div"),l=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(s-t);return l+c>this.dimensions.css.canvas.width&&(c=this.dimensions.css.canvas.width-l),a.style.height=`${n*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${l}px`,a.style.width=`${c}px`,a}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,n=s.ybase+s.y,a=Math.min(s.x,this._bufferService.cols-1),l=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=e;f<=t;f++){let h=f+s.ydisp,m=this._rowElements[f],g=s.lines.get(h);if(!m||!g)break;m.replaceChildren(...this._rowFactory.createRow(g,h,h===n,c,d,a,l,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${_g}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,n,a,l){s<0&&(e=0),n<0&&(t=0);let c=this._bufferService.rows-1;s=Math.max(Math.min(s,c),0),n=Math.max(Math.min(n,c),0),a=Math.min(a,this._bufferService.cols);let d=this._bufferService.buffer,f=d.ybase+d.y,h=Math.min(d.x,a-1),m=this._optionsService.rawOptions.cursorBlink,g=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let v=s;v<=n;++v){let y=v+d.ydisp,S=this._rowElements[v],j=d.lines.get(y);if(!S||!j)break;S.replaceChildren(...this._rowFactory.createRow(j,y,y===f,g,_,h,m,this.dimensions.css.cell.width,this._widthCache,l?v===s?e:0:-1,l?(v===n?t:a)-1:-1))}}};Jx=es([Ae(7,sv),Ae(8,Qh),Ae(9,nn),Ae(10,sn),Ae(11,Ba),Ae(12,ii),Ae(13,tl)],Jx);var Qx=class extends nt{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ke),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new pI(this._optionsService))}catch{this._measureStrategy=this._register(new fI(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Qx=es([Ae(2,nn)],Qx);var aN=class extends nt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},fI=class extends aN{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},pI=class extends aN{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},mI=class extends nt{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new gI(this._window)),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ke),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(n=>this._screenDprMonitor.setWindow(n))),this._register(Is.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ge(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ge(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},gI=class extends nt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Yo),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Ut(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ge(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},xI=class extends nt{constructor(){super(),this.linkProviders=[],this._register(Ut(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function uv(e,t,s){let n=s.getBoundingClientRect(),a=e.getComputedStyle(s),l=parseInt(a.getPropertyValue("padding-left")),c=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-n.left-l,t.clientY-n.top-c]}function vI(e,t,s,n,a,l,c,d,f){if(!l)return;let h=uv(e,t,s);if(h)return h[0]=Math.ceil((h[0]+(f?c/2:0))/c),h[1]=Math.ceil(h[1]/d),h[0]=Math.min(Math.max(h[0],1),n+(f?1:0)),h[1]=Math.min(Math.max(h[1],1),a),h}var Zx=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,n,a){return vI(window,e,t,s,n,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,t){let s=uv(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Zx=es([Ae(0,ai),Ae(1,Qh)],Zx);var bI=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},oN={};M9(oN,{getSafariVersion:()=>yI,isChromeOS:()=>dN,isFirefox:()=>lN,isIpad:()=>wI,isIphone:()=>SI,isLegacyEdge:()=>_I,isLinux:()=>dv,isMac:()=>Oh,isNode:()=>Zh,isSafari:()=>cN,isWindows:()=>uN});var Zh=typeof process<"u"&&"title"in process,mu=Zh?"node":navigator.userAgent,gu=Zh?"node":navigator.platform,lN=mu.includes("Firefox"),_I=mu.includes("Edge"),cN=/^((?!chrome|android).)*safari/i.test(mu);function yI(){if(!cN)return 0;let e=mu.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Oh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(gu),wI=gu==="iPad",SI=gu==="iPhone",uN=["Windows","Win16","Win32","WinCE"].includes(gu),dv=gu.indexOf("Linux")>=0,dN=/\bCrOS\b/.test(mu),hN=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,s=0,n=e.timeRemaining(),a=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),a=e.timeRemaining(),s*1.5>a){n-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-t))}ms`),this._start();return}n=a}this.clear()}},jI=class extends hN{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},kI=class extends hN{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},zh=!Zh&&"requestIdleCallback"in window?kI:jI,CI=class{constructor(){this._queue=new zh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},e0=class extends nt{constructor(e,t,s,n,a,l,c,d,f){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=n,this._coreService=a,this._coreBrowserService=d,this._renderer=this._register(new Yo),this._pausedResizeTask=new CI,this._observerDisposable=this._register(new Yo),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new ke),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ke),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ke),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new bI((h,m)=>this._renderRows(h,m),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new NI(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Ut(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(l.onDecorationRegistered(()=>this._fullRefresh())),this._register(l.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(c.cols,c.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(c.buffer.y,c.buffer.y,!0))),this._register(f.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(n=>this._handleIntersectionChange(n[n.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=Ut(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let n=this._syncOutputHandler.flush();n&&(e=Math.min(e,n.start),t=Math.max(t,n.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var n;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(n=this._renderer.value)==null||n.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};e0=es([Ae(2,nn),Ae(3,Qh),Ae(4,Ba),Ae(5,pu),Ae(6,sn),Ae(7,ii),Ae(8,tl)],e0);var NI=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function EI(e,t,s,n){let a=s.buffer.x,l=s.buffer.y;if(!s.buffer.hasScrollback)return AI(a,l,e,t,s,n)+ef(l,t,s,n)+RI(a,l,e,t,s,n);let c;if(l===t)return c=a>e?"D":"C",eu(Math.abs(a-e),Zc(c,n));c=l>t?"D":"C";let d=Math.abs(l-t),f=TI(l>t?e:a,s)+(d-1)*s.cols+1+MI(l>t?a:e);return eu(f,Zc(c,n))}function MI(e,t){return e-1}function TI(e,t){return t.cols-e}function AI(e,t,s,n,a,l){return ef(t,n,a,l).length===0?"":eu(pN(e,t,e,t-Da(t,a),!1,a).length,Zc("D",l))}function ef(e,t,s,n){let a=e-Da(e,s),l=t-Da(t,s),c=Math.abs(a-l)-DI(e,t,s);return eu(c,Zc(fN(e,t),n))}function RI(e,t,s,n,a,l){let c;ef(t,n,a,l).length>0?c=n-Da(n,a):c=t;let d=n,f=LI(e,t,s,n,a,l);return eu(pN(e,c,s,d,f==="C",a).length,Zc(f,l))}function DI(e,t,s){var c;let n=0,a=e-Da(e,s),l=t-Da(t,s);for(let d=0;d<Math.abs(a-l);d++){let f=fN(e,t)==="A"?-1:1;(c=s.buffer.lines.get(a+f*d))!=null&&c.isWrapped&&n++}return n}function Da(e,t){let s=0,n=t.buffer.lines.get(e),a=n==null?void 0:n.isWrapped;for(;a&&e>=0&&e<t.rows;)s++,n=t.buffer.lines.get(--e),a=n==null?void 0:n.isWrapped;return s}function LI(e,t,s,n,a,l){let c;return ef(s,n,a,l).length>0?c=n-Da(n,a):c=t,e<s&&c<=n||e>=s&&c<n?"C":"D"}function fN(e,t){return e>t?"A":"B"}function pN(e,t,s,n,a,l){let c=e,d=t,f="";for(;(c!==s||d!==n)&&d>=0&&d<l.buffer.lines.length;)c+=a?1:-1,a&&c>l.cols-1?(f+=l.buffer.translateBufferLineToString(d,!1,e,c),c=0,e=0,d++):!a&&c<0&&(f+=l.buffer.translateBufferLineToString(d,!1,0,e+1),c=l.cols-1,e=c,d--);return f+l.buffer.translateBufferLineToString(d,!1,e,c)}function Zc(e,t){let s=t?"O":"[";return xe.ESC+s+e}function eu(e,t){e=Math.floor(e);let s="";for(let n=0;n<e;n++)s+=t;return s}var BI=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function T2(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var yg=50,OI=15,zI=50,PI=500,$I=" ",II=new RegExp($I,"g"),t0=class extends nt{constructor(e,t,s,n,a,l,c,d,f){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=n,this._coreService=a,this._mouseService=l,this._optionsService=c,this._renderService=d,this._coreBrowserService=f,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Xn,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ke),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ke),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new BI(this._bufferService),this._activeSelectionMode=0,this._register(Ut(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,n=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let a=e[0]<t[0]?e[0]:t[0],l=e[0]<t[0]?t[0]:e[0];for(let c=e[1];c<=t[1];c++){let d=s.translateBufferLineToString(c,!0,a,l);n.push(d)}}else{let a=e[1]===t[1]?t[0]:void 0;n.push(s.translateBufferLineToString(e[1],!0,e[0],a));for(let l=e[1]+1;l<=t[1]-1;l++){let c=s.lines.get(l),d=s.translateBufferLineToString(l,!0);c!=null&&c.isWrapped?n[n.length-1]+=d:n.push(d)}if(e[1]!==t[1]){let l=s.lines.get(t[1]),c=s.translateBufferLineToString(t[1],!0,0,t[0]);l&&l.isWrapped?n[n.length-1]+=c:n.push(c)}}return n.map(a=>a.replace(II," ")).join(uN?`\r
255
+ `:`
256
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),dv&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!s||!n||!t?!1:this._areCoordsInSelection(t,s,n)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!s||!n?!1:this._areCoordsInSelection([e,t],s,n)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var a,l;let s=(l=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:l.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=T2(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(e);return n?(this._selectWordAt(n,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=uv(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-yg),yg),t/=yg,t/Math.abs(t)+Math.round(t*(OI-1)))}shouldForceSelection(e){return Oh?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),zI)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Oh&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let n=s.lines.get(this._model.selectionEnd[1]);n&&n.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<PI&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let n=EI(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(n,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let n=0;t>=n;n++){let a=e.loadCell(n,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:a>1&&t!==n&&(s+=a-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,n=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,l=a.lines.get(e[1]);if(!l)return;let c=a.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(l,e[0]),f=d,h=e[0]-d,m=0,g=0,_=0,v=0;if(c.charAt(d)===" "){for(;d>0&&c.charAt(d-1)===" ";)d--;for(;f<c.length&&c.charAt(f+1)===" ";)f++}else{let j=e[0],k=e[0];l.getWidth(j)===0&&(m++,j--),l.getWidth(k)===2&&(g++,k++);let N=l.getString(k).length;for(N>1&&(v+=N-1,f+=N-1);j>0&&d>0&&!this._isCharWordSeparator(l.loadCell(j-1,this._workCell));){l.loadCell(j-1,this._workCell);let E=this._workCell.getChars().length;this._workCell.getWidth()===0?(m++,j--):E>1&&(_+=E-1,d-=E-1),d--,j--}for(;k<l.length&&f+1<c.length&&!this._isCharWordSeparator(l.loadCell(k+1,this._workCell));){l.loadCell(k+1,this._workCell);let E=this._workCell.getChars().length;this._workCell.getWidth()===2?(g++,k++):E>1&&(v+=E-1,f+=E-1),f++,k++}}f++;let y=d+h-m+_,S=Math.min(this._bufferService.cols,f-d+m+g-_-v);if(!(!t&&c.slice(d,f).trim()==="")){if(s&&y===0&&l.getCodePoint(0)!==32){let j=a.lines.get(e[1]-1);if(j&&l.isWrapped&&j.getCodePoint(this._bufferService.cols-1)!==32){let k=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(k){let N=this._bufferService.cols-k.start;y-=N,S+=N}}}if(n&&y+S===this._bufferService.cols&&l.getCodePoint(this._bufferService.cols-1)!==32){let j=a.lines.get(e[1]+1);if(j!=null&&j.isWrapped&&j.getCodePoint(0)!==32){let k=this._getWordAt([0,e[1]+1],!1,!1,!0);k&&(S+=k.length)}}return{start:y,length:S}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=T2(s,this._bufferService.cols)}};t0=es([Ae(3,sn),Ae(4,Ba),Ae(5,nv),Ae(6,nn),Ae(7,ai),Ae(8,ii)],t0);var A2=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},R2=class{constructor(){this._color=new A2,this._css=new A2}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},bs=Object.freeze((()=>{let e=[Wt.toColor("#2e3436"),Wt.toColor("#cc0000"),Wt.toColor("#4e9a06"),Wt.toColor("#c4a000"),Wt.toColor("#3465a4"),Wt.toColor("#75507b"),Wt.toColor("#06989a"),Wt.toColor("#d3d7cf"),Wt.toColor("#555753"),Wt.toColor("#ef2929"),Wt.toColor("#8ae234"),Wt.toColor("#fce94f"),Wt.toColor("#729fcf"),Wt.toColor("#ad7fa8"),Wt.toColor("#34e2e2"),Wt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let n=t[s/36%6|0],a=t[s/6%6|0],l=t[s%6];e.push({css:fs.toCss(n,a,l),rgba:fs.toRgba(n,a,l)})}for(let s=0;s<24;s++){let n=8+s*10;e.push({css:fs.toCss(n,n,n),rgba:fs.toRgba(n,n,n)})}return e})()),wa=Wt.toColor("#ffffff"),Mc=Wt.toColor("#000000"),D2=Wt.toColor("#ffffff"),L2=Mc,fc={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},FI=wa,s0=class extends nt{constructor(e){super(),this._optionsService=e,this._contrastCache=new R2,this._halfContrastCache=new R2,this._onChangeColors=this._register(new ke),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:wa,background:Mc,cursor:D2,cursorAccent:L2,selectionForeground:void 0,selectionBackgroundTransparent:fc,selectionBackgroundOpaque:$t.blend(Mc,fc),selectionInactiveBackgroundTransparent:fc,selectionInactiveBackgroundOpaque:$t.blend(Mc,fc),scrollbarSliderBackground:$t.opacity(wa,.2),scrollbarSliderHoverBackground:$t.opacity(wa,.4),scrollbarSliderActiveBackground:$t.opacity(wa,.5),overviewRulerBorder:wa,ansi:bs.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Et(e.foreground,wa),t.background=Et(e.background,Mc),t.cursor=$t.blend(t.background,Et(e.cursor,D2)),t.cursorAccent=$t.blend(t.background,Et(e.cursorAccent,L2)),t.selectionBackgroundTransparent=Et(e.selectionBackground,fc),t.selectionBackgroundOpaque=$t.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Et(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=$t.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Et(e.selectionForeground,N2):void 0,t.selectionForeground===N2&&(t.selectionForeground=void 0),$t.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=$t.opacity(t.selectionBackgroundTransparent,.3)),$t.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=$t.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Et(e.scrollbarSliderBackground,$t.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Et(e.scrollbarSliderHoverBackground,$t.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Et(e.scrollbarSliderActiveBackground,$t.opacity(t.foreground,.5)),t.overviewRulerBorder=Et(e.overviewRulerBorder,FI),t.ansi=bs.slice(),t.ansi[0]=Et(e.black,bs[0]),t.ansi[1]=Et(e.red,bs[1]),t.ansi[2]=Et(e.green,bs[2]),t.ansi[3]=Et(e.yellow,bs[3]),t.ansi[4]=Et(e.blue,bs[4]),t.ansi[5]=Et(e.magenta,bs[5]),t.ansi[6]=Et(e.cyan,bs[6]),t.ansi[7]=Et(e.white,bs[7]),t.ansi[8]=Et(e.brightBlack,bs[8]),t.ansi[9]=Et(e.brightRed,bs[9]),t.ansi[10]=Et(e.brightGreen,bs[10]),t.ansi[11]=Et(e.brightYellow,bs[11]),t.ansi[12]=Et(e.brightBlue,bs[12]),t.ansi[13]=Et(e.brightMagenta,bs[13]),t.ansi[14]=Et(e.brightCyan,bs[14]),t.ansi[15]=Et(e.brightWhite,bs[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let n=0;n<s;n++)t.ansi[n+16]=Et(e.extendedAnsi[n],bs[n+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};s0=es([Ae(0,nn)],s0);function Et(e,t){if(e!==void 0)try{return Wt.toColor(e)}catch{}return t}var HI=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},UI=class{constructor(){this._services=new HI,this._services.set(sv,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=O9(e).sort((l,c)=>l.index-c.index),n=[];for(let l of s){let c=this._services.get(l.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${l.id._id}.`);n.push(c)}let a=s.length>0?s[0].index:t.length;if(t.length!==a)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...n)}},VI={trace:0,debug:1,info:2,warn:3,error:4,off:5},WI="xterm.js: ",n0=class extends nt{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=VI[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":WI)+t,...s)}trace(e,...t){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,t)}};n0=es([Ae(0,nn)],n0);var B2=class extends nt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ke),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ke),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ke),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...s){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let n=this._length-1;n>=e;n--)this._array[this._getCyclicIndex(n+s.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<s.length;n++)this._array[this._getCyclicIndex(e+n)]=s[n];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let n=this._length+s.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let a=t-1;a>=0;a--)this.set(e+a+s,this.get(e+a));let n=e+t+s-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<t;n++)this.set(e+n+s,this.get(e+n))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},st=3,hs=Object.freeze(new fu),Jd=0,wg=2,Tc=class mN{constructor(t,s,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*st);let a=s||Xn.fromCharData([0,LC,1,0]);for(let l=0;l<t;++l)this.setCell(l,a);this.length=t}get(t){let s=this._data[t*st+0],n=s&2097151;return[this._data[t*st+1],s&2097152?this._combined[t]:n?Fi(n):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n]}set(t,s){this._data[t*st+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*st+0]=t|2097152|s[2]<<22):this._data[t*st+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*st+0]>>22}hasWidth(t){return this._data[t*st+0]&12582912}getFg(t){return this._data[t*st+1]}getBg(t){return this._data[t*st+2]}hasContent(t){return this._data[t*st+0]&4194303}getCodePoint(t){let s=this._data[t*st+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*st+0]&2097152}getString(t){let s=this._data[t*st+0];return s&2097152?this._combined[t]:s&2097151?Fi(s&2097151):""}isProtected(t){return this._data[t*st+2]&536870912}loadCell(t,s){return Jd=t*st,s.content=this._data[Jd+0],s.fg=this._data[Jd+1],s.bg=this._data[Jd+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*st+0]=s.content,this._data[t*st+1]=s.fg,this._data[t*st+2]=s.bg}setCellFromCodepoint(t,s,n,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*st+0]=s|n<<22,this._data[t*st+1]=a.fg,this._data[t*st+2]=a.bg}addCodepointToCell(t,s,n){let a=this._data[t*st+0];a&2097152?this._combined[t]+=Fi(s):a&2097151?(this._combined[t]=Fi(a&2097151)+Fi(s),a&=-2097152,a|=2097152):a=s|1<<22,n&&(a&=-12582913,a|=n<<22),this._data[t*st+0]=a}insertCells(t,s,n){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),s<this.length-t){let a=new Xn;for(let l=this.length-t-s-1;l>=0;--l)this.setCell(t+s+l,this.loadCell(t+l,a));for(let l=0;l<s;++l)this.setCell(t+l,n)}else for(let a=t;a<this.length;++a)this.setCell(a,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(t,s,n){if(t%=this.length,s<this.length-t){let a=new Xn;for(let l=0;l<this.length-t-s;++l)this.setCell(t+l,this.loadCell(t+s+l,a));for(let l=this.length-s;l<this.length;++l)this.setCell(l,n)}else for(let a=t;a<this.length;++a)this.setCell(a,n);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,n)}replaceCells(t,s,n,a=!1){if(a){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,n),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,n);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,n),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,n);t<s&&t<this.length;)this.setCell(t++,n)}resize(t,s){if(t===this.length)return this._data.length*4*wg<this._data.buffer.byteLength;let n=t*st;if(t>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let a=new Uint32Array(n);a.set(this._data),this._data=a}for(let a=this.length;a<t;++a)this.setCell(a,s)}else{this._data=this._data.subarray(0,n);let a=Object.keys(this._combined);for(let c=0;c<a.length;c++){let d=parseInt(a[c],10);d>=t&&delete this._combined[d]}let l=Object.keys(this._extendedAttrs);for(let c=0;c<l.length;c++){let d=parseInt(l[c],10);d>=t&&delete this._extendedAttrs[d]}}return this.length=t,n*4*wg<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*wg<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let n=0;n<this.length;++n)this.isProtected(n)||this.setCell(n,t);return}this._combined={},this._extendedAttrs={};for(let n=0;n<this.length;++n)this.setCell(n,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new mN(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*st+0]&4194303)return t+(this._data[t*st+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*st+0]&4194303||this._data[t*st+2]&50331648)return t+(this._data[t*st+0]>>22);return 0}copyCellsFrom(t,s,n,a,l){let c=t._data;if(l)for(let f=a-1;f>=0;f--){for(let h=0;h<st;h++)this._data[(n+f)*st+h]=c[(s+f)*st+h];c[(s+f)*st+2]&268435456&&(this._extendedAttrs[n+f]=t._extendedAttrs[s+f])}else for(let f=0;f<a;f++){for(let h=0;h<st;h++)this._data[(n+f)*st+h]=c[(s+f)*st+h];c[(s+f)*st+2]&268435456&&(this._extendedAttrs[n+f]=t._extendedAttrs[s+f])}let d=Object.keys(t._combined);for(let f=0;f<d.length;f++){let h=parseInt(d[f],10);h>=s&&(this._combined[h-s+n]=t._combined[h])}}translateToString(t,s,n,a){s=s??0,n=n??this.length,t&&(n=Math.min(n,this.getTrimmedLength())),a&&(a.length=0);let l="";for(;s<n;){let c=this._data[s*st+0],d=c&2097151,f=c&2097152?this._combined[s]:d?Fi(d):Vi;if(l+=f,a)for(let h=0;h<f.length;++h)a.push(s);s+=c>>22||1}return a&&a.push(s),l}};function qI(e,t,s,n,a,l){let c=[];for(let d=0;d<e.length-1;d++){let f=d,h=e.get(++f);if(!h.isWrapped)continue;let m=[e.get(d)];for(;f<e.length&&h.isWrapped;)m.push(h),h=e.get(++f);if(!l&&n>=d&&n<f){d+=m.length-1;continue}let g=0,_=tu(m,g,t),v=1,y=0;for(;v<m.length;){let j=tu(m,v,t),k=j-y,N=s-_,E=Math.min(k,N);m[g].copyCellsFrom(m[v],y,_,E,!1),_+=E,_===s&&(g++,_=0),y+=E,y===j&&(v++,y=0),_===0&&g!==0&&m[g-1].getWidth(s-1)===2&&(m[g].copyCellsFrom(m[g-1],s-1,_++,1,!1),m[g-1].setCell(s-1,a))}m[g].replaceCells(_,s,a);let S=0;for(let j=m.length-1;j>0&&(j>g||m[j].getTrimmedLength()===0);j--)S++;S>0&&(c.push(d+m.length-S),c.push(S)),d+=m.length-1}return c}function GI(e,t){let s=[],n=0,a=t[n],l=0;for(let c=0;c<e.length;c++)if(a===c){let d=t[++n];e.onDeleteEmitter.fire({index:c-l,amount:d}),c+=d-1,l+=d,a=t[++n]}else s.push(c);return{layout:s,countRemoved:l}}function KI(e,t){let s=[];for(let n=0;n<t.length;n++)s.push(e.get(t[n]));for(let n=0;n<s.length;n++)e.set(n,s[n]);e.length=t.length}function YI(e,t,s){let n=[],a=e.map((f,h)=>tu(e,h,t)).reduce((f,h)=>f+h),l=0,c=0,d=0;for(;d<a;){if(a-d<s){n.push(a-d);break}l+=s;let f=tu(e,c,t);l>f&&(l-=f,c++);let h=e[c].getWidth(l-1)===2;h&&l--;let m=h?s-1:s;n.push(m),d+=m}return n}function tu(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let n=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,a=e[t+1].getWidth(0)===2;return n&&a?s-1:s}var gN=class xN{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=xN._nextId++,this._onDispose=this.register(new ke),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Ra(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};gN._nextId=1;var XI=gN,Ss={},Sa=Ss.B;Ss[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Ss.A={"#":"£"};Ss.B=void 0;Ss[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ss.C=Ss[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ss.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ss.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ss.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ss.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ss.E=Ss[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ss.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ss.H=Ss[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ss["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var O2=4294967295,z2=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=hs.clone(),this.savedCharset=Sa,this.markers=[],this._nullCell=Xn.fromCharData([0,LC,1,0]),this._whitespaceCell=Xn.fromCharData([0,Vi,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new zh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new B2(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Dh),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Dh),this._whitespaceCell}getBlankLine(e,t){return new Tc(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>O2?O2:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=hs);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new B2(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(hs),n=0,a=this._getCorrectBufferLength(t);if(a>this.lines.maxLength&&(this.lines.maxLength=a),this.lines.length>0){if(this._cols<e)for(let c=0;c<this.lines.length;c++)n+=+this.lines.get(c).resize(e,s);let l=0;if(this._rows<t)for(let c=this._rows;c<t;c++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Tc(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+l+1?(this.ybase--,l++,this.ydisp>0&&this.ydisp--):this.lines.push(new Tc(e,s)));else for(let c=this._rows;c>t;c--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(a<this.lines.maxLength){let c=this.lines.length-a;c>0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=a}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),l&&(this.y+=l),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let l=0;l<this.lines.length;l++)n+=+this.lines.get(l).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),n>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,n=qI(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(hs),s);if(n.length>0){let a=GI(this.lines,n);KI(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let n=this.getNullCell(hs),a=s;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Tc(e,n))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,n=this.getNullCell(hs),a=[],l=0;for(let c=this.lines.length-1;c>=0;c--){let d=this.lines.get(c);if(!d||!d.isWrapped&&d.getTrimmedLength()<=e)continue;let f=[d];for(;d.isWrapped&&c>0;)d=this.lines.get(--c),f.unshift(d);if(!s){let E=this.ybase+this.y;if(E>=c&&E<c+f.length)continue}let h=f[f.length-1].getTrimmedLength(),m=YI(f,this._cols,e),g=m.length-f.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+g):_=Math.max(0,this.lines.length-this.lines.maxLength+g);let v=[];for(let E=0;E<g;E++){let B=this.getBlankLine(hs,!0);v.push(B)}v.length>0&&(a.push({start:c+f.length+l,newLines:v}),l+=v.length),f.push(...v);let y=m.length-1,S=m[y];S===0&&(y--,S=m[y]);let j=f.length-g-1,k=h;for(;j>=0;){let E=Math.min(k,S);if(f[y]===void 0)break;if(f[y].copyCellsFrom(f[j],k-E,S-E,E,!0),S-=E,S===0&&(y--,S=m[y]),k-=E,k===0){j--;let B=Math.max(j,0);k=tu(f,B,this._cols)}}for(let E=0;E<f.length;E++)m[E]<e&&f[E].setCell(m[E],n);let N=g-_;for(;N-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+l)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+g,this.ybase+t-1)}if(a.length>0){let c=[],d=[];for(let S=0;S<this.lines.length;S++)d.push(this.lines.get(S));let f=this.lines.length,h=f-1,m=0,g=a[m];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+l);let _=0;for(let S=Math.min(this.lines.maxLength-1,f+l-1);S>=0;S--)if(g&&g.start>h+_){for(let j=g.newLines.length-1;j>=0;j--)this.lines.set(S--,g.newLines[j]);S++,c.push({index:h+1,amount:g.newLines.length}),_+=g.newLines.length,g=a[++m]}else this.lines.set(S,d[h--]);let v=0;for(let S=c.length-1;S>=0;S--)c[S].index+=v,this.lines.onInsertEmitter.fire(c[S]),v+=c[S].amount;let y=Math.max(0,f+l-this.lines.maxLength);y>0&&this.lines.onTrimEmitter.fire(y)}}translateBufferLineToString(e,t,s=0,n){let a=this.lines.get(e);return a?a.translateToString(t,s,n):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new XI(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},JI=class extends nt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ke),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new z2(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new z2(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},vN=2,bN=1,r0=class extends nt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,vN),this.rows=Math.max(e.rawOptions.rows||0,bN),this.buffers=this._register(new JI(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,n=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,n;n=this._cachedBlankLine,(!n||n.length!==this.cols||n.getFg(0)!==e.fg||n.getBg(0)!==e.bg)&&(n=s.getBlankLine(e,t),this._cachedBlankLine=n),n.isWrapped=t;let a=s.ybase+s.scrollTop,l=s.ybase+s.scrollBottom;if(s.scrollTop===0){let c=s.lines.isFull;l===s.lines.length-1?c?s.lines.recycle().copyFrom(n):s.lines.push(n.clone()):s.lines.splice(l+1,0,n.clone()),c?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let c=l-a+1;s.lines.shiftElements(a+1,c-1,-1),s.lines.set(l,n.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let n=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),n!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};r0=es([Ae(0,nn)],r0);var Mo={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Oh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},QI=["normal","bold","100","200","300","400","500","600","700","800","900"],ZI=class extends nt{constructor(e){super(),this._onOptionChange=this._register(new ke),this.onOptionChange=this._onOptionChange.event;let t={...Mo};for(let s in e)if(s in t)try{let n=e[s];t[s]=this._sanitizeAndValidateOption(s,n)}catch(n){console.error(n)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Ut(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in Mo))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,n)=>{if(!(s in Mo))throw new Error(`No option with key "${s}"`);n=this._sanitizeAndValidateOption(s,n),this.rawOptions[s]!==n&&(this.rawOptions[s]=n,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let n={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,n)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Mo[e]),!eF(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Mo[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=QI.includes(t)?t:Mo[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function eF(e){return e==="block"||e==="underline"||e==="bar"}function Ac(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let n in e)s[n]=t<=1?e[n]:e[n]&&Ac(e[n],t-1);return s}var P2=Object.freeze({insertMode:!1}),$2=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),i0=class extends nt{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ke),this.onData=this._onData.event,this._onUserInput=this._register(new ke),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ke),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Ac(P2),this.decPrivateModes=Ac($2)}reset(){this.modes=Ac(P2),this.decPrivateModes=Ac($2)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(n=>n.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};i0=es([Ae(0,sn),Ae(1,$C),Ae(2,nn)],i0);var I2={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Sg(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var jg=String.fromCharCode,F2={DEFAULT:e=>{let t=[Sg(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${jg(t[0])}${jg(t[1])}${jg(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Sg(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Sg(e,!0)};${e.x};${e.y}${t}`}},a0=class extends nt{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ke),this.onProtocolChange=this._onProtocolChange.event;for(let n of Object.keys(I2))this.addProtocol(n,I2[n]);for(let n of Object.keys(F2))this.addEncoding(n,F2[n]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let n=t/s,a=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(a/=n+0,Math.abs(e.deltaY)<50&&(a*=.3),this._wheelPartialScroll+=a,a=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(a*=this._bufferService.rows),a}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};a0=es([Ae(0,sn),Ae(1,Ba),Ae(2,nn)],a0);var kg=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],tF=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],_s;function sF(e,t){let s=0,n=t.length-1,a;if(e<t[0][0]||e>t[n][1])return!1;for(;n>=s;)if(a=s+n>>1,e>t[a][1])s=a+1;else if(e<t[a][0])n=a-1;else return!0;return!1}var nF=class{constructor(){if(this.version="6",!_s){_s=new Uint8Array(65536),_s.fill(1),_s[0]=0,_s.fill(0,1,32),_s.fill(0,127,160),_s.fill(2,4352,4448),_s[9001]=2,_s[9002]=2,_s.fill(2,11904,42192),_s[12351]=1,_s.fill(2,44032,55204),_s.fill(2,63744,64256),_s.fill(2,65040,65050),_s.fill(2,65072,65136),_s.fill(2,65280,65377),_s.fill(2,65504,65511);for(let e=0;e<kg.length;++e)_s.fill(0,kg[e][0],kg[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?_s[e]:sF(e,tF)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),n=s===0&&t!==0;if(n){let a=ja.extractWidth(t);a===0?n=!1:a>s&&(s=a)}return ja.createPropertyValue(0,s,n)}},ja=class dh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ke,this.onChange=this._onChange.event;let t=new nF;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,n=!1){return(t&16777215)<<3|(s&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,n=0,a=t.length;for(let l=0;l<a;++l){let c=t.charCodeAt(l);if(55296<=c&&c<=56319){if(++l>=a)return s+this.wcwidth(c);let h=t.charCodeAt(l);56320<=h&&h<=57343?c=(c-55296)*1024+h-56320+65536:s+=this.wcwidth(h)}let d=this.charProperties(c,n),f=dh.extractWidth(d);dh.extractShouldJoin(d)&&(f-=dh.extractWidth(n)),s+=f,n=d}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},rF=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function H2(e){var n;let t=(n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:n.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var pc=2147483647,iF=256,_N=class o0{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>iF)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new o0;if(!t.length)return s;for(let n=Array.isArray(t[0])?1:0;n<t.length;++n){let a=t[n];if(Array.isArray(a))for(let l=0;l<a.length;++l)s.addSubParam(a[l]);else s.addParam(a)}return s}clone(){let t=new o0(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let n=this._subParamsIdx[s]>>8,a=this._subParamsIdx[s]&255;a-n>0&&t.push(Array.prototype.slice.call(this._subParams,n,a))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>pc?pc:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>pc?pc:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,n=this._subParamsIdx[t]&255;return n-s>0?this._subParams.subarray(s,n):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let n=this._subParamsIdx[s]>>8,a=this._subParamsIdx[s]&255;a-n>0&&(t[s]=this._subParams.slice(n,a))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,a=n[s-1];n[s-1]=~a?Math.min(a*10+t,pc):t}},mc=[],aF=class{constructor(){this._state=0,this._active=mc,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let n=s.indexOf(t);n!==-1&&s.splice(n,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=mc}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=mc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||mc,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",Jh(e,t,s));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,n=this._active.length-1,a=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&s===!1){for(;n>=0&&(s=this._active[n].end(e),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}this._active=mc,this._id=-1,this._state=0}}},Nn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Jh(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},gc=[],oF=class{constructor(){this._handlers=Object.create(null),this._active=gc,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=gc}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let n=s.indexOf(t);n!==-1&&s.splice(n,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=gc,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||gc,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",Jh(e,t,s));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,n=this._active.length-1,a=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&s===!1){for(;n>=0&&(s=this._active[n].unhook(e),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}this._active=gc,this._ident=0}},Rc=new _N;Rc.addParam(0);var U2=class{constructor(e){this._handler=e,this._data="",this._params=Rc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Rc,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Jh(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=Rc,this._data="",this._hitLimit=!1,s));return this._params=Rc,this._data="",this._hitLimit=!1,t}},lF=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,n){this.table[t<<8|e]=s<<4|n}addMany(e,t,s,n){for(let a=0;a<e.length;a++)this.table[t<<8|e[a]]=s<<4|n}},qn=160,cF=(function(){let e=new lF(4095),t=Array.apply(null,Array(256)).map((d,f)=>f),s=(d,f)=>t.slice(d,f),n=s(32,127),a=s(0,24);a.push(25),a.push.apply(a,s(28,32));let l=s(0,14),c;e.setDefault(1,0),e.addMany(n,0,2,0);for(c in l)e.addMany([24,26,153,154],c,3,0),e.addMany(s(128,144),c,3,0),e.addMany(s(144,152),c,3,0),e.add(156,c,0,0),e.add(27,c,11,1),e.add(157,c,4,8),e.addMany([152,158,159],c,0,7),e.add(155,c,11,3),e.add(144,c,11,9);return e.addMany(a,0,3,0),e.addMany(a,1,3,1),e.add(127,1,0,1),e.addMany(a,8,0,8),e.addMany(a,3,3,3),e.add(127,3,0,3),e.addMany(a,4,3,4),e.add(127,4,0,4),e.addMany(a,6,3,6),e.addMany(a,5,3,5),e.add(127,5,0,5),e.addMany(a,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(n,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(n,7,0,7),e.addMany(a,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(a,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(a,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(a,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(a,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(a,13,13,13),e.addMany(n,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(qn,0,2,0),e.add(qn,8,5,8),e.add(qn,6,0,6),e.add(qn,11,0,11),e.add(qn,13,13,13),e})(),uF=class extends nt{constructor(e=cF){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new _N,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,n)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Ut(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new aF),this._dcsParser=this._register(new oF),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let a=0;a<e.intermediates.length;++a){let l=e.intermediates.charCodeAt(a);if(32>l||l>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=l}}if(e.final.length!==1)throw new Error("final must be a single byte");let n=e.final.charCodeAt(0);if(t[0]>n||n>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=n,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let n=this._escHandlers[s];return n.push(t),{dispose:()=>{let a=n.indexOf(t);a!==-1&&n.splice(a,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let n=this._csiHandlers[s];return n.push(t),{dispose:()=>{let a=n.indexOf(t);a!==-1&&n.splice(a,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,n,a){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=n,this._parseStack.chunkPos=a}parse(e,t,s){let n=0,a=0,l=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,l=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let d=this._parseStack.handlers,f=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&f>-1){for(;f>=0&&(c=d[f](this._params),c!==!0);f--)if(c instanceof Promise)return this._parseStack.handlerPos=f,c}this._parseStack.handlers=[];break;case 4:if(s===!1&&f>-1){for(;f>=0&&(c=d[f](),c!==!0);f--)if(c instanceof Promise)return this._parseStack.handlerPos=f,c}this._parseStack.handlers=[];break;case 6:if(n=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(n!==24&&n!==26,s),c)return c;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=e[this._parseStack.chunkPos],c=this._oscParser.end(n!==24&&n!==26,s),c)return c;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,l=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let d=l;d<t;++d){switch(n=e[d],a=this._transitions.table[this.currentState<<8|(n<160?n:qn)],a>>4){case 2:for(let _=d+1;;++_){if(_>=t||(n=e[_])<32||n>126&&n<qn){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(n=e[_])<32||n>126&&n<qn){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(n=e[_])<32||n>126&&n<qn){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(n=e[_])<32||n>126&&n<qn){this._printHandler(e,d,_),d=_-1;break}}break;case 3:this._executeHandlers[n]?this._executeHandlers[n]():this._executeHandlerFb(n),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:d,code:n,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let f=this._csiHandlers[this._collect<<8|n],h=f?f.length-1:-1;for(;h>=0&&(c=f[h](this._params),c!==!0);h--)if(c instanceof Promise)return this._preserveStack(3,f,h,a,d),c;h<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingJoinState=0;break;case 8:do switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(n-48)}while(++d<t&&(n=e[d])>47&&n<60);d--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:let m=this._escHandlers[this._collect<<8|n],g=m?m.length-1:-1;for(;g>=0&&(c=m[g](),c!==!0);g--)if(c instanceof Promise)return this._preserveStack(4,m,g,a,d),c;g<0&&this._escHandlerFb(this._collect<<8|n),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|n,this._params);break;case 13:for(let _=d+1;;++_)if(_>=t||(n=e[_])===24||n===26||n===27||n>127&&n<qn){this._dcsParser.put(e,d,_),d=_-1;break}break;case 14:if(c=this._dcsParser.unhook(n!==24&&n!==26),c)return this._preserveStack(6,[],0,a,d),c;n===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let _=d+1;;_++)if(_>=t||(n=e[_])<32||n>127&&n<qn){this._oscParser.put(e,d,_),d=_-1;break}break;case 6:if(c=this._oscParser.end(n!==24&&n!==26),c)return this._preserveStack(5,[],0,a,d),c;n===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=a&15}}},dF=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,hF=/^[\da-f]+$/;function V2(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=dF.exec(t);if(s){let n=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/n*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/n*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/n*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),hF.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,n=[0,0,0];for(let a=0;a<3;++a){let l=parseInt(t.slice(s*a,s*a+s),16);n[a]=s===1?l<<4:s===2?l:s===3?l>>4:l>>8}return n}}function Cg(e,t){let s=e.toString(16),n=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return n;case 12:return(n+n).slice(0,3);default:return n+n}}function fF(e,t=16){let[s,n,a]=e;return`rgb:${Cg(s,t)}/${Cg(n,t)}/${Cg(a,t)}`}var pF={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Pi=131072,W2=10;function q2(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var G2=5e3,K2=0,mF=class extends nt{constructor(e,t,s,n,a,l,c,d,f=new uF){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=n,this._optionsService=a,this._oscLinkService=l,this._coreMouseService=c,this._unicodeService=d,this._parser=f,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new L9,this._utf8Decoder=new B9,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=hs.clone(),this._eraseAttrDataInternal=hs.clone(),this._onRequestBell=this._register(new ke),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ke),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ke),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ke),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ke),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ke),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ke),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ke),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ke),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new l0(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,m)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:m.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,m,g)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:m,data:g})}),this._parser.setDcsHandlerFallback((h,m,g)=>{m==="HOOK"&&(g=g.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:m,payload:g})}),this._parser.setPrintHandler((h,m,g)=>this.print(h,m,g)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(xe.BEL,()=>this.bell()),this._parser.setExecuteHandler(xe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(xe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(xe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(xe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(xe.BS,()=>this.backspace()),this._parser.setExecuteHandler(xe.HT,()=>this.tab()),this._parser.setExecuteHandler(xe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(xe.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ch.IND,()=>this.index()),this._parser.setExecuteHandler(ch.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ch.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Nn(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Nn(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Nn(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Nn(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Nn(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Nn(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Nn(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Nn(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Nn(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Nn(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Nn(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Nn(h=>this.restoreCursorColor(h))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let h in Ss)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new U2((h,m)=>this.requestStatusString(h,m)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,n){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=n}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),G2))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${G2} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,n=this._activeBuffer.x,a=this._activeBuffer.y,l=0,c=this._parseStack.paused;if(c){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;n=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Pi&&(l=this._parseStack.position+Pi)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Pi&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Pi))),c||this._dirtyRowTracker.clearRange(),e.length>Pi)for(let h=l;h<e.length;h+=Pi){let m=h+Pi<e.length?h+Pi:e.length,g=typeof e=="string"?this._stringDecoder.decode(e.substring(h,m),this._parseBuffer):this._utf8Decoder.decode(e.subarray(h,m),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,g))return this._preserveStack(n,a,g,h),this._logSlowResolvingAsync(s),s}else if(!c){let h=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,h))return this._preserveStack(n,a,h,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==n||this._activeBuffer.y!==a)&&this._onCursorMove.fire();let d=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),f=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);f<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(f,this._bufferService.rows-1),end:Math.min(d,this._bufferService.rows-1)})}print(e,t,s){let n,a,l=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,f=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,m=this._curAttrData,g=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&g.getWidth(this._activeBuffer.x-1)===2&&g.setCellFromCodepoint(this._activeBuffer.x-1,0,1,m);let _=this._parser.precedingJoinState;for(let v=t;v<s;++v){if(n=e[v],n<127&&l){let k=l[String.fromCharCode(n)];k&&(n=k.charCodeAt(0))}let y=this._unicodeService.charProperties(n,_);a=ja.extractWidth(y);let S=ja.extractShouldJoin(y),j=S?ja.extractWidth(_):0;if(_=y,c&&this._onA11yChar.fire(Fi(n)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+a-j>d){if(f){let k=g,N=this._activeBuffer.x-j;for(this._activeBuffer.x=j,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),g=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),j>0&&g instanceof Tc&&g.copyCellsFrom(k,N,0,j,!1);N<d;)k.setCellFromCodepoint(N++,0,1,m)}else if(this._activeBuffer.x=d-1,a===2)continue}if(S&&this._activeBuffer.x){let k=g.getWidth(this._activeBuffer.x-1)?1:2;g.addCodepointToCell(this._activeBuffer.x-k,n,a);for(let N=a-j;--N>=0;)g.setCellFromCodepoint(this._activeBuffer.x++,0,0,m);continue}if(h&&(g.insertCells(this._activeBuffer.x,a-j,this._activeBuffer.getNullCell(m)),g.getWidth(d-1)===2&&g.setCellFromCodepoint(d-1,0,1,m)),g.setCellFromCodepoint(this._activeBuffer.x++,n,a,m),a>0)for(;--a;)g.setCellFromCodepoint(this._activeBuffer.x++,0,0,m)}this._parser.precedingJoinState=_,this._activeBuffer.x<d&&s-t>0&&g.getWidth(this._activeBuffer.x)===0&&!g.hasContent(this._activeBuffer.x)&&g.setCellFromCodepoint(this._activeBuffer.x,0,1,m),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>q2(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new U2(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Nn(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,n=!1,a=!1){let l=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);l.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),a),n&&(l.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var n;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&n.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let a=this._activeBuffer.lines.length-this._bufferService.rows;a>0&&(this._activeBuffer.lines.trimStart(a),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-a,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-a,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,a=this._bufferService.rows-1+this._activeBuffer.ybase-n+1;for(;t--;)this._activeBuffer.lines.splice(a-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,n;for(n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-n;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(hs));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,n=ja.extractWidth(t),a=this._activeBuffer.x-n,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(a),c=new Uint32Array(l.length*s),d=0;for(let h=0;h<l.length;){let m=l.codePointAt(h)||0;c[d++]=m,h+=m>65535?2:1}let f=d;for(let h=1;h<s;++h)c.copyWithin(f,0,d),f+=d;return this.print(c,0,f),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(xe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(xe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(xe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(xe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(xe.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Sa),this._charsetService.setgCharset(1,Sa),this._charsetService.setgCharset(2,Sa),this._charsetService.setgCharset(3,Sa);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(S=>(S[S.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",S[S.SET=1]="SET",S[S.RESET=2]="RESET",S[S.PERMANENTLY_SET=3]="PERMANENTLY_SET",S[S.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let n=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:l}=this._coreMouseService,c=this._coreService,{buffers:d,cols:f}=this._bufferService,{active:h,alt:m}=d,g=this._optionsService.rawOptions,_=(S,j)=>(c.triggerDataEvent(`${xe.ESC}[${t?"":"?"}${S};${j}$y`),!0),v=S=>S?1:2,y=e.params[0];return t?y===2?_(y,4):y===4?_(y,v(c.modes.insertMode)):y===12?_(y,3):y===20?_(y,v(g.convertEol)):_(y,0):y===1?_(y,v(n.applicationCursorKeys)):y===3?_(y,g.windowOptions.setWinLines?f===80?2:f===132?1:0:0):y===6?_(y,v(n.origin)):y===7?_(y,v(n.wraparound)):y===8?_(y,3):y===9?_(y,v(a==="X10")):y===12?_(y,v(g.cursorBlink)):y===25?_(y,v(!c.isCursorHidden)):y===45?_(y,v(n.reverseWraparound)):y===66?_(y,v(n.applicationKeypad)):y===67?_(y,4):y===1e3?_(y,v(a==="VT200")):y===1002?_(y,v(a==="DRAG")):y===1003?_(y,v(a==="ANY")):y===1004?_(y,v(n.sendFocus)):y===1005?_(y,4):y===1006?_(y,v(l==="SGR")):y===1015?_(y,4):y===1016?_(y,v(l==="SGR_PIXELS")):y===1048?_(y,1):y===47||y===1047||y===1049?_(y,v(h===m)):y===2004?_(y,v(n.bracketedPasteMode)):y===2026?_(y,v(n.synchronizedOutput)):_(y,0)}_updateAttrColor(e,t,s,n,a){return t===2?(e|=50331648,e&=-16777216,e|=fu.fromColorRGB([s,n,a])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let n=[0,0,-1,0,0,0],a=0,l=0;do{if(n[l+a]=e.params[t+l],e.hasSubParams(t+l)){let c=e.getSubParams(t+l),d=0;do n[1]===5&&(a=1),n[l+d+1+a]=c[d];while(++d<c.length&&d+l+1+a<n.length);break}if(n[1]===5&&l+a>=2||n[1]===2&&l+a>=5)break;n[1]&&(a=1)}while(++l+t<e.length&&l+a<n.length);for(let c=2;c<n.length;++c)n[c]===-1&&(n[c]=0);switch(n[0]){case 38:s.fg=this._updateAttrColor(s.fg,n[1],n[3],n[4],n[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,n[1],n[3],n[4],n[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,n[1],n[3],n[4],n[5])}return l}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=hs.fg,e.bg=hs.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,n=this._curAttrData;for(let a=0;a<t;a++)s=e.params[a],s>=30&&s<=37?(n.fg&=-50331904,n.fg|=16777216|s-30):s>=40&&s<=47?(n.bg&=-50331904,n.bg|=16777216|s-40):s>=90&&s<=97?(n.fg&=-50331904,n.fg|=16777216|s-90|8):s>=100&&s<=107?(n.bg&=-50331904,n.bg|=16777216|s-100|8):s===0?this._processSGR0(n):s===1?n.fg|=134217728:s===3?n.bg|=67108864:s===4?(n.fg|=268435456,this._processUnderline(e.hasSubParams(a)?e.getSubParams(a)[0]:1,n)):s===5?n.fg|=536870912:s===7?n.fg|=67108864:s===8?n.fg|=1073741824:s===9?n.fg|=2147483648:s===2?n.bg|=134217728:s===21?this._processUnderline(2,n):s===22?(n.fg&=-134217729,n.bg&=-134217729):s===23?n.bg&=-67108865:s===24?(n.fg&=-268435457,this._processUnderline(0,n)):s===25?n.fg&=-536870913:s===27?n.fg&=-67108865:s===28?n.fg&=-1073741825:s===29?n.fg&=2147483647:s===39?(n.fg&=-67108864,n.fg|=hs.fg&16777215):s===49?(n.bg&=-67108864,n.bg|=hs.bg&16777215):s===38||s===48||s===58?a+=this._extractColor(e,a,n):s===53?n.bg|=1073741824:s===55?n.bg&=-1073741825:s===59?(n.extended=n.extended.clone(),n.extended.underlineColor=-1,n.updateExtended()):s===100?(n.fg&=-67108864,n.fg|=hs.fg&16777215,n.bg&=-67108864,n.bg|=hs.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${xe.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${xe.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${xe.ESC}[?${t};${s}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=hs.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!q2(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${xe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>W2&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>W2&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let n=s.shift(),a=s.shift();if(/^\d+$/.exec(n)){let l=parseInt(n);if(Y2(l))if(a==="?")t.push({type:0,index:l});else{let c=V2(a);c&&t.push({type:1,index:l,color:c})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),n=e.slice(t+1);return n?this._createHyperlink(s,n):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),n,a=s.findIndex(l=>l.startsWith("id="));return a!==-1&&(n=s[a].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:n,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let n=0;n<s.length&&!(t>=this._specialColors.length);++n,++t)if(s[n]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let a=V2(s[n]);a&&this._onColor.fire([{type:1,index:this._specialColors[t],color:a}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let n=0;n<s.length;++n)if(/^\d+$/.exec(s[n])){let a=parseInt(s[n]);Y2(a)&&t.push({type:2,index:a})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Sa),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(pF[e[0]],Ss[e[1]]||Sa),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=hs.clone(),this._eraseAttrDataInternal=hs.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Xn;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,n=this._activeBuffer.lines.get(s);n&&(n.fill(e),n.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=c=>(this._coreService.triggerDataEvent(`${xe.ESC}${c}${xe.ESC}\\`),!0),n=this._bufferService.buffer,a=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[a.cursorStyle]-(a.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},l0=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(K2=e,e=t,t=K2),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};l0=es([Ae(0,sn)],l0);function Y2(e){return 0<=e&&e<256}var gF=5e7,X2=12,xF=50,vF=class extends nt{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new ke),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>gF)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let n=this._writeBuffer[this._bufferOffset],a=this._action(n,t);if(a){let c=d=>performance.now()-s>=X2?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(s,d);a.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(c);return}let l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=n.length,performance.now()-s>=X2)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>xF&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},c0=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let d=t.addMarker(t.ybase+t.y),f={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(f,d)),this._dataByLinkId.set(f.id,f),f.id}let s=e,n=this._getEntryIdKey(s),a=this._entriesWithId.get(n);if(a)return this.addLineToLink(a.id,t.ybase+t.y),a.id;let l=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(c,l)),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(n=>n.line!==t)){let n=this._bufferService.buffer.addMarker(t);s.lines.push(n),n.onDispose(()=>this._removeMarkerFromLink(s,n))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};c0=es([Ae(0,sn)],c0);var J2=!1,bF=class extends nt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Yo),this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onData=this._register(new ke),this.onData=this._onData.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ke),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ke),this._instantiationService=new UI,this.optionsService=this._register(new ZI(e)),this._instantiationService.setService(nn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(r0)),this._instantiationService.setService(sn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(n0)),this._instantiationService.setService($C,this._logService),this.coreService=this._register(this._instantiationService.createInstance(i0)),this._instantiationService.setService(Ba,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(a0)),this._instantiationService.setService(PC,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ja)),this._instantiationService.setService($9,this.unicodeService),this._charsetService=this._instantiationService.createInstance(rF),this._instantiationService.setService(P9,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(c0),this._instantiationService.setService(IC,this._oscLinkService),this._inputHandler=this._register(new mF(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Is.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Is.forward(this._bufferService.onResize,this._onResize)),this._register(Is.forward(this.coreService.onData,this._onData)),this._register(Is.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new vF((t,s)=>this._inputHandler.parse(t,s))),this._register(Is.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ke),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!J2&&(this._logService.warn("writeSync is unreliable and will be removed soon."),J2=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,vN),t=Math.max(t,bN),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(H2.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(H2(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ut(()=>{for(let t of e)t.dispose()})}}},_F={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function yF(e,t,s,n){var c;let a={type:0,cancel:!1,key:void 0},l=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?a.key=xe.ESC+"OA":a.key=xe.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=xe.ESC+"OD":a.key=xe.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=xe.ESC+"OC":a.key=xe.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=xe.ESC+"OB":a.key=xe.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":xe.DEL,e.altKey&&(a.key=xe.ESC+a.key);break;case 9:if(e.shiftKey){a.key=xe.ESC+"[Z";break}a.key=xe.HT,a.cancel=!0;break;case 13:a.key=e.altKey?xe.ESC+xe.CR:xe.CR,a.cancel=!0;break;case 27:a.key=xe.ESC,e.altKey&&(a.key=xe.ESC+xe.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;l?a.key=xe.ESC+"[1;"+(l+1)+"D":t?a.key=xe.ESC+"OD":a.key=xe.ESC+"[D";break;case 39:if(e.metaKey)break;l?a.key=xe.ESC+"[1;"+(l+1)+"C":t?a.key=xe.ESC+"OC":a.key=xe.ESC+"[C";break;case 38:if(e.metaKey)break;l?a.key=xe.ESC+"[1;"+(l+1)+"A":t?a.key=xe.ESC+"OA":a.key=xe.ESC+"[A";break;case 40:if(e.metaKey)break;l?a.key=xe.ESC+"[1;"+(l+1)+"B":t?a.key=xe.ESC+"OB":a.key=xe.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=xe.ESC+"[2~");break;case 46:l?a.key=xe.ESC+"[3;"+(l+1)+"~":a.key=xe.ESC+"[3~";break;case 36:l?a.key=xe.ESC+"[1;"+(l+1)+"H":t?a.key=xe.ESC+"OH":a.key=xe.ESC+"[H";break;case 35:l?a.key=xe.ESC+"[1;"+(l+1)+"F":t?a.key=xe.ESC+"OF":a.key=xe.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=xe.ESC+"[5;"+(l+1)+"~":a.key=xe.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=xe.ESC+"[6;"+(l+1)+"~":a.key=xe.ESC+"[6~";break;case 112:l?a.key=xe.ESC+"[1;"+(l+1)+"P":a.key=xe.ESC+"OP";break;case 113:l?a.key=xe.ESC+"[1;"+(l+1)+"Q":a.key=xe.ESC+"OQ";break;case 114:l?a.key=xe.ESC+"[1;"+(l+1)+"R":a.key=xe.ESC+"OR";break;case 115:l?a.key=xe.ESC+"[1;"+(l+1)+"S":a.key=xe.ESC+"OS";break;case 116:l?a.key=xe.ESC+"[15;"+(l+1)+"~":a.key=xe.ESC+"[15~";break;case 117:l?a.key=xe.ESC+"[17;"+(l+1)+"~":a.key=xe.ESC+"[17~";break;case 118:l?a.key=xe.ESC+"[18;"+(l+1)+"~":a.key=xe.ESC+"[18~";break;case 119:l?a.key=xe.ESC+"[19;"+(l+1)+"~":a.key=xe.ESC+"[19~";break;case 120:l?a.key=xe.ESC+"[20;"+(l+1)+"~":a.key=xe.ESC+"[20~";break;case 121:l?a.key=xe.ESC+"[21;"+(l+1)+"~":a.key=xe.ESC+"[21~";break;case 122:l?a.key=xe.ESC+"[23;"+(l+1)+"~":a.key=xe.ESC+"[23~";break;case 123:l?a.key=xe.ESC+"[24;"+(l+1)+"~":a.key=xe.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?a.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?a.key=xe.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=xe.DEL:e.keyCode===219?a.key=xe.ESC:e.keyCode===220?a.key=xe.FS:e.keyCode===221&&(a.key=xe.GS);else if((!s||n)&&e.altKey&&!e.metaKey){let d=(c=_F[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(d)a.key=xe.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let f=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(f);e.shiftKey&&(h=h.toUpperCase()),a.key=xe.ESC+h}else if(e.keyCode===32)a.key=xe.ESC+(e.ctrlKey?xe.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),a.key=xe.ESC+f,a.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(a.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?a.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(a.key=xe.US),e.key==="@"&&(a.key=xe.NUL));break}return a}var is=0,wF=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new zh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new zh,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((a,l)=>this._getKey(a)-this._getKey(l)),t=0,s=0,n=new Array(this._array.length+this._insertedValues.length);for(let a=0;a<n.length;a++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(n[a]=e[t],t++):n[a]=this._array[s++];this._array=n,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(is=this._search(t),is===-1)||this._getKey(this._array[is])!==t)return!1;do if(this._array[is]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(is),!0;while(++is<this._array.length&&this._getKey(this._array[is])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((a,l)=>a-l),t=0,s=new Array(this._array.length-e.length),n=0;for(let a=0;a<this._array.length;a++)e[t]===a?t++:s[n++]=this._array[a];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(is=this._search(e),!(is<0||is>=this._array.length)&&this._getKey(this._array[is])===e))do yield this._array[is];while(++is<this._array.length&&this._getKey(this._array[is])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(is=this._search(e),!(is<0||is>=this._array.length)&&this._getKey(this._array[is])===e))do t(this._array[is]);while(++is<this._array.length&&this._getKey(this._array[is])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let n=t+s>>1,a=this._getKey(this._array[n]);if(a>e)s=n-1;else if(a<e)t=n+1;else{for(;n>0&&this._getKey(this._array[n-1])===e;)n--;return n}}return t}},Ng=0,Q2=0,SF=class extends nt{constructor(){super(),this._decorations=new wF(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new ke),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ke),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ut(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new jF(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let n=0,a=0;for(let l of this._decorations.getKeyIterator(t))n=l.options.x??0,a=n+(l.options.width??1),e>=n&&e<a&&(!s||(l.options.layer??"bottom")===s)&&(yield l)}forEachDecorationAtCell(e,t,s,n){this._decorations.forEachByKey(t,a=>{Ng=a.options.x??0,Q2=Ng+(a.options.width??1),e>=Ng&&e<Q2&&(!s||(a.options.layer??"bottom")===s)&&n(a)})}},jF=class extends Yi{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ke),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ke),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Wt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Wt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},kF=1e3,CF=class{constructor(e,t=kF){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let n=performance.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=n-this._lastRefreshMs,l=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},l)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Z2=20,Ph=class extends nt{constructor(e,t,s,n){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=n,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let a=this._coreBrowserService.mainDocument;this._accessibilityContainer=a.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=a.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let l=0;l<this._terminal.rows;l++)this._rowElements[l]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[l]);if(this._topBoundaryFocusListener=l=>this._handleBoundaryFocus(l,0),this._bottomBoundaryFocusListener=l=>this._handleBoundaryFocus(l,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=a.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new CF(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(l=>this._handleResize(l.rows))),this._register(this._terminal.onRender(l=>this._refreshRows(l.start,l.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(l=>this._handleChar(l))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
257
+ `))),this._register(this._terminal.onA11yTab(l=>this._handleTab(l))),this._register(this._terminal.onKey(l=>this._handleKey(l.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ge(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ut(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Z2+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
258
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Z2+1&&(this._liveRegion.textContent+=Mx.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,n=s.lines.length.toString();for(let a=e;a<=t;a++){let l=s.lines.get(s.ydisp+a),c=[],d=(l==null?void 0:l.translateToString(!0,void 0,void 0,c))||"",f=(s.ydisp+a+1).toString(),h=this._rowElements[a];h&&(d.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=d,this._rowColumns.set(h,c)),h.setAttribute("aria-posinset",f),h.setAttribute("aria-setsize",n),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,n=this._rowElements[t===0?1:this._rowElements.length-2],a=s.getAttribute("aria-posinset"),l=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===l||e.relatedTarget!==n)return;let c,d;if(t===0?(c=s,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(c=this._rowElements.shift(),d=s,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let f=this._createAccessibilityTreeNode();this._rowElements.unshift(f),this._rowContainer.insertAdjacentElement("afterbegin",f)}else{let f=this._createAccessibilityTreeNode();this._rowElements.push(f),this._rowContainer.appendChild(f)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var d;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let n=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:n,offset:((d=n.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(s.node))return;let a=({node:f,offset:h})=>{let m=f instanceof Text?f.parentNode:f,g=parseInt(m==null?void 0:m.getAttribute("aria-posinset"),10)-1;if(isNaN(g))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(m);if(!_)return console.warn("columns is null. Race condition?"),null;let v=h<_.length?_[h]:_.slice(-1)[0]+1;return v>=this._terminal.cols&&(++g,v=0),{row:g,column:v}},l=a(t),c=a(s);if(!(!l||!c)){if(l.row>c.row||l.row===c.row&&l.column>=c.column)throw new Error("invalid range");this._terminal.select(l.column,l.row,(c.row-l.row)*this._terminal.cols-l.column+c.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var a,l;e.style.transform="";let t=e.getBoundingClientRect().width,s=(l=(a=this._rowColumns.get(e))==null?void 0:a.slice(-1))==null?void 0:l[0];if(!s)return;let n=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${n/t})`}};Ph=es([Ae(1,sv),Ae(2,ii),Ae(3,ai)],Ph);var u0=class extends nt{constructor(e,t,s,n,a){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=n,this._linkProviderService=a,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ke),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ke),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Ut(()=>{var l;Ra(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(l=this._activeProviderReplies)==null||l.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ge(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ge(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ge(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ge(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let n=0;n<s.length;n++){let a=s[n];if(a.classList.contains("xterm"))break;if(a.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var n,a;(!this._activeProviderReplies||!t)&&((n=this._activeProviderReplies)==null||n.forEach(l=>{l==null||l.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[l,c]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(l)&&(s=this._checkLinkProviderResult(l,e,s)):c.provideLinks(e.y,d=>{var h,m;if(this._isMouseOut)return;let f=d==null?void 0:d.map(g=>({link:g}));(h=this._activeProviderReplies)==null||h.set(l,f),s=this._checkLinkProviderResult(l,e,s),((m=this._activeProviderReplies)==null?void 0:m.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let n=0;n<t.size;n++){let a=t.get(n);if(a)for(let l=0;l<a.length;l++){let c=a[l],d=c.link.range.start.y<e?0:c.link.range.start.x,f=c.link.range.end.y>e?this._bufferService.cols:c.link.range.end.x;for(let h=d;h<=f;h++){if(s.has(h)){a.splice(l--,1);break}s.add(h)}}}}_checkLinkProviderResult(e,t,s){var l;if(!this._activeProviderReplies)return s;let n=this._activeProviderReplies.get(e),a=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(a=!0);if(!a&&n){let c=n.find(d=>this._linkAtPosition(d.link,t));c&&(s=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let c=0;c<this._activeProviderReplies.size;c++){let d=(l=this._activeProviderReplies.get(c))==null?void 0:l.find(f=>this._linkAtPosition(f.link,t));if(d){s=!0,this._handleNewLink(d);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&NF(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Ra(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var s,n;return(n=(s=this._currentLink)==null?void 0:s.state)==null?void 0:n.decorations.pointerCursor},set:s=>{var n;(n=this._currentLink)!=null&&n.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,n;return(n=(s=this._currentLink)==null?void 0:s.state)==null?void 0:n.decorations.underline},set:s=>{var n,a,l;(n=this._currentLink)!=null&&n.state&&((l=(a=this._currentLink)==null?void 0:a.state)==null?void 0:l.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let n=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=a&&(this._clearCurrentLink(n,a),this._lastMouseEvent)){let l=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);l&&this._askForLink(l,!1)}})))}_linkHover(e,t,s){var n;(n=this._currentLink)!=null&&n.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,n=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-n-1,s.end.x,s.end.y-n-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,t,s){var n;(n=this._currentLink)!=null&&n.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,n=e.range.end.y*this._bufferService.cols+e.range.end.x,a=t.y*this._bufferService.cols+t.x;return s<=a&&a<=n}_positionFromMouseEvent(e,t,s){let n=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(n)return{x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,n,a){return{x1:e,y1:t,x2:s,y2:n,cols:this._bufferService.cols,fg:a}}};u0=es([Ae(1,nv),Ae(2,ai),Ae(3,sn),Ae(4,HC)],u0);function NF(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var EF=class extends bF{constructor(e={}){super(e),this._linkifier=this._register(new Yo),this.browser=oN,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Yo),this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ke),this.onKey=this._onKey.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ke),this.onBell=this._onBell.event,this._onFocus=this._register(new ke),this._onBlur=this._register(new ke),this._onA11yCharEmitter=this._register(new ke),this._onA11yTabEmitter=this._register(new ke),this._onWillOpen=this._register(new ke),this._setup(),this._decorationService=this._instantiationService.createInstance(SF),this._instantiationService.setService(pu,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(xI),this._instantiationService.setService(HC,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Ax)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Is.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Is.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Is.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Is.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Ut(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,n="";switch(t.index){case 256:s="foreground",n="10";break;case 257:s="background",n="11";break;case 258:s="cursor",n="12";break;default:s="ansi",n="4;"+t.index}switch(t.type){case 0:let a=$t.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${xe.ESC}]${n};${fF(a)}${iN.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(l=>l.ansi[t.index]=fs.toColor(...t.color));else{let l=s;this._themeService.modifyColors(c=>c[l]=fs.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Ph,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(xe.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(xe.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),n=this._renderService.dimensions.css.cell.height,a=t.getWidth(s),l=this._renderService.dimensions.css.cell.width*a,c=this.buffer.y*this._renderService.dimensions.css.cell.height,d=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=c+"px",this.textarea.style.width=l+"px",this.textarea.style.height=n+"px",this.textarea.style.lineHeight=n+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ge(this.element,"copy",t=>{this.hasSelection()&&R9(t,this._selectionService)}));let e=t=>D9(t,this.textarea,this.coreService,this.optionsService);this._register(Ge(this.textarea,"paste",e)),this._register(Ge(this.element,"paste",e)),lN?this._register(Ge(this.element,"mousedown",t=>{t.button===2&&c2(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ge(this.element,"contextmenu",t=>{c2(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),dv&&this._register(Ge(this.element,"auxclick",t=>{t.button===1&&DC(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ge(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ge(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ge(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ge(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ge(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ge(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ge(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((a=this.element)==null?void 0:a.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ge(this.screenElement,"mousemove",l=>this.updateCursorStyle(l))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Ex.get()),dN||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(mI,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ii,this._coreBrowserService),this._register(Ge(this.textarea,"focus",l=>this._handleTextAreaFocus(l))),this._register(Ge(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Qx,this._document,this._helperContainer),this._instantiationService.setService(Qh,this._charSizeService),this._themeService=this._instantiationService.createInstance(s0),this._instantiationService.setService(tl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Bh),this._instantiationService.setService(FC,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(e0,this.rows,this.screenElement)),this._instantiationService.setService(ai,this._renderService),this._register(this._renderService.onRenderedViewportChange(l=>this._onRender.fire(l))),this.onResize(l=>this._renderService.resize(l.cols,l.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Yx,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Zx),this._instantiationService.setService(nv,this._mouseService);let n=this._linkifier.value=this._register(this._instantiationService.createInstance(u0,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Gx,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(l=>{super.scrollLines(l,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(t0,this.element,this.screenElement,n)),this._instantiationService.setService(F9,this._selectionService),this._register(this._selectionService.onRequestScrollLines(l=>this.scrollLines(l.amount,l.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(l=>this._renderService.handleSelectionChanged(l.start,l.end,l.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(l=>{this.textarea.value=l,this.textarea.focus(),this.textarea.select()})),this._register(Is.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var l;this._selectionService.refresh(),(l=this._viewport)==null||l.queueSync()})),this._register(this._instantiationService.createInstance(Kx,this.screenElement)),this._register(Ge(this.element,"mousedown",l=>this._selectionService.handleMouseDown(l))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Ph,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",l=>this._handleScreenReaderModeOptionChange(l))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Lh,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",l=>{!this._overviewRulerRenderer&&l&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Lh,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Jx,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(l){var h,m,g,_,v;let c=e._mouseService.getMouseReportCoords(l,e.screenElement);if(!c)return!1;let d,f;switch(l.overrideType||l.type){case"mousemove":f=32,l.buttons===void 0?(d=3,l.button!==void 0&&(d=l.button<3?l.button:3)):d=l.buttons&1?0:l.buttons&4?1:l.buttons&2?2:3;break;case"mouseup":f=0,d=l.button<3?l.button:3;break;case"mousedown":f=1,d=l.button<3?l.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(l)===!1)return!1;let y=l.deltaY;if(y===0||e.coreMouseService.consumeWheelEvent(l,(_=(g=(m=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:m.device)==null?void 0:g.cell)==null?void 0:_.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return!1;f=y<0?0:1,d=4;break;default:return!1}return f===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:d,action:f,ctrl:l.ctrlKey,alt:l.altKey,shift:l.shiftKey})}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:l=>(s(l),l.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.mousedrag)),this.cancel(l)),wheel:l=>(s(l),this.cancel(l,!0)),mousedrag:l=>{l.buttons&&s(l)},mousemove:l=>{l.buttons||s(l)}};this._register(this.coreMouseService.onProtocolChange(l=>{l?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(l)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),l&8?n.mousemove||(t.addEventListener("mousemove",a.mousemove),n.mousemove=a.mousemove):(t.removeEventListener("mousemove",n.mousemove),n.mousemove=null),l&16?n.wheel||(t.addEventListener("wheel",a.wheel,{passive:!1}),n.wheel=a.wheel):(t.removeEventListener("wheel",n.wheel),n.wheel=null),l&2?n.mouseup||(n.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),l&4?n.mousedrag||(n.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ge(t,"mousedown",l=>{if(l.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(l)))return s(l),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(l)})),this._register(Ge(t,"wheel",l=>{var c,d,f,h,m;if(!n.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(l)===!1)return!1;if(!this.buffer.hasScrollback){if(l.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(l,(h=(f=(d=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:d.device)==null?void 0:f.cell)==null?void 0:h.height,(m=e._coreBrowserService)==null?void 0:m.dpr)===0)return this.cancel(l,!0);let g=xe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(l.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(g,!0),this.cancel(l,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){RC(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var s;(s=this._selectionService)==null||s.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=yF(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let n=this.rows-1;return this.scrollLines(s.type===2?-n:n),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===xe.ETX||s.key===xe.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(MF(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var s;(s=this._charSizeService)==null||s.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(hs));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(xe.ESC+"[I"):this.coreService.triggerDataEvent(xe.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${xe.ESC}[4;${s};${t}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),a=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${xe.ESC}[6;${a};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function MF(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var TF=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},AF=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Xn)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},eS=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new AF(t)}getNullCell(){return new Xn}},RF=class extends nt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ke),this.onBufferChange=this._onBufferChange.event,this._normal=new eS(this._core.buffers.normal,"normal"),this._alternate=new eS(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},DF=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,n)=>t(s,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},LF=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},BF=["cols","rows"],hr=0,OF=class extends nt{constructor(e){super(),this._core=this._register(new EF(e)),this._addonManager=this._register(new TF),this._publicOptions={...this._core.options};let t=n=>this._core.options[n],s=(n,a)=>{this._checkReadonlyOptions(n),this._core.options[n]=a};for(let n in this._core.options){let a={get:t.bind(this,n),set:s.bind(this,n)};Object.defineProperty(this._publicOptions,n,a)}}_checkReadonlyOptions(e){if(BF.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new DF(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new LF(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new RF(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
259
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Ex.get()},set promptLabel(e){Ex.set(e)},get tooMuchOutput(){return Mx.get()},set tooMuchOutput(e){Mx.set(e)}}}_verifyIntegers(...e){for(hr of e)if(hr===1/0||isNaN(hr)||hr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(hr of e)if(hr&&(hr===1/0||isNaN(hr)||hr%1!==0||hr<0))throw new Error("This API only accepts positive integers")}};/**
260
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
261
+ * @license MIT
262
+ *
263
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
264
+ * @license MIT
265
+ *
266
+ * Originally forked from (with the author's permission):
267
+ * Fabrice Bellard's javascript vt100 for jslinux:
268
+ * http://bellard.org/jslinux/
269
+ * Copyright (c) 2011 Fabrice Bellard
270
+ */var zF=2,PF=1,$F=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var g;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((g=this._terminal.options.overviewRuler)==null?void 0:g.width)||14,s=window.getComputedStyle(this._terminal.element.parentElement),n=parseInt(s.getPropertyValue("height")),a=Math.max(0,parseInt(s.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),c={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},d=c.top+c.bottom,f=c.right+c.left,h=n-d,m=a-f-t;return{cols:Math.max(zF,Math.floor(m/e.css.cell.width)),rows:Math.max(PF,Math.floor(h/e.css.cell.height))}}};let Ts=null,Dc=null,Lc=null,Ii=null;function IF(e,t,s,n,a){yN();const c=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal/${e}`;Dc=t,Lc=s,Ii=n??null,Ts=new WebSocket(c),Ts.binaryType="arraybuffer",Ts.onopen=()=>{a==null||a()},Ts.onmessage=d=>{if(d.data instanceof ArrayBuffer)Dc==null||Dc(new Uint8Array(d.data));else try{const f=JSON.parse(d.data);f.type==="exit"&&(Lc==null||Lc(f.exitCode))}catch{}},Ts.onerror=()=>{Ii==null||Ii("Terminal WebSocket connection error")},Ts.onclose=d=>{d.wasClean||Ii==null||Ii("Terminal connection lost")}}function tS(e){(Ts==null?void 0:Ts.readyState)===WebSocket.OPEN&&Ts.send(JSON.stringify({type:"input",data:e}))}function sS(e,t){(Ts==null?void 0:Ts.readyState)===WebSocket.OPEN&&Ts.send(JSON.stringify({type:"resize",cols:e,rows:t}))}function yN(){Ts==null||Ts.close(),Ts=null,Dc=null,Lc=null,Ii=null}function nS(e){return{background:e?"#141413":"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"rgba(255, 255, 255, 0.2)"}}function FF({cwd:e,onClose:t,embedded:s=!1,initialCommand:n}){const a=w.useRef(null),l=w.useRef(null),c=w.useRef(null),d=G(h=>h.darkMode);w.useEffect(()=>{if(!a.current)return;let h=!1;const m=new OF({cursorBlink:!0,fontSize:13,fontFamily:"'SF Mono', 'Monaco', 'Menlo', 'Courier New', monospace",theme:nS(G.getState().darkMode)}),g=new $F;m.loadAddon(g),m.open(a.current),l.current=m,c.current=g,ne.spawnTerminal(e,m.cols,m.rows).then(({terminalId:S})=>{h||(G.getState().setTerminalId(S),IF(S,j=>m.write(j),j=>{m.writeln(`\r
271
+ [Process exited with code ${j}]`)},j=>{m.writeln(`\r
272
+ [${j}]`)},()=>{g.fit(),sS(m.cols,m.rows),n&&setTimeout(()=>tS(n+`
273
+ `),300)}))}).catch(S=>{h||m.writeln(`\r
274
+ [Failed to start terminal: ${S.message}]`)});const _=m.onData(S=>tS(S)),v=a.current,y=new ResizeObserver(()=>{g.fit(),sS(m.cols,m.rows)});return y.observe(v),()=>{h=!0,y.disconnect(),_.dispose(),yN(),m.dispose(),l.current=null,c.current=null,ne.killTerminal().catch(()=>{})}},[e,n]),w.useEffect(()=>{l.current&&(l.current.options.theme=nS(d))},[d]);const f=r.jsxs("div",{className:`flex flex-col rounded-xl shadow-2xl overflow-hidden border border-cc-border ${s?"h-full":"w-[90vw] max-w-4xl h-[70vh]"}`,style:{background:d?"#141413":"#1e1e1e"},onClick:h=>h.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-cc-border bg-cc-sidebar shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-cc-muted shrink-0",children:r.jsx("path",{d:"M2 3a1 1 0 011-1h10a1 1 0 011 1v10a1 1 0 01-1 1H3a1 1 0 01-1-1V3zm2 1.5l3 2.5-3 2.5V4.5zM8.5 10h3v1h-3v-1z"})}),r.jsx("span",{className:"text-xs text-cc-muted font-mono-code truncate",children:e})]}),t&&r.jsx("button",{onClick:t,className:"w-6 h-6 flex items-center justify-center rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer shrink-0",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})})})]}),r.jsx("div",{ref:a,className:"flex-1 min-h-0 p-1"})]});return s?r.jsx("div",{className:"h-full",children:f}):r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:f})}function HF(){const e=G(n=>n.terminalCwd),[t,s]=w.useState(!1);return r.jsxs("div",{className:"h-full bg-cc-bg overflow-y-auto",children:[r.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-8 py-6 sm:py-10 h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3 mb-6 shrink-0",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"Terminal"}),r.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Run shell commands in a project folder without leaving Campfire."})]}),r.jsx("button",{type:"button",onClick:()=>s(!0),className:"px-3 py-2 rounded-lg text-sm font-medium bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors cursor-pointer whitespace-nowrap",children:e?"Change Folder":"Choose Folder"})]}),r.jsx("div",{className:"flex-1 min-h-[420px]",children:e?r.jsx(FF,{cwd:e,embedded:!0}):r.jsx("div",{className:"h-full bg-cc-card border border-cc-border rounded-xl p-6 sm:p-8 flex items-center justify-center text-center",children:r.jsxs("div",{className:"max-w-md",children:[r.jsx("h2",{className:"text-lg font-semibold text-cc-fg mb-2",children:"No terminal started yet"}),r.jsx("p",{className:"text-sm text-cc-muted",children:"Choose a folder to start a terminal session. You can switch folders anytime."})]})})})]}),t&&r.jsx(ev,{initialPath:e||"",onSelect:n=>{G.getState().openTerminal(n),window.location.hash="#/terminal",s(!1)},onClose:()=>s(!1)})]})}let UF=0;function rS(){return`replay-${++UF}`}function VF(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function iS(e,t){var s;if(e.type==="user_message")return{id:e.id||rS(),role:"user",content:e.content||"",timestamp:e.timestamp||0};if(e.type==="assistant"){const n=e.message;return n?{id:n.id||rS(),role:"assistant",content:VF(n.content||[]),contentBlocks:n.content,timestamp:e.timestamp||0,parentToolUseId:e.parent_tool_use_id,model:n.model,stopReason:n.stop_reason}:null}if(e.type==="result"){const n=e.data;if(n!=null&&n.is_error&&((s=n.errors)!=null&&s.length))return{id:`replay-error-${t}`,role:"system",content:`Error: ${n.errors.join(", ")}`,timestamp:0}}return null}function aS(e){const t=[];let s="",n=null;for(let a=0;a<e.length;a++){const l=e[a];if(l.type==="stream_event"){const d=l.event;if((d==null?void 0:d.type)==="message_start"){if(s&&n){const f=t.find(h=>h.id===n);f&&(f.content=s)}s="",n=null}else if((d==null?void 0:d.type)==="content_block_delta"){const f=d.delta;(f==null?void 0:f.type)==="text_delta"&&f.text&&(s+=f.text)}continue}if(l.type==="assistant"){const d=iS(l,a);d&&(!d.content&&s&&(d.content=s),n=d.id,t.push(d)),s="";continue}if(s&&n){const d=t.find(f=>f.id===n);d&&!d.content&&(d.content=s),s="",n=null}const c=iS(l,a);c&&t.push(c)}if(s&&n){const a=t.find(l=>l.id===n);a&&!a.content&&(a.content=s)}return t}const WF=[1,2,4,8];function oS({filename:e,sessionId:t}){const s=G(O=>O.replaySpeed),n=G(O=>O.replayState),a=G(O=>O.replaySessionId),l=G(O=>O.setReplaySpeed),c=G(O=>O.setReplayState),d=G(O=>O.setReplaySessionId),f=G(O=>O.setMessages),h=w.useRef([]),m=w.useRef([]),g=w.useRef(0),_=w.useRef(null),[v,y]=w.useState(!0),[S,j]=w.useState(null),[k,N]=w.useState(!1),[E,B]=w.useState(null),[F,$]=w.useState(0),[K,Y]=w.useState(0);w.useEffect(()=>{const O=`replay-${Math.random().toString(36).slice(2,10)}`;return d(O),f(O,[]),c("idle"),()=>{d(null),c("idle"),f(O,[])}},[d,f,c]),w.useEffect(()=>{let O=!1;async function U(){y(!0),j(null);try{if(e){const I=await ne.getRecording(e);if(O)return;B(I.header);const R=aS(I.messages),P=I.timestamps,z=P.length>1?P.length/Math.max(R.length,1):1;m.current=R.map((T,oe)=>P[Math.min(Math.round(oe*z),P.length-1)]||0),h.current=R,$(R.length)}else if(t){const I=await ne.getSessionHistory(t);if(O)return;I.state&&B({session_id:t,backend_type:I.state.backend_type||"unknown",started_at:I.state.started_at||Date.now(),cwd:I.state.cwd||""});const R=aS(I.messages);h.current=R,$(R.length)}}catch(I){O||j(I.message||"Failed to load replay data")}finally{O||y(!1)}}return U(),()=>{O=!0}},[e,t]),w.useEffect(()=>()=>{_.current&&clearTimeout(_.current)},[]);const W=w.useCallback(O=>{const U=m.current;if(U.length>1&&O>0&&O<U.length){const I=U[O]-U[O-1];return Math.min(I,3e3)/s}return 300/s},[s]),L=w.useCallback(()=>{if(!a)return;const O=g.current;if(O>=h.current.length){c("ended");return}const U=h.current.slice(0,O+1);f(a,U),g.current=O+1,Y(O+1),O+1<h.current.length?_.current=setTimeout(L,W(O+1)):c("ended")},[a,f,c,W]),Q=w.useCallback(()=>{!a||h.current.length===0||(c("playing"),g.current>=h.current.length&&(g.current=0,Y(0),f(a,[])),_.current=setTimeout(L,W(g.current)))},[a,c,f,L,W]),V=w.useCallback(()=>{c("paused"),_.current&&(clearTimeout(_.current),_.current=null)},[c]),X=w.useCallback(()=>{_.current&&(clearTimeout(_.current),_.current=null),c("idle"),g.current=0,Y(0),a&&f(a,[])},[c,f,a]),q=w.useCallback(O=>{if(!a)return;_.current&&(clearTimeout(_.current),_.current=null);const U=Math.max(0,Math.min(O,h.current.length));g.current=U,Y(U),f(a,h.current.slice(0,U)),U>=h.current.length?c("ended"):n==="playing"?_.current=setTimeout(L,W(U)):c("paused")},[a,f,c,n,L,W]);w.useEffect(()=>{n==="playing"&&_.current&&(clearTimeout(_.current),_.current=setTimeout(L,W(g.current)))},[s]);const A=w.useCallback(()=>{var I;const O=e?`#/replay/${e}`:`#/replay/session/${t}`,U=`${window.location.origin}/${O}`;if((I=navigator.clipboard)!=null&&I.writeText)navigator.clipboard.writeText(U);else{const R=document.createElement("textarea");R.value=U,R.style.position="fixed",R.style.opacity="0",document.body.appendChild(R),R.select(),document.execCommand("copy"),document.body.removeChild(R)}N(!0),setTimeout(()=>N(!1),2e3)},[e,t]),M=w.useCallback(()=>{window.location.hash=""},[]);return v?r.jsx("div",{className:"flex items-center justify-center h-full text-cc-text-secondary",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("svg",{className:"animate-spin h-5 w-5",viewBox:"0 0 24 24",fill:"none",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",className:"opacity-25"}),r.jsx("path",{d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z",fill:"currentColor",className:"opacity-75"})]}),"Loading replay..."]})}):S?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-cc-text-secondary",children:[r.jsxs("p",{className:"text-red-400",children:["Failed to load replay: ",S]}),r.jsx("button",{onClick:M,className:"px-4 py-2 bg-cc-border rounded hover:bg-cc-hover transition-colors",children:"Go Back"})]}):!v&&F===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-cc-muted",children:[r.jsx("p",{className:"text-sm",children:"This recording contains no playable messages."}),r.jsx("p",{className:"text-xs text-cc-muted/60",children:"It may be a reconnect or initialization-only recording."}),r.jsx("button",{onClick:M,className:"px-4 py-2 bg-cc-border rounded hover:bg-cc-hover transition-colors text-sm",children:"Go Back"})]}):r.jsxs("div",{className:"flex flex-col h-full bg-cc-bg",children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-cc-border bg-cc-card",children:[r.jsxs("div",{className:"flex items-center gap-3 text-sm text-cc-muted",children:[r.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}),r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]}),r.jsx("span",{className:"font-medium text-cc-fg",children:"Session Replay"}),E&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-cc-hover text-cc-muted",children:E.backend_type}),r.jsxs("span",{className:"text-xs",children:[E.session_id.slice(0,8),"..."]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:A,className:`p-1.5 rounded hover:bg-cc-hover transition-colors ${k?"text-cc-success":"text-cc-muted"}`,title:k?"Copied!":"Copy replay link",children:k?r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.684 13.342C8.886 12.938 9 12.482 9 12c0-.482-.114-.938-.316-1.342m0 2.684a3 3 0 110-2.684m0 2.684l6.632 3.316m-6.632-6l6.632-3.316m0 0a3 3 0 105.367-2.684 3 3 0 00-5.367 2.684zm0 9.316a3 3 0 105.368 2.684 3 3 0 00-5.368-2.684z"})})}),r.jsx("button",{onClick:M,className:"p-1.5 rounded hover:bg-cc-hover transition-colors text-cc-muted",title:"Close replay",children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),r.jsx("div",{className:"border-b border-cc-border bg-cc-card px-4 py-2",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:n==="playing"?V:Q,className:"w-8 h-8 flex items-center justify-center rounded-lg bg-cc-primary text-white hover:bg-cc-primary-hover transition-colors cursor-pointer",title:n==="playing"?"Pause":"Play",children:n==="playing"?r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M5.5 3.5A1.5 1.5 0 017 5v6a1.5 1.5 0 01-3 0V5a1.5 1.5 0 011.5-1.5zm5 0A1.5 1.5 0 0112 5v6a1.5 1.5 0 01-3 0V5a1.5 1.5 0 011.5-1.5z"})}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M4.5 3.5A.5.5 0 015.22 3l7 4.5a.5.5 0 010 .86l-7 4.5A.5.5 0 014.5 12.5v-9z"})})}),r.jsx("button",{onClick:X,className:"w-8 h-8 flex items-center justify-center rounded-lg text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",title:"Reset",children:r.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),r.jsx("div",{className:"flex-1 h-1.5 bg-cc-hover rounded-full overflow-hidden cursor-pointer",onClick:O=>{const U=O.currentTarget.getBoundingClientRect(),I=(O.clientX-U.left)/U.width;q(Math.round(I*F))},children:r.jsx("div",{className:"h-full bg-cc-primary rounded-full transition-all",style:{width:`${F>0?K/F*100:0}%`}})}),r.jsxs("span",{className:"text-[10px] text-cc-muted tabular-nums",children:[K,"/",F]}),r.jsx("div",{className:"flex items-center gap-1",children:WF.map(O=>r.jsxs("button",{onClick:()=>l(O),className:`px-2 py-1 text-[10px] font-medium rounded transition-colors cursor-pointer ${s===O?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:[O,"x"]},O))}),r.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded font-medium ${n==="playing"?"bg-green-500/20 text-green-400":n==="paused"?"bg-yellow-500/20 text-yellow-400":"bg-cc-hover text-cc-muted"}`,children:n==="playing"?"Playing":n==="paused"?"Paused":n==="ended"?"Ended":"Ready"})]})}),r.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:a&&r.jsx(Y0,{sessionId:a})})]})}function qF({embedded:e=!1,prefillSessionId:t,prefillName:s}){const[n,a]=w.useState([]),[l,c]=w.useState(!0),[d,f]=w.useState(""),[h,m]=w.useState(""),[g,_]=w.useState(!1),[v,y]=w.useState(""),[S,j]=w.useState("votes"),[k,N]=w.useState("desc"),[E,B]=w.useState(!1),[F,$]=w.useState(null),[K,Y]=w.useState(!1),[W,L]=w.useState(!!t),[Q,V]=w.useState({sessionId:t||"",name:s||"",description:"",tags:""}),[X,q]=w.useState(!1),A=w.useCallback(()=>{const re={};h&&(re.backend=h),g&&(re.featured=!0),v.trim()&&(re.tags=v.split(",").map(ve=>ve.trim()).filter(Boolean)),S&&(re.sortBy=S),k&&(re.sortOrder=k),ne.listGalleryEntries(re).then(a).catch(ve=>f(ve instanceof Error?ve.message:String(ve))).finally(()=>c(!1))},[h,g,v,S,k]);w.useEffect(()=>{A();const re=setInterval(A,15e3);return()=>clearInterval(re)},[A]),w.useEffect(()=>{ne.getClawHubStatus().then(re=>B(re.available)).catch(()=>{}),ne.getMoltbookStatus().then(re=>Y(re.available)).catch(()=>{})},[]);async function M(re,ve){a(Te=>Te.map(Re=>Re.id===re?{...Re,votes:Re.votes+ve}:Re));try{const{votes:Te}=await ne.voteGalleryEntry(re,ve);a(Re=>Re.map(je=>je.id===re?{...je,votes:Te}:je))}catch{A()}}async function O(re){try{await ne.deleteGalleryEntry(re),A()}catch(ve){f(ve instanceof Error?ve.message:String(ve))}}async function U(re){try{await ne.featureGalleryEntry(re),A()}catch(ve){f(ve instanceof Error?ve.message:String(ve))}}async function I(re){if(!F){$(re),f("");try{const ve=await ne.exportToClawHub(re);ve.ok?(f(`Exported to ClawHub: ${ve.output||"success"}`),setTimeout(()=>f(""),5e3)):f(`ClawHub export failed: ${ve.error}`)}catch(ve){f(ve instanceof Error?ve.message:String(ve))}finally{$(null)}}}async function R(re){f("");try{const ve=await ne.postToMoltbook(re);if(ve.ok){const Te=ve.postUrl?` — ${ve.postUrl}`:"";f(`Posted to Moltbook${Te}`),setTimeout(()=>f(""),5e3)}else f(`Moltbook post failed: ${ve.error}`)}catch(ve){f(ve instanceof Error?ve.message:String(ve))}}async function P(re){var ve;f("");try{const Te=await ne.createPublicReplayLink(re),Re=`${window.location.origin}/${Te.url}`;if((ve=navigator.clipboard)!=null&&ve.writeText)await navigator.clipboard.writeText(Re),f("Public replay link copied to clipboard");else{const je=document.createElement("textarea");je.value=Re,je.style.position="fixed",je.style.opacity="0",document.body.appendChild(je),je.select(),document.execCommand("copy"),document.body.removeChild(je),f("Public replay link copied to clipboard")}setTimeout(()=>f(""),3e3)}catch(Te){f(Te instanceof Error?Te.message:String(Te))}}async function z(){const re=Q.name.trim(),ve=Q.sessionId.trim();if(!(!re||!ve)){q(!0),f("");try{await ne.createGalleryEntry({sessionId:ve,name:re,description:Q.description.trim(),tags:Q.tags.split(",").map(Te=>Te.trim()).filter(Boolean)}),V({sessionId:"",name:"",description:"",tags:""}),L(!1),A()}catch(Te){f(Te instanceof Error?Te.message:String(Te))}finally{q(!1)}}}const T=n.reduce((re,ve)=>re+ve.votes,0),oe=n.filter(re=>re.featured).length,be=r.jsxs("div",{className:"max-w-3xl mx-auto px-4 sm:px-8 py-6 sm:py-10 font-sans-ui antialiased",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[r.jsx("button",{onClick:()=>{window.location.hash=""},className:"flex items-center justify-center w-8 h-8 rounded-lg text-cc-fg/60 hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer","aria-label":"Go back",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",className:"w-4 h-4",children:r.jsx("path",{d:"M10 3L5 8l5 5",strokeLinecap:"round",strokeLinejoin:"round"})})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-[11px] text-cc-fg/50 font-medium",children:"Data"}),r.jsx("h1",{className:"text-xl font-semibold text-cc-fg -mt-0.5",children:"Session Gallery"})]}),r.jsx("button",{onClick:()=>{L(!W)},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all cursor-pointer ${W?"bg-cc-hover text-cc-fg":"bg-cc-primary hover:bg-cc-primary-hover text-white shadow-sm"}`,children:W?r.jsxs(r.Fragment,{children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3 h-3",children:r.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})}),"Cancel"]}):r.jsxs(r.Fragment,{children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"w-3 h-3",children:r.jsx("path",{d:"M8 3v10M3 8h10"})}),"Publish"]})})]}),r.jsx("p",{className:"text-[13px] text-cc-fg/55 mb-5 ml-11",children:"Showcase your best AI coding sessions. Vote, feature, and share."}),r.jsxs("div",{className:"flex items-center gap-4 mb-5 ml-11",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",children:[r.jsx("span",{className:"text-cc-fg/40",children:"Entries"}),r.jsx("span",{className:"font-semibold text-cc-fg",children:n.length})]}),r.jsx("div",{className:"w-px h-3.5 bg-cc-border/40"}),r.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",children:[r.jsx("span",{className:"text-cc-fg/40",children:"Total Votes"}),r.jsx("span",{className:"font-semibold text-cc-fg",children:T})]}),oe>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-px h-3.5 bg-cc-border/40"}),r.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-amber-500",children:r.jsx("path",{d:"M8 1.5l2.09 4.26 4.66.68-3.38 3.28.8 4.64L8 12.17l-4.17 2.19.8-4.64-3.38-3.28 4.66-.68L8 1.5z"})}),r.jsx("span",{className:"font-semibold text-cc-fg",children:oe})]})]})]}),d&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl bg-cc-error/8 border border-cc-error/15 text-[12px] text-cc-error flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 shrink-0",children:r.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm0 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 4zm0 7a1 1 0 100-2 1 1 0 000 2z"})}),d]}),r.jsx("button",{onClick:()=>f(""),className:"text-cc-error/70 hover:text-cc-error text-[11px] font-medium cursor-pointer shrink-0 ml-3",children:"Dismiss"})]}),W&&r.jsxs("div",{className:"mb-5 rounded-xl border border-cc-primary/30 bg-cc-card shadow-sm ring-1 ring-cc-primary/10 overflow-hidden",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-cc-border/30",children:[r.jsx("h3",{className:"text-[13px] font-semibold text-cc-fg",children:"Add to Gallery"}),r.jsx("p",{className:"text-[11px] text-cc-fg/50 mt-0.5",children:"Publish a session to the gallery for others to see."})]}),r.jsxs("div",{className:"px-5 py-4 space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-medium text-cc-fg/70 mb-1.5",htmlFor:"gallery-session-id",children:"Session ID"}),r.jsx("input",{id:"gallery-session-id",type:"text",value:Q.sessionId,onChange:re=>V({...Q,sessionId:re.target.value}),placeholder:"Paste session ID",className:"w-full px-3.5 py-2.5 text-[12px] font-mono-code bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg placeholder:text-cc-fg/35 focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 transition-all"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-medium text-cc-fg/70 mb-1.5",htmlFor:"gallery-name",children:"Name"}),r.jsx("input",{id:"gallery-name",type:"text",value:Q.name,onChange:re=>V({...Q,name:re.target.value}),placeholder:"e.g. Auth Refactor",className:"w-full px-3.5 py-2.5 text-[13px] bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg placeholder:text-cc-fg/35 focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 transition-all"})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-medium text-cc-fg/70 mb-1.5",htmlFor:"gallery-desc",children:"Description"}),r.jsx("textarea",{id:"gallery-desc",value:Q.description,onChange:re=>V({...Q,description:re.target.value}),placeholder:"What makes this session interesting? (optional)",rows:2,className:"w-full px-3.5 py-2.5 text-[13px] bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg placeholder:text-cc-fg/35 focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 transition-all resize-y"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-medium text-cc-fg/70 mb-1.5",htmlFor:"gallery-tags",children:"Tags"}),r.jsx("input",{id:"gallery-tags",type:"text",value:Q.tags,onChange:re=>V({...Q,tags:re.target.value}),placeholder:"auth, refactor, bug-fix (comma-separated)",className:"w-full px-3.5 py-2.5 text-[13px] bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg placeholder:text-cc-fg/35 focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 transition-all"})]}),r.jsx("div",{className:"flex justify-end pt-1",children:r.jsx("button",{onClick:z,disabled:!Q.name.trim()||!Q.sessionId.trim()||X,className:`px-4 py-2 rounded-lg text-[12px] font-medium transition-all ${Q.name.trim()&&Q.sessionId.trim()&&!X?"bg-cc-primary hover:bg-cc-primary-hover text-white shadow-sm cursor-pointer":"bg-cc-hover text-cc-fg/35 cursor-not-allowed"}`,children:X?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Publishing..."]}):"Publish to Gallery"})})]})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-5",children:[r.jsxs("select",{value:h,onChange:re=>m(re.target.value),className:"px-3 py-2 text-[12px] bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 cursor-pointer transition-all","aria-label":"Filter by backend",children:[r.jsx("option",{value:"",children:"All Backends"}),r.jsx("option",{value:"claude",children:"Claude"}),r.jsx("option",{value:"codex",children:"Codex"}),r.jsx("option",{value:"goose",children:"Goose"}),r.jsx("option",{value:"aider",children:"Aider"}),r.jsx("option",{value:"openhands",children:"OpenHands"}),r.jsx("option",{value:"openclaw",children:"OpenClaw"})]}),r.jsxs("select",{value:S,onChange:re=>j(re.target.value),className:"px-3 py-2 text-[12px] bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 cursor-pointer transition-all","aria-label":"Sort by",children:[r.jsx("option",{value:"votes",children:"Sort by Votes"}),r.jsx("option",{value:"recent",children:"Sort by Recent"}),r.jsx("option",{value:"cost",children:"Sort by Cost"}),r.jsx("option",{value:"duration",children:"Sort by Duration"})]}),r.jsx("button",{onClick:()=>N(re=>re==="desc"?"asc":"desc"),className:"px-3 py-2 text-[12px] bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg/60 hover:text-cc-fg transition-all cursor-pointer",title:k==="desc"?"Descending":"Ascending","aria-label":`Sort order: ${k}`,children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3.5 h-3.5 transition-transform ${k==="asc"?"rotate-180":""}`,children:r.jsx("path",{d:"M3.5 3a.5.5 0 01.5.5v8.793l2.146-2.147a.5.5 0 01.708.708l-3 3a.5.5 0 01-.708 0l-3-3a.5.5 0 11.708-.708L3 12.293V3.5a.5.5 0 01.5-.5zM7 4.5a.5.5 0 01.5-.5h5a.5.5 0 010 1h-5a.5.5 0 01-.5-.5zM7.5 7a.5.5 0 000 1h3.5a.5.5 0 000-1H7.5zm0 3a.5.5 0 000 1h2a.5.5 0 000-1h-2z"})})}),r.jsxs("button",{onClick:()=>_(!g),className:`flex items-center gap-1.5 px-3 py-2 text-[12px] font-medium rounded-lg transition-all cursor-pointer border ${g?"bg-amber-500/10 text-amber-600 border-amber-500/25":"bg-cc-bg text-cc-fg/50 border-cc-border/60 hover:text-cc-fg hover:border-cc-border"}`,"aria-pressed":g,children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("path",{d:"M8 1.5l2.09 4.26 4.66.68-3.38 3.28.8 4.64L8 12.17l-4.17 2.19.8-4.64-3.38-3.28 4.66-.68L8 1.5z"})}),"Featured"]}),r.jsx("div",{className:"flex-1 min-w-[120px]",children:r.jsx("input",{type:"text",value:v,onChange:re=>y(re.target.value),placeholder:"Filter by tags...",className:"w-full px-3 py-2 text-[12px] bg-cc-bg border border-cc-border/60 rounded-lg text-cc-fg placeholder:text-cc-fg/35 focus:outline-none focus:border-cc-primary/60 focus:ring-1 focus:ring-cc-primary/20 transition-all","aria-label":"Filter by tags"})})]}),l?r.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[r.jsx("span",{className:"w-6 h-6 border-2 border-cc-fg/10 border-t-cc-fg/50 rounded-full animate-spin mb-3"}),r.jsx("p",{className:"text-[12px] text-cc-fg/50",children:"Loading gallery..."})]}):n.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-cc-hover/70 flex items-center justify-center mb-4",children:r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-7 h-7 text-cc-fg/30",children:[r.jsx("path",{d:"M2 7l10-5 10 5-10 5-10-5z",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M2 12l10 5 10-5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M2 17l10 5 10-5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r.jsx("h3",{className:"text-[14px] font-semibold text-cc-fg mb-1",children:"No gallery entries yet"}),r.jsx("p",{className:"text-[12px] text-cc-fg/50 max-w-xs",children:"Publish your best sessions to showcase them. Vote on entries to surface the most interesting ones."}),!W&&r.jsx("button",{onClick:()=>L(!0),className:"mt-4 px-4 py-2 rounded-lg text-[12px] font-medium bg-cc-primary hover:bg-cc-primary-hover text-white shadow-sm transition-colors cursor-pointer",children:"Publish First Entry"})]}):r.jsx("div",{className:"space-y-3",children:n.map(re=>r.jsx(ih,{entry:re,onVote:M,onDelete:O,onFeature:U,onExportClawHub:I,clawHubAvailable:E,onPostMoltbook:R,moltbookAvailable:K,onCreatePublicLink:P},re.id))})]});return e?r.jsx("div",{className:"h-full bg-cc-bg overflow-y-auto text-cc-fg",children:be}):r.jsx("div",{className:"h-full bg-cc-bg overflow-y-auto text-cc-fg",children:be})}const GF=[{value:"session.created",label:"Session Created"},{value:"session.completed",label:"Session Completed"},{value:"session.failed",label:"Session Failed"},{value:"permission.requested",label:"Permission Requested"},{value:"permission.resolved",label:"Permission Resolved"},{value:"turn.completed",label:"Turn Completed"},{value:"cost.threshold",label:"Cost Threshold"}];function KF(e){const t=Date.now()-e,s=Math.floor(t/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const n=Math.floor(s/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}const Eg={name:"",url:"",events:["session.completed"],secret:"",format:"generic",backendFilter:"",cwdFilter:""};function YF({onClose:e,embedded:t=!1}){const[s,n]=w.useState([]),[a,l]=w.useState(!0),[c,d]=w.useState(""),[f,h]=w.useState(null),[m,g]=w.useState(Eg),[_,v]=w.useState(Eg),[y,S]=w.useState(!1),[j,k]=w.useState(!0),[N,E]=w.useState(new Set),[B,F]=w.useState(new Map),$=w.useCallback(()=>{ne.listWebhooks().then(n).catch(()=>{}).finally(()=>l(!1))},[]);w.useEffect(()=>{$();const O=setInterval($,15e3);return()=>clearInterval(O)},[$]);async function K(){const O=_.name.trim(),U=_.url.trim();if(!(!O||!U||_.events.length===0)){S(!0),d("");try{const I={};_.backendFilter&&(I.backendType=_.backendFilter),_.cwdFilter.trim()&&(I.cwd=_.cwdFilter.trim()),await ne.createWebhook({name:O,url:U,events:_.events,secret:_.secret.trim()||void 0,format:_.format||void 0,sessionFilter:Object.keys(I).length>0?I:void 0}),v(Eg),k(!0),$()}catch(I){d(I instanceof Error?I.message:String(I))}finally{S(!1)}}}function Y(O){var U,I;h(O.id),g({name:O.name,url:O.url,events:[...O.events],secret:O.secret||"",format:O.format||"generic",backendFilter:((U=O.sessionFilter)==null?void 0:U.backendType)||"",cwdFilter:((I=O.sessionFilter)==null?void 0:I.cwd)||""}),d("")}function W(){h(null),d("")}async function L(){if(!f)return;const O=m.name.trim(),U=m.url.trim();if(!(!O||!U||m.events.length===0))try{const I={};m.backendFilter&&(I.backendType=m.backendFilter),m.cwdFilter.trim()&&(I.cwd=m.cwdFilter.trim()),await ne.updateWebhook(f,{name:O,url:U,events:m.events,secret:m.secret.trim()||void 0,format:m.format||void 0,sessionFilter:Object.keys(I).length>0?I:void 0}),h(null),d(""),$()}catch(I){d(I instanceof Error?I.message:String(I))}}async function Q(O){try{await ne.deleteWebhook(O),f===O&&h(null),$()}catch(U){d(U instanceof Error?U.message:String(U))}}async function V(O){try{await ne.toggleWebhook(O),$()}catch(U){d(U instanceof Error?U.message:String(U))}}async function X(O){E(U=>new Set(U).add(O)),F(U=>{const I=new Map(U);return I.delete(O),I});try{const U=await ne.testWebhook(O);F(I=>new Map(I).set(O,U.ok)),$()}catch{F(U=>new Map(U).set(O,!1))}finally{E(U=>{const I=new Set(U);return I.delete(O),I})}}const q=c&&r.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:c}),A=a?r.jsx("div",{className:"text-sm text-cc-muted text-center py-6",children:"Loading webhooks..."}):s.length===0?r.jsx("div",{className:"text-sm text-cc-muted text-center py-6",children:"No webhooks configured. Create one below."}):r.jsx("div",{className:"space-y-3",children:s.map(O=>{var U,I;return r.jsxs("div",{className:"border border-cc-border rounded-lg overflow-hidden bg-cc-card",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 bg-cc-card border-b border-cc-border",children:[r.jsx("span",{className:"text-sm font-medium text-cc-fg flex-1 truncate",children:O.name}),O.totalDeliveries>0&&r.jsxs("span",{className:`text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 ${O.failedDeliveries>0?"text-cc-error bg-cc-error/10":"text-cc-success bg-cc-success/10"}`,children:[O.totalDeliveries-O.failedDeliveries,"/",O.totalDeliveries]}),r.jsx("button",{onClick:()=>V(O.id),className:`relative w-8 h-[18px] rounded-full transition-colors cursor-pointer shrink-0 ${O.enabled?"bg-cc-primary":"bg-cc-border"}`,title:O.enabled?"Disable":"Enable",children:r.jsx("span",{className:`absolute top-[2px] w-[14px] h-[14px] rounded-full bg-white transition-transform ${O.enabled?"left-[16px]":"left-[2px]"}`})}),f===O.id?r.jsx("button",{onClick:W,className:"text-xs text-cc-muted hover:text-cc-fg cursor-pointer",children:"Cancel"}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>X(O.id),disabled:N.has(O.id),className:`text-xs cursor-pointer ${N.has(O.id)?"text-cc-muted cursor-not-allowed":"text-cc-primary hover:text-cc-primary-hover"}`,children:N.has(O.id)?"Testing...":"Test"}),B.has(O.id)&&r.jsx("span",{className:`text-[10px] ${B.get(O.id)?"text-cc-success":"text-cc-error"}`,children:B.get(O.id)?"OK":"Failed"}),r.jsx("button",{onClick:()=>Y(O),className:"text-xs text-cc-muted hover:text-cc-fg cursor-pointer",children:"Edit"}),r.jsx("button",{onClick:()=>Q(O.id),className:"text-xs text-cc-muted hover:text-cc-error cursor-pointer",children:"Delete"})]})]}),f===O.id&&r.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[r.jsx(lS,{form:m,onChange:g}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:L,className:"px-3 py-2 text-xs font-medium bg-cc-primary hover:bg-cc-primary-hover text-white rounded-lg transition-colors cursor-pointer",children:"Save"}),r.jsx("button",{onClick:W,className:"px-3 py-2 text-xs font-medium text-cc-muted hover:text-cc-fg rounded-lg transition-colors cursor-pointer",children:"Cancel"})]})]}),f!==O.id&&r.jsxs("div",{className:"px-3 py-2.5 space-y-1.5",children:[r.jsx("div",{className:"text-xs text-cc-muted font-mono-code truncate",title:O.url,children:O.url}),r.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:O.events.map(R=>r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full bg-cc-hover text-cc-muted",children:R},R))}),r.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-cc-muted",children:[O.secret&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("path",{d:"M8 1a3.5 3.5 0 00-3.5 3.5V7H4a1 1 0 00-1 1v5a1 1 0 001 1h8a1 1 0 001-1V8a1 1 0 00-1-1h-.5V4.5A3.5 3.5 0 008 1zm2 6H6V4.5a2 2 0 114 0V7z"})}),"Signed"]}),O.lastDeliveryAt&&r.jsxs("span",{className:"flex items-center gap-1",children:["Last: ",KF(O.lastDeliveryAt),O.lastDeliverySuccess?r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-success",children:r.jsx("path",{d:"M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2.5-2.5a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z"})}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-error",children:r.jsx("path",{d:"M4.646 4.646a.5.5 0 01.708 0L8 7.293l2.646-2.647a.5.5 0 01.708.708L8.707 8l2.647 2.646a.5.5 0 01-.708.708L8 8.707l-2.646 2.647a.5.5 0 01-.708-.708L7.293 8 4.646 5.354a.5.5 0 010-.708z"})})]}),((U=O.sessionFilter)==null?void 0:U.backendType)&&r.jsxs("span",{children:["Filter: ",O.sessionFilter.backendType]}),((I=O.sessionFilter)==null?void 0:I.cwd)&&r.jsx("span",{className:"font-mono-code truncate max-w-[200px]",title:O.sessionFilter.cwd,children:O.sessionFilter.cwd})]})]})]},O.id)})}),M=r.jsxs("div",{className:"border border-cc-border rounded-lg overflow-hidden bg-cc-card",children:[r.jsxs("button",{onClick:()=>k(!j),className:"w-full flex items-center gap-2 px-3 py-2.5 bg-cc-card border-b border-cc-border cursor-pointer hover:bg-cc-hover transition-colors",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`w-3 h-3 text-cc-muted transition-transform ${j?"":"rotate-90"}`,children:r.jsx("path",{d:"M6 4l4 4-4 4",strokeLinecap:"round",strokeLinejoin:"round"})}),r.jsx("span",{className:"text-sm font-medium text-cc-fg",children:"New Webhook"})]}),!j&&r.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[r.jsx(lS,{form:_,onChange:v}),r.jsx("button",{onClick:K,disabled:!_.name.trim()||!_.url.trim()||_.events.length===0||y,className:`px-3 py-2 text-xs font-medium rounded-lg transition-colors ${_.name.trim()&&_.url.trim()&&_.events.length>0&&!y?"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:y?"Creating...":"Create"})]})]});return t?r.jsx("div",{className:"h-full bg-cc-bg overflow-y-auto",children:r.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-8 py-6 sm:py-10",children:[r.jsxs("div",{className:"mb-6",children:[r.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"Webhooks"}),r.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Receive HTTP notifications when session events occur."})]}),q,r.jsxs("div",{className:"mt-4 space-y-4",children:[r.jsxs("section",{className:"bg-cc-card border border-cc-border rounded-xl p-4 sm:p-5 space-y-3",children:[r.jsx("h2",{className:"text-sm font-semibold text-cc-fg",children:"Configured Webhooks"}),A]}),r.jsx("section",{className:"bg-cc-card border border-cc-border rounded-xl p-4 sm:p-5 space-y-3",children:M})]})]})}):null}function lS({form:e,onChange:t}){const s=a=>t({...e,...a});function n(a){const l=e.events.includes(a)?e.events.filter(c=>c!==a):[...e.events,a];s({events:l})}return r.jsxs("div",{className:"space-y-2.5",children:[r.jsx("input",{type:"text",value:e.name,onChange:a=>s({name:a.target.value}),placeholder:"Webhook name (e.g. Slack notifications)",className:"w-full px-3 py-2 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/50"}),r.jsx("input",{type:"text",value:e.url,onChange:a=>s({url:a.target.value}),placeholder:"https://hooks.slack.com/services/...",className:"w-full px-3 py-2 text-sm font-mono-code bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/50"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[11px] font-medium text-cc-muted mb-1.5",children:"Payload Format"}),r.jsx("div",{className:"flex gap-1.5",children:[{value:"generic",label:"Generic"},{value:"slack",label:"Slack"},{value:"openclaw",label:"OpenClaw"}].map(a=>r.jsx("button",{onClick:()=>s({format:a.value}),className:`px-2 py-1 text-[10px] font-medium rounded-md transition-colors cursor-pointer ${e.format===a.value?"bg-cc-primary/20 text-cc-primary border border-cc-primary/30":"bg-cc-hover text-cc-muted hover:text-cc-fg border border-transparent"}`,children:a.label},a.value))}),e.format==="openclaw"&&r.jsx("div",{className:"mt-1 text-[10px] text-cc-muted",children:"Posts to OpenClaw /hooks/agent endpoint. Use the signing secret field for the Bearer token."})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[11px] font-medium text-cc-muted mb-1.5",children:"Events"}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:GF.map(a=>r.jsx("button",{onClick:()=>n(a.value),className:`px-2 py-1 text-[10px] font-medium rounded-md transition-colors cursor-pointer ${e.events.includes(a.value)?"bg-cc-primary/20 text-cc-primary border border-cc-primary/30":"bg-cc-hover text-cc-muted hover:text-cc-fg border border-transparent"}`,children:a.label},a.value))})]}),r.jsx("input",{type:"password",value:e.secret,onChange:a=>s({secret:a.target.value}),placeholder:"Signing secret (optional, for HMAC-SHA256)",className:"w-full px-3 py-2 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/50"}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsxs("select",{value:e.backendFilter,onChange:a=>s({backendFilter:a.target.value}),className:"px-2 py-1.5 text-xs bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg focus:outline-none focus:border-cc-primary/50",children:[r.jsx("option",{value:"",children:"All backends"}),r.jsx("option",{value:"claude",children:"Claude Code"}),r.jsx("option",{value:"codex",children:"Codex"}),r.jsx("option",{value:"goose",children:"Goose"}),r.jsx("option",{value:"aider",children:"Aider"}),r.jsx("option",{value:"openhands",children:"OpenHands"}),r.jsx("option",{value:"openclaw",children:"OpenClaw"})]}),r.jsx("input",{type:"text",value:e.cwdFilter,onChange:a=>s({cwdFilter:a.target.value}),placeholder:"Filter by path prefix (optional)",className:"flex-1 px-2 py-1.5 text-xs font-mono-code bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/50"})]})]})}function XF(e){const t=Date.now()-e,s=Math.floor(t/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const n=Math.floor(s/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}const JF={stdio:"stdio",websocket:"WebSocket",http:"HTTP"};function QF({embedded:e=!1}){const[t,s]=w.useState([]),[n,a]=w.useState(!0),[l,c]=w.useState(""),[d,f]=w.useState(""),[h,m]=w.useState(!1),[g,_]=w.useState(new Set),v=w.useCallback(()=>{ne.listAdapters().then(s).catch(()=>{}).finally(()=>a(!1))},[]);w.useEffect(()=>{v();const E=setInterval(v,3e4);return()=>clearInterval(E)},[v]);async function y(){const E=d.trim();if(E){m(!0),c("");try{await ne.installAdapter(E),f(""),v()}catch(B){c(B instanceof Error?B.message:String(B))}finally{m(!1)}}}async function S(E){_(B=>new Set(B).add(E));try{await ne.uninstallAdapter(E),v()}catch(B){c(B instanceof Error?B.message:String(B))}finally{_(B=>{const F=new Set(B);return F.delete(E),F})}}const j=l&&r.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:l}),k=n?r.jsx("div",{className:"text-sm text-cc-muted text-center py-6",children:"Loading adapters..."}):t.length===0?r.jsx("div",{className:"text-sm text-cc-muted text-center py-6",children:"No community adapters installed. Install one below."}):r.jsx("div",{className:"space-y-3",children:t.map(E=>{const B=E.metadata;return r.jsxs("div",{className:"border border-cc-border rounded-lg overflow-hidden bg-cc-card",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 bg-cc-card border-b border-cc-border",children:[r.jsx("span",{className:"text-sm font-medium text-cc-fg flex-1 truncate",children:B.displayName}),r.jsxs("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-cc-muted bg-cc-hover",children:["v",B.version]}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 rounded-full leading-[16px] shrink-0 text-blue-500 bg-blue-500/10",children:JF[B.protocol]||B.protocol}),r.jsx("button",{onClick:()=>S(B.name),disabled:g.has(B.name),className:`text-xs cursor-pointer ${g.has(B.name)?"text-cc-muted cursor-not-allowed":"text-cc-muted hover:text-cc-error"}`,children:g.has(B.name)?"Removing...":"Uninstall"})]}),r.jsxs("div",{className:"px-3 py-2.5 space-y-1.5",children:[B.description&&r.jsx("div",{className:"text-xs text-cc-muted",children:B.description}),r.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-cc-muted",children:[r.jsx("span",{className:"font-mono-code",children:B.name}),r.jsxs("span",{children:[B.models.length," model",B.models.length!==1?"s":""]}),B.binaryName&&r.jsx("span",{className:"font-mono-code",children:B.binaryName}),B.author&&r.jsxs("span",{children:["by ",B.author]}),r.jsxs("span",{children:["Installed ",XF(E.installedAt)]}),r.jsx("span",{className:"font-mono-code",children:E.npmPackage})]}),B.models.length>1&&r.jsx("div",{className:"flex flex-wrap gap-1",children:B.models.map(F=>r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full bg-cc-hover text-cc-muted",children:F.label},F.value))})]})]},B.name)})}),N=r.jsxs("div",{className:"space-y-2.5",children:[r.jsx("div",{className:"text-[11px] font-medium text-cc-muted",children:"Install a community adapter from npm"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"text",value:d,onChange:E=>f(E.target.value),onKeyDown:E=>E.key==="Enter"&&y(),placeholder:"@campfire/example-adapter",className:"flex-1 px-3 py-2 text-sm font-mono-code bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/50"}),r.jsx("button",{onClick:y,disabled:!d.trim()||h,className:`px-3 py-2 text-xs font-medium rounded-lg transition-colors ${d.trim()&&!h?"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:h?"Installing...":"Install"})]}),r.jsx("div",{className:"text-[10px] text-cc-muted",children:'Adapters must declare a "campfireAdapter" field in their package.json'})]});return e?r.jsx("div",{className:"h-full bg-cc-bg overflow-y-auto",children:r.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-8 py-6 sm:py-10",children:[r.jsxs("div",{className:"mb-6",children:[r.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"Adapters"}),r.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Install and manage community agent adapters."})]}),j,r.jsxs("div",{className:"mt-4 space-y-4",children:[r.jsxs("section",{className:"bg-cc-card border border-cc-border rounded-xl p-4 sm:p-5 space-y-3",children:[r.jsx("h2",{className:"text-sm font-semibold text-cc-fg",children:"Installed Adapters"}),k]}),r.jsxs("section",{className:"bg-cc-card border border-cc-border rounded-xl p-4 sm:p-5 space-y-3",children:[r.jsx("h2",{className:"text-sm font-semibold text-cc-fg",children:"Install Adapter"}),N]})]})]})}):null}function ZF({onClose:e,embedded:t=!1}){const[s,n]=w.useState(null),[a,l]=w.useState(""),[c,d]=w.useState([]),[f,h]=w.useState(!1),[m,g]=w.useState(null),[_,v]=w.useState(new Map),[y,S]=w.useState("");w.useEffect(()=>{ne.getClawHubStatus().then(E=>n(E.available)).catch(()=>n(!1))},[]);const j=w.useCallback(async()=>{if(a.trim()){h(!0),S("");try{const E=await ne.searchClawHub(a.trim());d(E)}catch(E){S(E instanceof Error?E.message:String(E))}finally{h(!1)}}},[a]);async function k(E){g(E),v(B=>{const F=new Map(B);return F.delete(E),F});try{const B=await ne.installClawHubSkill(E);v(F=>new Map(F).set(E,B.ok))}catch{v(B=>new Map(B).set(E,!1))}finally{g(null)}}if(s===null)return r.jsx("div",{className:"text-sm text-cc-muted text-center py-10",children:"Checking ClawHub availability..."});if(!s)return r.jsx("div",{className:"h-full bg-cc-bg overflow-y-auto",children:r.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-8 py-6 sm:py-10",children:[r.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"ClawHub Skills"}),r.jsxs("div",{className:"mt-4 p-6 bg-cc-card border border-cc-border rounded-xl text-center",children:[r.jsxs("p",{className:"text-sm text-cc-muted mb-3",children:["The ",r.jsx("code",{className:"text-cc-fg bg-cc-hover px-1 rounded",children:"clawhub"})," CLI is not installed."]}),r.jsxs("p",{className:"text-xs text-cc-muted",children:["Install it with: ",r.jsx("code",{className:"text-cc-fg bg-cc-hover px-1 rounded",children:"npm install -g clawhub"})]})]})]})});const N=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"mb-6",children:[r.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"ClawHub Skills"}),r.jsx("p",{className:"mt-1 text-sm text-cc-muted",children:"Browse and install skills from the OpenClaw skill marketplace."})]}),y&&r.jsx("div",{className:"mb-4 px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:y}),r.jsxs("div",{className:"flex gap-2 mb-4",children:[r.jsx("input",{type:"text",value:a,onChange:E=>l(E.target.value),onKeyDown:E=>E.key==="Enter"&&j(),placeholder:"Search skills (e.g. 'code review', 'email', 'slack')",className:"flex-1 px-3 py-2 text-sm bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/50"}),r.jsx("button",{onClick:j,disabled:f||!a.trim(),className:`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${!f&&a.trim()?"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:f?"Searching...":"Search"})]}),c.length>0?r.jsx("div",{className:"space-y-3",children:c.map(E=>r.jsx("div",{className:"border border-cc-border rounded-lg overflow-hidden bg-cc-card",children:r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm font-medium text-cc-fg",children:E.name}),r.jsxs("span",{className:"text-[10px] text-cc-muted bg-cc-hover px-1.5 py-0.5 rounded",children:["v",E.version]})]}),r.jsx("p",{className:"text-xs text-cc-muted mt-0.5 truncate",children:E.description}),r.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[10px] text-cc-muted",children:[E.author&&r.jsxs("span",{children:["by ",E.author]}),E.downloads!==void 0&&r.jsxs("span",{children:[E.downloads.toLocaleString()," downloads"]})]})]}),r.jsx("button",{onClick:()=>k(E.name),disabled:m===E.name,className:`shrink-0 px-3 py-1.5 text-xs font-medium rounded-lg transition-colors ${m===E.name?"bg-cc-hover text-cc-muted cursor-not-allowed":_.get(E.name)===!0?"bg-cc-success/20 text-cc-success cursor-default":_.get(E.name)===!1?"bg-cc-error/20 text-cc-error cursor-pointer":"bg-cc-primary/20 text-cc-primary hover:bg-cc-primary/30 cursor-pointer"}`,children:m===E.name?"Installing...":_.get(E.name)===!0?"Installed":_.get(E.name)===!1?"Failed — Retry":"Install"})]})},E.name))}):!f&&a?r.jsxs("div",{className:"text-sm text-cc-muted text-center py-8",children:["No skills found for “",a,"”"]}):f?null:r.jsx("div",{className:"text-sm text-cc-muted text-center py-8",children:"Enter a search term to browse ClawHub skills."})]});return t?r.jsx("div",{className:"h-full bg-cc-bg overflow-y-auto",children:r.jsx("div",{className:"max-w-5xl mx-auto px-4 sm:px-8 py-6 sm:py-10",children:N})}):null}const eH=w.lazy(()=>Xi(()=>Promise.resolve().then(()=>hu),void 0).then(e=>({default:e.CodeEditor})));function wN(e){const t=Date.now()-e,s=Math.floor(t/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const n=Math.floor(s/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function tH(e){const t=e-Date.now();if(t<=0)return"now";const s=Math.floor(t/6e4);if(s<60)return`in ${s}m`;const n=Math.floor(s/60);return n<24?`in ${n}h`:`in ${Math.floor(n/24)}d`}const sH={claude:"text-[#5BA8A0] bg-[#5BA8A0]/10",codex:"text-blue-500 bg-blue-500/10",goose:"text-amber-500 bg-amber-500/10",aider:"text-purple-500 bg-purple-500/10",openhands:"text-rose-500 bg-rose-500/10",openclaw:"text-orange-500 bg-orange-500/10",opencode:"text-teal-500 bg-teal-500/10"},nH=[{value:"claude",label:"Claude"},{value:"codex",label:"Codex"},{value:"goose",label:"Goose"},{value:"aider",label:"Aider"},{value:"openhands",label:"OpenHands"},{value:"openclaw",label:"OpenClaw"},{value:"opencode",label:"OpenCode"}],cS={name:"",description:"",icon:"🤖",backendType:"claude",model:si("claude"),permissionMode:Jc("claude"),cwd:"",prompt:"",envSlug:"",webhookEnabled:!1,scheduleEnabled:!1,scheduleExpression:"0 8 * * *",scheduleRecurring:!0,codexInternetAccess:!1},rH=[{label:"Every hour",value:"0 * * * *"},{label:"Daily at 8am",value:"0 8 * * *"},{label:"Every 2 hours",value:"0 */2 * * *"},{label:"Weekdays at 9am",value:"0 9 * * 1-5"}],iH=["🤖","🔥","⚡","🚀","🧪","🔧","📋","🔍","🎯","📦"];function aH({embedded:e=!1}){var P;const[t,s]=w.useState([]),[n,a]=w.useState(!0),[l,c]=w.useState(""),[d,f]=w.useState(!1),[h,m]=w.useState(null),[g,_]=w.useState(cS),[v,y]=w.useState(!1),[S,j]=w.useState(null),[k,N]=w.useState(""),[E,B]=w.useState(null),[F,$]=w.useState([]),[K,Y]=w.useState("all"),[W,L]=w.useState([]),Q=w.useCallback(()=>{ne.listAgents().then(s).catch(()=>{}).finally(()=>a(!1))},[]);w.useEffect(()=>{Q(),ne.listEnvs().then(L).catch(()=>{});const z=setInterval(Q,1e4);return()=>clearInterval(z)},[Q]),w.useEffect(()=>{E&&ne.getAgentExecutions(E).then($).catch(()=>$([]))},[E]);function V(){m(null),_(cS),f(!0),c("")}function X(z){var T,oe,be,re,ve,Te,Re,je;m(z.id),_({name:z.name,description:z.description,icon:z.icon||"🤖",backendType:z.backendType,model:z.model,permissionMode:z.permissionMode,cwd:z.cwd,prompt:z.prompt,envSlug:z.envSlug||"",webhookEnabled:((oe=(T=z.triggers)==null?void 0:T.webhook)==null?void 0:oe.enabled)||!1,scheduleEnabled:((re=(be=z.triggers)==null?void 0:be.schedule)==null?void 0:re.enabled)||!1,scheduleExpression:((Te=(ve=z.triggers)==null?void 0:ve.schedule)==null?void 0:Te.expression)||"0 8 * * *",scheduleRecurring:((je=(Re=z.triggers)==null?void 0:Re.schedule)==null?void 0:je.recurring)??!0,codexInternetAccess:z.codexInternetAccess||!1}),f(!0),c("")}async function q(){if(!g.name.trim()||!g.prompt.trim()||!g.cwd.trim()){c("Name, prompt, and working directory are required");return}y(!0),c("");const z={name:g.name,description:g.description,icon:g.icon,backendType:g.backendType,model:g.backendType==="codex"?"":g.model,permissionMode:g.permissionMode,cwd:g.cwd,prompt:g.prompt,envSlug:g.envSlug||void 0,codexInternetAccess:g.backendType==="codex"?g.codexInternetAccess:void 0,triggers:{webhook:{enabled:g.webhookEnabled},schedule:g.scheduleEnabled?{enabled:!0,expression:g.scheduleExpression,recurring:g.scheduleRecurring}:{enabled:!1,expression:"",recurring:!0}}};try{h?await ne.updateAgentProfile(h,z):await ne.createAgent(z),f(!1),m(null),Q()}catch(T){c(T instanceof Error?T.message:"Unknown error")}finally{y(!1)}}async function A(z){try{await ne.deleteAgent(z),Q()}catch{}}async function M(z){try{await ne.toggleAgent(z),Q()}catch{}}async function O(z){if(z.prompt.includes("{{input}}"))j(z),N("");else try{await ne.runAgent(z.id),Q()}catch{}}async function U(){if(S)try{await ne.runAgent(S.id,k),j(null),Q()}catch{}}const I=t.filter(z=>{var T,oe,be,re;return K==="enabled"?z.enabled:K==="scheduled"?(oe=(T=z.triggers)==null?void 0:T.schedule)==null?void 0:oe.enabled:K==="webhook"?(re=(be=z.triggers)==null?void 0:be.webhook)==null?void 0:re.enabled:!0}),R={all:t.length,enabled:t.filter(z=>z.enabled).length,scheduled:t.filter(z=>{var T,oe;return(oe=(T=z.triggers)==null?void 0:T.schedule)==null?void 0:oe.enabled}).length,webhook:t.filter(z=>{var T,oe;return(oe=(T=z.triggers)==null?void 0:T.webhook)==null?void 0:oe.enabled}).length};return r.jsxs("div",{className:e?"px-4 py-6 max-w-4xl mx-auto":"p-6 max-w-4xl mx-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Agents"}),r.jsx("p",{className:"text-[12px] text-cc-muted mt-0.5",children:"Persistent agent profiles with automated triggers"})]}),r.jsx("button",{onClick:V,className:"px-3 py-1.5 rounded-lg bg-cc-primary text-white text-[12px] font-medium hover:bg-cc-primary-hover transition-colors cursor-pointer",children:"+ Create Agent"})]}),r.jsx("div",{className:"flex gap-1 mb-4",children:["all","enabled","scheduled","webhook"].map(z=>r.jsxs("button",{onClick:()=>Y(z),className:`px-2.5 py-1 rounded-md text-[11px] font-medium transition-colors cursor-pointer ${K===z?"bg-cc-primary/10 text-cc-primary":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:[z.charAt(0).toUpperCase()+z.slice(1),r.jsx("span",{className:"ml-1 text-[10px] opacity-60 tabular-nums",children:R[z]})]},z))}),n&&r.jsx("p",{className:"text-cc-muted text-sm",children:"Loading..."}),!n&&I.length===0&&r.jsxs("div",{className:"text-center py-12 text-cc-muted",children:[r.jsx("p",{className:"text-sm",children:"No agents yet"}),r.jsx("p",{className:"text-xs mt-1",children:"Create your first agent to automate tasks across any backend"})]}),r.jsx("div",{className:"space-y-2",children:I.map(z=>r.jsxs("div",{children:[r.jsx(uH,{agent:z,onEdit:()=>X(z),onDelete:()=>A(z.id),onToggle:()=>M(z.id),onRun:()=>O(z),expanded:E===z.id,onExpand:()=>B(E===z.id?null:z.id)}),E===z.id&&r.jsxs("div",{className:"ml-8 mt-1 mb-3 space-y-1",children:[F.length===0&&r.jsx("p",{className:"text-[11px] text-cc-muted",children:"No executions yet"}),F.slice(0,10).map(T=>r.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-cc-muted px-2 py-1 rounded bg-cc-hover/50",children:[r.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${oH(T)}`}),r.jsx("span",{className:"font-mono-code",children:T.trigger}),r.jsx("span",{className:"flex-1 truncate",children:T.input?`"${T.input.slice(0,40)}"`:""}),r.jsx("span",{className:"font-mono-code tabular-nums",children:wN(T.startedAt)}),T.error&&r.jsx("span",{className:"text-cc-error truncate max-w-[120px]",children:T.error})]},T.executionId))]})]},z.id))}),d&&r.jsx("dialog",{open:!0,className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 backdrop-blur-sm w-full h-full m-0 p-0 border-none",children:r.jsxs("div",{className:"w-full max-w-lg max-h-[85vh] overflow-y-auto bg-cc-card border border-cc-border rounded-xl shadow-float p-5 m-auto",children:[r.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-4",children:h?"Edit Agent":"Create Agent"}),l&&r.jsx("p",{className:"text-[11px] text-cc-error mb-3 bg-cc-error/5 px-3 py-1.5 rounded",children:l}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx("select",{value:g.icon,onChange:z=>_({...g,icon:z.target.value}),className:"w-12 h-9 rounded-lg border border-cc-border bg-cc-input-bg text-center text-base cursor-pointer",children:iH.map(z=>r.jsx("option",{value:z,children:z},z))}),r.jsx("input",{value:g.name,onChange:z=>_({...g,name:z.target.value}),placeholder:"Agent name",className:"flex-1 h-9 px-3 rounded-lg border border-cc-border bg-cc-input-bg text-[13px] text-cc-fg"})]}),r.jsx("input",{value:g.description,onChange:z=>_({...g,description:z.target.value}),placeholder:"Short description (optional)",className:"w-full h-9 px-3 rounded-lg border border-cc-border bg-cc-input-bg text-[13px] text-cc-fg"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("select",{value:g.backendType,onChange:z=>{const T=z.target.value;_({...g,backendType:T,model:si(T),permissionMode:Jc(T)})},className:"h-9 px-2 rounded-lg border border-cc-border bg-cc-input-bg text-[12px] text-cc-fg cursor-pointer",children:nH.map(z=>r.jsx("option",{value:z.value,children:z.label},z.value))}),g.backendType==="codex"?r.jsx("div",{className:"flex-1 h-9 px-2 rounded-lg border border-cc-border bg-cc-input-bg text-[12px] text-cc-muted flex items-center",children:"Codex default"}):r.jsx("select",{value:g.model,onChange:z=>_({...g,model:z.target.value}),className:"flex-1 h-9 px-2 rounded-lg border border-cc-border bg-cc-input-bg text-[12px] text-cc-fg cursor-pointer",children:Yh(g.backendType).map(z=>r.jsx("option",{value:z.value,children:z.label},z.value))})]}),r.jsx("select",{value:g.permissionMode,onChange:z=>_({...g,permissionMode:z.target.value}),className:"w-full h-9 px-2 rounded-lg border border-cc-border bg-cc-input-bg text-[12px] text-cc-fg cursor-pointer",children:Sx(g.backendType).map(z=>r.jsx("option",{value:z.value,children:z.label},z.value))}),r.jsx("input",{value:g.cwd,onChange:z=>_({...g,cwd:z.target.value}),placeholder:"Working directory (absolute path)",className:"w-full h-9 px-3 rounded-lg border border-cc-border bg-cc-input-bg text-[13px] text-cc-fg font-mono-code"}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("label",{htmlFor:"agent-env-select",className:"text-[11px] text-cc-muted font-medium",children:"Environment"}),g.backendType==="codex"&&!g.envSlug&&r.jsx("span",{className:"text-[9px] text-cc-warning font-medium px-1.5 rounded-full bg-cc-warning/10",children:"Codex requires OPENAI_API_KEY"})]}),r.jsxs("select",{id:"agent-env-select",value:g.envSlug,onChange:z=>_({...g,envSlug:z.target.value}),className:`w-full h-9 px-2 rounded-lg border bg-cc-input-bg text-[12px] text-cc-fg cursor-pointer ${g.backendType==="codex"&&!g.envSlug?"border-cc-warning/50":"border-cc-border"}`,children:[r.jsx("option",{value:"",children:"No environment profile"}),W.map(z=>r.jsxs("option",{value:z.slug,children:[z.name," (",Object.keys(z.variables).length," vars)"]},z.slug))]}),g.envSlug&&W.length>0&&r.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1",children:Object.keys(((P=W.find(z=>z.slug===g.envSlug))==null?void 0:P.variables)||{}).map(z=>r.jsx("span",{className:"text-[9px] font-mono-code px-1.5 py-0.5 rounded bg-cc-hover text-cc-muted",children:z},z))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[11px] font-medium text-cc-muted block mb-1",children:"Prompt"}),r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"h-[180px] rounded-xl border border-cc-border flex items-center justify-center text-cc-muted text-[12px]",children:"Loading editor..."}),children:r.jsx(eH,{value:g.prompt,onChange:z=>_({...g,prompt:z}),language:"markdown",height:"180px",minimap:!1,wordWrap:!0,ariaLabel:"Agent prompt editor. Use {{input}} as a placeholder for trigger input."})})]}),g.backendType==="codex"&&r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:g.codexInternetAccess,onChange:z=>_({...g,codexInternetAccess:z.target.checked}),className:"rounded"}),r.jsx("span",{className:"text-[12px] text-cc-fg",children:"Enable internet access (Codex)"})]}),r.jsxs("div",{className:"border border-cc-border/50 rounded-lg p-3 space-y-2.5",children:[r.jsx("span",{className:"text-[11px] font-semibold text-cc-muted uppercase tracking-wider",children:"Triggers"}),r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:g.webhookEnabled,onChange:z=>_({...g,webhookEnabled:z.target.checked}),className:"rounded"}),r.jsx("span",{className:"text-[12px] text-cc-fg",children:"Webhook"})]}),r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:g.scheduleEnabled,onChange:z=>_({...g,scheduleEnabled:z.target.checked}),className:"rounded"}),r.jsx("span",{className:"text-[12px] text-cc-fg",children:"Schedule"})]}),g.scheduleEnabled&&r.jsxs("div",{className:"ml-5 space-y-2",children:[r.jsx("div",{className:"flex gap-1.5 flex-wrap",children:rH.map(z=>r.jsx("button",{type:"button",onClick:()=>_({...g,scheduleExpression:z.value}),className:`px-2 py-0.5 rounded text-[10px] transition-colors cursor-pointer ${g.scheduleExpression===z.value?"bg-cc-primary/10 text-cc-primary":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:z.label},z.value))}),r.jsx("input",{value:g.scheduleExpression,onChange:z=>_({...g,scheduleExpression:z.target.value}),placeholder:"Cron expression",className:"w-full h-8 px-2 rounded border border-cc-border bg-cc-input-bg text-[12px] text-cc-fg font-mono-code"})]})]})]}),r.jsxs("div",{className:"flex justify-end gap-2 mt-5",children:[r.jsx("button",{onClick:()=>f(!1),className:"px-3 py-1.5 rounded-lg text-[12px] text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Cancel"}),r.jsx("button",{onClick:q,disabled:v,className:"px-4 py-1.5 rounded-lg bg-cc-primary text-white text-[12px] font-medium hover:bg-cc-primary-hover transition-colors cursor-pointer disabled:opacity-40",children:lH(v,h)})]})]})}),S&&r.jsx("dialog",{open:!0,className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 backdrop-blur-sm w-full h-full m-0 p-0 border-none",children:r.jsxs("div",{className:"w-full max-w-md bg-cc-card border border-cc-border rounded-xl shadow-float p-5 m-auto",children:[r.jsxs("h2",{className:"text-sm font-semibold text-cc-fg mb-1",children:["Run ",S.name]}),r.jsxs("p",{className:"text-[11px] text-cc-muted mb-3",children:["This agent uses ","{{input}}"," in its prompt. Provide the input below."]}),r.jsx("textarea",{value:k,onChange:z=>N(z.target.value),placeholder:"Enter input...",rows:4,className:"w-full px-3 py-2 rounded-lg border border-cc-border bg-cc-input-bg text-[13px] text-cc-fg resize-y",autoFocus:!0}),r.jsxs("div",{className:"flex justify-end gap-2 mt-3",children:[r.jsx("button",{onClick:()=>j(null),className:"px-3 py-1.5 rounded-lg text-[12px] text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Cancel"}),r.jsx("button",{onClick:U,className:"px-4 py-1.5 rounded-lg bg-cc-primary text-white text-[12px] font-medium hover:bg-cc-primary-hover transition-colors cursor-pointer",children:"Run"})]})]})})]})}function oH(e){return e.success===!1?"bg-cc-error":e.completedAt?"bg-cc-success":"bg-cc-primary animate-breathing"}function lH(e,t){return e?"Saving...":t?"Update":"Create"}function cH(e){return e.isRunning?"bg-cc-primary animate-breathing":e.enabled?"bg-cc-success":"bg-cc-muted/40"}function uH({agent:e,onEdit:t,onDelete:s,onToggle:n,onRun:a,expanded:l,onExpand:c}){var f,h,m,g;const d=sH[e.backendType]||"text-cc-muted bg-cc-hover";return r.jsx("div",{className:`border rounded-lg transition-all ${e.enabled?"border-cc-border bg-cc-card hover:shadow-panel":"border-cc-border/50 bg-cc-card/60 opacity-70"}`,children:r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[r.jsxs("button",{onClick:c,className:"relative text-lg shrink-0 cursor-pointer",title:"Show executions",children:[e.icon||"🤖",r.jsx("span",{className:`absolute -bottom-0.5 -right-0.5 w-2 h-2 rounded-full border border-cc-card ${cH(e)}`})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[13px] font-medium text-cc-fg truncate",children:e.name}),r.jsx("span",{className:`text-[9px] font-medium px-1.5 rounded-full leading-[16px] ${d}`,children:e.backendType}),e.isRunning&&r.jsx("span",{className:"text-[9px] text-cc-primary font-mono-code",children:"running"})]}),r.jsxs("div",{className:"flex items-center gap-2 mt-0.5 text-[10px] text-cc-muted",children:[e.description&&r.jsx("span",{className:"truncate max-w-[200px]",children:e.description}),((h=(f=e.triggers)==null?void 0:f.schedule)==null?void 0:h.enabled)&&r.jsx("span",{className:"font-mono-code",children:"scheduled"}),((g=(m=e.triggers)==null?void 0:m.webhook)==null?void 0:g.enabled)&&r.jsx("span",{className:"font-mono-code",children:"webhook"}),e.totalRuns>0&&r.jsxs("span",{className:"tabular-nums",children:[e.totalRuns," runs"]}),e.lastRunAt!=null&&r.jsx("span",{className:"tabular-nums",children:wN(e.lastRunAt)}),e.nextRunAt!=null&&r.jsxs("span",{className:"tabular-nums",children:["next ",tH(e.nextRunAt)]})]})]}),r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx("button",{onClick:a,title:"Run now",className:"p-1.5 rounded-md hover:bg-cc-hover transition-colors cursor-pointer text-cc-primary",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M4 2l10 6-10 6V2z"})})}),r.jsx("button",{onClick:n,title:e.enabled?"Disable":"Enable",className:"p-1.5 rounded-md hover:bg-cc-hover transition-colors cursor-pointer text-cc-muted",children:e.enabled?r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-success",children:r.jsx("path",{d:"M8 2a6 6 0 100 12A6 6 0 008 2zm3.22 4.78l-4 4a.75.75 0 01-1.06 0l-2-2a.75.75 0 011.06-1.06L6.5 9l3.47-3.47a.75.75 0 011.06 1.06z"})}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M8 2a6 6 0 100 12A6 6 0 008 2zm0 1.5a4.5 4.5 0 110 9 4.5 4.5 0 010-9z"})})}),r.jsx("button",{onClick:t,title:"Edit",className:"p-1.5 rounded-md hover:bg-cc-hover transition-colors cursor-pointer text-cc-muted",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61z"})})}),r.jsx("button",{onClick:s,title:"Delete",className:"p-1.5 rounded-md hover:bg-cc-hover transition-colors cursor-pointer text-cc-muted hover:text-cc-error",children:r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M6.5 1.75a.25.25 0 01.25-.25h2.5a.25.25 0 01.25.25V3h-3V1.75zM11 3V1.75A1.75 1.75 0 009.25 0h-2.5A1.75 1.75 0 005 1.75V3H2.75a.75.75 0 000 1.5h.928l.856 10.268A1.75 1.75 0 006.282 16h3.436a1.75 1.75 0 001.748-1.632l.856-10.268h.928a.75.75 0 000-1.5H11z"})})})]})]})})}function dH(e){return e===0?"$0":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function hH(e){if(e<6e4)return`${Math.round(e/1e3)}s`;const t=Math.floor(e/6e4);return t<60?`${t}m`:`${Math.floor(t/60)}h ${t%60}m`}let fH=0;function uS(){return`public-replay-${++fH}`}function pH(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function mH(e,t){var s;if(e.type==="user_message")return{id:e.id||uS(),role:"user",content:e.content||"",timestamp:e.timestamp||0};if(e.type==="assistant"){const n=e.message;return n?{id:n.id||uS(),role:"assistant",content:pH(n.content||[]),contentBlocks:n.content,timestamp:e.timestamp||0,parentToolUseId:e.parent_tool_use_id,model:n.model,stopReason:n.stop_reason}:null}if(e.type==="result"){const n=e.data;if(n!=null&&n.is_error&&((s=n.errors)!=null&&s.length))return{id:`replay-error-${t}`,role:"system",content:`Error: ${n.errors.join(", ")}`,timestamp:0}}return null}function gH({token:e}){const[t,s]=w.useState(null),[n,a]=w.useState(""),[l,c]=w.useState(!0),[d,f]=w.useState(0),[h,m]=w.useState(!1),[g,_]=w.useState(1),v=w.useRef(null),y=`public-replay-${e}`,S=G(E=>E.setMessages);w.useEffect(()=>{ne.getPublicReplay(e).then(E=>{const F=E.messages.map(($,K)=>mH($,K)).filter($=>$!==null);s({messages:F,gallery:E.gallery})}).catch(E=>a(E instanceof Error?E.message:String(E))).finally(()=>c(!1))},[e]),w.useEffect(()=>{if(!t)return;const E=t.messages.slice(0,d);S(y,E)},[t,d,y,S]),w.useEffect(()=>{if(!(!h||!t))return v.current=setInterval(()=>{f(E=>E>=t.messages.length?(m(!1),E):E+1)},300/g),()=>{v.current&&clearInterval(v.current)}},[h,g,t]);const j=w.useCallback(()=>{t&&(d>=t.messages.length?(f(0),m(!0)):m(E=>!E))},[t,d]);if(l)return r.jsx("div",{className:"h-full bg-cc-bg flex items-center justify-center",children:r.jsx("span",{className:"text-sm text-cc-muted",children:"Loading replay..."})});if(n)return r.jsx("div",{className:"h-full bg-cc-bg flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-sm text-cc-error",children:n}),r.jsx("p",{className:"text-xs text-cc-muted mt-2",children:"This replay link may have expired or is invalid."})]})});if(!t)return null;const k=t.gallery,N=t.messages.length>0?d/t.messages.length*100:0;return r.jsxs("div",{className:"h-full bg-cc-bg flex flex-col",children:[r.jsx("div",{className:"border-b border-cc-border bg-cc-card px-4 py-3",children:r.jsxs("div",{className:"max-w-5xl mx-auto",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"text-lg font-semibold text-cc-fg",children:(k==null?void 0:k.name)||"Session Replay"}),r.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-cc-hover text-cc-muted font-medium",children:"Public Replay"})]}),k&&r.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-1.5 text-xs text-cc-muted",children:[k.backendType&&r.jsx("span",{className:"font-medium px-1.5 rounded-full bg-cc-hover",children:k.backendType}),k.model&&r.jsx("span",{children:k.model}),k.totalCostUsd!=null&&k.totalCostUsd>0&&r.jsx("span",{children:dH(k.totalCostUsd)}),k.numTurns!=null&&k.numTurns>0&&r.jsxs("span",{children:[k.numTurns," turns"]}),k.durationMs!=null&&k.durationMs>0&&r.jsx("span",{children:hH(k.durationMs)}),k.tags&&k.tags.length>0&&r.jsx("span",{children:k.tags.join(", ")})]}),(k==null?void 0:k.description)&&r.jsx("p",{className:"text-xs text-cc-muted mt-1",children:k.description})]})}),r.jsx("div",{className:"border-b border-cc-border bg-cc-card px-4 py-2",children:r.jsxs("div",{className:"max-w-5xl mx-auto flex items-center gap-3",children:[r.jsx("button",{onClick:j,className:"w-8 h-8 flex items-center justify-center rounded-lg bg-cc-primary text-white hover:bg-cc-primary-hover transition-colors cursor-pointer",children:h?r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M5.5 3.5A1.5 1.5 0 017 5v6a1.5 1.5 0 01-3 0V5a1.5 1.5 0 011.5-1.5zm5 0A1.5 1.5 0 0112 5v6a1.5 1.5 0 01-3 0V5a1.5 1.5 0 011.5-1.5z"})}):r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:r.jsx("path",{d:"M4.5 3.5A.5.5 0 015.22 3l7 4.5a.5.5 0 010 .86l-7 4.5A.5.5 0 014.5 12.5v-9z"})})}),r.jsx("div",{className:"flex-1 h-1.5 bg-cc-hover rounded-full overflow-hidden cursor-pointer",onClick:E=>{const B=E.currentTarget.getBoundingClientRect(),F=(E.clientX-B.left)/B.width;f(Math.round(F*t.messages.length))},children:r.jsx("div",{className:"h-full bg-cc-primary rounded-full transition-all",style:{width:`${N}%`}})}),r.jsxs("span",{className:"text-[10px] text-cc-muted tabular-nums",children:[d,"/",t.messages.length]}),r.jsxs("button",{onClick:()=>_(E=>E>=8?1:E*2),className:"px-2 py-1 text-[10px] font-medium bg-cc-hover rounded text-cc-muted hover:text-cc-fg transition-colors cursor-pointer",children:[g,"x"]})]})}),r.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:r.jsx(Y0,{sessionId:y})})]})}const Mg={name:"",content:"",scope:"global",projectPath:""};function xH({embedded:e}){const[t,s]=w.useState([]),[n,a]=w.useState(!0),[l,c]=w.useState(null),[d,f]=w.useState(""),[h,m]=w.useState(!1),[g,_]=w.useState(null),[v,y]=w.useState(Mg),[S,j]=w.useState(!1),[k,N]=w.useState(null),E=w.useCallback(async()=>{a(!0),c(null);try{const L=await ne.listPrompts();s(L)}catch{c("Failed to load prompts.")}finally{a(!1)}},[]);w.useEffect(()=>{E()},[E]);const B=t.filter(L=>!d||L.name.toLowerCase().includes(d.toLowerCase())||L.content.toLowerCase().includes(d.toLowerCase()));function F(){_(null),y(Mg),N(null),m(!0)}function $(L){_(L.id),y({name:L.name,content:L.content,scope:L.scope,projectPath:L.projectPath??""}),N(null),m(!0)}function K(){m(!1),_(null),y(Mg),N(null)}async function Y(){if(!v.name.trim()||!v.content.trim()){N("Name and content are required.");return}j(!0),N(null);try{g?await ne.updatePrompt(g,{name:v.name.trim(),content:v.content.trim(),scope:v.scope,projectPath:v.scope==="project"&&v.projectPath.trim()||void 0}):await ne.createPrompt({name:v.name.trim(),content:v.content.trim(),scope:v.scope,projectPath:v.scope==="project"&&v.projectPath.trim()||void 0}),K(),await E()}catch{N("Failed to save prompt.")}finally{j(!1)}}async function W(L){if(confirm("Delete this prompt?"))try{await ne.deletePrompt(L),s(Q=>Q.filter(V=>V.id!==L))}catch{c("Failed to delete prompt.")}}return r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsxs("div",{className:"max-w-2xl mx-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-xl font-semibold text-cc-fg",children:"Prompt Library"}),r.jsx("p",{className:"text-sm text-cc-muted mt-0.5",children:"Save reusable prompts and insert them with @ in the composer."})]}),r.jsx("button",{onClick:F,className:"px-3 py-1.5 rounded-lg bg-cc-primary text-white text-sm font-medium hover:bg-cc-primary-hover transition-colors cursor-pointer",children:"+ New Prompt"})]}),r.jsx("div",{className:"mb-4",children:r.jsx("input",{type:"text",value:d,onChange:L=>f(L.target.value),placeholder:"Search prompts...",className:"w-full px-3 py-2 rounded-lg border border-cc-border bg-cc-input-bg text-cc-fg text-sm focus:outline-none focus:border-cc-primary/50"})}),h&&r.jsxs("div",{className:"mb-6 p-4 rounded-lg border border-cc-border bg-cc-card",children:[r.jsx("h3",{className:"text-sm font-medium text-cc-fg mb-3",children:g?"Edit Prompt":"New Prompt"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-cc-muted mb-1",children:"Name"}),r.jsx("input",{type:"text",value:v.name,onChange:L=>y(Q=>({...Q,name:L.target.value})),placeholder:"e.g. Code review checklist",className:"w-full px-3 py-1.5 rounded-lg border border-cc-border bg-cc-input-bg text-cc-fg text-sm focus:outline-none focus:border-cc-primary/50"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-cc-muted mb-1",children:"Content"}),r.jsx("textarea",{value:v.content,onChange:L=>y(Q=>({...Q,content:L.target.value})),placeholder:"The prompt text...",rows:5,className:"w-full px-3 py-1.5 rounded-lg border border-cc-border bg-cc-input-bg text-cc-fg text-sm font-mono-code resize-y focus:outline-none focus:border-cc-primary/50"})]}),r.jsxs("div",{className:"flex gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-cc-muted mb-1",children:"Scope"}),r.jsxs("select",{value:v.scope,onChange:L=>y(Q=>({...Q,scope:L.target.value})),className:"px-2 py-1.5 rounded-lg border border-cc-border bg-cc-input-bg text-cc-fg text-sm focus:outline-none focus:border-cc-primary/50",children:[r.jsx("option",{value:"global",children:"Global"}),r.jsx("option",{value:"project",children:"Project"})]})]}),v.scope==="project"&&r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-cc-muted mb-1",children:"Project path"}),r.jsx("input",{type:"text",value:v.projectPath,onChange:L=>y(Q=>({...Q,projectPath:L.target.value})),placeholder:"/home/user/my-project",className:"w-full px-3 py-1.5 rounded-lg border border-cc-border bg-cc-input-bg text-cc-fg text-sm font-mono-code focus:outline-none focus:border-cc-primary/50"})]})]}),k&&r.jsx("p",{className:"text-xs text-cc-error",children:k}),r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsx("button",{onClick:K,className:"px-3 py-1.5 rounded-lg border border-cc-border text-cc-muted text-sm hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Cancel"}),r.jsx("button",{onClick:Y,disabled:S,className:`px-3 py-1.5 rounded-lg text-sm font-medium transition-colors cursor-pointer ${S?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary text-white hover:bg-cc-primary-hover"}`,children:S?"Saving...":"Save"})]})]})]}),n?r.jsx("div",{className:"text-sm text-cc-muted",children:"Loading..."}):l?r.jsx("div",{className:"text-sm text-cc-error",children:l}):B.length===0?r.jsx("div",{className:"text-center py-12 text-cc-muted",children:d?r.jsxs("p",{className:"text-sm",children:['No prompts match "',d,'"']}):r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm mb-2",children:"No prompts yet."}),r.jsx("button",{onClick:F,className:"text-sm text-cc-primary hover:text-cc-primary-hover transition-colors cursor-pointer",children:"Create your first prompt"})]})}):r.jsx("div",{className:"space-y-2",children:B.map(L=>r.jsx("div",{className:"p-4 rounded-lg border border-cc-border bg-cc-card group",children:r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm font-medium text-cc-fg",children:L.name}),r.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-cc-hover text-cc-muted border border-cc-border capitalize",children:L.scope})]}),L.scope==="project"&&L.projectPath&&r.jsx("p",{className:"text-xs text-cc-muted font-mono-code mt-0.5",children:L.projectPath}),r.jsx("p",{className:"text-xs text-cc-muted mt-1 line-clamp-2 whitespace-pre-line",children:L.content})]}),r.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[r.jsx("button",{onClick:()=>$(L),className:"px-2 py-1 rounded text-xs text-cc-muted hover:text-cc-fg transition-colors cursor-pointer",children:"Edit"}),r.jsx("button",{onClick:()=>W(L.id),className:"px-2 py-1 rounded text-xs text-cc-error hover:text-cc-error/80 transition-colors cursor-pointer",children:"Delete"})]})]})},L.id))})]})})}function SN({className:e}){return r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:e,children:[r.jsx("circle",{cx:"12",cy:"12",r:"10",fill:"currentColor"}),r.jsx("path",{d:"M7.2 15.2l6.6-6.6",stroke:"white",strokeWidth:"2",strokeLinecap:"round"}),r.jsx("circle",{cx:"16.4",cy:"8.8",r:"1.8",fill:"white"})]})}function jN(e){window.location.hash=e}function vH({embedded:e}){const[t,s]=w.useState(!1),[n,a]=w.useState(!0);w.useEffect(()=>{ne.getSettings().then(c=>{c.linearApiKeyConfigured?ne.getLinearConnection().then(d=>s(d.connected)).catch(()=>s(!1)).finally(()=>a(!1)):a(!1)}).catch(()=>{a(!1)})},[]);const l=[{id:"linear",name:"Linear",description:"Browse issues and auto-generate branch names from Linear tickets.",icon:r.jsx(SN,{className:"w-8 h-8 text-[#5E6AD2]"}),route:"#/integrations/linear",connected:t,checking:n}];return r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsxs("div",{className:"max-w-2xl mx-auto",children:[r.jsx("h2",{className:"text-xl font-semibold text-cc-fg mb-2",children:"Integrations"}),r.jsx("p",{className:"text-sm text-cc-fg-muted mb-6",children:"Connect external services to enhance your sessions."}),r.jsx("div",{className:"grid gap-4",children:l.map(c=>r.jsxs("button",{onClick:()=>jN(c.route),className:"flex items-center gap-4 p-4 rounded-lg border border-cc-border bg-cc-bg-subtle hover:bg-cc-bg-hover text-left transition-colors group",children:[r.jsx("div",{className:"shrink-0",children:c.icon}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm font-medium text-cc-fg",children:c.name}),c.checking?r.jsx("span",{className:"text-xs text-cc-fg-muted",children:"checking…"}):c.connected?r.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-green-500/10 text-green-400 border border-green-500/20",children:"Connected"}):r.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-cc-fg-muted/10 text-cc-fg-muted border border-cc-border",children:"Not connected"})]}),r.jsx("p",{className:"text-xs text-cc-fg-muted mt-0.5",children:c.description})]}),r.jsx("div",{className:"text-cc-fg-muted group-hover:text-cc-fg transition-colors",children:"→"})]},c.id))})]})})}function bH({embedded:e}){const[t,s]=w.useState(""),[n,a]=w.useState(null),[l,c]=w.useState(!1),[d,f]=w.useState(!1),[h,m]=w.useState(null),[g,_]=w.useState(!1);w.useEffect(()=>{ne.getSettings().then(j=>{j.linearApiKeyConfigured&&v()}).catch(()=>{})},[]);async function v(){f(!0),m(null);try{const j=await ne.getLinearConnection();a(j)}catch{a({connected:!1}),m("Could not connect to Linear. Check your API key.")}finally{f(!1)}}async function y(){if(t.trim()){c(!0),m(null);try{await ne.updateSettings({linearApiKey:t.trim()}),s(""),_(!0),setTimeout(()=>_(!1),2e3),await v()}catch{m("Failed to save API key.")}finally{c(!1)}}}async function S(){c(!0),m(null);try{await ne.updateSettings({linearApiKey:""}),a(null)}catch{m("Failed to disconnect.")}finally{c(!1)}}return r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsxs("div",{className:"max-w-xl mx-auto",children:[r.jsx("div",{className:"flex items-center gap-3 mb-6",children:r.jsx("button",{onClick:()=>jN("#/integrations"),className:"text-cc-fg-muted hover:text-cc-fg transition-colors text-sm",children:"← Integrations"})}),r.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[r.jsx(SN,{className:"w-8 h-8 text-[#5E6AD2]"}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold text-cc-fg",children:"Linear"}),r.jsx("p",{className:"text-sm text-cc-fg-muted",children:"Connect your Linear workspace to browse issues"})]})]}),(n==null?void 0:n.connected)&&n.viewer&&r.jsx("div",{className:"mb-6 p-4 rounded-lg border border-green-500/20 bg-green-500/5",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs("p",{className:"text-sm font-medium text-cc-fg",children:["Connected as ",r.jsx("span",{className:"text-green-400",children:n.viewer.name})]}),r.jsx("p",{className:"text-xs text-cc-fg-muted",children:n.viewer.email}),n.teams&&n.teams.length>0&&r.jsxs("p",{className:"text-xs text-cc-fg-muted mt-1",children:["Teams: ",n.teams.map(j=>j.name).join(", ")]})]}),r.jsx("button",{onClick:S,disabled:l,className:"text-xs text-red-400 hover:text-red-300 transition-colors disabled:opacity-50",children:"Disconnect"})]})}),!(n!=null&&n.connected)&&r.jsxs("div",{className:"mb-6",children:[r.jsx("label",{className:"block text-sm font-medium text-cc-fg mb-2",children:"Linear API Key"}),r.jsxs("p",{className:"text-xs text-cc-fg-muted mb-3",children:["Create a personal API key at"," ",r.jsx("span",{className:"font-mono text-cc-accent",children:"linear.app/settings/api"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"password",value:t,onChange:j=>s(j.target.value),onKeyDown:j=>{j.key==="Enter"&&y()},placeholder:"lin_api_...",className:"flex-1 px-3 py-2 rounded-md border border-cc-border bg-cc-input text-cc-fg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-cc-accent"}),r.jsx("button",{onClick:y,disabled:l||!t.trim(),className:"px-4 py-2 rounded-md bg-cc-accent text-white text-sm font-medium hover:bg-cc-accent/90 disabled:opacity-50 transition-colors",children:l?"Saving…":g?"Saved!":"Connect"})]})]}),!n&&!d&&r.jsx("button",{onClick:v,className:"text-sm text-cc-accent hover:text-cc-accent/80 transition-colors",children:"Check connection"}),d&&r.jsx("p",{className:"text-sm text-cc-fg-muted",children:"Checking connection…"}),h&&r.jsx("p",{className:"text-sm text-red-400 mt-2",children:h}),r.jsxs("div",{className:"mt-8 p-4 rounded-lg border border-cc-border bg-cc-bg-subtle",children:[r.jsx("h3",{className:"text-sm font-medium text-cc-fg mb-2",children:"What this enables"}),r.jsxs("ul",{className:"text-xs text-cc-fg-muted space-y-1 list-disc list-inside",children:[r.jsx("li",{children:"Browse and search Linear issues when creating sessions"}),r.jsx("li",{children:"Auto-generate branch names from issue titles"}),r.jsx("li",{children:"Inject issue context as startup prompt for the agent"})]})]})]})})}function _H(){const e=G(N=>N.currentSessionId),[t,s]=w.useState([]),[n,a]=w.useState([]),[l,c]=w.useState(!1),[d,f]=w.useState("fragments"),[h,m]=w.useState(""),[g,_]=w.useState("");w.useEffect(()=>{e&&v()},[e]);async function v(){if(e){c(!0);try{const N=await ne.getSessionMemory(e);s(N.fragments||[]),a(N.consolidated||[])}catch(N){console.error("[MemoryPanel] Failed to load memory:",N)}finally{c(!1)}}}async function y(){if(!(!e||!h.trim())){c(!0);try{const N=await ne.queryMemory(e,h,20);s(N.results||[]),a(N.consolidated||[])}catch(N){console.error("[MemoryPanel] Failed to query memory:",N)}finally{c(!1)}}}async function S(){if(e){c(!0);try{await ne.consolidateMemory(e),await v()}catch(N){console.error("[MemoryPanel] Failed to consolidate memory:",N)}finally{c(!1)}}}const j=Array.from(new Set(t.flatMap(N=>N.tags))).sort(),k=g?t.filter(N=>N.tags.includes(g)):t;return e?r.jsxs("div",{className:"flex flex-col h-full bg-cc-bg",children:[r.jsxs("div",{className:"shrink-0 px-4 py-3 border-b border-cc-border",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h2",{className:"text-sm font-semibold text-cc-fg",children:"Semantic Memory"}),r.jsx("button",{onClick:S,disabled:l,className:"px-2 py-1 text-xs font-medium text-cc-primary hover:bg-cc-active rounded cursor-pointer disabled:opacity-50",children:l?"Consolidating...":"Consolidate"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"text",value:h,onChange:N=>m(N.target.value),onKeyDown:N=>N.key==="Enter"&&y(),placeholder:"Search memory...",className:"flex-1 px-3 py-1.5 text-sm bg-cc-card border border-cc-border rounded-lg text-cc-fg placeholder-cc-muted focus:outline-none focus:border-cc-primary"}),r.jsx("button",{onClick:y,className:"px-3 py-1.5 text-sm font-medium text-white bg-cc-primary hover:bg-cc-primary/90 rounded-lg cursor-pointer",children:"Search"})]}),r.jsxs("div",{className:"flex items-center gap-1 mt-3 bg-cc-hover rounded-lg p-0.5",children:[r.jsxs("button",{onClick:()=>f("fragments"),className:`flex-1 px-3 py-1 text-xs font-medium rounded-md transition-colors cursor-pointer ${d==="fragments"?"bg-cc-card text-cc-fg shadow-sm":"text-cc-muted hover:text-cc-fg"}`,children:["Fragments (",k.length,")"]}),r.jsxs("button",{onClick:()=>f("consolidated"),className:`flex-1 px-3 py-1 text-xs font-medium rounded-md transition-colors cursor-pointer ${d==="consolidated"?"bg-cc-card text-cc-fg shadow-sm":"text-cc-muted hover:text-cc-fg"}`,children:["Consolidated (",n.length,")"]})]})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[d==="fragments"&&r.jsxs("div",{className:"p-4 space-y-3",children:[j.length>0&&r.jsxs("div",{className:"flex flex-wrap gap-1.5 pb-2 border-b border-cc-border",children:[r.jsx("button",{onClick:()=>_(""),className:`px-2 py-0.5 text-xs rounded cursor-pointer ${g?"bg-cc-hover text-cc-muted hover:text-cc-fg":"bg-cc-primary text-white"}`,children:"All"}),j.map(N=>r.jsx("button",{onClick:()=>_(N),className:`px-2 py-0.5 text-xs rounded cursor-pointer ${g===N?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:N},N))]}),k.length===0?r.jsx("div",{className:"text-center py-8 text-cc-muted text-sm",children:l?"Loading...":"No memory fragments yet"}):k.map(N=>r.jsxs("div",{className:"p-3 bg-cc-card border border-cc-border rounded-lg",children:[r.jsxs("div",{className:"flex items-start justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`px-1.5 py-0.5 text-[10px] font-medium rounded ${N.type==="observation"?"bg-blue-500/20 text-blue-400":N.type==="hypothesis"?"bg-purple-500/20 text-purple-400":N.type==="decision"?"bg-green-500/20 text-green-400":"bg-yellow-500/20 text-yellow-400"}`,children:N.type}),r.jsx("span",{className:"text-xs text-cc-muted",children:new Date(N.timestamp).toLocaleString()})]}),r.jsxs("span",{className:"text-xs text-cc-muted font-mono",children:[(N.confidence*100).toFixed(0),"%"]})]}),r.jsx("p",{className:"text-sm text-cc-fg mb-2",children:N.content}),N.tags.length>0&&r.jsx("div",{className:"flex flex-wrap gap-1",children:N.tags.map(E=>r.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] bg-cc-hover text-cc-muted rounded",children:["#",E]},E))}),N.gitContext.files.length>0&&r.jsxs("div",{className:"mt-2 text-xs text-cc-muted font-mono",children:[N.gitContext.files.slice(0,2).join(", "),N.gitContext.files.length>2&&` +${N.gitContext.files.length-2} more`]})]},N.id))]}),d==="consolidated"&&r.jsx("div",{className:"p-4 space-y-3",children:n.length===0?r.jsx("div",{className:"text-center py-8 text-cc-muted text-sm",children:l?"Loading...":"No consolidated knowledge yet"}):n.map(N=>r.jsxs("div",{className:"p-3 bg-cc-card border border-cc-border rounded-lg",children:[r.jsxs("div",{className:"flex items-start justify-between mb-2",children:[r.jsxs("span",{className:"px-2 py-1 text-xs font-semibold bg-cc-primary/20 text-cc-primary rounded",children:["#",N.tag]}),r.jsxs("span",{className:"text-xs text-cc-muted",children:["Updated ",new Date(N.lastUpdated).toLocaleDateString()]})]}),r.jsx("p",{className:"text-sm text-cc-fg mb-2",children:N.summary}),r.jsxs("div",{className:"text-xs text-cc-muted",children:["Synthesized from ",N.sourceFragments.length," fragments"," · ","Confidence: ",(N.confidence*100).toFixed(0),"%"]})]},N.id))})]})]}):r.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-cc-muted",children:[r.jsx("svg",{className:"w-16 h-16 mb-4 opacity-20",viewBox:"0 0 24 24",fill:"currentColor",children:r.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),r.jsx("p",{className:"text-sm",children:"No session selected"}),r.jsx("p",{className:"text-xs text-cc-muted mt-1",children:"Select a session to view its semantic memory"})]})}function yH(){const e=G(k=>k.sdkSessions),[t,s]=w.useState([]),[n,a]=w.useState(""),[l,c]=w.useState([]),[d,f]=w.useState(null),[h,m]=w.useState(!1),[g,_]=w.useState(!1);w.useEffect(()=>{v()},[]);async function v(){_(!0);try{const k=await ne.getCapabilities();s(k.sessions||[]),c(k.sessions.map(N=>N.sessionId))}catch(k){console.error("[TaskRouterPage] Failed to load capabilities:",k)}finally{_(!1)}}async function y(){if(!(!n.trim()||l.length===0)){m(!0),f(null);try{const k=await ne.routeTask({taskDescription:n,availableSessions:l});f(k)}catch(k){console.error("[TaskRouterPage] Failed to route task:",k)}finally{m(!1)}}}function S(k){c(N=>N.includes(k)?N.filter(E=>E!==k):[...N,k])}function j(k){const N=e.find(E=>E.sessionId===k);return(N==null?void 0:N.name)||`Session ${k.slice(0,8)}`}return r.jsxs("div",{className:"flex h-full bg-cc-bg",children:[r.jsx("div",{className:"w-1/2 border-r border-cc-border overflow-y-auto",children:r.jsxs("div",{className:"p-6 space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Task Router"}),r.jsx("p",{className:"text-sm text-cc-muted mt-1",children:"Route complex tasks to the best-suited agent based on capabilities and historical performance"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-cc-fg mb-2",children:"Task Description"}),r.jsx("textarea",{value:n,onChange:k=>a(k.target.value),placeholder:"Describe the task you want to route... e.g., 'Refactor auth module to use JWT tokens with TypeScript strict mode'",className:"w-full px-3 py-2 text-sm bg-cc-card border border-cc-border rounded-lg text-cc-fg placeholder-cc-muted focus:outline-none focus:border-cc-primary resize-none",rows:4})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("label",{className:"text-sm font-medium text-cc-fg",children:["Available Sessions (",l.length,"/",t.length,")"]}),r.jsx("button",{onClick:()=>c(l.length===t.length?[]:t.map(k=>k.sessionId)),className:"text-xs text-cc-primary hover:underline cursor-pointer",children:l.length===t.length?"Deselect All":"Select All"})]}),g?r.jsx("div",{className:"text-sm text-cc-muted",children:"Loading capabilities..."}):t.length===0?r.jsx("div",{className:"text-sm text-cc-muted",children:"No active sessions with capabilities reported"}):r.jsx("div",{className:"space-y-2",children:t.map(k=>r.jsx("div",{onClick:()=>S(k.sessionId),className:`p-3 border rounded-lg cursor-pointer transition-colors ${l.includes(k.sessionId)?"bg-cc-active border-cc-primary":"bg-cc-card border-cc-border hover:border-cc-primary/50"}`,children:r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"text-sm font-medium text-cc-fg",children:j(k.sessionId)}),r.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-cc-hover text-cc-muted rounded",children:k.backendType})]}),k.strengths.length>0&&r.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:k.strengths.slice(0,5).map(N=>r.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-green-500/20 text-green-400 rounded",children:N},N))})]}),r.jsxs("div",{className:"text-xs text-cc-muted text-right",children:[r.jsxs("div",{children:[k.availableTools.length," tools"]}),r.jsxs("div",{children:[k.contextUsedPercent.toFixed(0),"% context"]})]})]})},k.sessionId))})]}),r.jsx("button",{onClick:y,disabled:!n.trim()||l.length===0||h,className:"w-full px-4 py-2 text-sm font-medium text-white bg-cc-primary hover:bg-cc-primary/90 rounded-lg cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:h?"Routing...":"Route Task"})]})}),r.jsx("div",{className:"w-1/2 overflow-y-auto",children:d?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-base font-semibold text-cc-fg",children:"Routing Result"}),r.jsx("p",{className:"text-sm text-cc-muted mt-1",children:"Best agent for this task"})]}),r.jsxs("div",{className:"p-4 bg-cc-card border-2 border-cc-primary rounded-lg",children:[r.jsxs("div",{className:"flex items-start justify-between mb-2",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("svg",{className:"w-5 h-5 text-cc-primary",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})}),r.jsx("span",{className:"text-base font-semibold text-cc-fg",children:j(d.sessionId)})]}),r.jsx("span",{className:"px-2 py-0.5 text-xs bg-cc-hover text-cc-muted rounded inline-block mt-1",children:d.backendType})]}),r.jsxs("div",{className:"text-right",children:[r.jsxs("div",{className:"text-2xl font-bold text-cc-primary",children:[(d.confidence*100).toFixed(0),"%"]}),r.jsx("div",{className:"text-xs text-cc-muted",children:"confidence"})]})]}),r.jsxs("div",{className:"mt-3 p-3 bg-cc-bg rounded border border-cc-border",children:[r.jsx("div",{className:"text-xs font-semibold text-cc-muted mb-1",children:"Reasoning:"}),r.jsx("p",{className:"text-sm text-cc-fg",children:d.reasoning})]})]}),d.alternatives.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-medium text-cc-fg mb-2",children:"Alternative Options"}),r.jsx("div",{className:"space-y-2",children:d.alternatives.map((k,N)=>r.jsx("div",{className:"p-3 bg-cc-card border border-cc-border rounded-lg",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-cc-fg",children:j(k.sessionId)}),r.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-cc-hover text-cc-muted rounded",children:k.backendType})]}),r.jsxs("span",{className:"text-sm font-semibold text-cc-muted",children:[(k.confidence*100).toFixed(0),"%"]})]})},N))})]})]}):r.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-cc-muted",children:[r.jsx("svg",{className:"w-16 h-16 mb-4 opacity-20",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M11.3 1.046A1 1 0 0112 2v5h4a1 1 0 01.82 1.573l-7 10A1 1 0 018 18v-5H4a1 1 0 01-.82-1.573l7-10a1 1 0 011.12-.38z",clipRule:"evenodd"})}),r.jsx("p",{className:"text-sm",children:"No routing result yet"}),r.jsx("p",{className:"text-xs text-cc-muted mt-1",children:"Describe a task and route it to see recommendations"})]})})]})}function wH(){const e=G(S=>S.currentSessionId),[t,s]=w.useState([]),[n,a]=w.useState(null),[l,c]=w.useState(!1),[d,f]=w.useState("stream"),[h,m]=w.useState("");w.useEffect(()=>{if(!e)return;g();const S=setInterval(g,5e3);return()=>clearInterval(S)},[e]);async function g(){if(e){c(!0);try{const[S,j]=await Promise.all([ne.getContextStream(e),ne.getConsensusState(e)]);s(S.fragments||[]),a(j)}catch(S){console.error("[CollectiveMindPanel] Failed to load context:",S)}finally{c(!1)}}}if(!e)return r.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-cc-muted",children:[r.jsx("svg",{className:"w-16 h-16 mb-4 opacity-20",viewBox:"0 0 24 24",fill:"currentColor",children:r.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),r.jsx("p",{className:"text-sm",children:"No session selected"}),r.jsx("p",{className:"text-xs text-cc-muted mt-1",children:"Select a session to view its collective reasoning"})]});const _=Array.from(new Set(t.map(S=>S.type))).sort(),y=[...h?t.filter(S=>S.type===h):t].sort((S,j)=>j.timestamp-S.timestamp);return r.jsxs("div",{className:"flex flex-col h-full bg-cc-bg",children:[r.jsxs("div",{className:"shrink-0 px-4 py-3 border-b border-cc-border",children:[r.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-3",children:"Collective Mind"}),r.jsxs("div",{className:"flex items-center gap-1 bg-cc-hover rounded-lg p-0.5",children:[r.jsxs("button",{onClick:()=>f("stream"),className:`flex-1 px-3 py-1 text-xs font-medium rounded-md transition-colors cursor-pointer ${d==="stream"?"bg-cc-card text-cc-fg shadow-sm":"text-cc-muted hover:text-cc-fg"}`,children:["Thought Stream (",t.length,")"]}),r.jsx("button",{onClick:()=>f("consensus"),className:`flex-1 px-3 py-1 text-xs font-medium rounded-md transition-colors cursor-pointer ${d==="consensus"?"bg-cc-card text-cc-fg shadow-sm":"text-cc-muted hover:text-cc-fg"}`,children:"Consensus"})]})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[d==="stream"&&r.jsxs("div",{className:"p-4 space-y-3",children:[_.length>0&&r.jsxs("div",{className:"flex flex-wrap gap-1.5 pb-2 border-b border-cc-border",children:[r.jsx("button",{onClick:()=>m(""),className:`px-2 py-0.5 text-xs rounded cursor-pointer ${h?"bg-cc-hover text-cc-muted hover:text-cc-fg":"bg-cc-primary text-white"}`,children:"All"}),_.map(S=>r.jsx("button",{onClick:()=>m(S),className:`px-2 py-0.5 text-xs rounded cursor-pointer ${h===S?"bg-cc-primary text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:S},S))]}),y.length===0?r.jsx("div",{className:"text-center py-8 text-cc-muted text-sm",children:l?"Loading...":"No thoughts in the stream yet"}):r.jsx("div",{className:"space-y-3",children:y.map(S=>r.jsxs("div",{className:`p-3 rounded-lg border ${S.consensusScore>.7?"bg-green-500/5 border-green-500/30":S.isControversial?"bg-orange-500/5 border-orange-500/30":"bg-cc-card border-cc-border"}`,children:[r.jsxs("div",{className:"flex items-start justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-2 h-2 rounded-full ${S.isHuman?"bg-blue-400":"bg-purple-400"}`}),r.jsxs("span",{className:"text-xs text-cc-muted",children:[S.isHuman?"Human":"Agent"," · ",S.agentId.slice(0,8)]}),r.jsx("span",{className:`px-1.5 py-0.5 text-[10px] font-medium rounded ${S.type==="thought"?"bg-purple-500/20 text-purple-400":S.type==="observation"?"bg-blue-500/20 text-blue-400":S.type==="plan"?"bg-green-500/20 text-green-400":S.type==="question"?"bg-yellow-500/20 text-yellow-400":S.type==="answer"?"bg-teal-500/20 text-teal-400":S.type==="insight"?"bg-pink-500/20 text-pink-400":"bg-red-500/20 text-red-400"}`,children:S.type}),r.jsx("span",{className:"text-xs text-cc-muted",children:new Date(S.timestamp).toLocaleTimeString()})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[S.consensusScore>0&&r.jsxs("span",{className:"text-xs text-cc-muted font-mono",children:[(S.consensusScore*100).toFixed(0),"% agree"]}),S.isControversial&&r.jsx("span",{className:"text-xs text-orange-400",children:"⚠ Controversial"})]})]}),r.jsx("p",{className:"text-sm text-cc-fg mb-2",children:S.content}),S.semanticLinks.length>0&&r.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:S.semanticLinks.map((j,k)=>r.jsxs("span",{className:`px-1.5 py-0.5 text-[10px] rounded ${j.relation==="agrees_with"?"bg-green-500/20 text-green-400":j.relation==="disagrees_with"?"bg-red-500/20 text-red-400":j.relation==="builds_on"?"bg-blue-500/20 text-blue-400":j.relation==="contradicts"?"bg-orange-500/20 text-orange-400":"bg-yellow-500/20 text-yellow-400"}`,children:[j.relation.replace("_"," ")," #",j.targetFragmentId.slice(0,6)]},k))}),S.parentId&&r.jsxs("div",{className:"mt-2 text-xs text-cc-muted",children:["↳ Reply to #",S.parentId.slice(0,8)]})]},S.fragmentId))})]}),d==="consensus"&&r.jsx("div",{className:"p-4 space-y-4",children:n?r.jsxs(r.Fragment,{children:[n.consensusPoints.length>0&&r.jsxs("div",{children:[r.jsxs("h3",{className:"text-sm font-semibold text-cc-fg mb-2 flex items-center gap-2",children:[r.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"}),"Consensus Points (",n.consensusPoints.length,")"]}),r.jsx("div",{className:"space-y-2",children:n.consensusPoints.map(S=>{const j=t.find(k=>k.fragmentId===S);return j?r.jsxs("div",{className:"p-2 bg-green-500/5 border border-green-500/30 rounded text-sm",children:[r.jsx("div",{className:"text-cc-fg",children:j.content}),r.jsxs("div",{className:"text-xs text-cc-muted mt-1",children:[(j.consensusScore*100).toFixed(0),"% agreement"]})]},S):null})})]}),n.disagreements.length>0&&r.jsxs("div",{children:[r.jsxs("h3",{className:"text-sm font-semibold text-cc-fg mb-2 flex items-center gap-2",children:[r.jsx("span",{className:"w-2 h-2 rounded-full bg-orange-400"}),"Disagreements (",n.disagreements.length,")"]}),r.jsx("div",{className:"space-y-2",children:n.disagreements.map((S,j)=>r.jsxs("div",{className:"p-3 bg-orange-500/5 border border-orange-500/30 rounded",children:[r.jsx("div",{className:"text-sm font-medium text-cc-fg mb-1",children:S.topic}),r.jsx("div",{className:"text-sm text-cc-muted mb-2",children:S.summary}),r.jsxs("div",{className:"text-xs text-cc-muted",children:[S.fragmentIds.length," conflicting thoughts"]})]},j))})]}),n.openQuestions.length>0&&r.jsxs("div",{children:[r.jsxs("h3",{className:"text-sm font-semibold text-cc-fg mb-2 flex items-center gap-2",children:[r.jsx("span",{className:"w-2 h-2 rounded-full bg-yellow-400"}),"Open Questions (",n.openQuestions.length,")"]}),r.jsx("div",{className:"space-y-2",children:n.openQuestions.map(S=>{const j=t.find(k=>k.fragmentId===S);return j?r.jsxs("div",{className:"p-2 bg-yellow-500/5 border border-yellow-500/30 rounded text-sm",children:[r.jsx("div",{className:"text-cc-fg",children:j.content}),r.jsxs("div",{className:"text-xs text-cc-muted mt-1",children:["Asked by ",j.isHuman?"human":"agent"," · No answers yet"]})]},S):null})})]}),n.consensusPoints.length===0&&n.disagreements.length===0&&n.openQuestions.length===0&&r.jsx("div",{className:"text-center py-8 text-cc-muted text-sm",children:"No consensus data available yet"})]}):r.jsx("div",{className:"text-center py-8 text-cc-muted text-sm",children:l?"Loading...":"No consensus data yet"})})]})]})}function d0(e){if(e<1e3)return`${e}ms`;const t=Math.floor(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function h0(e){return e===0?"$0":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}const f0={pending:"text-cc-muted",running:"text-cc-primary",completed:"text-cc-success",failed:"text-cc-error",cancelled:"text-cc-warning",skipped:"text-cc-muted/50"},SH={pending:"bg-cc-muted/30",running:"bg-cc-primary animate-pulse",completed:"bg-cc-success",failed:"bg-cc-error",cancelled:"bg-cc-warning",skipped:"bg-cc-muted/20"};function jH({stage:e,index:t,onChange:s,onRemove:n}){return r.jsxs("div",{className:"border border-cc-border rounded-lg p-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-[11px] font-mono-code text-cc-muted",children:["Stage ",t+1]}),r.jsx("button",{onClick:n,className:"text-[10px] text-cc-error hover:text-cc-error/80 transition-colors",children:"Remove"})]}),r.jsx("input",{type:"text",value:e.name,onChange:a=>s({...e,name:a.target.value}),placeholder:"Stage name (e.g. Implement feature)",className:"w-full px-2.5 py-1.5 text-[12px] bg-cc-input-bg border border-cc-border rounded-md text-cc-fg placeholder:text-cc-muted/40 focus:outline-none focus:border-cc-muted/30"}),r.jsx("textarea",{value:e.prompt,onChange:a=>s({...e,prompt:a.target.value}),placeholder:"Prompt for this stage...",rows:3,className:"w-full px-2.5 py-1.5 text-[12px] bg-cc-input-bg border border-cc-border rounded-md text-cc-fg placeholder:text-cc-muted/40 focus:outline-none focus:border-cc-muted/30 resize-none font-mono-code"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("select",{value:e.backend,onChange:a=>s({...e,backend:a.target.value}),className:"px-2 py-1 text-[11px] bg-cc-input-bg border border-cc-border rounded-md text-cc-fg focus:outline-none",children:[r.jsx("option",{value:"claude",children:"Claude Code"}),r.jsx("option",{value:"codex",children:"Codex"}),r.jsx("option",{value:"goose",children:"Goose"}),r.jsx("option",{value:"aider",children:"Aider"})]}),r.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-cc-muted cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:e.inheritContext??!0,onChange:a=>s({...e,inheritContext:a.target.checked}),className:"rounded"}),"Pass context from previous stage"]})]})]})}function kH({onSave:e,onCancel:t}){const[s,n]=w.useState(""),[a,l]=w.useState(""),[c,d]=w.useState(""),[f,h]=w.useState([{name:"Implement",prompt:"",backend:"claude",inheritContext:!1},{name:"Test",prompt:"Run the test suite and fix any failures.",backend:"claude",inheritContext:!0},{name:"Review",prompt:"Review the changes for code quality, security, and best practices.",backend:"claude",inheritContext:!0}]),[m,g]=w.useState(!1);w.useEffect(()=>{ne.getHome().then(y=>d(y.cwd)).catch(()=>{})},[]);const _=()=>{h([...f,{name:"",prompt:"",backend:"claude",inheritContext:!0}])},v=async()=>{if(!(!s.trim()||!c.trim()||f.length===0)){g(!0);try{const y=await ne.createPipeline({name:s.trim(),description:a.trim()||void 0,cwd:c,stages:f});e(y)}catch(y){console.error("Failed to create pipeline:",y)}g(!1)}};return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h2",{className:"text-[14px] font-semibold text-cc-fg",children:"Create Pipeline"}),r.jsx("button",{onClick:t,className:"text-[11px] text-cc-muted hover:text-cc-fg transition-colors",children:"Cancel"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("input",{type:"text",value:s,onChange:y=>n(y.target.value),placeholder:"Pipeline name",className:"w-full px-3 py-2 text-[13px] bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted/40 focus:outline-none focus:border-cc-muted/30"}),r.jsx("input",{type:"text",value:a,onChange:y=>l(y.target.value),placeholder:"Description (optional)",className:"w-full px-3 py-2 text-[13px] bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted/40 focus:outline-none focus:border-cc-muted/30"}),r.jsx("input",{type:"text",value:c,onChange:y=>d(y.target.value),placeholder:"Working directory",className:"w-full px-3 py-2 text-[13px] bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted/40 focus:outline-none focus:border-cc-muted/30 font-mono-code"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[12px] font-medium text-cc-fg",children:"Stages"}),r.jsx("button",{onClick:_,className:"text-[11px] text-cc-primary hover:text-cc-primary-hover transition-colors",children:"+ Add Stage"})]}),f.map((y,S)=>r.jsx(jH,{stage:y,index:S,onChange:j=>{const k=[...f];k[S]=j,h(k)},onRemove:()=>h(f.filter((j,k)=>k!==S))},S))]}),r.jsx("button",{onClick:v,disabled:m||!s.trim()||!c.trim()||f.length===0,className:"w-full py-2 rounded-lg text-[13px] font-medium transition-colors bg-cc-fg text-cc-bg hover:opacity-80 disabled:opacity-30 disabled:cursor-not-allowed",children:m?"Creating...":"Create Pipeline"})]})}function CH({runId:e,onBack:t}){const[s,n]=w.useState(null),a=w.useCallback(async()=>{try{const l=await ne.getRun(e);return n(l),l.status==="running"||l.status==="pending"}catch{return!1}},[e]);return w.useEffect(()=>{let l=!0;const c=async()=>{const d=await a();l&&d&&setTimeout(c,2e3)};return c(),()=>{l=!1}},[a]),s?r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("button",{onClick:t,className:"text-[11px] text-cc-muted hover:text-cc-fg transition-colors flex items-center gap-1",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:r.jsx("path",{d:"M7.78 12.53a.75.75 0 01-1.06 0L2.47 8.28a.75.75 0 010-1.06l4.25-4.25a.75.75 0 011.06 1.06L4.81 7h7.44a.75.75 0 010 1.5H4.81l2.97 2.97a.75.75 0 010 1.06z"})}),"Back"]}),r.jsx("span",{className:`text-[11px] font-mono-code ${f0[s.status]}`,children:s.status})]}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-[14px] font-semibold text-cc-fg",children:s.pipelineName}),r.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[11px] text-cc-muted font-mono-code",children:[r.jsx("span",{children:d0(s.totalDurationMs)}),r.jsx("span",{children:h0(s.totalCostUsd)})]})]}),r.jsx("div",{className:"space-y-0",children:s.stageResults.map((l,c)=>r.jsxs("div",{className:"flex items-start gap-3 relative",children:[c<s.stageResults.length-1&&r.jsx("div",{className:"absolute left-[7px] top-[18px] bottom-0 w-px bg-cc-border"}),r.jsx("div",{className:`w-[15px] h-[15px] rounded-full border-2 border-cc-bg shrink-0 mt-0.5 ${SH[l.status]}`}),r.jsxs("div",{className:"flex-1 pb-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-[12px] font-medium text-cc-fg",children:["Stage ",c+1]}),r.jsxs("span",{className:`text-[10px] font-mono-code ${f0[l.status]}`,children:[l.status,l.durationMs?` · ${d0(l.durationMs)}`:"",l.costUsd?` · ${h0(l.costUsd)}`:""]})]}),l.sessionId&&r.jsx("a",{href:`#/?session=${l.sessionId}`,className:"text-[10px] text-cc-primary hover:text-cc-primary-hover font-mono-code mt-0.5 inline-block",children:"View session"}),l.error&&r.jsx("p",{className:"text-[10px] text-cc-error mt-1 font-mono-code",children:l.error}),l.outputSummary&&r.jsx("p",{className:"text-[10px] text-cc-muted mt-1 line-clamp-2",children:l.outputSummary})]})]},l.stageId))}),s.status==="running"&&r.jsx("button",{onClick:async()=>{await ne.cancelRun(s.id),a()},className:"w-full py-2 rounded-lg text-[12px] bg-cc-error/10 text-cc-error hover:bg-cc-error/20 transition-colors",children:"Cancel Run"})]}):r.jsx("div",{className:"text-[13px] text-cc-muted p-6 text-center",children:"Loading run..."})}function NH(){const[e,t]=w.useState("list"),[s,n]=w.useState([]),[a,l]=w.useState([]),[c,d]=w.useState(null),[f,h]=w.useState(!0),m=w.useCallback(async()=>{try{const[g,_]=await Promise.all([ne.listPipelines(),ne.listRuns()]);n(g),l(_)}catch{}h(!1)},[]);return w.useEffect(()=>{m()},[m]),e==="create"?r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsx("div",{className:"max-w-2xl mx-auto",children:r.jsx(kH,{onSave:()=>{m(),t("list")},onCancel:()=>t("list")})})}):e==="run-view"&&c?r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsx("div",{className:"max-w-2xl mx-auto",children:r.jsx(CH,{runId:c,onBack:()=>{t("list"),m()}})})}):r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-[16px] font-semibold text-cc-fg",children:"Orchestrator"}),r.jsx("p",{className:"text-[12px] text-cc-muted mt-0.5",children:"Chain multiple AI sessions into multi-stage pipelines"})]}),r.jsx("button",{onClick:()=>t("create"),className:"px-3 py-1.5 rounded-lg text-[12px] font-medium bg-cc-fg text-cc-bg hover:opacity-80 transition-colors",children:"New Pipeline"})]}),f?r.jsx("div",{className:"text-center py-8 text-[13px] text-cc-muted",children:"Loading..."}):r.jsxs(r.Fragment,{children:[s.length===0?r.jsxs("div",{className:"text-center py-12 border border-dashed border-cc-border rounded-lg",children:[r.jsx("p",{className:"text-[13px] text-cc-muted",children:"No pipelines yet"}),r.jsx("p",{className:"text-[11px] text-cc-muted/60 mt-1",children:"Create a pipeline to chain AI sessions into multi-stage workflows"})]}):r.jsxs("div",{className:"space-y-2",children:[r.jsx("h2",{className:"text-[12px] text-cc-muted uppercase tracking-wider font-medium",children:"Pipelines"}),s.map(g=>r.jsx("div",{className:"border border-cc-border rounded-lg p-3 hover:bg-cc-hover/30 transition-colors",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("span",{className:"text-[13px] font-medium text-cc-fg",children:g.name}),g.description&&r.jsx("p",{className:"text-[11px] text-cc-muted mt-0.5",children:g.description}),r.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[r.jsxs("span",{className:"text-[10px] text-cc-muted/60 font-mono-code",children:[g.stages.length," stages"]}),r.jsx("span",{className:"text-[10px] text-cc-muted/60 font-mono-code",children:g.cwd})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:async()=>{try{const _=await ne.runPipeline(g.id);d(_.id),t("run-view")}catch(_){console.error("Failed to run pipeline:",_)}},className:"px-2.5 py-1 rounded-md text-[11px] bg-cc-primary/10 text-cc-primary hover:bg-cc-primary/20 transition-colors",children:"Run"}),r.jsx("button",{onClick:async()=>{await ne.deletePipeline(g.id),m()},className:"px-2 py-1 rounded-md text-[11px] text-cc-muted hover:text-cc-error transition-colors",children:"Delete"})]})]})},g.id))]}),a.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h2",{className:"text-[12px] text-cc-muted uppercase tracking-wider font-medium",children:"Recent Runs"}),a.slice(0,10).map(g=>r.jsxs("button",{onClick:()=>{d(g.id),t("run-view")},className:"w-full border border-cc-border rounded-lg p-3 hover:bg-cc-hover/30 transition-colors text-left",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[12px] font-medium text-cc-fg",children:g.pipelineName}),r.jsx("span",{className:`text-[10px] font-mono-code ${f0[g.status]}`,children:g.status})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[10px] text-cc-muted font-mono-code",children:[r.jsx("span",{children:d0(g.totalDurationMs)}),r.jsx("span",{children:h0(g.totalCostUsd)}),r.jsxs("span",{children:[g.stageResults.filter(_=>_.status==="completed").length,"/",g.stageResults.length," stages"]}),r.jsx("span",{children:new Date(g.startedAt).toLocaleDateString()})]})]},g.id))]})]})]})})}function EH(e){if(!e)return"-";const t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function MH(e){return e?e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`:"$0"}function TH(e){return e==="completed"?"text-cc-success":e==="failed"||e==="timeout"?"text-cc-error":e==="running"?"text-cc-primary":"text-cc-muted"}function AH({race:e,onUpdate:t}){const s=G(h=>h.setCurrentSession),[n,a]=w.useState(new Map),[l,c]=w.useState(null),d=async h=>{const m=await ne.pickRaceWinner(e.raceId,h);t(m)},f=async h=>{c(h.id);try{const m=await ne.getRaceEntryDiff(e.raceId,h.id);a(g=>new Map(g).set(h.id,m.diff||""))}finally{c(null)}};return r.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-3",children:e.entries.map(h=>{var m,g,_,v,y,S;return r.jsxs("div",{className:"rounded-lg border border-cc-border bg-cc-card overflow-hidden",children:[r.jsxs("div",{className:"px-3 py-2.5 border-b border-cc-border/50 flex items-center justify-between",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-[13px] font-semibold text-cc-fg truncate",children:h.backendType}),r.jsx("div",{className:`text-[10px] uppercase font-mono-code ${TH(h.status)}`,children:h.status})]}),r.jsx("button",{disabled:h.status!=="completed"||e.winnerId===h.sessionId,onClick:()=>void d(h.sessionId),className:"px-2 py-1 rounded-md text-[11px] bg-cc-fg text-cc-bg disabled:opacity-30 disabled:cursor-not-allowed",children:e.winnerId===h.sessionId?"Selected":"Merge"})]}),r.jsxs("div",{className:"px-3 py-2.5 grid grid-cols-2 gap-2 text-[11px]",children:[r.jsx(Qd,{label:"Time",value:EH((m=h.metrics)==null?void 0:m.wallClockMs)}),r.jsx(Qd,{label:"Cost",value:MH((g=h.metrics)==null?void 0:g.costUsd)}),r.jsx(Qd,{label:"Files",value:String(((_=h.metrics)==null?void 0:_.filesChanged)??0)}),r.jsx(Qd,{label:"Lines",value:`+${((v=h.metrics)==null?void 0:v.linesAdded)??0} -${((y=h.metrics)==null?void 0:y.linesRemoved)??0}`})]}),r.jsxs("div",{className:"px-3 pb-3",children:[r.jsx("div",{className:"text-[10px] text-cc-muted uppercase tracking-wider mb-1",children:"Summary"}),r.jsx("p",{className:"min-h-20 max-h-40 overflow-auto rounded-md bg-cc-bg/60 px-2 py-1.5 text-[11px] text-cc-muted whitespace-pre-wrap",children:h.error||h.outputSummary||"No output yet."})]}),r.jsxs("div",{className:"px-3 pb-3",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("div",{className:"text-[10px] text-cc-muted uppercase tracking-wider",children:"Diff"}),r.jsx("button",{onClick:()=>void f(h),className:"text-[10px] text-cc-primary hover:text-cc-primary-hover",children:l===h.id?"Loading...":"Load"})]}),n.has(h.id)?n.get(h.id)?r.jsx("div",{className:"max-h-72 overflow-auto rounded-md border border-cc-border/50",children:r.jsx(br,{unifiedDiff:n.get(h.id),fileName:h.branch,mode:"compact"})}):r.jsx("p",{className:"rounded-md bg-cc-bg/60 px-2 py-1.5 text-[11px] text-cc-muted",children:"No diff for this entry."}):r.jsx("p",{className:"rounded-md bg-cc-bg/60 px-2 py-1.5 text-[11px] text-cc-muted",children:(S=h.filesChanged)!=null&&S.length?`${h.filesChanged.length} changed files`:"No changed files recorded yet."})]}),r.jsxs("button",{onClick:()=>{s(h.sessionId),Sr(h.sessionId),window.location.hash=""},className:"w-full border-t border-cc-border/50 px-3 py-2 text-left text-[11px] text-cc-muted hover:text-cc-fg hover:bg-cc-hover",children:["Open session ",h.sessionId.slice(0,8)]})]},h.id)})})}function Qd({label:e,value:t}){return r.jsxs("div",{className:"rounded-md bg-cc-bg/60 px-2 py-1.5",children:[r.jsx("div",{className:"text-[9px] text-cc-muted uppercase tracking-wider",children:e}),r.jsx("div",{className:"text-[12px] text-cc-fg font-mono-code",children:t})]})}const RH=[{id:"claude",label:"Claude"},{id:"codex",label:"Codex"},{id:"goose",label:"Goose"},{id:"aider",label:"Aider"},{id:"openhands",label:"OpenHands"}];function DH(){var Y;const e=typeof window<"u"?(Y=window.location.hash.match(/^#\/races\/([^/?#]+)/))==null?void 0:Y[1]:void 0,[t,s]=w.useState([]),[n,a]=w.useState(e?decodeURIComponent(e):null),[l,c]=w.useState(""),[d,f]=w.useState(""),[h,m]=w.useState(["claude","codex"]),[g,_]=w.useState([]),[v,y]=w.useState(()=>{try{return localStorage.getItem("cc-selected-env")||""}catch{return""}}),[S,j]=w.useState(null),[k,N]=w.useState(!1),E=w.useMemo(()=>t.find(W=>W.raceId===n)||t[0]||null,[t,n]),B=w.useCallback(async()=>{const W=await ne.listRaces();s(W),!n&&W[0]&&a(e?decodeURIComponent(e):W[0].raceId)},[n]);w.useEffect(()=>{ne.getHome().then(async W=>{try{const L=await ne.getRepoInfo(W.cwd);c(L.repoRoot)}catch{c(W.cwd)}}).catch(()=>{}),ne.listEnvs().then(_).catch(()=>{}),B()},[B]),w.useEffect(()=>{if(!((E==null?void 0:E.status)==="running"))return;const L=setInterval(()=>void B(),2e3);return()=>clearInterval(L)},[B,E==null?void 0:E.status]);const F=W=>{m(L=>L.includes(W)?L.filter(Q=>Q!==W):[...L,W])},$=async()=>{j(null),N(!0);try{const W=await ne.createRace({prompt:d,repoRoot:l,backends:h,envSlug:v||void 0});s(L=>[W,...L]),a(W.raceId),window.location.hash=`#/races/${encodeURIComponent(W.raceId)}`,f("")}catch(W){j(W instanceof Error?W.message:String(W))}finally{N(!1)}},K=async W=>{const L=await ne.cancelRace(W);s(Q=>Q.map(V=>V.raceId===L.raceId?L:V))};return r.jsx("div",{className:"h-full overflow-auto bg-cc-bg",children:r.jsxs("div",{className:"max-w-6xl mx-auto p-4 space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("h1",{className:"text-[18px] font-semibold text-cc-fg",children:"Agent Races"}),r.jsx("p",{className:"text-[12px] text-cc-muted",children:"Run the same task in isolated worktrees and compare the results."})]})}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[360px_1fr] gap-4",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"rounded-lg border border-cc-border bg-cc-card p-3 space-y-3",children:[r.jsx("input",{value:l,onChange:W=>c(W.target.value),placeholder:"Repository root",className:"w-full px-2.5 py-2 rounded-md border border-cc-border bg-cc-input-bg text-[12px] text-cc-fg font-mono-code"}),r.jsx("textarea",{value:d,onChange:W=>f(W.target.value),placeholder:"Task prompt",rows:5,className:"w-full px-2.5 py-2 rounded-md border border-cc-border bg-cc-input-bg text-[12px] text-cc-fg resize-none"}),r.jsx("div",{className:"grid grid-cols-2 gap-2",children:RH.map(W=>r.jsxs("label",{className:"flex items-center gap-2 rounded-md border border-cc-border px-2 py-1.5 text-[11px] text-cc-fg",children:[r.jsx("input",{type:"checkbox",checked:h.includes(W.id),onChange:()=>F(W.id)}),W.label]},W.id))}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[10px] font-semibold text-cc-muted/60 uppercase tracking-wider mb-1.5",htmlFor:"race-env-select",children:"Environment"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsxs("select",{id:"race-env-select",value:v,onChange:W=>{y(W.target.value);try{localStorage.setItem("cc-selected-env",W.target.value)}catch{}},onFocus:()=>{ne.listEnvs().then(_).catch(()=>{})},className:"flex-1 min-w-0 px-2.5 py-2 rounded-md border border-cc-border bg-cc-input-bg text-[12px] text-cc-fg focus:outline-none focus:border-cc-primary/50 cursor-pointer",children:[r.jsx("option",{value:"",children:"No environment"}),g.map(W=>r.jsxs("option",{value:W.slug,children:[W.name," (",Object.keys(W.variables).length," vars)"]},W.slug))]}),r.jsx("button",{type:"button",onClick:()=>{window.location.hash="#/environments"},"aria-label":"Manage environments",className:"px-2.5 py-2 rounded-md border border-cc-border bg-cc-input-bg text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer shrink-0",children:r.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:[r.jsx("path",{d:"M8 4.754a3.246 3.246 0 100 6.492 3.246 3.246 0 000-6.492zM5.754 8a2.246 2.246 0 114.492 0 2.246 2.246 0 01-4.492 0z"}),r.jsx("path",{d:"M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0a1.843 1.843 0 01-2.739 1.049c-1.547-.966-3.317.803-2.35 2.35a1.843 1.843 0 01-1.049 2.74c-1.79.526-1.79 3.064 0 3.59a1.843 1.843 0 011.049 2.74c-.966 1.547.803 3.317 2.35 2.35a1.843 1.843 0 012.74 1.049c.526 1.79 3.064 1.79 3.59 0a1.843 1.843 0 012.74-1.049c1.547.966 3.317-.803 2.35-2.35a1.843 1.843 0 011.049-2.74c1.79-.526 1.79-3.064 0-3.59a1.843 1.843 0 01-1.049-2.74c.966-1.547-.803-3.317-2.35-2.35a1.843 1.843 0 01-2.74-1.049z"})]})})]})]}),S&&r.jsx("div",{className:"text-[11px] text-cc-error",children:S}),r.jsx("button",{onClick:()=>void $(),disabled:k||!d.trim()||!l.trim()||h.length<2,className:"w-full rounded-md bg-cc-fg text-cc-bg px-3 py-2 text-[12px] font-medium disabled:opacity-30 disabled:cursor-not-allowed",children:k?"Starting...":"Start Race"})]}),r.jsxs("div",{className:"rounded-lg border border-cc-border bg-cc-card overflow-hidden",children:[t.map(W=>r.jsxs("button",{onClick:()=>{a(W.raceId),window.location.hash=`#/races/${encodeURIComponent(W.raceId)}`},className:`w-full text-left px-3 py-2 border-b border-cc-border/40 hover:bg-cc-hover ${(E==null?void 0:E.raceId)===W.raceId?"bg-cc-hover":""}`,children:[r.jsx("div",{className:"text-[12px] text-cc-fg truncate",children:W.prompt}),r.jsxs("div",{className:"text-[10px] text-cc-muted uppercase font-mono-code",children:[W.status," / ",W.entries.length," agents"]})]},W.raceId)),t.length===0&&r.jsx("div",{className:"px-3 py-5 text-[12px] text-cc-muted",children:"No races yet."})]})]}),r.jsx("div",{className:"space-y-3",children:E?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"rounded-lg border border-cc-border bg-cc-card p-3 flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-[13px] font-semibold text-cc-fg truncate",children:E.prompt}),r.jsxs("div",{className:"text-[10px] text-cc-muted font-mono-code uppercase",children:[E.status," on ",E.baseBranch]})]}),E.status==="running"&&r.jsx("button",{onClick:()=>void K(E.raceId),className:"px-2 py-1 rounded-md text-[11px] text-cc-error border border-cc-error/40",children:"Cancel"})]}),r.jsx(AH,{race:E,onUpdate:W=>s(L=>L.map(Q=>Q.raceId===W.raceId?W:Q))})]}):r.jsx("div",{className:"rounded-lg border border-cc-border bg-cc-card p-6 text-[12px] text-cc-muted",children:"Start a race to compare agents."})})]})]})})}const LH={pending:{label:"To Do",emptyText:"No pending tasks",dotColor:"bg-cc-muted/40",headerColor:"text-cc-muted"},in_progress:{label:"In Progress",emptyText:"Nothing in progress",dotColor:"bg-cc-primary animate-pulse",headerColor:"text-cc-primary"},completed:{label:"Done",emptyText:"Nothing completed yet",dotColor:"bg-cc-success",headerColor:"text-cc-success"}};function BH({task:e}){const t=e.blockedBy&&e.blockedBy.length>0;return r.jsxs("div",{className:`p-3 rounded-lg border transition-colors ${t?"border-cc-border/50 bg-cc-hover/30 opacity-60":"border-cc-border bg-cc-card hover:border-cc-muted/20"}`,children:[r.jsx("div",{className:"flex items-start gap-2",children:r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-[12px] font-medium text-cc-fg leading-tight",children:e.subject}),e.description&&e.description!==e.subject&&r.jsx("p",{className:"text-[10px] text-cc-muted mt-1 line-clamp-2 leading-relaxed",children:e.description})]})}),r.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap",children:[e.owner&&r.jsx("span",{className:"text-[9px] font-mono-code px-1.5 py-0.5 rounded bg-cc-hover text-cc-muted",children:e.owner}),e.activeForm&&e.status==="in_progress"&&r.jsx("span",{className:"text-[9px] font-mono-code px-1.5 py-0.5 rounded bg-cc-primary/10 text-cc-primary",children:e.activeForm}),t&&r.jsx("span",{className:"text-[9px] font-mono-code px-1.5 py-0.5 rounded bg-cc-warning/10 text-cc-warning",children:"blocked"}),r.jsxs("span",{className:"text-[9px] font-mono-code text-cc-muted/40 ml-auto",children:["#",e.id]})]})]})}function Tg({column:e,tasks:t}){const s=LH[e];return r.jsxs("div",{className:"flex-1 min-w-[250px] max-w-[400px]",children:[r.jsxs("div",{className:"flex items-center gap-2 px-1 pb-3 border-b border-cc-border",children:[r.jsx("div",{className:`w-2 h-2 rounded-full ${s.dotColor}`}),r.jsx("span",{className:`text-[12px] font-semibold ${s.headerColor}`,children:s.label}),r.jsx("span",{className:"text-[10px] text-cc-muted/50 font-mono-code tabular-nums ml-auto",children:t.length})]}),r.jsx("div",{className:"space-y-2 pt-3 min-h-[100px]",children:t.length===0?r.jsx("div",{className:"text-[11px] text-cc-muted/40 italic text-center py-6",children:s.emptyText}):t.map(n=>r.jsx(BH,{task:n},n.id))})]})}function OH(){var f;const e=G(h=>h.currentSessionId),t=G(h=>h.sessionTasks),s=G(h=>h.sessionNames),n=G(h=>h.sdkSessions),{grouped:a,totalCount:l,sessionId:c}=w.useMemo(()=>{const h=[],m=[],g=[],_=e?[[e,t.get(e)||[]]]:Array.from(t.entries());for(const[,v]of _)for(const y of v)y.status==="completed"?g.push(y):y.status==="in_progress"?m.push(y):h.push(y);return{grouped:{pending:h,in_progress:m,completed:g},totalCount:h.length+m.length+g.length,sessionId:e}},[t,e]),d=c?s.get(c)||((f=n.find(h=>h.sessionId===c))==null?void 0:f.name)||c.slice(0,8):null;return r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-[16px] font-semibold text-cc-fg",children:"Task Board"}),r.jsx("p",{className:"text-[12px] text-cc-muted mt-0.5",children:d?`Tasks from session: ${d}`:"Tasks extracted from agent tool calls (TodoWrite, TaskCreate)"})]}),l===0?r.jsxs("div",{className:"text-center py-16 border border-dashed border-cc-border rounded-lg",children:[r.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-8 h-8 mx-auto text-cc-muted/20 mb-3",children:r.jsx("path",{d:"M1.5 3.25a2.25 2.25 0 013-2.122V1A2.5 2.5 0 017 3.5H3.25a.75.75 0 010-1.5h3.06A1 1 0 005.5 1.5h-1a.75.75 0 01-.75-.75.75.75 0 00-1.5 0v.5h-.5a.25.25 0 00-.25.25zm13 0v.5a.25.25 0 01-.25.25H8V1h.75a.75.75 0 01.75.75.75.75 0 001.5 0h-1a1 1 0 00-.81.5h3.06a.75.75 0 010 1.5H9A2.5 2.5 0 0111.5 1v.128a2.25 2.25 0 013 2.122zM1.5 5v8.25c0 .966.784 1.75 1.75 1.75h9.5A1.75 1.75 0 0014.5 13.25V5h-13z"})}),r.jsx("p",{className:"text-[13px] text-cc-muted",children:"No tasks yet"}),r.jsx("p",{className:"text-[11px] text-cc-muted/60 mt-1",children:"Tasks appear here when agents use TodoWrite or TaskCreate tools"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-4 text-[11px] font-mono-code",children:[r.jsxs("span",{className:"text-cc-muted",children:[a.completed.length,"/",l," complete"]}),a.in_progress.length>0&&r.jsxs("span",{className:"text-cc-primary",children:[a.in_progress.length," in progress"]}),r.jsx("div",{className:"flex-1 h-1 rounded-full bg-cc-hover overflow-hidden max-w-[200px]",children:r.jsx("div",{className:"h-full rounded-full bg-cc-success transition-all duration-500",style:{width:`${a.completed.length/l*100}%`}})})]}),r.jsxs("div",{className:"flex gap-4 overflow-x-auto pb-4",children:[r.jsx(Tg,{column:"pending",tasks:a.pending}),r.jsx(Tg,{column:"in_progress",tasks:a.in_progress}),r.jsx(Tg,{column:"completed",tasks:a.completed})]})]})]})})}function zH({embedded:e}){const[t,s]=w.useState([]),[n,a]=w.useState(!0),[l,c]=w.useState(""),[d,f]=w.useState(null),[h,m]=w.useState({}),[g,_]=w.useState(null);w.useEffect(()=>{v()},[]);async function v(){a(!0),c("");try{const N=await ne.listPlugins();s(N)}catch(N){c(N instanceof Error?N.message:"Failed to load plugins")}finally{a(!1)}}async function y(N){_(N.id);try{const E=await ne.togglePlugin(N.id,!N.disabledInCampfire);s(B=>B.map(F=>F.id===N.id?{...F,disabledInCampfire:E.disabled}:F))}catch(E){c(E instanceof Error?E.message:"Failed to toggle plugin")}finally{_(null)}}async function S(N,E){const B=`${N}:${E}`;if(!h[B])try{const{content:F}=await ne.readSkillContent(N,E);m($=>({...$,[B]:F}))}catch{m(F=>({...F,[B]:"Failed to load skill content."}))}}const j=t.reduce((N,E)=>N+E.skills.length,0),k=t.reduce((N,E)=>N+E.commands.length,0);return r.jsxs("div",{className:"h-full flex flex-col ",children:[r.jsx("div",{className:"shrink-0 px-4 py-3 border-b border-cc-border",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-sm font-medium text-cc-fg",children:"Skills & Plugins"}),r.jsxs("p",{className:"text-[11px] text-cc-muted mt-0.5",children:[t.length," plugin",t.length!==1?"s":""," installed",j>0&&` · ${j} skill${j!==1?"s":""}`,k>0&&` · ${k} command${k!==1?"s":""}`]})]}),r.jsx("button",{onClick:v,disabled:n,className:"px-2.5 py-1 text-[11px] font-mono-code text-cc-muted hover:text-cc-fg rounded-md hover:bg-cc-hover transition-colors cursor-pointer",children:n?"Loading...":"Refresh"})]})}),r.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3",children:[l&&r.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/5 border border-cc-error/20 text-xs text-cc-error",children:l}),n&&t.length===0&&r.jsxs("div",{className:"flex items-center justify-center py-12 text-cc-muted text-xs",children:[r.jsx("span",{className:"w-4 h-4 border-2 border-cc-muted/30 border-t-cc-muted rounded-full animate-spin mr-2"}),"Loading plugins..."]}),!n&&t.length===0&&!l&&r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-cc-muted",children:[r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",className:"w-8 h-8 opacity-30 mb-2",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),r.jsx("p",{className:"text-xs",children:"No plugins installed."}),r.jsxs("p",{className:"text-[11px] mt-1 opacity-70",children:["Install plugins via ",r.jsx("code",{className:"font-mono-code bg-cc-hover px-1 rounded",children:"/install-plugin"})," in Claude Code."]})]}),t.map(N=>r.jsxs("div",{className:`rounded-lg border transition-colors ${N.blocked?"border-cc-error/20 bg-cc-error/5":N.disabledInCampfire?"border-cc-border bg-cc-hover/50 opacity-60":"border-cc-border bg-cc-card"}`,children:[r.jsxs("div",{className:"px-3 py-2.5 flex items-start gap-3",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>f(d===N.id?null:N.id),className:"text-xs font-medium text-cc-fg hover:text-cc-primary transition-colors cursor-pointer truncate",children:N.name}),r.jsx("span",{className:"text-[10px] font-mono-code text-cc-muted bg-cc-hover px-1.5 py-0.5 rounded shrink-0",children:N.marketplace}),N.blocked&&r.jsx("span",{className:"text-[10px] font-mono-code text-cc-error bg-cc-error/10 px-1.5 py-0.5 rounded shrink-0",children:"blocked"})]}),N.description&&r.jsx("p",{className:"text-[11px] text-cc-muted mt-0.5 line-clamp-2",children:N.description}),r.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-[10px] text-cc-muted",children:[N.author&&r.jsxs("span",{children:["by ",N.author]}),r.jsxs("span",{children:["v",N.version]}),N.skills.length>0&&r.jsxs("span",{children:[N.skills.length," skill",N.skills.length!==1?"s":""]}),N.commands.length>0&&r.jsxs("span",{children:[N.commands.length," cmd",N.commands.length!==1?"s":""]})]})]}),r.jsx("button",{onClick:()=>y(N),disabled:g===N.id||N.blocked,className:`shrink-0 px-2.5 py-1 text-[11px] font-medium rounded-md transition-colors cursor-pointer disabled:opacity-50 ${N.disabledInCampfire?"bg-cc-hover text-cc-muted hover:text-cc-fg":"bg-cc-primary/15 text-cc-primary hover:bg-cc-primary/25"}`,children:g===N.id?"...":N.disabledInCampfire?"Enable":"Disable"})]}),d===N.id&&r.jsxs("div",{className:"border-t border-cc-border px-3 py-2.5 space-y-2",children:[N.skills.length>0&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-[10px] font-mono-code text-cc-muted uppercase tracking-wider mb-1",children:"Skills"}),N.skills.map(E=>{const B=`${N.id}:${E.name}`;return r.jsxs("div",{className:"mb-1.5",children:[r.jsx("button",{onClick:()=>S(N.id,E.name),className:"text-[11px] font-mono-code text-cc-fg hover:text-cc-primary transition-colors cursor-pointer",children:E.name}),E.description&&r.jsx("p",{className:"text-[10px] text-cc-muted ml-2",children:E.description}),h[B]&&r.jsx("pre",{className:"mt-1 p-2 rounded bg-cc-code-bg text-cc-code-fg text-[10px] font-mono-code overflow-x-auto max-h-48 overflow-y-auto",children:h[B]})]},E.name)})]}),N.commands.length>0&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-[10px] font-mono-code text-cc-muted uppercase tracking-wider mb-1",children:"Commands"}),N.commands.map(E=>r.jsxs("div",{className:"text-[11px] font-mono-code text-cc-fg",children:["/",E.name]},E.name))]}),r.jsx("div",{className:"text-[10px] font-mono-code text-cc-muted pt-1 border-t border-cc-border truncate",title:N.installPath,children:N.installPath})]})]},N.id))]})]})}function PH(){return w.useSyncExternalStore(e=>(window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)),()=>window.location.hash)}function $H(){const[e,t]=w.useState(!1),[s,n]=w.useState(!1),[a,l]=w.useState(!1);w.useEffect(()=>{ne.getAuthStatus().then(je=>{je.enabled&&!je.isLoggedIn&&(Hh()&&TM(),n(!0)),t(!0)}).catch(()=>{t(!0)})},[]),w.useEffect(()=>{ne.getSettings().then(je=>{je.onboardingCompleted||l(!0)}).catch(()=>{})},[]);const c=G(je=>je.darkMode),d=G(je=>je.currentSessionId),f=G(je=>{const Ye=je.currentSessionId;return Ye?(je.myRole.get(Ye)??null)==="spectator":!1}),h=G(je=>{const Ye=je.currentSessionId;return Ye&&(je.myRole.get(Ye)??null)==="spectator"?!1:je.sidebarOpen}),m=G(je=>je.taskPanelOpen),g=G(je=>je.homeResetKey),_=G(je=>je.activeTab),v=G(je=>je.updateOverlayActive),y=PH(),S=y==="#/settings",j=y==="#/terminal",k=y==="#/environments",N=y==="#/scheduled",E=y==="#/hub",B=y==="#/monitor",F=y==="#/commands",$=y==="#/gallery"||y.startsWith("#/gallery?"),K=$&&new URLSearchParams(y.replace(/^#\/gallery\??/,"")).get("session")||void 0,Y=G(je=>{var Ye,Xe;if(K)return((Ye=je.sessionNames)==null?void 0:Ye.get(K))||((Xe=je.sdkSessions.find(Pe=>Pe.sessionId===K))==null?void 0:Xe.name)||void 0}),W=y==="#/webhooks",L=y==="#/adapters",Q=y==="#/clawhub",V=y==="#/agents",X=y==="#/prompts",q=y==="#/integrations",A=y==="#/integrations/linear",M=y==="#/memory",O=y==="#/router",U=y==="#/collective",I=y==="#/orchestrator",R=y==="#/races"||y.startsWith("#/races/"),P=y==="#/kanban",z=y==="#/skills",T=y.match(/^#\/replay\/(?!session\/)(.+)$/),oe=y.match(/^#\/replay\/session\/(.+)$/),be=!!T||!!oe,re=y.match(/^#\/public-replay\/(.+)$/),ve=!!re,Te=!S&&!j&&!k&&!N&&!$&&!W&&!L&&!Q&&!V&&!X&&!q&&!A&&!M&&!O&&!U&&!I&&!R&&!P&&!z&&!be&&!ve&&!E&&!B&&!F;w.useEffect(()=>{MM(y||"#/")},[y]),w.useEffect(()=>{document.documentElement.classList.toggle("dark",c)},[c]);const Re=y.startsWith("#/join/");return Re&&nh(!0),w.useEffect(()=>{f&&!Te&&!Re&&(window.location.hash="")},[f,Te,Re]),w.useEffect(()=>{const je=y.match(/^#\/join\/(.+)$/);if(!je)return;const Ye=je[1];ne.joinSession(Ye).then(Xe=>{Xe.token&&Lj(Xe.token,Xe.session_id),qo(Xe.session_id),G.getState().setCurrentSession(Xe.session_id),Sr(Xe.session_id),nh(!1),window.location.hash=""}).catch(()=>{console.warn(`[App] Invalid invite token: ${Ye}`),nh(!1),window.location.hash=""})},[y]),w.useEffect(()=>{const je=G.getState().currentSessionId;je&&Sr(je)},[]),w.useEffect(()=>{if(!e||s)return;const je=()=>{ne.checkForUpdate().then(Xe=>G.getState().setUpdateInfo(Xe)).catch(()=>{})};je();const Ye=setInterval(je,300*1e3);return()=>clearInterval(Ye)},[e,s]),e?s?r.jsx(VM,{onLogin:()=>n(!1)}):y==="#/playground"?r.jsx(vP,{}):r.jsxs("div",{className:"h-[100dvh] flex font-sans-ui bg-cc-bg text-cc-fg antialiased text-[12.5px] leading-normal",children:[h&&!f&&r.jsx("div",{className:"fixed inset-0 bg-black/30 z-30 md:hidden",onClick:()=>G.getState().setSidebarOpen(!1)}),!f&&r.jsx("div",{className:`
275
+ fixed md:relative z-40 md:z-auto
276
+ h-full shrink-0 transition-all duration-150 ease-out
277
+ ${h?"w-[232px] translate-x-0":"w-0 -translate-x-full md:w-0 md:-translate-x-full"}
278
+ overflow-hidden
279
+ `,children:r.jsx(JM,{})}),r.jsxs("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:[r.jsx(WB,{}),r.jsx(EC,{}),r.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[S&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(_9,{embedded:!0})}),j&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(HF,{})}),k&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(pC,{embedded:!0})}),N&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(N9,{embedded:!0})}),$&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(qF,{embedded:!0,prefillSessionId:K,prefillName:Y})}),E&&r.jsx("div",{className:"absolute inset-0 overflow-y-auto",children:r.jsx($P,{embedded:!0})}),B&&r.jsx("div",{className:"absolute inset-0 overflow-y-auto",children:r.jsx(UP,{embedded:!0})}),F&&r.jsx("div",{className:"absolute inset-0 overflow-y-auto",children:r.jsx(qP,{embedded:!0})}),W&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(YF,{embedded:!0})}),L&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(QF,{embedded:!0})}),Q&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(ZF,{embedded:!0})}),V&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(aH,{embedded:!0})}),X&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(xH,{embedded:!0})}),q&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(vH,{embedded:!0})}),A&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(bH,{embedded:!0})}),M&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(_H,{})}),O&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(yH,{})}),U&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(wH,{})}),I&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(NH,{})}),R&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(DH,{})}),P&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(OH,{})}),z&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(zH,{embedded:!0})}),ve&&re&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(gH,{token:re[1]})}),be&&r.jsx("div",{className:"absolute inset-0",children:oe?r.jsx(oS,{sessionId:oe[1]},`session-${oe[1]}`):T?r.jsx(oS,{filename:T[1]},`file-${T[1]}`):null}),Te&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`absolute inset-0 ${_==="chat"||!d?"":"hidden"}`,children:d?r.jsx(uC,{sessionId:d}):r.jsx(ZB,{},g)}),d&&_==="diff"&&r.jsx("div",{className:"absolute inset-0",children:r.jsx($z,{sessionId:d})}),d&&_==="files"&&r.jsx("div",{className:"absolute inset-0",children:r.jsx(Hz,{sessionId:d})})]})]})]}),d&&Te&&r.jsxs(r.Fragment,{children:[m&&r.jsx("div",{className:"fixed inset-0 bg-black/20 backdrop-blur-sm z-30 lg:hidden",onClick:()=>G.getState().setTaskPanelOpen(!1)}),r.jsx("div",{className:`
280
+ fixed lg:relative z-40 lg:z-auto right-0 top-0
281
+ h-full shrink-0 transition-all duration-150 ease-out
282
+ ${m?"w-[264px] translate-x-0":"w-0 translate-x-full lg:w-0 lg:translate-x-full"}
283
+ overflow-hidden
284
+ `,children:r.jsx(yO,{sessionId:d})})]}),r.jsx(RP,{}),a&&r.jsx(JP,{onComplete:()=>l(!1)}),r.jsx(l9,{active:v})]}):r.jsx("div",{className:"h-[100dvh] flex items-center justify-center bg-cc-bg text-cc-fg text-[12px] text-cc-muted",children:"Loading..."})}class IH extends w.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,s){console.error("[AppErrorBoundary] Runtime error:",t),console.error("[AppErrorBoundary] Component stack:",s.componentStack),Tj(t,{source:"react_error_boundary",componentStack:s.componentStack})}render(){return this.state.hasError?r.jsx("div",{className:"h-[100dvh] flex items-center justify-center bg-cc-bg text-cc-fg px-4",children:r.jsxs("div",{className:"max-w-md w-full rounded-xl border border-cc-border bg-cc-card p-5 shadow-sm",children:[r.jsx("h1",{className:"text-base font-semibold",children:"A runtime error occurred"}),r.jsx("p",{className:"text-sm text-cc-muted mt-2",children:"Reload the page to recover. The error has been reported."}),r.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"mt-4 inline-flex items-center rounded-md bg-cc-primary px-3 py-1.5 text-sm text-white hover:bg-cc-primary-hover cursor-pointer",children:"Reload"})]})}):this.props.children}}EM();"serviceWorker"in navigator&&window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js").catch(e=>{console.warn("[SW] Registration failed:",e)})});V4.createRoot(document.getElementById("root")).render(r.jsx(w.StrictMode,{children:r.jsx(IH,{children:r.jsx($H,{})})}));export{Xi as _,FH as a,p0 as g,r as j,w as r};